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
188 //=============================================================
189 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
192 void ExportMeshToFile(int theCommandID);
194 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
196 void SetDisplayEntity(int theCommandID);
198 void Control( int theCommandID );
201 //================================================================================
203 * \brief Reads meshes from file
205 //================================================================================
207 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
211 std::string myExtension;
213 if ( theCommandID == 113 ) {
214 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
215 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
217 else if ( theCommandID == 112 ) {
218 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
220 else if ( theCommandID == 111 ) {
221 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
223 else if ( theCommandID == 115 ) {
224 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
226 else if ( theCommandID == 116 ) {
227 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
229 else if ( theCommandID == 117 ) {
230 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
231 filter.append( QObject::tr( "All files (*)" ) );
233 else if ( theCommandID == 118 ) {
234 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
235 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
238 QString anInitialPath = "";
239 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
240 anInitialPath = QDir::currentPath();
242 QStringList filenames;
243 bool toCreateGroups = true;
245 // if ( theCommandID == 118 ) { // GMF
246 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
247 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
248 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
249 // fd->setNameFilters( filter );
250 // fd->SetChecked( true );
252 // filenames << fd->selectedFile();
253 // toCreateGroups = fd->IsChecked();
259 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
262 QObject::tr( "SMESH_IMPORT_MESH" ) );
264 if ( filenames.count() > 0 ) {
265 SUIT_OverrideCursor wc;
266 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
269 QStringList anEntryList;
270 bool isEmpty = false;
271 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
272 QString filename = *it;
273 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
275 switch ( theCommandID ) {
278 // DAT format (currently unsupported)
279 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
280 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
286 aMeshes->length( 1 );
287 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
288 if ( aMeshes[0]->_is_nil() )
289 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
290 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
296 SMESH::DriverMED_ReadStatus res;
297 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
298 if ( res != SMESH::DRS_OK ) {
299 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
300 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
307 aMeshes->length( 1 );
308 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
309 if ( aMeshes[0]->_is_nil() ) {
310 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
311 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
318 SMESH::DriverMED_ReadStatus res;
319 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
320 if ( res != SMESH::DRS_OK ) {
321 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
322 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
329 SMESH::DriverMED_ReadStatus res;
330 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
331 if ( res != SMESH::DRS_OK ) {
332 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
333 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
340 SMESH::ComputeError_var res;
341 aMeshes->length( 1 );
342 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
345 if ( res->code != SMESH::DRS_OK ) {
346 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
347 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
348 if ( strlen( res->comment.in() ) > 0 ) {
349 errors.back() += ": ";
350 errors.back() += res->comment.in();
357 catch ( const SALOME::SALOME_Exception& S_ex ) {
358 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
359 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
362 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
363 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
365 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
366 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
367 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
368 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
369 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
371 anEntryList.append( aMeshSO->GetID().c_str() );
379 // update Object browser
380 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
382 // browse to the published meshes
383 if( LightApp_Application* anApp =
384 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
385 anApp->browseObjects( anEntryList );
387 // show Error message box if there were errors
388 if ( errors.count() > 0 ) {
389 SUIT_MessageBox::critical( SMESHGUI::desktop(),
390 QObject::tr( "SMESH_ERROR" ),
391 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
394 // show warning message box, if some imported mesh is empty
396 SUIT_MessageBox::warning( SMESHGUI::desktop(),
397 QObject::tr( "SMESH_WRN_WARNING" ),
398 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
403 //================================================================================
405 * \brief Export selected meshes or groups into a file
407 //================================================================================
409 void ExportMeshToFile( int theCommandID )
411 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
412 SALOME_ListIO selected;
414 aSel->selectedObjects( selected );
416 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
417 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
418 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
419 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
420 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
421 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
422 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
424 // actually, the following condition can't be met (added for insurance)
425 if( selected.Extent() == 0 ||
426 ( selected.Extent() > 1 && !isMED && !isSTL ))
429 // get mesh object from selection and check duplication of their names
430 bool hasDuplicatedMeshNames = false;
431 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
432 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
433 SALOME_ListIteratorOfListIO It( selected );
434 for( ; It.More(); It.Next() )
436 Handle(SALOME_InteractiveObject) anIObject = It.Value();
437 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
438 if ( aMeshItem->_is_nil() ) {
439 SUIT_MessageBox::warning( SMESHGUI::desktop(),
440 QObject::tr( "SMESH_WRN_WARNING" ),
441 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
445 QString aMeshName = anIObject->getName();
447 // check for name duplications
448 if ( !hasDuplicatedMeshNames )
449 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
450 if( aMeshName == (*aMeshIter).second ) {
451 hasDuplicatedMeshNames = true;
456 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
459 if( hasDuplicatedMeshNames && isMED ) {
460 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
461 QObject::tr("SMESH_WRN_WARNING"),
462 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
463 QObject::tr("SMESH_BUT_YES"),
464 QObject::tr("SMESH_BUT_NO"), 0, 1);
469 aMeshIter = aMeshList.begin();
470 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
471 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
472 QString aMeshName = (*aMeshIter).second;
474 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
476 // check for equal group names within each mesh
477 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
478 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
479 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
480 int aRet = SUIT_MessageBox::warning
481 (SMESHGUI::desktop(),
482 QObject::tr("SMESH_WRN_WARNING"),
483 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
484 QObject::tr("SMESH_BUT_YES"),
485 QObject::tr("SMESH_BUT_NO"), 0, 1);
492 // Warn the user about presence of not supported elements
494 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
498 notSupportedElemTypes.push_back( SMESH::Entity_0D );
499 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
504 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
505 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
506 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
507 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
508 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
509 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
510 notSupportedElemTypes.push_back( SMESH::Entity_0D );
511 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
516 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
517 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
518 notSupportedElemTypes.push_back( SMESH::Entity_0D );
519 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
524 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
525 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
530 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
532 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
533 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
534 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
535 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
536 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
541 notSupportedElemTypes.push_back( SMESH::Entity_0D );
542 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
543 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
544 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
545 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
546 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
547 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
548 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
549 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
551 if ( ! notSupportedElemTypes.empty() )
553 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
554 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
555 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
556 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
558 if ( !presentNotSupported.empty() )
561 const char* typeMsg[SMESH::Entity_Last] = {
562 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
563 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
564 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
565 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
566 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
567 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
568 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
569 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
571 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
572 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
573 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
574 if ( iType != presentNotSupported.size() - 1 )
575 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
577 int aRet = SUIT_MessageBox::warning
578 (SMESHGUI::desktop(),
579 QObject::tr("SMESH_WRN_WARNING"),
580 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
581 QObject::tr("SMESH_BUT_YES"),
582 QObject::tr("SMESH_BUT_NO"), 0, 1);
587 // Get parameters of export operation
590 SMESH::MED_VERSION aFormat;
591 // Init the parameters with the default values
592 bool aIsASCII_STL = true;
593 bool toCreateGroups = false;
594 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
596 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
597 bool toOverwrite = true;
598 bool toFindOutDim = true;
600 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
601 QString anInitialPath = "";
602 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
603 anInitialPath = QDir::currentPath();
605 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
607 // Get a file name to write in and additional otions
608 if ( isUNV || isDAT || isGMF ) // Export w/o options
611 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
613 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
615 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
616 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
617 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
618 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
619 anInitialPath + QString("/") + aMeshName,
620 aFilter, aTitle, false);
622 else if ( isCGNS )// Export to CGNS
624 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
625 fd->setWindowTitle( aTitle );
626 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
627 if ( !anInitialPath.isEmpty() )
628 fd->setDirectory( anInitialPath );
629 fd->selectFile(aMeshName);
630 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
631 fd->setValidator( fv );
634 aFilename = fd->selectedFile();
635 toOverwrite = fv->isOverwrite();
639 else if ( isSTL ) // Export to STL
641 QMap<QString, int> aFilterMap;
642 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
643 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
646 QMap<QString, int>::const_iterator it = aFilterMap.begin();
647 for ( ; it != aFilterMap.end(); ++it )
648 filters.push_back( it.key() );
650 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
651 fd->setWindowTitle( aTitle );
652 fd->setNameFilters( filters );
653 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
654 if ( !anInitialPath.isEmpty() )
655 fd->setDirectory( anInitialPath );
656 fd->selectFile(aMeshName);
660 aFilename = fd->selectedFile();
661 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
666 else if ( isMED || isSAUV ) // Export to MED or SAUV
668 QMap<QString, SMESH::MED_VERSION> aFilterMap;
669 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
671 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
672 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
673 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
676 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
677 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
678 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
682 QString aDefaultFilter;
683 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
684 for ( ; it != aFilterMap.end(); ++it ) {
685 filters.push_back( it.key() );
686 if (it.value() == SMESH::MED_V2_2)
687 aDefaultFilter = it.key();
689 QStringList checkBoxes;
690 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
692 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
693 QList< QWidget* > wdgList;
694 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
695 wdgList.append( fieldSelWdg );
697 SalomeApp_CheckFileDlg* fd =
698 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
699 fd->setWindowTitle( aTitle );
700 fd->setNameFilters( filters );
701 fd->selectNameFilter( aDefaultFilter );
702 fd->SetChecked( toCreateGroups, 0 );
703 fd->SetChecked( toFindOutDim, 1 );
704 if ( !anInitialPath.isEmpty() )
705 fd->setDirectory( anInitialPath );
706 fd->selectFile(aMeshName);
708 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
709 fd->setValidator( fv );
714 aFilename = fd->selectedFile();
716 aFilename = QString::null;
719 aFormat = aFilterMap[fd->selectedNameFilter()];
720 toOverwrite = fv->isOverwrite();
722 if ( !aFilename.isEmpty() ) {
723 // med-2.1 does not support poly elements
724 if ( aFormat==SMESH::MED_V2_1 )
725 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
726 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
727 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
728 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
729 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
731 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
732 QObject::tr("SMESH_WRN_WARNING"),
733 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
734 QObject::tr("SMESH_BUT_YES"),
735 QObject::tr("SMESH_BUT_NO"), 0, 1);
743 // can't append to an existing using other format
744 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
745 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
746 if( !isVersionOk || aVersion != aFormat ) {
747 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
748 QObject::tr("SMESH_WRN_WARNING"),
749 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
750 QObject::tr("SMESH_BUT_YES"),
751 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 QStringList aMeshNamesCollisionList;
759 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
760 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
761 QString anExistingMeshName( aMeshNames[ i ] );
762 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
763 QString anExportMeshName = (*aMeshIter).second;
764 if( anExportMeshName == anExistingMeshName ) {
765 aMeshNamesCollisionList.append( anExportMeshName );
770 if( !aMeshNamesCollisionList.isEmpty() ) {
771 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
772 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
773 QObject::tr("SMESH_WRN_WARNING"),
774 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
775 QObject::tr("SMESH_BUT_YES"),
776 QObject::tr("SMESH_BUT_NO"),
777 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
786 toCreateGroups = fd->IsChecked(0);
787 toFindOutDim = fd->IsChecked(1);
788 fieldSelWdg->GetSelectedFeilds();
789 if ( !fieldSelWdg->parent() )
800 if ( !aFilename.isEmpty() ) {
801 // Check whether the file already exists and delete it if yes
802 QFile aFile( aFilename );
803 if ( aFile.exists() && toOverwrite )
805 SUIT_OverrideCursor wc;
808 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
809 // bool Renumber = false;
810 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
812 // Renumber= resMgr->booleanValue("renumbering");
814 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
815 // aMeshEditor->RenumberNodes();
816 // aMeshEditor->RenumberElements();
817 // if ( SMESHGUI::automaticUpdate() )
818 // SMESH::UpdateView();
822 aMeshIter = aMeshList.begin();
823 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
825 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
826 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
827 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
828 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
829 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
830 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
831 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
832 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
834 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
835 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
836 fields, geoAssFields.toLatin1().data() );
841 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
843 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
844 if( !aMeshItem->_is_nil() )
845 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
850 if ( aMeshOrGroup->_is_equivalent( aMesh ))
851 aMesh->ExportDAT( aFilename.toUtf8().data() );
853 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
857 if ( aMeshOrGroup->_is_equivalent( aMesh ))
858 aMesh->ExportUNV( aFilename.toUtf8().data() );
860 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
864 if ( aMeshOrGroup->_is_equivalent( aMesh ))
865 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
867 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
871 aMeshIter = aMeshList.begin();
872 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
874 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
875 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
876 aMeshItem->ExportCGNS( aMeshOrGroup,
877 aFilename.toUtf8().data(),
878 toOverwrite && aMeshIndex == 0 );
883 toCreateGroups = true;
884 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
887 catch (const SALOME::SALOME_Exception& S_ex){
889 SUIT_MessageBox::warning(SMESHGUI::desktop(),
890 QObject::tr("SMESH_WRN_WARNING"),
891 QObject::tr("SMESH_EXPORT_FAILED"));
897 inline void InverseEntityMode(unsigned int& theOutputMode,
898 unsigned int theMode)
900 bool anIsNotPresent = ~theOutputMode & theMode;
902 theOutputMode |= theMode;
904 theOutputMode &= ~theMode;
907 void SetDisplayEntity(int theCommandID){
908 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
909 SALOME_ListIO selected;
911 aSel->selectedObjects( selected );
913 if(selected.Extent() >= 1){
914 SALOME_ListIteratorOfListIO It( selected );
915 for( ; It.More(); It.Next()){
916 Handle(SALOME_InteractiveObject) IObject = It.Value();
917 if(IObject->hasEntry()){
918 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
919 unsigned int aMode = anActor->GetEntityMode();
920 switch(theCommandID){
922 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
925 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
928 InverseEntityMode(aMode,SMESH_Actor::eEdges);
931 InverseEntityMode(aMode,SMESH_Actor::eFaces);
934 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
937 aMode = SMESH_Actor::eAllEntity;
941 anActor->SetEntityMode(aMode);
950 SALOME_ListIO selected;
951 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
955 LightApp_SelectionMgr* aSel = app->selectionMgr();
956 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
957 if( !aSel || !appStudy )
960 aSel->selectedObjects( selected );
961 if( selected.IsEmpty() )
964 Handle(SALOME_InteractiveObject) anIObject = selected.First();
966 _PTR(Study) aStudy = appStudy->studyDS();
967 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
968 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
969 if( aMainObject->_is_nil() )
972 SUIT_OverrideCursor wc;
974 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
976 QList<SALOMEDS::Color> aReservedColors;
978 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
979 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
981 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
982 //SALOMEDS::Color aColor = aGroupObject->GetColor();
984 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
985 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
986 #else // old algorithm for auto-colors
987 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
988 aReservedColors.append( aColor );
989 #endif // SIMPLE_AUTOCOLOR
990 aGroupObject->SetColor( aColor );
992 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
996 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
997 switch ( aGroupObject->GetType ()) {
999 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1001 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1003 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1005 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1007 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1008 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1011 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1012 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1018 SMESH::RepaintCurrentView();
1021 void OverallMeshQuality() {
1022 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1023 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1024 SALOME_ListIO selected;
1026 aSel->selectedObjects( selected );
1028 if ( selected.IsEmpty() ) return;
1029 SALOME_ListIteratorOfListIO It( selected );
1030 for ( ; It.More(); It.Next() ) {
1031 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1032 ctrlDlg->showInfo( It.Value() );
1037 QString functorToString( SMESH::Controls::FunctorPtr f )
1039 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1040 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1041 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1042 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1043 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1044 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1045 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1046 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1047 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1048 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1049 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1050 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1051 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1052 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1053 type = QObject::tr( "WARP_ELEMENTS" );
1054 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1055 type = QObject::tr( "TAPER_ELEMENTS" );
1056 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1057 type = QObject::tr( "SKEW_ELEMENTS" );
1058 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1059 type = QObject::tr( "AREA_ELEMENTS" );
1060 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1061 type = QObject::tr( "LENGTH_EDGES" );
1062 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1063 type = QObject::tr( "LENGTH2D_EDGES" );
1064 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1065 type = QObject::tr( "MULTI_BORDERS" );
1066 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1067 type = QObject::tr( "MULTI2D_BORDERS" );
1068 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1069 type = QObject::tr( "FREE_NODES" );
1070 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1071 type = QObject::tr( "FREE_EDGES" );
1072 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1073 type = QObject::tr( "FREE_BORDERS" );
1074 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1075 type = QObject::tr( "FREE_FACES" );
1076 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1077 type = QObject::tr( "BARE_BORDER_VOLUME" );
1078 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1079 type = QObject::tr( "BARE_BORDER_FACE" );
1080 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1081 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1082 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1083 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1084 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1085 type = QObject::tr( "EQUAL_NODE" );
1086 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1087 type = QObject::tr( "EQUAL_EDGE" );
1088 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1089 type = QObject::tr( "EQUAL_FACE" );
1090 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1091 type = QObject::tr( "EQUAL_VOLUME" );
1095 void SaveDistribution()
1097 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1098 SALOME_ListIO selected;
1100 aSel->selectedObjects( selected );
1102 if ( selected.Extent() == 1 ) {
1103 Handle(SALOME_InteractiveObject) anIO = selected.First();
1104 if ( anIO->hasEntry() ) {
1105 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1106 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1107 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1108 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1109 if ( aScalarBarActor && aFunctor ) {
1110 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1112 std::vector<int> elements;
1113 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1114 if ( mesh->_is_nil() ) {
1115 SMESH::SMESH_IDSource_var idSource =
1116 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1117 if ( !idSource->_is_nil() )
1119 SMESH::long_array_var ids = idSource->GetIDs();
1120 elements.resize( ids->length() );
1121 for ( unsigned i = 0; i < elements.size(); ++i )
1122 elements[i] = ids[i];
1125 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1126 vtkLookupTable* lookupTable =
1127 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1128 double * minmax = lookupTable->GetRange();
1129 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1130 std::vector<int> nbEvents;
1131 std::vector<double> funValues;
1132 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1133 QString anInitialPath = "";
1134 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1135 anInitialPath = QDir::currentPath();
1136 QString aMeshName = anIO->getName();
1138 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1139 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1140 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1141 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1142 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1145 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1147 if ( !aFilename.isEmpty() ) {
1148 QFile f( aFilename );
1149 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1150 QTextStream out( &f );
1151 out << "# Mesh: " << aMeshName << endl;
1152 out << "# Control: " << functorToString( aFunctor ) << endl;
1154 out.setFieldWidth( 10 );
1155 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1156 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1167 void ShowDistribution() {
1168 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1169 SALOME_ListIO selected;
1171 aSel->selectedObjects( selected );
1173 if ( selected.Extent() == 1 ) {
1174 Handle(SALOME_InteractiveObject) anIO = selected.First();
1175 if ( anIO->hasEntry() ) {
1176 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1177 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1178 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1179 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1185 #ifndef DISABLE_PLOT2DVIEWER
1186 void PlotDistribution() {
1187 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1191 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1192 SALOME_ListIO selected;
1194 aSel->selectedObjects( selected );
1196 if ( selected.Extent() == 1 ) {
1197 Handle(SALOME_InteractiveObject) anIO = selected.First();
1198 if ( anIO->hasEntry() ) {
1199 //Find Actor by entry before getting Plot2d viewer,
1200 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1201 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1203 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1208 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1212 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1216 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1217 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1218 QString functorName = functorToString( anActor->GetFunctor());
1219 QString aHistogramName("%1 : %2");
1220 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1221 aHistogram->setName(aHistogramName);
1222 aHistogram->setHorTitle(functorName);
1223 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1224 aPlot->displayObject(aHistogram, true);
1229 #endif //DISABLE_PLOT2DVIEWER
1231 void DisableAutoColor(){
1232 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1233 SALOME_ListIO selected;
1235 aSel->selectedObjects( selected );
1237 if(selected.Extent()){
1238 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1239 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1240 if ( !aMesh->_is_nil() ) {
1241 aMesh->SetAutoColor( false );
1246 void sortChildren(){
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 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1255 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1257 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1258 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1265 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1267 SALOME_ListIO selected;
1268 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1272 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1273 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1274 if( !aSel || !appStudy )
1277 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1278 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1279 aModule->EmitSignalDeactivateDialog();
1280 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1281 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1286 _PTR(Study) aStudy = appStudy->studyDS();
1288 aSel->selectedObjects( selected );
1290 if(selected.Extent() >= 1){
1291 switch(theCommandID){
1293 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1294 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1299 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1300 QColor orientationColor, outlineColor, volumeColor;
1301 int deltaF = 0, deltaV = 0;
1304 double ballScale = 1.0;
1306 int outlineWidth = 1;
1307 double shrinkCoef = 0.0;
1308 double orientationScale = 0.0;
1309 bool orientation3d = false;
1310 VTK::MarkerType markerType = VTK::MT_NONE;
1311 VTK::MarkerScale markerScale = VTK::MS_NONE;
1313 bool hasNodes = false;
1314 int presentEntities = 0;
1315 bool firstTime = true;
1317 SALOME_ListIteratorOfListIO It( selected );
1318 for ( ; It.More(); It.Next() ) {
1319 Handle(SALOME_InteractiveObject) IObject = It.Value();
1320 if ( !IObject->hasEntry() ) continue;
1321 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1322 if ( !anActor || !anActor->GetObject() ) continue;
1325 // nodes: color, marker
1326 anActor->GetNodeColor( color[0], color[1], color[2] );
1327 nodeColor.setRgbF( color[0], color[1], color[2] );
1328 markerType = anActor->GetMarkerType();
1329 markerScale = anActor->GetMarkerScale();
1330 markerId = anActor->GetMarkerTexture();
1331 // edges: color, width
1332 anActor->GetEdgeColor( color[0], color[1], color[2] );
1333 edgeColor.setRgbF( color[0], color[1], color[2] );
1334 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1335 // faces: front color, back color (delta)
1336 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1337 faceColor.setRgbF( color[0], color[1], color[2] );
1338 // faces: front color, back color (delta)
1339 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1340 volumeColor.setRgbF( color[0], color[1], color[2] );
1341 // 0d elements: color, size
1342 anActor->Get0DColor( color[0], color[1], color[2] );
1343 elem0dColor.setRgbF( color[0], color[1], color[2] );
1344 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1345 // balls: color, size
1346 anActor->GetBallColor( color[0], color[1], color[2] );
1347 ballColor.setRgbF( color[0], color[1], color[2] );
1348 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1349 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1351 anActor->GetOutlineColor( color[0], color[1], color[2] );
1352 outlineColor.setRgbF( color[0], color[1], color[2] );
1353 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1354 // orientation vectors: color, scale, 3d flag
1355 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1356 orientationColor.setRgbF( color[0], color[1], color[2] );
1357 orientationScale = anActor->GetFacesOrientationScale();
1358 orientation3d = anActor->GetFacesOrientation3DVectors();
1360 shrinkCoef = anActor->GetShrinkFactor();
1363 firstTime = false; // we only take properties from first object (for performance reasons)
1366 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1367 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1368 presentEntities = presentEntities | SMESH_Actor::eEdges;
1369 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1370 presentEntities = presentEntities | SMESH_Actor::eFaces;
1371 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1372 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1373 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1374 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1375 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1376 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1378 // as we know that all types of elements are present, we can exit the loop
1379 if ( presentEntities == SMESH_Actor::eAllEntity )
1383 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1384 // nodes: color, marker
1385 dlg.setNodeColor( nodeColor );
1386 if( markerType != VTK::MT_USER )
1387 dlg.setNodeMarker( markerType, markerScale );
1389 dlg.setNodeCustomMarker( markerId );
1390 // edges: color, line width
1391 dlg.setEdgeColor( edgeColor );
1392 dlg.setEdgeWidth( edgeWidth );
1393 // faces: front color, back color
1394 dlg.setFaceColor( faceColor, deltaF );
1395 // volumes: normal color, reversed color
1396 dlg.setVolumeColor( volumeColor, deltaV );
1397 // outlines: color, line width
1398 dlg.setOutlineColor( outlineColor );
1399 dlg.setOutlineWidth( outlineWidth );
1400 // 0d elements: color, size
1401 dlg.setElem0dColor( elem0dColor );
1402 dlg.setElem0dSize( elem0dSize );
1403 // balls: color, size
1404 dlg.setBallColor( ballColor );
1405 dlg.setBallSize( ballSize );
1406 dlg.setBallScale( ballScale );
1407 // orientation: color, scale, 3d flag
1408 dlg.setOrientationColor( orientationColor );
1409 dlg.setOrientationSize( int( orientationScale * 100. ) );
1410 dlg.setOrientation3d( orientation3d );
1411 // shrink: scale factor
1412 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1413 // hide unused controls
1414 dlg.showControls( presentEntities, hasNodes );
1417 nodeColor = dlg.nodeColor();
1418 markerType = dlg.nodeMarkerType();
1419 markerScale = dlg.nodeMarkerScale();
1420 markerId = dlg.nodeMarkerId();
1421 edgeColor = dlg.edgeColor();
1422 edgeWidth = dlg.edgeWidth();
1423 faceColor = dlg.faceColor();
1424 deltaF = dlg.faceColorDelta();
1425 volumeColor = dlg.volumeColor();
1426 deltaV = dlg.volumeColorDelta();
1427 outlineColor = dlg.outlineColor();
1428 outlineWidth = dlg.outlineWidth();
1429 elem0dColor = dlg.elem0dColor();
1430 elem0dSize = dlg.elem0dSize();
1431 ballColor = dlg.ballColor();
1432 ballSize = dlg.ballSize();
1433 ballScale = dlg.ballScale();
1434 orientationColor = dlg.orientationColor();
1435 orientationScale = dlg.orientationSize() / 100.;
1436 orientation3d = dlg.orientation3d();
1437 shrinkCoef = dlg.shrinkCoef() / 100.;
1439 // store point markers map that might be changed by the user
1440 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1442 // set properties from dialog box to the presentations
1443 SALOME_ListIteratorOfListIO It( selected );
1444 for ( ; It.More(); It.Next() ) {
1445 Handle(SALOME_InteractiveObject) IObject = It.Value();
1446 if ( !IObject->hasEntry() ) continue;
1447 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1448 if ( !anActor ) continue;
1450 // nodes: color, marker
1451 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1452 if ( markerType != VTK::MT_USER ) {
1453 anActor->SetMarkerStd( markerType, markerScale );
1456 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1457 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1458 if ( iter != markerMap.end() )
1459 anActor->SetMarkerTexture( markerId, iter->second.second );
1461 // volumes: normal color, reversed color (delta)
1462 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1463 // faces: front color, back color (delta)
1464 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1465 // edges: color, width
1466 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1467 anActor->SetLineWidth( edgeWidth );
1469 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1470 anActor->SetOutlineWidth( outlineWidth );
1471 // 0D elements: color, size
1472 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1473 anActor->Set0DSize( elem0dSize );
1474 // balls: color, size
1475 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1476 anActor->SetBallSize( ballSize );
1477 anActor->SetBallScale( ballScale );
1478 // orientation: color, scale, 3d flag
1479 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1480 anActor->SetFacesOrientationScale( orientationScale );
1481 anActor->SetFacesOrientation3DVectors( orientation3d );
1483 anActor->SetShrinkFactor( shrinkCoef );
1485 // for groups, set also proper color
1486 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1487 if ( !aGroupObject->_is_nil() ) {
1488 SMESH::ElementType anElementType = aGroupObject->GetType();
1490 switch( anElementType ) {
1492 aColor = nodeColor; break;
1494 aColor = edgeColor; break;
1496 aColor = faceColor; break;
1498 aColor = volumeColor; break;
1500 aColor = elem0dColor; break;
1502 aColor = ballColor; break;
1506 if ( aColor.isValid() ) {
1507 SALOMEDS::Color aGroupColor;
1508 aGroupColor.R = aColor.redF();
1509 aGroupColor.G = aColor.greenF();
1510 aGroupColor.B = aColor.blueF();
1511 aGroupObject->SetColor( aGroupColor );
1513 } // if ( !aGroupObject->_is_nil() )
1514 } // for ( ; It.More(); It.Next() )
1515 SMESH::RepaintCurrentView();
1516 } // if ( dlg.exec() )
1519 } // switch(theCommandID)
1520 SALOME_ListIteratorOfListIO It( selected );
1521 for( ; It.More(); It.Next()){
1522 Handle(SALOME_InteractiveObject) IObject = It.Value();
1523 if(IObject->hasEntry()){
1524 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1525 switch(theCommandID){
1527 anActor->SetRepresentation(SMESH_Actor::eEdge);
1530 anActor->SetRepresentation(SMESH_Actor::eSurface);
1533 if(anActor->IsShrunk())
1534 anActor->UnShrink();
1536 anActor->SetShrink();
1539 anActor->SetRepresentation(SMESH_Actor::ePoint);
1542 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1543 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1546 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1547 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1553 SMESH::RepaintCurrentView();
1557 void Control( int theCommandID )
1559 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1560 SALOME_ListIO selected;
1562 aSel->selectedObjects( selected );
1564 if( !selected.IsEmpty() ){
1565 Handle(SALOME_InteractiveObject) anIO = selected.First();
1567 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1569 switch ( theCommandID ){
1571 aControl = SMESH_Actor::eLength;
1574 aControl = SMESH_Actor::eLength2D;
1577 aControl = SMESH_Actor::eFreeEdges;
1580 aControl = SMESH_Actor::eFreeBorders;
1583 aControl = SMESH_Actor::eMultiConnection;
1586 aControl = SMESH_Actor::eFreeNodes;
1589 aControl = SMESH_Actor::eMultiConnection2D;
1592 aControl = SMESH_Actor::eArea;
1595 aControl = SMESH_Actor::eTaper;
1598 aControl = SMESH_Actor::eAspectRatio;
1601 aControl = SMESH_Actor::eAspectRatio3D;
1604 aControl = SMESH_Actor::eMinimumAngle;
1607 aControl = SMESH_Actor::eWarping;
1610 aControl = SMESH_Actor::eSkew;
1613 aControl = SMESH_Actor::eVolume3D;
1616 aControl = SMESH_Actor::eFreeFaces;
1619 aControl = SMESH_Actor::eMaxElementLength2D;
1622 aControl = SMESH_Actor::eMaxElementLength3D;
1625 aControl = SMESH_Actor::eBareBorderVolume;
1628 aControl = SMESH_Actor::eBareBorderFace;
1631 aControl = SMESH_Actor::eOverConstrainedVolume;
1634 aControl = SMESH_Actor::eOverConstrainedFace;
1637 aControl = SMESH_Actor::eCoincidentNodes;
1640 aControl = SMESH_Actor::eCoincidentElems1D;
1643 aControl = SMESH_Actor:: eCoincidentElems2D;
1646 aControl = SMESH_Actor::eCoincidentElems3D;
1650 anActor->SetControlMode(aControl);
1651 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1652 SMESH::RepaintCurrentView();
1653 #ifndef DISABLE_PLOT2DVIEWER
1654 if(anActor->GetPlot2Histogram()) {
1655 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1656 QString functorName = functorToString( anActor->GetFunctor());
1657 QString aHistogramName("%1 : %2");
1658 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1659 aHistogram->setName(aHistogramName);
1660 aHistogram->setHorTitle(functorName);
1661 SMESH::ProcessIn2DViewers(anActor);
1670 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1671 SMESH::MeshObjectType theType,
1672 const QString theInTypeName,
1673 QString & theOutTypeName)
1675 SMESH_TypeFilter aTypeFilter( theType );
1677 if( !theIO.IsNull() )
1679 entry = theIO->getEntry();
1680 LightApp_DataOwner owner( entry );
1681 if ( aTypeFilter.isOk( &owner )) {
1682 theOutTypeName = theInTypeName;
1690 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1692 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1693 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1695 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1696 CORBA::String_var anID = aSComp->GetID().c_str();
1697 if (!strcmp(anID.in(),theIO->getEntry()))
1703 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1704 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1705 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1706 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1707 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1715 QString CheckHomogeneousSelection()
1717 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1718 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1719 SALOME_ListIO selected;
1721 aSel->selectedObjects( selected );
1723 QString RefType = CheckTypeObject(selected.First());
1724 SALOME_ListIteratorOfListIO It(selected);
1725 for ( ; It.More(); It.Next())
1727 Handle(SALOME_InteractiveObject) IObject = It.Value();
1728 QString Type = CheckTypeObject(IObject);
1729 if (Type.compare(RefType) != 0)
1730 return "Heterogeneous Selection";
1738 void SMESHGUI::OnEditDelete()
1740 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1741 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1742 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1744 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1745 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1746 _PTR(GenericAttribute) anAttr;
1747 _PTR(AttributeIOR) anIOR;
1749 int objectCount = 0;
1751 QString aParentComponent = QString::null;
1752 Handle(SALOME_InteractiveObject) anIO;
1753 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1755 anIO = anIt.Value();
1756 QString cur = anIO->getComponentDataType();
1757 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1759 // check if object is reference
1760 _PTR(SObject) aRefSObj;
1761 aNameList.append("\n - ");
1762 if ( aSO->ReferencedObject( aRefSObj ) ) {
1763 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1764 aNameList.append( aRefName );
1765 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1768 aNameList.append(anIO->getName());
1772 if( aParentComponent.isNull() )
1773 aParentComponent = cur;
1774 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1775 aParentComponent = "";
1778 if ( objectCount == 0 )
1779 return; // No Valid Objects Selected
1781 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1782 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1783 QObject::tr("ERR_ERROR"),
1784 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1787 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1788 if (SUIT_MessageBox::warning
1789 (SMESHGUI::desktop(),
1790 QObject::tr("SMESH_WRN_WARNING"),
1791 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1792 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1793 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1796 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1798 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1799 // then treat them all starting from the deepest objects (at list back)
1800 std::list< _PTR(SObject) > listSO;
1801 SALOME_ListIteratorOfListIO It(selected);
1802 for( ; It.More(); It.Next()) // loop on selected IO's
1804 Handle(SALOME_InteractiveObject) IObject = It.Value();
1805 if(IObject->hasEntry()) {
1806 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1808 // disable removal of "SMESH" component object
1809 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1811 if ( engineIOR() == anIOR->Value().c_str() )
1814 //Check the referenced object
1815 _PTR(SObject) aRefSObject;
1816 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1817 aSO = aRefSObject; // Delete main Object instead of reference
1819 listSO.push_back( aSO );
1820 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1821 for ( ; itSO != listSO.end(); ++itSO ) {
1822 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1823 for (it->InitEx(false); it->More(); it->Next())
1824 listSO.push_back( it->Value() );
1828 // Check if none of objects to delete is referred from outside
1829 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1830 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1832 _PTR(SObject) SO = *ritSO;
1833 if ( !SO ) continue;
1834 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1835 for (size_t i = 0; i < aReferences.size(); i++) {
1836 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1837 std::string type = aComponent->ComponentDataType();
1838 if ( type != "SMESH" )
1840 SUIT_MessageBox::warning( anApp->desktop(),
1841 QObject::tr("WRN_WARNING"),
1842 QObject::tr("DEP_OBJECT") );
1843 return; // outside SMESH, there is an object depending on a SMESH object
1848 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1849 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1851 Handle(SALOME_InteractiveObject) IObject = It.Value();
1852 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1853 if ( !mesh->_is_nil() )
1857 // Treat SO's in the list starting from the back
1858 aStudyBuilder->NewCommand(); // There is a transaction
1859 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1861 _PTR(SObject) SO = *ritSO;
1862 if ( !SO ) continue;
1863 std::string anEntry = SO->GetID();
1865 /** Erase graphical object and remove all its data **/
1866 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1867 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1869 /** Remove an object from data structures **/
1870 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1871 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1872 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1873 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1874 aMesh->RemoveGroup( aGroup );
1876 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1877 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1878 aMesh->RemoveSubMesh( aSubMesh );
1880 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1882 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1885 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1886 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1887 QString objType = CheckTypeObject(IObject);
1888 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1889 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1890 aStudyBuilder->RemoveObjectWithChildren( SO );
1892 else {// default action: remove SObject from the study
1893 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1894 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1896 aStudyBuilder->RemoveObjectWithChildren( SO );
1900 } /* listSO back loop */
1902 aStudyBuilder->CommitCommand();
1904 /* Clear any previous selection */
1906 aSel->setSelectedObjects( l1 );
1908 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1912 SMESHGUI_EXPORT CAM_Module* createModule()
1914 return new SMESHGUI();
1917 SMESHGUI_EXPORT char* getModuleVersion() {
1918 return (char*)SMESH_VERSION_STR;
1922 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1924 //=============================================================================
1928 //=============================================================================
1929 SMESHGUI::SMESHGUI() :
1930 SalomeApp_Module( "SMESH" )
1932 if ( CORBA::is_nil( myComponentSMESH ) )
1934 CORBA::Boolean anIsEmbeddedMode;
1935 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1936 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1938 // 0019923: EDF 765 SMESH : default values of hypothesis
1939 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1940 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1941 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1942 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1943 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1945 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1946 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1947 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1949 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1950 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1954 myActiveDialogBox = 0;
1955 myFilterLibraryDlg = 0;
1959 myEventCallbackCommand = vtkCallbackCommand::New();
1960 myEventCallbackCommand->Delete();
1961 myEventCallbackCommand->SetClientData( this );
1962 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1965 /* load resources for all available meshers */
1966 SMESH::InitAvailableHypotheses();
1969 //=============================================================================
1973 //=============================================================================
1974 SMESHGUI::~SMESHGUI()
1978 //=============================================================================
1982 //=============================================================================
1983 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1985 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1987 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1992 //=============================================================================
1996 //=============================================================================
1997 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1999 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2003 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2004 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2005 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2006 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2007 return autoUpdate && !exceeded;
2010 //=============================================================================
2014 //=============================================================================
2015 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2016 int* entities, bool* limitExceeded, int* hidden )
2018 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2022 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2023 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2024 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2026 long requestedSize = theMesh->NbElements();
2028 *entities = SMESH_Actor::eAllEntity;
2031 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2033 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2035 if ( incrementalLimit ) {
2036 long nbOdElems = theMesh->Nb0DElements();
2037 long nbEdges = theMesh->NbEdges();
2038 long nbFaces = theMesh->NbFaces();
2039 long nbVolumes = theMesh->NbVolumes();
2040 long nbBalls = theMesh->NbBalls();
2043 if ( nbOdElems > 0 ) {
2044 if ( total + nbOdElems > updateLimit ) {
2045 *entities = *entities & ~SMESH_Actor::e0DElements;
2046 *hidden = *hidden | SMESH_Actor::e0DElements;
2053 if ( nbEdges > 0 ) {
2054 if ( total + nbEdges > updateLimit ) {
2055 *entities = *entities & ~SMESH_Actor::eEdges;
2056 *hidden = *hidden | SMESH_Actor::eEdges;
2063 if ( nbFaces > 0 ) {
2064 if ( total + nbFaces > updateLimit ) {
2065 *entities = *entities & ~SMESH_Actor::eFaces;
2066 *hidden = *hidden | SMESH_Actor::eFaces;
2073 if ( nbVolumes > 0 ) {
2074 if ( total + nbVolumes > updateLimit ) {
2075 *entities = *entities & ~SMESH_Actor::eVolumes;
2076 *hidden = *hidden | SMESH_Actor::eVolumes;
2083 if ( nbBalls > 0 ) {
2084 if ( total + nbBalls > updateLimit ) {
2085 *entities = *entities & ~SMESH_Actor::eBallElem;
2086 *hidden = *hidden | SMESH_Actor::eBallElem;
2094 return autoUpdate && !exceeded;
2097 //=============================================================================
2101 //=============================================================================
2102 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2104 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2107 //=============================================================================
2111 //=============================================================================
2112 SMESHGUI* SMESHGUI::GetSMESHGUI()
2114 SMESHGUI* smeshMod = 0;
2115 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2118 CAM_Module* module = app->module( "Mesh" );
2119 smeshMod = dynamic_cast<SMESHGUI*>( module );
2122 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2124 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2127 _PTR(Study) aStudy = study->studyDS();
2129 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2138 Standard_EXPORT SMESHGUI* GetComponentGUI()
2140 return SMESHGUI::GetSMESHGUI();
2144 //=============================================================================
2148 //=============================================================================
2149 void SMESHGUI::SetState(int aState)
2154 //=============================================================================
2158 //=============================================================================
2159 void SMESHGUI::ResetState()
2164 //=============================================================================
2168 //=============================================================================
2169 void SMESHGUI::EmitSignalDeactivateDialog()
2171 emit SignalDeactivateActiveDialog();
2174 //=============================================================================
2178 //=============================================================================
2179 void SMESHGUI::EmitSignalStudyFrameChanged()
2181 emit SignalStudyFrameChanged();
2184 //=============================================================================
2188 //=============================================================================
2189 void SMESHGUI::EmitSignalCloseAllDialogs()
2191 emit SignalCloseAllDialogs();
2194 //=============================================================================
2198 //=============================================================================
2199 void SMESHGUI::EmitSignalVisibilityChanged()
2201 emit SignalVisibilityChanged();
2204 //=============================================================================
2208 //=============================================================================
2209 QDialog *SMESHGUI::GetActiveDialogBox()
2211 return myActiveDialogBox;
2214 //=============================================================================
2218 //=============================================================================
2219 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2221 myActiveDialogBox = (QDialog *) aDlg;
2225 //=============================================================================
2229 //=============================================================================
2230 SUIT_Desktop* SMESHGUI::desktop()
2232 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2234 return app->desktop();
2239 //=============================================================================
2243 //=============================================================================
2244 SalomeApp_Study* SMESHGUI::activeStudy()
2246 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2248 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2253 //=============================================================================
2257 //=============================================================================
2258 void SMESHGUI::Modified( bool theIsUpdateActions )
2260 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2261 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2262 appStudy->Modified();
2263 if( theIsUpdateActions )
2264 app->updateActions();
2269 //=============================================================================
2273 //=============================================================================
2274 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2276 /* Here the position is on the bottom right corner - 10 */
2277 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2279 SUIT_Desktop *PP = desktop();
2280 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2281 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2285 //=============================================================================
2289 //=============================================================================
2290 static int isStudyLocked(_PTR(Study) theStudy){
2291 return theStudy->GetProperties()->IsLocked();
2294 static bool checkLock(_PTR(Study) theStudy) {
2295 if (isStudyLocked(theStudy)) {
2296 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2297 QObject::tr("WRN_WARNING"),
2298 QObject::tr("WRN_STUDY_LOCKED") );
2304 //=======================================================================
2305 //function : CheckActiveStudyLocked
2307 //=======================================================================
2309 bool SMESHGUI::isActiveStudyLocked()
2311 _PTR(Study) aStudy = activeStudy()->studyDS();
2312 return checkLock( aStudy );
2315 //=============================================================================
2319 //=============================================================================
2320 bool SMESHGUI::OnGUIEvent( int theCommandID )
2322 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2326 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2327 SUIT_ResourceMgr* mgr = resourceMgr();
2331 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2332 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2335 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2336 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2338 //QAction* act = action( theCommandID );
2340 switch (theCommandID) {
2342 if(checkLock(aStudy)) break;
2354 if(checkLock(aStudy)) break;
2355 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2359 case 150: //MED FILE INFORMATION
2361 SALOME_ListIO selected;
2362 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2364 aSel->selectedObjects( selected );
2365 if( selected.Extent() )
2367 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2368 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2369 if ( !aMesh->_is_nil() )
2371 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2378 case 122: // EXPORT MED
2393 ::ExportMeshToFile(theCommandID);
2397 case 200: // SCALAR BAR
2399 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2400 SALOME_ListIO selected;
2402 aSel->selectedObjects( selected );
2404 if( selected.Extent() ) {
2405 Handle(SALOME_InteractiveObject) anIO = selected.First();
2406 if( anIO->hasEntry() ) {
2407 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2408 anActor->SetControlMode( SMESH_Actor::eNone );
2409 #ifndef DISABLE_PLOT2DVIEWER
2410 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2419 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2424 // dump control distribution data to the text file
2425 ::SaveDistribution();
2431 // show/ distribution
2432 ::ShowDistribution();
2436 #ifndef DISABLE_PLOT2DVIEWER
2439 // plot distribution
2440 ::PlotDistribution();
2451 ::DisableAutoColor();
2454 case 1134: // Clipping
2455 case 1133: // Tranparency
2456 case 1132: // Display preferences (colors, shrink size, line width, ...)
2463 ::SetDisplayMode(theCommandID, myMarkerMap);
2466 //2D quadratic representation
2469 ::SetDisplayMode(theCommandID, myMarkerMap);
2473 case 216: // 0D elements
2476 case 219: // Volumes
2477 case 220: // All Entity
2479 ::SetDisplayEntity(theCommandID);
2482 case 221: // Orientation of faces
2484 LightApp_SelectionMgr* mgr = selectionMgr();
2485 SALOME_ListIO selected; mgr->selectedObjects( selected );
2487 SALOME_ListIteratorOfListIO it(selected);
2488 for( ; it.More(); it.Next()) {
2489 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2490 if(anIObject->hasEntry()) {
2491 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2492 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2501 if(checkLock(aStudy)) break;
2502 SUIT_OverrideCursor wc;
2504 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2507 SMESH::UpdateView();
2509 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2510 SMESH::OnVisuException();
2512 catch (...) { // PAL16774 (Crash after display of many groups)
2513 SMESH::OnVisuException();
2517 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2518 aSel->selectedObjects( l );
2519 aSel->setSelectedObjects( l );
2524 case 301: // DISPLAY
2525 case 302: // DISPLAY ONLY
2527 SMESH::EDisplaing anAction;
2528 switch (theCommandID) {
2529 case 300: anAction = SMESH::eErase; break;
2530 case 301: anAction = SMESH::eDisplay; break;
2531 case 302: anAction = SMESH::eDisplayOnly; break;
2534 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2535 SALOME_ListIO sel_objects, to_process;
2537 aSel->selectedObjects( sel_objects );
2539 if( theCommandID==302 )
2541 MESSAGE("anAction = SMESH::eDisplayOnly");
2542 startOperation( myEraseAll );
2545 extractContainers( sel_objects, to_process );
2548 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2552 SALOME_ListIteratorOfListIO It( to_process );
2553 for ( ; It.More(); It.Next()) {
2555 Handle(SALOME_InteractiveObject) IOS = It.Value();
2556 if (IOS->hasEntry()) {
2558 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2559 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2560 break; // PAL16774 (Crash after display of many groups)
2562 if (anAction == SMESH::eDisplayOnly)
2564 MESSAGE("anAction = SMESH::eDisplayOnly");
2565 anAction = SMESH::eDisplay;
2571 // PAL13338 + PAL15161 -->
2572 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2573 MESSAGE("anAction = SMESH::eDisplayOnly");
2574 SMESH::UpdateView();
2575 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2577 // PAL13338 + PAL15161 <--
2579 catch (...) { // PAL16774 (Crash after display of many groups)
2580 SMESH::OnVisuException();
2583 if (anAction == SMESH::eErase) {
2584 MESSAGE("anAction == SMESH::eErase");
2586 aSel->setSelectedObjects( l1 );
2589 aSel->setSelectedObjects( to_process );
2596 if(checkLock(aStudy)) break;
2599 EmitSignalDeactivateDialog();
2601 ( new SMESHGUI_NodesDlg( this ) )->show();
2604 SUIT_MessageBox::warning(desktop(),
2605 tr("SMESH_WRN_WARNING"),
2606 tr("SMESH_WRN_VIEWER_VTK"));
2611 case 2151: // FILTER
2615 EmitSignalDeactivateDialog();
2616 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2621 case 701: // COMPUTE MESH
2622 case 711: // PRECOMPUTE MESH
2623 case 712: // EVALUATE MESH
2624 case 713: // MESH ORDER
2625 case 702: // Create mesh
2626 case 703: // Create sub-mesh
2627 case 704: // Edit mesh/sub-mesh
2628 startOperation( theCommandID );
2630 case 705: // copy mesh
2632 if (checkLock(aStudy)) break;
2633 EmitSignalDeactivateDialog();
2634 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2637 case 710: // Build compound mesh
2639 if (checkLock(aStudy)) break;
2640 EmitSignalDeactivateDialog();
2641 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2645 case 407: // DIAGONAL INVERSION
2646 case 408: // Delete diagonal
2650 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2651 tr( "NOT_A_VTK_VIEWER" ) );
2655 if ( checkLock( aStudy ) )
2658 /*Standard_Boolean aRes;
2659 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2660 if ( aMesh->_is_nil() )
2662 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2663 tr( "SMESH_BAD_SELECTION" ) );
2667 EmitSignalDeactivateDialog();
2668 if ( theCommandID == 407 )
2669 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2671 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2674 case 409: // Change orientation
2675 case 410: // Union of triangles
2676 case 411: // Cutting of quadrangles
2677 case 419: // Splitting volumes into tetrahedra
2681 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2682 tr( "NOT_A_VTK_VIEWER" ) );
2686 if ( checkLock( aStudy ) )
2689 EmitSignalDeactivateDialog();
2690 SMESHGUI_MultiEditDlg* aDlg = NULL;
2691 if ( theCommandID == 409 )
2692 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2693 else if ( theCommandID == 410 )
2694 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2695 else if ( theCommandID == 419 )
2696 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2698 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2703 case 412: // Smoothing
2705 if(checkLock(aStudy)) break;
2707 EmitSignalDeactivateDialog();
2708 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2711 SUIT_MessageBox::warning(desktop(),
2712 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2716 case 413: // Extrusion
2718 if (checkLock(aStudy)) break;
2720 EmitSignalDeactivateDialog();
2721 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2723 SUIT_MessageBox::warning(desktop(),
2724 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2728 case 414: // Revolution
2730 if(checkLock(aStudy)) break;
2732 EmitSignalDeactivateDialog();
2733 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2736 SUIT_MessageBox::warning(desktop(),
2737 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2741 case 415: // Pattern mapping
2743 if ( checkLock( aStudy ) )
2747 EmitSignalDeactivateDialog();
2748 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2751 SUIT_MessageBox::warning(desktop(),
2752 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2756 case 416: // Extrusion along a path
2758 if (checkLock(aStudy)) break;
2760 EmitSignalDeactivateDialog();
2761 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2763 SUIT_MessageBox::warning(desktop(),
2764 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2768 case 417: // Convert mesh to quadratic
2769 case 418: // create 2D mesh from 3D
2770 case 420: // Reorient faces
2771 case 806: // CREATE GEO GROUP
2773 startOperation( theCommandID );
2776 case 801: // CREATE GROUP
2780 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2781 tr( "NOT_A_VTK_VIEWER" ) );
2785 if(checkLock(aStudy)) break;
2786 EmitSignalDeactivateDialog();
2787 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2789 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2790 SALOME_ListIO selected;
2792 aSel->selectedObjects( selected );
2794 int nbSel = selected.Extent();
2796 // check if mesh is selected
2797 aMesh = SMESH::GetMeshByIO( selected.First() );
2799 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2804 case 802: // CONSTRUCT GROUP
2808 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2809 tr( "NOT_A_VTK_VIEWER" ) );
2813 if(checkLock(aStudy)) break;
2814 EmitSignalDeactivateDialog();
2816 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2817 SALOME_ListIO selected;
2819 aSel->selectedObjects( selected );
2821 int nbSel = selected.Extent();
2823 // check if submesh is selected
2824 Handle(SALOME_InteractiveObject) IObject = selected.First();
2825 if (IObject->hasEntry()) {
2826 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2828 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2829 if (!aSubMesh->_is_nil()) {
2831 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2832 // get submesh elements list by types
2833 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2834 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2835 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2836 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2837 // create group for each type o elements
2838 QString aName = IObject->getName();
2839 QStringList anEntryList;
2840 if (aNodes->length() > 0) {
2841 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2842 aGroup->Add(aNodes.inout());
2843 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2844 anEntryList.append( aSObject->GetID().c_str() );
2846 if (aEdges->length() > 0) {
2847 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2848 aGroup->Add(aEdges.inout());
2849 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2850 anEntryList.append( aSObject->GetID().c_str() );
2852 if (aFaces->length() > 0) {
2853 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2854 aGroup->Add(aFaces.inout());
2855 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2856 anEntryList.append( aSObject->GetID().c_str() );
2858 if (aVolumes->length() > 0) {
2859 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2860 aGroup->Add(aVolumes.inout());
2861 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2862 anEntryList.append( aSObject->GetID().c_str() );
2865 anApp->browseObjects( anEntryList );
2867 catch(const SALOME::SALOME_Exception & S_ex){
2868 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2875 SUIT_MessageBox::warning(desktop(),
2876 tr("SMESH_WRN_WARNING"),
2877 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2882 case 803: // EDIT GROUP
2886 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2887 tr( "NOT_A_VTK_VIEWER" ) );
2891 if(checkLock(aStudy)) break;
2892 EmitSignalDeactivateDialog();
2894 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2895 SALOME_ListIO selected;
2897 aSel->selectedObjects( selected );
2899 SALOME_ListIteratorOfListIO It (selected);
2900 int nbSelectedGroups = 0;
2901 for ( ; It.More(); It.Next() )
2903 SMESH::SMESH_GroupBase_var aGroup =
2904 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2905 if (!aGroup->_is_nil()) {
2907 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2911 if (nbSelectedGroups == 0)
2913 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2919 case 804: // Add elements to group
2921 if(checkLock(aStudy)) break;
2922 if (myState == 800) {
2923 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2924 if (aDlg) aDlg->onAdd();
2929 case 805: // Remove elements from group
2931 if(checkLock(aStudy)) break;
2932 if (myState == 800) {
2933 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2934 if (aDlg) aDlg->onRemove();
2939 case 815: // Edit GEOM GROUP as standalone
2943 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2944 tr( "NOT_A_VTK_VIEWER" ) );
2948 if(checkLock(aStudy)) break;
2949 EmitSignalDeactivateDialog();
2951 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2952 SALOME_ListIO selected;
2954 aSel->selectedObjects( selected );
2956 SALOME_ListIteratorOfListIO It (selected);
2957 for ( ; It.More(); It.Next() )
2959 SMESH::SMESH_GroupOnGeom_var aGroup =
2960 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2961 if (!aGroup->_is_nil()) {
2962 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2967 SMESH::SMESH_GroupOnFilter_var aGroup =
2968 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2969 if (!aGroup->_is_nil()) {
2970 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2978 case 810: // Union Groups
2979 case 811: // Intersect groups
2980 case 812: // Cut groups
2984 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2985 tr( "NOT_A_VTK_VIEWER" ) );
2989 if ( checkLock( aStudy ) )
2992 EmitSignalDeactivateDialog();
2994 SMESHGUI_GroupOpDlg* aDlg = 0;
2995 if ( theCommandID == 810 )
2996 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2997 else if ( theCommandID == 811 )
2998 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3000 aDlg = new SMESHGUI_CutGroupsDlg( this );
3007 case 814: // Create groups of entities from existing groups of superior dimensions
3009 if ( checkLock( aStudy ) )
3012 EmitSignalDeactivateDialog();
3013 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3019 case 813: // Delete groups with their contents
3023 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3024 tr( "NOT_A_VTK_VIEWER" ) );
3028 if ( checkLock( aStudy ) )
3031 EmitSignalDeactivateDialog();
3033 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3037 case 900: // MESH INFOS
3038 case 903: // WHAT IS
3040 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3041 EmitSignalDeactivateDialog();
3042 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3043 SALOME_ListIO selected;
3045 aSel->selectedObjects( selected );
3047 if ( selected.Extent() > 1 ) { // a dlg for each IO
3048 SALOME_ListIteratorOfListIO It( selected );
3049 for ( ; It.More(); It.Next() ) {
3050 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3051 dlg->showInfo( It.Value() );
3056 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3062 case 904: // FIND ELEM
3064 startOperation( theCommandID );
3068 case 1100: // EDIT HYPOTHESIS
3070 if(checkLock(aStudy)) break;
3072 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3073 SALOME_ListIO selected;
3075 aSel->selectedObjects( selected );
3077 int nbSel = selected.Extent();
3080 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3081 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3083 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3084 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3085 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3086 if ( !aHypothesis->_is_nil() )
3089 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3090 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3092 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3102 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3104 if(checkLock(aStudy)) break;
3105 SUIT_OverrideCursor wc;
3107 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3108 SALOME_ListIO selected;
3110 aSel->selectedObjects( selected, QString::null, false );
3112 SALOME_ListIteratorOfListIO It(selected);
3113 for (int i = 0; It.More(); It.Next(), i++) {
3114 Handle(SALOME_InteractiveObject) IObject = It.Value();
3115 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3118 aSel->setSelectedObjects( l1 );
3124 case 4009: // ELEM0D
3126 case 4021: // TRIANGLE
3128 case 4023: // POLYGON
3132 case 4134: // PYRAMID
3133 case 4135: // OCTA12
3135 if(checkLock(aStudy)) break;
3137 EmitSignalDeactivateDialog();
3138 SMDSAbs_EntityType type = SMDSEntity_Edge;
3139 switch (theCommandID) {
3140 case 4008: type = SMDSEntity_Ball; break;
3141 case 4009: type = SMDSEntity_0D; break;
3142 case 4021: type = SMDSEntity_Triangle; break;
3143 case 4022: type = SMDSEntity_Quadrangle; break;
3144 case 4031: type = SMDSEntity_Tetra; break;
3145 case 4023: type = SMDSEntity_Polygon; break;
3146 case 4032: type = SMDSEntity_Hexa; break;
3147 case 4133: type = SMDSEntity_Penta; break;
3148 case 4134: type = SMDSEntity_Pyramid; break;
3149 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3152 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3155 SUIT_MessageBox::warning(desktop(),
3156 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3160 case 4033: // POLYHEDRON
3162 if(checkLock(aStudy)) break;
3164 EmitSignalDeactivateDialog();
3165 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3168 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3169 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3173 case 4034: // QUADRATIC EDGE
3174 case 4035: // QUADRATIC TRIANGLE
3175 case 4036: // QUADRATIC QUADRANGLE
3176 case 4136: // BIQUADRATIC QUADRANGLE
3177 case 4137: // BIQUADRATIC TRIANGLE
3178 case 4037: // QUADRATIC TETRAHEDRON
3179 case 4038: // QUADRATIC PYRAMID
3180 case 4039: // QUADRATIC PENTAHEDRON
3181 case 4040: // QUADRATIC HEXAHEDRON
3182 case 4140: // TRIQUADRATIC HEXAHEDRON
3184 if(checkLock(aStudy)) break;
3186 EmitSignalDeactivateDialog();
3187 SMDSAbs_EntityType type = SMDSEntity_Last;
3189 switch (theCommandID) {
3190 case 4034: type = SMDSEntity_Quad_Edge; break;
3191 case 4035: type = SMDSEntity_Quad_Triangle; break;
3192 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3193 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3194 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3195 case 4037: type = SMDSEntity_Quad_Tetra; break;
3196 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3197 case 4039: type = SMDSEntity_Quad_Penta; break;
3198 case 4040: type = SMDSEntity_Quad_Hexa; break;
3199 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3202 if ( type != SMDSEntity_Last )
3203 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3206 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3207 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3211 case 4041: // REMOVES NODES
3213 if(checkLock(aStudy)) break;
3215 EmitSignalDeactivateDialog();
3216 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3219 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3220 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3224 case 4042: // REMOVES ELEMENTS
3226 if(checkLock(aStudy)) break;
3228 EmitSignalDeactivateDialog();
3229 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3233 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3234 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3238 case 4043: { // CLEAR_MESH
3240 if(checkLock(aStudy)) break;
3242 SALOME_ListIO selected;
3243 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3244 aSel->selectedObjects( selected );
3246 SUIT_OverrideCursor wc;
3247 SALOME_ListIteratorOfListIO It (selected);
3248 for ( ; It.More(); It.Next() )
3250 Handle(SALOME_InteractiveObject) IOS = It.Value();
3251 SMESH::SMESH_Mesh_var aMesh =
3252 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3253 if ( aMesh->_is_nil()) continue;
3255 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3257 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3258 SMESH::ModifiedMesh( aMeshSObj, false, true);
3259 // hide groups and submeshes
3260 _PTR(ChildIterator) anIter =
3261 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3262 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3264 _PTR(SObject) so = anIter->Value();
3265 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3268 catch (const SALOME::SALOME_Exception& S_ex){
3270 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3274 SMESH::UpdateView();
3278 case 4044: // REMOVE ORPHAN NODES
3280 if(checkLock(aStudy)) break;
3281 SALOME_ListIO selected;
3282 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3283 aSel->selectedObjects( selected );
3284 if ( selected.Extent() == 1 ) {
3285 Handle(SALOME_InteractiveObject) anIO = selected.First();
3286 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3287 if ( !aMesh->_is_nil() ) {
3288 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3289 tr( "SMESH_WARNING" ),
3290 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3291 SUIT_MessageBox::Yes |
3292 SUIT_MessageBox::No,
3293 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3296 SUIT_OverrideCursor wc;
3297 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3298 int removed = aMeshEditor->RemoveOrphanNodes();
3299 SUIT_MessageBox::information(SMESHGUI::desktop(),
3300 tr("SMESH_INFORMATION"),
3301 tr("NB_NODES_REMOVED").arg(removed));
3302 if ( removed > 0 ) {
3303 SMESH::UpdateView();
3304 SMESHGUI::Modified();
3307 catch (const SALOME::SALOME_Exception& S_ex) {
3308 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3317 case 4051: // RENUMBERING NODES
3319 if(checkLock(aStudy)) break;
3321 EmitSignalDeactivateDialog();
3322 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3326 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3327 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3331 case 4052: // RENUMBERING ELEMENTS
3333 if(checkLock(aStudy)) break;
3335 EmitSignalDeactivateDialog();
3336 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3340 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3341 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3345 case 4061: // TRANSLATION
3347 if(checkLock(aStudy)) break;
3349 EmitSignalDeactivateDialog();
3350 ( new SMESHGUI_TranslationDlg( this ) )->show();
3353 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3354 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3358 case 4062: // ROTATION
3360 if(checkLock(aStudy)) break;
3362 EmitSignalDeactivateDialog();
3363 ( new SMESHGUI_RotationDlg( this ) )->show();
3366 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3367 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3371 case 4063: // SYMMETRY
3373 if(checkLock(aStudy)) break;
3375 EmitSignalDeactivateDialog();
3376 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3379 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3380 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3384 case 4064: // SEWING
3386 if(checkLock(aStudy)) break;
3388 EmitSignalDeactivateDialog();
3389 ( new SMESHGUI_SewingDlg( this ) )->show();
3392 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3393 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3397 case 4065: // MERGE NODES
3399 if(checkLock(aStudy)) break;
3401 EmitSignalDeactivateDialog();
3402 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3405 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3406 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3410 case 4066: // MERGE EQUAL ELEMENTS
3412 if (checkLock(aStudy)) break;
3414 EmitSignalDeactivateDialog();
3415 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3417 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3418 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3423 case 4067: // MAKE MESH PASS THROUGH POINT
3424 startOperation( 4067 );
3429 if(checkLock(aStudy)) break;
3431 EmitSignalDeactivateDialog();
3432 ( new SMESHGUI_ScaleDlg( this ) )->show();
3435 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3436 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3441 case 4069: // DUPLICATE NODES
3443 if(checkLock(aStudy)) break;
3445 EmitSignalDeactivateDialog();
3446 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3449 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3450 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3455 case 4070: // 0D_ON_ALL_NODES
3456 startOperation( 4070 );
3459 case 5105: // Library of selection filters
3461 static QList<int> aTypes;
3462 if ( aTypes.isEmpty() )
3464 aTypes.append( SMESH::NODE );
3465 aTypes.append( SMESH::EDGE );
3466 aTypes.append( SMESH::FACE );
3467 aTypes.append( SMESH::VOLUME );
3469 if (!myFilterLibraryDlg)
3470 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3471 else if (myFilterLibraryDlg->isHidden())
3472 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3473 myFilterLibraryDlg->raise();
3477 case 6017: // CONTROLS
3505 LightApp_SelectionMgr* mgr = selectionMgr();
3506 SALOME_ListIO selected; mgr->selectedObjects( selected );
3508 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3509 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3511 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3512 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3513 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3514 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3515 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3516 SUIT_OverrideCursor wc;
3517 ::Control( theCommandID );
3522 SUIT_MessageBox::warning(desktop(),
3523 tr( "SMESH_WRN_WARNING" ),
3524 tr( "SMESH_BAD_SELECTION" ) );
3528 SUIT_MessageBox::warning(desktop(),
3529 tr( "SMESH_WRN_WARNING" ),
3530 tr( "NOT_A_VTK_VIEWER" ) );
3534 OverallMeshQuality();
3538 SUIT_OverrideCursor wc;
3539 LightApp_SelectionMgr* mgr = selectionMgr();
3540 SALOME_ListIO selected; mgr->selectedObjects( selected );
3542 SALOME_ListIteratorOfListIO it(selected);
3543 for( ; it.More(); it.Next()) {
3544 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3545 if(anIObject->hasEntry()) {
3546 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3547 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3555 SUIT_OverrideCursor wc;
3556 LightApp_SelectionMgr* mgr = selectionMgr();
3557 SALOME_ListIO selected; mgr->selectedObjects( selected );
3559 SALOME_ListIteratorOfListIO it(selected);
3560 for( ; it.More(); it.Next()) {
3561 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3562 if(anIObject->hasEntry())
3563 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3564 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3575 int page = SMESHGUI_MeasureDlg::MinDistance;
3576 if ( theCommandID == 502 )
3577 page = SMESHGUI_MeasureDlg::BoundingBox;
3578 else if ( theCommandID == 503 )
3579 page = SMESHGUI_MeasureDlg::Length;
3580 else if ( theCommandID == 504 )
3581 page = SMESHGUI_MeasureDlg::Area;
3582 else if ( theCommandID == 505 )
3583 page = SMESHGUI_MeasureDlg::Volume;
3585 EmitSignalDeactivateDialog();
3586 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3596 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3597 //updateObjBrowser();
3601 //=============================================================================
3605 //=============================================================================
3606 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3611 //=============================================================================
3615 //=============================================================================
3616 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3621 //=============================================================================
3625 //=============================================================================
3626 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3631 //=============================================================================
3632 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3633 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3635 //=============================================================================
3636 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3637 SUIT_ViewWindow* wnd )
3639 if(theIO->hasEntry()){
3640 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3641 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3645 //=======================================================================
3646 // function : createSMESHAction
3648 //=======================================================================
3649 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3650 const int key, const bool toggle, const QString& shortcutAction )
3653 QWidget* parent = application()->desktop();
3654 SUIT_ResourceMgr* resMgr = resourceMgr();
3656 if ( !icon_id.isEmpty() )
3657 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3659 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3660 if ( !pix.isNull() )
3661 icon = QIcon( pix );
3663 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3664 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3665 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3667 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3668 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3671 //=======================================================================
3672 // function : createPopupItem
3674 //=======================================================================
3675 void SMESHGUI::createPopupItem( const int id,
3676 const QString& clients,
3677 const QString& types,
3678 const QString& theRule,
3681 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3682 popupMgr()->insert( action( id ), pId, 0 );
3684 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3685 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3686 QString rule = "(%1) and (%2) and (%3)";
3687 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3688 if( clients.isEmpty() )
3689 rule = rule.arg( QString( "true" ) );
3691 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3692 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3695 bool cont = myRules.contains( id );
3697 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3699 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3700 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3703 //=======================================================================
3704 // function : initialize
3706 //=======================================================================
3707 void SMESHGUI::initialize( CAM_Application* app )
3709 SalomeApp_Module::initialize( app );
3711 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3713 /* Automatic Update flag */
3714 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3716 // ----- create actions --------------
3718 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3719 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3720 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3721 createSMESHAction( 114, "NUM" );
3722 createSMESHAction( 115, "IMPORT_STL" );
3723 createSMESHAction( 116, "IMPORT_CGNS" );
3724 createSMESHAction( 117, "IMPORT_SAUV" );
3725 createSMESHAction( 118, "IMPORT_GMF" );
3726 createSMESHAction( 121, "DAT" );
3727 createSMESHAction( 122, "MED" );
3728 createSMESHAction( 123, "UNV" );
3729 createSMESHAction( 140, "STL" );
3730 createSMESHAction( 142, "CGNS");
3731 createSMESHAction( 144, "SAUV");
3732 createSMESHAction( 146, "GMF" );
3733 createSMESHAction( 124, "DAT" );
3734 createSMESHAction( 125, "MED" );
3735 createSMESHAction( 126, "UNV" );
3736 createSMESHAction( 141, "STL" );
3737 createSMESHAction( 143, "CGNS");
3738 createSMESHAction( 145, "SAUV");
3739 createSMESHAction( 147, "GMF" );
3740 createSMESHAction( 150, "FILE_INFO" );
3741 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3742 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3743 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3744 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3745 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3746 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3747 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3748 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3749 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3750 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3751 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3752 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3753 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3754 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3755 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3756 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3757 createSMESHAction( 804, "ADD" );
3758 createSMESHAction( 805, "REMOVE" );
3759 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3760 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3761 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3762 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3763 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3764 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3765 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3766 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3767 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3768 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3769 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3770 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3771 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3772 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3773 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3774 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3775 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3776 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3777 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3778 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3779 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3780 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3781 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3782 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3783 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3784 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3785 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3786 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3787 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3788 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3789 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3790 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3791 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3792 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3793 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3794 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3795 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3796 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3797 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3798 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3799 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3800 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3801 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3802 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3803 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3804 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3805 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3806 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3807 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3808 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3809 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3810 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3811 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3812 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3813 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3814 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3815 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3816 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3817 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3818 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3819 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3820 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3821 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3822 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3823 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3824 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3825 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3826 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3827 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3828 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3829 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3830 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3831 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3832 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3833 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3834 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3835 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3836 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3837 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3838 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3839 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3840 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3841 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3842 createSMESHAction( 415, "MAP", "ICON_MAP" );
3843 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3844 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3845 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3846 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3847 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3848 createSMESHAction( 200, "RESET" );
3849 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3850 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3851 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3852 #ifndef DISABLE_PLOT2DVIEWER
3853 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3855 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3856 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3857 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3858 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3859 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3860 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3861 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3862 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3863 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3864 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3865 createSMESHAction( 220, "ALL" );
3866 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3868 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3869 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3871 createSMESHAction( 1100, "EDIT_HYPO" );
3872 createSMESHAction( 1102, "UNASSIGN" );
3873 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3874 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3875 createSMESHAction( 1131, "DISPMODE" );
3876 createSMESHAction( 1132, "COLORS" );
3877 createSMESHAction( 1133, "TRANSP" );
3878 createSMESHAction( 1134, "CLIP" );
3879 createSMESHAction( 1135, "DISP_ENT" );
3880 createSMESHAction( 1136, "AUTO_COLOR" );
3881 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3882 createSMESHAction( 2000, "CTRL" );
3884 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3885 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3886 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3887 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3888 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3890 createSMESHAction( 300, "HIDE" );
3891 createSMESHAction( 301, "SHOW" );
3892 createSMESHAction( 302, "DISPLAY_ONLY" );
3894 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3896 // ----- create menu --------------
3897 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3898 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3899 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3900 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3901 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3902 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3903 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3904 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3906 createMenu( separator(), fileId );
3908 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3909 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3910 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3911 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3912 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3913 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3914 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3915 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3916 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3917 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3918 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3920 //createMenu( 111, importId, -1 );
3921 createMenu( 112, importId, -1 );
3922 createMenu( 113, importId, -1 );
3923 createMenu( 115, importId, -1 );
3925 createMenu( 116, importId, -1 );
3927 createMenu( 117, importId, -1 );
3928 createMenu( 118, importId, -1 );
3929 createMenu( 121, exportId, -1 );
3930 createMenu( 122, exportId, -1 );
3931 createMenu( 123, exportId, -1 );
3932 createMenu( 140, exportId, -1 ); // export to STL
3934 createMenu( 142, exportId, -1 ); // export to CGNS
3936 createMenu( 144, exportId, -1 ); // export to SAUV
3937 createMenu( 146, exportId, -1 ); // export to GMF
3938 createMenu( separator(), fileId, 10 );
3940 createMenu( 33, editId, -1 );
3942 createMenu( 5105, toolsId, -1 );
3944 createMenu( 702, meshId, -1 ); // "Mesh" menu
3945 createMenu( 703, meshId, -1 );
3946 createMenu( 704, meshId, -1 );
3947 createMenu( 710, meshId, -1 );
3948 createMenu( 705, meshId, -1 );
3949 createMenu( separator(), meshId, -1 );
3950 createMenu( 701, meshId, -1 );
3951 createMenu( 711, meshId, -1 );
3952 createMenu( 712, meshId, -1 );
3953 createMenu( 713, meshId, -1 );
3954 createMenu( separator(), meshId, -1 );
3955 createMenu( 801, meshId, -1 );
3956 createMenu( 806, meshId, -1 );
3957 createMenu( 802, meshId, -1 );
3958 createMenu( 803, meshId, -1 );
3959 createMenu( 815, meshId, -1 );
3960 createMenu( separator(), meshId, -1 );
3961 createMenu( 810, meshId, -1 );
3962 createMenu( 811, meshId, -1 );
3963 createMenu( 812, meshId, -1 );
3964 createMenu( separator(), meshId, -1 );
3965 createMenu( 814, meshId, -1 );
3966 createMenu( separator(), meshId, -1 );
3967 createMenu( 900, meshId, -1 );
3968 //createMenu( 902, meshId, -1 );
3969 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3970 createMenu( 904, meshId, -1 );
3971 createMenu( separator(), meshId, -1 );
3973 createMenu( 6005, nodeId, -1 );
3974 createMenu( 6028, nodeId, -1 );
3975 createMenu( 6002, edgeId, -1 );
3976 createMenu( 6003, edgeId, -1 );
3977 createMenu( 6001, edgeId, -1 );
3978 createMenu( 6004, edgeId, -1 );
3979 createMenu( 6029, edgeId, -1 );
3980 createMenu( 6021, faceId, -1 );
3981 createMenu( 6025, faceId, -1 );
3982 createMenu( 6027, faceId, -1 );
3983 createMenu( 6018, faceId, -1 );
3984 createMenu( 6019, faceId, -1 );
3985 createMenu( 6011, faceId, -1 );
3986 createMenu( 6012, faceId, -1 );
3987 createMenu( 6013, faceId, -1 );
3988 createMenu( 6014, faceId, -1 );
3989 createMenu( 6015, faceId, -1 );
3990 createMenu( 6016, faceId, -1 );
3991 createMenu( 6022, faceId, -1 );
3992 createMenu( 6030, faceId, -1 );
3993 createMenu( 6017, volumeId, -1 );
3994 createMenu( 6009, volumeId, -1 );
3995 createMenu( 6023, volumeId, -1 );
3996 createMenu( 6024, volumeId, -1 );
3997 createMenu( 6026, volumeId, -1 );
3998 createMenu( 6031, volumeId, -1 );
3999 createMenu( separator(), ctrlId, -1 );
4000 createMenu( 6032, ctrlId, -1 );
4002 createMenu( 4000, addId, -1 );
4003 createMenu( 4009, addId, -1 );
4004 createMenu( 4070, addId, -1 );
4005 createMenu( 4008, addId, -1 );
4006 createMenu( 4010, addId, -1 );
4007 createMenu( 4021, addId, -1 );
4008 createMenu( 4022, addId, -1 );
4009 createMenu( 4023, addId, -1 );
4010 createMenu( 4031, addId, -1 );
4011 createMenu( 4032, addId, -1 );
4012 createMenu( 4133, addId, -1 );
4013 createMenu( 4134, addId, -1 );
4014 createMenu( 4135, addId, -1 );
4015 createMenu( 4033, addId, -1 );
4016 createMenu( separator(), addId, -1 );
4017 createMenu( 4034, addId, -1 );
4018 createMenu( 4035, addId, -1 );
4019 createMenu( 4137, addId, -1 );
4020 createMenu( 4036, addId, -1 );
4021 createMenu( 4136, addId, -1 );
4022 createMenu( 4037, addId, -1 );
4023 createMenu( 4038, addId, -1 );
4024 createMenu( 4039, addId, -1 );
4025 createMenu( 4040, addId, -1 );
4026 createMenu( 4140, addId, -1 );
4028 createMenu( 4041, removeId, -1 );
4029 createMenu( 4042, removeId, -1 );
4030 createMenu( 4044, removeId, -1 );
4031 createMenu( separator(), removeId, -1 );
4032 createMenu( 813, removeId, -1 );
4033 createMenu( separator(), removeId, -1 );
4034 createMenu( 4043, removeId, -1 );
4036 createMenu( 4051, renumId, -1 );
4037 createMenu( 4052, renumId, -1 );
4039 createMenu( 4061, transfId, -1 );
4040 createMenu( 4062, transfId, -1 );
4041 createMenu( 4063, transfId, -1 );
4042 createMenu( 4068, transfId, -1 );
4043 createMenu( 4064, transfId, -1 );
4044 createMenu( 4065, transfId, -1 );
4045 createMenu( 4066, transfId, -1 );
4046 createMenu( 4069, transfId, -1 );
4048 createMenu( 4067,modifyId, -1 );
4049 createMenu( 407, modifyId, -1 );
4050 createMenu( 408, modifyId, -1 );
4051 createMenu( 409, modifyId, -1 );
4052 createMenu( 420, modifyId, -1 );
4053 createMenu( 410, modifyId, -1 );
4054 createMenu( 411, modifyId, -1 );
4055 createMenu( 419, modifyId, -1 );
4056 createMenu( 412, modifyId, -1 );
4057 createMenu( 413, modifyId, -1 );
4058 createMenu( 416, modifyId, -1 );
4059 createMenu( 414, modifyId, -1 );
4060 createMenu( 415, modifyId, -1 );
4061 createMenu( 417, modifyId, -1 );
4062 createMenu( 418, modifyId, -1 );
4064 createMenu( 501, measureId, -1 );
4065 createMenu( 502, measureId, -1 );
4066 createMenu( 503, basicPropId, -1 );
4067 createMenu( 504, basicPropId, -1 );
4068 createMenu( 505, basicPropId, -1 );
4069 createMenu( 214, viewId, -1 );
4071 // ----- create toolbars --------------
4072 int meshTb = createTool( tr( "TB_MESH" ) ),
4073 info = createTool( tr( "TB_INFO" ) ),
4074 groupTb = createTool( tr( "TB_GROUP" ) ),
4075 ctrl0dTb = createTool( tr( "TB_CTRL0D" ) ),
4076 ctrl1dTb = createTool( tr( "TB_CTRL1D" ) ),
4077 ctrl2dTb = createTool( tr( "TB_CTRL2D" ) ),
4078 ctrl3dTb = createTool( tr( "TB_CTRL3D" ) ),
4079 addElemTb = createTool( tr( "TB_ADD" ) ),
4080 addNonElemTb = createTool( tr( "TB_ADDNON" ) ),
4081 remTb = createTool( tr( "TB_REM" ) ),
4082 renumbTb = createTool( tr( "TB_RENUMBER" ) ),
4083 transformTb = createTool( tr( "TB_TRANSFORM" ) ),
4084 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4085 measuremTb = createTool( tr( "TB_MEASUREM" ) ),
4086 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4088 createTool( 702, meshTb );
4089 createTool( 703, meshTb );
4090 createTool( 704, meshTb );
4091 createTool( 710, meshTb );
4092 createTool( 705, meshTb );
4093 createTool( separator(), meshTb );
4094 createTool( 701, meshTb );
4095 createTool( 711, meshTb );
4096 createTool( 712, meshTb );
4097 createTool( 713, meshTb );
4099 createTool( 801, groupTb );
4100 createTool( 806, groupTb );
4101 createTool( 802, groupTb );
4102 createTool( 803, groupTb );
4104 createTool( 900, info );
4105 //createTool( 902, meshTb );
4106 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4107 createTool( 904, info );
4109 createTool( 6005, ctrl0dTb );
4110 createTool( 6028, ctrl0dTb );
4112 createTool( 6002, ctrl1dTb );
4113 createTool( 6003, ctrl1dTb );
4114 createTool( 6001, ctrl1dTb );
4115 createTool( 6004, ctrl1dTb );
4116 createTool( 6029, ctrl1dTb );
4118 createTool( 6021, ctrl2dTb );
4119 createTool( 6025, ctrl2dTb );
4120 createTool( 6027, ctrl2dTb );
4121 createTool( 6018, ctrl2dTb );
4122 createTool( 6019, ctrl2dTb );
4123 createTool( 6011, ctrl2dTb );
4124 createTool( 6012, ctrl2dTb );
4125 createTool( 6013, ctrl2dTb );
4126 createTool( 6014, ctrl2dTb );
4127 createTool( 6015, ctrl2dTb );
4128 createTool( 6016, ctrl2dTb );
4129 createTool( 6022, ctrl2dTb );
4130 createTool( 6030, ctrl2dTb );
4132 createTool( 6017, ctrl3dTb );
4133 createTool( 6009, ctrl3dTb );
4134 createTool( 6023, ctrl3dTb );
4135 createTool( 6024, ctrl3dTb );
4136 createTool( 6026, ctrl3dTb );
4137 createTool( 6031, ctrl3dTb );
4139 createTool( 4000, addElemTb );
4140 createTool( 4009, addElemTb );
4141 createTool( 4070, addElemTb );
4142 createTool( 4008, addElemTb );
4143 createTool( 4010, addElemTb );
4144 createTool( 4021, addElemTb );
4145 createTool( 4022, addElemTb );
4146 createTool( 4023, addElemTb );
4147 createTool( 4031, addElemTb );
4148 createTool( 4032, addElemTb );
4149 createTool( 4133, addElemTb );
4150 createTool( 4134, addElemTb );
4151 createTool( 4135, addElemTb );
4152 createTool( 4033, addElemTb );
4154 createTool( 4034, addNonElemTb );
4155 createTool( 4035, addNonElemTb );
4156 createTool( 4137, addNonElemTb );
4157 createTool( 4036, addNonElemTb );
4158 createTool( 4136, addNonElemTb );
4159 createTool( 4037, addNonElemTb );
4160 createTool( 4038, addNonElemTb );
4161 createTool( 4039, addNonElemTb );
4162 createTool( 4040, addNonElemTb );
4163 createTool( 4140, addNonElemTb );
4165 createTool( 4041, remTb );
4166 createTool( 4042, remTb );
4167 createTool( 4044, remTb );
4168 createTool( 4043, remTb );
4170 createTool( 4051, renumbTb );
4171 createTool( 4052, renumbTb );
4174 createTool( 4061, transformTb );
4175 createTool( 4062, transformTb );
4176 createTool( 4063, transformTb );
4177 createTool( 4068, transformTb );
4178 createTool( 4064, transformTb );
4179 createTool( 4065, transformTb );
4180 createTool( 4066, transformTb );
4181 createTool( 4069, transformTb );
4183 createTool( 4067,modifyTb );
4184 createTool( 407, modifyTb );
4185 createTool( 408, modifyTb );
4186 createTool( 409, modifyTb );
4187 createTool( 420, modifyTb );
4188 createTool( 410, modifyTb );
4189 createTool( 411, modifyTb );
4190 createTool( 419, modifyTb );
4191 createTool( 412, modifyTb );
4192 createTool( 413, modifyTb );
4193 createTool( 416, modifyTb );
4194 createTool( 414, modifyTb );
4195 createTool( 415, modifyTb );
4196 createTool( 417, modifyTb );
4197 createTool( 418, modifyTb );
4199 createTool( 501, measuremTb );
4201 createTool( 214, dispModeTb );
4203 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4204 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4207 QString OB = "'ObjectBrowser'",
4208 View = "'" + SVTK_Viewer::Type() + "'",
4210 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4211 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4212 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4213 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4214 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4215 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4216 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4217 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4218 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4219 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4220 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4222 mesh_part = mesh + " " + subMesh + " " + group,
4223 mesh_group = mesh + " " + group,
4224 hyp_alg = hypo + " " + algo;
4226 // popup for object browser
4228 isInvisible("not( isVisible )"),
4229 isEmpty("numberOfNodes = 0"),
4230 isNotEmpty("numberOfNodes <> 0"),
4232 // has nodes, edges, etc in VISIBLE! actor
4233 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4234 hasElems("(count( elemTypes ) > 0)"),
4235 hasDifferentElems("(count( elemTypes ) > 1)"),
4236 hasBalls("({'BallElem'} in elemTypes)"),
4237 hasElems0d("({'Elem0d'} in elemTypes)"),
4238 hasEdges("({'Edge'} in elemTypes)"),
4239 hasFaces("({'Face'} in elemTypes)"),
4240 hasVolumes("({'Volume'} in elemTypes)");
4242 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4243 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4244 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4245 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4246 createPopupItem( 803, OB, group ); // EDIT_GROUP
4247 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4249 popupMgr()->insert( separator(), -1, 0 );
4250 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4251 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4252 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4253 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4254 createPopupItem( 214, OB, mesh_part ); // UPDATE
4255 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4256 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4257 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4258 popupMgr()->insert( separator(), -1, 0 );
4259 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4260 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4261 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4262 popupMgr()->insert( separator(), -1, 0 );
4263 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4264 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4265 popupMgr()->insert( separator(), -1, 0 );
4266 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4267 popupMgr()->insert( separator(), -1, 0 );
4268 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4269 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4271 popupMgr()->insert( separator(), -1, 0 );
4273 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4274 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4275 QString only_one_2D = only_one_non_empty + " && dim>1";
4277 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4278 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4279 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4280 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4282 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4284 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4285 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4286 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4287 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4288 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4289 popupMgr()->insert( separator(), -1, 0 );
4292 createPopupItem( 803, View, group ); // EDIT_GROUP
4293 createPopupItem( 804, View, elems ); // ADD
4294 createPopupItem( 805, View, elems ); // REMOVE
4296 popupMgr()->insert( separator(), -1, 0 );
4297 createPopupItem( 214, View, mesh_part ); // UPDATE
4298 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4299 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4300 createPopupItem( 904, View, mesh ); // FIND_ELEM
4301 popupMgr()->insert( separator(), -1, 0 );
4303 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4304 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4305 popupMgr()->insert( separator(), -1, 0 );
4307 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4308 QString aType = QString( "%1type in {%2}" ).arg( lc );
4309 aType = aType.arg( mesh_part );
4310 QString aMeshInVTK = aClient + "&&" + aType;
4312 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4313 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4314 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4316 //-------------------------------------------------
4318 //-------------------------------------------------
4319 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4321 popupMgr()->insert( action( 9010 ), anId, -1 );
4322 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4323 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4325 popupMgr()->insert( action( 9011 ), anId, -1 );
4326 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4327 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4329 popupMgr()->insert( separator(), -1, -1 );
4331 //-------------------------------------------------
4333 //-------------------------------------------------
4334 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4336 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4337 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4338 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4340 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4341 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4342 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4344 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4345 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4346 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4348 popupMgr()->insert( separator(), anId, -1 );
4350 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4351 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4352 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4354 //-------------------------------------------------
4356 //-------------------------------------------------
4357 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4359 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4361 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4362 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4363 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4365 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4366 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4367 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4369 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4370 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4371 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4373 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4374 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4375 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4377 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4378 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4379 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4381 popupMgr()->insert( separator(), anId, -1 );
4383 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4384 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4387 //-------------------------------------------------
4388 // Representation of the 2D Quadratic elements
4389 //-------------------------------------------------
4390 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4391 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4392 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4393 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4395 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4396 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4397 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4399 //-------------------------------------------------
4400 // Orientation of faces
4401 //-------------------------------------------------
4402 popupMgr()->insert( action( 221 ), -1, -1 );
4403 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4404 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4406 //-------------------------------------------------
4408 //-------------------------------------------------
4409 popupMgr()->insert( action( 1132 ), -1, -1 );
4410 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4412 //-------------------------------------------------
4414 //-------------------------------------------------
4415 popupMgr()->insert( action( 1133 ), -1, -1 );
4416 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4418 //-------------------------------------------------
4420 //-------------------------------------------------
4422 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4423 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4424 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4425 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4427 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4429 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4430 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4432 popupMgr()->insert( separator(), anId, -1 );
4434 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4436 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4437 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4438 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4440 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4441 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4442 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4444 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4446 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4447 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4448 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4450 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4451 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4452 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4454 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4455 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4456 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4458 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4459 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4460 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4461 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4462 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4463 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4465 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4467 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4468 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4469 QtxPopupMgr::VisibleRule );
4470 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4472 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4473 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4474 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4476 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4477 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4478 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4480 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4481 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4482 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4484 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4485 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4486 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4488 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4489 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4490 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4492 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4493 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4494 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4496 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4497 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4498 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4500 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4501 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4502 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4504 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4505 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4506 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4508 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4509 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4510 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4512 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4513 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4514 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4515 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4516 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4517 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4519 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4521 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4522 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4523 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4525 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4526 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4527 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4529 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4530 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4531 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4533 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4534 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4535 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4537 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4538 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4539 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4541 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4542 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4543 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4545 popupMgr()->insert( separator(), anId, -1 );
4547 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4548 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4550 popupMgr()->insert( separator(), anId, -1 );
4552 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4554 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4555 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4557 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4558 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4559 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4561 #ifndef DISABLE_PLOT2DVIEWER
4562 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4563 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4566 //-------------------------------------------------
4568 //-------------------------------------------------
4569 popupMgr()->insert( separator(), -1, -1 );
4570 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4571 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4572 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4573 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4575 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4576 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4578 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4579 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4581 popupMgr()->insert( separator(), -1, -1 );
4583 //-------------------------------------------------
4585 //-------------------------------------------------
4586 popupMgr()->insert( action( 1134 ), -1, -1 );
4587 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4589 popupMgr()->insert( separator(), -1, -1 );
4591 popupMgr()->insert( action( 41 ), -1, -1 );
4592 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4593 popupMgr()->insert( separator(), -1, -1 );
4595 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4596 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4598 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4599 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4602 //================================================================================
4604 * \brief Return true if SMESH or GEOM objects are selected.
4605 * Is called form LightApp_Module::activateModule() which clear selection if
4606 * not isSelectionCompatible()
4608 //================================================================================
4610 bool SMESHGUI::isSelectionCompatible()
4612 bool isCompatible = true;
4613 SALOME_ListIO selected;
4614 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4615 Sel->selectedObjects( selected );
4617 SALOME_ListIteratorOfListIO It( selected );
4618 for ( ; isCompatible && It.More(); It.Next())
4620 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4621 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4623 return isCompatible;
4627 bool SMESHGUI::reusableOperation( const int id )
4629 // compute, evaluate and precompute are not reusable operations
4630 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4633 bool SMESHGUI::activateModule( SUIT_Study* study )
4635 bool res = SalomeApp_Module::activateModule( study );
4637 setMenuShown( true );
4638 setToolShown( true );
4640 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4641 PyGILState_STATE gstate = PyGILState_Ensure();
4642 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4643 if ( !pluginsmanager ) {
4647 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4651 PyGILState_Release(gstate);
4652 // end of SMESH plugins loading
4654 // Reset actions accelerator keys
4655 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4656 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4657 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4659 action( 33)->setEnabled(true); // Delete: Key_Delete
4661 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4662 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4663 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4664 if ( _PTR(Study) aStudy = s->studyDS()) {
4665 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4666 updateObjBrowser(); // objects can be removed
4669 // get all view currently opened in the study and connect their signals to
4670 // the corresponding slots of the class.
4671 SUIT_Desktop* aDesk = study->application()->desktop();
4673 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4674 SUIT_ViewWindow* wnd;
4675 foreach ( wnd, wndList )
4682 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4684 setMenuShown( false );
4685 setToolShown( false );
4687 EmitSignalCloseAllDialogs();
4689 // Unset actions accelerator keys
4690 //action(111)->setShortcut(QKeySequence()); // Import DAT
4691 action(112)->setShortcut(QKeySequence()); // Import UNV
4692 action(113)->setShortcut(QKeySequence()); // Import MED
4694 action( 33)->setEnabled(false); // Delete: Key_Delete
4696 return SalomeApp_Module::deactivateModule( study );
4699 void SMESHGUI::studyClosed( SUIT_Study* s )
4701 SMESH::RemoveVisuData( s->id() );
4702 SalomeApp_Module::studyClosed( s );
4705 void SMESHGUI::OnGUIEvent()
4707 const QObject* obj = sender();
4708 if ( !obj || !obj->inherits( "QAction" ) )
4710 int id = actionId((QAction*)obj);
4715 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4717 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4718 if ( CORBA::is_nil( myComponentSMESH ) )
4720 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4722 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4723 return aGUI.myComponentSMESH;
4726 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4727 return myComponentSMESH;
4730 QString SMESHGUI::engineIOR() const
4732 CORBA::ORB_var anORB = getApp()->orb();
4733 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4734 return QString( anIOR.in() );
4737 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4739 SalomeApp_Module::contextMenuPopup( client, menu, title );
4741 selectionMgr()->selectedObjects( lst );
4742 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4743 Handle(SALOME_InteractiveObject) io = lst.First();
4744 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4745 _PTR(Study) study = appStudy->studyDS();
4746 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4748 QString aName = QString( obj->GetName().c_str() );
4749 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4750 aName.remove( (aName.length() - 1), 1 );
4756 LightApp_Selection* SMESHGUI::createSelection() const
4758 return new SMESHGUI_Selection();
4761 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4763 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4764 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4767 void SMESHGUI::viewManagers( QStringList& list ) const
4769 list.append( SVTK_Viewer::Type() );
4772 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4774 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4775 SMESH::UpdateSelectionProp( this );
4777 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4778 for(int i = 0; i < aViews.count() ; i++){
4779 SUIT_ViewWindow *sf = aViews[i];
4785 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4787 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4788 myClippingPlaneInfoMap.erase( theViewManager );
4791 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4793 theActor->AddObserver( SMESH::DeleteActorEvent,
4794 myEventCallbackCommand.GetPointer(),
4798 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4799 unsigned long theEvent,
4800 void* theClientData,
4803 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4804 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4805 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4806 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4807 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4808 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4809 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4810 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4811 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4812 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4813 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4814 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4815 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4816 if( anActor == *anIter3 ) {
4817 anActorList.erase( anIter3 );
4828 void SMESHGUI::createPreferences()
4830 // General tab ------------------------------------------------------------------------
4831 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4833 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4834 setPreferenceProperty( autoUpdate, "columns", 2 );
4835 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4836 setPreferenceProperty( lim, "min", 0 );
4837 setPreferenceProperty( lim, "max", 100000000 );
4838 setPreferenceProperty( lim, "step", 1000 );
4839 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4840 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4842 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4843 setPreferenceProperty( qaGroup, "columns", 2 );
4844 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4845 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4846 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4847 setPreferenceProperty( prec, "min", 0 );
4848 setPreferenceProperty( prec, "max", 16 );
4849 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4850 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4851 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4852 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4853 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4855 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4856 setPreferenceProperty( dispgroup, "columns", 2 );
4857 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4859 modes.append( tr("MEN_WIRE") );
4860 modes.append( tr("MEN_SHADE") );
4861 modes.append( tr("MEN_NODES") );
4862 modes.append( tr("MEN_SHRINK") );
4863 QList<QVariant> indices;
4864 indices.append( 0 );
4865 indices.append( 1 );
4866 indices.append( 2 );
4867 indices.append( 3 );
4868 setPreferenceProperty( dispmode, "strings", modes );
4869 setPreferenceProperty( dispmode, "indexes", indices );
4871 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4872 setPreferenceProperty( arcgroup, "columns", 2 );
4873 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4874 QStringList quadraticModes;
4875 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4876 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4878 indices.append( 0 );
4879 indices.append( 1 );
4880 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4881 setPreferenceProperty( quadraticmode, "indexes", indices );
4883 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4884 "SMESH", "max_angle" );
4885 setPreferenceProperty( maxAngle, "min", 1 );
4886 setPreferenceProperty( maxAngle, "max", 90 );
4890 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4891 setPreferenceProperty( exportgroup, "columns", 2 );
4892 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4893 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4895 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4896 setPreferenceProperty( computeGroup, "columns", 2 );
4897 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4899 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4900 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4901 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4903 indices.append( 0 );
4904 indices.append( 1 );
4905 indices.append( 2 );
4906 setPreferenceProperty( notifyMode, "strings", modes );
4907 setPreferenceProperty( notifyMode, "indexes", indices );
4909 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4910 setPreferenceProperty( infoGroup, "columns", 2 );
4911 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4913 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4914 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4916 indices.append( 0 );
4917 indices.append( 1 );
4918 setPreferenceProperty( elemInfo, "strings", modes );
4919 setPreferenceProperty( elemInfo, "indexes", indices );
4920 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4921 setPreferenceProperty( nodesLim, "min", 0 );
4922 setPreferenceProperty( nodesLim, "max", 10000000 );
4923 setPreferenceProperty( nodesLim, "step", 10000 );
4924 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4925 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4926 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4927 setPreferenceProperty( ctrlLim, "min", 0 );
4928 setPreferenceProperty( ctrlLim, "max", 10000000 );
4929 setPreferenceProperty( ctrlLim, "step", 1000 );
4930 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4931 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4932 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4933 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4934 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4936 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4937 setPreferenceProperty( segGroup, "columns", 2 );
4938 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4939 "SMESH", "segmentation" );
4940 setPreferenceProperty( segLen, "min", 1 );
4941 setPreferenceProperty( segLen, "max", 10000000 );
4942 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4943 "SMESH", "nb_segments_per_edge" );
4944 setPreferenceProperty( nbSeg, "min", 1 );
4945 setPreferenceProperty( nbSeg, "max", 10000000 );
4947 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4948 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4949 "SMESH", "forget_mesh_on_hyp_modif" );
4952 // Quantities with individual precision settings
4953 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4954 setPreferenceProperty( precGroup, "columns", 2 );
4956 const int nbQuantities = 6;
4957 int precs[nbQuantities], ii = 0;
4958 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4959 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4960 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4961 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4962 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4963 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4964 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4965 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4966 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4967 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4968 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4969 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4971 // Set property for precision value for spinboxes
4972 for ( ii = 0; ii < nbQuantities; ii++ ){
4973 setPreferenceProperty( precs[ii], "min", -14 );
4974 setPreferenceProperty( precs[ii], "max", 14 );
4975 setPreferenceProperty( precs[ii], "precision", 2 );
4978 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4979 setPreferenceProperty( previewGroup, "columns", 2 );
4980 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4981 setPreferenceProperty( chunkSize, "min", 1 );
4982 setPreferenceProperty( chunkSize, "max", 1000 );
4983 setPreferenceProperty( chunkSize, "step", 50 );
4985 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4986 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4988 // Mesh tab ------------------------------------------------------------------------
4989 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4990 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4991 setPreferenceProperty( nodeGroup, "columns", 3 );
4993 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4995 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4997 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4998 QList<QVariant> aMarkerTypeIndicesList;
4999 QList<QVariant> aMarkerTypeIconsList;
5000 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5001 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5002 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5003 aMarkerTypeIndicesList << i;
5004 aMarkerTypeIconsList << pixmap;
5006 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5007 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5009 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5011 QList<QVariant> aMarkerScaleIndicesList;
5012 QStringList aMarkerScaleValuesList;
5013 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5014 aMarkerScaleIndicesList << i;
5015 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5017 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5018 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5020 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5021 //setPreferenceProperty( elemGroup, "columns", 2 );
5023 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5024 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5025 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5026 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5027 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5028 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5029 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5030 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5031 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5034 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5035 setPreferenceProperty( grpGroup, "columns", 2 );
5037 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5038 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5040 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5041 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5042 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5043 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5044 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5045 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5046 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5047 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5048 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5049 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5050 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5051 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5053 setPreferenceProperty( size0d, "min", 1 );
5054 setPreferenceProperty( size0d, "max", 10 );
5056 setPreferenceProperty( ballSize, "min", 1 );
5057 setPreferenceProperty( ballSize, "max", 10 );
5059 setPreferenceProperty( ballScale, "min", 1e-2 );
5060 setPreferenceProperty( ballScale, "max", 1e7 );
5061 setPreferenceProperty( ballScale, "step", 0.5 );
5063 setPreferenceProperty( elemW, "min", 1 );
5064 setPreferenceProperty( elemW, "max", 5 );
5066 setPreferenceProperty( outW, "min", 1 );
5067 setPreferenceProperty( outW, "max", 5 );
5069 setPreferenceProperty( shrink, "min", 0 );
5070 setPreferenceProperty( shrink, "max", 100 );
5072 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5073 setPreferenceProperty( numGroup, "columns", 2 );
5075 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5076 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5078 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5079 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5081 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5082 setPreferenceProperty( orientGroup, "columns", 1 );
5084 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5085 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5087 setPreferenceProperty( orientScale, "min", 0.05 );
5088 setPreferenceProperty( orientScale, "max", 0.5 );
5089 setPreferenceProperty( orientScale, "step", 0.05 );
5091 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5093 // Selection tab ------------------------------------------------------------------------
5094 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5096 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5097 setPreferenceProperty( selGroup, "columns", 2 );
5099 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5100 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5102 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5103 setPreferenceProperty( preGroup, "columns", 2 );
5105 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5107 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5108 setPreferenceProperty( precSelGroup, "columns", 2 );
5110 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5111 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5112 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5114 // Scalar Bar tab ------------------------------------------------------------------------
5115 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5116 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5117 setPreferenceProperty( fontGr, "columns", 2 );
5119 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5120 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5122 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5123 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5125 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5126 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5128 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5129 setPreferenceProperty( numcol, "min", 2 );
5130 setPreferenceProperty( numcol, "max", 256 );
5132 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5133 setPreferenceProperty( numlab, "min", 2 );
5134 setPreferenceProperty( numlab, "max", 65 );
5136 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5137 setPreferenceProperty( orientGr, "columns", 2 );
5138 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5139 QStringList orients;
5140 orients.append( tr( "SMESH_VERTICAL" ) );
5141 orients.append( tr( "SMESH_HORIZONTAL" ) );
5142 indices.clear(); indices.append( 0 ); indices.append( 1 );
5143 setPreferenceProperty( orient, "strings", orients );
5144 setPreferenceProperty( orient, "indexes", indices );
5146 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5147 setPreferenceProperty( posVSizeGr, "columns", 2 );
5148 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5149 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5150 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5151 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5152 setPreferenceProperty( xv, "step", 0.1 );
5153 setPreferenceProperty( xv, "min", 0.0 );
5154 setPreferenceProperty( xv, "max", 1.0 );
5155 setPreferenceProperty( yv, "step", 0.1 );
5156 setPreferenceProperty( yv, "min", 0.0 );
5157 setPreferenceProperty( yv, "max", 1.0 );
5158 setPreferenceProperty( wv, "step", 0.1 );
5159 setPreferenceProperty( wv, "min", 0.0 );
5160 setPreferenceProperty( wv, "max", 1.0 );
5161 setPreferenceProperty( hv, "min", 0.0 );
5162 setPreferenceProperty( hv, "max", 1.0 );
5163 setPreferenceProperty( hv, "step", 0.1 );
5165 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5166 setPreferenceProperty( posHSizeGr, "columns", 2 );
5167 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5168 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5169 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5170 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5171 setPreferenceProperty( xv, "min", 0.0 );
5172 setPreferenceProperty( xv, "max", 1.0 );
5173 setPreferenceProperty( xv, "step", 0.1 );
5174 setPreferenceProperty( xh, "min", 0.0 );
5175 setPreferenceProperty( xh, "max", 1.0 );
5176 setPreferenceProperty( xh, "step", 0.1 );
5177 setPreferenceProperty( yh, "min", 0.0 );
5178 setPreferenceProperty( yh, "max", 1.0 );
5179 setPreferenceProperty( yh, "step", 0.1 );
5180 setPreferenceProperty( wh, "min", 0.0 );
5181 setPreferenceProperty( wh, "max", 1.0 );
5182 setPreferenceProperty( wh, "step", 0.1 );
5183 setPreferenceProperty( hh, "min", 0.0 );
5184 setPreferenceProperty( hh, "max", 1.0 );
5185 setPreferenceProperty( hh, "step", 0.1 );
5187 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5188 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5189 setPreferenceProperty( distributionGr, "columns", 3 );
5191 types.append( tr( "SMESH_MONOCOLOR" ) );
5192 types.append( tr( "SMESH_MULTICOLOR" ) );
5193 indices.clear(); indices.append( 0 ); indices.append( 1 );
5194 setPreferenceProperty( coloringType, "strings", types );
5195 setPreferenceProperty( coloringType, "indexes", indices );
5196 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5200 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5202 if( sect=="SMESH" ) {
5203 float sbX1,sbY1,sbW,sbH;
5204 float aTol = 1.00000009999999;
5205 std::string aWarning;
5206 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5207 if( name=="selection_object_color" || name=="selection_element_color" ||
5208 name=="highlight_color" ||
5209 name=="selection_precision_node" || name=="selection_precision_element" ||
5210 name=="selection_precision_object")
5211 SMESH::UpdateSelectionProp( this );
5212 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5213 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5214 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5215 if(sbX1+sbW > aTol){
5216 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5219 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5220 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5223 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5224 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5225 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5226 if(sbY1+sbH > aTol){
5227 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5228 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5229 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5232 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5233 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5234 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5235 if(sbX1+sbW > aTol){
5236 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5239 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5240 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5243 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5244 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5245 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5246 if(sbY1+sbH > aTol){
5247 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5250 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5251 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5254 else if ( name == "segmentation" ) {
5255 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5256 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5258 else if ( name == "nb_segments_per_edge" ) {
5259 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5260 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5262 else if ( name == "historical_python_dump" ||
5263 name == "forget_mesh_on_hyp_modif") {
5264 QString val = aResourceMgr->stringValue( "SMESH", name );
5265 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5267 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5268 SMESH::UpdateFontProp( this );
5270 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5271 SMESH::UpdateFontProp( this );
5274 if(aWarning.size() != 0){
5275 aWarning += "The default values are applied instead.";
5276 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5277 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5278 QObject::tr(aWarning.c_str()));
5283 //================================================================================
5285 * \brief Update something in accordance with update flags
5286 * \param theFlags - update flags
5288 * Update viewer or/and object browser etc. in accordance with update flags ( see
5289 * LightApp_UpdateFlags enumeration ).
5291 //================================================================================
5292 void SMESHGUI::update( const int flags )
5294 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5295 SMESH::UpdateView();
5297 SalomeApp_Module::update( flags );
5300 //================================================================================
5302 * \brief Set default selection mode
5304 * SLOT called when operation commited. Sets default selection mode
5306 //================================================================================
5307 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5309 SVTK_ViewWindow* vtkWnd =
5310 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5312 vtkWnd->SetSelectionMode( ActorSelection );
5315 //================================================================================
5317 * \brief Set default selection mode
5319 * SLOT called when operation aborted. Sets default selection mode
5321 //================================================================================
5322 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5324 SVTK_ViewWindow* vtkWnd =
5325 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5327 vtkWnd->SetSelectionMode( ActorSelection );
5330 //================================================================================
5332 * \brief Creates operation with given identifier
5333 * \param id - identifier of operation to be started
5334 * \return Pointer on created operation or NULL if operation is not created
5336 * Virtual method redefined from the base class creates operation with given id.
5337 * It is called called automatically from startOperation method of base class.
5339 //================================================================================
5340 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5342 LightApp_Operation* op = 0;
5343 // to do : create operation here
5346 case 417: //convert to quadratic
5347 op = new SMESHGUI_ConvToQuadOp();
5349 case 418: // create 2D mesh as boundary on 3D
5350 op = new SMESHGUI_Make2DFrom3DOp();
5352 case 420: // Reorient faces
5353 op = new SMESHGUI_ReorientFacesOp();
5355 case 701: // Compute mesh
5356 op = new SMESHGUI_ComputeOp();
5358 case 702: // Create mesh
5359 op = new SMESHGUI_MeshOp( true, true );
5361 case 703: // Create sub-mesh
5362 op = new SMESHGUI_MeshOp( true, false );
5364 case 704: // Edit mesh/sub-mesh
5365 op = new SMESHGUI_MeshOp( false );
5367 case 711: // Precompute mesh
5368 op = new SMESHGUI_PrecomputeOp();
5370 case 712: // Evaluate mesh
5371 op = new SMESHGUI_EvaluateOp();
5373 case 713: // Evaluate mesh
5374 op = new SMESHGUI_MeshOrderOp();
5376 case 806: // Create group on geom
5377 op = new SMESHGUI_GroupOnShapeOp();
5379 case 904: // Find element
5380 op = new SMESHGUI_FindElemByPointOp();
5382 case 4067: // Make mesh pass through point
5383 op = new SMESHGUI_MakeNodeAtPointOp();
5385 case 4070: // Create 0D elements on all nodes
5386 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5393 op = SalomeApp_Module::createOperation( id );
5397 //================================================================================
5399 * \brief Stops current operations and starts a given one
5400 * \param id - The id of the operation to start
5402 //================================================================================
5404 void SMESHGUI::switchToOperation(int id)
5406 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5407 activeStudy()->abortAllOperations();
5408 startOperation( id );
5411 LightApp_Displayer* SMESHGUI::displayer()
5414 myDisplayer = new SMESHGUI_Displayer( getApp() );
5418 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5421 int aTolerance = 64;
5422 int anIterations = 0;
5428 if( anIterations % aPeriod == 0 )
5431 if( aTolerance < 1 )
5435 aHue = (int)( 360.0 * rand() / RAND_MAX );
5438 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5439 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5440 for( ; it != itEnd; ++it )
5442 SALOMEDS::Color anAutoColor = *it;
5443 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5446 aQColor.getHsv( &h, &s, &v );
5447 if( abs( h - aHue ) < aTolerance )
5459 aColor.setHsv( aHue, 255, 255 );
5461 SALOMEDS::Color aSColor;
5462 aSColor.R = aColor.redF();
5463 aSColor.G = aColor.greenF();
5464 aSColor.B = aColor.blueF();
5469 const char* gSeparator = "_"; // character used to separate parameter names
5470 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5471 const char* gPathSep = "|"; // character used to separate paths
5474 * \brief Store visual parameters
5476 * This method is called just before the study document is saved.
5477 * Store visual parameters in AttributeParameter attribue(s)
5479 void SMESHGUI::storeVisualParameters (int savePoint)
5482 Kernel_Utils::Localizer loc;
5484 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5485 if (!appStudy || !appStudy->studyDS())
5487 _PTR(Study) studyDS = appStudy->studyDS();
5489 // componentName is used for encoding of entries when storing them in IParameters
5490 std::string componentName = myComponentSMESH->ComponentDataType();
5491 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5492 //if (!aSComponent) return;
5495 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5496 componentName.c_str(),
5498 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5500 // store map of custom markers
5501 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5502 if( !aMarkerMap.empty() )
5504 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5505 for( ; anIter != aMarkerMap.end(); anIter++ )
5507 int anId = anIter->first;
5508 VTK::MarkerData aMarkerData = anIter->second;
5509 std::string aMarkerFileName = aMarkerData.first;
5510 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5511 if( aMarkerTexture.size() < 3 )
5512 continue; // should contain at least width, height and the first value
5514 QString aPropertyName( "texture" );
5515 aPropertyName += gSeparator;
5516 aPropertyName += QString::number( anId );
5518 QString aPropertyValue = aMarkerFileName.c_str();
5519 aPropertyValue += gPathSep;
5521 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5522 ushort aWidth = *aTextureIter++;
5523 ushort aHeight = *aTextureIter++;
5524 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5525 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5526 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5527 aPropertyValue += QString::number( *aTextureIter );
5529 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5533 // viewers counters are used for storing view_numbers in IParameters
5536 // main cycle to store parameters of displayed objects
5537 QList<SUIT_ViewManager*> lst;
5538 QList<SUIT_ViewManager*>::Iterator it;
5539 getApp()->viewManagers(lst);
5540 for (it = lst.begin(); it != lst.end(); it++)
5542 SUIT_ViewManager* vman = *it;
5543 QString vType = vman->getType();
5545 // saving VTK actors properties
5546 if (vType == SVTK_Viewer::Type())
5548 // store the clipping planes attached to the view manager
5549 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5550 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5551 if( anIter != myClippingPlaneInfoMap.end() )
5552 aClippingPlaneInfoList = anIter->second;
5554 if( !aClippingPlaneInfoList.empty() ) {
5555 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5556 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5558 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5559 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5561 QString aPropertyName( "ClippingPlane" );
5562 aPropertyName += gSeparator;
5563 aPropertyName += QString::number( vtkViewers );
5564 aPropertyName += gSeparator;
5565 aPropertyName += QString::number( anId );
5567 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5568 aPropertyValue += gDigitsSep;
5569 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5570 aPropertyValue += gDigitsSep;
5571 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5572 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5573 aPropertyValue += gDigitsSep;
5574 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5575 aPropertyValue += gDigitsSep;
5576 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5577 aPropertyValue += gDigitsSep;
5578 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5579 aPropertyValue += gDigitsSep;
5580 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5581 aPropertyValue += gDigitsSep;
5582 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5583 aPropertyValue += gDigitsSep;
5584 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5586 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5587 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5588 aPropertyValue += gDigitsSep;
5589 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5590 aPropertyValue += gDigitsSep;
5591 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5592 aPropertyValue += gDigitsSep;
5593 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5596 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5600 QVector<SUIT_ViewWindow*> views = vman->getViews();
5601 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5603 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5605 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5606 vtkActorCollection* allActors = aCopy.GetActors();
5607 allActors->InitTraversal();
5608 while (vtkActor* actor = allActors->GetNextActor())
5610 if (actor->GetVisibility()) // store only visible actors
5612 SMESH_Actor* aSmeshActor = 0;
5613 if (actor->IsA("SMESH_Actor"))
5614 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5615 if (aSmeshActor && aSmeshActor->hasIO())
5617 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5620 // entry is "encoded" = it does NOT contain component adress,
5621 // since it is a subject to change on next component loading
5622 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5624 std::string param, vtkParam = vType.toLatin1().data();
5625 vtkParam += gSeparator;
5626 vtkParam += QString::number(vtkViewers).toLatin1().data();
5627 vtkParam += gSeparator;
5630 param = vtkParam + "Visibility";
5631 ip->setParameter(entry, param, "On");
5634 param = vtkParam + "Representation";
5635 ip->setParameter(entry, param, QString::number
5636 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5639 param = vtkParam + "IsShrunk";
5640 ip->setParameter(entry, param, QString::number
5641 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5643 // Displayed entities
5644 unsigned int aMode = aSmeshActor->GetEntityMode();
5645 bool isE = aMode & SMESH_Actor::eEdges;
5646 bool isF = aMode & SMESH_Actor::eFaces;
5647 bool isV = aMode & SMESH_Actor::eVolumes;
5648 bool is0d = aMode & SMESH_Actor::e0DElements;
5649 bool isB = aMode & SMESH_Actor::eBallElem;
5651 QString modeStr ("e");
5652 modeStr += gDigitsSep; modeStr += QString::number(isE);
5653 modeStr += gDigitsSep; modeStr += "f";
5654 modeStr += gDigitsSep; modeStr += QString::number(isF);
5655 modeStr += gDigitsSep; modeStr += "v";
5656 modeStr += gDigitsSep; modeStr += QString::number(isV);
5657 modeStr += gDigitsSep; modeStr += "0d";
5658 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5659 modeStr += gDigitsSep; modeStr += "b";
5660 modeStr += gDigitsSep; modeStr += QString::number(isB);
5662 param = vtkParam + "Entities";
5663 ip->setParameter(entry, param, modeStr.toLatin1().data());
5669 aSmeshActor->GetSufaceColor(r, g, b, delta);
5670 QStringList colorStr;
5671 colorStr << "surface";
5672 colorStr << QString::number(r);
5673 colorStr << QString::number(g);
5674 colorStr << QString::number(b);
5676 colorStr << "backsurface";
5677 colorStr << QString::number(delta);
5679 aSmeshActor->GetVolumeColor(r, g, b, delta);
5680 colorStr << "volume";
5681 colorStr << QString::number(r);
5682 colorStr << QString::number(g);
5683 colorStr << QString::number(b);
5684 colorStr << QString::number(delta);
5686 aSmeshActor->GetEdgeColor(r, g, b);
5688 colorStr << QString::number(r);
5689 colorStr << QString::number(g);
5690 colorStr << QString::number(b);
5692 aSmeshActor->GetNodeColor(r, g, b);
5694 colorStr << QString::number(r);
5695 colorStr << QString::number(g);
5696 colorStr << QString::number(b);
5698 aSmeshActor->GetOutlineColor(r, g, b);
5699 colorStr << "outline";
5700 colorStr << QString::number(r);
5701 colorStr << QString::number(g);
5702 colorStr << QString::number(b);
5704 aSmeshActor->Get0DColor(r, g, b);
5705 colorStr << "elem0d";
5706 colorStr << QString::number(r);
5707 colorStr << QString::number(g);
5708 colorStr << QString::number(b);
5710 aSmeshActor->GetBallColor(r, g, b);
5712 colorStr << QString::number(r);
5713 colorStr << QString::number(g);
5714 colorStr << QString::number(b);
5716 aSmeshActor->GetFacesOrientationColor(r, g, b);
5717 colorStr << "orientation";
5718 colorStr << QString::number(r);
5719 colorStr << QString::number(g);
5720 colorStr << QString::number(b);
5722 param = vtkParam + "Colors";
5723 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5726 QStringList sizeStr;
5728 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5729 sizeStr << "outline";
5730 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5731 sizeStr << "elem0d";
5732 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5734 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5735 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5736 sizeStr << "shrink";
5737 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5738 sizeStr << "orientation";
5739 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5740 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5742 param = vtkParam + "Sizes";
5743 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5748 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5749 if( aMarkerType == VTK::MT_USER ) {
5750 markerStr += "custom";
5751 markerStr += gDigitsSep;
5752 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5756 markerStr += gDigitsSep;
5757 markerStr += QString::number( (int)aMarkerType );
5758 markerStr += gDigitsSep;
5759 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5762 param = vtkParam + "PointMarker";
5763 ip->setParameter(entry, param, markerStr.toLatin1().data());
5766 param = vtkParam + "Opacity";
5767 ip->setParameter(entry, param,
5768 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5771 param = vtkParam + "ClippingPlane";
5773 if( !aClippingPlaneInfoList.empty() ) {
5774 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5775 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5777 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5778 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5779 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5780 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5781 if( aSmeshActor == *anIter2 ) {
5782 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5783 QString::number( anId ).toLatin1().constData() );
5790 ip->setParameter( entry, param, "Off" );
5791 } // if (io->hasEntry())
5792 } // SMESH_Actor && hasIO
5794 } // while.. actors traversal
5798 } // if (SVTK view model)
5799 } // for (viewManagers)
5802 // data structures for clipping planes processing
5806 bool isOpenGLClipping;
5807 vtkIdType RelativeOrientation;
5810 int AbsoluteOrientation;
5811 double X, Y, Z, Dx, Dy, Dz;
5813 typedef std::list<TPlaneData> TPlaneDataList;
5814 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5816 typedef std::list<vtkActor*> TActorList;
5819 TActorList ActorList;
5820 SUIT_ViewManager* ViewManager;
5822 typedef std::list<TPlaneInfo> TPlaneInfoList;
5823 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5826 * \brief Restore visual parameters
5828 * This method is called after the study document is opened.
5829 * Restore visual parameters from AttributeParameter attribue(s)
5831 void SMESHGUI::restoreVisualParameters (int savePoint)
5834 Kernel_Utils::Localizer loc;
5836 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5837 if (!appStudy || !appStudy->studyDS())
5839 _PTR(Study) studyDS = appStudy->studyDS();
5841 // componentName is used for encoding of entries when storing them in IParameters
5842 std::string componentName = myComponentSMESH->ComponentDataType();
5843 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5844 //if (!aSComponent) return;
5847 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5848 componentName.c_str(),
5850 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5852 // restore map of custom markers and map of clipping planes
5853 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5854 TPlaneDataMap aPlaneDataMap;
5856 std::vector<std::string> properties = ip->getProperties();
5857 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5859 std::string property = *propIt;
5860 QString aPropertyName( property.c_str() );
5861 QString aPropertyValue( ip->getProperty( property ).c_str() );
5863 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5864 if( aPropertyNameList.isEmpty() )
5867 QString aPropertyType = aPropertyNameList[0];
5868 if( aPropertyType == "texture" )
5870 if( aPropertyNameList.size() != 2 )
5874 int anId = aPropertyNameList[1].toInt( &ok );
5875 if( !ok || anId < 1 )
5878 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5879 if( aPropertyValueList.size() != 2 )
5882 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5883 QString aMarkerTextureString = aPropertyValueList[1];
5884 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5885 if( aMarkerTextureStringList.size() != 3 )
5889 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5894 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5898 VTK::MarkerTexture aMarkerTexture;
5899 aMarkerTexture.push_back( aWidth );
5900 aMarkerTexture.push_back( aHeight );
5902 QString aMarkerTextureData = aMarkerTextureStringList[2];
5903 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5905 QChar aChar = aMarkerTextureData.at( i );
5906 if( aChar.isDigit() )
5907 aMarkerTexture.push_back( aChar.digitValue() );
5910 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5912 else if( aPropertyType == "ClippingPlane" )
5914 if( aPropertyNameList.size() != 3 )
5918 int aViewId = aPropertyNameList[1].toInt( &ok );
5919 if( !ok || aViewId < 0 )
5923 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5924 if( !ok || aClippingPlaneId < 0 )
5927 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5928 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
5931 TPlaneData aPlaneData;
5932 aPlaneData.Id = aClippingPlaneId;
5935 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
5940 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
5944 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
5947 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
5952 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
5957 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
5962 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
5967 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
5972 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
5977 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
5981 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
5983 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
5988 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
5993 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
5998 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6003 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6004 aPlaneDataList.push_back( aPlaneData );
6008 TPlaneInfoMap aPlaneInfoMap;
6010 std::vector<std::string> entries = ip->getEntries();
6012 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6014 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6015 QString entry (ip->decodeEntry(*entIt).c_str());
6017 // Check that the entry corresponds to a real object in the Study
6018 // as the object may be deleted or modified after the visual state is saved.
6019 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6020 if (!so) continue; //Skip the not existent entry
6022 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6023 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6025 std::vector<std::string>::iterator namesIt = paramNames.begin();
6026 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6028 // actors are stored in a map after displaying of them for
6029 // quicker access in the future: map < viewID to actor >
6030 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6032 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6034 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6035 // '_' is used as separator and should not be used in viewer type or parameter names.
6036 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6037 if (lst.size() != 3)
6040 QString viewerTypStr = lst[0];
6041 QString viewIndexStr = lst[1];
6042 QString paramNameStr = lst[2];
6045 int viewIndex = viewIndexStr.toUInt(&ok);
6046 if (!ok) // bad conversion of view index to integer
6050 if (viewerTypStr == SVTK_Viewer::Type())
6052 SMESH_Actor* aSmeshActor = 0;
6053 if (vtkActors.IsBound(viewIndex))
6054 aSmeshActor = vtkActors.Find(viewIndex);
6056 QList<SUIT_ViewManager*> lst;
6057 getApp()->viewManagers(viewerTypStr, lst);
6059 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6060 SUIT_ViewManager* vman = NULL;
6061 if (viewIndex >= 0 && viewIndex < lst.count())
6062 vman = lst.at(viewIndex);
6064 if (paramNameStr == "Visibility")
6066 if (!aSmeshActor && displayer() && vman)
6068 SUIT_ViewModel* vmodel = vman->getViewModel();
6069 // SVTK view model can be casted to SALOME_View
6070 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6072 // store displayed actor in a temporary map for quicker
6073 // access later when restoring other parameters
6074 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6075 vtkRenderer* Renderer = vtkView->getRenderer();
6076 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6077 vtkActorCollection* theActors = aCopy.GetActors();
6078 theActors->InitTraversal();
6079 bool isFound = false;
6080 vtkActor *ac = theActors->GetNextActor();
6081 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6082 if (ac->IsA("SMESH_Actor")) {
6083 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6084 if (aGeomAc->hasIO()) {
6085 Handle(SALOME_InteractiveObject) io =
6086 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6087 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6089 vtkActors.Bind(viewIndex, aGeomAc);
6095 } // if (paramNameStr == "Visibility")
6098 // the rest properties "work" with SMESH_Actor
6101 QString val ((*valuesIt).c_str());
6104 if (paramNameStr == "Representation") {
6105 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6108 else if (paramNameStr == "IsShrunk") {
6110 if (!aSmeshActor->IsShrunk())
6111 aSmeshActor->SetShrink();
6114 if (aSmeshActor->IsShrunk())
6115 aSmeshActor->UnShrink();
6118 // Displayed entities
6119 else if (paramNameStr == "Entities") {
6120 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6121 int aEntityMode = SMESH_Actor::eAllEntity;
6122 for ( int i = 0; i < mode.count(); i+=2 ) {
6123 if ( i < mode.count()-1 ) {
6124 QString type = mode[i];
6125 bool val = mode[i+1].toInt();
6126 if ( type == "e" && !val )
6127 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6128 else if ( type == "f" && !val )
6129 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6130 else if ( type == "v" && !val )
6131 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6132 else if ( type == "0d" && !val )
6133 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6134 else if ( type == "b" && !val )
6135 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6138 aSmeshActor->SetEntityMode( aEntityMode );
6141 else if (paramNameStr == "Colors") {
6142 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6149 QColor outlineColor;
6150 QColor orientationColor;
6156 // below lines are required to get default values for delta coefficients
6157 // of backface color for faces and color of reversed volumes
6158 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6159 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6160 for ( int i = 0; i < colors.count(); i++ ) {
6161 QString type = colors[i];
6162 if ( type == "surface" ) {
6163 // face color is set by 3 values r:g:b, where
6164 // - r,g,b - is rgb color components
6165 if ( i+1 >= colors.count() ) break; // format error
6166 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6167 if ( i+2 >= colors.count() ) break; // format error
6168 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6169 if ( i+3 >= colors.count() ) break; // format error
6170 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6171 faceColor.setRgbF( r, g, b );
6174 else if ( type == "backsurface" ) {
6175 // backface color can be defined in several ways
6176 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6177 // - in latest versions, it is set as delta coefficient
6178 bool rgbOk = false, deltaOk;
6179 if ( i+1 >= colors.count() ) break; // format error
6180 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6181 int delta = colors[i+1].toInt( &deltaOk );
6183 if ( i+1 < colors.count() ) // index is shifted to 1
6184 g = colors[i+1].toDouble( &rgbOk );
6185 if ( rgbOk ) i++; // shift index
6186 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6187 b = colors[i+1].toDouble( &rgbOk );
6189 // - as currently there's no way to set directly backsurface color as it was before,
6190 // we ignore old dump where r,g,b triple was set
6191 // - also we check that delta parameter is set properly
6192 if ( !rgbOk && deltaOk )
6195 else if ( type == "volume" ) {
6196 // volume color is set by 4 values r:g:b:delta, where
6197 // - r,g,b - is a normal volume rgb color components
6198 // - delta - is a reversed volume color delta coefficient
6199 if ( i+1 >= colors.count() ) break; // format error
6200 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6201 if ( i+2 >= colors.count() ) break; // format error
6202 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6203 if ( i+3 >= colors.count() ) break; // format error
6204 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6205 if ( i+4 >= colors.count() ) break; // format error
6206 int delta = colors[i+4].toInt( &bOk );
6207 if ( !bOk ) break; // format error
6208 volumeColor.setRgbF( r, g, b );
6212 else if ( type == "edge" ) {
6213 // edge color is set by 3 values r:g:b, where
6214 // - r,g,b - is rgb color components
6215 if ( i+1 >= colors.count() ) break; // format error
6216 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6217 if ( i+2 >= colors.count() ) break; // format error
6218 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6219 if ( i+3 >= colors.count() ) break; // format error
6220 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6221 edgeColor.setRgbF( r, g, b );
6224 else if ( type == "node" ) {
6225 // node color is set by 3 values r:g:b, where
6226 // - r,g,b - is rgb color components
6227 if ( i+1 >= colors.count() ) break; // format error
6228 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6229 if ( i+2 >= colors.count() ) break; // format error
6230 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6231 if ( i+3 >= colors.count() ) break; // format error
6232 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6233 nodeColor.setRgbF( r, g, b );
6236 else if ( type == "elem0d" ) {
6237 // 0d element color is set by 3 values r:g:b, where
6238 // - r,g,b - is rgb color components
6239 if ( i+1 >= colors.count() ) break; // format error
6240 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6241 if ( i+2 >= colors.count() ) break; // format error
6242 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6243 if ( i+3 >= colors.count() ) break; // format error
6244 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6245 elem0dColor.setRgbF( r, g, b );
6248 else if ( type == "ball" ) {
6249 // ball color is set by 3 values r:g:b, where
6250 // - r,g,b - is rgb color components
6251 if ( i+1 >= colors.count() ) break; // format error
6252 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6253 if ( i+2 >= colors.count() ) break; // format error
6254 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6255 if ( i+3 >= colors.count() ) break; // format error
6256 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6257 ballColor.setRgbF( r, g, b );
6260 else if ( type == "outline" ) {
6261 // outline color is set by 3 values r:g:b, where
6262 // - r,g,b - is rgb color components
6263 if ( i+1 >= colors.count() ) break; // format error
6264 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6265 if ( i+2 >= colors.count() ) break; // format error
6266 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6267 if ( i+3 >= colors.count() ) break; // format error
6268 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6269 outlineColor.setRgbF( r, g, b );
6272 else if ( type == "orientation" ) {
6273 // orientation color is set by 3 values r:g:b, where
6274 // - r,g,b - is rgb color components
6275 if ( i+1 >= colors.count() ) break; // format error
6276 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6277 if ( i+2 >= colors.count() ) break; // format error
6278 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6279 if ( i+3 >= colors.count() ) break; // format error
6280 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6281 orientationColor.setRgbF( r, g, b );
6286 if ( nodeColor.isValid() )
6287 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6289 if ( edgeColor.isValid() )
6290 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6292 if ( faceColor.isValid() )
6293 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6295 if ( volumeColor.isValid() )
6296 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6297 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6298 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6300 if ( elem0dColor.isValid() )
6301 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6303 if ( ballColor.isValid() )
6304 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6306 if ( outlineColor.isValid() )
6307 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6308 // orientation color
6309 if ( orientationColor.isValid() )
6310 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6313 else if (paramNameStr == "Sizes") {
6314 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6317 int outlineWidth = -1;
6318 int elem0dSize = -1;
6320 double ballScale = -1.0;
6321 double shrinkSize = -1;
6322 double orientationSize = -1;
6323 bool orientation3d = false;
6324 for ( int i = 0; i < sizes.count(); i++ ) {
6325 QString type = sizes[i];
6326 if ( type == "line" ) {
6327 // line (wireframe) width is given as single integer value
6328 if ( i+1 >= sizes.count() ) break; // format error
6329 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6333 if ( type == "outline" ) {
6334 // outline width is given as single integer value
6335 if ( i+1 >= sizes.count() ) break; // format error
6336 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6340 else if ( type == "elem0d" ) {
6341 // 0d element size is given as single integer value
6342 if ( i+1 >= sizes.count() ) break; // format error
6343 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6347 else if ( type == "ball" ) {
6348 // balls are specified by two values: size:scale, where
6349 // - size - is a integer value specifying size
6350 // - scale - is a double value specifying scale factor
6351 if ( i+1 >= sizes.count() ) break; // format error
6352 int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6353 if ( i+2 >= sizes.count() ) break; // format error
6354 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6359 else if ( type == "shrink" ) {
6360 // shrink factor is given as single floating point value
6361 if ( i+1 >= sizes.count() ) break; // format error
6362 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6366 else if ( type == "orientation" ) {
6367 // orientation vectors are specified by two values size:3d, where
6368 // - size - is a floating point value specifying scale factor
6369 // - 3d - is a boolean
6370 if ( i+1 >= sizes.count() ) break; // format error
6371 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6372 if ( i+2 >= sizes.count() ) break; // format error
6373 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6374 orientationSize = v1;
6375 orientation3d = (bool)v2;
6379 // line (wireframe) width
6380 if ( lineWidth > 0 )
6381 aSmeshActor->SetLineWidth( lineWidth );
6383 if ( outlineWidth > 0 )
6384 aSmeshActor->SetOutlineWidth( outlineWidth );
6385 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6386 aSmeshActor->SetOutlineWidth( lineWidth );
6388 if ( elem0dSize > 0 )
6389 aSmeshActor->Set0DSize( elem0dSize );
6392 aSmeshActor->SetBallSize( ballSize );
6394 if ( ballScale > 0.0 )
6395 aSmeshActor->SetBallScale( ballScale );
6397 if ( shrinkSize > 0 )
6398 aSmeshActor->SetShrinkFactor( shrinkSize );
6399 // orientation vectors
6400 if ( orientationSize > 0 ) {
6401 aSmeshActor->SetFacesOrientationScale( orientationSize );
6402 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6406 else if (paramNameStr == "PointMarker") {
6407 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6408 if( data.count() >= 2 ) {
6410 int aParam1 = data[1].toInt( &ok );
6412 if( data[0] == "std" && data.count() == 3 ) {
6413 int aParam2 = data[2].toInt( &ok );
6414 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6416 else if( data[0] == "custom" ) {
6417 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6418 if( markerIt != aMarkerMap.end() ) {
6419 VTK::MarkerData aMarkerData = markerIt->second;
6420 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6427 else if (paramNameStr == "Opacity") {
6428 aSmeshActor->SetOpacity(val.toFloat());
6431 else if (paramNameStr.startsWith("ClippingPlane")) {
6432 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6433 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6434 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6435 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6436 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6437 // new format - val looks like "Off" or "0" (plane id)
6438 // (note: in new format "Off" value is used only for consistency,
6439 // so it is processed together with values in old format)
6440 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6441 if( anIsOldFormat ) {
6442 if (paramNameStr == "ClippingPlane1" || val == "Off")
6443 aSmeshActor->RemoveAllClippingPlanes();
6445 QList<SUIT_ViewManager*> lst;
6446 getApp()->viewManagers(viewerTypStr, lst);
6447 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6448 if (viewIndex >= 0 && viewIndex < lst.count()) {
6449 SUIT_ViewManager* vman = lst.at(viewIndex);
6450 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6452 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6454 SMESH::TActorList anActorList;
6455 anActorList.push_back( aSmeshActor );
6456 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6457 aPlane->myViewWindow = vtkView;
6458 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6459 aPlane->PlaneMode = aMode;
6460 bool isOpenGLClipping = ( bool )vals[1].toInt();
6461 aPlane->IsOpenGLClipping = isOpenGLClipping;
6462 if ( aMode == SMESH::Absolute ) {
6463 aPlane->myAbsoluteOrientation = vals[2].toInt();
6464 aPlane->X = vals[3].toFloat();
6465 aPlane->Y = vals[4].toFloat();
6466 aPlane->Z = vals[5].toFloat();
6467 aPlane->Dx = vals[6].toFloat();
6468 aPlane->Dy = vals[7].toFloat();
6469 aPlane->Dz = vals[8].toFloat();
6471 else if ( aMode == SMESH::Relative ) {
6472 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6473 aPlane->myDistance = vals[3].toFloat();
6474 aPlane->myAngle[0] = vals[4].toFloat();
6475 aPlane->myAngle[1] = vals[5].toFloat();
6479 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6480 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6481 aClippingPlaneInfo.Plane = aPlane;
6482 aClippingPlaneInfo.ActorList = anActorList;
6483 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6491 int aPlaneId = val.toInt( &ok );
6492 if( ok && aPlaneId >= 0 ) {
6493 bool anIsDefinedPlane = false;
6494 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6495 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6496 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6497 TPlaneInfo& aPlaneInfo = *anIter;
6498 if( aPlaneInfo.PlaneId == aPlaneId ) {
6499 aPlaneInfo.ActorList.push_back( aSmeshActor );
6500 anIsDefinedPlane = true;
6504 if( !anIsDefinedPlane ) {
6505 TPlaneInfo aPlaneInfo;
6506 aPlaneInfo.PlaneId = aPlaneId;
6507 aPlaneInfo.ActorList.push_back( aSmeshActor );
6508 aPlaneInfo.ViewManager = vman;
6510 // to make the list sorted by plane id
6511 anIter = aPlaneInfoList.begin();
6512 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6513 const TPlaneInfo& aPlaneInfoRef = *anIter;
6514 if( aPlaneInfoRef.PlaneId > aPlaneId )
6517 aPlaneInfoList.insert( anIter, aPlaneInfo );
6522 } // if (aSmeshActor)
6523 } // other parameters than Visibility
6525 } // for names/parameters iterator
6526 } // for entries iterator
6528 // take into account planes with empty list of actors referred to them
6529 QList<SUIT_ViewManager*> aVMList;
6530 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6532 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6533 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6534 int aViewId = aPlaneDataIter->first;
6535 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6536 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6538 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6540 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6541 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6542 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6543 const TPlaneData& aPlaneData = *anIter2;
6544 int aPlaneId = aPlaneData.Id;
6546 bool anIsFound = false;
6547 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6548 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6549 const TPlaneInfo& aPlaneInfo = *anIter3;
6550 if( aPlaneInfo.PlaneId == aPlaneId ) {
6557 TPlaneInfo aPlaneInfo; // ActorList field is empty
6558 aPlaneInfo.PlaneId = aPlaneId;
6559 aPlaneInfo.ViewManager = aViewManager;
6561 // to make the list sorted by plane id
6562 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6563 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6564 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6565 if( aPlaneInfoRef.PlaneId > aPlaneId )
6568 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6574 // add clipping planes to actors according to the restored parameters
6575 // and update the clipping plane map
6576 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6577 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6578 int aViewId = anIter1->first;
6579 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6581 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6582 if( anIter2 == aPlaneDataMap.end() )
6584 const TPlaneDataList& aPlaneDataList = anIter2->second;
6586 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6587 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6588 const TPlaneInfo& aPlaneInfo = *anIter3;
6589 int aPlaneId = aPlaneInfo.PlaneId;
6590 const TActorList& anActorList = aPlaneInfo.ActorList;
6591 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6595 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6599 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6601 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6602 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6603 const TPlaneData& aPlaneData = *anIter4;
6604 if( aPlaneData.Id == aPlaneId ) {
6605 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6606 aPlane->myViewWindow = aViewWindow;
6607 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6608 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6609 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6610 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6611 aPlane->X = aPlaneData.X;
6612 aPlane->Y = aPlaneData.Y;
6613 aPlane->Z = aPlaneData.Z;
6614 aPlane->Dx = aPlaneData.Dx;
6615 aPlane->Dy = aPlaneData.Dy;
6616 aPlane->Dz = aPlaneData.Dz;
6618 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6619 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6620 aPlane->myDistance = aPlaneData.Distance;
6621 aPlane->myAngle[0] = aPlaneData.Angle[0];
6622 aPlane->myAngle[1] = aPlaneData.Angle[1];
6625 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6626 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6627 aClippingPlaneInfo.Plane = aPlane;
6628 aClippingPlaneInfo.ActorList = anActorList;
6629 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6640 // update all VTK views
6641 QList<SUIT_ViewManager*> lst;
6642 getApp()->viewManagers(lst);
6643 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6644 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6645 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6646 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6647 // set OpenGL clipping planes
6648 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6649 vtkActorCollection* anAllActors = aCopy.GetActors();
6650 anAllActors->InitTraversal();
6651 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6652 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6653 anActor->SetOpenGLClippingPlane();
6655 vtkView->getRenderer()->ResetCameraClippingRange();
6662 \brief Adds preferences for dfont of VTK viewer
6664 \param pIf group identifier
6665 \param param parameter
6666 \return identifier of preferences
6668 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6670 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6672 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6675 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6676 fam.append( tr( "SMESH_FONT_COURIER" ) );
6677 fam.append( tr( "SMESH_FONT_TIMES" ) );
6679 setPreferenceProperty( tfont, "fonts", fam );
6681 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6682 if ( needSize ) f = f | QtxFontEdit::Size;
6683 setPreferenceProperty( tfont, "features", f );
6689 \brief Actions after hypothesis edition
6690 Updates object browser after hypothesis edition
6692 void SMESHGUI::onHypothesisEdit( int result )
6695 SMESHGUI::Modified();
6696 updateObjBrowser( true );
6701 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6702 \param pview view being closed
6704 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6705 #ifndef DISABLE_PLOT2DVIEWER
6706 //Crear all Plot2d Viewers if need.
6707 SMESH::ClearPlot2Viewers(pview);
6711 void SMESHGUI::message( const QString& msg )
6714 QStringList data = msg.split("/");
6715 if ( data.count() > 0 ) {
6716 if ( data.first() == "mesh_loading" ) {
6718 QString entry = data.count() > 1 ? data[1] : QString();
6719 if ( entry.isEmpty() )
6722 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6724 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6727 name = obj->GetName().c_str();
6728 if ( name.isEmpty() )
6731 if ( data.last() == "stop" )
6732 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6734 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6735 QApplication::processEvents();
6741 \brief Connects or disconnects signals about activating and cloning view on the module slots
6742 \param pview view which is connected/disconnected
6744 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6748 SUIT_ViewManager* viewMgr = pview->getViewManager();
6750 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6751 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6753 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6754 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6759 \brief Return \c true if object can be renamed
6761 bool SMESHGUI::renameAllowed( const QString& entry) const {
6762 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6766 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6770 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6775 if(appStudy->isComponent(entry) || obj->isReference())
6778 // check type to prevent renaming of inappropriate objects
6779 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6780 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6781 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6782 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6783 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6784 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6791 Rename object by entry.
6792 \param entry entry of the object
6793 \param name new name of the object
6794 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6796 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6798 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6802 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6807 _PTR(Study) aStudy = appStudy->studyDS();
6812 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6814 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6819 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6820 _PTR(GenericAttribute) anAttr;
6821 _PTR(AttributeName) aName;
6823 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6825 // check type to prevent renaming of inappropriate objects
6826 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6827 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6828 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6829 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6830 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6831 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6832 if ( !name.isEmpty() ) {
6833 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6835 // update name of group object and its actor
6836 Handle(SALOME_InteractiveObject) IObject =
6837 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6839 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6840 if( !aGroupObject->_is_nil() ) {
6841 aGroupObject->SetName( qPrintable(name) );
6842 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6843 anActor->setName( qPrintable(name) );
6853 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6855 static QList<QColor> colors;
6857 if ( colors.isEmpty() ) {
6859 for (int s = 0; s < 2 ; s++)
6861 for (int v = 100; v >= 40; v = v - 20)
6863 for (int h = 0; h < 359 ; h = h + 60)
6865 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6870 static int currentColor = 0;
6872 SALOMEDS::Color color;
6873 color.R = (double)colors[currentColor].red() / 255.0;
6874 color.G = (double)colors[currentColor].green() / 255.0;
6875 color.B = (double)colors[currentColor].blue() / 255.0;
6877 currentColor = (currentColor+1) % colors.count();