1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
68 #include "SMESHGUI_PropertiesDlg.h"
69 #include "SMESHGUI_RemoveElementsDlg.h"
70 #include "SMESHGUI_RemoveNodesDlg.h"
71 #include "SMESHGUI_RenumberingDlg.h"
72 #include "SMESHGUI_ReorientFacesDlg.h"
73 #include "SMESHGUI_RevolutionDlg.h"
74 #include "SMESHGUI_RotationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_Selection.h"
77 #include "SMESHGUI_SewingDlg.h"
78 #include "SMESHGUI_SingleEditDlg.h"
79 #include "SMESHGUI_SmoothingDlg.h"
80 #include "SMESHGUI_SymmetryDlg.h"
81 #include "SMESHGUI_TranslationDlg.h"
82 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
87 #include "SMESHGUI_MeshUtils.h"
88 #include "SMESHGUI_PatternUtils.h"
89 #include "SMESHGUI_Utils.h"
90 #include "SMESHGUI_VTKUtils.h"
92 #include <SMESH_version.h>
94 #include "SMESH_ControlsDef.hxx"
95 #include <SMESH_Actor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_Client.hxx>
98 #include <SMESH_ScalarBarActor.h>
99 #include <SMESH_TypeFilter.hxx>
101 // SALOME GUI includes
102 #include <SalomeApp_Application.h>
103 #include <SalomeApp_CheckFileDlg.h>
104 #include <SalomeApp_DataObject.h>
105 #include <SalomeApp_Study.h>
106 #include <SalomeApp_Tools.h>
108 #include <LightApp_DataOwner.h>
109 #include <LightApp_NameDlg.h>
110 #include <LightApp_Preferences.h>
111 #include <LightApp_SelectionMgr.h>
112 #include <LightApp_UpdateFlags.h>
114 #include <SVTK_ViewManager.h>
115 #include <SVTK_ViewModel.h>
116 #include <SVTK_ViewWindow.h>
118 #include <VTKViewer_Algorithm.h>
120 #include <PyInterp_Interp.h>
122 #include <SUIT_Desktop.h>
123 #include <SUIT_FileDlg.h>
124 #include <SUIT_MessageBox.h>
125 #include <SUIT_OverrideCursor.h>
126 #include <SUIT_ResourceMgr.h>
127 #include <SUIT_Session.h>
129 #include <QtxPopupMgr.h>
130 #include <QtxFontEdit.h>
132 #include <SALOME_ListIO.hxx>
133 #include <SALOME_ListIteratorOfListIO.hxx>
135 #ifndef DISABLE_PLOT2DVIEWER
136 #include <SPlot2d_ViewModel.h>
137 #include <SPlot2d_Histogram.h>
141 #include <SALOMEconfig.h>
142 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
143 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
144 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QTextStream>
153 #include <boost/shared_ptr.hpp>
156 #include <vtkCallbackCommand.h>
157 #include <vtkCamera.h>
158 #include <vtkLookupTable.h>
159 #include <vtkPlane.h>
160 #include <vtkRenderer.h>
162 // SALOME KERNEL includes
163 #include <SALOMEDSClient_ClientFactory.hxx>
164 #include <SALOMEDSClient_IParameters.hxx>
165 #include <SALOMEDSClient_SComponent.hxx>
166 #include <SALOMEDSClient_StudyBuilder.hxx>
167 #include <SALOMEDS_Study.hxx>
168 #include <SALOMEDS_SObject.hxx>
171 #include <Standard_ErrorHandler.hxx>
172 #include <NCollection_DataMap.hxx>
174 #include <Basics_Utils.hxx>
176 //To disable automatic genericobj management, the following line should be commented.
177 //Otherwise, it should be uncommented.
178 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
179 #define WITHGENERICOBJ
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
185 // REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1
186 #include <vtkMatplotlibMathTextUtilities.h>
189 // Creation of this class disables vtkMatplotlibMathTextUtilities
190 struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities
192 MPLMathText_Disabler()
194 vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
195 vtkMatplotlibMathTextUtilities::UNAVAILABLE;
203 //=============================================================
204 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
207 void ExportMeshToFile(int theCommandID);
209 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
211 void SetDisplayEntity(int theCommandID);
213 void Control( int theCommandID );
216 //================================================================================
218 * \brief Reads meshes from file
220 //================================================================================
222 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
226 std::string myExtension;
228 if ( theCommandID == 113 ) {
229 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
230 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
232 else if ( theCommandID == 112 ) {
233 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
235 else if ( theCommandID == 111 ) {
236 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
238 else if ( theCommandID == 115 ) {
239 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
241 else if ( theCommandID == 116 ) {
242 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
244 else if ( theCommandID == 117 ) {
245 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
246 filter.append( QObject::tr( "All files (*)" ) );
248 else if ( theCommandID == 118 ) {
249 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
250 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
253 QString anInitialPath = "";
254 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
255 anInitialPath = QDir::currentPath();
257 QStringList filenames;
258 bool toCreateGroups = true;
260 // if ( theCommandID == 118 ) { // GMF
261 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
262 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
263 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
264 // fd->setNameFilters( filter );
265 // fd->SetChecked( true );
267 // filenames << fd->selectedFile();
268 // toCreateGroups = fd->IsChecked();
274 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_IMPORT_MESH" ) );
279 if ( filenames.count() > 0 ) {
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
287 QString filename = *it;
288 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
290 switch ( theCommandID ) {
293 // DAT format (currently unsupported)
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
301 aMeshes->length( 1 );
302 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
303 if ( aMeshes[0]->_is_nil() )
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 SMESH::DriverMED_ReadStatus res;
312 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
313 if ( res != SMESH::DRS_OK ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
322 aMeshes->length( 1 );
323 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
324 if ( aMeshes[0]->_is_nil() ) {
325 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
326 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
333 SMESH::DriverMED_ReadStatus res;
334 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
335 if ( res != SMESH::DRS_OK ) {
336 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
337 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 SMESH::DriverMED_ReadStatus res;
345 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
346 if ( res != SMESH::DRS_OK ) {
347 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
348 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
355 SMESH::ComputeError_var res;
356 aMeshes->length( 1 );
357 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
360 if ( res->code != SMESH::DRS_OK ) {
361 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
362 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
363 if ( strlen( res->comment.in() ) > 0 ) {
364 errors.back() += ": ";
365 errors.back() += res->comment.in();
372 catch ( const SALOME::SALOME_Exception& S_ex ) {
373 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
374 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
377 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
378 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
380 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
381 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
382 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
383 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
384 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
386 anEntryList.append( aMeshSO->GetID().c_str() );
394 // update Object browser
395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
397 // browse to the published meshes
398 if( LightApp_Application* anApp =
399 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
400 anApp->browseObjects( anEntryList );
402 // show Error message box if there were errors
403 if ( errors.count() > 0 ) {
404 SUIT_MessageBox::critical( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_ERROR" ),
406 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
409 // show warning message box, if some imported mesh is empty
411 SUIT_MessageBox::warning( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_WRN_WARNING" ),
413 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
418 //================================================================================
420 * \brief Export selected meshes or groups into a file
422 //================================================================================
424 void ExportMeshToFile( int theCommandID )
426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
427 SALOME_ListIO selected;
429 aSel->selectedObjects( selected );
431 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
432 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
433 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
434 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
435 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
436 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
437 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
439 // actually, the following condition can't be met (added for insurance)
440 if( selected.Extent() == 0 ||
441 ( selected.Extent() > 1 && !isMED && !isSTL ))
444 // get mesh object from selection and check duplication of their names
445 bool hasDuplicatedMeshNames = false;
446 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
448 SALOME_ListIteratorOfListIO It( selected );
449 for( ; It.More(); It.Next() )
451 Handle(SALOME_InteractiveObject) anIObject = It.Value();
452 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
453 if ( aMeshItem->_is_nil() ) {
454 SUIT_MessageBox::warning( SMESHGUI::desktop(),
455 QObject::tr( "SMESH_WRN_WARNING" ),
456 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
460 QString aMeshName = anIObject->getName();
462 // check for name duplications
463 if ( !hasDuplicatedMeshNames )
464 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
465 if( aMeshName == (*aMeshIter).second ) {
466 hasDuplicatedMeshNames = true;
471 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
474 if( hasDuplicatedMeshNames && isMED ) {
475 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
476 QObject::tr("SMESH_WRN_WARNING"),
477 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
478 QObject::tr("SMESH_BUT_YES"),
479 QObject::tr("SMESH_BUT_NO"), 0, 1);
484 aMeshIter = aMeshList.begin();
485 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
486 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
487 QString aMeshName = (*aMeshIter).second;
489 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
491 // check for equal group names within each mesh
492 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
493 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
494 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
495 int aRet = SUIT_MessageBox::warning
496 (SMESHGUI::desktop(),
497 QObject::tr("SMESH_WRN_WARNING"),
498 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
499 QObject::tr("SMESH_BUT_YES"),
500 QObject::tr("SMESH_BUT_NO"), 0, 1);
507 // Warn the user about presence of not supported elements
509 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
513 notSupportedElemTypes.push_back( SMESH::Entity_0D );
514 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
519 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
520 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
522 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
523 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
524 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
525 notSupportedElemTypes.push_back( SMESH::Entity_0D );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
532 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
533 notSupportedElemTypes.push_back( SMESH::Entity_0D );
534 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
539 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
540 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
546 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
547 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
548 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
549 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
556 notSupportedElemTypes.push_back( SMESH::Entity_0D );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
559 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
561 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
562 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
563 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 if ( ! notSupportedElemTypes.empty() )
568 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
569 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
570 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
571 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
573 if ( !presentNotSupported.empty() )
576 const char* typeMsg[SMESH::Entity_Last] = {
577 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
578 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
579 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
580 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
581 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
582 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
583 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
584 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
586 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
587 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
588 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
589 if ( iType != presentNotSupported.size() - 1 )
590 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
592 int aRet = SUIT_MessageBox::warning
593 (SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
596 QObject::tr("SMESH_BUT_YES"),
597 QObject::tr("SMESH_BUT_NO"), 0, 1);
602 // Get parameters of export operation
605 SMESH::MED_VERSION aFormat;
606 // Init the parameters with the default values
607 bool aIsASCII_STL = true;
608 bool toCreateGroups = false;
609 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
611 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
612 bool toOverwrite = true;
613 bool toFindOutDim = true;
615 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
616 QString anInitialPath = "";
617 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
618 anInitialPath = QDir::currentPath();
620 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
622 // Get a file name to write in and additional otions
623 if ( isUNV || isDAT || isGMF ) // Export w/o options
626 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
628 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
630 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
631 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
632 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
633 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
634 anInitialPath + QString("/") + aMeshName,
635 aFilter, aTitle, false);
637 else if ( isCGNS )// Export to CGNS
639 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
640 fd->setWindowTitle( aTitle );
641 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
642 if ( !anInitialPath.isEmpty() )
643 fd->setDirectory( anInitialPath );
644 fd->selectFile(aMeshName);
645 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
646 fd->setValidator( fv );
649 aFilename = fd->selectedFile();
650 toOverwrite = fv->isOverwrite();
654 else if ( isSTL ) // Export to STL
656 QMap<QString, int> aFilterMap;
657 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
658 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
661 QMap<QString, int>::const_iterator it = aFilterMap.begin();
662 for ( ; it != aFilterMap.end(); ++it )
663 filters.push_back( it.key() );
665 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
666 fd->setWindowTitle( aTitle );
667 fd->setNameFilters( filters );
668 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
669 if ( !anInitialPath.isEmpty() )
670 fd->setDirectory( anInitialPath );
671 fd->selectFile(aMeshName);
675 aFilename = fd->selectedFile();
676 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
681 else if ( isMED || isSAUV ) // Export to MED or SAUV
683 QMap<QString, SMESH::MED_VERSION> aFilterMap;
684 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
686 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
687 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
688 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
691 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
692 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
693 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
697 QString aDefaultFilter;
698 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
699 for ( ; it != aFilterMap.end(); ++it ) {
700 filters.push_back( it.key() );
701 if (it.value() == SMESH::MED_V2_2)
702 aDefaultFilter = it.key();
704 QStringList checkBoxes;
705 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
707 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
708 QList< QWidget* > wdgList;
709 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
710 wdgList.append( fieldSelWdg );
712 SalomeApp_CheckFileDlg* fd =
713 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
714 fd->setWindowTitle( aTitle );
715 fd->setNameFilters( filters );
716 fd->selectNameFilter( aDefaultFilter );
717 fd->SetChecked( toCreateGroups, 0 );
718 fd->SetChecked( toFindOutDim, 1 );
719 if ( !anInitialPath.isEmpty() )
720 fd->setDirectory( anInitialPath );
721 fd->selectFile(aMeshName);
723 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
724 fd->setValidator( fv );
729 aFilename = fd->selectedFile();
731 aFilename = QString::null;
734 aFormat = aFilterMap[fd->selectedNameFilter()];
735 toOverwrite = fv->isOverwrite();
737 if ( !aFilename.isEmpty() ) {
738 // med-2.1 does not support poly elements
739 if ( aFormat==SMESH::MED_V2_1 )
740 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
741 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
742 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
743 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
744 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
746 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
747 QObject::tr("SMESH_WRN_WARNING"),
748 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
749 QObject::tr("SMESH_BUT_YES"),
750 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 // can't append to an existing using other format
759 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
760 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
761 if( !isVersionOk || aVersion != aFormat ) {
762 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
763 QObject::tr("SMESH_WRN_WARNING"),
764 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
765 QObject::tr("SMESH_BUT_YES"),
766 QObject::tr("SMESH_BUT_NO"), 0, 1);
773 QStringList aMeshNamesCollisionList;
774 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
775 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
776 QString anExistingMeshName( aMeshNames[ i ] );
777 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
778 QString anExportMeshName = (*aMeshIter).second;
779 if( anExportMeshName == anExistingMeshName ) {
780 aMeshNamesCollisionList.append( anExportMeshName );
785 if( !aMeshNamesCollisionList.isEmpty() ) {
786 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
787 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
788 QObject::tr("SMESH_WRN_WARNING"),
789 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
790 QObject::tr("SMESH_BUT_YES"),
791 QObject::tr("SMESH_BUT_NO"),
792 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
801 toCreateGroups = fd->IsChecked(0);
802 toFindOutDim = fd->IsChecked(1);
803 fieldSelWdg->GetSelectedFeilds();
804 if ( !fieldSelWdg->parent() )
815 if ( !aFilename.isEmpty() ) {
816 // Check whether the file already exists and delete it if yes
817 QFile aFile( aFilename );
818 if ( aFile.exists() && toOverwrite )
820 SUIT_OverrideCursor wc;
823 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
824 // bool Renumber = false;
825 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
827 // Renumber= resMgr->booleanValue("renumbering");
829 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
830 // aMeshEditor->RenumberNodes();
831 // aMeshEditor->RenumberElements();
832 // if ( SMESHGUI::automaticUpdate() )
833 // SMESH::UpdateView();
837 aMeshIter = aMeshList.begin();
838 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
840 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
841 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
842 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
843 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
844 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
845 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
846 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
847 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
849 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
850 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
851 fields, geoAssFields.toLatin1().data() );
856 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
858 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
859 if( !aMeshItem->_is_nil() )
860 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
865 if ( aMeshOrGroup->_is_equivalent( aMesh ))
866 aMesh->ExportDAT( aFilename.toUtf8().data() );
868 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
872 if ( aMeshOrGroup->_is_equivalent( aMesh ))
873 aMesh->ExportUNV( aFilename.toUtf8().data() );
875 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
879 if ( aMeshOrGroup->_is_equivalent( aMesh ))
880 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
882 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
886 aMeshIter = aMeshList.begin();
887 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
889 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
890 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
891 aMeshItem->ExportCGNS( aMeshOrGroup,
892 aFilename.toUtf8().data(),
893 toOverwrite && aMeshIndex == 0 );
898 toCreateGroups = true;
899 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
902 catch (const SALOME::SALOME_Exception& S_ex){
904 SUIT_MessageBox::warning(SMESHGUI::desktop(),
905 QObject::tr("SMESH_WRN_WARNING"),
906 QObject::tr("SMESH_EXPORT_FAILED"));
912 inline void InverseEntityMode(unsigned int& theOutputMode,
913 unsigned int theMode)
915 bool anIsNotPresent = ~theOutputMode & theMode;
917 theOutputMode |= theMode;
919 theOutputMode &= ~theMode;
922 void SetDisplayEntity(int theCommandID){
923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
924 SALOME_ListIO selected;
926 aSel->selectedObjects( selected );
928 if(selected.Extent() >= 1){
929 SALOME_ListIteratorOfListIO It( selected );
930 for( ; It.More(); It.Next()){
931 Handle(SALOME_InteractiveObject) IObject = It.Value();
932 if(IObject->hasEntry()){
933 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
934 unsigned int aMode = anActor->GetEntityMode();
935 switch(theCommandID){
937 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
940 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
943 InverseEntityMode(aMode,SMESH_Actor::eEdges);
946 InverseEntityMode(aMode,SMESH_Actor::eFaces);
949 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
952 aMode = SMESH_Actor::eAllEntity;
956 anActor->SetEntityMode(aMode);
965 SALOME_ListIO selected;
966 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
970 LightApp_SelectionMgr* aSel = app->selectionMgr();
971 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
972 if( !aSel || !appStudy )
975 aSel->selectedObjects( selected );
976 if( selected.IsEmpty() )
979 Handle(SALOME_InteractiveObject) anIObject = selected.First();
981 _PTR(Study) aStudy = appStudy->studyDS();
982 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
983 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
984 if( aMainObject->_is_nil() )
987 SUIT_OverrideCursor wc;
989 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
991 QList<SALOMEDS::Color> aReservedColors;
993 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
994 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
996 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
997 //SALOMEDS::Color aColor = aGroupObject->GetColor();
999 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1000 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1001 #else // old algorithm for auto-colors
1002 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1003 aReservedColors.append( aColor );
1004 #endif // SIMPLE_AUTOCOLOR
1005 aGroupObject->SetColor( aColor );
1007 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1008 if (aGroupSObject) {
1011 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1012 switch ( aGroupObject->GetType ()) {
1014 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1016 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1018 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1020 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1022 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1023 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1026 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1027 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1033 SMESH::RepaintCurrentView();
1036 void OverallMeshQuality() {
1037 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1039 SALOME_ListIO selected;
1041 aSel->selectedObjects( selected );
1043 if ( selected.IsEmpty() ) return;
1044 SALOME_ListIteratorOfListIO It( selected );
1045 for ( ; It.More(); It.Next() ) {
1046 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1047 ctrlDlg->showInfo( It.Value() );
1052 QString functorToString( SMESH::Controls::FunctorPtr f )
1054 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1055 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1056 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1057 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1058 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1059 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1060 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1061 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1062 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1064 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1065 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1066 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1067 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1068 type = QObject::tr( "WARP_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1070 type = QObject::tr( "TAPER_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1072 type = QObject::tr( "SKEW_ELEMENTS" );
1073 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1074 type = QObject::tr( "AREA_ELEMENTS" );
1075 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1076 type = QObject::tr( "LENGTH_EDGES" );
1077 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1078 type = QObject::tr( "LENGTH2D_EDGES" );
1079 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1080 type = QObject::tr( "MULTI_BORDERS" );
1081 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1082 type = QObject::tr( "MULTI2D_BORDERS" );
1083 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1084 type = QObject::tr( "FREE_NODES" );
1085 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1086 type = QObject::tr( "FREE_EDGES" );
1087 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1088 type = QObject::tr( "FREE_BORDERS" );
1089 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1090 type = QObject::tr( "FREE_FACES" );
1091 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1092 type = QObject::tr( "BARE_BORDER_VOLUME" );
1093 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1094 type = QObject::tr( "BARE_BORDER_FACE" );
1095 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1096 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1097 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1098 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1099 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1100 type = QObject::tr( "EQUAL_NODE" );
1101 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1102 type = QObject::tr( "EQUAL_EDGE" );
1103 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1104 type = QObject::tr( "EQUAL_FACE" );
1105 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1106 type = QObject::tr( "EQUAL_VOLUME" );
1110 void SaveDistribution()
1112 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1113 SALOME_ListIO selected;
1115 aSel->selectedObjects( selected );
1117 if ( selected.Extent() == 1 ) {
1118 Handle(SALOME_InteractiveObject) anIO = selected.First();
1119 if ( anIO->hasEntry() ) {
1120 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1121 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1122 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1123 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1124 if ( aScalarBarActor && aFunctor ) {
1125 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1127 std::vector<int> elements;
1128 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1129 if ( mesh->_is_nil() ) {
1130 SMESH::SMESH_IDSource_var idSource =
1131 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1132 if ( !idSource->_is_nil() )
1134 SMESH::long_array_var ids = idSource->GetIDs();
1135 elements.resize( ids->length() );
1136 for ( unsigned i = 0; i < elements.size(); ++i )
1137 elements[i] = ids[i];
1140 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1141 vtkLookupTable* lookupTable =
1142 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1143 double * minmax = lookupTable->GetRange();
1144 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1145 std::vector<int> nbEvents;
1146 std::vector<double> funValues;
1147 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1148 QString anInitialPath = "";
1149 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1150 anInitialPath = QDir::currentPath();
1151 QString aMeshName = anIO->getName();
1153 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1154 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1155 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1156 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1157 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1160 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1162 if ( !aFilename.isEmpty() ) {
1163 QFile f( aFilename );
1164 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1165 QTextStream out( &f );
1166 out << "# Mesh: " << aMeshName << endl;
1167 out << "# Control: " << functorToString( aFunctor ) << endl;
1169 out.setFieldWidth( 10 );
1170 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1171 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1182 void ShowDistribution() {
1183 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1184 SALOME_ListIO selected;
1186 aSel->selectedObjects( selected );
1188 if ( selected.Extent() == 1 ) {
1189 Handle(SALOME_InteractiveObject) anIO = selected.First();
1190 if ( anIO->hasEntry() ) {
1191 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1192 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1193 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1194 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1200 #ifndef DISABLE_PLOT2DVIEWER
1201 void PlotDistribution() {
1202 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1206 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1207 SALOME_ListIO selected;
1209 aSel->selectedObjects( selected );
1211 if ( selected.Extent() == 1 ) {
1212 Handle(SALOME_InteractiveObject) anIO = selected.First();
1213 if ( anIO->hasEntry() ) {
1214 //Find Actor by entry before getting Plot2d viewer,
1215 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1216 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1218 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1223 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1227 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1231 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1232 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1233 QString functorName = functorToString( anActor->GetFunctor());
1234 QString aHistogramName("%1 : %2");
1235 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1236 aHistogram->setName(aHistogramName);
1237 aHistogram->setHorTitle(functorName);
1238 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1239 aPlot->displayObject(aHistogram, true);
1244 #endif //DISABLE_PLOT2DVIEWER
1246 void DisableAutoColor(){
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if(selected.Extent()){
1253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1254 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1255 if ( !aMesh->_is_nil() ) {
1256 aMesh->SetAutoColor( false );
1261 void sortChildren(){
1262 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1263 SALOME_ListIO selected;
1265 aSel->selectedObjects( selected );
1267 if(selected.Extent()){
1268 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1269 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1270 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1272 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1273 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1280 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1282 SALOME_ListIO selected;
1283 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1287 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1288 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1289 if( !aSel || !appStudy )
1292 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1293 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1294 aModule->EmitSignalDeactivateDialog();
1295 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1296 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1301 _PTR(Study) aStudy = appStudy->studyDS();
1303 aSel->selectedObjects( selected );
1305 if(selected.Extent() >= 1){
1306 switch(theCommandID){
1308 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1309 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1314 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1315 QColor orientationColor, outlineColor, volumeColor;
1316 int deltaF = 0, deltaV = 0;
1320 int outlineWidth = 1;
1321 double shrinkCoef = 0.0;
1322 double orientationScale = 0.0;
1323 bool orientation3d = false;
1324 VTK::MarkerType markerType = VTK::MT_NONE;
1325 VTK::MarkerScale markerScale = VTK::MS_NONE;
1327 bool hasNodes = false;
1328 int presentEntities = 0;
1329 bool firstTime = true;
1331 SALOME_ListIteratorOfListIO It( selected );
1332 for ( ; It.More(); It.Next() ) {
1333 Handle(SALOME_InteractiveObject) IObject = It.Value();
1334 if ( !IObject->hasEntry() ) continue;
1335 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1336 if ( !anActor || !anActor->GetObject() ) continue;
1339 // nodes: color, marker
1340 anActor->GetNodeColor( color[0], color[1], color[2] );
1341 nodeColor.setRgbF( color[0], color[1], color[2] );
1342 markerType = anActor->GetMarkerType();
1343 markerScale = anActor->GetMarkerScale();
1344 markerId = anActor->GetMarkerTexture();
1345 // edges: color, width
1346 anActor->GetEdgeColor( color[0], color[1], color[2] );
1347 edgeColor.setRgbF( color[0], color[1], color[2] );
1348 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1349 // faces: front color, back color (delta)
1350 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1351 faceColor.setRgbF( color[0], color[1], color[2] );
1352 // faces: front color, back color (delta)
1353 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1354 volumeColor.setRgbF( color[0], color[1], color[2] );
1355 // 0d elements: color, size
1356 anActor->Get0DColor( color[0], color[1], color[2] );
1357 elem0dColor.setRgbF( color[0], color[1], color[2] );
1358 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1359 // balls: color, size
1360 anActor->GetBallColor( color[0], color[1], color[2] );
1361 ballColor.setRgbF( color[0], color[1], color[2] );
1362 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1364 anActor->GetOutlineColor( color[0], color[1], color[2] );
1365 outlineColor.setRgbF( color[0], color[1], color[2] );
1366 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1367 // orientation vectors: color, scale, 3d flag
1368 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1369 orientationColor.setRgbF( color[0], color[1], color[2] );
1370 orientationScale = anActor->GetFacesOrientationScale();
1371 orientation3d = anActor->GetFacesOrientation3DVectors();
1373 shrinkCoef = anActor->GetShrinkFactor();
1376 firstTime = false; // we only take properties from first object (for performance reasons)
1379 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1380 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1381 presentEntities = presentEntities | SMESH_Actor::eEdges;
1382 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1383 presentEntities = presentEntities | SMESH_Actor::eFaces;
1384 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1385 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1386 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1387 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1388 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1389 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1391 // as we know that all types of elements are present, we can exit the loop
1392 if ( presentEntities == SMESH_Actor::eAllEntity )
1396 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1397 // nodes: color, marker
1398 dlg.setNodeColor( nodeColor );
1399 if( markerType != VTK::MT_USER )
1400 dlg.setNodeMarker( markerType, markerScale );
1402 dlg.setNodeCustomMarker( markerId );
1403 // edges: color, line width
1404 dlg.setEdgeColor( edgeColor );
1405 dlg.setEdgeWidth( edgeWidth );
1406 // faces: front color, back color
1407 dlg.setFaceColor( faceColor, deltaF );
1408 // volumes: normal color, reversed color
1409 dlg.setVolumeColor( volumeColor, deltaV );
1410 // outlines: color, line width
1411 dlg.setOutlineColor( outlineColor );
1412 dlg.setOutlineWidth( outlineWidth );
1413 // 0d elements: color, size
1414 dlg.setElem0dColor( elem0dColor );
1415 dlg.setElem0dSize( elem0dSize );
1416 // balls: color, size
1417 dlg.setBallColor( ballColor );
1418 dlg.setBallSize( ballSize );
1419 // orientation: color, scale, 3d flag
1420 dlg.setOrientationColor( orientationColor );
1421 dlg.setOrientationSize( int( orientationScale * 100. ) );
1422 dlg.setOrientation3d( orientation3d );
1423 // shrink: scale factor
1424 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1425 // hide unused controls
1426 dlg.showControls( presentEntities, hasNodes );
1429 nodeColor = dlg.nodeColor();
1430 markerType = dlg.nodeMarkerType();
1431 markerScale = dlg.nodeMarkerScale();
1432 markerId = dlg.nodeMarkerId();
1433 edgeColor = dlg.edgeColor();
1434 edgeWidth = dlg.edgeWidth();
1435 faceColor = dlg.faceColor();
1436 deltaF = dlg.faceColorDelta();
1437 volumeColor = dlg.volumeColor();
1438 deltaV = dlg.volumeColorDelta();
1439 outlineColor = dlg.outlineColor();
1440 outlineWidth = dlg.outlineWidth();
1441 elem0dColor = dlg.elem0dColor();
1442 elem0dSize = dlg.elem0dSize();
1443 ballColor = dlg.ballColor();
1444 ballSize = dlg.ballSize();
1445 orientationColor = dlg.orientationColor();
1446 orientationScale = dlg.orientationSize() / 100.;
1447 orientation3d = dlg.orientation3d();
1448 shrinkCoef = dlg.shrinkCoef() / 100.;
1450 // store point markers map that might be changed by the user
1451 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1453 // set properties from dialog box to the presentations
1454 SALOME_ListIteratorOfListIO It( selected );
1455 for ( ; It.More(); It.Next() ) {
1456 Handle(SALOME_InteractiveObject) IObject = It.Value();
1457 if ( !IObject->hasEntry() ) continue;
1458 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1459 if ( !anActor ) continue;
1461 // nodes: color, marker
1462 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1463 if ( markerType != VTK::MT_USER ) {
1464 anActor->SetMarkerStd( markerType, markerScale );
1467 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1468 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1469 if ( iter != markerMap.end() )
1470 anActor->SetMarkerTexture( markerId, iter->second.second );
1472 // volumes: normal color, reversed color (delta)
1473 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1474 // faces: front color, back color (delta)
1475 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1476 // edges: color, width
1477 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1478 anActor->SetLineWidth( edgeWidth );
1480 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1481 anActor->SetOutlineWidth( outlineWidth );
1482 // 0D elements: color, size
1483 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1484 anActor->Set0DSize( elem0dSize );
1485 // balls: color, size
1486 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1487 anActor->SetBallSize( ballSize );
1488 // orientation: color, scale, 3d flag
1489 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1490 anActor->SetFacesOrientationScale( orientationScale );
1491 anActor->SetFacesOrientation3DVectors( orientation3d );
1493 anActor->SetShrinkFactor( shrinkCoef );
1495 // for groups, set also proper color
1496 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1497 if ( !aGroupObject->_is_nil() ) {
1498 SMESH::ElementType anElementType = aGroupObject->GetType();
1500 switch( anElementType ) {
1502 aColor = nodeColor; break;
1504 aColor = edgeColor; break;
1506 aColor = faceColor; break;
1508 aColor = volumeColor; break;
1510 aColor = elem0dColor; break;
1512 aColor = ballColor; break;
1516 if ( aColor.isValid() ) {
1517 SALOMEDS::Color aGroupColor;
1518 aGroupColor.R = aColor.redF();
1519 aGroupColor.G = aColor.greenF();
1520 aGroupColor.B = aColor.blueF();
1521 aGroupObject->SetColor( aGroupColor );
1523 } // if ( !aGroupObject->_is_nil() )
1524 } // for ( ; It.More(); It.Next() )
1525 SMESH::RepaintCurrentView();
1526 } // if ( dlg.exec() )
1529 } // switch(theCommandID)
1530 SALOME_ListIteratorOfListIO It( selected );
1531 for( ; It.More(); It.Next()){
1532 Handle(SALOME_InteractiveObject) IObject = It.Value();
1533 if(IObject->hasEntry()){
1534 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1535 switch(theCommandID){
1537 anActor->SetRepresentation(SMESH_Actor::eEdge);
1540 anActor->SetRepresentation(SMESH_Actor::eSurface);
1543 if(anActor->IsShrunk())
1544 anActor->UnShrink();
1546 anActor->SetShrink();
1549 anActor->SetRepresentation(SMESH_Actor::ePoint);
1552 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1553 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1556 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1557 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1563 SMESH::RepaintCurrentView();
1567 void Control( int theCommandID )
1569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1570 SALOME_ListIO selected;
1572 aSel->selectedObjects( selected );
1574 if( !selected.IsEmpty() ){
1575 Handle(SALOME_InteractiveObject) anIO = selected.First();
1577 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1578 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1579 switch ( theCommandID ){
1581 aControl = SMESH_Actor::eLength;
1584 aControl = SMESH_Actor::eLength2D;
1587 aControl = SMESH_Actor::eFreeEdges;
1590 aControl = SMESH_Actor::eFreeBorders;
1593 aControl = SMESH_Actor::eMultiConnection;
1596 aControl = SMESH_Actor::eFreeNodes;
1599 aControl = SMESH_Actor::eMultiConnection2D;
1602 aControl = SMESH_Actor::eArea;
1605 aControl = SMESH_Actor::eTaper;
1608 aControl = SMESH_Actor::eAspectRatio;
1611 aControl = SMESH_Actor::eAspectRatio3D;
1614 aControl = SMESH_Actor::eMinimumAngle;
1617 aControl = SMESH_Actor::eWarping;
1620 aControl = SMESH_Actor::eSkew;
1623 aControl = SMESH_Actor::eVolume3D;
1626 aControl = SMESH_Actor::eFreeFaces;
1629 aControl = SMESH_Actor::eMaxElementLength2D;
1632 aControl = SMESH_Actor::eMaxElementLength3D;
1635 aControl = SMESH_Actor::eBareBorderVolume;
1638 aControl = SMESH_Actor::eBareBorderFace;
1641 aControl = SMESH_Actor::eOverConstrainedVolume;
1644 aControl = SMESH_Actor::eOverConstrainedFace;
1647 aControl = SMESH_Actor::eCoincidentNodes;
1650 aControl = SMESH_Actor::eCoincidentElems1D;
1653 aControl = SMESH_Actor:: eCoincidentElems2D;
1656 aControl = SMESH_Actor::eCoincidentElems3D;
1660 anActor->SetControlMode(aControl);
1661 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1662 SMESH::RepaintCurrentView();
1663 #ifndef DISABLE_PLOT2DVIEWER
1664 if(anActor->GetPlot2Histogram()) {
1665 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1666 QString functorName = functorToString( anActor->GetFunctor());
1667 QString aHistogramName("%1 : %2");
1668 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1669 aHistogram->setName(aHistogramName);
1670 aHistogram->setHorTitle(functorName);
1671 SMESH::ProcessIn2DViewers(anActor);
1680 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1681 SMESH::MeshObjectType theType,
1682 const QString theInTypeName,
1683 QString & theOutTypeName)
1685 SMESH_TypeFilter aTypeFilter( theType );
1687 if( !theIO.IsNull() )
1689 entry = theIO->getEntry();
1690 LightApp_DataOwner owner( entry );
1691 if ( aTypeFilter.isOk( &owner )) {
1692 theOutTypeName = theInTypeName;
1700 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1702 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1703 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1705 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1706 CORBA::String_var anID = aSComp->GetID().c_str();
1707 if (!strcmp(anID.in(),theIO->getEntry()))
1713 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1714 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1715 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1716 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1717 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1725 QString CheckHomogeneousSelection()
1727 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1728 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1729 SALOME_ListIO selected;
1731 aSel->selectedObjects( selected );
1733 QString RefType = CheckTypeObject(selected.First());
1734 SALOME_ListIteratorOfListIO It(selected);
1735 for ( ; It.More(); It.Next())
1737 Handle(SALOME_InteractiveObject) IObject = It.Value();
1738 QString Type = CheckTypeObject(IObject);
1739 if (Type.compare(RefType) != 0)
1740 return "Heterogeneous Selection";
1748 void SMESHGUI::OnEditDelete()
1750 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1751 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1752 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1754 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1755 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1756 _PTR(GenericAttribute) anAttr;
1757 _PTR(AttributeIOR) anIOR;
1759 int objectCount = 0;
1761 QString aParentComponent = QString::null;
1762 Handle(SALOME_InteractiveObject) anIO;
1763 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1765 anIO = anIt.Value();
1766 QString cur = anIO->getComponentDataType();
1767 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1769 // check if object is reference
1770 _PTR(SObject) aRefSObj;
1771 aNameList.append("\n - ");
1772 if ( aSO->ReferencedObject( aRefSObj ) ) {
1773 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1774 aNameList.append( aRefName );
1775 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1778 aNameList.append(anIO->getName());
1782 if( aParentComponent.isNull() )
1783 aParentComponent = cur;
1784 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1785 aParentComponent = "";
1788 if ( objectCount == 0 )
1789 return; // No Valid Objects Selected
1791 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1792 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1793 QObject::tr("ERR_ERROR"),
1794 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1797 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1798 if (SUIT_MessageBox::warning
1799 (SMESHGUI::desktop(),
1800 QObject::tr("SMESH_WRN_WARNING"),
1801 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1802 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1803 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1806 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1808 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1809 // then treat them all starting from the deepest objects (at list back)
1810 std::list< _PTR(SObject) > listSO;
1811 SALOME_ListIteratorOfListIO It(selected);
1812 for( ; It.More(); It.Next()) // loop on selected IO's
1814 Handle(SALOME_InteractiveObject) IObject = It.Value();
1815 if(IObject->hasEntry()) {
1816 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1818 // disable removal of "SMESH" component object
1819 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1821 if ( engineIOR() == anIOR->Value().c_str() )
1824 //Check the referenced object
1825 _PTR(SObject) aRefSObject;
1826 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1827 aSO = aRefSObject; // Delete main Object instead of reference
1829 listSO.push_back( aSO );
1830 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1831 for ( ; itSO != listSO.end(); ++itSO ) {
1832 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1833 for (it->InitEx(false); it->More(); it->Next())
1834 listSO.push_back( it->Value() );
1838 // Check if none of objects to delete is referred from outside
1839 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1840 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1842 _PTR(SObject) SO = *ritSO;
1843 if ( !SO ) continue;
1844 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1845 for (size_t i = 0; i < aReferences.size(); i++) {
1846 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1847 std::string type = aComponent->ComponentDataType();
1848 if ( type != "SMESH" )
1850 SUIT_MessageBox::warning( anApp->desktop(),
1851 QObject::tr("WRN_WARNING"),
1852 QObject::tr("DEP_OBJECT") );
1853 return; // outside SMESH, there is an object depending on a SMESH object
1858 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1859 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1861 Handle(SALOME_InteractiveObject) IObject = It.Value();
1862 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1863 if ( !mesh->_is_nil() )
1867 // Treat SO's in the list starting from the back
1868 aStudyBuilder->NewCommand(); // There is a transaction
1869 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1871 _PTR(SObject) SO = *ritSO;
1872 if ( !SO ) continue;
1873 std::string anEntry = SO->GetID();
1875 /** Erase graphical object and remove all its data **/
1876 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1877 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1879 /** Remove an object from data structures **/
1880 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1881 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1882 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1883 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1884 aMesh->RemoveGroup( aGroup );
1886 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1887 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1888 aMesh->RemoveSubMesh( aSubMesh );
1890 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1892 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1895 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1896 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1897 QString objType = CheckTypeObject(IObject);
1898 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1899 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1900 aStudyBuilder->RemoveObjectWithChildren( SO );
1902 else {// default action: remove SObject from the study
1903 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1904 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1906 aStudyBuilder->RemoveObjectWithChildren( SO );
1910 } /* listSO back loop */
1912 aStudyBuilder->CommitCommand();
1914 /* Clear any previous selection */
1916 aSel->setSelectedObjects( l1 );
1918 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1922 SMESHGUI_EXPORT CAM_Module* createModule()
1924 return new SMESHGUI();
1927 SMESHGUI_EXPORT char* getModuleVersion() {
1928 return (char*)SMESH_VERSION_STR;
1932 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1934 //=============================================================================
1938 //=============================================================================
1939 SMESHGUI::SMESHGUI() :
1940 SalomeApp_Module( "SMESH" )
1942 if ( CORBA::is_nil( myComponentSMESH ) )
1944 CORBA::Boolean anIsEmbeddedMode;
1945 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1946 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1948 // 0019923: EDF 765 SMESH : default values of hypothesis
1949 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1950 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1951 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1952 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1953 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1955 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1956 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1957 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1959 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1960 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1964 myActiveDialogBox = 0;
1965 myFilterLibraryDlg = 0;
1969 myEventCallbackCommand = vtkCallbackCommand::New();
1970 myEventCallbackCommand->Delete();
1971 myEventCallbackCommand->SetClientData( this );
1972 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1975 /* load resources for all available meshers */
1976 SMESH::InitAvailableHypotheses();
1978 MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities
1981 //=============================================================================
1985 //=============================================================================
1986 SMESHGUI::~SMESHGUI()
1990 //=============================================================================
1994 //=============================================================================
1995 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1997 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1999 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2004 //=============================================================================
2008 //=============================================================================
2009 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2011 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2015 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2016 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2017 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2018 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2019 return autoUpdate && !exceeded;
2022 //=============================================================================
2026 //=============================================================================
2027 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2028 int* entities, bool* limitExceeded, int* hidden )
2030 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2034 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2035 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2036 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2038 long requestedSize = theMesh->NbElements();
2040 *entities = SMESH_Actor::eAllEntity;
2043 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2045 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2047 if ( incrementalLimit ) {
2048 long nbOdElems = theMesh->Nb0DElements();
2049 long nbEdges = theMesh->NbEdges();
2050 long nbFaces = theMesh->NbFaces();
2051 long nbVolumes = theMesh->NbVolumes();
2052 long nbBalls = theMesh->NbBalls();
2055 if ( nbOdElems > 0 ) {
2056 if ( total + nbOdElems > updateLimit ) {
2057 *entities = *entities & ~SMESH_Actor::e0DElements;
2058 *hidden = *hidden | SMESH_Actor::e0DElements;
2065 if ( nbEdges > 0 ) {
2066 if ( total + nbEdges > updateLimit ) {
2067 *entities = *entities & ~SMESH_Actor::eEdges;
2068 *hidden = *hidden | SMESH_Actor::eEdges;
2075 if ( nbFaces > 0 ) {
2076 if ( total + nbFaces > updateLimit ) {
2077 *entities = *entities & ~SMESH_Actor::eFaces;
2078 *hidden = *hidden | SMESH_Actor::eFaces;
2085 if ( nbVolumes > 0 ) {
2086 if ( total + nbVolumes > updateLimit ) {
2087 *entities = *entities & ~SMESH_Actor::eVolumes;
2088 *hidden = *hidden | SMESH_Actor::eVolumes;
2095 if ( nbBalls > 0 ) {
2096 if ( total + nbBalls > updateLimit ) {
2097 *entities = *entities & ~SMESH_Actor::eBallElem;
2098 *hidden = *hidden | SMESH_Actor::eBallElem;
2106 return autoUpdate && !exceeded;
2109 //=============================================================================
2113 //=============================================================================
2114 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2116 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2119 //=============================================================================
2123 //=============================================================================
2124 SMESHGUI* SMESHGUI::GetSMESHGUI()
2126 SMESHGUI* smeshMod = 0;
2127 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2130 CAM_Module* module = app->module( "Mesh" );
2131 smeshMod = dynamic_cast<SMESHGUI*>( module );
2134 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2136 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2139 _PTR(Study) aStudy = study->studyDS();
2141 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2150 Standard_EXPORT SMESHGUI* GetComponentGUI()
2152 return SMESHGUI::GetSMESHGUI();
2156 //=============================================================================
2160 //=============================================================================
2161 void SMESHGUI::SetState(int aState)
2166 //=============================================================================
2170 //=============================================================================
2171 void SMESHGUI::ResetState()
2176 //=============================================================================
2180 //=============================================================================
2181 void SMESHGUI::EmitSignalDeactivateDialog()
2183 emit SignalDeactivateActiveDialog();
2186 //=============================================================================
2190 //=============================================================================
2191 void SMESHGUI::EmitSignalStudyFrameChanged()
2193 emit SignalStudyFrameChanged();
2196 //=============================================================================
2200 //=============================================================================
2201 void SMESHGUI::EmitSignalCloseAllDialogs()
2203 emit SignalCloseAllDialogs();
2206 //=============================================================================
2210 //=============================================================================
2211 void SMESHGUI::EmitSignalVisibilityChanged()
2213 emit SignalVisibilityChanged();
2216 //=============================================================================
2220 //=============================================================================
2221 QDialog *SMESHGUI::GetActiveDialogBox()
2223 return myActiveDialogBox;
2226 //=============================================================================
2230 //=============================================================================
2231 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2233 myActiveDialogBox = (QDialog *) aDlg;
2237 //=============================================================================
2241 //=============================================================================
2242 SUIT_Desktop* SMESHGUI::desktop()
2244 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2246 return app->desktop();
2251 //=============================================================================
2255 //=============================================================================
2256 SalomeApp_Study* SMESHGUI::activeStudy()
2258 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2260 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2265 //=============================================================================
2269 //=============================================================================
2270 void SMESHGUI::Modified( bool theIsUpdateActions )
2272 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2273 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2274 appStudy->Modified();
2275 if( theIsUpdateActions )
2276 app->updateActions();
2281 //=============================================================================
2285 //=============================================================================
2286 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2288 /* Here the position is on the bottom right corner - 10 */
2289 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2291 SUIT_Desktop *PP = desktop();
2292 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2293 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2297 //=============================================================================
2301 //=============================================================================
2302 static int isStudyLocked(_PTR(Study) theStudy){
2303 return theStudy->GetProperties()->IsLocked();
2306 static bool checkLock(_PTR(Study) theStudy) {
2307 if (isStudyLocked(theStudy)) {
2308 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2309 QObject::tr("WRN_WARNING"),
2310 QObject::tr("WRN_STUDY_LOCKED") );
2316 //=======================================================================
2317 //function : CheckActiveStudyLocked
2319 //=======================================================================
2321 bool SMESHGUI::isActiveStudyLocked()
2323 _PTR(Study) aStudy = activeStudy()->studyDS();
2324 return checkLock( aStudy );
2327 //=============================================================================
2331 //=============================================================================
2332 bool SMESHGUI::OnGUIEvent( int theCommandID )
2334 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2338 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2339 SUIT_ResourceMgr* mgr = resourceMgr();
2343 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2344 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2347 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2348 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2350 //QAction* act = action( theCommandID );
2352 switch (theCommandID) {
2354 if(checkLock(aStudy)) break;
2366 if(checkLock(aStudy)) break;
2367 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2371 case 150: //MED FILE INFORMATION
2373 SALOME_ListIO selected;
2374 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2376 aSel->selectedObjects( selected );
2377 if( selected.Extent() )
2379 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2380 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2381 if ( !aMesh->_is_nil() )
2383 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2390 case 122: // EXPORT MED
2405 ::ExportMeshToFile(theCommandID);
2409 case 200: // SCALAR BAR
2411 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2412 SALOME_ListIO selected;
2414 aSel->selectedObjects( selected );
2416 if( selected.Extent() ) {
2417 Handle(SALOME_InteractiveObject) anIO = selected.First();
2418 if( anIO->hasEntry() ) {
2419 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2420 anActor->SetControlMode( SMESH_Actor::eNone );
2421 #ifndef DISABLE_PLOT2DVIEWER
2422 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2431 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2436 // dump control distribution data to the text file
2437 ::SaveDistribution();
2443 // show/ distribution
2444 ::ShowDistribution();
2448 #ifndef DISABLE_PLOT2DVIEWER
2451 // plot distribution
2452 ::PlotDistribution();
2463 ::DisableAutoColor();
2466 case 1134: // Clipping
2467 case 1133: // Tranparency
2468 case 1132: // Display preferences (colors, shrink size, line width, ...)
2475 ::SetDisplayMode(theCommandID, myMarkerMap);
2478 //2D quadratic representation
2481 ::SetDisplayMode(theCommandID, myMarkerMap);
2485 case 216: // 0D elements
2488 case 219: // Volumes
2489 case 220: // All Entity
2491 ::SetDisplayEntity(theCommandID);
2494 case 221: // Orientation of faces
2496 LightApp_SelectionMgr* mgr = selectionMgr();
2497 SALOME_ListIO selected; mgr->selectedObjects( selected );
2499 SALOME_ListIteratorOfListIO it(selected);
2500 for( ; it.More(); it.Next()) {
2501 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2502 if(anIObject->hasEntry()) {
2503 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2504 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2513 if(checkLock(aStudy)) break;
2514 SUIT_OverrideCursor wc;
2516 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2519 SMESH::UpdateView();
2521 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2522 SMESH::OnVisuException();
2524 catch (...) { // PAL16774 (Crash after display of many groups)
2525 SMESH::OnVisuException();
2529 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2530 aSel->selectedObjects( l );
2531 aSel->setSelectedObjects( l );
2536 case 301: // DISPLAY
2537 case 302: // DISPLAY ONLY
2539 SMESH::EDisplaing anAction;
2540 switch (theCommandID) {
2541 case 300: anAction = SMESH::eErase; break;
2542 case 301: anAction = SMESH::eDisplay; break;
2543 case 302: anAction = SMESH::eDisplayOnly; break;
2546 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2547 SALOME_ListIO sel_objects, to_process;
2549 aSel->selectedObjects( sel_objects );
2551 if( theCommandID==302 )
2553 MESSAGE("anAction = SMESH::eDisplayOnly");
2554 startOperation( myEraseAll );
2557 extractContainers( sel_objects, to_process );
2560 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2564 SALOME_ListIteratorOfListIO It( to_process );
2565 for ( ; It.More(); It.Next()) {
2567 Handle(SALOME_InteractiveObject) IOS = It.Value();
2568 if (IOS->hasEntry()) {
2570 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2571 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2572 break; // PAL16774 (Crash after display of many groups)
2574 if (anAction == SMESH::eDisplayOnly)
2576 MESSAGE("anAction = SMESH::eDisplayOnly");
2577 anAction = SMESH::eDisplay;
2583 // PAL13338 + PAL15161 -->
2584 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2585 MESSAGE("anAction = SMESH::eDisplayOnly");
2586 SMESH::UpdateView();
2587 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2589 // PAL13338 + PAL15161 <--
2591 catch (...) { // PAL16774 (Crash after display of many groups)
2592 SMESH::OnVisuException();
2595 if (anAction == SMESH::eErase) {
2596 MESSAGE("anAction == SMESH::eErase");
2598 aSel->setSelectedObjects( l1 );
2601 aSel->setSelectedObjects( to_process );
2608 if(checkLock(aStudy)) break;
2611 EmitSignalDeactivateDialog();
2613 ( new SMESHGUI_NodesDlg( this ) )->show();
2616 SUIT_MessageBox::warning(desktop(),
2617 tr("SMESH_WRN_WARNING"),
2618 tr("SMESH_WRN_VIEWER_VTK"));
2623 case 2151: // FILTER
2627 EmitSignalDeactivateDialog();
2628 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2633 case 701: // COMPUTE MESH
2634 case 711: // PRECOMPUTE MESH
2635 case 712: // EVALUATE MESH
2636 case 713: // MESH ORDER
2637 case 702: // Create mesh
2638 case 703: // Create sub-mesh
2639 case 704: // Edit mesh/sub-mesh
2640 startOperation( theCommandID );
2642 case 705: // copy mesh
2644 if (checkLock(aStudy)) break;
2645 EmitSignalDeactivateDialog();
2646 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2649 case 710: // Build compound mesh
2651 if (checkLock(aStudy)) break;
2652 EmitSignalDeactivateDialog();
2653 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2657 case 407: // DIAGONAL INVERSION
2658 case 408: // Delete diagonal
2662 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2663 tr( "NOT_A_VTK_VIEWER" ) );
2667 if ( checkLock( aStudy ) )
2670 /*Standard_Boolean aRes;
2671 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2672 if ( aMesh->_is_nil() )
2674 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2675 tr( "SMESH_BAD_SELECTION" ) );
2679 EmitSignalDeactivateDialog();
2680 if ( theCommandID == 407 )
2681 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2683 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2686 case 409: // Change orientation
2687 case 410: // Union of triangles
2688 case 411: // Cutting of quadrangles
2689 case 419: // Splitting volumes into tetrahedra
2693 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2694 tr( "NOT_A_VTK_VIEWER" ) );
2698 if ( checkLock( aStudy ) )
2701 EmitSignalDeactivateDialog();
2702 SMESHGUI_MultiEditDlg* aDlg = NULL;
2703 if ( theCommandID == 409 )
2704 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2705 else if ( theCommandID == 410 )
2706 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2707 else if ( theCommandID == 419 )
2708 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2710 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2715 case 412: // Smoothing
2717 if(checkLock(aStudy)) break;
2719 EmitSignalDeactivateDialog();
2720 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2723 SUIT_MessageBox::warning(desktop(),
2724 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2728 case 413: // Extrusion
2730 if (checkLock(aStudy)) break;
2732 EmitSignalDeactivateDialog();
2733 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2735 SUIT_MessageBox::warning(desktop(),
2736 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2740 case 414: // Revolution
2742 if(checkLock(aStudy)) break;
2744 EmitSignalDeactivateDialog();
2745 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2748 SUIT_MessageBox::warning(desktop(),
2749 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2753 case 415: // Pattern mapping
2755 if ( checkLock( aStudy ) )
2759 EmitSignalDeactivateDialog();
2760 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2763 SUIT_MessageBox::warning(desktop(),
2764 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2768 case 416: // Extrusion along a path
2770 if (checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2773 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2775 SUIT_MessageBox::warning(desktop(),
2776 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2780 case 417: // Convert mesh to quadratic
2781 case 418: // create 2D mesh from 3D
2782 case 420: // Reorient faces
2783 case 806: // CREATE GEO GROUP
2785 startOperation( theCommandID );
2788 case 801: // CREATE GROUP
2792 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2793 tr( "NOT_A_VTK_VIEWER" ) );
2797 if(checkLock(aStudy)) break;
2798 EmitSignalDeactivateDialog();
2799 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2801 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2802 SALOME_ListIO selected;
2804 aSel->selectedObjects( selected );
2806 int nbSel = selected.Extent();
2808 // check if mesh is selected
2809 aMesh = SMESH::GetMeshByIO( selected.First() );
2811 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2816 case 802: // CONSTRUCT GROUP
2820 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2821 tr( "NOT_A_VTK_VIEWER" ) );
2825 if(checkLock(aStudy)) break;
2826 EmitSignalDeactivateDialog();
2828 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2829 SALOME_ListIO selected;
2831 aSel->selectedObjects( selected );
2833 int nbSel = selected.Extent();
2835 // check if submesh is selected
2836 Handle(SALOME_InteractiveObject) IObject = selected.First();
2837 if (IObject->hasEntry()) {
2838 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2840 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2841 if (!aSubMesh->_is_nil()) {
2843 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2844 // get submesh elements list by types
2845 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2846 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2847 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2848 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2849 // create group for each type o elements
2850 QString aName = IObject->getName();
2851 QStringList anEntryList;
2852 if (aNodes->length() > 0) {
2853 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2854 aGroup->Add(aNodes.inout());
2855 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2856 anEntryList.append( aSObject->GetID().c_str() );
2858 if (aEdges->length() > 0) {
2859 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2860 aGroup->Add(aEdges.inout());
2861 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2862 anEntryList.append( aSObject->GetID().c_str() );
2864 if (aFaces->length() > 0) {
2865 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2866 aGroup->Add(aFaces.inout());
2867 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2868 anEntryList.append( aSObject->GetID().c_str() );
2870 if (aVolumes->length() > 0) {
2871 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2872 aGroup->Add(aVolumes.inout());
2873 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2874 anEntryList.append( aSObject->GetID().c_str() );
2877 anApp->browseObjects( anEntryList );
2879 catch(const SALOME::SALOME_Exception & S_ex){
2880 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2887 SUIT_MessageBox::warning(desktop(),
2888 tr("SMESH_WRN_WARNING"),
2889 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2894 case 803: // EDIT GROUP
2898 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2899 tr( "NOT_A_VTK_VIEWER" ) );
2903 if(checkLock(aStudy)) break;
2904 EmitSignalDeactivateDialog();
2906 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2907 SALOME_ListIO selected;
2909 aSel->selectedObjects( selected );
2911 SALOME_ListIteratorOfListIO It (selected);
2912 int nbSelectedGroups = 0;
2913 for ( ; It.More(); It.Next() )
2915 SMESH::SMESH_GroupBase_var aGroup =
2916 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2917 if (!aGroup->_is_nil()) {
2919 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2923 if (nbSelectedGroups == 0)
2925 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2931 case 804: // Add elements to group
2933 if(checkLock(aStudy)) break;
2934 if (myState == 800) {
2935 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2936 if (aDlg) aDlg->onAdd();
2941 case 805: // Remove elements from group
2943 if(checkLock(aStudy)) break;
2944 if (myState == 800) {
2945 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2946 if (aDlg) aDlg->onRemove();
2951 case 815: // Edit GEOM GROUP as standalone
2955 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2956 tr( "NOT_A_VTK_VIEWER" ) );
2960 if(checkLock(aStudy)) break;
2961 EmitSignalDeactivateDialog();
2963 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2964 SALOME_ListIO selected;
2966 aSel->selectedObjects( selected );
2968 SALOME_ListIteratorOfListIO It (selected);
2969 for ( ; It.More(); It.Next() )
2971 SMESH::SMESH_GroupOnGeom_var aGroup =
2972 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2973 if (!aGroup->_is_nil()) {
2974 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2979 SMESH::SMESH_GroupOnFilter_var aGroup =
2980 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2981 if (!aGroup->_is_nil()) {
2982 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2990 case 810: // Union Groups
2991 case 811: // Intersect groups
2992 case 812: // Cut groups
2996 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2997 tr( "NOT_A_VTK_VIEWER" ) );
3001 if ( checkLock( aStudy ) )
3004 EmitSignalDeactivateDialog();
3006 SMESHGUI_GroupOpDlg* aDlg = 0;
3007 if ( theCommandID == 810 )
3008 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3009 else if ( theCommandID == 811 )
3010 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3012 aDlg = new SMESHGUI_CutGroupsDlg( this );
3019 case 814: // Create groups of entities from existing groups of superior dimensions
3021 if ( checkLock( aStudy ) )
3024 EmitSignalDeactivateDialog();
3025 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3031 case 813: // Delete groups with their contents
3035 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3036 tr( "NOT_A_VTK_VIEWER" ) );
3040 if ( checkLock( aStudy ) )
3043 EmitSignalDeactivateDialog();
3045 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3049 case 900: // MESH INFOS
3050 case 903: // WHAT IS
3052 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3053 EmitSignalDeactivateDialog();
3054 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3055 SALOME_ListIO selected;
3057 aSel->selectedObjects( selected );
3059 if ( selected.Extent() > 1 ) { // a dlg for each IO
3060 SALOME_ListIteratorOfListIO It( selected );
3061 for ( ; It.More(); It.Next() ) {
3062 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3063 dlg->showInfo( It.Value() );
3068 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3074 case 904: // FIND ELEM
3076 startOperation( theCommandID );
3080 case 1100: // EDIT HYPOTHESIS
3082 if(checkLock(aStudy)) break;
3084 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3085 SALOME_ListIO selected;
3087 aSel->selectedObjects( selected );
3089 int nbSel = selected.Extent();
3092 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3093 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3095 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3096 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3097 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3098 if ( !aHypothesis->_is_nil() )
3101 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3102 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3104 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3114 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3116 if(checkLock(aStudy)) break;
3117 SUIT_OverrideCursor wc;
3119 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3120 SALOME_ListIO selected;
3122 aSel->selectedObjects( selected, QString::null, false );
3124 SALOME_ListIteratorOfListIO It(selected);
3125 for (int i = 0; It.More(); It.Next(), i++) {
3126 Handle(SALOME_InteractiveObject) IObject = It.Value();
3127 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3130 aSel->setSelectedObjects( l1 );
3136 case 4009: // ELEM0D
3138 case 4021: // TRIANGLE
3140 case 4023: // POLYGON
3144 case 4134: // PYRAMID
3145 case 4135: // OCTA12
3147 if(checkLock(aStudy)) break;
3149 EmitSignalDeactivateDialog();
3150 SMDSAbs_EntityType type = SMDSEntity_Edge;
3151 switch (theCommandID) {
3152 case 4008: type = SMDSEntity_Ball; break;
3153 case 4009: type = SMDSEntity_0D; break;
3154 case 4021: type = SMDSEntity_Triangle; break;
3155 case 4022: type = SMDSEntity_Quadrangle; break;
3156 case 4031: type = SMDSEntity_Tetra; break;
3157 case 4023: type = SMDSEntity_Polygon; break;
3158 case 4032: type = SMDSEntity_Hexa; break;
3159 case 4133: type = SMDSEntity_Penta; break;
3160 case 4134: type = SMDSEntity_Pyramid; break;
3161 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3164 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3167 SUIT_MessageBox::warning(desktop(),
3168 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3172 case 4033: // POLYHEDRON
3174 if(checkLock(aStudy)) break;
3176 EmitSignalDeactivateDialog();
3177 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3180 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3181 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3185 case 4034: // QUADRATIC EDGE
3186 case 4035: // QUADRATIC TRIANGLE
3187 case 4036: // QUADRATIC QUADRANGLE
3188 case 4136: // BIQUADRATIC QUADRANGLE
3189 case 4137: // BIQUADRATIC TRIANGLE
3190 case 4037: // QUADRATIC TETRAHEDRON
3191 case 4038: // QUADRATIC PYRAMID
3192 case 4039: // QUADRATIC PENTAHEDRON
3193 case 4040: // QUADRATIC HEXAHEDRON
3194 case 4140: // TRIQUADRATIC HEXAHEDRON
3196 if(checkLock(aStudy)) break;
3198 EmitSignalDeactivateDialog();
3199 SMDSAbs_EntityType type = SMDSEntity_Last;
3201 switch (theCommandID) {
3202 case 4034: type = SMDSEntity_Quad_Edge; break;
3203 case 4035: type = SMDSEntity_Quad_Triangle; break;
3204 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3205 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3206 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3207 case 4037: type = SMDSEntity_Quad_Tetra; break;
3208 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3209 case 4039: type = SMDSEntity_Quad_Penta; break;
3210 case 4040: type = SMDSEntity_Quad_Hexa; break;
3211 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3214 if ( type != SMDSEntity_Last )
3215 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3218 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3219 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3223 case 4041: // REMOVES NODES
3225 if(checkLock(aStudy)) break;
3227 EmitSignalDeactivateDialog();
3228 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3231 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3232 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3236 case 4042: // REMOVES ELEMENTS
3238 if(checkLock(aStudy)) break;
3240 EmitSignalDeactivateDialog();
3241 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3245 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3246 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3250 case 4043: { // CLEAR_MESH
3252 if(checkLock(aStudy)) break;
3254 SALOME_ListIO selected;
3255 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3256 aSel->selectedObjects( selected );
3258 SUIT_OverrideCursor wc;
3259 SALOME_ListIteratorOfListIO It (selected);
3260 for ( ; It.More(); It.Next() )
3262 Handle(SALOME_InteractiveObject) IOS = It.Value();
3263 SMESH::SMESH_Mesh_var aMesh =
3264 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3265 if ( aMesh->_is_nil()) continue;
3267 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3269 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3270 SMESH::ModifiedMesh( aMeshSObj, false, true);
3271 // hide groups and submeshes
3272 _PTR(ChildIterator) anIter =
3273 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3274 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3276 _PTR(SObject) so = anIter->Value();
3277 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3280 catch (const SALOME::SALOME_Exception& S_ex){
3282 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3286 SMESH::UpdateView();
3290 case 4044: // REMOVE ORPHAN NODES
3292 if(checkLock(aStudy)) break;
3293 SALOME_ListIO selected;
3294 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3295 aSel->selectedObjects( selected );
3296 if ( selected.Extent() == 1 ) {
3297 Handle(SALOME_InteractiveObject) anIO = selected.First();
3298 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3299 if ( !aMesh->_is_nil() ) {
3300 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3301 tr( "SMESH_WARNING" ),
3302 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3303 SUIT_MessageBox::Yes |
3304 SUIT_MessageBox::No,
3305 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3308 SUIT_OverrideCursor wc;
3309 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3310 int removed = aMeshEditor->RemoveOrphanNodes();
3311 SUIT_MessageBox::information(SMESHGUI::desktop(),
3312 tr("SMESH_INFORMATION"),
3313 tr("NB_NODES_REMOVED").arg(removed));
3314 if ( removed > 0 ) {
3315 SMESH::UpdateView();
3316 SMESHGUI::Modified();
3319 catch (const SALOME::SALOME_Exception& S_ex) {
3320 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3329 case 4051: // RENUMBERING NODES
3331 if(checkLock(aStudy)) break;
3333 EmitSignalDeactivateDialog();
3334 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3338 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3343 case 4052: // RENUMBERING ELEMENTS
3345 if(checkLock(aStudy)) break;
3347 EmitSignalDeactivateDialog();
3348 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3352 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3353 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3357 case 4061: // TRANSLATION
3359 if(checkLock(aStudy)) break;
3361 EmitSignalDeactivateDialog();
3362 ( new SMESHGUI_TranslationDlg( this ) )->show();
3365 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3366 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3370 case 4062: // ROTATION
3372 if(checkLock(aStudy)) break;
3374 EmitSignalDeactivateDialog();
3375 ( new SMESHGUI_RotationDlg( this ) )->show();
3378 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3379 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3383 case 4063: // SYMMETRY
3385 if(checkLock(aStudy)) break;
3387 EmitSignalDeactivateDialog();
3388 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3391 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3392 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3396 case 4064: // SEWING
3398 if(checkLock(aStudy)) break;
3400 EmitSignalDeactivateDialog();
3401 ( new SMESHGUI_SewingDlg( this ) )->show();
3404 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3405 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3409 case 4065: // MERGE NODES
3411 if(checkLock(aStudy)) break;
3413 EmitSignalDeactivateDialog();
3414 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3417 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3418 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3422 case 4066: // MERGE EQUAL ELEMENTS
3424 if (checkLock(aStudy)) break;
3426 EmitSignalDeactivateDialog();
3427 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3429 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3435 case 4067: // MAKE MESH PASS THROUGH POINT
3436 startOperation( 4067 );
3441 if(checkLock(aStudy)) break;
3443 EmitSignalDeactivateDialog();
3444 ( new SMESHGUI_ScaleDlg( this ) )->show();
3447 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3448 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3453 case 4069: // DUPLICATE NODES
3455 if(checkLock(aStudy)) break;
3457 EmitSignalDeactivateDialog();
3458 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3461 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3462 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3467 case 4070: // 0D_ON_ALL_NODES
3468 startOperation( 4070 );
3471 case 5105: // Library of selection filters
3473 static QList<int> aTypes;
3474 if ( aTypes.isEmpty() )
3476 aTypes.append( SMESH::NODE );
3477 aTypes.append( SMESH::EDGE );
3478 aTypes.append( SMESH::FACE );
3479 aTypes.append( SMESH::VOLUME );
3481 if (!myFilterLibraryDlg)
3482 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3483 else if (myFilterLibraryDlg->isHidden())
3484 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3485 myFilterLibraryDlg->raise();
3489 case 6017: // CONTROLS
3517 LightApp_SelectionMgr* mgr = selectionMgr();
3518 SALOME_ListIO selected; mgr->selectedObjects( selected );
3520 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3521 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3523 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3524 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3525 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3526 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3527 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3528 SUIT_OverrideCursor wc;
3529 ::Control( theCommandID );
3534 SUIT_MessageBox::warning(desktop(),
3535 tr( "SMESH_WRN_WARNING" ),
3536 tr( "SMESH_BAD_SELECTION" ) );
3540 SUIT_MessageBox::warning(desktop(),
3541 tr( "SMESH_WRN_WARNING" ),
3542 tr( "NOT_A_VTK_VIEWER" ) );
3546 OverallMeshQuality();
3550 SUIT_OverrideCursor wc;
3551 LightApp_SelectionMgr* mgr = selectionMgr();
3552 SALOME_ListIO selected; mgr->selectedObjects( selected );
3554 SALOME_ListIteratorOfListIO it(selected);
3555 for( ; it.More(); it.Next()) {
3556 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3557 if(anIObject->hasEntry()) {
3558 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3559 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3567 SUIT_OverrideCursor wc;
3568 LightApp_SelectionMgr* mgr = selectionMgr();
3569 SALOME_ListIO selected; mgr->selectedObjects( selected );
3571 SALOME_ListIteratorOfListIO it(selected);
3572 for( ; it.More(); it.Next()) {
3573 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3574 if(anIObject->hasEntry())
3575 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3576 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3587 int page = SMESHGUI_MeasureDlg::MinDistance;
3588 if ( theCommandID == 502 )
3589 page = SMESHGUI_MeasureDlg::BoundingBox;
3590 else if ( theCommandID == 503 )
3591 page = SMESHGUI_MeasureDlg::Length;
3592 else if ( theCommandID == 504 )
3593 page = SMESHGUI_MeasureDlg::Area;
3594 else if ( theCommandID == 505 )
3595 page = SMESHGUI_MeasureDlg::Volume;
3597 EmitSignalDeactivateDialog();
3598 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3608 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3609 //updateObjBrowser();
3613 //=============================================================================
3617 //=============================================================================
3618 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3623 //=============================================================================
3627 //=============================================================================
3628 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3633 //=============================================================================
3637 //=============================================================================
3638 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3643 //=============================================================================
3644 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3645 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3647 //=============================================================================
3648 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3649 SUIT_ViewWindow* wnd )
3651 if(theIO->hasEntry()){
3652 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3653 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3657 //=======================================================================
3658 // function : createSMESHAction
3660 //=======================================================================
3661 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3662 const int key, const bool toggle, const QString& shortcutAction )
3665 QWidget* parent = application()->desktop();
3666 SUIT_ResourceMgr* resMgr = resourceMgr();
3668 if ( !icon_id.isEmpty() )
3669 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3671 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3672 if ( !pix.isNull() )
3673 icon = QIcon( pix );
3675 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3676 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3677 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3679 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3680 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3683 //=======================================================================
3684 // function : createPopupItem
3686 //=======================================================================
3687 void SMESHGUI::createPopupItem( const int id,
3688 const QString& clients,
3689 const QString& types,
3690 const QString& theRule,
3693 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3694 popupMgr()->insert( action( id ), pId, 0 );
3696 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3697 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3698 QString rule = "(%1) and (%2) and (%3)";
3699 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3700 if( clients.isEmpty() )
3701 rule = rule.arg( QString( "true" ) );
3703 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3704 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3707 bool cont = myRules.contains( id );
3709 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3711 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3712 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3715 //=======================================================================
3716 // function : initialize
3718 //=======================================================================
3719 void SMESHGUI::initialize( CAM_Application* app )
3721 SalomeApp_Module::initialize( app );
3723 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3725 /* Automatic Update flag */
3726 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3728 // ----- create actions --------------
3730 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3731 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3732 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3733 createSMESHAction( 114, "NUM" );
3734 createSMESHAction( 115, "IMPORT_STL" );
3735 createSMESHAction( 116, "IMPORT_CGNS" );
3736 createSMESHAction( 117, "IMPORT_SAUV" );
3737 createSMESHAction( 118, "IMPORT_GMF" );
3738 createSMESHAction( 121, "DAT" );
3739 createSMESHAction( 122, "MED" );
3740 createSMESHAction( 123, "UNV" );
3741 createSMESHAction( 140, "STL" );
3742 createSMESHAction( 142, "CGNS");
3743 createSMESHAction( 144, "SAUV");
3744 createSMESHAction( 146, "GMF" );
3745 createSMESHAction( 124, "DAT" );
3746 createSMESHAction( 125, "MED" );
3747 createSMESHAction( 126, "UNV" );
3748 createSMESHAction( 141, "STL" );
3749 createSMESHAction( 143, "CGNS");
3750 createSMESHAction( 145, "SAUV");
3751 createSMESHAction( 147, "GMF" );
3752 createSMESHAction( 150, "FILE_INFO" );
3753 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3754 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3755 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3756 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3757 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3758 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3759 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3760 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3761 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3762 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3763 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3764 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3765 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3766 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3767 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3768 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3769 createSMESHAction( 804, "ADD" );
3770 createSMESHAction( 805, "REMOVE" );
3771 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3772 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3773 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3774 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3775 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3776 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3777 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3778 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3779 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3780 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3781 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3782 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3783 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3784 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3785 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3786 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3787 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3788 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3789 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3790 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3791 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3792 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3793 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3794 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3795 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3796 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3797 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3798 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3799 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3800 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3801 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3802 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3803 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3804 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3805 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3806 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3807 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3808 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3809 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3810 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3811 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3812 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3813 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3814 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3815 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3816 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3817 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3818 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3819 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3820 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3821 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3822 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3823 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3824 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3825 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3826 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3827 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3828 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3829 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3830 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3831 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3832 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3833 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3834 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3835 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3836 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3837 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3838 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3839 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3840 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3841 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3842 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3843 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3844 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3845 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3846 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3847 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3848 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3849 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3850 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3851 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3852 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3853 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3854 createSMESHAction( 415, "MAP", "ICON_MAP" );
3855 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3856 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3857 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3858 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3859 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3860 createSMESHAction( 200, "RESET" );
3861 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3862 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3863 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3864 #ifndef DISABLE_PLOT2DVIEWER
3865 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3867 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3868 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3869 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3870 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3871 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3872 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3873 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3874 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3875 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3876 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3877 createSMESHAction( 220, "ALL" );
3878 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3880 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3881 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3883 createSMESHAction( 1100, "EDIT_HYPO" );
3884 createSMESHAction( 1102, "UNASSIGN" );
3885 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3886 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3887 createSMESHAction( 1131, "DISPMODE" );
3888 createSMESHAction( 1132, "COLORS" );
3889 createSMESHAction( 1133, "TRANSP" );
3890 createSMESHAction( 1134, "CLIP" );
3891 createSMESHAction( 1135, "DISP_ENT" );
3892 createSMESHAction( 1136, "AUTO_COLOR" );
3893 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3894 createSMESHAction( 2000, "CTRL" );
3896 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3897 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3898 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3899 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3900 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3902 createSMESHAction( 300, "HIDE" );
3903 createSMESHAction( 301, "SHOW" );
3904 createSMESHAction( 302, "DISPLAY_ONLY" );
3906 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3908 // ----- create menu --------------
3909 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3910 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3911 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3912 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3913 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3914 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3915 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3916 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3918 createMenu( separator(), fileId );
3920 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3921 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3922 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3923 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3924 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3925 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3926 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3927 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3928 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3929 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3930 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3932 //createMenu( 111, importId, -1 );
3933 createMenu( 112, importId, -1 );
3934 createMenu( 113, importId, -1 );
3935 createMenu( 115, importId, -1 );
3937 createMenu( 116, importId, -1 );
3939 createMenu( 117, importId, -1 );
3940 createMenu( 118, importId, -1 );
3941 createMenu( 121, exportId, -1 );
3942 createMenu( 122, exportId, -1 );
3943 createMenu( 123, exportId, -1 );
3944 createMenu( 140, exportId, -1 ); // export to STL
3946 createMenu( 142, exportId, -1 ); // export to CGNS
3948 createMenu( 144, exportId, -1 ); // export to SAUV
3949 createMenu( 146, exportId, -1 ); // export to GMF
3950 createMenu( separator(), fileId, 10 );
3952 createMenu( 33, editId, -1 );
3954 createMenu( 5105, toolsId, -1 );
3956 createMenu( 702, meshId, -1 ); // "Mesh" menu
3957 createMenu( 703, meshId, -1 );
3958 createMenu( 704, meshId, -1 );
3959 createMenu( 710, meshId, -1 );
3960 createMenu( 705, meshId, -1 );
3961 createMenu( separator(), meshId, -1 );
3962 createMenu( 701, meshId, -1 );
3963 createMenu( 711, meshId, -1 );
3964 createMenu( 712, meshId, -1 );
3965 createMenu( 713, meshId, -1 );
3966 createMenu( separator(), meshId, -1 );
3967 createMenu( 801, meshId, -1 );
3968 createMenu( 806, meshId, -1 );
3969 createMenu( 802, meshId, -1 );
3970 createMenu( 803, meshId, -1 );
3971 createMenu( 815, meshId, -1 );
3972 createMenu( separator(), meshId, -1 );
3973 createMenu( 810, meshId, -1 );
3974 createMenu( 811, meshId, -1 );
3975 createMenu( 812, meshId, -1 );
3976 createMenu( separator(), meshId, -1 );
3977 createMenu( 814, meshId, -1 );
3978 createMenu( separator(), meshId, -1 );
3979 createMenu( 900, meshId, -1 );
3980 //createMenu( 902, meshId, -1 );
3981 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3982 createMenu( 904, meshId, -1 );
3983 createMenu( separator(), meshId, -1 );
3985 createMenu( 6005, nodeId, -1 );
3986 createMenu( 6028, nodeId, -1 );
3987 createMenu( 6002, edgeId, -1 );
3988 createMenu( 6003, edgeId, -1 );
3989 createMenu( 6001, edgeId, -1 );
3990 createMenu( 6004, edgeId, -1 );
3991 createMenu( 6029, edgeId, -1 );
3992 createMenu( 6021, faceId, -1 );
3993 createMenu( 6025, faceId, -1 );
3994 createMenu( 6027, faceId, -1 );
3995 createMenu( 6018, faceId, -1 );
3996 createMenu( 6019, faceId, -1 );
3997 createMenu( 6011, faceId, -1 );
3998 createMenu( 6012, faceId, -1 );
3999 createMenu( 6013, faceId, -1 );
4000 createMenu( 6014, faceId, -1 );
4001 createMenu( 6015, faceId, -1 );
4002 createMenu( 6016, faceId, -1 );
4003 createMenu( 6022, faceId, -1 );
4004 createMenu( 6030, faceId, -1 );
4005 createMenu( 6017, volumeId, -1 );
4006 createMenu( 6009, volumeId, -1 );
4007 createMenu( 6023, volumeId, -1 );
4008 createMenu( 6024, volumeId, -1 );
4009 createMenu( 6026, volumeId, -1 );
4010 createMenu( 6031, volumeId, -1 );
4011 createMenu( separator(), ctrlId, -1 );
4012 createMenu( 6032, ctrlId, -1 );
4014 createMenu( 4000, addId, -1 );
4015 createMenu( 4009, addId, -1 );
4016 createMenu( 4070, addId, -1 );
4017 createMenu( 4008, addId, -1 );
4018 createMenu( 4010, addId, -1 );
4019 createMenu( 4021, addId, -1 );
4020 createMenu( 4022, addId, -1 );
4021 createMenu( 4023, addId, -1 );
4022 createMenu( 4031, addId, -1 );
4023 createMenu( 4032, addId, -1 );
4024 createMenu( 4133, addId, -1 );
4025 createMenu( 4134, addId, -1 );
4026 createMenu( 4135, addId, -1 );
4027 createMenu( 4033, addId, -1 );
4028 createMenu( separator(), addId, -1 );
4029 createMenu( 4034, addId, -1 );
4030 createMenu( 4035, addId, -1 );
4031 createMenu( 4137, addId, -1 );
4032 createMenu( 4036, addId, -1 );
4033 createMenu( 4136, addId, -1 );
4034 createMenu( 4037, addId, -1 );
4035 createMenu( 4038, addId, -1 );
4036 createMenu( 4039, addId, -1 );
4037 createMenu( 4040, addId, -1 );
4038 createMenu( 4140, addId, -1 );
4040 createMenu( 4041, removeId, -1 );
4041 createMenu( 4042, removeId, -1 );
4042 createMenu( 4044, removeId, -1 );
4043 createMenu( separator(), removeId, -1 );
4044 createMenu( 813, removeId, -1 );
4045 createMenu( separator(), removeId, -1 );
4046 createMenu( 4043, removeId, -1 );
4048 createMenu( 4051, renumId, -1 );
4049 createMenu( 4052, renumId, -1 );
4051 createMenu( 4061, transfId, -1 );
4052 createMenu( 4062, transfId, -1 );
4053 createMenu( 4063, transfId, -1 );
4054 createMenu( 4068, transfId, -1 );
4055 createMenu( 4064, transfId, -1 );
4056 createMenu( 4065, transfId, -1 );
4057 createMenu( 4066, transfId, -1 );
4058 createMenu( 4069, transfId, -1 );
4060 createMenu( 4067,modifyId, -1 );
4061 createMenu( 407, modifyId, -1 );
4062 createMenu( 408, modifyId, -1 );
4063 createMenu( 409, modifyId, -1 );
4064 createMenu( 420, modifyId, -1 );
4065 createMenu( 410, modifyId, -1 );
4066 createMenu( 411, modifyId, -1 );
4067 createMenu( 419, modifyId, -1 );
4068 createMenu( 412, modifyId, -1 );
4069 createMenu( 413, modifyId, -1 );
4070 createMenu( 416, modifyId, -1 );
4071 createMenu( 414, modifyId, -1 );
4072 createMenu( 415, modifyId, -1 );
4073 createMenu( 417, modifyId, -1 );
4074 createMenu( 418, modifyId, -1 );
4076 createMenu( 501, measureId, -1 );
4077 createMenu( 502, measureId, -1 );
4078 createMenu( 503, basicPropId, -1 );
4079 createMenu( 504, basicPropId, -1 );
4080 createMenu( 505, basicPropId, -1 );
4081 createMenu( 214, viewId, -1 );
4083 // ----- create toolbars --------------
4084 int meshTb = createTool( tr( "TB_MESH" ) ),
4085 info = createTool( tr( "TB_INFO" ) ),
4086 groupTb = createTool( tr( "TB_GROUP" ) ),
4087 ctrl0dTb = createTool( tr( "TB_CTRL0D" ) ),
4088 ctrl1dTb = createTool( tr( "TB_CTRL1D" ) ),
4089 ctrl2dTb = createTool( tr( "TB_CTRL2D" ) ),
4090 ctrl3dTb = createTool( tr( "TB_CTRL3D" ) ),
4091 addElemTb = createTool( tr( "TB_ADD" ) ),
4092 addNonElemTb = createTool( tr( "TB_ADDNON" ) ),
4093 remTb = createTool( tr( "TB_REM" ) ),
4094 renumbTb = createTool( tr( "TB_RENUMBER" ) ),
4095 transformTb = createTool( tr( "TB_TRANSFORM" ) ),
4096 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4097 measuremTb = createTool( tr( "TB_MEASUREM" ) ),
4098 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4100 createTool( 702, meshTb );
4101 createTool( 703, meshTb );
4102 createTool( 704, meshTb );
4103 createTool( 710, meshTb );
4104 createTool( 705, meshTb );
4105 createTool( separator(), meshTb );
4106 createTool( 701, meshTb );
4107 createTool( 711, meshTb );
4108 createTool( 712, meshTb );
4109 createTool( 713, meshTb );
4111 createTool( 801, groupTb );
4112 createTool( 806, groupTb );
4113 createTool( 802, groupTb );
4114 createTool( 803, groupTb );
4116 createTool( 900, info );
4117 //createTool( 902, meshTb );
4118 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4119 createTool( 904, info );
4121 createTool( 6005, ctrl0dTb );
4122 createTool( 6028, ctrl0dTb );
4124 createTool( 6002, ctrl1dTb );
4125 createTool( 6003, ctrl1dTb );
4126 createTool( 6001, ctrl1dTb );
4127 createTool( 6004, ctrl1dTb );
4128 createTool( 6029, ctrl1dTb );
4130 createTool( 6021, ctrl2dTb );
4131 createTool( 6025, ctrl2dTb );
4132 createTool( 6027, ctrl2dTb );
4133 createTool( 6018, ctrl2dTb );
4134 createTool( 6019, ctrl2dTb );
4135 createTool( 6011, ctrl2dTb );
4136 createTool( 6012, ctrl2dTb );
4137 createTool( 6013, ctrl2dTb );
4138 createTool( 6014, ctrl2dTb );
4139 createTool( 6015, ctrl2dTb );
4140 createTool( 6016, ctrl2dTb );
4141 createTool( 6022, ctrl2dTb );
4142 createTool( 6030, ctrl2dTb );
4144 createTool( 6017, ctrl3dTb );
4145 createTool( 6009, ctrl3dTb );
4146 createTool( 6023, ctrl3dTb );
4147 createTool( 6024, ctrl3dTb );
4148 createTool( 6026, ctrl3dTb );
4149 createTool( 6031, ctrl3dTb );
4151 createTool( 4000, addElemTb );
4152 createTool( 4009, addElemTb );
4153 createTool( 4070, addElemTb );
4154 createTool( 4008, addElemTb );
4155 createTool( 4010, addElemTb );
4156 createTool( 4021, addElemTb );
4157 createTool( 4022, addElemTb );
4158 createTool( 4023, addElemTb );
4159 createTool( 4031, addElemTb );
4160 createTool( 4032, addElemTb );
4161 createTool( 4133, addElemTb );
4162 createTool( 4134, addElemTb );
4163 createTool( 4135, addElemTb );
4164 createTool( 4033, addElemTb );
4166 createTool( 4034, addNonElemTb );
4167 createTool( 4035, addNonElemTb );
4168 createTool( 4137, addNonElemTb );
4169 createTool( 4036, addNonElemTb );
4170 createTool( 4136, addNonElemTb );
4171 createTool( 4037, addNonElemTb );
4172 createTool( 4038, addNonElemTb );
4173 createTool( 4039, addNonElemTb );
4174 createTool( 4040, addNonElemTb );
4175 createTool( 4140, addNonElemTb );
4177 createTool( 4041, remTb );
4178 createTool( 4042, remTb );
4179 createTool( 4044, remTb );
4180 createTool( 4043, remTb );
4182 createTool( 4051, renumbTb );
4183 createTool( 4052, renumbTb );
4186 createTool( 4061, transformTb );
4187 createTool( 4062, transformTb );
4188 createTool( 4063, transformTb );
4189 createTool( 4068, transformTb );
4190 createTool( 4064, transformTb );
4191 createTool( 4065, transformTb );
4192 createTool( 4066, transformTb );
4193 createTool( 4069, transformTb );
4195 createTool( 4067,modifyTb );
4196 createTool( 407, modifyTb );
4197 createTool( 408, modifyTb );
4198 createTool( 409, modifyTb );
4199 createTool( 420, modifyTb );
4200 createTool( 410, modifyTb );
4201 createTool( 411, modifyTb );
4202 createTool( 419, modifyTb );
4203 createTool( 412, modifyTb );
4204 createTool( 413, modifyTb );
4205 createTool( 416, modifyTb );
4206 createTool( 414, modifyTb );
4207 createTool( 415, modifyTb );
4208 createTool( 417, modifyTb );
4209 createTool( 418, modifyTb );
4211 createTool( 501, measuremTb );
4213 createTool( 214, dispModeTb );
4215 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4216 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4219 QString OB = "'ObjectBrowser'",
4220 View = "'" + SVTK_Viewer::Type() + "'",
4222 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4223 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4224 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4225 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4226 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4227 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4228 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4229 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4230 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4231 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4232 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4234 mesh_part = mesh + " " + subMesh + " " + group,
4235 mesh_group = mesh + " " + group,
4236 hyp_alg = hypo + " " + algo;
4238 // popup for object browser
4240 isInvisible("not( isVisible )"),
4241 isEmpty("numberOfNodes = 0"),
4242 isNotEmpty("numberOfNodes <> 0"),
4244 // has nodes, edges, etc in VISIBLE! actor
4245 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4246 hasElems("(count( elemTypes ) > 0)"),
4247 hasDifferentElems("(count( elemTypes ) > 1)"),
4248 hasBalls("({'BallElem'} in elemTypes)"),
4249 hasElems0d("({'Elem0d'} in elemTypes)"),
4250 hasEdges("({'Edge'} in elemTypes)"),
4251 hasFaces("({'Face'} in elemTypes)"),
4252 hasVolumes("({'Volume'} in elemTypes)");
4254 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4255 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4256 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4257 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4258 createPopupItem( 803, OB, group ); // EDIT_GROUP
4259 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4261 popupMgr()->insert( separator(), -1, 0 );
4262 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4263 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4264 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4265 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4266 createPopupItem( 214, OB, mesh_part ); // UPDATE
4267 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4268 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4269 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4270 popupMgr()->insert( separator(), -1, 0 );
4271 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4272 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4273 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4274 popupMgr()->insert( separator(), -1, 0 );
4275 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4276 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4277 popupMgr()->insert( separator(), -1, 0 );
4278 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4279 popupMgr()->insert( separator(), -1, 0 );
4280 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4281 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4283 popupMgr()->insert( separator(), -1, 0 );
4285 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4286 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4287 QString only_one_2D = only_one_non_empty + " && dim>1";
4289 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4290 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4291 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4292 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4294 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4296 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4297 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4298 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4299 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4300 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4301 popupMgr()->insert( separator(), -1, 0 );
4304 createPopupItem( 803, View, group ); // EDIT_GROUP
4305 createPopupItem( 804, View, elems ); // ADD
4306 createPopupItem( 805, View, elems ); // REMOVE
4308 popupMgr()->insert( separator(), -1, 0 );
4309 createPopupItem( 214, View, mesh_part ); // UPDATE
4310 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4311 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4312 createPopupItem( 904, View, mesh ); // FIND_ELEM
4313 popupMgr()->insert( separator(), -1, 0 );
4315 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4316 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4317 popupMgr()->insert( separator(), -1, 0 );
4319 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4320 QString aType = QString( "%1type in {%2}" ).arg( lc );
4321 aType = aType.arg( mesh_part );
4322 QString aMeshInVTK = aClient + "&&" + aType;
4324 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4325 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4326 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4328 //-------------------------------------------------
4330 //-------------------------------------------------
4331 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4333 popupMgr()->insert( action( 9010 ), anId, -1 );
4334 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4335 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4337 popupMgr()->insert( action( 9011 ), anId, -1 );
4338 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4339 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4341 popupMgr()->insert( separator(), -1, -1 );
4343 //-------------------------------------------------
4345 //-------------------------------------------------
4346 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4348 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4349 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4350 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4352 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4353 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4354 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4356 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4357 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4358 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4360 popupMgr()->insert( separator(), anId, -1 );
4362 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4363 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4364 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4366 //-------------------------------------------------
4368 //-------------------------------------------------
4369 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4371 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4373 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4374 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4375 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4377 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4378 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4379 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4381 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4382 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4383 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4385 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4386 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4387 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4389 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4390 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4391 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4393 popupMgr()->insert( separator(), anId, -1 );
4395 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4396 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4399 //-------------------------------------------------
4400 // Representation of the 2D Quadratic elements
4401 //-------------------------------------------------
4402 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4403 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4404 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4405 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4407 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4408 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4409 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4411 //-------------------------------------------------
4412 // Orientation of faces
4413 //-------------------------------------------------
4414 popupMgr()->insert( action( 221 ), -1, -1 );
4415 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4416 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4418 //-------------------------------------------------
4420 //-------------------------------------------------
4421 popupMgr()->insert( action( 1132 ), -1, -1 );
4422 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4424 //-------------------------------------------------
4426 //-------------------------------------------------
4427 popupMgr()->insert( action( 1133 ), -1, -1 );
4428 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4430 //-------------------------------------------------
4432 //-------------------------------------------------
4434 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4435 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4436 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4437 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4439 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4441 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4442 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4444 popupMgr()->insert( separator(), anId, -1 );
4446 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4448 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4449 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4450 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4452 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4453 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4454 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4456 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4458 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4459 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4460 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4462 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4463 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4464 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4466 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4467 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4468 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4470 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4471 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4472 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4473 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4474 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4475 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4477 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4479 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4480 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4481 QtxPopupMgr::VisibleRule );
4482 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4484 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4485 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4486 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4488 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4489 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4490 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4492 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4493 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4494 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4496 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4497 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4498 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4500 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4501 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4502 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4504 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4505 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4506 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4508 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4509 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4510 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4512 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4513 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4514 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4516 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4517 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4518 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4520 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4521 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4522 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4524 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4525 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4526 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4527 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4528 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4529 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4531 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4533 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4534 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4535 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4537 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4538 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4539 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4541 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4542 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4543 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4545 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4546 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4547 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4549 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4550 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4551 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4553 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4554 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4555 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4557 popupMgr()->insert( separator(), anId, -1 );
4559 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4560 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4562 popupMgr()->insert( separator(), anId, -1 );
4564 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4566 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4567 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4569 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4570 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4571 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4573 #ifndef DISABLE_PLOT2DVIEWER
4574 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4575 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4578 //-------------------------------------------------
4580 //-------------------------------------------------
4581 popupMgr()->insert( separator(), -1, -1 );
4582 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4583 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4584 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4585 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4587 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4588 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4590 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4591 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4593 popupMgr()->insert( separator(), -1, -1 );
4595 //-------------------------------------------------
4597 //-------------------------------------------------
4598 popupMgr()->insert( action( 1134 ), -1, -1 );
4599 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4601 popupMgr()->insert( separator(), -1, -1 );
4603 popupMgr()->insert( action( 41 ), -1, -1 );
4604 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4605 popupMgr()->insert( separator(), -1, -1 );
4607 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4608 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4610 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4611 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4614 //================================================================================
4616 * \brief Return true if SMESH or GEOM objects are selected.
4617 * Is called form LightApp_Module::activateModule() which clear selection if
4618 * not isSelectionCompatible()
4620 //================================================================================
4622 bool SMESHGUI::isSelectionCompatible()
4624 bool isCompatible = true;
4625 SALOME_ListIO selected;
4626 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4627 Sel->selectedObjects( selected );
4629 SALOME_ListIteratorOfListIO It( selected );
4630 for ( ; isCompatible && It.More(); It.Next())
4632 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4633 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4635 return isCompatible;
4639 bool SMESHGUI::reusableOperation( const int id )
4641 // compute, evaluate and precompute are not reusable operations
4642 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4645 bool SMESHGUI::activateModule( SUIT_Study* study )
4647 bool res = SalomeApp_Module::activateModule( study );
4649 setMenuShown( true );
4650 setToolShown( true );
4652 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4653 PyGILState_STATE gstate = PyGILState_Ensure();
4654 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4655 if ( !pluginsmanager ) {
4659 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4663 PyGILState_Release(gstate);
4664 // end of SMESH plugins loading
4666 // Reset actions accelerator keys
4667 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4668 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4669 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4671 action( 33)->setEnabled(true); // Delete: Key_Delete
4673 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4674 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4675 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4676 if ( _PTR(Study) aStudy = s->studyDS()) {
4677 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4678 updateObjBrowser(); // objects can be removed
4681 // get all view currently opened in the study and connect their signals to
4682 // the corresponding slots of the class.
4683 SUIT_Desktop* aDesk = study->application()->desktop();
4685 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4686 SUIT_ViewWindow* wnd;
4687 foreach ( wnd, wndList )
4694 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4696 setMenuShown( false );
4697 setToolShown( false );
4699 EmitSignalCloseAllDialogs();
4701 // Unset actions accelerator keys
4702 //action(111)->setShortcut(QKeySequence()); // Import DAT
4703 action(112)->setShortcut(QKeySequence()); // Import UNV
4704 action(113)->setShortcut(QKeySequence()); // Import MED
4706 action( 33)->setEnabled(false); // Delete: Key_Delete
4708 return SalomeApp_Module::deactivateModule( study );
4711 void SMESHGUI::studyClosed( SUIT_Study* s )
4713 SMESH::RemoveVisuData( s->id() );
4714 SalomeApp_Module::studyClosed( s );
4717 void SMESHGUI::OnGUIEvent()
4719 const QObject* obj = sender();
4720 if ( !obj || !obj->inherits( "QAction" ) )
4722 int id = actionId((QAction*)obj);
4727 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4729 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4730 if ( CORBA::is_nil( myComponentSMESH ) )
4732 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4734 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4735 return aGUI.myComponentSMESH;
4738 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4739 return myComponentSMESH;
4742 QString SMESHGUI::engineIOR() const
4744 CORBA::ORB_var anORB = getApp()->orb();
4745 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4746 return QString( anIOR.in() );
4749 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4751 SalomeApp_Module::contextMenuPopup( client, menu, title );
4753 selectionMgr()->selectedObjects( lst );
4754 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4755 Handle(SALOME_InteractiveObject) io = lst.First();
4756 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4757 _PTR(Study) study = appStudy->studyDS();
4758 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4760 QString aName = QString( obj->GetName().c_str() );
4761 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4762 aName.remove( (aName.length() - 1), 1 );
4768 LightApp_Selection* SMESHGUI::createSelection() const
4770 return new SMESHGUI_Selection();
4773 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4775 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4776 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4779 void SMESHGUI::viewManagers( QStringList& list ) const
4781 list.append( SVTK_Viewer::Type() );
4784 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4786 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4787 SMESH::UpdateSelectionProp( this );
4789 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4790 for(int i = 0; i < aViews.count() ; i++){
4791 SUIT_ViewWindow *sf = aViews[i];
4797 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4799 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4800 myClippingPlaneInfoMap.erase( theViewManager );
4803 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4805 theActor->AddObserver( SMESH::DeleteActorEvent,
4806 myEventCallbackCommand.GetPointer(),
4810 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4811 unsigned long theEvent,
4812 void* theClientData,
4815 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4816 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4817 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4818 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4819 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4820 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4821 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4822 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4823 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4824 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4825 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4826 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4827 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4828 if( anActor == *anIter3 ) {
4829 anActorList.erase( anIter3 );
4840 void SMESHGUI::createPreferences()
4842 // General tab ------------------------------------------------------------------------
4843 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4845 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4846 setPreferenceProperty( autoUpdate, "columns", 2 );
4847 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4848 setPreferenceProperty( lim, "min", 0 );
4849 setPreferenceProperty( lim, "max", 100000000 );
4850 setPreferenceProperty( lim, "step", 1000 );
4851 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4852 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4854 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4855 setPreferenceProperty( qaGroup, "columns", 2 );
4856 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4857 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4858 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4859 setPreferenceProperty( prec, "min", 0 );
4860 setPreferenceProperty( prec, "max", 16 );
4861 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4862 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4863 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4864 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4865 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4867 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4868 setPreferenceProperty( dispgroup, "columns", 2 );
4869 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4871 modes.append( tr("MEN_WIRE") );
4872 modes.append( tr("MEN_SHADE") );
4873 modes.append( tr("MEN_NODES") );
4874 modes.append( tr("MEN_SHRINK") );
4875 QList<QVariant> indices;
4876 indices.append( 0 );
4877 indices.append( 1 );
4878 indices.append( 2 );
4879 indices.append( 3 );
4880 setPreferenceProperty( dispmode, "strings", modes );
4881 setPreferenceProperty( dispmode, "indexes", indices );
4883 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4884 setPreferenceProperty( arcgroup, "columns", 2 );
4885 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4886 QStringList quadraticModes;
4887 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4888 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4890 indices.append( 0 );
4891 indices.append( 1 );
4892 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4893 setPreferenceProperty( quadraticmode, "indexes", indices );
4895 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4896 "SMESH", "max_angle" );
4897 setPreferenceProperty( maxAngle, "min", 1 );
4898 setPreferenceProperty( maxAngle, "max", 90 );
4902 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4903 setPreferenceProperty( exportgroup, "columns", 2 );
4904 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4905 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4907 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4908 setPreferenceProperty( computeGroup, "columns", 2 );
4909 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4911 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4912 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4913 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4915 indices.append( 0 );
4916 indices.append( 1 );
4917 indices.append( 2 );
4918 setPreferenceProperty( notifyMode, "strings", modes );
4919 setPreferenceProperty( notifyMode, "indexes", indices );
4921 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4922 setPreferenceProperty( infoGroup, "columns", 2 );
4923 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4925 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4926 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4928 indices.append( 0 );
4929 indices.append( 1 );
4930 setPreferenceProperty( elemInfo, "strings", modes );
4931 setPreferenceProperty( elemInfo, "indexes", indices );
4932 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4933 setPreferenceProperty( nodesLim, "min", 0 );
4934 setPreferenceProperty( nodesLim, "max", 10000000 );
4935 setPreferenceProperty( nodesLim, "step", 10000 );
4936 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4937 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4938 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4939 setPreferenceProperty( ctrlLim, "min", 0 );
4940 setPreferenceProperty( ctrlLim, "max", 10000000 );
4941 setPreferenceProperty( ctrlLim, "step", 1000 );
4942 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4943 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4944 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4945 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4946 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4948 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4949 setPreferenceProperty( segGroup, "columns", 2 );
4950 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4951 "SMESH", "segmentation" );
4952 setPreferenceProperty( segLen, "min", 1 );
4953 setPreferenceProperty( segLen, "max", 10000000 );
4954 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4955 "SMESH", "nb_segments_per_edge" );
4956 setPreferenceProperty( nbSeg, "min", 1 );
4957 setPreferenceProperty( nbSeg, "max", 10000000 );
4959 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4960 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4961 "SMESH", "forget_mesh_on_hyp_modif" );
4964 // Quantities with individual precision settings
4965 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4966 setPreferenceProperty( precGroup, "columns", 2 );
4968 const int nbQuantities = 6;
4969 int precs[nbQuantities], ii = 0;
4970 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4971 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4972 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4973 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4974 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4975 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4976 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4977 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4978 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4979 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4980 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4981 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4983 // Set property for precision value for spinboxes
4984 for ( ii = 0; ii < nbQuantities; ii++ ){
4985 setPreferenceProperty( precs[ii], "min", -14 );
4986 setPreferenceProperty( precs[ii], "max", 14 );
4987 setPreferenceProperty( precs[ii], "precision", 2 );
4990 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4991 setPreferenceProperty( previewGroup, "columns", 2 );
4992 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4993 setPreferenceProperty( chunkSize, "min", 1 );
4994 setPreferenceProperty( chunkSize, "max", 1000 );
4995 setPreferenceProperty( chunkSize, "step", 50 );
4997 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4998 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5000 // Mesh tab ------------------------------------------------------------------------
5001 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5002 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5003 setPreferenceProperty( nodeGroup, "columns", 3 );
5005 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5007 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5009 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5010 QList<QVariant> aMarkerTypeIndicesList;
5011 QList<QVariant> aMarkerTypeIconsList;
5012 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5013 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5014 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5015 aMarkerTypeIndicesList << i;
5016 aMarkerTypeIconsList << pixmap;
5018 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5019 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5021 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5023 QList<QVariant> aMarkerScaleIndicesList;
5024 QStringList aMarkerScaleValuesList;
5025 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5026 aMarkerScaleIndicesList << i;
5027 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5029 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5030 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5032 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5033 //setPreferenceProperty( elemGroup, "columns", 2 );
5035 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5036 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5037 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5038 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5039 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5040 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5041 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5042 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5043 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5046 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5047 setPreferenceProperty( grpGroup, "columns", 2 );
5049 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5050 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5052 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5053 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5054 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5055 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5056 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5057 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5058 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5059 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5060 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5061 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5063 setPreferenceProperty( size0d, "min", 1 );
5064 setPreferenceProperty( size0d, "max", 10 );
5066 setPreferenceProperty( ballSize, "min", 1 );
5067 setPreferenceProperty( ballSize, "max", 10 );
5069 setPreferenceProperty( elemW, "min", 1 );
5070 setPreferenceProperty( elemW, "max", 5 );
5072 setPreferenceProperty( outW, "min", 1 );
5073 setPreferenceProperty( outW, "max", 5 );
5075 setPreferenceProperty( shrink, "min", 0 );
5076 setPreferenceProperty( shrink, "max", 100 );
5078 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5079 setPreferenceProperty( numGroup, "columns", 2 );
5081 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5082 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5084 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5085 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5087 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5088 setPreferenceProperty( orientGroup, "columns", 1 );
5090 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5091 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5093 setPreferenceProperty( orientScale, "min", 0.05 );
5094 setPreferenceProperty( orientScale, "max", 0.5 );
5095 setPreferenceProperty( orientScale, "step", 0.05 );
5097 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5099 // Selection tab ------------------------------------------------------------------------
5100 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5102 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5103 setPreferenceProperty( selGroup, "columns", 2 );
5105 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5106 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5108 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5109 setPreferenceProperty( preGroup, "columns", 2 );
5111 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5113 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5114 setPreferenceProperty( precSelGroup, "columns", 2 );
5116 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5117 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5118 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5120 // Scalar Bar tab ------------------------------------------------------------------------
5121 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5122 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5123 setPreferenceProperty( fontGr, "columns", 2 );
5125 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5126 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5128 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5129 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5131 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5132 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5134 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5135 setPreferenceProperty( numcol, "min", 2 );
5136 setPreferenceProperty( numcol, "max", 256 );
5138 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5139 setPreferenceProperty( numlab, "min", 2 );
5140 setPreferenceProperty( numlab, "max", 65 );
5142 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5143 setPreferenceProperty( orientGr, "columns", 2 );
5144 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5145 QStringList orients;
5146 orients.append( tr( "SMESH_VERTICAL" ) );
5147 orients.append( tr( "SMESH_HORIZONTAL" ) );
5148 indices.clear(); indices.append( 0 ); indices.append( 1 );
5149 setPreferenceProperty( orient, "strings", orients );
5150 setPreferenceProperty( orient, "indexes", indices );
5152 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5153 setPreferenceProperty( posVSizeGr, "columns", 2 );
5154 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5155 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5156 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5157 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5158 setPreferenceProperty( xv, "step", 0.1 );
5159 setPreferenceProperty( xv, "min", 0.0 );
5160 setPreferenceProperty( xv, "max", 1.0 );
5161 setPreferenceProperty( yv, "step", 0.1 );
5162 setPreferenceProperty( yv, "min", 0.0 );
5163 setPreferenceProperty( yv, "max", 1.0 );
5164 setPreferenceProperty( wv, "step", 0.1 );
5165 setPreferenceProperty( wv, "min", 0.0 );
5166 setPreferenceProperty( wv, "max", 1.0 );
5167 setPreferenceProperty( hv, "min", 0.0 );
5168 setPreferenceProperty( hv, "max", 1.0 );
5169 setPreferenceProperty( hv, "step", 0.1 );
5171 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5172 setPreferenceProperty( posHSizeGr, "columns", 2 );
5173 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5174 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5175 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5176 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5177 setPreferenceProperty( xv, "min", 0.0 );
5178 setPreferenceProperty( xv, "max", 1.0 );
5179 setPreferenceProperty( xv, "step", 0.1 );
5180 setPreferenceProperty( xh, "min", 0.0 );
5181 setPreferenceProperty( xh, "max", 1.0 );
5182 setPreferenceProperty( xh, "step", 0.1 );
5183 setPreferenceProperty( yh, "min", 0.0 );
5184 setPreferenceProperty( yh, "max", 1.0 );
5185 setPreferenceProperty( yh, "step", 0.1 );
5186 setPreferenceProperty( wh, "min", 0.0 );
5187 setPreferenceProperty( wh, "max", 1.0 );
5188 setPreferenceProperty( wh, "step", 0.1 );
5189 setPreferenceProperty( hh, "min", 0.0 );
5190 setPreferenceProperty( hh, "max", 1.0 );
5191 setPreferenceProperty( hh, "step", 0.1 );
5193 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5194 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5195 setPreferenceProperty( distributionGr, "columns", 3 );
5197 types.append( tr( "SMESH_MONOCOLOR" ) );
5198 types.append( tr( "SMESH_MULTICOLOR" ) );
5199 indices.clear(); indices.append( 0 ); indices.append( 1 );
5200 setPreferenceProperty( coloringType, "strings", types );
5201 setPreferenceProperty( coloringType, "indexes", indices );
5202 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5206 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5208 if( sect=="SMESH" ) {
5209 float sbX1,sbY1,sbW,sbH;
5210 float aTol = 1.00000009999999;
5211 std::string aWarning;
5212 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5213 if( name=="selection_object_color" || name=="selection_element_color" ||
5214 name=="highlight_color" ||
5215 name=="selection_precision_node" || name=="selection_precision_element" ||
5216 name=="selection_precision_object")
5217 SMESH::UpdateSelectionProp( this );
5218 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5219 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5220 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5221 if(sbX1+sbW > aTol){
5222 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5225 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5226 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5229 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5230 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5231 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5232 if(sbY1+sbH > aTol){
5233 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5234 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5235 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5238 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5239 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5240 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5241 if(sbX1+sbW > aTol){
5242 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5245 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5246 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5249 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5250 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5251 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5252 if(sbY1+sbH > aTol){
5253 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5256 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5257 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5260 else if ( name == "segmentation" ) {
5261 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5262 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5264 else if ( name == "nb_segments_per_edge" ) {
5265 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5266 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5268 else if ( name == "historical_python_dump" ||
5269 name == "forget_mesh_on_hyp_modif") {
5270 QString val = aResourceMgr->stringValue( "SMESH", name );
5271 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5273 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5274 SMESH::UpdateFontProp( this );
5276 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5277 SMESH::UpdateFontProp( this );
5280 if(aWarning.size() != 0){
5281 aWarning += "The default values are applied instead.";
5282 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5283 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5284 QObject::tr(aWarning.c_str()));
5289 //================================================================================
5291 * \brief Update something in accordance with update flags
5292 * \param theFlags - update flags
5294 * Update viewer or/and object browser etc. in accordance with update flags ( see
5295 * LightApp_UpdateFlags enumeration ).
5297 //================================================================================
5298 void SMESHGUI::update( const int flags )
5300 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5301 SMESH::UpdateView();
5303 SalomeApp_Module::update( flags );
5306 //================================================================================
5308 * \brief Set default selection mode
5310 * SLOT called when operation commited. Sets default selection mode
5312 //================================================================================
5313 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5315 SVTK_ViewWindow* vtkWnd =
5316 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5318 vtkWnd->SetSelectionMode( ActorSelection );
5321 //================================================================================
5323 * \brief Set default selection mode
5325 * SLOT called when operation aborted. Sets default selection mode
5327 //================================================================================
5328 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5330 SVTK_ViewWindow* vtkWnd =
5331 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5333 vtkWnd->SetSelectionMode( ActorSelection );
5336 //================================================================================
5338 * \brief Creates operation with given identifier
5339 * \param id - identifier of operation to be started
5340 * \return Pointer on created operation or NULL if operation is not created
5342 * Virtual method redefined from the base class creates operation with given id.
5343 * It is called called automatically from startOperation method of base class.
5345 //================================================================================
5346 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5348 LightApp_Operation* op = 0;
5349 // to do : create operation here
5352 case 417: //convert to quadratic
5353 op = new SMESHGUI_ConvToQuadOp();
5355 case 418: // create 2D mesh as boundary on 3D
5356 op = new SMESHGUI_Make2DFrom3DOp();
5358 case 420: // Reorient faces
5359 op = new SMESHGUI_ReorientFacesOp();
5361 case 701: // Compute mesh
5362 op = new SMESHGUI_ComputeOp();
5364 case 702: // Create mesh
5365 op = new SMESHGUI_MeshOp( true, true );
5367 case 703: // Create sub-mesh
5368 op = new SMESHGUI_MeshOp( true, false );
5370 case 704: // Edit mesh/sub-mesh
5371 op = new SMESHGUI_MeshOp( false );
5373 case 711: // Precompute mesh
5374 op = new SMESHGUI_PrecomputeOp();
5376 case 712: // Evaluate mesh
5377 op = new SMESHGUI_EvaluateOp();
5379 case 713: // Evaluate mesh
5380 op = new SMESHGUI_MeshOrderOp();
5382 case 806: // Create group on geom
5383 op = new SMESHGUI_GroupOnShapeOp();
5385 case 904: // Find element
5386 op = new SMESHGUI_FindElemByPointOp();
5388 case 4067: // Make mesh pass through point
5389 op = new SMESHGUI_MakeNodeAtPointOp();
5391 case 4070: // Create 0D elements on all nodes
5392 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5399 op = SalomeApp_Module::createOperation( id );
5403 //================================================================================
5405 * \brief Stops current operations and starts a given one
5406 * \param id - The id of the operation to start
5408 //================================================================================
5410 void SMESHGUI::switchToOperation(int id)
5412 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5413 activeStudy()->abortAllOperations();
5414 startOperation( id );
5417 LightApp_Displayer* SMESHGUI::displayer()
5420 myDisplayer = new SMESHGUI_Displayer( getApp() );
5424 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5427 int aTolerance = 64;
5428 int anIterations = 0;
5434 if( anIterations % aPeriod == 0 )
5437 if( aTolerance < 1 )
5441 aHue = (int)( 360.0 * rand() / RAND_MAX );
5444 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5445 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5446 for( ; it != itEnd; ++it )
5448 SALOMEDS::Color anAutoColor = *it;
5449 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5452 aQColor.getHsv( &h, &s, &v );
5453 if( abs( h - aHue ) < aTolerance )
5465 aColor.setHsv( aHue, 255, 255 );
5467 SALOMEDS::Color aSColor;
5468 aSColor.R = aColor.redF();
5469 aSColor.G = aColor.greenF();
5470 aSColor.B = aColor.blueF();
5475 const char* gSeparator = "_"; // character used to separate parameter names
5476 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5477 const char* gPathSep = "|"; // character used to separate paths
5480 * \brief Store visual parameters
5482 * This method is called just before the study document is saved.
5483 * Store visual parameters in AttributeParameter attribue(s)
5485 void SMESHGUI::storeVisualParameters (int savePoint)
5488 Kernel_Utils::Localizer loc;
5490 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5491 if (!appStudy || !appStudy->studyDS())
5493 _PTR(Study) studyDS = appStudy->studyDS();
5495 // componentName is used for encoding of entries when storing them in IParameters
5496 std::string componentName = myComponentSMESH->ComponentDataType();
5497 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5498 //if (!aSComponent) return;
5501 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5502 componentName.c_str(),
5504 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5506 // store map of custom markers
5507 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5508 if( !aMarkerMap.empty() )
5510 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5511 for( ; anIter != aMarkerMap.end(); anIter++ )
5513 int anId = anIter->first;
5514 VTK::MarkerData aMarkerData = anIter->second;
5515 std::string aMarkerFileName = aMarkerData.first;
5516 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5517 if( aMarkerTexture.size() < 3 )
5518 continue; // should contain at least width, height and the first value
5520 QString aPropertyName( "texture" );
5521 aPropertyName += gSeparator;
5522 aPropertyName += QString::number( anId );
5524 QString aPropertyValue = aMarkerFileName.c_str();
5525 aPropertyValue += gPathSep;
5527 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5528 ushort aWidth = *aTextureIter++;
5529 ushort aHeight = *aTextureIter++;
5530 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5531 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5532 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5533 aPropertyValue += QString::number( *aTextureIter );
5535 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5539 // viewers counters are used for storing view_numbers in IParameters
5542 // main cycle to store parameters of displayed objects
5543 QList<SUIT_ViewManager*> lst;
5544 QList<SUIT_ViewManager*>::Iterator it;
5545 getApp()->viewManagers(lst);
5546 for (it = lst.begin(); it != lst.end(); it++)
5548 SUIT_ViewManager* vman = *it;
5549 QString vType = vman->getType();
5551 // saving VTK actors properties
5552 if (vType == SVTK_Viewer::Type())
5554 // store the clipping planes attached to the view manager
5555 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5556 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5557 if( anIter != myClippingPlaneInfoMap.end() )
5558 aClippingPlaneInfoList = anIter->second;
5560 if( !aClippingPlaneInfoList.empty() ) {
5561 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5562 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5564 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5565 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5567 QString aPropertyName( "ClippingPlane" );
5568 aPropertyName += gSeparator;
5569 aPropertyName += QString::number( vtkViewers );
5570 aPropertyName += gSeparator;
5571 aPropertyName += QString::number( anId );
5573 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5574 aPropertyValue += gDigitsSep;
5575 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5576 aPropertyValue += gDigitsSep;
5577 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5578 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5579 aPropertyValue += gDigitsSep;
5580 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5581 aPropertyValue += gDigitsSep;
5582 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5583 aPropertyValue += gDigitsSep;
5584 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5585 aPropertyValue += gDigitsSep;
5586 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5587 aPropertyValue += gDigitsSep;
5588 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5589 aPropertyValue += gDigitsSep;
5590 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5592 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5593 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5594 aPropertyValue += gDigitsSep;
5595 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5596 aPropertyValue += gDigitsSep;
5597 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5598 aPropertyValue += gDigitsSep;
5599 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5602 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5606 QVector<SUIT_ViewWindow*> views = vman->getViews();
5607 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5609 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5611 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5612 vtkActorCollection* allActors = aCopy.GetActors();
5613 allActors->InitTraversal();
5614 while (vtkActor* actor = allActors->GetNextActor())
5616 if (actor->GetVisibility()) // store only visible actors
5618 SMESH_Actor* aSmeshActor = 0;
5619 if (actor->IsA("SMESH_Actor"))
5620 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5621 if (aSmeshActor && aSmeshActor->hasIO())
5623 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5626 // entry is "encoded" = it does NOT contain component adress,
5627 // since it is a subject to change on next component loading
5628 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5630 std::string param, vtkParam = vType.toLatin1().data();
5631 vtkParam += gSeparator;
5632 vtkParam += QString::number(vtkViewers).toLatin1().data();
5633 vtkParam += gSeparator;
5636 param = vtkParam + "Visibility";
5637 ip->setParameter(entry, param, "On");
5640 param = vtkParam + "Representation";
5641 ip->setParameter(entry, param, QString::number
5642 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5645 param = vtkParam + "IsShrunk";
5646 ip->setParameter(entry, param, QString::number
5647 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5649 // Displayed entities
5650 unsigned int aMode = aSmeshActor->GetEntityMode();
5651 bool isE = aMode & SMESH_Actor::eEdges;
5652 bool isF = aMode & SMESH_Actor::eFaces;
5653 bool isV = aMode & SMESH_Actor::eVolumes;
5654 bool is0d = aMode & SMESH_Actor::e0DElements;
5655 bool isB = aMode & SMESH_Actor::eBallElem;
5657 QString modeStr ("e");
5658 modeStr += gDigitsSep; modeStr += QString::number(isE);
5659 modeStr += gDigitsSep; modeStr += "f";
5660 modeStr += gDigitsSep; modeStr += QString::number(isF);
5661 modeStr += gDigitsSep; modeStr += "v";
5662 modeStr += gDigitsSep; modeStr += QString::number(isV);
5663 modeStr += gDigitsSep; modeStr += "0d";
5664 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5665 modeStr += gDigitsSep; modeStr += "b";
5666 modeStr += gDigitsSep; modeStr += QString::number(isB);
5668 param = vtkParam + "Entities";
5669 ip->setParameter(entry, param, modeStr.toLatin1().data());
5675 aSmeshActor->GetSufaceColor(r, g, b, delta);
5676 QStringList colorStr;
5677 colorStr << "surface";
5678 colorStr << QString::number(r);
5679 colorStr << QString::number(g);
5680 colorStr << QString::number(b);
5682 colorStr << "backsurface";
5683 colorStr << QString::number(delta);
5685 aSmeshActor->GetVolumeColor(r, g, b, delta);
5686 colorStr << "volume";
5687 colorStr << QString::number(r);
5688 colorStr << QString::number(g);
5689 colorStr << QString::number(b);
5690 colorStr << QString::number(delta);
5692 aSmeshActor->GetEdgeColor(r, g, b);
5694 colorStr << QString::number(r);
5695 colorStr << QString::number(g);
5696 colorStr << QString::number(b);
5698 aSmeshActor->GetNodeColor(r, g, b);
5700 colorStr << QString::number(r);
5701 colorStr << QString::number(g);
5702 colorStr << QString::number(b);
5704 aSmeshActor->GetOutlineColor(r, g, b);
5705 colorStr << "outline";
5706 colorStr << QString::number(r);
5707 colorStr << QString::number(g);
5708 colorStr << QString::number(b);
5710 aSmeshActor->Get0DColor(r, g, b);
5711 colorStr << "elem0d";
5712 colorStr << QString::number(r);
5713 colorStr << QString::number(g);
5714 colorStr << QString::number(b);
5716 aSmeshActor->GetBallColor(r, g, b);
5718 colorStr << QString::number(r);
5719 colorStr << QString::number(g);
5720 colorStr << QString::number(b);
5722 aSmeshActor->GetFacesOrientationColor(r, g, b);
5723 colorStr << "orientation";
5724 colorStr << QString::number(r);
5725 colorStr << QString::number(g);
5726 colorStr << QString::number(b);
5728 param = vtkParam + "Colors";
5729 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5732 QStringList sizeStr;
5734 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5735 sizeStr << "outline";
5736 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5737 sizeStr << "elem0d";
5738 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5740 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5741 sizeStr << "shrink";
5742 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5743 sizeStr << "orientation";
5744 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5745 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5747 param = vtkParam + "Sizes";
5748 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5753 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5754 if( aMarkerType == VTK::MT_USER ) {
5755 markerStr += "custom";
5756 markerStr += gDigitsSep;
5757 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5761 markerStr += gDigitsSep;
5762 markerStr += QString::number( (int)aMarkerType );
5763 markerStr += gDigitsSep;
5764 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5767 param = vtkParam + "PointMarker";
5768 ip->setParameter(entry, param, markerStr.toLatin1().data());
5771 param = vtkParam + "Opacity";
5772 ip->setParameter(entry, param,
5773 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5776 param = vtkParam + "ClippingPlane";
5778 if( !aClippingPlaneInfoList.empty() ) {
5779 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5780 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5782 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5783 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5784 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5785 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5786 if( aSmeshActor == *anIter2 ) {
5787 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5788 QString::number( anId ).toLatin1().constData() );
5795 ip->setParameter( entry, param, "Off" );
5796 } // if (io->hasEntry())
5797 } // SMESH_Actor && hasIO
5799 } // while.. actors traversal
5803 } // if (SVTK view model)
5804 } // for (viewManagers)
5807 // data structures for clipping planes processing
5811 bool isOpenGLClipping;
5812 vtkIdType RelativeOrientation;
5815 int AbsoluteOrientation;
5816 double X, Y, Z, Dx, Dy, Dz;
5818 typedef std::list<TPlaneData> TPlaneDataList;
5819 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5821 typedef std::list<vtkActor*> TActorList;
5824 TActorList ActorList;
5825 SUIT_ViewManager* ViewManager;
5827 typedef std::list<TPlaneInfo> TPlaneInfoList;
5828 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5831 * \brief Restore visual parameters
5833 * This method is called after the study document is opened.
5834 * Restore visual parameters from AttributeParameter attribue(s)
5836 void SMESHGUI::restoreVisualParameters (int savePoint)
5839 Kernel_Utils::Localizer loc;
5841 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5842 if (!appStudy || !appStudy->studyDS())
5844 _PTR(Study) studyDS = appStudy->studyDS();
5846 // componentName is used for encoding of entries when storing them in IParameters
5847 std::string componentName = myComponentSMESH->ComponentDataType();
5848 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5849 //if (!aSComponent) return;
5852 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5853 componentName.c_str(),
5855 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5857 // restore map of custom markers and map of clipping planes
5858 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5859 TPlaneDataMap aPlaneDataMap;
5861 std::vector<std::string> properties = ip->getProperties();
5862 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5864 std::string property = *propIt;
5865 QString aPropertyName( property.c_str() );
5866 QString aPropertyValue( ip->getProperty( property ).c_str() );
5868 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5869 if( aPropertyNameList.isEmpty() )
5872 QString aPropertyType = aPropertyNameList[0];
5873 if( aPropertyType == "texture" )
5875 if( aPropertyNameList.size() != 2 )
5879 int anId = aPropertyNameList[1].toInt( &ok );
5880 if( !ok || anId < 1 )
5883 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5884 if( aPropertyValueList.size() != 2 )
5887 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5888 QString aMarkerTextureString = aPropertyValueList[1];
5889 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5890 if( aMarkerTextureStringList.size() != 3 )
5894 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5899 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5903 VTK::MarkerTexture aMarkerTexture;
5904 aMarkerTexture.push_back( aWidth );
5905 aMarkerTexture.push_back( aHeight );
5907 QString aMarkerTextureData = aMarkerTextureStringList[2];
5908 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5910 QChar aChar = aMarkerTextureData.at( i );
5911 if( aChar.isDigit() )
5912 aMarkerTexture.push_back( aChar.digitValue() );
5915 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5917 else if( aPropertyType == "ClippingPlane" )
5919 if( aPropertyNameList.size() != 3 )
5923 int aViewId = aPropertyNameList[1].toInt( &ok );
5924 if( !ok || aViewId < 0 )
5928 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5929 if( !ok || aClippingPlaneId < 0 )
5932 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5933 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
5936 TPlaneData aPlaneData;
5937 aPlaneData.Id = aClippingPlaneId;
5940 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
5945 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
5949 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
5952 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
5957 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
5962 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
5967 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
5972 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
5977 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
5982 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
5986 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
5988 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
5993 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
5998 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6003 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6008 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6009 aPlaneDataList.push_back( aPlaneData );
6013 TPlaneInfoMap aPlaneInfoMap;
6015 std::vector<std::string> entries = ip->getEntries();
6017 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6019 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6020 QString entry (ip->decodeEntry(*entIt).c_str());
6022 // Check that the entry corresponds to a real object in the Study
6023 // as the object may be deleted or modified after the visual state is saved.
6024 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6025 if (!so) continue; //Skip the not existent entry
6027 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6028 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6030 std::vector<std::string>::iterator namesIt = paramNames.begin();
6031 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6033 // actors are stored in a map after displaying of them for
6034 // quicker access in the future: map < viewID to actor >
6035 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6037 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6039 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6040 // '_' is used as separator and should not be used in viewer type or parameter names.
6041 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6042 if (lst.size() != 3)
6045 QString viewerTypStr = lst[0];
6046 QString viewIndexStr = lst[1];
6047 QString paramNameStr = lst[2];
6050 int viewIndex = viewIndexStr.toUInt(&ok);
6051 if (!ok) // bad conversion of view index to integer
6055 if (viewerTypStr == SVTK_Viewer::Type())
6057 SMESH_Actor* aSmeshActor = 0;
6058 if (vtkActors.IsBound(viewIndex))
6059 aSmeshActor = vtkActors.Find(viewIndex);
6061 QList<SUIT_ViewManager*> lst;
6062 getApp()->viewManagers(viewerTypStr, lst);
6064 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6065 SUIT_ViewManager* vman = NULL;
6066 if (viewIndex >= 0 && viewIndex < lst.count())
6067 vman = lst.at(viewIndex);
6069 if (paramNameStr == "Visibility")
6071 if (!aSmeshActor && displayer() && vman)
6073 SUIT_ViewModel* vmodel = vman->getViewModel();
6074 // SVTK view model can be casted to SALOME_View
6075 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6077 // store displayed actor in a temporary map for quicker
6078 // access later when restoring other parameters
6079 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6080 vtkRenderer* Renderer = vtkView->getRenderer();
6081 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6082 vtkActorCollection* theActors = aCopy.GetActors();
6083 theActors->InitTraversal();
6084 bool isFound = false;
6085 vtkActor *ac = theActors->GetNextActor();
6086 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6087 if (ac->IsA("SMESH_Actor")) {
6088 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6089 if (aGeomAc->hasIO()) {
6090 Handle(SALOME_InteractiveObject) io =
6091 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6092 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6094 vtkActors.Bind(viewIndex, aGeomAc);
6100 } // if (paramNameStr == "Visibility")
6103 // the rest properties "work" with SMESH_Actor
6106 QString val ((*valuesIt).c_str());
6109 if (paramNameStr == "Representation") {
6110 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6113 else if (paramNameStr == "IsShrunk") {
6115 if (!aSmeshActor->IsShrunk())
6116 aSmeshActor->SetShrink();
6119 if (aSmeshActor->IsShrunk())
6120 aSmeshActor->UnShrink();
6123 // Displayed entities
6124 else if (paramNameStr == "Entities") {
6125 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6126 int aEntityMode = SMESH_Actor::eAllEntity;
6127 for ( int i = 0; i < mode.count(); i+=2 ) {
6128 if ( i < mode.count()-1 ) {
6129 QString type = mode[i];
6130 bool val = mode[i+1].toInt();
6131 if ( type == "e" && !val )
6132 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6133 else if ( type == "f" && !val )
6134 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6135 else if ( type == "v" && !val )
6136 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6137 else if ( type == "0d" && !val )
6138 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6139 else if ( type == "b" && !val )
6140 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6143 aSmeshActor->SetEntityMode( aEntityMode );
6146 else if (paramNameStr == "Colors") {
6147 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6154 QColor outlineColor;
6155 QColor orientationColor;
6161 // below lines are required to get default values for delta coefficients
6162 // of backface color for faces and color of reversed volumes
6163 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6164 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6165 for ( int i = 0; i < colors.count(); i++ ) {
6166 QString type = colors[i];
6167 if ( type == "surface" ) {
6168 // face color is set by 3 values r:g:b, where
6169 // - r,g,b - is rgb color components
6170 if ( i+1 >= colors.count() ) break; // format error
6171 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6172 if ( i+2 >= colors.count() ) break; // format error
6173 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6174 if ( i+3 >= colors.count() ) break; // format error
6175 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6176 faceColor.setRgbF( r, g, b );
6179 else if ( type == "backsurface" ) {
6180 // backface color can be defined in several ways
6181 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6182 // - in latest versions, it is set as delta coefficient
6183 bool rgbOk = false, deltaOk;
6184 if ( i+1 >= colors.count() ) break; // format error
6185 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6186 int delta = colors[i+1].toInt( &deltaOk );
6188 if ( i+1 < colors.count() ) // index is shifted to 1
6189 g = colors[i+1].toDouble( &rgbOk );
6190 if ( rgbOk ) i++; // shift index
6191 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6192 b = colors[i+1].toDouble( &rgbOk );
6194 // - as currently there's no way to set directly backsurface color as it was before,
6195 // we ignore old dump where r,g,b triple was set
6196 // - also we check that delta parameter is set properly
6197 if ( !rgbOk && deltaOk )
6200 else if ( type == "volume" ) {
6201 // volume color is set by 4 values r:g:b:delta, where
6202 // - r,g,b - is a normal volume rgb color components
6203 // - delta - is a reversed volume color delta coefficient
6204 if ( i+1 >= colors.count() ) break; // format error
6205 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6206 if ( i+2 >= colors.count() ) break; // format error
6207 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6208 if ( i+3 >= colors.count() ) break; // format error
6209 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6210 if ( i+4 >= colors.count() ) break; // format error
6211 int delta = colors[i+4].toInt( &bOk );
6212 if ( !bOk ) break; // format error
6213 volumeColor.setRgbF( r, g, b );
6217 else if ( type == "edge" ) {
6218 // edge color is set by 3 values r:g:b, where
6219 // - r,g,b - is rgb color components
6220 if ( i+1 >= colors.count() ) break; // format error
6221 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6222 if ( i+2 >= colors.count() ) break; // format error
6223 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6224 if ( i+3 >= colors.count() ) break; // format error
6225 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6226 edgeColor.setRgbF( r, g, b );
6229 else if ( type == "node" ) {
6230 // node color is set by 3 values r:g:b, where
6231 // - r,g,b - is rgb color components
6232 if ( i+1 >= colors.count() ) break; // format error
6233 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6234 if ( i+2 >= colors.count() ) break; // format error
6235 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6236 if ( i+3 >= colors.count() ) break; // format error
6237 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6238 nodeColor.setRgbF( r, g, b );
6241 else if ( type == "elem0d" ) {
6242 // 0d element color is set by 3 values r:g:b, where
6243 // - r,g,b - is rgb color components
6244 if ( i+1 >= colors.count() ) break; // format error
6245 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6246 if ( i+2 >= colors.count() ) break; // format error
6247 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6248 if ( i+3 >= colors.count() ) break; // format error
6249 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6250 elem0dColor.setRgbF( r, g, b );
6253 else if ( type == "ball" ) {
6254 // ball color is set by 3 values r:g:b, where
6255 // - r,g,b - is rgb color components
6256 if ( i+1 >= colors.count() ) break; // format error
6257 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6258 if ( i+2 >= colors.count() ) break; // format error
6259 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6260 if ( i+3 >= colors.count() ) break; // format error
6261 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6262 ballColor.setRgbF( r, g, b );
6265 else if ( type == "outline" ) {
6266 // outline color is set by 3 values r:g:b, where
6267 // - r,g,b - is rgb color components
6268 if ( i+1 >= colors.count() ) break; // format error
6269 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6270 if ( i+2 >= colors.count() ) break; // format error
6271 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6272 if ( i+3 >= colors.count() ) break; // format error
6273 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6274 outlineColor.setRgbF( r, g, b );
6277 else if ( type == "orientation" ) {
6278 // orientation color is set by 3 values r:g:b, where
6279 // - r,g,b - is rgb color components
6280 if ( i+1 >= colors.count() ) break; // format error
6281 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6282 if ( i+2 >= colors.count() ) break; // format error
6283 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6284 if ( i+3 >= colors.count() ) break; // format error
6285 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6286 orientationColor.setRgbF( r, g, b );
6291 if ( nodeColor.isValid() )
6292 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6294 if ( edgeColor.isValid() )
6295 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6297 if ( faceColor.isValid() )
6298 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6300 if ( volumeColor.isValid() )
6301 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6302 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6303 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6305 if ( elem0dColor.isValid() )
6306 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6308 if ( ballColor.isValid() )
6309 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6311 if ( outlineColor.isValid() )
6312 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6313 // orientation color
6314 if ( orientationColor.isValid() )
6315 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6318 else if (paramNameStr == "Sizes") {
6319 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6322 int outlineWidth = -1;
6323 int elem0dSize = -1;
6325 double shrinkSize = -1;
6326 double orientationSize = -1;
6327 bool orientation3d = false;
6328 for ( int i = 0; i < sizes.count(); i++ ) {
6329 QString type = sizes[i];
6330 if ( type == "line" ) {
6331 // line (wireframe) width is given as single integer value
6332 if ( i+1 >= sizes.count() ) break; // format error
6333 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6337 if ( type == "outline" ) {
6338 // outline width is given as single integer value
6339 if ( i+1 >= sizes.count() ) break; // format error
6340 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6344 else if ( type == "elem0d" ) {
6345 // 0d element size is given as single integer value
6346 if ( i+1 >= sizes.count() ) break; // format error
6347 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6351 else if ( type == "ball" ) {
6352 // ball size is given as single integer value
6353 if ( i+1 >= sizes.count() ) break; // format error
6354 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6358 else if ( type == "shrink" ) {
6359 // shrink factor is given as single floating point value
6360 if ( i+1 >= sizes.count() ) break; // format error
6361 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6365 else if ( type == "orientation" ) {
6366 // orientation vectors are specified by two values size:3d, where
6367 // - size - is a floating point value specifying scale factor
6368 // - 3d - is a boolean
6369 if ( i+1 >= sizes.count() ) break; // format error
6370 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6371 if ( i+2 >= sizes.count() ) break; // format error
6372 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6373 orientationSize = v1;
6374 orientation3d = (bool)v2;
6378 // line (wireframe) width
6379 if ( lineWidth > 0 )
6380 aSmeshActor->SetLineWidth( lineWidth );
6382 if ( outlineWidth > 0 )
6383 aSmeshActor->SetOutlineWidth( outlineWidth );
6384 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6385 aSmeshActor->SetOutlineWidth( lineWidth );
6387 if ( elem0dSize > 0 )
6388 aSmeshActor->Set0DSize( elem0dSize );
6391 aSmeshActor->SetBallSize( ballSize );
6393 if ( shrinkSize > 0 )
6394 aSmeshActor->SetShrinkFactor( shrinkSize );
6395 // orientation vectors
6396 if ( orientationSize > 0 ) {
6397 aSmeshActor->SetFacesOrientationScale( orientationSize );
6398 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6402 else if (paramNameStr == "PointMarker") {
6403 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6404 if( data.count() >= 2 ) {
6406 int aParam1 = data[1].toInt( &ok );
6408 if( data[0] == "std" && data.count() == 3 ) {
6409 int aParam2 = data[2].toInt( &ok );
6410 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6412 else if( data[0] == "custom" ) {
6413 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6414 if( markerIt != aMarkerMap.end() ) {
6415 VTK::MarkerData aMarkerData = markerIt->second;
6416 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6423 else if (paramNameStr == "Opacity") {
6424 aSmeshActor->SetOpacity(val.toFloat());
6427 else if (paramNameStr.startsWith("ClippingPlane")) {
6428 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6429 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6430 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6431 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6432 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6433 // new format - val looks like "Off" or "0" (plane id)
6434 // (note: in new format "Off" value is used only for consistency,
6435 // so it is processed together with values in old format)
6436 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6437 if( anIsOldFormat ) {
6438 if (paramNameStr == "ClippingPlane1" || val == "Off")
6439 aSmeshActor->RemoveAllClippingPlanes();
6441 QList<SUIT_ViewManager*> lst;
6442 getApp()->viewManagers(viewerTypStr, lst);
6443 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6444 if (viewIndex >= 0 && viewIndex < lst.count()) {
6445 SUIT_ViewManager* vman = lst.at(viewIndex);
6446 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6448 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6450 SMESH::TActorList anActorList;
6451 anActorList.push_back( aSmeshActor );
6452 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6453 aPlane->myViewWindow = vtkView;
6454 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6455 aPlane->PlaneMode = aMode;
6456 bool isOpenGLClipping = ( bool )vals[1].toInt();
6457 aPlane->IsOpenGLClipping = isOpenGLClipping;
6458 if ( aMode == SMESH::Absolute ) {
6459 aPlane->myAbsoluteOrientation = vals[2].toInt();
6460 aPlane->X = vals[3].toFloat();
6461 aPlane->Y = vals[4].toFloat();
6462 aPlane->Z = vals[5].toFloat();
6463 aPlane->Dx = vals[6].toFloat();
6464 aPlane->Dy = vals[7].toFloat();
6465 aPlane->Dz = vals[8].toFloat();
6467 else if ( aMode == SMESH::Relative ) {
6468 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6469 aPlane->myDistance = vals[3].toFloat();
6470 aPlane->myAngle[0] = vals[4].toFloat();
6471 aPlane->myAngle[1] = vals[5].toFloat();
6475 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6476 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6477 aClippingPlaneInfo.Plane = aPlane;
6478 aClippingPlaneInfo.ActorList = anActorList;
6479 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6487 int aPlaneId = val.toInt( &ok );
6488 if( ok && aPlaneId >= 0 ) {
6489 bool anIsDefinedPlane = false;
6490 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6491 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6492 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6493 TPlaneInfo& aPlaneInfo = *anIter;
6494 if( aPlaneInfo.PlaneId == aPlaneId ) {
6495 aPlaneInfo.ActorList.push_back( aSmeshActor );
6496 anIsDefinedPlane = true;
6500 if( !anIsDefinedPlane ) {
6501 TPlaneInfo aPlaneInfo;
6502 aPlaneInfo.PlaneId = aPlaneId;
6503 aPlaneInfo.ActorList.push_back( aSmeshActor );
6504 aPlaneInfo.ViewManager = vman;
6506 // to make the list sorted by plane id
6507 anIter = aPlaneInfoList.begin();
6508 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6509 const TPlaneInfo& aPlaneInfoRef = *anIter;
6510 if( aPlaneInfoRef.PlaneId > aPlaneId )
6513 aPlaneInfoList.insert( anIter, aPlaneInfo );
6518 } // if (aSmeshActor)
6519 } // other parameters than Visibility
6521 } // for names/parameters iterator
6522 } // for entries iterator
6524 // take into account planes with empty list of actors referred to them
6525 QList<SUIT_ViewManager*> aVMList;
6526 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6528 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6529 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6530 int aViewId = aPlaneDataIter->first;
6531 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6532 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6534 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6536 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6537 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6538 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6539 const TPlaneData& aPlaneData = *anIter2;
6540 int aPlaneId = aPlaneData.Id;
6542 bool anIsFound = false;
6543 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6544 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6545 const TPlaneInfo& aPlaneInfo = *anIter3;
6546 if( aPlaneInfo.PlaneId == aPlaneId ) {
6553 TPlaneInfo aPlaneInfo; // ActorList field is empty
6554 aPlaneInfo.PlaneId = aPlaneId;
6555 aPlaneInfo.ViewManager = aViewManager;
6557 // to make the list sorted by plane id
6558 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6559 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6560 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6561 if( aPlaneInfoRef.PlaneId > aPlaneId )
6564 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6570 // add clipping planes to actors according to the restored parameters
6571 // and update the clipping plane map
6572 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6573 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6574 int aViewId = anIter1->first;
6575 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6577 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6578 if( anIter2 == aPlaneDataMap.end() )
6580 const TPlaneDataList& aPlaneDataList = anIter2->second;
6582 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6583 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6584 const TPlaneInfo& aPlaneInfo = *anIter3;
6585 int aPlaneId = aPlaneInfo.PlaneId;
6586 const TActorList& anActorList = aPlaneInfo.ActorList;
6587 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6591 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6595 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6597 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6598 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6599 const TPlaneData& aPlaneData = *anIter4;
6600 if( aPlaneData.Id == aPlaneId ) {
6601 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6602 aPlane->myViewWindow = aViewWindow;
6603 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6604 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6605 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6606 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6607 aPlane->X = aPlaneData.X;
6608 aPlane->Y = aPlaneData.Y;
6609 aPlane->Z = aPlaneData.Z;
6610 aPlane->Dx = aPlaneData.Dx;
6611 aPlane->Dy = aPlaneData.Dy;
6612 aPlane->Dz = aPlaneData.Dz;
6614 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6615 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6616 aPlane->myDistance = aPlaneData.Distance;
6617 aPlane->myAngle[0] = aPlaneData.Angle[0];
6618 aPlane->myAngle[1] = aPlaneData.Angle[1];
6621 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6622 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6623 aClippingPlaneInfo.Plane = aPlane;
6624 aClippingPlaneInfo.ActorList = anActorList;
6625 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6636 // update all VTK views
6637 QList<SUIT_ViewManager*> lst;
6638 getApp()->viewManagers(lst);
6639 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6640 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6641 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6642 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6643 // set OpenGL clipping planes
6644 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6645 vtkActorCollection* anAllActors = aCopy.GetActors();
6646 anAllActors->InitTraversal();
6647 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6648 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6649 anActor->SetOpenGLClippingPlane();
6651 vtkView->getRenderer()->ResetCameraClippingRange();
6658 \brief Adds preferences for dfont of VTK viewer
6660 \param pIf group identifier
6661 \param param parameter
6662 \return identifier of preferences
6664 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6666 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6668 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6671 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6672 fam.append( tr( "SMESH_FONT_COURIER" ) );
6673 fam.append( tr( "SMESH_FONT_TIMES" ) );
6675 setPreferenceProperty( tfont, "fonts", fam );
6677 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6678 if ( needSize ) f = f | QtxFontEdit::Size;
6679 setPreferenceProperty( tfont, "features", f );
6685 \brief Actions after hypothesis edition
6686 Updates object browser after hypothesis edition
6688 void SMESHGUI::onHypothesisEdit( int result )
6691 SMESHGUI::Modified();
6692 updateObjBrowser( true );
6697 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6698 \param pview view being closed
6700 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6701 #ifndef DISABLE_PLOT2DVIEWER
6702 //Crear all Plot2d Viewers if need.
6703 SMESH::ClearPlot2Viewers(pview);
6707 void SMESHGUI::message( const QString& msg )
6710 QStringList data = msg.split("/");
6711 if ( data.count() > 0 ) {
6712 if ( data.first() == "mesh_loading" ) {
6714 QString entry = data.count() > 1 ? data[1] : QString();
6715 if ( entry.isEmpty() )
6718 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6720 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6723 name = obj->GetName().c_str();
6724 if ( name.isEmpty() )
6727 if ( data.last() == "stop" )
6728 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6730 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6731 QApplication::processEvents();
6737 \brief Connects or disconnects signals about activating and cloning view on the module slots
6738 \param pview view which is connected/disconnected
6740 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6744 SUIT_ViewManager* viewMgr = pview->getViewManager();
6746 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6747 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6749 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6750 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6755 \brief Return \c true if object can be renamed
6757 bool SMESHGUI::renameAllowed( const QString& entry) const {
6758 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6762 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6766 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6771 if(appStudy->isComponent(entry) || obj->isReference())
6774 // check type to prevent renaming of inappropriate objects
6775 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6776 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6777 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6778 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6779 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6780 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6787 Rename object by entry.
6788 \param entry entry of the object
6789 \param name new name of the object
6790 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6792 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6794 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6798 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6803 _PTR(Study) aStudy = appStudy->studyDS();
6808 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6810 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6815 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6816 _PTR(GenericAttribute) anAttr;
6817 _PTR(AttributeName) aName;
6819 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6821 // check type to prevent renaming of inappropriate objects
6822 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6823 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6824 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6825 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6826 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6827 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6828 if ( !name.isEmpty() ) {
6829 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6831 // update name of group object and its actor
6832 Handle(SALOME_InteractiveObject) IObject =
6833 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6835 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6836 if( !aGroupObject->_is_nil() ) {
6837 aGroupObject->SetName( qPrintable(name) );
6838 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6839 anActor->setName( qPrintable(name) );
6849 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6851 static QList<QColor> colors;
6853 if ( colors.isEmpty() ) {
6855 for (int s = 0; s < 2 ; s++)
6857 for (int v = 100; v >= 40; v = v - 20)
6859 for (int h = 0; h < 359 ; h = h + 60)
6861 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6866 static int currentColor = 0;
6868 SALOMEDS::Color color;
6869 color.R = (double)colors[currentColor].red() / 255.0;
6870 color.G = (double)colors[currentColor].green() / 255.0;
6871 color.B = (double)colors[currentColor].blue() / 255.0;
6873 currentColor = (currentColor+1) % colors.count();