1 // Copyright (C) 2007-2013 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 <PyInterp_Interp.h>
121 #include <SUIT_Desktop.h>
122 #include <SUIT_FileDlg.h>
123 #include <SUIT_MessageBox.h>
124 #include <SUIT_OverrideCursor.h>
125 #include <SUIT_ResourceMgr.h>
126 #include <SUIT_Session.h>
128 #include <QtxPopupMgr.h>
129 #include <QtxFontEdit.h>
131 #include <SALOME_ListIO.hxx>
132 #include <SALOME_ListIteratorOfListIO.hxx>
134 #ifndef DISABLE_PLOT2DVIEWER
135 #include <SPlot2d_ViewModel.h>
136 #include <SPlot2d_Histogram.h>
140 #include <SALOMEconfig.h>
141 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
142 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
143 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
146 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
147 #include <QApplication>
149 #include <QTextStream>
152 #include <boost/shared_ptr.hpp>
155 #include <vtkCallbackCommand.h>
156 #include <vtkCamera.h>
157 #include <vtkLookupTable.h>
158 #include <vtkPlane.h>
159 #include <vtkRenderer.h>
161 // SALOME KERNEL includes
162 #include <SALOMEDSClient_ClientFactory.hxx>
163 #include <SALOMEDSClient_IParameters.hxx>
164 #include <SALOMEDSClient_SComponent.hxx>
165 #include <SALOMEDSClient_StudyBuilder.hxx>
166 #include <SALOMEDS_Study.hxx>
167 #include <SALOMEDS_SObject.hxx>
170 #include <Standard_ErrorHandler.hxx>
171 #include <NCollection_DataMap.hxx>
173 #include <Basics_Utils.hxx>
175 //To disable automatic genericobj management, the following line should be commented.
176 //Otherwise, it should be uncommented.
177 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
178 #define WITHGENERICOBJ
180 // Below macro, when uncommented, switches on simplified (more performant) algorithm
181 // of auto-color picking up
182 #define SIMPLE_AUTOCOLOR
184 // REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1
185 #include <vtkMatplotlibMathTextUtilities.h>
188 // Creation of this class disables vtkMatplotlibMathTextUtilities
189 struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities
191 MPLMathText_Disabler()
193 vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
194 vtkMatplotlibMathTextUtilities::UNAVAILABLE;
202 //=============================================================
203 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
206 void ExportMeshToFile(int theCommandID);
208 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
210 void SetDisplayEntity(int theCommandID);
212 void Control( int theCommandID );
215 //=============================================================
216 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
220 std::string myExtension;
222 if ( theCommandID == 113 ) {
223 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
224 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
226 else if ( theCommandID == 112 ) {
227 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
229 else if ( theCommandID == 111 ) {
230 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
232 else if ( theCommandID == 115 ) {
233 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
235 else if ( theCommandID == 116 ) {
236 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
238 else if ( theCommandID == 117 ) {
239 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
240 filter.append( QObject::tr( "All files (*)" ) );
242 else if ( theCommandID == 118 ) {
243 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
244 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
247 QString anInitialPath = "";
248 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
249 anInitialPath = QDir::currentPath();
251 QStringList filenames;
252 bool toCreateGroups = true;
254 // if ( theCommandID == 118 ) { // GMF
255 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
256 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
257 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
258 // fd->setNameFilters( filter );
259 // fd->SetChecked( true );
261 // filenames << fd->selectedFile();
262 // toCreateGroups = fd->IsChecked();
268 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
271 QObject::tr( "SMESH_IMPORT_MESH" ) );
273 if ( filenames.count() > 0 ) {
274 SUIT_OverrideCursor wc;
275 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
278 QStringList anEntryList;
279 bool isEmpty = false;
280 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
281 QString filename = *it;
282 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
284 switch ( theCommandID ) {
287 // DAT format (currently unsupported)
288 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
289 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
295 aMeshes->length( 1 );
296 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
297 if ( aMeshes[0]->_is_nil() )
298 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
299 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
305 SMESH::DriverMED_ReadStatus res;
306 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
307 if ( res != SMESH::DRS_OK ) {
308 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
309 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
316 aMeshes->length( 1 );
317 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
318 if ( aMeshes[0]->_is_nil() ) {
319 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
320 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
327 SMESH::DriverMED_ReadStatus res;
328 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
329 if ( res != SMESH::DRS_OK ) {
330 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
331 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
338 SMESH::DriverMED_ReadStatus res;
339 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
340 if ( res != SMESH::DRS_OK ) {
341 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
342 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
349 SMESH::ComputeError_var res;
350 aMeshes->length( 1 );
351 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
354 if ( res->code != SMESH::DRS_OK ) {
355 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
356 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
357 if ( strlen( res->comment.in() ) > 0 ) {
358 errors.back() += ": ";
359 errors.back() += res->comment.in();
366 catch ( const SALOME::SALOME_Exception& S_ex ) {
367 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
368 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
371 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
372 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
374 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
375 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
376 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
377 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
378 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
380 anEntryList.append( aMeshSO->GetID().c_str() );
388 // update Object browser
389 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
391 // browse to the published meshes
392 if( LightApp_Application* anApp =
393 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
394 anApp->browseObjects( anEntryList );
396 // show Error message box if there were errors
397 if ( errors.count() > 0 ) {
398 SUIT_MessageBox::critical( SMESHGUI::desktop(),
399 QObject::tr( "SMESH_ERROR" ),
400 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
403 // show warning message box, if some imported mesh is empty
405 SUIT_MessageBox::warning( SMESHGUI::desktop(),
406 QObject::tr( "SMESH_WRN_WARNING" ),
407 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
412 //================================================================================
414 * \brief Export selected meshes or groups into a file
416 //================================================================================
418 void ExportMeshToFile( int theCommandID )
420 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
421 SALOME_ListIO selected;
423 aSel->selectedObjects( selected );
425 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
426 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
427 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
428 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
429 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
430 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
431 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
433 // actually, the following condition can't be met (added for insurance)
434 if( selected.Extent() == 0 ||
435 ( selected.Extent() > 1 && !isMED && !isSTL ))
438 // get mesh object from selection and check duplication of their names
439 bool hasDuplicatedMeshNames = false;
440 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
441 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
442 SALOME_ListIteratorOfListIO It( selected );
443 for( ; It.More(); It.Next() )
445 Handle(SALOME_InteractiveObject) anIObject = It.Value();
446 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
447 if ( aMeshItem->_is_nil() ) {
448 SUIT_MessageBox::warning( SMESHGUI::desktop(),
449 QObject::tr( "SMESH_WRN_WARNING" ),
450 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
454 QString aMeshName = anIObject->getName();
456 // check for name duplications
457 if ( !hasDuplicatedMeshNames )
458 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
459 if( aMeshName == (*aMeshIter).second ) {
460 hasDuplicatedMeshNames = true;
465 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
468 if( hasDuplicatedMeshNames && isMED ) {
469 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
470 QObject::tr("SMESH_WRN_WARNING"),
471 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
472 QObject::tr("SMESH_BUT_YES"),
473 QObject::tr("SMESH_BUT_NO"), 0, 1);
478 aMeshIter = aMeshList.begin();
479 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
480 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
481 QString aMeshName = (*aMeshIter).second;
483 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
485 // check for equal group names within each mesh
486 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
487 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
488 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
489 int aRet = SUIT_MessageBox::warning
490 (SMESHGUI::desktop(),
491 QObject::tr("SMESH_WRN_WARNING"),
492 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
493 QObject::tr("SMESH_BUT_YES"),
494 QObject::tr("SMESH_BUT_NO"), 0, 1);
501 // Warn the user about presence of not supported elements
503 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
507 notSupportedElemTypes.push_back( SMESH::Entity_0D );
508 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
513 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
514 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
515 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
516 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
517 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
518 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
519 notSupportedElemTypes.push_back( SMESH::Entity_0D );
520 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
525 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
526 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
527 notSupportedElemTypes.push_back( SMESH::Entity_0D );
528 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
533 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
534 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
539 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
540 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
541 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
542 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
543 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
544 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
545 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
550 notSupportedElemTypes.push_back( SMESH::Entity_0D );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
552 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
553 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
554 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
555 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
556 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
557 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
558 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
560 if ( ! notSupportedElemTypes.empty() )
562 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
563 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
564 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
565 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
567 if ( !presentNotSupported.empty() )
570 const char* typeMsg[SMESH::Entity_Last] = {
571 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
572 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
573 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
574 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
575 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
576 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
577 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
578 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
580 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
581 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
582 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
583 if ( iType != presentNotSupported.size() - 1 )
584 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
586 int aRet = SUIT_MessageBox::warning
587 (SMESHGUI::desktop(),
588 QObject::tr("SMESH_WRN_WARNING"),
589 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
590 QObject::tr("SMESH_BUT_YES"),
591 QObject::tr("SMESH_BUT_NO"), 0, 1);
596 // Get parameters of export operation
599 SMESH::MED_VERSION aFormat;
600 // Init the parameters with the default values
601 bool aIsASCII_STL = true;
602 bool toCreateGroups = false;
603 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
605 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
606 bool toOverwrite = true;
607 bool toFindOutDim = true;
609 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
610 QString anInitialPath = "";
611 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
612 anInitialPath = QDir::currentPath();
614 // Get a file name to write in and additional otions
615 if ( isUNV || isDAT || isGMF ) // Export w/o options
618 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
620 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
622 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
623 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
624 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
625 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
626 anInitialPath + QString("/") + aMeshName,
627 aFilter, aTitle, false);
629 else if ( isCGNS )// Export to CGNS
631 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
632 fd->setWindowTitle( aTitle );
633 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
634 if ( !anInitialPath.isEmpty() )
635 fd->setDirectory( anInitialPath );
636 fd->selectFile(aMeshName);
637 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
638 fd->setValidator( fv );
641 aFilename = fd->selectedFile();
642 toOverwrite = fv->isOverwrite();
646 else if ( isSTL ) // Export to STL
648 QMap<QString, int> aFilterMap;
649 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
650 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
653 QMap<QString, int>::const_iterator it = aFilterMap.begin();
654 for ( ; it != aFilterMap.end(); ++it )
655 filters.push_back( it.key() );
657 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
658 fd->setWindowTitle( aTitle );
659 fd->setNameFilters( filters );
660 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
661 if ( !anInitialPath.isEmpty() )
662 fd->setDirectory( anInitialPath );
663 fd->selectFile(aMeshName);
667 aFilename = fd->selectedFile();
668 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
673 else if ( isMED || isSAUV ) // Export to MED or SAUV
675 QMap<QString, SMESH::MED_VERSION> aFilterMap;
676 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
678 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
679 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
680 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
683 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
684 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
685 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
689 QString aDefaultFilter;
690 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
691 for ( ; it != aFilterMap.end(); ++it ) {
692 filters.push_back( it.key() );
693 if (it.value() == SMESH::MED_V2_2)
694 aDefaultFilter = it.key();
696 QStringList checkBoxes;
697 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
699 SalomeApp_CheckFileDlg* fd =
700 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
701 fd->setWindowTitle( aTitle );
702 fd->setNameFilters( filters );
703 fd->selectNameFilter( aDefaultFilter );
704 fd->SetChecked( toCreateGroups, 0 );
705 fd->SetChecked( toFindOutDim, 1 );
706 if ( !anInitialPath.isEmpty() )
707 fd->setDirectory( anInitialPath );
708 fd->selectFile(aMeshName);
710 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
711 fd->setValidator( fv );
716 aFilename = fd->selectedFile();
718 aFilename = QString::null;
721 aFormat = aFilterMap[fd->selectedNameFilter()];
722 toOverwrite = fv->isOverwrite();
724 if ( !aFilename.isEmpty() ) {
725 // med-2.1 does not support poly elements
726 if ( aFormat==SMESH::MED_V2_1 )
727 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
728 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
729 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
730 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
731 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
733 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
734 QObject::tr("SMESH_WRN_WARNING"),
735 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
736 QObject::tr("SMESH_BUT_YES"),
737 QObject::tr("SMESH_BUT_NO"), 0, 1);
745 // can't append to an existing using other format
746 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
747 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
748 if( !isVersionOk || aVersion != aFormat ) {
749 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
750 QObject::tr("SMESH_WRN_WARNING"),
751 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
752 QObject::tr("SMESH_BUT_YES"),
753 QObject::tr("SMESH_BUT_NO"), 0, 1);
760 QStringList aMeshNamesCollisionList;
761 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
762 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
763 QString anExistingMeshName( aMeshNames[ i ] );
764 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
765 QString anExportMeshName = (*aMeshIter).second;
766 if( anExportMeshName == anExistingMeshName ) {
767 aMeshNamesCollisionList.append( anExportMeshName );
772 if( !aMeshNamesCollisionList.isEmpty() ) {
773 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
774 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
775 QObject::tr("SMESH_WRN_WARNING"),
776 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
777 QObject::tr("SMESH_BUT_YES"),
778 QObject::tr("SMESH_BUT_NO"),
779 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
788 toCreateGroups = fd->IsChecked(0);
789 toFindOutDim = fd->IsChecked(1);
799 if ( !aFilename.isEmpty() ) {
800 // Check whether the file already exists and delete it if yes
801 QFile aFile( aFilename );
802 if ( aFile.exists() && toOverwrite )
804 SUIT_OverrideCursor wc;
807 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
808 // bool Renumber = false;
809 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
811 // Renumber= resMgr->booleanValue("renumbering");
813 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
814 // aMeshEditor->RenumberNodes();
815 // aMeshEditor->RenumberElements();
816 // if ( SMESHGUI::automaticUpdate() )
817 // SMESH::UpdateView();
821 aMeshIter = aMeshList.begin();
822 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
824 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
825 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
826 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
827 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
828 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
830 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
831 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
836 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
838 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
839 if( !aMeshItem->_is_nil() )
840 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
845 if ( aMeshOrGroup->_is_equivalent( aMesh ))
846 aMesh->ExportDAT( aFilename.toUtf8().data() );
848 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
852 if ( aMeshOrGroup->_is_equivalent( aMesh ))
853 aMesh->ExportUNV( aFilename.toUtf8().data() );
855 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
859 if ( aMeshOrGroup->_is_equivalent( aMesh ))
860 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
862 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
866 aMeshIter = aMeshList.begin();
867 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
869 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
870 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
871 aMeshItem->ExportCGNS( aMeshOrGroup,
872 aFilename.toUtf8().data(),
873 toOverwrite && aMeshIndex == 0 );
878 toCreateGroups = true;
879 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
882 catch (const SALOME::SALOME_Exception& S_ex){
884 SUIT_MessageBox::warning(SMESHGUI::desktop(),
885 QObject::tr("SMESH_WRN_WARNING"),
886 QObject::tr("SMESH_EXPORT_FAILED"));
892 inline void InverseEntityMode(unsigned int& theOutputMode,
893 unsigned int theMode)
895 bool anIsNotPresent = ~theOutputMode & theMode;
897 theOutputMode |= theMode;
899 theOutputMode &= ~theMode;
902 void SetDisplayEntity(int theCommandID){
903 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
904 SALOME_ListIO selected;
906 aSel->selectedObjects( selected );
908 if(selected.Extent() >= 1){
909 SALOME_ListIteratorOfListIO It( selected );
910 for( ; It.More(); It.Next()){
911 Handle(SALOME_InteractiveObject) IObject = It.Value();
912 if(IObject->hasEntry()){
913 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
914 unsigned int aMode = anActor->GetEntityMode();
915 switch(theCommandID){
917 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
920 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
923 InverseEntityMode(aMode,SMESH_Actor::eEdges);
926 InverseEntityMode(aMode,SMESH_Actor::eFaces);
929 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
932 aMode = SMESH_Actor::eAllEntity;
936 anActor->SetEntityMode(aMode);
945 SALOME_ListIO selected;
946 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
950 LightApp_SelectionMgr* aSel = app->selectionMgr();
951 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
952 if( !aSel || !appStudy )
955 aSel->selectedObjects( selected );
956 if( selected.IsEmpty() )
959 Handle(SALOME_InteractiveObject) anIObject = selected.First();
961 _PTR(Study) aStudy = appStudy->studyDS();
962 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
963 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
964 if( aMainObject->_is_nil() )
967 SUIT_OverrideCursor wc;
969 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
971 QList<SALOMEDS::Color> aReservedColors;
973 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
974 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
976 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
977 //SALOMEDS::Color aColor = aGroupObject->GetColor();
979 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
980 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
981 #else // old algorithm for auto-colors
982 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
983 aReservedColors.append( aColor );
984 #endif // SIMPLE_AUTOCOLOR
985 aGroupObject->SetColor( aColor );
987 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
991 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
992 switch ( aGroupObject->GetType ()) {
994 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
996 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
998 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1000 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1002 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1003 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1006 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1007 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1013 SMESH::RepaintCurrentView();
1016 void OverallMeshQuality() {
1017 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1018 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1019 SALOME_ListIO selected;
1021 aSel->selectedObjects( selected );
1023 if ( selected.IsEmpty() ) return;
1024 SALOME_ListIteratorOfListIO It( selected );
1025 for ( ; It.More(); It.Next() ) {
1026 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1027 ctrlDlg->showInfo( It.Value() );
1032 QString functorToString( SMESH::Controls::FunctorPtr f )
1034 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1035 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1036 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1037 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1038 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1039 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1040 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1041 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1042 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1043 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1044 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1045 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1046 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1047 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1048 type = QObject::tr( "WARP_ELEMENTS" );
1049 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1050 type = QObject::tr( "TAPER_ELEMENTS" );
1051 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1052 type = QObject::tr( "SKEW_ELEMENTS" );
1053 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1054 type = QObject::tr( "AREA_ELEMENTS" );
1055 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1056 type = QObject::tr( "LENGTH_EDGES" );
1057 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1058 type = QObject::tr( "LENGTH2D_EDGES" );
1059 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1060 type = QObject::tr( "MULTI_BORDERS" );
1061 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1062 type = QObject::tr( "MULTI2D_BORDERS" );
1063 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1064 type = QObject::tr( "FREE_NODES" );
1065 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1066 type = QObject::tr( "FREE_EDGES" );
1067 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1068 type = QObject::tr( "FREE_BORDERS" );
1069 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1070 type = QObject::tr( "FREE_FACES" );
1071 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1072 type = QObject::tr( "BARE_BORDER_VOLUME" );
1073 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1074 type = QObject::tr( "BARE_BORDER_FACE" );
1075 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1076 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1077 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1078 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1079 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1080 type = QObject::tr( "EQUAL_NODE" );
1081 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1082 type = QObject::tr( "EQUAL_EDGE" );
1083 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1084 type = QObject::tr( "EQUAL_FACE" );
1085 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1086 type = QObject::tr( "EQUAL_VOLUME" );
1090 void SaveDistribution()
1092 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1093 SALOME_ListIO selected;
1095 aSel->selectedObjects( selected );
1097 if ( selected.Extent() == 1 ) {
1098 Handle(SALOME_InteractiveObject) anIO = selected.First();
1099 if ( anIO->hasEntry() ) {
1100 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1101 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1102 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1103 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1104 if ( aScalarBarActor && aFunctor ) {
1105 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1107 std::vector<int> elements;
1108 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1109 if ( mesh->_is_nil() ) {
1110 SMESH::SMESH_IDSource_var idSource =
1111 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1112 if ( !idSource->_is_nil() )
1114 SMESH::long_array_var ids = idSource->GetIDs();
1115 elements.resize( ids->length() );
1116 for ( unsigned i = 0; i < elements.size(); ++i )
1117 elements[i] = ids[i];
1120 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1121 vtkLookupTable* lookupTable =
1122 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1123 double * minmax = lookupTable->GetRange();
1124 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1125 std::vector<int> nbEvents;
1126 std::vector<double> funValues;
1127 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1128 QString anInitialPath = "";
1129 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1130 anInitialPath = QDir::currentPath();
1131 QString aMeshName = anIO->getName();
1133 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1134 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1135 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1136 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1137 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1140 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1142 if ( !aFilename.isEmpty() ) {
1143 QFile f( aFilename );
1144 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1145 QTextStream out( &f );
1146 out << "# Mesh: " << aMeshName << endl;
1147 out << "# Control: " << functorToString( aFunctor ) << endl;
1149 out.setFieldWidth( 10 );
1150 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1151 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1162 void ShowDistribution() {
1163 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1164 SALOME_ListIO selected;
1166 aSel->selectedObjects( selected );
1168 if ( selected.Extent() == 1 ) {
1169 Handle(SALOME_InteractiveObject) anIO = selected.First();
1170 if ( anIO->hasEntry() ) {
1171 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1172 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1173 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1174 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1180 #ifndef DISABLE_PLOT2DVIEWER
1181 void PlotDistribution() {
1182 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1186 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1187 SALOME_ListIO selected;
1189 aSel->selectedObjects( selected );
1191 if ( selected.Extent() == 1 ) {
1192 Handle(SALOME_InteractiveObject) anIO = selected.First();
1193 if ( anIO->hasEntry() ) {
1194 //Find Actor by entry before getting Plot2d viewer,
1195 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1196 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1198 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1203 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1207 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1211 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1212 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1213 QString functorName = functorToString( anActor->GetFunctor());
1214 QString aHistogramName("%1 : %2");
1215 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1216 aHistogram->setName(aHistogramName);
1217 aHistogram->setHorTitle(functorName);
1218 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1219 aPlot->displayObject(aHistogram, true);
1224 #endif //DISABLE_PLOT2DVIEWER
1226 void DisableAutoColor(){
1227 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1228 SALOME_ListIO selected;
1230 aSel->selectedObjects( selected );
1232 if(selected.Extent()){
1233 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1234 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1235 if ( !aMesh->_is_nil() ) {
1236 aMesh->SetAutoColor( false );
1241 void sortChildren(){
1242 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1243 SALOME_ListIO selected;
1245 aSel->selectedObjects( selected );
1247 if(selected.Extent()){
1248 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1249 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1250 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1252 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1253 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1260 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1262 SALOME_ListIO selected;
1263 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1267 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1268 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1269 if( !aSel || !appStudy )
1272 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1273 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1274 aModule->EmitSignalDeactivateDialog();
1275 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1276 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1281 _PTR(Study) aStudy = appStudy->studyDS();
1283 aSel->selectedObjects( selected );
1285 if(selected.Extent() >= 1){
1286 switch(theCommandID){
1288 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1289 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1294 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1295 QColor orientationColor, outlineColor, volumeColor;
1296 int deltaF = 0, deltaV = 0;
1300 int outlineWidth = 1;
1301 double shrinkCoef = 0.0;
1302 double orientationScale = 0.0;
1303 bool orientation3d = false;
1304 VTK::MarkerType markerType = VTK::MT_NONE;
1305 VTK::MarkerScale markerScale = VTK::MS_NONE;
1307 bool hasNodes = false;
1308 int presentEntities = 0;
1309 bool firstTime = true;
1311 SALOME_ListIteratorOfListIO It( selected );
1312 for ( ; It.More(); It.Next() ) {
1313 Handle(SALOME_InteractiveObject) IObject = It.Value();
1314 if ( !IObject->hasEntry() ) continue;
1315 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1316 if ( !anActor || !anActor->GetObject() ) continue;
1319 // nodes: color, marker
1320 anActor->GetNodeColor( color[0], color[1], color[2] );
1321 nodeColor.setRgbF( color[0], color[1], color[2] );
1322 markerType = anActor->GetMarkerType();
1323 markerScale = anActor->GetMarkerScale();
1324 markerId = anActor->GetMarkerTexture();
1325 // edges: color, width
1326 anActor->GetEdgeColor( color[0], color[1], color[2] );
1327 edgeColor.setRgbF( color[0], color[1], color[2] );
1328 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1329 // faces: front color, back color (delta)
1330 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1331 faceColor.setRgbF( color[0], color[1], color[2] );
1332 // faces: front color, back color (delta)
1333 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1334 volumeColor.setRgbF( color[0], color[1], color[2] );
1335 // 0d elements: color, size
1336 anActor->Get0DColor( color[0], color[1], color[2] );
1337 elem0dColor.setRgbF( color[0], color[1], color[2] );
1338 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1339 // balls: color, size
1340 anActor->GetBallColor( color[0], color[1], color[2] );
1341 ballColor.setRgbF( color[0], color[1], color[2] );
1342 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1344 anActor->GetOutlineColor( color[0], color[1], color[2] );
1345 outlineColor.setRgbF( color[0], color[1], color[2] );
1346 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1347 // orientation vectors: color, scale, 3d flag
1348 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1349 orientationColor.setRgbF( color[0], color[1], color[2] );
1350 orientationScale = anActor->GetFacesOrientationScale();
1351 orientation3d = anActor->GetFacesOrientation3DVectors();
1353 shrinkCoef = anActor->GetShrinkFactor();
1356 firstTime = false; // we only take properties from first object (for performance reasons)
1359 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1360 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1361 presentEntities = presentEntities | SMESH_Actor::eEdges;
1362 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1363 presentEntities = presentEntities | SMESH_Actor::eFaces;
1364 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1365 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1366 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1367 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1368 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1369 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1371 // as we know that all types of elements are present, we can exit the loop
1372 if ( presentEntities == SMESH_Actor::eAllEntity )
1376 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1377 // nodes: color, marker
1378 dlg.setNodeColor( nodeColor );
1379 if( markerType != VTK::MT_USER )
1380 dlg.setNodeMarker( markerType, markerScale );
1382 dlg.setNodeCustomMarker( markerId );
1383 // edges: color, line width
1384 dlg.setEdgeColor( edgeColor );
1385 dlg.setEdgeWidth( edgeWidth );
1386 // faces: front color, back color
1387 dlg.setFaceColor( faceColor, deltaF );
1388 // volumes: normal color, reversed color
1389 dlg.setVolumeColor( volumeColor, deltaV );
1390 // outlines: color, line width
1391 dlg.setOutlineColor( outlineColor );
1392 dlg.setOutlineWidth( outlineWidth );
1393 // 0d elements: color, size
1394 dlg.setElem0dColor( elem0dColor );
1395 dlg.setElem0dSize( elem0dSize );
1396 // balls: color, size
1397 dlg.setBallColor( ballColor );
1398 dlg.setBallSize( ballSize );
1399 // orientation: color, scale, 3d flag
1400 dlg.setOrientationColor( orientationColor );
1401 dlg.setOrientationSize( int( orientationScale * 100. ) );
1402 dlg.setOrientation3d( orientation3d );
1403 // shrink: scale factor
1404 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1405 // hide unused controls
1406 dlg.showControls( presentEntities, hasNodes );
1409 nodeColor = dlg.nodeColor();
1410 markerType = dlg.nodeMarkerType();
1411 markerScale = dlg.nodeMarkerScale();
1412 markerId = dlg.nodeMarkerId();
1413 edgeColor = dlg.edgeColor();
1414 edgeWidth = dlg.edgeWidth();
1415 faceColor = dlg.faceColor();
1416 deltaF = dlg.faceColorDelta();
1417 volumeColor = dlg.volumeColor();
1418 deltaV = dlg.volumeColorDelta();
1419 outlineColor = dlg.outlineColor();
1420 outlineWidth = dlg.outlineWidth();
1421 elem0dColor = dlg.elem0dColor();
1422 elem0dSize = dlg.elem0dSize();
1423 ballColor = dlg.ballColor();
1424 ballSize = dlg.ballSize();
1425 orientationColor = dlg.orientationColor();
1426 orientationScale = dlg.orientationSize() / 100.;
1427 orientation3d = dlg.orientation3d();
1428 shrinkCoef = dlg.shrinkCoef() / 100.;
1430 // store point markers map that might be changed by the user
1431 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1433 // set properties from dialog box to the presentations
1434 SALOME_ListIteratorOfListIO It( selected );
1435 for ( ; It.More(); It.Next() ) {
1436 Handle(SALOME_InteractiveObject) IObject = It.Value();
1437 if ( !IObject->hasEntry() ) continue;
1438 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1439 if ( !anActor ) continue;
1441 // nodes: color, marker
1442 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1443 if ( markerType != VTK::MT_USER ) {
1444 anActor->SetMarkerStd( markerType, markerScale );
1447 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1448 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1449 if ( iter != markerMap.end() )
1450 anActor->SetMarkerTexture( markerId, iter->second.second );
1452 // volumes: normal color, reversed color (delta)
1453 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1454 // faces: front color, back color (delta)
1455 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1456 // edges: color, width
1457 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1458 anActor->SetLineWidth( edgeWidth );
1460 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1461 anActor->SetOutlineWidth( outlineWidth );
1462 // 0D elements: color, size
1463 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1464 anActor->Set0DSize( elem0dSize );
1465 // balls: color, size
1466 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1467 anActor->SetBallSize( ballSize );
1468 // orientation: color, scale, 3d flag
1469 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1470 anActor->SetFacesOrientationScale( orientationScale );
1471 anActor->SetFacesOrientation3DVectors( orientation3d );
1473 anActor->SetShrinkFactor( shrinkCoef );
1475 // for groups, set also proper color
1476 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1477 if ( !aGroupObject->_is_nil() ) {
1478 SMESH::ElementType anElementType = aGroupObject->GetType();
1480 switch( anElementType ) {
1482 aColor = nodeColor; break;
1484 aColor = edgeColor; break;
1486 aColor = faceColor; break;
1488 aColor = volumeColor; break;
1490 aColor = elem0dColor; break;
1492 aColor = ballColor; break;
1496 if ( aColor.isValid() ) {
1497 SALOMEDS::Color aGroupColor;
1498 aGroupColor.R = aColor.redF();
1499 aGroupColor.G = aColor.greenF();
1500 aGroupColor.B = aColor.blueF();
1501 aGroupObject->SetColor( aGroupColor );
1503 } // if ( !aGroupObject->_is_nil() )
1504 } // for ( ; It.More(); It.Next() )
1505 SMESH::RepaintCurrentView();
1506 } // if ( dlg.exec() )
1509 } // switch(theCommandID)
1510 SALOME_ListIteratorOfListIO It( selected );
1511 for( ; It.More(); It.Next()){
1512 Handle(SALOME_InteractiveObject) IObject = It.Value();
1513 if(IObject->hasEntry()){
1514 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1515 switch(theCommandID){
1517 anActor->SetRepresentation(SMESH_Actor::eEdge);
1520 anActor->SetRepresentation(SMESH_Actor::eSurface);
1523 if(anActor->IsShrunk())
1524 anActor->UnShrink();
1526 anActor->SetShrink();
1529 anActor->SetRepresentation(SMESH_Actor::ePoint);
1532 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1533 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1536 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1537 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1543 SMESH::RepaintCurrentView();
1547 void Control( int theCommandID )
1549 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1550 SALOME_ListIO selected;
1552 aSel->selectedObjects( selected );
1554 if( !selected.IsEmpty() ){
1555 Handle(SALOME_InteractiveObject) anIO = selected.First();
1557 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1558 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1559 switch ( theCommandID ){
1561 aControl = SMESH_Actor::eLength;
1564 aControl = SMESH_Actor::eLength2D;
1567 aControl = SMESH_Actor::eFreeEdges;
1570 aControl = SMESH_Actor::eFreeBorders;
1573 aControl = SMESH_Actor::eMultiConnection;
1576 aControl = SMESH_Actor::eFreeNodes;
1579 aControl = SMESH_Actor::eMultiConnection2D;
1582 aControl = SMESH_Actor::eArea;
1585 aControl = SMESH_Actor::eTaper;
1588 aControl = SMESH_Actor::eAspectRatio;
1591 aControl = SMESH_Actor::eAspectRatio3D;
1594 aControl = SMESH_Actor::eMinimumAngle;
1597 aControl = SMESH_Actor::eWarping;
1600 aControl = SMESH_Actor::eSkew;
1603 aControl = SMESH_Actor::eVolume3D;
1606 aControl = SMESH_Actor::eFreeFaces;
1609 aControl = SMESH_Actor::eMaxElementLength2D;
1612 aControl = SMESH_Actor::eMaxElementLength3D;
1615 aControl = SMESH_Actor::eBareBorderVolume;
1618 aControl = SMESH_Actor::eBareBorderFace;
1621 aControl = SMESH_Actor::eOverConstrainedVolume;
1624 aControl = SMESH_Actor::eOverConstrainedFace;
1627 aControl = SMESH_Actor::eCoincidentNodes;
1630 aControl = SMESH_Actor::eCoincidentElems1D;
1633 aControl = SMESH_Actor:: eCoincidentElems2D;
1636 aControl = SMESH_Actor::eCoincidentElems3D;
1640 anActor->SetControlMode(aControl);
1641 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1642 SMESH::RepaintCurrentView();
1643 #ifndef DISABLE_PLOT2DVIEWER
1644 if(anActor->GetPlot2Histogram()) {
1645 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1646 QString functorName = functorToString( anActor->GetFunctor());
1647 QString aHistogramName("%1 : %2");
1648 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1649 aHistogram->setName(aHistogramName);
1650 aHistogram->setHorTitle(functorName);
1651 SMESH::ProcessIn2DViewers(anActor);
1660 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1661 SMESH::MeshObjectType theType,
1662 const QString theInTypeName,
1663 QString & theOutTypeName)
1665 SMESH_TypeFilter aTypeFilter( theType );
1667 if( !theIO.IsNull() )
1669 entry = theIO->getEntry();
1670 LightApp_DataOwner owner( entry );
1671 if ( aTypeFilter.isOk( &owner )) {
1672 theOutTypeName = theInTypeName;
1680 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1682 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1683 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1685 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1686 CORBA::String_var anID = aSComp->GetID().c_str();
1687 if (!strcmp(anID.in(),theIO->getEntry()))
1693 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1694 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1695 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1696 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1697 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1705 QString CheckHomogeneousSelection()
1707 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1708 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1709 SALOME_ListIO selected;
1711 aSel->selectedObjects( selected );
1713 QString RefType = CheckTypeObject(selected.First());
1714 SALOME_ListIteratorOfListIO It(selected);
1715 for ( ; It.More(); It.Next())
1717 Handle(SALOME_InteractiveObject) IObject = It.Value();
1718 QString Type = CheckTypeObject(IObject);
1719 if (Type.compare(RefType) != 0)
1720 return "Heterogeneous Selection";
1728 void SMESHGUI::OnEditDelete()
1730 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1731 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1732 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1734 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1735 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1736 _PTR(GenericAttribute) anAttr;
1737 _PTR(AttributeIOR) anIOR;
1739 int objectCount = 0;
1741 QString aParentComponent = QString::null;
1742 Handle(SALOME_InteractiveObject) anIO;
1743 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1745 anIO = anIt.Value();
1746 QString cur = anIO->getComponentDataType();
1747 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1749 // check if object is reference
1750 _PTR(SObject) aRefSObj;
1751 aNameList.append("\n - ");
1752 if ( aSO->ReferencedObject( aRefSObj ) ) {
1753 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1754 aNameList.append( aRefName );
1755 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1758 aNameList.append(anIO->getName());
1762 if( aParentComponent.isNull() )
1763 aParentComponent = cur;
1764 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1765 aParentComponent = "";
1768 if ( objectCount == 0 )
1769 return; // No Valid Objects Selected
1771 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1772 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1773 QObject::tr("ERR_ERROR"),
1774 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1777 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1778 if (SUIT_MessageBox::warning
1779 (SMESHGUI::desktop(),
1780 QObject::tr("SMESH_WRN_WARNING"),
1781 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1782 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1783 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1786 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1788 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1789 // then treat them all starting from the deepest objects (at list back)
1790 std::list< _PTR(SObject) > listSO;
1791 SALOME_ListIteratorOfListIO It(selected);
1792 for( ; It.More(); It.Next()) // loop on selected IO's
1794 Handle(SALOME_InteractiveObject) IObject = It.Value();
1795 if(IObject->hasEntry()) {
1796 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1798 // disable removal of "SMESH" component object
1799 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1801 if ( engineIOR() == anIOR->Value().c_str() )
1804 //Check the referenced object
1805 _PTR(SObject) aRefSObject;
1806 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1807 aSO = aRefSObject; // Delete main Object instead of reference
1809 listSO.push_back( aSO );
1810 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1811 for ( ; itSO != listSO.end(); ++itSO ) {
1812 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1813 for (it->InitEx(false); it->More(); it->Next())
1814 listSO.push_back( it->Value() );
1818 // Check if none of objects to delete is referred from outside
1819 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1820 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1822 _PTR(SObject) SO = *ritSO;
1823 if ( !SO ) continue;
1824 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1825 for (size_t i = 0; i < aReferences.size(); i++) {
1826 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1827 std::string type = aComponent->ComponentDataType();
1828 if ( type != "SMESH" )
1830 SUIT_MessageBox::warning( anApp->desktop(),
1831 QObject::tr("WRN_WARNING"),
1832 QObject::tr("DEP_OBJECT") );
1833 return; // outside SMESH, there is an object depending on a SMESH object
1838 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1839 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1841 Handle(SALOME_InteractiveObject) IObject = It.Value();
1842 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1843 if ( !mesh->_is_nil() )
1847 // Treat SO's in the list starting from the back
1848 aStudyBuilder->NewCommand(); // There is a transaction
1849 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1851 _PTR(SObject) SO = *ritSO;
1852 if ( !SO ) continue;
1853 std::string anEntry = SO->GetID();
1855 /** Erase graphical object and remove all its data **/
1856 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1857 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1859 /** Remove an object from data structures **/
1860 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1861 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1862 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1863 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1864 aMesh->RemoveGroup( aGroup );
1866 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1867 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1868 aMesh->RemoveSubMesh( aSubMesh );
1870 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1872 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1875 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1876 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1877 QString objType = CheckTypeObject(IObject);
1878 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1879 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1880 aStudyBuilder->RemoveObjectWithChildren( SO );
1882 else {// default action: remove SObject from the study
1883 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1884 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1886 aStudyBuilder->RemoveObjectWithChildren( SO );
1890 } /* listSO back loop */
1892 aStudyBuilder->CommitCommand();
1894 /* Clear any previous selection */
1896 aSel->setSelectedObjects( l1 );
1898 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1902 SMESHGUI_EXPORT CAM_Module* createModule()
1904 return new SMESHGUI();
1907 SMESHGUI_EXPORT char* getModuleVersion() {
1908 return (char*)SMESH_VERSION_STR;
1912 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1914 //=============================================================================
1918 //=============================================================================
1919 SMESHGUI::SMESHGUI() :
1920 SalomeApp_Module( "SMESH" )
1922 if ( CORBA::is_nil( myComponentSMESH ) )
1924 CORBA::Boolean anIsEmbeddedMode;
1925 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1926 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1928 // 0019923: EDF 765 SMESH : default values of hypothesis
1929 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1930 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1931 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1932 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1933 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1935 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1936 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1937 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1939 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1940 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1944 myActiveDialogBox = 0;
1945 myFilterLibraryDlg = 0;
1949 myEventCallbackCommand = vtkCallbackCommand::New();
1950 myEventCallbackCommand->Delete();
1951 myEventCallbackCommand->SetClientData( this );
1952 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1955 /* load resources for all available meshers */
1956 SMESH::InitAvailableHypotheses();
1958 MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities
1961 //=============================================================================
1965 //=============================================================================
1966 SMESHGUI::~SMESHGUI()
1970 //=============================================================================
1974 //=============================================================================
1975 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1977 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1979 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1984 //=============================================================================
1988 //=============================================================================
1989 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1991 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1995 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1996 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1997 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1998 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1999 return autoUpdate && !exceeded;
2002 //=============================================================================
2006 //=============================================================================
2007 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2008 int* entities, bool* limitExceeded, int* hidden )
2010 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2014 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2015 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2016 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2018 long requestedSize = theMesh->NbElements();
2020 *entities = SMESH_Actor::eAllEntity;
2023 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2025 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2027 if ( incrementalLimit ) {
2028 long nbOdElems = theMesh->Nb0DElements();
2029 long nbEdges = theMesh->NbEdges();
2030 long nbFaces = theMesh->NbFaces();
2031 long nbVolumes = theMesh->NbVolumes();
2032 long nbBalls = theMesh->NbBalls();
2035 if ( nbOdElems > 0 ) {
2036 if ( total + nbOdElems > updateLimit ) {
2037 *entities = *entities & ~SMESH_Actor::e0DElements;
2038 *hidden = *hidden | SMESH_Actor::e0DElements;
2045 if ( nbEdges > 0 ) {
2046 if ( total + nbEdges > updateLimit ) {
2047 *entities = *entities & ~SMESH_Actor::eEdges;
2048 *hidden = *hidden | SMESH_Actor::eEdges;
2055 if ( nbFaces > 0 ) {
2056 if ( total + nbFaces > updateLimit ) {
2057 *entities = *entities & ~SMESH_Actor::eFaces;
2058 *hidden = *hidden | SMESH_Actor::eFaces;
2065 if ( nbVolumes > 0 ) {
2066 if ( total + nbVolumes > updateLimit ) {
2067 *entities = *entities & ~SMESH_Actor::eVolumes;
2068 *hidden = *hidden | SMESH_Actor::eVolumes;
2075 if ( nbBalls > 0 ) {
2076 if ( total + nbBalls > updateLimit ) {
2077 *entities = *entities & ~SMESH_Actor::eBallElem;
2078 *hidden = *hidden | SMESH_Actor::eBallElem;
2086 return autoUpdate && !exceeded;
2089 //=============================================================================
2093 //=============================================================================
2094 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2096 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2099 //=============================================================================
2103 //=============================================================================
2104 SMESHGUI* SMESHGUI::GetSMESHGUI()
2106 SMESHGUI* smeshMod = 0;
2107 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2110 CAM_Module* module = app->module( "Mesh" );
2111 smeshMod = dynamic_cast<SMESHGUI*>( module );
2114 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2116 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2119 _PTR(Study) aStudy = study->studyDS();
2121 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2130 Standard_EXPORT SMESHGUI* GetComponentGUI()
2132 return SMESHGUI::GetSMESHGUI();
2136 //=============================================================================
2140 //=============================================================================
2141 void SMESHGUI::SetState(int aState)
2146 //=============================================================================
2150 //=============================================================================
2151 void SMESHGUI::ResetState()
2156 //=============================================================================
2160 //=============================================================================
2161 void SMESHGUI::EmitSignalDeactivateDialog()
2163 emit SignalDeactivateActiveDialog();
2166 //=============================================================================
2170 //=============================================================================
2171 void SMESHGUI::EmitSignalStudyFrameChanged()
2173 emit SignalStudyFrameChanged();
2176 //=============================================================================
2180 //=============================================================================
2181 void SMESHGUI::EmitSignalCloseAllDialogs()
2183 emit SignalCloseAllDialogs();
2186 //=============================================================================
2190 //=============================================================================
2191 void SMESHGUI::EmitSignalVisibilityChanged()
2193 emit SignalVisibilityChanged();
2196 //=============================================================================
2200 //=============================================================================
2201 QDialog *SMESHGUI::GetActiveDialogBox()
2203 return myActiveDialogBox;
2206 //=============================================================================
2210 //=============================================================================
2211 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2213 myActiveDialogBox = (QDialog *) aDlg;
2217 //=============================================================================
2221 //=============================================================================
2222 SUIT_Desktop* SMESHGUI::desktop()
2224 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2226 return app->desktop();
2231 //=============================================================================
2235 //=============================================================================
2236 SalomeApp_Study* SMESHGUI::activeStudy()
2238 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2240 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2245 //=============================================================================
2249 //=============================================================================
2250 void SMESHGUI::Modified( bool theIsUpdateActions )
2252 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2253 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2254 appStudy->Modified();
2255 if( theIsUpdateActions )
2256 app->updateActions();
2261 //=============================================================================
2265 //=============================================================================
2266 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2268 /* Here the position is on the bottom right corner - 10 */
2269 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2271 SUIT_Desktop *PP = desktop();
2272 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2273 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2277 //=============================================================================
2281 //=============================================================================
2282 static int isStudyLocked(_PTR(Study) theStudy){
2283 return theStudy->GetProperties()->IsLocked();
2286 static bool checkLock(_PTR(Study) theStudy) {
2287 if (isStudyLocked(theStudy)) {
2288 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2289 QObject::tr("WRN_WARNING"),
2290 QObject::tr("WRN_STUDY_LOCKED") );
2296 //=======================================================================
2297 //function : CheckActiveStudyLocked
2299 //=======================================================================
2301 bool SMESHGUI::isActiveStudyLocked()
2303 _PTR(Study) aStudy = activeStudy()->studyDS();
2304 return checkLock( aStudy );
2307 //=============================================================================
2311 //=============================================================================
2312 bool SMESHGUI::OnGUIEvent( int theCommandID )
2314 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2318 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2319 SUIT_ResourceMgr* mgr = resourceMgr();
2323 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2324 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2327 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2328 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2330 //QAction* act = action( theCommandID );
2332 switch (theCommandID) {
2334 if(checkLock(aStudy)) break;
2346 if(checkLock(aStudy)) break;
2347 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2351 case 150: //MED FILE INFORMATION
2353 SALOME_ListIO selected;
2354 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2356 aSel->selectedObjects( selected );
2357 if( selected.Extent() )
2359 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2360 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2361 if ( !aMesh->_is_nil() )
2363 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2370 case 122: // EXPORT MED
2385 ::ExportMeshToFile(theCommandID);
2389 case 200: // SCALAR BAR
2391 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2392 SALOME_ListIO selected;
2394 aSel->selectedObjects( selected );
2396 if( selected.Extent() ) {
2397 Handle(SALOME_InteractiveObject) anIO = selected.First();
2398 if( anIO->hasEntry() ) {
2399 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2400 anActor->SetControlMode( SMESH_Actor::eNone );
2401 #ifndef DISABLE_PLOT2DVIEWER
2402 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2411 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2416 // dump control distribution data to the text file
2417 ::SaveDistribution();
2423 // show/ distribution
2424 ::ShowDistribution();
2428 #ifndef DISABLE_PLOT2DVIEWER
2431 // plot distribution
2432 ::PlotDistribution();
2443 ::DisableAutoColor();
2446 case 1134: // Clipping
2447 case 1133: // Tranparency
2448 case 1132: // Display preferences (colors, shrink size, line width, ...)
2455 ::SetDisplayMode(theCommandID, myMarkerMap);
2458 //2D quadratic representation
2461 ::SetDisplayMode(theCommandID, myMarkerMap);
2465 case 216: // 0D elements
2468 case 219: // Volumes
2469 case 220: // All Entity
2471 ::SetDisplayEntity(theCommandID);
2474 case 221: // Orientation of faces
2476 LightApp_SelectionMgr* mgr = selectionMgr();
2477 SALOME_ListIO selected; mgr->selectedObjects( selected );
2479 SALOME_ListIteratorOfListIO it(selected);
2480 for( ; it.More(); it.Next()) {
2481 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2482 if(anIObject->hasEntry()) {
2483 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2484 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2493 if(checkLock(aStudy)) break;
2494 SUIT_OverrideCursor wc;
2496 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2499 SMESH::UpdateView();
2501 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2502 SMESH::OnVisuException();
2504 catch (...) { // PAL16774 (Crash after display of many groups)
2505 SMESH::OnVisuException();
2509 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2510 aSel->selectedObjects( l );
2511 aSel->setSelectedObjects( l );
2516 case 301: // DISPLAY
2517 case 302: // DISPLAY ONLY
2519 SMESH::EDisplaing anAction;
2520 switch (theCommandID) {
2521 case 300: anAction = SMESH::eErase; break;
2522 case 301: anAction = SMESH::eDisplay; break;
2523 case 302: anAction = SMESH::eDisplayOnly; break;
2526 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2527 SALOME_ListIO sel_objects, to_process;
2529 aSel->selectedObjects( sel_objects );
2531 if( theCommandID==302 )
2533 MESSAGE("anAction = SMESH::eDisplayOnly");
2534 startOperation( myEraseAll );
2537 extractContainers( sel_objects, to_process );
2540 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2544 SALOME_ListIteratorOfListIO It( to_process );
2545 for ( ; It.More(); It.Next()) {
2547 Handle(SALOME_InteractiveObject) IOS = It.Value();
2548 if (IOS->hasEntry()) {
2550 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2551 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2552 break; // PAL16774 (Crash after display of many groups)
2554 if (anAction == SMESH::eDisplayOnly)
2556 MESSAGE("anAction = SMESH::eDisplayOnly");
2557 anAction = SMESH::eDisplay;
2563 // PAL13338 + PAL15161 -->
2564 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2565 MESSAGE("anAction = SMESH::eDisplayOnly");
2566 SMESH::UpdateView();
2567 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2569 // PAL13338 + PAL15161 <--
2571 catch (...) { // PAL16774 (Crash after display of many groups)
2572 SMESH::OnVisuException();
2575 if (anAction == SMESH::eErase) {
2576 MESSAGE("anAction == SMESH::eErase");
2578 aSel->setSelectedObjects( l1 );
2581 aSel->setSelectedObjects( to_process );
2588 if(checkLock(aStudy)) break;
2591 EmitSignalDeactivateDialog();
2593 ( new SMESHGUI_NodesDlg( this ) )->show();
2596 SUIT_MessageBox::warning(desktop(),
2597 tr("SMESH_WRN_WARNING"),
2598 tr("SMESH_WRN_VIEWER_VTK"));
2603 case 2151: // FILTER
2607 EmitSignalDeactivateDialog();
2608 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2613 case 701: // COMPUTE MESH
2614 case 711: // PRECOMPUTE MESH
2615 case 712: // EVALUATE MESH
2616 case 713: // MESH ORDER
2617 case 702: // Create mesh
2618 case 703: // Create sub-mesh
2619 case 704: // Edit mesh/sub-mesh
2620 startOperation( theCommandID );
2622 case 705: // copy mesh
2624 if (checkLock(aStudy)) break;
2625 EmitSignalDeactivateDialog();
2626 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2629 case 710: // Build compound mesh
2631 if (checkLock(aStudy)) break;
2632 EmitSignalDeactivateDialog();
2633 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2637 case 407: // DIAGONAL INVERSION
2638 case 408: // Delete diagonal
2642 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2643 tr( "NOT_A_VTK_VIEWER" ) );
2647 if ( checkLock( aStudy ) )
2650 /*Standard_Boolean aRes;
2651 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2652 if ( aMesh->_is_nil() )
2654 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2655 tr( "SMESH_BAD_SELECTION" ) );
2659 EmitSignalDeactivateDialog();
2660 if ( theCommandID == 407 )
2661 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2663 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2666 case 409: // Change orientation
2667 case 410: // Union of triangles
2668 case 411: // Cutting of quadrangles
2669 case 419: // Splitting volumes into tetrahedra
2673 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2674 tr( "NOT_A_VTK_VIEWER" ) );
2678 if ( checkLock( aStudy ) )
2681 EmitSignalDeactivateDialog();
2682 SMESHGUI_MultiEditDlg* aDlg = NULL;
2683 if ( theCommandID == 409 )
2684 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2685 else if ( theCommandID == 410 )
2686 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2687 else if ( theCommandID == 419 )
2688 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2690 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2695 case 412: // Smoothing
2697 if(checkLock(aStudy)) break;
2699 EmitSignalDeactivateDialog();
2700 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2703 SUIT_MessageBox::warning(desktop(),
2704 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2708 case 413: // Extrusion
2710 if (checkLock(aStudy)) break;
2712 EmitSignalDeactivateDialog();
2713 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2715 SUIT_MessageBox::warning(desktop(),
2716 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2720 case 414: // Revolution
2722 if(checkLock(aStudy)) break;
2724 EmitSignalDeactivateDialog();
2725 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2728 SUIT_MessageBox::warning(desktop(),
2729 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2733 case 415: // Pattern mapping
2735 if ( checkLock( aStudy ) )
2739 EmitSignalDeactivateDialog();
2740 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2743 SUIT_MessageBox::warning(desktop(),
2744 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2748 case 416: // Extrusion along a path
2750 if (checkLock(aStudy)) break;
2752 EmitSignalDeactivateDialog();
2753 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2755 SUIT_MessageBox::warning(desktop(),
2756 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2760 case 417: // Convert mesh to quadratic
2761 case 418: // create 2D mesh from 3D
2762 case 420: // Reorient faces
2763 case 806: // CREATE GEO GROUP
2765 startOperation( theCommandID );
2768 case 801: // CREATE GROUP
2772 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2773 tr( "NOT_A_VTK_VIEWER" ) );
2777 if(checkLock(aStudy)) break;
2778 EmitSignalDeactivateDialog();
2779 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2781 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2782 SALOME_ListIO selected;
2784 aSel->selectedObjects( selected );
2786 int nbSel = selected.Extent();
2788 // check if mesh is selected
2789 aMesh = SMESH::GetMeshByIO( selected.First() );
2791 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2796 case 802: // CONSTRUCT GROUP
2800 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2801 tr( "NOT_A_VTK_VIEWER" ) );
2805 if(checkLock(aStudy)) break;
2806 EmitSignalDeactivateDialog();
2808 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2809 SALOME_ListIO selected;
2811 aSel->selectedObjects( selected );
2813 int nbSel = selected.Extent();
2815 // check if submesh is selected
2816 Handle(SALOME_InteractiveObject) IObject = selected.First();
2817 if (IObject->hasEntry()) {
2818 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2820 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2821 if (!aSubMesh->_is_nil()) {
2823 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2824 // get submesh elements list by types
2825 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2826 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2827 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2828 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2829 // create group for each type o elements
2830 QString aName = IObject->getName();
2831 QStringList anEntryList;
2832 if (aNodes->length() > 0) {
2833 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2834 aGroup->Add(aNodes.inout());
2835 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2836 anEntryList.append( aSObject->GetID().c_str() );
2838 if (aEdges->length() > 0) {
2839 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2840 aGroup->Add(aEdges.inout());
2841 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2842 anEntryList.append( aSObject->GetID().c_str() );
2844 if (aFaces->length() > 0) {
2845 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2846 aGroup->Add(aFaces.inout());
2847 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2848 anEntryList.append( aSObject->GetID().c_str() );
2850 if (aVolumes->length() > 0) {
2851 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2852 aGroup->Add(aVolumes.inout());
2853 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2854 anEntryList.append( aSObject->GetID().c_str() );
2857 anApp->browseObjects( anEntryList );
2859 catch(const SALOME::SALOME_Exception & S_ex){
2860 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2867 SUIT_MessageBox::warning(desktop(),
2868 tr("SMESH_WRN_WARNING"),
2869 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2874 case 803: // EDIT GROUP
2878 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2879 tr( "NOT_A_VTK_VIEWER" ) );
2883 if(checkLock(aStudy)) break;
2884 EmitSignalDeactivateDialog();
2886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2887 SALOME_ListIO selected;
2889 aSel->selectedObjects( selected );
2891 SALOME_ListIteratorOfListIO It (selected);
2892 int nbSelectedGroups = 0;
2893 for ( ; It.More(); It.Next() )
2895 SMESH::SMESH_GroupBase_var aGroup =
2896 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2897 if (!aGroup->_is_nil()) {
2899 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2903 if (nbSelectedGroups == 0)
2905 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2911 case 804: // Add elements to group
2913 if(checkLock(aStudy)) break;
2914 if (myState == 800) {
2915 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2916 if (aDlg) aDlg->onAdd();
2921 case 805: // Remove elements from group
2923 if(checkLock(aStudy)) break;
2924 if (myState == 800) {
2925 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2926 if (aDlg) aDlg->onRemove();
2931 case 815: // Edit GEOM GROUP as standalone
2935 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2936 tr( "NOT_A_VTK_VIEWER" ) );
2940 if(checkLock(aStudy)) break;
2941 EmitSignalDeactivateDialog();
2943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2944 SALOME_ListIO selected;
2946 aSel->selectedObjects( selected );
2948 SALOME_ListIteratorOfListIO It (selected);
2949 for ( ; It.More(); It.Next() )
2951 SMESH::SMESH_GroupOnGeom_var aGroup =
2952 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2953 if (!aGroup->_is_nil()) {
2954 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2959 SMESH::SMESH_GroupOnFilter_var aGroup =
2960 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2961 if (!aGroup->_is_nil()) {
2962 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2970 case 810: // Union Groups
2971 case 811: // Intersect groups
2972 case 812: // Cut groups
2976 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2977 tr( "NOT_A_VTK_VIEWER" ) );
2981 if ( checkLock( aStudy ) )
2984 EmitSignalDeactivateDialog();
2986 SMESHGUI_GroupOpDlg* aDlg = 0;
2987 if ( theCommandID == 810 )
2988 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2989 else if ( theCommandID == 811 )
2990 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2992 aDlg = new SMESHGUI_CutGroupsDlg( this );
2999 case 814: // Create groups of entities from existing groups of superior dimensions
3001 if ( checkLock( aStudy ) )
3004 EmitSignalDeactivateDialog();
3005 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3011 case 813: // Delete groups with their contents
3015 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3016 tr( "NOT_A_VTK_VIEWER" ) );
3020 if ( checkLock( aStudy ) )
3023 EmitSignalDeactivateDialog();
3025 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3029 case 900: // MESH INFOS
3030 case 903: // WHAT IS
3032 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3033 EmitSignalDeactivateDialog();
3034 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3035 SALOME_ListIO selected;
3037 aSel->selectedObjects( selected );
3039 if ( selected.Extent() > 1 ) { // a dlg for each IO
3040 SALOME_ListIteratorOfListIO It( selected );
3041 for ( ; It.More(); It.Next() ) {
3042 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3043 dlg->showInfo( It.Value() );
3048 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3054 case 904: // FIND ELEM
3056 startOperation( theCommandID );
3060 case 1100: // EDIT HYPOTHESIS
3062 if(checkLock(aStudy)) break;
3064 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3065 SALOME_ListIO selected;
3067 aSel->selectedObjects( selected );
3069 int nbSel = selected.Extent();
3072 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3073 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3075 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3076 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3077 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3078 if ( !aHypothesis->_is_nil() )
3081 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3082 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3084 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3094 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3096 if(checkLock(aStudy)) break;
3097 SUIT_OverrideCursor wc;
3099 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3100 SALOME_ListIO selected;
3102 aSel->selectedObjects( selected, QString::null, false );
3104 SALOME_ListIteratorOfListIO It(selected);
3105 for (int i = 0; It.More(); It.Next(), i++) {
3106 Handle(SALOME_InteractiveObject) IObject = It.Value();
3107 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3110 aSel->setSelectedObjects( l1 );
3116 case 4009: // ELEM0D
3118 case 4021: // TRIANGLE
3120 case 4023: // POLYGON
3124 case 4134: // PYRAMID
3125 case 4135: // OCTA12
3127 if(checkLock(aStudy)) break;
3129 EmitSignalDeactivateDialog();
3130 SMDSAbs_EntityType type = SMDSEntity_Edge;
3131 switch (theCommandID) {
3132 case 4008: type = SMDSEntity_Ball; break;
3133 case 4009: type = SMDSEntity_0D; break;
3134 case 4021: type = SMDSEntity_Triangle; break;
3135 case 4022: type = SMDSEntity_Quadrangle; break;
3136 case 4031: type = SMDSEntity_Tetra; break;
3137 case 4023: type = SMDSEntity_Polygon; break;
3138 case 4032: type = SMDSEntity_Hexa; break;
3139 case 4133: type = SMDSEntity_Penta; break;
3140 case 4134: type = SMDSEntity_Pyramid; break;
3141 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3144 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3147 SUIT_MessageBox::warning(desktop(),
3148 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3152 case 4033: // POLYHEDRON
3154 if(checkLock(aStudy)) break;
3156 EmitSignalDeactivateDialog();
3157 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3160 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3165 case 4034: // QUADRATIC EDGE
3166 case 4035: // QUADRATIC TRIANGLE
3167 case 4036: // QUADRATIC QUADRANGLE
3168 case 4136: // BIQUADRATIC QUADRANGLE
3169 case 4137: // BIQUADRATIC TRIANGLE
3170 case 4037: // QUADRATIC TETRAHEDRON
3171 case 4038: // QUADRATIC PYRAMID
3172 case 4039: // QUADRATIC PENTAHEDRON
3173 case 4040: // QUADRATIC HEXAHEDRON
3174 case 4140: // TRIQUADRATIC HEXAHEDRON
3176 if(checkLock(aStudy)) break;
3178 EmitSignalDeactivateDialog();
3179 SMDSAbs_EntityType type = SMDSEntity_Last;
3181 switch (theCommandID) {
3182 case 4034: type = SMDSEntity_Quad_Edge; break;
3183 case 4035: type = SMDSEntity_Quad_Triangle; break;
3184 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3185 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3186 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3187 case 4037: type = SMDSEntity_Quad_Tetra; break;
3188 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3189 case 4039: type = SMDSEntity_Quad_Penta; break;
3190 case 4040: type = SMDSEntity_Quad_Hexa; break;
3191 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3194 if ( type != SMDSEntity_Last )
3195 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3198 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3199 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3203 case 4041: // REMOVES NODES
3205 if(checkLock(aStudy)) break;
3207 EmitSignalDeactivateDialog();
3208 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3211 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3212 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3216 case 4042: // REMOVES ELEMENTS
3218 if(checkLock(aStudy)) break;
3220 EmitSignalDeactivateDialog();
3221 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3225 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3226 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3230 case 4043: { // CLEAR_MESH
3232 if(checkLock(aStudy)) break;
3234 SALOME_ListIO selected;
3235 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3236 aSel->selectedObjects( selected );
3238 SUIT_OverrideCursor wc;
3239 SALOME_ListIteratorOfListIO It (selected);
3240 for ( ; It.More(); It.Next() )
3242 Handle(SALOME_InteractiveObject) IOS = It.Value();
3243 SMESH::SMESH_Mesh_var aMesh =
3244 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3245 if ( aMesh->_is_nil()) continue;
3247 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3249 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3250 SMESH::ModifiedMesh( aMeshSObj, false, true);
3251 // hide groups and submeshes
3252 _PTR(ChildIterator) anIter =
3253 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3254 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3256 _PTR(SObject) so = anIter->Value();
3257 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3260 catch (const SALOME::SALOME_Exception& S_ex){
3262 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3266 SMESH::UpdateView();
3270 case 4044: // REMOVE ORPHAN NODES
3272 if(checkLock(aStudy)) break;
3273 SALOME_ListIO selected;
3274 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3275 aSel->selectedObjects( selected );
3276 if ( selected.Extent() == 1 ) {
3277 Handle(SALOME_InteractiveObject) anIO = selected.First();
3278 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3279 if ( !aMesh->_is_nil() ) {
3280 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3281 tr( "SMESH_WARNING" ),
3282 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3283 SUIT_MessageBox::Yes |
3284 SUIT_MessageBox::No,
3285 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3288 SUIT_OverrideCursor wc;
3289 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3290 int removed = aMeshEditor->RemoveOrphanNodes();
3291 SUIT_MessageBox::information(SMESHGUI::desktop(),
3292 tr("SMESH_INFORMATION"),
3293 tr("NB_NODES_REMOVED").arg(removed));
3294 if ( removed > 0 ) {
3295 SMESH::UpdateView();
3296 SMESHGUI::Modified();
3299 catch (const SALOME::SALOME_Exception& S_ex) {
3300 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3309 case 4051: // RENUMBERING NODES
3311 if(checkLock(aStudy)) break;
3313 EmitSignalDeactivateDialog();
3314 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3318 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3319 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3323 case 4052: // RENUMBERING ELEMENTS
3325 if(checkLock(aStudy)) break;
3327 EmitSignalDeactivateDialog();
3328 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3332 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3333 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3337 case 4061: // TRANSLATION
3339 if(checkLock(aStudy)) break;
3341 EmitSignalDeactivateDialog();
3342 ( new SMESHGUI_TranslationDlg( this ) )->show();
3345 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3346 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3350 case 4062: // ROTATION
3352 if(checkLock(aStudy)) break;
3354 EmitSignalDeactivateDialog();
3355 ( new SMESHGUI_RotationDlg( this ) )->show();
3358 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3359 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3363 case 4063: // SYMMETRY
3365 if(checkLock(aStudy)) break;
3367 EmitSignalDeactivateDialog();
3368 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3371 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3372 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3376 case 4064: // SEWING
3378 if(checkLock(aStudy)) break;
3380 EmitSignalDeactivateDialog();
3381 ( new SMESHGUI_SewingDlg( this ) )->show();
3384 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3385 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3389 case 4065: // MERGE NODES
3391 if(checkLock(aStudy)) break;
3393 EmitSignalDeactivateDialog();
3394 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3397 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3398 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3402 case 4066: // MERGE EQUAL ELEMENTS
3404 if (checkLock(aStudy)) break;
3406 EmitSignalDeactivateDialog();
3407 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3409 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3415 case 4067: // MAKE MESH PASS THROUGH POINT
3416 startOperation( 4067 );
3421 if(checkLock(aStudy)) break;
3423 EmitSignalDeactivateDialog();
3424 ( new SMESHGUI_ScaleDlg( this ) )->show();
3427 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3428 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3433 case 4069: // DUPLICATE NODES
3435 if(checkLock(aStudy)) break;
3437 EmitSignalDeactivateDialog();
3438 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3441 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3442 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3447 case 4070: // 0D_ON_ALL_NODES
3448 startOperation( 4070 );
3451 case 5105: // Library of selection filters
3453 static QList<int> aTypes;
3454 if ( aTypes.isEmpty() )
3456 aTypes.append( SMESH::NODE );
3457 aTypes.append( SMESH::EDGE );
3458 aTypes.append( SMESH::FACE );
3459 aTypes.append( SMESH::VOLUME );
3461 if (!myFilterLibraryDlg)
3462 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3463 else if (myFilterLibraryDlg->isHidden())
3464 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3465 myFilterLibraryDlg->raise();
3469 case 6017: // CONTROLS
3497 LightApp_SelectionMgr* mgr = selectionMgr();
3498 SALOME_ListIO selected; mgr->selectedObjects( selected );
3500 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3501 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3503 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3504 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3505 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3506 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3507 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3508 SUIT_OverrideCursor wc;
3509 ::Control( theCommandID );
3514 SUIT_MessageBox::warning(desktop(),
3515 tr( "SMESH_WRN_WARNING" ),
3516 tr( "SMESH_BAD_SELECTION" ) );
3520 SUIT_MessageBox::warning(desktop(),
3521 tr( "SMESH_WRN_WARNING" ),
3522 tr( "NOT_A_VTK_VIEWER" ) );
3526 OverallMeshQuality();
3530 SUIT_OverrideCursor wc;
3531 LightApp_SelectionMgr* mgr = selectionMgr();
3532 SALOME_ListIO selected; mgr->selectedObjects( selected );
3534 SALOME_ListIteratorOfListIO it(selected);
3535 for( ; it.More(); it.Next()) {
3536 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3537 if(anIObject->hasEntry()) {
3538 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3539 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3547 SUIT_OverrideCursor wc;
3548 LightApp_SelectionMgr* mgr = selectionMgr();
3549 SALOME_ListIO selected; mgr->selectedObjects( selected );
3551 SALOME_ListIteratorOfListIO it(selected);
3552 for( ; it.More(); it.Next()) {
3553 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3554 if(anIObject->hasEntry())
3555 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3556 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3567 int page = SMESHGUI_MeasureDlg::MinDistance;
3568 if ( theCommandID == 502 )
3569 page = SMESHGUI_MeasureDlg::BoundingBox;
3570 else if ( theCommandID == 503 )
3571 page = SMESHGUI_MeasureDlg::Length;
3572 else if ( theCommandID == 504 )
3573 page = SMESHGUI_MeasureDlg::Area;
3574 else if ( theCommandID == 505 )
3575 page = SMESHGUI_MeasureDlg::Volume;
3577 EmitSignalDeactivateDialog();
3578 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3588 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3589 //updateObjBrowser();
3593 //=============================================================================
3597 //=============================================================================
3598 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3603 //=============================================================================
3607 //=============================================================================
3608 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3613 //=============================================================================
3617 //=============================================================================
3618 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3623 //=============================================================================
3624 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3625 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3627 //=============================================================================
3628 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3629 SUIT_ViewWindow* wnd )
3631 if(theIO->hasEntry()){
3632 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3633 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3637 //=======================================================================
3638 // function : createSMESHAction
3640 //=======================================================================
3641 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3642 const int key, const bool toggle, const QString& shortcutAction )
3645 QWidget* parent = application()->desktop();
3646 SUIT_ResourceMgr* resMgr = resourceMgr();
3648 if ( !icon_id.isEmpty() )
3649 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3651 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3652 if ( !pix.isNull() )
3653 icon = QIcon( pix );
3655 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3656 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3657 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3659 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3660 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3663 //=======================================================================
3664 // function : createPopupItem
3666 //=======================================================================
3667 void SMESHGUI::createPopupItem( const int id,
3668 const QString& clients,
3669 const QString& types,
3670 const QString& theRule,
3673 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3674 popupMgr()->insert( action( id ), pId, 0 );
3676 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3677 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3678 QString rule = "(%1) and (%2) and (%3)";
3679 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3680 if( clients.isEmpty() )
3681 rule = rule.arg( QString( "true" ) );
3683 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3684 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3687 bool cont = myRules.contains( id );
3689 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3691 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3692 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3695 //=======================================================================
3696 // function : initialize
3698 //=======================================================================
3699 void SMESHGUI::initialize( CAM_Application* app )
3701 SalomeApp_Module::initialize( app );
3703 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3705 /* Automatic Update flag */
3706 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3708 // ----- create actions --------------
3710 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3711 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3712 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3713 createSMESHAction( 114, "NUM" );
3714 createSMESHAction( 115, "IMPORT_STL" );
3715 createSMESHAction( 116, "IMPORT_CGNS" );
3716 createSMESHAction( 117, "IMPORT_SAUV" );
3717 createSMESHAction( 118, "IMPORT_GMF" );
3718 createSMESHAction( 121, "DAT" );
3719 createSMESHAction( 122, "MED" );
3720 createSMESHAction( 123, "UNV" );
3721 createSMESHAction( 140, "STL" );
3722 createSMESHAction( 142, "CGNS");
3723 createSMESHAction( 144, "SAUV");
3724 createSMESHAction( 146, "GMF" );
3725 createSMESHAction( 124, "DAT" );
3726 createSMESHAction( 125, "MED" );
3727 createSMESHAction( 126, "UNV" );
3728 createSMESHAction( 141, "STL" );
3729 createSMESHAction( 143, "CGNS");
3730 createSMESHAction( 145, "SAUV");
3731 createSMESHAction( 147, "GMF" );
3732 createSMESHAction( 150, "FILE_INFO" );
3733 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3734 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3735 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3736 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3737 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3738 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3739 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3740 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3741 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3742 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3743 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3744 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3745 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3746 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3747 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3748 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3749 createSMESHAction( 804, "ADD" );
3750 createSMESHAction( 805, "REMOVE" );
3751 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3752 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3753 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3754 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3755 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3756 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3757 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3758 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3759 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3760 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3761 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3762 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3763 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3764 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3765 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3766 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3767 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3768 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3769 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3770 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3771 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3772 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3773 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3774 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3775 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3776 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3777 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3778 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3779 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3780 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3781 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3782 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3783 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3784 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3785 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3786 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3787 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3788 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3789 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3790 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3791 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3792 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3793 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3794 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3795 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3796 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3797 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3798 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3799 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3800 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3801 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3802 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3803 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3804 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3805 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3806 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3807 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3808 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3809 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3810 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3811 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3812 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3813 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3814 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3815 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3816 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3817 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3818 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3819 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3820 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3821 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3822 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3823 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3824 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3825 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3826 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3827 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3828 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3829 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3830 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3831 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3832 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3833 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3834 createSMESHAction( 415, "MAP", "ICON_MAP" );
3835 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3836 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3837 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3838 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3839 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3840 createSMESHAction( 200, "RESET" );
3841 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3842 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3843 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3844 #ifndef DISABLE_PLOT2DVIEWER
3845 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3847 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3848 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3849 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3850 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3851 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3852 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3853 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3854 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3855 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3856 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3857 createSMESHAction( 220, "ALL" );
3858 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3860 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3861 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3863 createSMESHAction( 1100, "EDIT_HYPO" );
3864 createSMESHAction( 1102, "UNASSIGN" );
3865 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3866 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3867 createSMESHAction( 1131, "DISPMODE" );
3868 createSMESHAction( 1132, "COLORS" );
3869 createSMESHAction( 1133, "TRANSP" );
3870 createSMESHAction( 1134, "CLIP" );
3871 createSMESHAction( 1135, "DISP_ENT" );
3872 createSMESHAction( 1136, "AUTO_COLOR" );
3873 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3874 createSMESHAction( 2000, "CTRL" );
3876 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3877 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3878 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3879 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3880 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3882 createSMESHAction( 300, "HIDE" );
3883 createSMESHAction( 301, "SHOW" );
3884 createSMESHAction( 302, "DISPLAY_ONLY" );
3886 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3888 // ----- create menu --------------
3889 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3890 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3891 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3892 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3893 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3894 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3895 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3896 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3898 createMenu( separator(), fileId );
3900 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3901 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3902 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3903 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3904 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3905 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3906 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3907 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3908 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3909 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3910 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3912 //createMenu( 111, importId, -1 );
3913 createMenu( 112, importId, -1 );
3914 createMenu( 113, importId, -1 );
3915 createMenu( 115, importId, -1 );
3917 createMenu( 116, importId, -1 );
3919 createMenu( 117, importId, -1 );
3920 createMenu( 118, importId, -1 );
3921 createMenu( 121, exportId, -1 );
3922 createMenu( 122, exportId, -1 );
3923 createMenu( 123, exportId, -1 );
3924 createMenu( 140, exportId, -1 ); // export to STL
3926 createMenu( 142, exportId, -1 ); // export to CGNS
3928 createMenu( 144, exportId, -1 ); // export to SAUV
3929 createMenu( 146, exportId, -1 ); // export to GMF
3930 createMenu( separator(), fileId, 10 );
3932 createMenu( 33, editId, -1 );
3934 createMenu( 5105, toolsId, -1 );
3936 createMenu( 702, meshId, -1 ); // "Mesh" menu
3937 createMenu( 703, meshId, -1 );
3938 createMenu( 704, meshId, -1 );
3939 createMenu( 710, meshId, -1 );
3940 createMenu( 705, meshId, -1 );
3941 createMenu( separator(), meshId, -1 );
3942 createMenu( 701, meshId, -1 );
3943 createMenu( 711, meshId, -1 );
3944 createMenu( 712, meshId, -1 );
3945 createMenu( 713, meshId, -1 );
3946 createMenu( separator(), meshId, -1 );
3947 createMenu( 801, meshId, -1 );
3948 createMenu( 806, meshId, -1 );
3949 createMenu( 802, meshId, -1 );
3950 createMenu( 803, meshId, -1 );
3951 createMenu( 815, meshId, -1 );
3952 createMenu( separator(), meshId, -1 );
3953 createMenu( 810, meshId, -1 );
3954 createMenu( 811, meshId, -1 );
3955 createMenu( 812, meshId, -1 );
3956 createMenu( separator(), meshId, -1 );
3957 createMenu( 814, meshId, -1 );
3958 createMenu( separator(), meshId, -1 );
3959 createMenu( 900, meshId, -1 );
3960 //createMenu( 902, meshId, -1 );
3961 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3962 createMenu( 904, meshId, -1 );
3963 createMenu( separator(), meshId, -1 );
3965 createMenu( 6005, nodeId, -1 );
3966 createMenu( 6028, nodeId, -1 );
3967 createMenu( 6002, edgeId, -1 );
3968 createMenu( 6003, edgeId, -1 );
3969 createMenu( 6001, edgeId, -1 );
3970 createMenu( 6004, edgeId, -1 );
3971 createMenu( 6029, edgeId, -1 );
3972 createMenu( 6021, faceId, -1 );
3973 createMenu( 6025, faceId, -1 );
3974 createMenu( 6027, faceId, -1 );
3975 createMenu( 6018, faceId, -1 );
3976 createMenu( 6019, faceId, -1 );
3977 createMenu( 6011, faceId, -1 );
3978 createMenu( 6012, faceId, -1 );
3979 createMenu( 6013, faceId, -1 );
3980 createMenu( 6014, faceId, -1 );
3981 createMenu( 6015, faceId, -1 );
3982 createMenu( 6016, faceId, -1 );
3983 createMenu( 6022, faceId, -1 );
3984 createMenu( 6030, faceId, -1 );
3985 createMenu( 6017, volumeId, -1 );
3986 createMenu( 6009, volumeId, -1 );
3987 createMenu( 6023, volumeId, -1 );
3988 createMenu( 6024, volumeId, -1 );
3989 createMenu( 6026, volumeId, -1 );
3990 createMenu( 6031, volumeId, -1 );
3991 createMenu( separator(), ctrlId, -1 );
3992 createMenu( 6032, ctrlId, -1 );
3994 createMenu( 4000, addId, -1 );
3995 createMenu( 4009, addId, -1 );
3996 createMenu( 4070, addId, -1 );
3997 createMenu( 4008, addId, -1 );
3998 createMenu( 4010, addId, -1 );
3999 createMenu( 4021, addId, -1 );
4000 createMenu( 4022, addId, -1 );
4001 createMenu( 4023, addId, -1 );
4002 createMenu( 4031, addId, -1 );
4003 createMenu( 4032, addId, -1 );
4004 createMenu( 4133, addId, -1 );
4005 createMenu( 4134, addId, -1 );
4006 createMenu( 4135, addId, -1 );
4007 createMenu( 4033, addId, -1 );
4008 createMenu( separator(), addId, -1 );
4009 createMenu( 4034, addId, -1 );
4010 createMenu( 4035, addId, -1 );
4011 createMenu( 4137, addId, -1 );
4012 createMenu( 4036, addId, -1 );
4013 createMenu( 4136, addId, -1 );
4014 createMenu( 4037, addId, -1 );
4015 createMenu( 4038, addId, -1 );
4016 createMenu( 4039, addId, -1 );
4017 createMenu( 4040, addId, -1 );
4018 createMenu( 4140, addId, -1 );
4020 createMenu( 4041, removeId, -1 );
4021 createMenu( 4042, removeId, -1 );
4022 createMenu( 4044, removeId, -1 );
4023 createMenu( separator(), removeId, -1 );
4024 createMenu( 813, removeId, -1 );
4025 createMenu( separator(), removeId, -1 );
4026 createMenu( 4043, removeId, -1 );
4028 createMenu( 4051, renumId, -1 );
4029 createMenu( 4052, renumId, -1 );
4031 createMenu( 4061, transfId, -1 );
4032 createMenu( 4062, transfId, -1 );
4033 createMenu( 4063, transfId, -1 );
4034 createMenu( 4068, transfId, -1 );
4035 createMenu( 4064, transfId, -1 );
4036 createMenu( 4065, transfId, -1 );
4037 createMenu( 4066, transfId, -1 );
4038 createMenu( 4069, transfId, -1 );
4040 createMenu( 4067,modifyId, -1 );
4041 createMenu( 407, modifyId, -1 );
4042 createMenu( 408, modifyId, -1 );
4043 createMenu( 409, modifyId, -1 );
4044 createMenu( 420, modifyId, -1 );
4045 createMenu( 410, modifyId, -1 );
4046 createMenu( 411, modifyId, -1 );
4047 createMenu( 419, modifyId, -1 );
4048 createMenu( 412, modifyId, -1 );
4049 createMenu( 413, modifyId, -1 );
4050 createMenu( 416, modifyId, -1 );
4051 createMenu( 414, modifyId, -1 );
4052 createMenu( 415, modifyId, -1 );
4053 createMenu( 417, modifyId, -1 );
4054 createMenu( 418, modifyId, -1 );
4056 createMenu( 501, measureId, -1 );
4057 createMenu( 502, measureId, -1 );
4058 createMenu( 503, basicPropId, -1 );
4059 createMenu( 504, basicPropId, -1 );
4060 createMenu( 505, basicPropId, -1 );
4061 createMenu( 214, viewId, -1 );
4063 // ----- create toolbars --------------
4064 int meshTb = createTool( tr( "TB_MESH" ) ),
4065 info = createTool( tr( "TB_INFO" ) ),
4066 groupTb = createTool( tr( "TB_GROUP" ) ),
4067 ctrl0dTb = createTool( tr( "TB_CTRL0D" ) ),
4068 ctrl1dTb = createTool( tr( "TB_CTRL1D" ) ),
4069 ctrl2dTb = createTool( tr( "TB_CTRL2D" ) ),
4070 ctrl3dTb = createTool( tr( "TB_CTRL3D" ) ),
4071 addElemTb = createTool( tr( "TB_ADD" ) ),
4072 addNonElemTb = createTool( tr( "TB_ADDNON" ) ),
4073 remTb = createTool( tr( "TB_REM" ) ),
4074 renumbTb = createTool( tr( "TB_RENUMBER" ) ),
4075 transformTb = createTool( tr( "TB_TRANSFORM" ) ),
4076 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4077 measuremTb = createTool( tr( "TB_MEASUREM" ) ),
4078 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4080 createTool( 702, meshTb );
4081 createTool( 703, meshTb );
4082 createTool( 704, meshTb );
4083 createTool( 710, meshTb );
4084 createTool( 705, meshTb );
4085 createTool( separator(), meshTb );
4086 createTool( 701, meshTb );
4087 createTool( 711, meshTb );
4088 createTool( 712, meshTb );
4089 createTool( 713, meshTb );
4091 createTool( 801, groupTb );
4092 createTool( 806, groupTb );
4093 createTool( 802, groupTb );
4094 createTool( 803, groupTb );
4096 createTool( 900, info );
4097 //createTool( 902, meshTb );
4098 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4099 createTool( 904, info );
4101 createTool( 6005, ctrl0dTb );
4102 createTool( 6028, ctrl0dTb );
4104 createTool( 6002, ctrl1dTb );
4105 createTool( 6003, ctrl1dTb );
4106 createTool( 6001, ctrl1dTb );
4107 createTool( 6004, ctrl1dTb );
4108 createTool( 6029, ctrl1dTb );
4110 createTool( 6021, ctrl2dTb );
4111 createTool( 6025, ctrl2dTb );
4112 createTool( 6027, ctrl2dTb );
4113 createTool( 6018, ctrl2dTb );
4114 createTool( 6019, ctrl2dTb );
4115 createTool( 6011, ctrl2dTb );
4116 createTool( 6012, ctrl2dTb );
4117 createTool( 6013, ctrl2dTb );
4118 createTool( 6014, ctrl2dTb );
4119 createTool( 6015, ctrl2dTb );
4120 createTool( 6016, ctrl2dTb );
4121 createTool( 6022, ctrl2dTb );
4122 createTool( 6030, ctrl2dTb );
4124 createTool( 6017, ctrl3dTb );
4125 createTool( 6009, ctrl3dTb );
4126 createTool( 6023, ctrl3dTb );
4127 createTool( 6024, ctrl3dTb );
4128 createTool( 6026, ctrl3dTb );
4129 createTool( 6031, ctrl3dTb );
4131 createTool( 4000, addElemTb );
4132 createTool( 4009, addElemTb );
4133 createTool( 4070, addElemTb );
4134 createTool( 4008, addElemTb );
4135 createTool( 4010, addElemTb );
4136 createTool( 4021, addElemTb );
4137 createTool( 4022, addElemTb );
4138 createTool( 4023, addElemTb );
4139 createTool( 4031, addElemTb );
4140 createTool( 4032, addElemTb );
4141 createTool( 4133, addElemTb );
4142 createTool( 4134, addElemTb );
4143 createTool( 4135, addElemTb );
4144 createTool( 4033, addElemTb );
4146 createTool( 4034, addNonElemTb );
4147 createTool( 4035, addNonElemTb );
4148 createTool( 4137, addNonElemTb );
4149 createTool( 4036, addNonElemTb );
4150 createTool( 4136, addNonElemTb );
4151 createTool( 4037, addNonElemTb );
4152 createTool( 4038, addNonElemTb );
4153 createTool( 4039, addNonElemTb );
4154 createTool( 4040, addNonElemTb );
4155 createTool( 4140, addNonElemTb );
4157 createTool( 4041, remTb );
4158 createTool( 4042, remTb );
4159 createTool( 4044, remTb );
4160 createTool( 4043, remTb );
4162 createTool( 4051, renumbTb );
4163 createTool( 4052, renumbTb );
4166 createTool( 4061, transformTb );
4167 createTool( 4062, transformTb );
4168 createTool( 4063, transformTb );
4169 createTool( 4068, transformTb );
4170 createTool( 4064, transformTb );
4171 createTool( 4065, transformTb );
4172 createTool( 4066, transformTb );
4173 createTool( 4069, transformTb );
4175 createTool( 4067,modifyTb );
4176 createTool( 407, modifyTb );
4177 createTool( 408, modifyTb );
4178 createTool( 409, modifyTb );
4179 createTool( 420, modifyTb );
4180 createTool( 410, modifyTb );
4181 createTool( 411, modifyTb );
4182 createTool( 419, modifyTb );
4183 createTool( 412, modifyTb );
4184 createTool( 413, modifyTb );
4185 createTool( 416, modifyTb );
4186 createTool( 414, modifyTb );
4187 createTool( 415, modifyTb );
4188 createTool( 417, modifyTb );
4189 createTool( 418, modifyTb );
4191 createTool( 501, measuremTb );
4193 createTool( 214, dispModeTb );
4195 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4196 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4199 QString OB = "'ObjectBrowser'",
4200 View = "'" + SVTK_Viewer::Type() + "'",
4202 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4203 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4204 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4205 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4206 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4207 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4208 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4209 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4210 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4211 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4212 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4214 mesh_part = mesh + " " + subMesh + " " + group,
4215 mesh_group = mesh + " " + group,
4216 hyp_alg = hypo + " " + algo;
4218 // popup for object browser
4220 isInvisible("not( isVisible )"),
4221 isEmpty("numberOfNodes = 0"),
4222 isNotEmpty("numberOfNodes <> 0"),
4224 // has nodes, edges, etc in VISIBLE! actor
4225 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4226 hasElems("(count( elemTypes ) > 0)"),
4227 hasDifferentElems("(count( elemTypes ) > 1)"),
4228 hasBalls("({'BallElem'} in elemTypes)"),
4229 hasElems0d("({'Elem0d'} in elemTypes)"),
4230 hasEdges("({'Edge'} in elemTypes)"),
4231 hasFaces("({'Face'} in elemTypes)"),
4232 hasVolumes("({'Volume'} in elemTypes)");
4234 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4235 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4236 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4237 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4238 createPopupItem( 803, OB, group ); // EDIT_GROUP
4239 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4241 popupMgr()->insert( separator(), -1, 0 );
4242 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4243 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4244 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4245 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4246 createPopupItem( 214, OB, mesh_part ); // UPDATE
4247 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4248 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4249 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4250 popupMgr()->insert( separator(), -1, 0 );
4251 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4252 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4253 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4254 popupMgr()->insert( separator(), -1, 0 );
4255 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4256 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4257 popupMgr()->insert( separator(), -1, 0 );
4258 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4259 popupMgr()->insert( separator(), -1, 0 );
4260 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4261 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4263 popupMgr()->insert( separator(), -1, 0 );
4265 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4266 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4267 QString only_one_2D = only_one_non_empty + " && dim>1";
4269 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4270 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4271 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4272 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4274 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4276 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4277 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4278 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4279 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4280 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4281 popupMgr()->insert( separator(), -1, 0 );
4284 createPopupItem( 803, View, group ); // EDIT_GROUP
4285 createPopupItem( 804, View, elems ); // ADD
4286 createPopupItem( 805, View, elems ); // REMOVE
4288 popupMgr()->insert( separator(), -1, 0 );
4289 createPopupItem( 214, View, mesh_part ); // UPDATE
4290 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4291 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4292 createPopupItem( 904, View, mesh ); // FIND_ELEM
4293 popupMgr()->insert( separator(), -1, 0 );
4295 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4296 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4297 popupMgr()->insert( separator(), -1, 0 );
4299 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4300 QString aType = QString( "%1type in {%2}" ).arg( lc );
4301 aType = aType.arg( mesh_part );
4302 QString aMeshInVTK = aClient + "&&" + aType;
4304 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4305 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4306 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4308 //-------------------------------------------------
4310 //-------------------------------------------------
4311 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4313 popupMgr()->insert( action( 9010 ), anId, -1 );
4314 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4315 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4317 popupMgr()->insert( action( 9011 ), anId, -1 );
4318 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4319 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4321 popupMgr()->insert( separator(), -1, -1 );
4323 //-------------------------------------------------
4325 //-------------------------------------------------
4326 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4328 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4329 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4330 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4332 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4333 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4334 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4336 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4337 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4338 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4340 popupMgr()->insert( separator(), anId, -1 );
4342 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4343 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4344 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4346 //-------------------------------------------------
4348 //-------------------------------------------------
4349 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4351 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4353 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4354 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4355 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4357 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4358 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4359 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4361 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4362 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4363 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4365 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4366 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4367 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4369 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4370 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4371 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4373 popupMgr()->insert( separator(), anId, -1 );
4375 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4376 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4379 //-------------------------------------------------
4380 // Representation of the 2D Quadratic elements
4381 //-------------------------------------------------
4382 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4383 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4384 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4385 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4387 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4388 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4389 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4391 //-------------------------------------------------
4392 // Orientation of faces
4393 //-------------------------------------------------
4394 popupMgr()->insert( action( 221 ), -1, -1 );
4395 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4396 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4398 //-------------------------------------------------
4400 //-------------------------------------------------
4401 popupMgr()->insert( action( 1132 ), -1, -1 );
4402 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4404 //-------------------------------------------------
4406 //-------------------------------------------------
4407 popupMgr()->insert( action( 1133 ), -1, -1 );
4408 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4410 //-------------------------------------------------
4412 //-------------------------------------------------
4414 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4415 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4416 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4417 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4419 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4421 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4422 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4424 popupMgr()->insert( separator(), anId, -1 );
4426 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4428 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4429 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4430 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4432 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4433 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4434 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4436 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4438 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4439 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4440 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4442 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4443 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4444 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4446 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4447 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4448 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4450 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4451 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4452 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4453 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4454 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4455 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4457 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4459 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4460 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4461 QtxPopupMgr::VisibleRule );
4462 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4464 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4465 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4466 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4468 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4469 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4470 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4472 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4473 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4474 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4476 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4477 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4478 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4480 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4481 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4482 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4484 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4485 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4486 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4488 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4489 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4490 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4492 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4493 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4494 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4496 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4497 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4498 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4500 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4501 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4502 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4504 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4505 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4506 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4507 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4508 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4509 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4511 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4513 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4514 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4515 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4517 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4518 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4519 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4521 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4522 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4523 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4525 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4526 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4527 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4529 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4530 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4531 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4533 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4534 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4535 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4537 popupMgr()->insert( separator(), anId, -1 );
4539 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4540 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4542 popupMgr()->insert( separator(), anId, -1 );
4544 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4546 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4547 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4549 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4550 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4551 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4553 #ifndef DISABLE_PLOT2DVIEWER
4554 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4555 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4558 //-------------------------------------------------
4560 //-------------------------------------------------
4561 popupMgr()->insert( separator(), -1, -1 );
4562 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4563 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4564 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4565 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4567 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4568 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4570 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4571 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4573 popupMgr()->insert( separator(), -1, -1 );
4575 //-------------------------------------------------
4577 //-------------------------------------------------
4578 popupMgr()->insert( action( 1134 ), -1, -1 );
4579 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4581 popupMgr()->insert( separator(), -1, -1 );
4583 popupMgr()->insert( action( 41 ), -1, -1 );
4584 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4585 popupMgr()->insert( separator(), -1, -1 );
4587 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4588 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4590 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4591 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4594 //================================================================================
4596 * \brief Return true if SMESH or GEOM objects are selected.
4597 * Is called form LightApp_Module::activateModule() which clear selection if
4598 * not isSelectionCompatible()
4600 //================================================================================
4602 bool SMESHGUI::isSelectionCompatible()
4604 bool isCompatible = true;
4605 SALOME_ListIO selected;
4606 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4607 Sel->selectedObjects( selected );
4609 SALOME_ListIteratorOfListIO It( selected );
4610 for ( ; isCompatible && It.More(); It.Next())
4612 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4613 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4615 return isCompatible;
4619 bool SMESHGUI::reusableOperation( const int id )
4621 // compute, evaluate and precompute are not reusable operations
4622 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4625 bool SMESHGUI::activateModule( SUIT_Study* study )
4627 bool res = SalomeApp_Module::activateModule( study );
4629 setMenuShown( true );
4630 setToolShown( true );
4632 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4633 PyGILState_STATE gstate = PyGILState_Ensure();
4634 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4635 if ( !pluginsmanager ) {
4639 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4643 PyGILState_Release(gstate);
4644 // end of SMESH plugins loading
4646 // Reset actions accelerator keys
4647 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4648 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4649 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4651 action( 33)->setEnabled(true); // Delete: Key_Delete
4653 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4654 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4655 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4656 if ( _PTR(Study) aStudy = s->studyDS()) {
4657 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4658 updateObjBrowser(); // objects can be removed
4661 // get all view currently opened in the study and connect their signals to
4662 // the corresponding slots of the class.
4663 SUIT_Desktop* aDesk = study->application()->desktop();
4665 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4666 SUIT_ViewWindow* wnd;
4667 foreach ( wnd, wndList )
4674 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4676 setMenuShown( false );
4677 setToolShown( false );
4679 EmitSignalCloseAllDialogs();
4681 // Unset actions accelerator keys
4682 //action(111)->setShortcut(QKeySequence()); // Import DAT
4683 action(112)->setShortcut(QKeySequence()); // Import UNV
4684 action(113)->setShortcut(QKeySequence()); // Import MED
4686 action( 33)->setEnabled(false); // Delete: Key_Delete
4688 return SalomeApp_Module::deactivateModule( study );
4691 void SMESHGUI::studyClosed( SUIT_Study* s )
4693 SMESH::RemoveVisuData( s->id() );
4694 SalomeApp_Module::studyClosed( s );
4697 void SMESHGUI::OnGUIEvent()
4699 const QObject* obj = sender();
4700 if ( !obj || !obj->inherits( "QAction" ) )
4702 int id = actionId((QAction*)obj);
4707 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4709 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4710 if ( CORBA::is_nil( myComponentSMESH ) )
4712 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4714 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4715 return aGUI.myComponentSMESH;
4718 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4719 return myComponentSMESH;
4722 QString SMESHGUI::engineIOR() const
4724 CORBA::ORB_var anORB = getApp()->orb();
4725 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4726 return QString( anIOR.in() );
4729 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4731 SalomeApp_Module::contextMenuPopup( client, menu, title );
4733 selectionMgr()->selectedObjects( lst );
4734 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4735 Handle(SALOME_InteractiveObject) io = lst.First();
4736 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4737 _PTR(Study) study = appStudy->studyDS();
4738 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4740 QString aName = QString( obj->GetName().c_str() );
4741 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4742 aName.remove( (aName.length() - 1), 1 );
4748 LightApp_Selection* SMESHGUI::createSelection() const
4750 return new SMESHGUI_Selection();
4753 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4755 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4756 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4759 void SMESHGUI::viewManagers( QStringList& list ) const
4761 list.append( SVTK_Viewer::Type() );
4764 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4766 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4767 SMESH::UpdateSelectionProp( this );
4769 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4770 for(int i = 0; i < aViews.count() ; i++){
4771 SUIT_ViewWindow *sf = aViews[i];
4777 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4779 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4780 myClippingPlaneInfoMap.erase( theViewManager );
4783 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4785 theActor->AddObserver( SMESH::DeleteActorEvent,
4786 myEventCallbackCommand.GetPointer(),
4790 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4791 unsigned long theEvent,
4792 void* theClientData,
4795 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4796 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4797 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4798 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4799 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4800 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4801 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4802 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4803 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4804 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4805 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4806 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4807 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4808 if( anActor == *anIter3 ) {
4809 anActorList.erase( anIter3 );
4820 void SMESHGUI::createPreferences()
4822 // General tab ------------------------------------------------------------------------
4823 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4825 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4826 setPreferenceProperty( autoUpdate, "columns", 2 );
4827 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4828 setPreferenceProperty( lim, "min", 0 );
4829 setPreferenceProperty( lim, "max", 100000000 );
4830 setPreferenceProperty( lim, "step", 1000 );
4831 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4832 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4834 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4835 setPreferenceProperty( qaGroup, "columns", 2 );
4836 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4837 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4838 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4839 setPreferenceProperty( prec, "min", 0 );
4840 setPreferenceProperty( prec, "max", 16 );
4841 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4842 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4843 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4844 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4845 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4847 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4848 setPreferenceProperty( dispgroup, "columns", 2 );
4849 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4851 modes.append( tr("MEN_WIRE") );
4852 modes.append( tr("MEN_SHADE") );
4853 modes.append( tr("MEN_NODES") );
4854 modes.append( tr("MEN_SHRINK") );
4855 QList<QVariant> indices;
4856 indices.append( 0 );
4857 indices.append( 1 );
4858 indices.append( 2 );
4859 indices.append( 3 );
4860 setPreferenceProperty( dispmode, "strings", modes );
4861 setPreferenceProperty( dispmode, "indexes", indices );
4863 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4864 setPreferenceProperty( arcgroup, "columns", 2 );
4865 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4866 QStringList quadraticModes;
4867 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4868 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4870 indices.append( 0 );
4871 indices.append( 1 );
4872 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4873 setPreferenceProperty( quadraticmode, "indexes", indices );
4875 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4876 "SMESH", "max_angle" );
4877 setPreferenceProperty( maxAngle, "min", 1 );
4878 setPreferenceProperty( maxAngle, "max", 90 );
4882 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4883 setPreferenceProperty( exportgroup, "columns", 2 );
4884 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4885 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4887 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4888 setPreferenceProperty( computeGroup, "columns", 2 );
4889 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4891 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4892 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4893 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4895 indices.append( 0 );
4896 indices.append( 1 );
4897 indices.append( 2 );
4898 setPreferenceProperty( notifyMode, "strings", modes );
4899 setPreferenceProperty( notifyMode, "indexes", indices );
4901 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4902 setPreferenceProperty( infoGroup, "columns", 2 );
4903 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4905 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4906 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4908 indices.append( 0 );
4909 indices.append( 1 );
4910 setPreferenceProperty( elemInfo, "strings", modes );
4911 setPreferenceProperty( elemInfo, "indexes", indices );
4912 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4913 setPreferenceProperty( nodesLim, "min", 0 );
4914 setPreferenceProperty( nodesLim, "max", 10000000 );
4915 setPreferenceProperty( nodesLim, "step", 10000 );
4916 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4917 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4918 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4919 setPreferenceProperty( ctrlLim, "min", 0 );
4920 setPreferenceProperty( ctrlLim, "max", 10000000 );
4921 setPreferenceProperty( ctrlLim, "step", 1000 );
4922 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4923 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4924 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4925 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4926 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4928 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4929 setPreferenceProperty( segGroup, "columns", 2 );
4930 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4931 "SMESH", "segmentation" );
4932 setPreferenceProperty( segLen, "min", 1 );
4933 setPreferenceProperty( segLen, "max", 10000000 );
4934 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4935 "SMESH", "nb_segments_per_edge" );
4936 setPreferenceProperty( nbSeg, "min", 1 );
4937 setPreferenceProperty( nbSeg, "max", 10000000 );
4939 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4940 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4941 "SMESH", "forget_mesh_on_hyp_modif" );
4944 // Quantities with individual precision settings
4945 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4946 setPreferenceProperty( precGroup, "columns", 2 );
4948 const int nbQuantities = 6;
4949 int precs[nbQuantities], ii = 0;
4950 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4951 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4952 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4953 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4954 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4955 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4956 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4957 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4958 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4959 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4960 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4961 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4963 // Set property for precision value for spinboxes
4964 for ( ii = 0; ii < nbQuantities; ii++ ){
4965 setPreferenceProperty( precs[ii], "min", -14 );
4966 setPreferenceProperty( precs[ii], "max", 14 );
4967 setPreferenceProperty( precs[ii], "precision", 2 );
4970 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4971 setPreferenceProperty( previewGroup, "columns", 2 );
4972 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4973 setPreferenceProperty( chunkSize, "min", 1 );
4974 setPreferenceProperty( chunkSize, "max", 1000 );
4975 setPreferenceProperty( chunkSize, "step", 50 );
4977 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4978 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4980 // Mesh tab ------------------------------------------------------------------------
4981 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4982 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4983 setPreferenceProperty( nodeGroup, "columns", 3 );
4985 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4987 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4989 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4990 QList<QVariant> aMarkerTypeIndicesList;
4991 QList<QVariant> aMarkerTypeIconsList;
4992 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4993 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4994 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4995 aMarkerTypeIndicesList << i;
4996 aMarkerTypeIconsList << pixmap;
4998 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4999 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5001 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5003 QList<QVariant> aMarkerScaleIndicesList;
5004 QStringList aMarkerScaleValuesList;
5005 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5006 aMarkerScaleIndicesList << i;
5007 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5009 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5010 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5012 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5013 //setPreferenceProperty( elemGroup, "columns", 2 );
5015 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5016 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5017 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5018 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5019 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5020 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5021 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5022 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5023 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5026 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5027 setPreferenceProperty( grpGroup, "columns", 2 );
5029 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5030 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5032 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5033 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5034 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5035 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5036 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5037 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5038 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5039 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5040 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5041 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5043 setPreferenceProperty( size0d, "min", 1 );
5044 setPreferenceProperty( size0d, "max", 10 );
5046 setPreferenceProperty( ballSize, "min", 1 );
5047 setPreferenceProperty( ballSize, "max", 10 );
5049 setPreferenceProperty( elemW, "min", 1 );
5050 setPreferenceProperty( elemW, "max", 5 );
5052 setPreferenceProperty( outW, "min", 1 );
5053 setPreferenceProperty( outW, "max", 5 );
5055 setPreferenceProperty( shrink, "min", 0 );
5056 setPreferenceProperty( shrink, "max", 100 );
5058 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5059 setPreferenceProperty( numGroup, "columns", 2 );
5061 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5062 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5064 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5065 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5067 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5068 setPreferenceProperty( orientGroup, "columns", 1 );
5070 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5071 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5073 setPreferenceProperty( orientScale, "min", 0.05 );
5074 setPreferenceProperty( orientScale, "max", 0.5 );
5075 setPreferenceProperty( orientScale, "step", 0.05 );
5077 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5079 // Selection tab ------------------------------------------------------------------------
5080 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5082 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5083 setPreferenceProperty( selGroup, "columns", 2 );
5085 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5086 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5088 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5089 setPreferenceProperty( preGroup, "columns", 2 );
5091 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5093 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5094 setPreferenceProperty( precSelGroup, "columns", 2 );
5096 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5097 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5098 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5100 // Scalar Bar tab ------------------------------------------------------------------------
5101 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5102 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5103 setPreferenceProperty( fontGr, "columns", 2 );
5105 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5106 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5108 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5109 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5111 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5112 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5114 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5115 setPreferenceProperty( numcol, "min", 2 );
5116 setPreferenceProperty( numcol, "max", 256 );
5118 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5119 setPreferenceProperty( numlab, "min", 2 );
5120 setPreferenceProperty( numlab, "max", 65 );
5122 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5123 setPreferenceProperty( orientGr, "columns", 2 );
5124 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5125 QStringList orients;
5126 orients.append( tr( "SMESH_VERTICAL" ) );
5127 orients.append( tr( "SMESH_HORIZONTAL" ) );
5128 indices.clear(); indices.append( 0 ); indices.append( 1 );
5129 setPreferenceProperty( orient, "strings", orients );
5130 setPreferenceProperty( orient, "indexes", indices );
5132 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5133 setPreferenceProperty( posVSizeGr, "columns", 2 );
5134 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5135 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5136 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5137 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5138 setPreferenceProperty( xv, "step", 0.1 );
5139 setPreferenceProperty( xv, "min", 0.0 );
5140 setPreferenceProperty( xv, "max", 1.0 );
5141 setPreferenceProperty( yv, "step", 0.1 );
5142 setPreferenceProperty( yv, "min", 0.0 );
5143 setPreferenceProperty( yv, "max", 1.0 );
5144 setPreferenceProperty( wv, "step", 0.1 );
5145 setPreferenceProperty( wv, "min", 0.0 );
5146 setPreferenceProperty( wv, "max", 1.0 );
5147 setPreferenceProperty( hv, "min", 0.0 );
5148 setPreferenceProperty( hv, "max", 1.0 );
5149 setPreferenceProperty( hv, "step", 0.1 );
5151 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5152 setPreferenceProperty( posHSizeGr, "columns", 2 );
5153 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5154 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5155 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5156 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5157 setPreferenceProperty( xv, "min", 0.0 );
5158 setPreferenceProperty( xv, "max", 1.0 );
5159 setPreferenceProperty( xv, "step", 0.1 );
5160 setPreferenceProperty( xh, "min", 0.0 );
5161 setPreferenceProperty( xh, "max", 1.0 );
5162 setPreferenceProperty( xh, "step", 0.1 );
5163 setPreferenceProperty( yh, "min", 0.0 );
5164 setPreferenceProperty( yh, "max", 1.0 );
5165 setPreferenceProperty( yh, "step", 0.1 );
5166 setPreferenceProperty( wh, "min", 0.0 );
5167 setPreferenceProperty( wh, "max", 1.0 );
5168 setPreferenceProperty( wh, "step", 0.1 );
5169 setPreferenceProperty( hh, "min", 0.0 );
5170 setPreferenceProperty( hh, "max", 1.0 );
5171 setPreferenceProperty( hh, "step", 0.1 );
5173 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5174 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5175 setPreferenceProperty( distributionGr, "columns", 3 );
5177 types.append( tr( "SMESH_MONOCOLOR" ) );
5178 types.append( tr( "SMESH_MULTICOLOR" ) );
5179 indices.clear(); indices.append( 0 ); indices.append( 1 );
5180 setPreferenceProperty( coloringType, "strings", types );
5181 setPreferenceProperty( coloringType, "indexes", indices );
5182 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5186 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5188 if( sect=="SMESH" ) {
5189 float sbX1,sbY1,sbW,sbH;
5190 float aTol = 1.00000009999999;
5191 std::string aWarning;
5192 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5193 if( name=="selection_object_color" || name=="selection_element_color" ||
5194 name=="highlight_color" ||
5195 name=="selection_precision_node" || name=="selection_precision_element" ||
5196 name=="selection_precision_object")
5197 SMESH::UpdateSelectionProp( this );
5198 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5199 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5200 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5201 if(sbX1+sbW > aTol){
5202 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5205 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5206 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5209 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5210 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5211 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5212 if(sbY1+sbH > aTol){
5213 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5214 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5215 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5218 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5219 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5220 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5221 if(sbX1+sbW > aTol){
5222 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5225 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5226 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5229 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5230 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5231 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5232 if(sbY1+sbH > aTol){
5233 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5236 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5237 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5240 else if ( name == "segmentation" ) {
5241 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5242 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5244 else if ( name == "nb_segments_per_edge" ) {
5245 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5246 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5248 else if ( name == "historical_python_dump" ||
5249 name == "forget_mesh_on_hyp_modif") {
5250 QString val = aResourceMgr->stringValue( "SMESH", name );
5251 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5253 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5254 SMESH::UpdateFontProp( this );
5256 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5257 SMESH::UpdateFontProp( this );
5260 if(aWarning.size() != 0){
5261 aWarning += "The default values are applied instead.";
5262 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5263 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5264 QObject::tr(aWarning.c_str()));
5269 //================================================================================
5271 * \brief Update something in accordance with update flags
5272 * \param theFlags - update flags
5274 * Update viewer or/and object browser etc. in accordance with update flags ( see
5275 * LightApp_UpdateFlags enumeration ).
5277 //================================================================================
5278 void SMESHGUI::update( const int flags )
5280 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5281 SMESH::UpdateView();
5283 SalomeApp_Module::update( flags );
5286 //================================================================================
5288 * \brief Set default selection mode
5290 * SLOT called when operation commited. Sets default selection mode
5292 //================================================================================
5293 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5295 SVTK_ViewWindow* vtkWnd =
5296 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5298 vtkWnd->SetSelectionMode( ActorSelection );
5301 //================================================================================
5303 * \brief Set default selection mode
5305 * SLOT called when operation aborted. Sets default selection mode
5307 //================================================================================
5308 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5310 SVTK_ViewWindow* vtkWnd =
5311 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5313 vtkWnd->SetSelectionMode( ActorSelection );
5316 //================================================================================
5318 * \brief Creates operation with given identifier
5319 * \param id - identifier of operation to be started
5320 * \return Pointer on created operation or NULL if operation is not created
5322 * Virtual method redefined from the base class creates operation with given id.
5323 * It is called called automatically from startOperation method of base class.
5325 //================================================================================
5326 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5328 LightApp_Operation* op = 0;
5329 // to do : create operation here
5332 case 417: //convert to quadratic
5333 op = new SMESHGUI_ConvToQuadOp();
5335 case 418: // create 2D mesh as boundary on 3D
5336 op = new SMESHGUI_Make2DFrom3DOp();
5338 case 420: // Reorient faces
5339 op = new SMESHGUI_ReorientFacesOp();
5341 case 701: // Compute mesh
5342 op = new SMESHGUI_ComputeOp();
5344 case 702: // Create mesh
5345 op = new SMESHGUI_MeshOp( true, true );
5347 case 703: // Create sub-mesh
5348 op = new SMESHGUI_MeshOp( true, false );
5350 case 704: // Edit mesh/sub-mesh
5351 op = new SMESHGUI_MeshOp( false );
5353 case 711: // Precompute mesh
5354 op = new SMESHGUI_PrecomputeOp();
5356 case 712: // Evaluate mesh
5357 op = new SMESHGUI_EvaluateOp();
5359 case 713: // Evaluate mesh
5360 op = new SMESHGUI_MeshOrderOp();
5362 case 806: // Create group on geom
5363 op = new SMESHGUI_GroupOnShapeOp();
5365 case 904: // Find element
5366 op = new SMESHGUI_FindElemByPointOp();
5368 case 4067: // Make mesh pass through point
5369 op = new SMESHGUI_MakeNodeAtPointOp();
5371 case 4070: // Create 0D elements on all nodes
5372 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5379 op = SalomeApp_Module::createOperation( id );
5383 //================================================================================
5385 * \brief Stops current operations and starts a given one
5386 * \param id - The id of the operation to start
5388 //================================================================================
5390 void SMESHGUI::switchToOperation(int id)
5392 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5393 activeStudy()->abortAllOperations();
5394 startOperation( id );
5397 LightApp_Displayer* SMESHGUI::displayer()
5400 myDisplayer = new SMESHGUI_Displayer( getApp() );
5404 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5407 int aTolerance = 64;
5408 int anIterations = 0;
5414 if( anIterations % aPeriod == 0 )
5417 if( aTolerance < 1 )
5421 aHue = (int)( 360.0 * rand() / RAND_MAX );
5424 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5425 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5426 for( ; it != itEnd; ++it )
5428 SALOMEDS::Color anAutoColor = *it;
5429 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5432 aQColor.getHsv( &h, &s, &v );
5433 if( abs( h - aHue ) < aTolerance )
5445 aColor.setHsv( aHue, 255, 255 );
5447 SALOMEDS::Color aSColor;
5448 aSColor.R = aColor.redF();
5449 aSColor.G = aColor.greenF();
5450 aSColor.B = aColor.blueF();
5455 const char* gSeparator = "_"; // character used to separate parameter names
5456 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5457 const char* gPathSep = "|"; // character used to separate paths
5460 * \brief Store visual parameters
5462 * This method is called just before the study document is saved.
5463 * Store visual parameters in AttributeParameter attribue(s)
5465 void SMESHGUI::storeVisualParameters (int savePoint)
5468 Kernel_Utils::Localizer loc;
5470 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5471 if (!appStudy || !appStudy->studyDS())
5473 _PTR(Study) studyDS = appStudy->studyDS();
5475 // componentName is used for encoding of entries when storing them in IParameters
5476 std::string componentName = myComponentSMESH->ComponentDataType();
5477 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5478 //if (!aSComponent) return;
5481 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5482 componentName.c_str(),
5484 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5486 // store map of custom markers
5487 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5488 if( !aMarkerMap.empty() )
5490 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5491 for( ; anIter != aMarkerMap.end(); anIter++ )
5493 int anId = anIter->first;
5494 VTK::MarkerData aMarkerData = anIter->second;
5495 std::string aMarkerFileName = aMarkerData.first;
5496 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5497 if( aMarkerTexture.size() < 3 )
5498 continue; // should contain at least width, height and the first value
5500 QString aPropertyName( "texture" );
5501 aPropertyName += gSeparator;
5502 aPropertyName += QString::number( anId );
5504 QString aPropertyValue = aMarkerFileName.c_str();
5505 aPropertyValue += gPathSep;
5507 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5508 ushort aWidth = *aTextureIter++;
5509 ushort aHeight = *aTextureIter++;
5510 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5511 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5512 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5513 aPropertyValue += QString::number( *aTextureIter );
5515 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5519 // viewers counters are used for storing view_numbers in IParameters
5522 // main cycle to store parameters of displayed objects
5523 QList<SUIT_ViewManager*> lst;
5524 QList<SUIT_ViewManager*>::Iterator it;
5525 getApp()->viewManagers(lst);
5526 for (it = lst.begin(); it != lst.end(); it++)
5528 SUIT_ViewManager* vman = *it;
5529 QString vType = vman->getType();
5531 // saving VTK actors properties
5532 if (vType == SVTK_Viewer::Type())
5534 // store the clipping planes attached to the view manager
5535 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5536 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5537 if( anIter != myClippingPlaneInfoMap.end() )
5538 aClippingPlaneInfoList = anIter->second;
5540 if( !aClippingPlaneInfoList.empty() ) {
5541 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5542 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5544 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5545 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5547 QString aPropertyName( "ClippingPlane" );
5548 aPropertyName += gSeparator;
5549 aPropertyName += QString::number( vtkViewers );
5550 aPropertyName += gSeparator;
5551 aPropertyName += QString::number( anId );
5553 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5554 aPropertyValue += gDigitsSep;
5555 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5556 aPropertyValue += gDigitsSep;
5557 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5558 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5559 aPropertyValue += gDigitsSep;
5560 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5561 aPropertyValue += gDigitsSep;
5562 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5563 aPropertyValue += gDigitsSep;
5564 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5565 aPropertyValue += gDigitsSep;
5566 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5567 aPropertyValue += gDigitsSep;
5568 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5569 aPropertyValue += gDigitsSep;
5570 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5572 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5573 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5574 aPropertyValue += gDigitsSep;
5575 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5576 aPropertyValue += gDigitsSep;
5577 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5578 aPropertyValue += gDigitsSep;
5579 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5582 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5586 QVector<SUIT_ViewWindow*> views = vman->getViews();
5587 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5589 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5591 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5592 vtkActorCollection* allActors = aCopy.GetActors();
5593 allActors->InitTraversal();
5594 while (vtkActor* actor = allActors->GetNextActor())
5596 if (actor->GetVisibility()) // store only visible actors
5598 SMESH_Actor* aSmeshActor = 0;
5599 if (actor->IsA("SMESH_Actor"))
5600 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5601 if (aSmeshActor && aSmeshActor->hasIO())
5603 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5606 // entry is "encoded" = it does NOT contain component adress,
5607 // since it is a subject to change on next component loading
5608 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5610 std::string param, vtkParam = vType.toLatin1().data();
5611 vtkParam += gSeparator;
5612 vtkParam += QString::number(vtkViewers).toLatin1().data();
5613 vtkParam += gSeparator;
5616 param = vtkParam + "Visibility";
5617 ip->setParameter(entry, param, "On");
5620 param = vtkParam + "Representation";
5621 ip->setParameter(entry, param, QString::number
5622 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5625 param = vtkParam + "IsShrunk";
5626 ip->setParameter(entry, param, QString::number
5627 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5629 // Displayed entities
5630 unsigned int aMode = aSmeshActor->GetEntityMode();
5631 bool isE = aMode & SMESH_Actor::eEdges;
5632 bool isF = aMode & SMESH_Actor::eFaces;
5633 bool isV = aMode & SMESH_Actor::eVolumes;
5634 bool is0d = aMode & SMESH_Actor::e0DElements;
5635 bool isB = aMode & SMESH_Actor::eBallElem;
5637 QString modeStr ("e");
5638 modeStr += gDigitsSep; modeStr += QString::number(isE);
5639 modeStr += gDigitsSep; modeStr += "f";
5640 modeStr += gDigitsSep; modeStr += QString::number(isF);
5641 modeStr += gDigitsSep; modeStr += "v";
5642 modeStr += gDigitsSep; modeStr += QString::number(isV);
5643 modeStr += gDigitsSep; modeStr += "0d";
5644 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5645 modeStr += gDigitsSep; modeStr += "b";
5646 modeStr += gDigitsSep; modeStr += QString::number(isB);
5648 param = vtkParam + "Entities";
5649 ip->setParameter(entry, param, modeStr.toLatin1().data());
5655 aSmeshActor->GetSufaceColor(r, g, b, delta);
5656 QStringList colorStr;
5657 colorStr << "surface";
5658 colorStr << QString::number(r);
5659 colorStr << QString::number(g);
5660 colorStr << QString::number(b);
5662 colorStr << "backsurface";
5663 colorStr << QString::number(delta);
5665 aSmeshActor->GetVolumeColor(r, g, b, delta);
5666 colorStr << "volume";
5667 colorStr << QString::number(r);
5668 colorStr << QString::number(g);
5669 colorStr << QString::number(b);
5670 colorStr << QString::number(delta);
5672 aSmeshActor->GetEdgeColor(r, g, b);
5674 colorStr << QString::number(r);
5675 colorStr << QString::number(g);
5676 colorStr << QString::number(b);
5678 aSmeshActor->GetNodeColor(r, g, b);
5680 colorStr << QString::number(r);
5681 colorStr << QString::number(g);
5682 colorStr << QString::number(b);
5684 aSmeshActor->GetOutlineColor(r, g, b);
5685 colorStr << "outline";
5686 colorStr << QString::number(r);
5687 colorStr << QString::number(g);
5688 colorStr << QString::number(b);
5690 aSmeshActor->Get0DColor(r, g, b);
5691 colorStr << "elem0d";
5692 colorStr << QString::number(r);
5693 colorStr << QString::number(g);
5694 colorStr << QString::number(b);
5696 aSmeshActor->GetBallColor(r, g, b);
5698 colorStr << QString::number(r);
5699 colorStr << QString::number(g);
5700 colorStr << QString::number(b);
5702 aSmeshActor->GetFacesOrientationColor(r, g, b);
5703 colorStr << "orientation";
5704 colorStr << QString::number(r);
5705 colorStr << QString::number(g);
5706 colorStr << QString::number(b);
5708 param = vtkParam + "Colors";
5709 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5712 QStringList sizeStr;
5714 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5715 sizeStr << "outline";
5716 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5717 sizeStr << "elem0d";
5718 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5720 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5721 sizeStr << "shrink";
5722 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5723 sizeStr << "orientation";
5724 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5725 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5727 param = vtkParam + "Sizes";
5728 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5733 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5734 if( aMarkerType == VTK::MT_USER ) {
5735 markerStr += "custom";
5736 markerStr += gDigitsSep;
5737 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5741 markerStr += gDigitsSep;
5742 markerStr += QString::number( (int)aMarkerType );
5743 markerStr += gDigitsSep;
5744 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5747 param = vtkParam + "PointMarker";
5748 ip->setParameter(entry, param, markerStr.toLatin1().data());
5751 param = vtkParam + "Opacity";
5752 ip->setParameter(entry, param,
5753 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5756 param = vtkParam + "ClippingPlane";
5758 if( !aClippingPlaneInfoList.empty() ) {
5759 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5760 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5762 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5763 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5764 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5765 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5766 if( aSmeshActor == *anIter2 ) {
5767 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5768 QString::number( anId ).toLatin1().constData() );
5775 ip->setParameter( entry, param, "Off" );
5776 } // if (io->hasEntry())
5777 } // SMESH_Actor && hasIO
5779 } // while.. actors traversal
5783 } // if (SVTK view model)
5784 } // for (viewManagers)
5787 // data structures for clipping planes processing
5791 bool isOpenGLClipping;
5792 vtkIdType RelativeOrientation;
5795 int AbsoluteOrientation;
5796 double X, Y, Z, Dx, Dy, Dz;
5798 typedef std::list<TPlaneData> TPlaneDataList;
5799 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5801 typedef std::list<vtkActor*> TActorList;
5804 TActorList ActorList;
5805 SUIT_ViewManager* ViewManager;
5807 typedef std::list<TPlaneInfo> TPlaneInfoList;
5808 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5811 * \brief Restore visual parameters
5813 * This method is called after the study document is opened.
5814 * Restore visual parameters from AttributeParameter attribue(s)
5816 void SMESHGUI::restoreVisualParameters (int savePoint)
5819 Kernel_Utils::Localizer loc;
5821 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5822 if (!appStudy || !appStudy->studyDS())
5824 _PTR(Study) studyDS = appStudy->studyDS();
5826 // componentName is used for encoding of entries when storing them in IParameters
5827 std::string componentName = myComponentSMESH->ComponentDataType();
5828 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5829 //if (!aSComponent) return;
5832 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5833 componentName.c_str(),
5835 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5837 // restore map of custom markers and map of clipping planes
5838 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5839 TPlaneDataMap aPlaneDataMap;
5841 std::vector<std::string> properties = ip->getProperties();
5842 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5844 std::string property = *propIt;
5845 QString aPropertyName( property.c_str() );
5846 QString aPropertyValue( ip->getProperty( property ).c_str() );
5848 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5849 if( aPropertyNameList.isEmpty() )
5852 QString aPropertyType = aPropertyNameList[0];
5853 if( aPropertyType == "texture" )
5855 if( aPropertyNameList.size() != 2 )
5859 int anId = aPropertyNameList[1].toInt( &ok );
5860 if( !ok || anId < 1 )
5863 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5864 if( aPropertyValueList.size() != 2 )
5867 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5868 QString aMarkerTextureString = aPropertyValueList[1];
5869 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5870 if( aMarkerTextureStringList.size() != 3 )
5874 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5879 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5883 VTK::MarkerTexture aMarkerTexture;
5884 aMarkerTexture.push_back( aWidth );
5885 aMarkerTexture.push_back( aHeight );
5887 QString aMarkerTextureData = aMarkerTextureStringList[2];
5888 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5890 QChar aChar = aMarkerTextureData.at( i );
5891 if( aChar.isDigit() )
5892 aMarkerTexture.push_back( aChar.digitValue() );
5895 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5897 else if( aPropertyType == "ClippingPlane" )
5899 if( aPropertyNameList.size() != 3 )
5903 int aViewId = aPropertyNameList[1].toInt( &ok );
5904 if( !ok || aViewId < 0 )
5908 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5909 if( !ok || aClippingPlaneId < 0 )
5912 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5913 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
5916 TPlaneData aPlaneData;
5917 aPlaneData.Id = aClippingPlaneId;
5920 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
5925 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
5929 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
5932 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
5937 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
5942 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
5947 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
5952 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
5957 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
5962 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
5966 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
5968 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
5973 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
5978 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
5983 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
5988 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5989 aPlaneDataList.push_back( aPlaneData );
5993 TPlaneInfoMap aPlaneInfoMap;
5995 std::vector<std::string> entries = ip->getEntries();
5997 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5999 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6000 QString entry (ip->decodeEntry(*entIt).c_str());
6002 // Check that the entry corresponds to a real object in the Study
6003 // as the object may be deleted or modified after the visual state is saved.
6004 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6005 if (!so) continue; //Skip the not existent entry
6007 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6008 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6010 std::vector<std::string>::iterator namesIt = paramNames.begin();
6011 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6013 // actors are stored in a map after displaying of them for
6014 // quicker access in the future: map < viewID to actor >
6015 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6017 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6019 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6020 // '_' is used as separator and should not be used in viewer type or parameter names.
6021 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6022 if (lst.size() != 3)
6025 QString viewerTypStr = lst[0];
6026 QString viewIndexStr = lst[1];
6027 QString paramNameStr = lst[2];
6030 int viewIndex = viewIndexStr.toUInt(&ok);
6031 if (!ok) // bad conversion of view index to integer
6035 if (viewerTypStr == SVTK_Viewer::Type())
6037 SMESH_Actor* aSmeshActor = 0;
6038 if (vtkActors.IsBound(viewIndex))
6039 aSmeshActor = vtkActors.Find(viewIndex);
6041 QList<SUIT_ViewManager*> lst;
6042 getApp()->viewManagers(viewerTypStr, lst);
6044 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6045 SUIT_ViewManager* vman = NULL;
6046 if (viewIndex >= 0 && viewIndex < lst.count())
6047 vman = lst.at(viewIndex);
6049 if (paramNameStr == "Visibility")
6051 if (!aSmeshActor && displayer() && vman)
6053 SUIT_ViewModel* vmodel = vman->getViewModel();
6054 // SVTK view model can be casted to SALOME_View
6055 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6057 // store displayed actor in a temporary map for quicker
6058 // access later when restoring other parameters
6059 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6060 vtkRenderer* Renderer = vtkView->getRenderer();
6061 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6062 vtkActorCollection* theActors = aCopy.GetActors();
6063 theActors->InitTraversal();
6064 bool isFound = false;
6065 vtkActor *ac = theActors->GetNextActor();
6066 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6067 if (ac->IsA("SMESH_Actor")) {
6068 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6069 if (aGeomAc->hasIO()) {
6070 Handle(SALOME_InteractiveObject) io =
6071 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6072 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6074 vtkActors.Bind(viewIndex, aGeomAc);
6080 } // if (paramNameStr == "Visibility")
6083 // the rest properties "work" with SMESH_Actor
6086 QString val ((*valuesIt).c_str());
6089 if (paramNameStr == "Representation") {
6090 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6093 else if (paramNameStr == "IsShrunk") {
6095 if (!aSmeshActor->IsShrunk())
6096 aSmeshActor->SetShrink();
6099 if (aSmeshActor->IsShrunk())
6100 aSmeshActor->UnShrink();
6103 // Displayed entities
6104 else if (paramNameStr == "Entities") {
6105 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6106 int aEntityMode = SMESH_Actor::eAllEntity;
6107 for ( int i = 0; i < mode.count(); i+=2 ) {
6108 if ( i < mode.count()-1 ) {
6109 QString type = mode[i];
6110 bool val = mode[i+1].toInt();
6111 if ( type == "e" && !val )
6112 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6113 else if ( type == "f" && !val )
6114 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6115 else if ( type == "v" && !val )
6116 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6117 else if ( type == "0d" && !val )
6118 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6119 else if ( type == "b" && !val )
6120 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6123 aSmeshActor->SetEntityMode( aEntityMode );
6126 else if (paramNameStr == "Colors") {
6127 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6134 QColor outlineColor;
6135 QColor orientationColor;
6141 // below lines are required to get default values for delta coefficients
6142 // of backface color for faces and color of reversed volumes
6143 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6144 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6145 for ( int i = 0; i < colors.count(); i++ ) {
6146 QString type = colors[i];
6147 if ( type == "surface" ) {
6148 // face color is set by 3 values r:g:b, where
6149 // - r,g,b - is rgb color components
6150 if ( i+1 >= colors.count() ) break; // format error
6151 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6152 if ( i+2 >= colors.count() ) break; // format error
6153 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6154 if ( i+3 >= colors.count() ) break; // format error
6155 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6156 faceColor.setRgbF( r, g, b );
6159 else if ( type == "backsurface" ) {
6160 // backface color can be defined in several ways
6161 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6162 // - in latest versions, it is set as delta coefficient
6163 bool rgbOk = false, deltaOk;
6164 if ( i+1 >= colors.count() ) break; // format error
6165 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6166 int delta = colors[i+1].toInt( &deltaOk );
6168 if ( i+1 < colors.count() ) // index is shifted to 1
6169 g = colors[i+1].toDouble( &rgbOk );
6170 if ( rgbOk ) i++; // shift index
6171 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6172 b = colors[i+1].toDouble( &rgbOk );
6174 // - as currently there's no way to set directly backsurface color as it was before,
6175 // we ignore old dump where r,g,b triple was set
6176 // - also we check that delta parameter is set properly
6177 if ( !rgbOk && deltaOk )
6180 else if ( type == "volume" ) {
6181 // volume color is set by 4 values r:g:b:delta, where
6182 // - r,g,b - is a normal volume rgb color components
6183 // - delta - is a reversed volume color delta coefficient
6184 if ( i+1 >= colors.count() ) break; // format error
6185 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6186 if ( i+2 >= colors.count() ) break; // format error
6187 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6188 if ( i+3 >= colors.count() ) break; // format error
6189 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6190 if ( i+4 >= colors.count() ) break; // format error
6191 int delta = colors[i+4].toInt( &bOk );
6192 if ( !bOk ) break; // format error
6193 volumeColor.setRgbF( r, g, b );
6197 else if ( type == "edge" ) {
6198 // edge color is set by 3 values r:g:b, where
6199 // - r,g,b - is rgb color components
6200 if ( i+1 >= colors.count() ) break; // format error
6201 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6202 if ( i+2 >= colors.count() ) break; // format error
6203 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6204 if ( i+3 >= colors.count() ) break; // format error
6205 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6206 edgeColor.setRgbF( r, g, b );
6209 else if ( type == "node" ) {
6210 // node color is set by 3 values r:g:b, where
6211 // - r,g,b - is rgb color components
6212 if ( i+1 >= colors.count() ) break; // format error
6213 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6214 if ( i+2 >= colors.count() ) break; // format error
6215 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6216 if ( i+3 >= colors.count() ) break; // format error
6217 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6218 nodeColor.setRgbF( r, g, b );
6221 else if ( type == "elem0d" ) {
6222 // 0d element color is set by 3 values r:g:b, where
6223 // - r,g,b - is rgb color components
6224 if ( i+1 >= colors.count() ) break; // format error
6225 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6226 if ( i+2 >= colors.count() ) break; // format error
6227 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6228 if ( i+3 >= colors.count() ) break; // format error
6229 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6230 elem0dColor.setRgbF( r, g, b );
6233 else if ( type == "ball" ) {
6234 // ball color is set by 3 values r:g:b, where
6235 // - r,g,b - is rgb color components
6236 if ( i+1 >= colors.count() ) break; // format error
6237 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6238 if ( i+2 >= colors.count() ) break; // format error
6239 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6240 if ( i+3 >= colors.count() ) break; // format error
6241 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6242 ballColor.setRgbF( r, g, b );
6245 else if ( type == "outline" ) {
6246 // outline color is set by 3 values r:g:b, where
6247 // - r,g,b - is rgb color components
6248 if ( i+1 >= colors.count() ) break; // format error
6249 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6250 if ( i+2 >= colors.count() ) break; // format error
6251 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6252 if ( i+3 >= colors.count() ) break; // format error
6253 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6254 outlineColor.setRgbF( r, g, b );
6257 else if ( type == "orientation" ) {
6258 // orientation color is set by 3 values r:g:b, where
6259 // - r,g,b - is rgb color components
6260 if ( i+1 >= colors.count() ) break; // format error
6261 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6262 if ( i+2 >= colors.count() ) break; // format error
6263 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6264 if ( i+3 >= colors.count() ) break; // format error
6265 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6266 orientationColor.setRgbF( r, g, b );
6271 if ( nodeColor.isValid() )
6272 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6274 if ( edgeColor.isValid() )
6275 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6277 if ( faceColor.isValid() )
6278 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6280 if ( volumeColor.isValid() )
6281 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6282 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6283 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6285 if ( elem0dColor.isValid() )
6286 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6288 if ( ballColor.isValid() )
6289 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6291 if ( outlineColor.isValid() )
6292 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6293 // orientation color
6294 if ( orientationColor.isValid() )
6295 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6298 else if (paramNameStr == "Sizes") {
6299 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6302 int outlineWidth = -1;
6303 int elem0dSize = -1;
6305 double shrinkSize = -1;
6306 double orientationSize = -1;
6307 bool orientation3d = false;
6308 for ( int i = 0; i < sizes.count(); i++ ) {
6309 QString type = sizes[i];
6310 if ( type == "line" ) {
6311 // line (wireframe) width is given as single integer value
6312 if ( i+1 >= sizes.count() ) break; // format error
6313 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6317 if ( type == "outline" ) {
6318 // outline width is given as single integer value
6319 if ( i+1 >= sizes.count() ) break; // format error
6320 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6324 else if ( type == "elem0d" ) {
6325 // 0d element size is given as single integer value
6326 if ( i+1 >= sizes.count() ) break; // format error
6327 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6331 else if ( type == "ball" ) {
6332 // ball size is given as single integer value
6333 if ( i+1 >= sizes.count() ) break; // format error
6334 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6338 else if ( type == "shrink" ) {
6339 // shrink factor is given as single floating point value
6340 if ( i+1 >= sizes.count() ) break; // format error
6341 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6345 else if ( type == "orientation" ) {
6346 // orientation vectors are specified by two values size:3d, where
6347 // - size - is a floating point value specifying scale factor
6348 // - 3d - is a boolean
6349 if ( i+1 >= sizes.count() ) break; // format error
6350 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6351 if ( i+2 >= sizes.count() ) break; // format error
6352 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6353 orientationSize = v1;
6354 orientation3d = (bool)v2;
6358 // line (wireframe) width
6359 if ( lineWidth > 0 )
6360 aSmeshActor->SetLineWidth( lineWidth );
6362 if ( outlineWidth > 0 )
6363 aSmeshActor->SetOutlineWidth( outlineWidth );
6364 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6365 aSmeshActor->SetOutlineWidth( lineWidth );
6367 if ( elem0dSize > 0 )
6368 aSmeshActor->Set0DSize( elem0dSize );
6371 aSmeshActor->SetBallSize( ballSize );
6373 if ( shrinkSize > 0 )
6374 aSmeshActor->SetShrinkFactor( shrinkSize );
6375 // orientation vectors
6376 if ( orientationSize > 0 ) {
6377 aSmeshActor->SetFacesOrientationScale( orientationSize );
6378 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6382 else if (paramNameStr == "PointMarker") {
6383 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6384 if( data.count() >= 2 ) {
6386 int aParam1 = data[1].toInt( &ok );
6388 if( data[0] == "std" && data.count() == 3 ) {
6389 int aParam2 = data[2].toInt( &ok );
6390 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6392 else if( data[0] == "custom" ) {
6393 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6394 if( markerIt != aMarkerMap.end() ) {
6395 VTK::MarkerData aMarkerData = markerIt->second;
6396 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6403 else if (paramNameStr == "Opacity") {
6404 aSmeshActor->SetOpacity(val.toFloat());
6407 else if (paramNameStr.startsWith("ClippingPlane")) {
6408 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6409 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6410 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6411 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6412 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6413 // new format - val looks like "Off" or "0" (plane id)
6414 // (note: in new format "Off" value is used only for consistency,
6415 // so it is processed together with values in old format)
6416 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6417 if( anIsOldFormat ) {
6418 if (paramNameStr == "ClippingPlane1" || val == "Off")
6419 aSmeshActor->RemoveAllClippingPlanes();
6421 QList<SUIT_ViewManager*> lst;
6422 getApp()->viewManagers(viewerTypStr, lst);
6423 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6424 if (viewIndex >= 0 && viewIndex < lst.count()) {
6425 SUIT_ViewManager* vman = lst.at(viewIndex);
6426 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6428 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6430 SMESH::TActorList anActorList;
6431 anActorList.push_back( aSmeshActor );
6432 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6433 aPlane->myViewWindow = vtkView;
6434 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6435 aPlane->PlaneMode = aMode;
6436 bool isOpenGLClipping = ( bool )vals[1].toInt();
6437 aPlane->IsOpenGLClipping = isOpenGLClipping;
6438 if ( aMode == SMESH::Absolute ) {
6439 aPlane->myAbsoluteOrientation = vals[2].toInt();
6440 aPlane->X = vals[3].toFloat();
6441 aPlane->Y = vals[4].toFloat();
6442 aPlane->Z = vals[5].toFloat();
6443 aPlane->Dx = vals[6].toFloat();
6444 aPlane->Dy = vals[7].toFloat();
6445 aPlane->Dz = vals[8].toFloat();
6447 else if ( aMode == SMESH::Relative ) {
6448 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6449 aPlane->myDistance = vals[3].toFloat();
6450 aPlane->myAngle[0] = vals[4].toFloat();
6451 aPlane->myAngle[1] = vals[5].toFloat();
6455 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6456 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6457 aClippingPlaneInfo.Plane = aPlane;
6458 aClippingPlaneInfo.ActorList = anActorList;
6459 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6467 int aPlaneId = val.toInt( &ok );
6468 if( ok && aPlaneId >= 0 ) {
6469 bool anIsDefinedPlane = false;
6470 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6471 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6472 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6473 TPlaneInfo& aPlaneInfo = *anIter;
6474 if( aPlaneInfo.PlaneId == aPlaneId ) {
6475 aPlaneInfo.ActorList.push_back( aSmeshActor );
6476 anIsDefinedPlane = true;
6480 if( !anIsDefinedPlane ) {
6481 TPlaneInfo aPlaneInfo;
6482 aPlaneInfo.PlaneId = aPlaneId;
6483 aPlaneInfo.ActorList.push_back( aSmeshActor );
6484 aPlaneInfo.ViewManager = vman;
6486 // to make the list sorted by plane id
6487 anIter = aPlaneInfoList.begin();
6488 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6489 const TPlaneInfo& aPlaneInfoRef = *anIter;
6490 if( aPlaneInfoRef.PlaneId > aPlaneId )
6493 aPlaneInfoList.insert( anIter, aPlaneInfo );
6498 } // if (aSmeshActor)
6499 } // other parameters than Visibility
6501 } // for names/parameters iterator
6502 } // for entries iterator
6504 // take into account planes with empty list of actors referred to them
6505 QList<SUIT_ViewManager*> aVMList;
6506 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6508 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6509 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6510 int aViewId = aPlaneDataIter->first;
6511 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6512 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6514 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6516 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6517 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6518 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6519 const TPlaneData& aPlaneData = *anIter2;
6520 int aPlaneId = aPlaneData.Id;
6522 bool anIsFound = false;
6523 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6524 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6525 const TPlaneInfo& aPlaneInfo = *anIter3;
6526 if( aPlaneInfo.PlaneId == aPlaneId ) {
6533 TPlaneInfo aPlaneInfo; // ActorList field is empty
6534 aPlaneInfo.PlaneId = aPlaneId;
6535 aPlaneInfo.ViewManager = aViewManager;
6537 // to make the list sorted by plane id
6538 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6539 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6540 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6541 if( aPlaneInfoRef.PlaneId > aPlaneId )
6544 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6550 // add clipping planes to actors according to the restored parameters
6551 // and update the clipping plane map
6552 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6553 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6554 int aViewId = anIter1->first;
6555 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6557 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6558 if( anIter2 == aPlaneDataMap.end() )
6560 const TPlaneDataList& aPlaneDataList = anIter2->second;
6562 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6563 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6564 const TPlaneInfo& aPlaneInfo = *anIter3;
6565 int aPlaneId = aPlaneInfo.PlaneId;
6566 const TActorList& anActorList = aPlaneInfo.ActorList;
6567 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6571 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6575 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6577 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6578 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6579 const TPlaneData& aPlaneData = *anIter4;
6580 if( aPlaneData.Id == aPlaneId ) {
6581 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6582 aPlane->myViewWindow = aViewWindow;
6583 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6584 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6585 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6586 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6587 aPlane->X = aPlaneData.X;
6588 aPlane->Y = aPlaneData.Y;
6589 aPlane->Z = aPlaneData.Z;
6590 aPlane->Dx = aPlaneData.Dx;
6591 aPlane->Dy = aPlaneData.Dy;
6592 aPlane->Dz = aPlaneData.Dz;
6594 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6595 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6596 aPlane->myDistance = aPlaneData.Distance;
6597 aPlane->myAngle[0] = aPlaneData.Angle[0];
6598 aPlane->myAngle[1] = aPlaneData.Angle[1];
6601 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6602 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6603 aClippingPlaneInfo.Plane = aPlane;
6604 aClippingPlaneInfo.ActorList = anActorList;
6605 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6616 // update all VTK views
6617 QList<SUIT_ViewManager*> lst;
6618 getApp()->viewManagers(lst);
6619 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6620 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6621 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6622 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6623 // set OpenGL clipping planes
6624 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6625 vtkActorCollection* anAllActors = aCopy.GetActors();
6626 anAllActors->InitTraversal();
6627 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6628 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6629 anActor->SetOpenGLClippingPlane();
6631 vtkView->getRenderer()->ResetCameraClippingRange();
6638 \brief Adds preferences for dfont of VTK viewer
6640 \param pIf group identifier
6641 \param param parameter
6642 \return identifier of preferences
6644 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6646 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6648 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6651 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6652 fam.append( tr( "SMESH_FONT_COURIER" ) );
6653 fam.append( tr( "SMESH_FONT_TIMES" ) );
6655 setPreferenceProperty( tfont, "fonts", fam );
6657 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6658 if ( needSize ) f = f | QtxFontEdit::Size;
6659 setPreferenceProperty( tfont, "features", f );
6665 \brief Actions after hypothesis edition
6666 Updates object browser after hypothesis edition
6668 void SMESHGUI::onHypothesisEdit( int result )
6671 SMESHGUI::Modified();
6672 updateObjBrowser( true );
6677 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6678 \param pview view being closed
6680 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6681 #ifndef DISABLE_PLOT2DVIEWER
6682 //Crear all Plot2d Viewers if need.
6683 SMESH::ClearPlot2Viewers(pview);
6687 void SMESHGUI::message( const QString& msg )
6690 QStringList data = msg.split("/");
6691 if ( data.count() > 0 ) {
6692 if ( data.first() == "mesh_loading" ) {
6694 QString entry = data.count() > 1 ? data[1] : QString();
6695 if ( entry.isEmpty() )
6698 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6700 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6703 name = obj->GetName().c_str();
6704 if ( name.isEmpty() )
6707 if ( data.last() == "stop" )
6708 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6710 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6711 QApplication::processEvents();
6717 \brief Connects or disconnects signals about activating and cloning view on the module slots
6718 \param pview view which is connected/disconnected
6720 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6724 SUIT_ViewManager* viewMgr = pview->getViewManager();
6726 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6727 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6729 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6730 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6735 \brief Return \c true if object can be renamed
6737 bool SMESHGUI::renameAllowed( const QString& entry) const {
6738 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6742 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6746 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6751 if(appStudy->isComponent(entry) || obj->isReference())
6754 // check type to prevent renaming of inappropriate objects
6755 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6756 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6757 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6758 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6759 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6760 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6767 Rename object by entry.
6768 \param entry entry of the object
6769 \param name new name of the object
6770 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6772 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6774 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6778 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6783 _PTR(Study) aStudy = appStudy->studyDS();
6788 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6790 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6795 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6796 _PTR(GenericAttribute) anAttr;
6797 _PTR(AttributeName) aName;
6799 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6801 // check type to prevent renaming of inappropriate objects
6802 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6803 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6804 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6805 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6806 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6807 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6808 if ( !name.isEmpty() ) {
6809 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6811 // update name of group object and its actor
6812 Handle(SALOME_InteractiveObject) IObject =
6813 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6815 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6816 if( !aGroupObject->_is_nil() ) {
6817 aGroupObject->SetName( qPrintable(name) );
6818 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6819 anActor->setName( qPrintable(name) );
6829 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6831 static QList<QColor> colors;
6833 if ( colors.isEmpty() ) {
6835 for (int s = 0; s < 2 ; s++)
6837 for (int v = 100; v >= 40; v = v - 20)
6839 for (int h = 0; h < 359 ; h = h + 60)
6841 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6846 static int currentColor = 0;
6848 SALOMEDS::Color color;
6849 color.R = (double)colors[currentColor].red() / 255.0;
6850 color.G = (double)colors[currentColor].green() / 255.0;
6851 color.B = (double)colors[currentColor].blue() / 255.0;
6853 currentColor = (currentColor+1) % colors.count();