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_IDSource_ptr theMesh,
2016 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
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 SMESH::long_array_var info = theMesh->GetMeshInfo();
2027 long nbOdElems = info[SMDSEntity_0D];
2028 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2029 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2030 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2031 info[SMDSEntity_Polygon];
2032 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2033 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2034 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2035 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2036 info[SMDSEntity_Polyhedra] +
2037 info[SMDSEntity_Hexagonal_Prism];
2038 long nbBalls = info[SMDSEntity_Ball];
2040 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2041 *nbElements = requestedSize;
2043 *entities = SMESH_Actor::eAllEntity;
2046 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2048 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2050 if ( incrementalLimit ) {
2053 if ( nbOdElems > 0 ) {
2054 if ( total + nbOdElems > updateLimit ) {
2055 *entities = *entities & ~SMESH_Actor::e0DElements;
2056 *hidden = *hidden | SMESH_Actor::e0DElements;
2063 if ( nbEdges > 0 ) {
2064 if ( total + nbEdges > updateLimit ) {
2065 *entities = *entities & ~SMESH_Actor::eEdges;
2066 *hidden = *hidden | SMESH_Actor::eEdges;
2073 if ( nbFaces > 0 ) {
2074 if ( total + nbFaces > updateLimit ) {
2075 *entities = *entities & ~SMESH_Actor::eFaces;
2076 *hidden = *hidden | SMESH_Actor::eFaces;
2083 if ( nbVolumes > 0 ) {
2084 if ( total + nbVolumes > updateLimit ) {
2085 *entities = *entities & ~SMESH_Actor::eVolumes;
2086 *hidden = *hidden | SMESH_Actor::eVolumes;
2093 if ( nbBalls > 0 ) {
2094 if ( total + nbBalls > updateLimit ) {
2095 *entities = *entities & ~SMESH_Actor::eBallElem;
2096 *hidden = *hidden | SMESH_Actor::eBallElem;
2104 return autoUpdate && !exceeded;
2107 //=============================================================================
2111 //=============================================================================
2112 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2114 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2117 //=============================================================================
2121 //=============================================================================
2122 SMESHGUI* SMESHGUI::GetSMESHGUI()
2124 SMESHGUI* smeshMod = 0;
2125 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2128 CAM_Module* module = app->module( "Mesh" );
2129 smeshMod = dynamic_cast<SMESHGUI*>( module );
2132 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2134 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2137 _PTR(Study) aStudy = study->studyDS();
2139 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2148 Standard_EXPORT SMESHGUI* GetComponentGUI()
2150 return SMESHGUI::GetSMESHGUI();
2154 //=============================================================================
2158 //=============================================================================
2159 void SMESHGUI::SetState(int aState)
2164 //=============================================================================
2168 //=============================================================================
2169 void SMESHGUI::ResetState()
2174 //=============================================================================
2178 //=============================================================================
2179 void SMESHGUI::EmitSignalDeactivateDialog()
2181 emit SignalDeactivateActiveDialog();
2184 //=============================================================================
2188 //=============================================================================
2189 void SMESHGUI::EmitSignalStudyFrameChanged()
2191 emit SignalStudyFrameChanged();
2194 //=============================================================================
2198 //=============================================================================
2199 void SMESHGUI::EmitSignalCloseAllDialogs()
2201 emit SignalCloseAllDialogs();
2204 //=============================================================================
2208 //=============================================================================
2209 void SMESHGUI::EmitSignalVisibilityChanged()
2211 emit SignalVisibilityChanged();
2214 //=============================================================================
2218 //=============================================================================
2219 QDialog *SMESHGUI::GetActiveDialogBox()
2221 return myActiveDialogBox;
2224 //=============================================================================
2228 //=============================================================================
2229 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2231 myActiveDialogBox = (QDialog *) aDlg;
2235 //=============================================================================
2239 //=============================================================================
2240 SUIT_Desktop* SMESHGUI::desktop()
2242 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2244 return app->desktop();
2249 //=============================================================================
2253 //=============================================================================
2254 SalomeApp_Study* SMESHGUI::activeStudy()
2256 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2258 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2263 //=============================================================================
2267 //=============================================================================
2268 void SMESHGUI::Modified( bool theIsUpdateActions )
2270 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2271 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2272 appStudy->Modified();
2273 if( theIsUpdateActions )
2274 app->updateActions();
2279 //=============================================================================
2283 //=============================================================================
2284 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2286 /* Here the position is on the bottom right corner - 10 */
2287 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2289 SUIT_Desktop *PP = desktop();
2290 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2291 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2295 //=============================================================================
2299 //=============================================================================
2300 static int isStudyLocked(_PTR(Study) theStudy){
2301 return theStudy->GetProperties()->IsLocked();
2304 static bool checkLock(_PTR(Study) theStudy) {
2305 if (isStudyLocked(theStudy)) {
2306 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2307 QObject::tr("WRN_WARNING"),
2308 QObject::tr("WRN_STUDY_LOCKED") );
2314 //=======================================================================
2315 //function : CheckActiveStudyLocked
2317 //=======================================================================
2319 bool SMESHGUI::isActiveStudyLocked()
2321 _PTR(Study) aStudy = activeStudy()->studyDS();
2322 return checkLock( aStudy );
2325 //=============================================================================
2329 //=============================================================================
2330 bool SMESHGUI::OnGUIEvent( int theCommandID )
2332 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2336 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2337 SUIT_ResourceMgr* mgr = resourceMgr();
2341 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2342 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2345 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2346 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2348 //QAction* act = action( theCommandID );
2350 switch (theCommandID) {
2352 if(checkLock(aStudy)) break;
2364 if(checkLock(aStudy)) break;
2365 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2369 case 150: //MED FILE INFORMATION
2371 SALOME_ListIO selected;
2372 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2374 aSel->selectedObjects( selected );
2375 if( selected.Extent() )
2377 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2378 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2379 if ( !aMesh->_is_nil() )
2381 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2388 case 122: // EXPORT MED
2403 ::ExportMeshToFile(theCommandID);
2407 case 200: // SCALAR BAR
2409 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2410 SALOME_ListIO selected;
2412 aSel->selectedObjects( selected );
2414 if( selected.Extent() ) {
2415 Handle(SALOME_InteractiveObject) anIO = selected.First();
2416 if( anIO->hasEntry() ) {
2417 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2418 anActor->SetControlMode( SMESH_Actor::eNone );
2419 #ifndef DISABLE_PLOT2DVIEWER
2420 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2429 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2434 // dump control distribution data to the text file
2435 ::SaveDistribution();
2441 // show/ distribution
2442 ::ShowDistribution();
2446 #ifndef DISABLE_PLOT2DVIEWER
2449 // plot distribution
2450 ::PlotDistribution();
2461 ::DisableAutoColor();
2464 case 1134: // Clipping
2465 case 1133: // Tranparency
2466 case 1132: // Display preferences (colors, shrink size, line width, ...)
2473 ::SetDisplayMode(theCommandID, myMarkerMap);
2476 //2D quadratic representation
2479 ::SetDisplayMode(theCommandID, myMarkerMap);
2483 case 216: // 0D elements
2486 case 219: // Volumes
2487 case 220: // All Entity
2489 ::SetDisplayEntity(theCommandID);
2492 case 221: // Orientation of faces
2494 LightApp_SelectionMgr* mgr = selectionMgr();
2495 SALOME_ListIO selected; mgr->selectedObjects( selected );
2497 SALOME_ListIteratorOfListIO it(selected);
2498 for( ; it.More(); it.Next()) {
2499 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2500 if(anIObject->hasEntry()) {
2501 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2502 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2511 if(checkLock(aStudy)) break;
2512 SUIT_OverrideCursor wc;
2514 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2517 SMESH::UpdateView();
2519 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2520 SMESH::OnVisuException();
2522 catch (...) { // PAL16774 (Crash after display of many groups)
2523 SMESH::OnVisuException();
2527 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2528 aSel->selectedObjects( l );
2529 aSel->setSelectedObjects( l );
2534 case 301: // DISPLAY
2535 case 302: // DISPLAY ONLY
2537 SMESH::EDisplaing anAction;
2538 switch (theCommandID) {
2539 case 300: anAction = SMESH::eErase; break;
2540 case 301: anAction = SMESH::eDisplay; break;
2541 case 302: anAction = SMESH::eDisplayOnly; break;
2544 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2545 SALOME_ListIO sel_objects, to_process;
2547 aSel->selectedObjects( sel_objects );
2549 if( theCommandID==302 )
2551 MESSAGE("anAction = SMESH::eDisplayOnly");
2552 startOperation( myEraseAll );
2555 extractContainers( sel_objects, to_process );
2558 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2562 SALOME_ListIteratorOfListIO It( to_process );
2563 for ( ; It.More(); It.Next()) {
2565 Handle(SALOME_InteractiveObject) IOS = It.Value();
2566 if (IOS->hasEntry()) {
2568 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2569 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2570 break; // PAL16774 (Crash after display of many groups)
2572 if (anAction == SMESH::eDisplayOnly)
2574 MESSAGE("anAction = SMESH::eDisplayOnly");
2575 anAction = SMESH::eDisplay;
2581 // PAL13338 + PAL15161 -->
2582 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2583 MESSAGE("anAction = SMESH::eDisplayOnly");
2584 SMESH::UpdateView();
2585 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2587 // PAL13338 + PAL15161 <--
2589 catch (...) { // PAL16774 (Crash after display of many groups)
2590 SMESH::OnVisuException();
2593 if (anAction == SMESH::eErase) {
2594 MESSAGE("anAction == SMESH::eErase");
2596 aSel->setSelectedObjects( l1 );
2599 aSel->setSelectedObjects( to_process );
2606 if(checkLock(aStudy)) break;
2609 EmitSignalDeactivateDialog();
2611 ( new SMESHGUI_NodesDlg( this ) )->show();
2614 SUIT_MessageBox::warning(desktop(),
2615 tr("SMESH_WRN_WARNING"),
2616 tr("SMESH_WRN_VIEWER_VTK"));
2621 case 2151: // FILTER
2625 EmitSignalDeactivateDialog();
2626 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2631 case 701: // COMPUTE MESH
2632 case 711: // PRECOMPUTE MESH
2633 case 712: // EVALUATE MESH
2634 case 713: // MESH ORDER
2635 case 702: // Create mesh
2636 case 703: // Create sub-mesh
2637 case 704: // Edit mesh/sub-mesh
2638 startOperation( theCommandID );
2640 case 705: // copy mesh
2642 if (checkLock(aStudy)) break;
2643 EmitSignalDeactivateDialog();
2644 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2647 case 710: // Build compound mesh
2649 if (checkLock(aStudy)) break;
2650 EmitSignalDeactivateDialog();
2651 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2655 case 407: // DIAGONAL INVERSION
2656 case 408: // Delete diagonal
2660 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2661 tr( "NOT_A_VTK_VIEWER" ) );
2665 if ( checkLock( aStudy ) )
2668 /*Standard_Boolean aRes;
2669 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2670 if ( aMesh->_is_nil() )
2672 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2673 tr( "SMESH_BAD_SELECTION" ) );
2677 EmitSignalDeactivateDialog();
2678 if ( theCommandID == 407 )
2679 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2681 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2684 case 409: // Change orientation
2685 case 410: // Union of triangles
2686 case 411: // Cutting of quadrangles
2687 case 419: // Splitting volumes into tetrahedra
2691 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2692 tr( "NOT_A_VTK_VIEWER" ) );
2696 if ( checkLock( aStudy ) )
2699 EmitSignalDeactivateDialog();
2700 SMESHGUI_MultiEditDlg* aDlg = NULL;
2701 if ( theCommandID == 409 )
2702 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2703 else if ( theCommandID == 410 )
2704 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2705 else if ( theCommandID == 419 )
2706 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2708 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2713 case 412: // Smoothing
2715 if(checkLock(aStudy)) break;
2717 EmitSignalDeactivateDialog();
2718 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2721 SUIT_MessageBox::warning(desktop(),
2722 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2726 case 413: // Extrusion
2728 if (checkLock(aStudy)) break;
2730 EmitSignalDeactivateDialog();
2731 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2733 SUIT_MessageBox::warning(desktop(),
2734 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2738 case 414: // Revolution
2740 if(checkLock(aStudy)) break;
2742 EmitSignalDeactivateDialog();
2743 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2746 SUIT_MessageBox::warning(desktop(),
2747 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2751 case 415: // Pattern mapping
2753 if ( checkLock( aStudy ) )
2757 EmitSignalDeactivateDialog();
2758 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2761 SUIT_MessageBox::warning(desktop(),
2762 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2766 case 416: // Extrusion along a path
2768 if (checkLock(aStudy)) break;
2770 EmitSignalDeactivateDialog();
2771 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2773 SUIT_MessageBox::warning(desktop(),
2774 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2778 case 417: // Convert mesh to quadratic
2779 case 418: // create 2D mesh from 3D
2780 case 420: // Reorient faces
2781 case 806: // CREATE GEO GROUP
2783 startOperation( theCommandID );
2786 case 801: // CREATE GROUP
2790 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2791 tr( "NOT_A_VTK_VIEWER" ) );
2795 if(checkLock(aStudy)) break;
2796 EmitSignalDeactivateDialog();
2797 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2799 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2800 SALOME_ListIO selected;
2802 aSel->selectedObjects( selected );
2804 int nbSel = selected.Extent();
2806 // check if mesh is selected
2807 aMesh = SMESH::GetMeshByIO( selected.First() );
2809 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2814 case 802: // CONSTRUCT GROUP
2818 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2819 tr( "NOT_A_VTK_VIEWER" ) );
2823 if(checkLock(aStudy)) break;
2824 EmitSignalDeactivateDialog();
2826 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2827 SALOME_ListIO selected;
2829 aSel->selectedObjects( selected );
2831 int nbSel = selected.Extent();
2833 // check if submesh is selected
2834 Handle(SALOME_InteractiveObject) IObject = selected.First();
2835 if (IObject->hasEntry()) {
2836 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2838 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2839 if (!aSubMesh->_is_nil()) {
2841 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2842 // get submesh elements list by types
2843 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2844 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2845 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2846 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2847 // create group for each type o elements
2848 QString aName = IObject->getName();
2849 QStringList anEntryList;
2850 if (aNodes->length() > 0) {
2851 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2852 aGroup->Add(aNodes.inout());
2853 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2854 anEntryList.append( aSObject->GetID().c_str() );
2856 if (aEdges->length() > 0) {
2857 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2858 aGroup->Add(aEdges.inout());
2859 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2860 anEntryList.append( aSObject->GetID().c_str() );
2862 if (aFaces->length() > 0) {
2863 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2864 aGroup->Add(aFaces.inout());
2865 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2866 anEntryList.append( aSObject->GetID().c_str() );
2868 if (aVolumes->length() > 0) {
2869 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2870 aGroup->Add(aVolumes.inout());
2871 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2872 anEntryList.append( aSObject->GetID().c_str() );
2875 anApp->browseObjects( anEntryList );
2877 catch(const SALOME::SALOME_Exception & S_ex){
2878 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2885 SUIT_MessageBox::warning(desktop(),
2886 tr("SMESH_WRN_WARNING"),
2887 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2892 case 803: // EDIT GROUP
2896 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2897 tr( "NOT_A_VTK_VIEWER" ) );
2901 if(checkLock(aStudy)) break;
2902 EmitSignalDeactivateDialog();
2904 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2905 SALOME_ListIO selected;
2907 aSel->selectedObjects( selected );
2909 SALOME_ListIteratorOfListIO It (selected);
2910 int nbSelectedGroups = 0;
2911 for ( ; It.More(); It.Next() )
2913 SMESH::SMESH_GroupBase_var aGroup =
2914 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2915 if (!aGroup->_is_nil()) {
2917 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2921 if (nbSelectedGroups == 0)
2923 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2929 case 804: // Add elements to group
2931 if(checkLock(aStudy)) break;
2932 if (myState == 800) {
2933 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2934 if (aDlg) aDlg->onAdd();
2939 case 805: // Remove elements from group
2941 if(checkLock(aStudy)) break;
2942 if (myState == 800) {
2943 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2944 if (aDlg) aDlg->onRemove();
2949 case 815: // Edit GEOM GROUP as standalone
2953 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2954 tr( "NOT_A_VTK_VIEWER" ) );
2958 if(checkLock(aStudy)) break;
2959 EmitSignalDeactivateDialog();
2961 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2962 SALOME_ListIO selected;
2964 aSel->selectedObjects( selected );
2966 SALOME_ListIteratorOfListIO It (selected);
2967 for ( ; It.More(); It.Next() )
2969 SMESH::SMESH_GroupOnGeom_var aGroup =
2970 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2971 if (!aGroup->_is_nil()) {
2972 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2977 SMESH::SMESH_GroupOnFilter_var aGroup =
2978 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2979 if (!aGroup->_is_nil()) {
2980 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2988 case 810: // Union Groups
2989 case 811: // Intersect groups
2990 case 812: // Cut groups
2994 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2995 tr( "NOT_A_VTK_VIEWER" ) );
2999 if ( checkLock( aStudy ) )
3002 EmitSignalDeactivateDialog();
3004 SMESHGUI_GroupOpDlg* aDlg = 0;
3005 if ( theCommandID == 810 )
3006 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3007 else if ( theCommandID == 811 )
3008 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3010 aDlg = new SMESHGUI_CutGroupsDlg( this );
3017 case 814: // Create groups of entities from existing groups of superior dimensions
3019 if ( checkLock( aStudy ) )
3022 EmitSignalDeactivateDialog();
3023 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3029 case 813: // Delete groups with their contents
3033 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3034 tr( "NOT_A_VTK_VIEWER" ) );
3038 if ( checkLock( aStudy ) )
3041 EmitSignalDeactivateDialog();
3043 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3047 case 900: // MESH INFOS
3048 case 903: // WHAT IS
3050 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3051 EmitSignalDeactivateDialog();
3052 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3053 SALOME_ListIO selected;
3055 aSel->selectedObjects( selected );
3057 if ( selected.Extent() > 1 ) { // a dlg for each IO
3058 SALOME_ListIteratorOfListIO It( selected );
3059 for ( ; It.More(); It.Next() ) {
3060 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3061 dlg->showInfo( It.Value() );
3066 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3072 case 904: // FIND ELEM
3074 startOperation( theCommandID );
3078 case 1100: // EDIT HYPOTHESIS
3080 if(checkLock(aStudy)) break;
3082 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3083 SALOME_ListIO selected;
3085 aSel->selectedObjects( selected );
3087 int nbSel = selected.Extent();
3090 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3091 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3093 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3094 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3095 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3096 if ( !aHypothesis->_is_nil() )
3099 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3100 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3102 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3112 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3114 if(checkLock(aStudy)) break;
3115 SUIT_OverrideCursor wc;
3117 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3118 SALOME_ListIO selected;
3120 aSel->selectedObjects( selected, QString::null, false );
3122 SALOME_ListIteratorOfListIO It(selected);
3123 for (int i = 0; It.More(); It.Next(), i++) {
3124 Handle(SALOME_InteractiveObject) IObject = It.Value();
3125 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3128 aSel->setSelectedObjects( l1 );
3134 case 4009: // ELEM0D
3136 case 4021: // TRIANGLE
3138 case 4023: // POLYGON
3142 case 4134: // PYRAMID
3143 case 4135: // OCTA12
3145 if(checkLock(aStudy)) break;
3147 EmitSignalDeactivateDialog();
3148 SMDSAbs_EntityType type = SMDSEntity_Edge;
3149 switch (theCommandID) {
3150 case 4008: type = SMDSEntity_Ball; break;
3151 case 4009: type = SMDSEntity_0D; break;
3152 case 4021: type = SMDSEntity_Triangle; break;
3153 case 4022: type = SMDSEntity_Quadrangle; break;
3154 case 4031: type = SMDSEntity_Tetra; break;
3155 case 4023: type = SMDSEntity_Polygon; break;
3156 case 4032: type = SMDSEntity_Hexa; break;
3157 case 4133: type = SMDSEntity_Penta; break;
3158 case 4134: type = SMDSEntity_Pyramid; break;
3159 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3162 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3165 SUIT_MessageBox::warning(desktop(),
3166 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3170 case 4033: // POLYHEDRON
3172 if(checkLock(aStudy)) break;
3174 EmitSignalDeactivateDialog();
3175 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3178 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3179 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3183 case 4034: // QUADRATIC EDGE
3184 case 4035: // QUADRATIC TRIANGLE
3185 case 4036: // QUADRATIC QUADRANGLE
3186 case 4136: // BIQUADRATIC QUADRANGLE
3187 case 4137: // BIQUADRATIC TRIANGLE
3188 case 4037: // QUADRATIC TETRAHEDRON
3189 case 4038: // QUADRATIC PYRAMID
3190 case 4039: // QUADRATIC PENTAHEDRON
3191 case 4040: // QUADRATIC HEXAHEDRON
3192 case 4140: // TRIQUADRATIC HEXAHEDRON
3194 if(checkLock(aStudy)) break;
3196 EmitSignalDeactivateDialog();
3197 SMDSAbs_EntityType type = SMDSEntity_Last;
3199 switch (theCommandID) {
3200 case 4034: type = SMDSEntity_Quad_Edge; break;
3201 case 4035: type = SMDSEntity_Quad_Triangle; break;
3202 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3203 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3204 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3205 case 4037: type = SMDSEntity_Quad_Tetra; break;
3206 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3207 case 4039: type = SMDSEntity_Quad_Penta; break;
3208 case 4040: type = SMDSEntity_Quad_Hexa; break;
3209 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3212 if ( type != SMDSEntity_Last )
3213 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3216 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3217 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3221 case 4041: // REMOVES NODES
3223 if(checkLock(aStudy)) break;
3225 EmitSignalDeactivateDialog();
3226 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3229 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3230 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3234 case 4042: // REMOVES ELEMENTS
3236 if(checkLock(aStudy)) break;
3238 EmitSignalDeactivateDialog();
3239 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3243 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3244 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3248 case 4043: { // CLEAR_MESH
3250 if(checkLock(aStudy)) break;
3252 SALOME_ListIO selected;
3253 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3254 aSel->selectedObjects( selected );
3256 SUIT_OverrideCursor wc;
3257 SALOME_ListIteratorOfListIO It (selected);
3258 for ( ; It.More(); It.Next() )
3260 Handle(SALOME_InteractiveObject) IOS = It.Value();
3261 SMESH::SMESH_Mesh_var aMesh =
3262 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3263 if ( aMesh->_is_nil()) continue;
3265 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3267 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3268 SMESH::ModifiedMesh( aMeshSObj, false, true);
3269 // hide groups and submeshes
3270 _PTR(ChildIterator) anIter =
3271 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3272 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3274 _PTR(SObject) so = anIter->Value();
3275 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3278 catch (const SALOME::SALOME_Exception& S_ex){
3280 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3284 SMESH::UpdateView();
3288 case 4044: // REMOVE ORPHAN NODES
3290 if(checkLock(aStudy)) break;
3291 SALOME_ListIO selected;
3292 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3293 aSel->selectedObjects( selected );
3294 if ( selected.Extent() == 1 ) {
3295 Handle(SALOME_InteractiveObject) anIO = selected.First();
3296 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3297 if ( !aMesh->_is_nil() ) {
3298 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3299 tr( "SMESH_WARNING" ),
3300 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3301 SUIT_MessageBox::Yes |
3302 SUIT_MessageBox::No,
3303 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3306 SUIT_OverrideCursor wc;
3307 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3308 int removed = aMeshEditor->RemoveOrphanNodes();
3309 SUIT_MessageBox::information(SMESHGUI::desktop(),
3310 tr("SMESH_INFORMATION"),
3311 tr("NB_NODES_REMOVED").arg(removed));
3312 if ( removed > 0 ) {
3313 SMESH::UpdateView();
3314 SMESHGUI::Modified();
3317 catch (const SALOME::SALOME_Exception& S_ex) {
3318 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3327 case 4051: // RENUMBERING NODES
3329 if(checkLock(aStudy)) break;
3331 EmitSignalDeactivateDialog();
3332 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3336 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3337 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3341 case 4052: // RENUMBERING ELEMENTS
3343 if(checkLock(aStudy)) break;
3345 EmitSignalDeactivateDialog();
3346 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3350 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3351 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3355 case 4061: // TRANSLATION
3357 if(checkLock(aStudy)) break;
3359 EmitSignalDeactivateDialog();
3360 ( new SMESHGUI_TranslationDlg( this ) )->show();
3363 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3364 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3368 case 4062: // ROTATION
3370 if(checkLock(aStudy)) break;
3372 EmitSignalDeactivateDialog();
3373 ( new SMESHGUI_RotationDlg( this ) )->show();
3376 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3377 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3381 case 4063: // SYMMETRY
3383 if(checkLock(aStudy)) break;
3385 EmitSignalDeactivateDialog();
3386 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3389 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3390 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3394 case 4064: // SEWING
3396 if(checkLock(aStudy)) break;
3398 EmitSignalDeactivateDialog();
3399 ( new SMESHGUI_SewingDlg( this ) )->show();
3402 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3403 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3407 case 4065: // MERGE NODES
3409 if(checkLock(aStudy)) break;
3411 EmitSignalDeactivateDialog();
3412 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3415 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3416 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3420 case 4066: // MERGE EQUAL ELEMENTS
3422 if (checkLock(aStudy)) break;
3424 EmitSignalDeactivateDialog();
3425 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3427 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3428 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3433 case 4067: // MAKE MESH PASS THROUGH POINT
3434 startOperation( 4067 );
3439 if(checkLock(aStudy)) break;
3441 EmitSignalDeactivateDialog();
3442 ( new SMESHGUI_ScaleDlg( this ) )->show();
3445 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3446 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3451 case 4069: // DUPLICATE NODES
3453 if(checkLock(aStudy)) break;
3455 EmitSignalDeactivateDialog();
3456 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3459 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3460 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3465 case 4070: // 0D_ON_ALL_NODES
3466 startOperation( 4070 );
3469 case 5105: // Library of selection filters
3471 static QList<int> aTypes;
3472 if ( aTypes.isEmpty() )
3474 aTypes.append( SMESH::NODE );
3475 aTypes.append( SMESH::EDGE );
3476 aTypes.append( SMESH::FACE );
3477 aTypes.append( SMESH::VOLUME );
3479 if (!myFilterLibraryDlg)
3480 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3481 else if (myFilterLibraryDlg->isHidden())
3482 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3483 myFilterLibraryDlg->raise();
3487 case 6017: // CONTROLS
3515 LightApp_SelectionMgr* mgr = selectionMgr();
3516 SALOME_ListIO selected; mgr->selectedObjects( selected );
3518 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3519 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3521 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3522 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3523 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3524 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3525 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3526 SUIT_OverrideCursor wc;
3527 ::Control( theCommandID );
3532 SUIT_MessageBox::warning(desktop(),
3533 tr( "SMESH_WRN_WARNING" ),
3534 tr( "SMESH_BAD_SELECTION" ) );
3538 SUIT_MessageBox::warning(desktop(),
3539 tr( "SMESH_WRN_WARNING" ),
3540 tr( "NOT_A_VTK_VIEWER" ) );
3544 OverallMeshQuality();
3548 SUIT_OverrideCursor wc;
3549 LightApp_SelectionMgr* mgr = selectionMgr();
3550 SALOME_ListIO selected; mgr->selectedObjects( selected );
3552 SALOME_ListIteratorOfListIO it(selected);
3553 for( ; it.More(); it.Next()) {
3554 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3555 if(anIObject->hasEntry()) {
3556 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3557 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3565 SUIT_OverrideCursor wc;
3566 LightApp_SelectionMgr* mgr = selectionMgr();
3567 SALOME_ListIO selected; mgr->selectedObjects( selected );
3569 SALOME_ListIteratorOfListIO it(selected);
3570 for( ; it.More(); it.Next()) {
3571 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3572 if(anIObject->hasEntry())
3573 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3574 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3585 int page = SMESHGUI_MeasureDlg::MinDistance;
3586 if ( theCommandID == 502 )
3587 page = SMESHGUI_MeasureDlg::BoundingBox;
3588 else if ( theCommandID == 503 )
3589 page = SMESHGUI_MeasureDlg::Length;
3590 else if ( theCommandID == 504 )
3591 page = SMESHGUI_MeasureDlg::Area;
3592 else if ( theCommandID == 505 )
3593 page = SMESHGUI_MeasureDlg::Volume;
3595 EmitSignalDeactivateDialog();
3596 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3606 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3607 //updateObjBrowser();
3611 //=============================================================================
3615 //=============================================================================
3616 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3621 //=============================================================================
3625 //=============================================================================
3626 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3631 //=============================================================================
3635 //=============================================================================
3636 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3641 //=============================================================================
3642 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3643 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3645 //=============================================================================
3646 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3647 SUIT_ViewWindow* wnd )
3649 if(theIO->hasEntry()){
3650 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3651 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3655 //=======================================================================
3656 // function : createSMESHAction
3658 //=======================================================================
3659 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3660 const int key, const bool toggle, const QString& shortcutAction )
3663 QWidget* parent = application()->desktop();
3664 SUIT_ResourceMgr* resMgr = resourceMgr();
3666 if ( !icon_id.isEmpty() )
3667 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3669 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3670 if ( !pix.isNull() )
3671 icon = QIcon( pix );
3673 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3674 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3675 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3677 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3678 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3681 //=======================================================================
3682 // function : createPopupItem
3684 //=======================================================================
3685 void SMESHGUI::createPopupItem( const int id,
3686 const QString& clients,
3687 const QString& types,
3688 const QString& theRule,
3691 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3692 popupMgr()->insert( action( id ), pId, 0 );
3694 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3695 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3696 QString rule = "(%1) and (%2) and (%3)";
3697 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3698 if( clients.isEmpty() )
3699 rule = rule.arg( QString( "true" ) );
3701 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3702 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3705 bool cont = myRules.contains( id );
3707 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3709 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3710 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3713 //=======================================================================
3714 // function : initialize
3716 //=======================================================================
3717 void SMESHGUI::initialize( CAM_Application* app )
3719 SalomeApp_Module::initialize( app );
3721 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3723 /* Automatic Update flag */
3724 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3726 // ----- create actions --------------
3728 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3729 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3730 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3731 createSMESHAction( 114, "NUM" );
3732 createSMESHAction( 115, "IMPORT_STL" );
3733 createSMESHAction( 116, "IMPORT_CGNS" );
3734 createSMESHAction( 117, "IMPORT_SAUV" );
3735 createSMESHAction( 118, "IMPORT_GMF" );
3736 createSMESHAction( 121, "DAT" );
3737 createSMESHAction( 122, "MED" );
3738 createSMESHAction( 123, "UNV" );
3739 createSMESHAction( 140, "STL" );
3740 createSMESHAction( 142, "CGNS");
3741 createSMESHAction( 144, "SAUV");
3742 createSMESHAction( 146, "GMF" );
3743 createSMESHAction( 124, "DAT" );
3744 createSMESHAction( 125, "MED" );
3745 createSMESHAction( 126, "UNV" );
3746 createSMESHAction( 141, "STL" );
3747 createSMESHAction( 143, "CGNS");
3748 createSMESHAction( 145, "SAUV");
3749 createSMESHAction( 147, "GMF" );
3750 createSMESHAction( 150, "FILE_INFO" );
3751 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3752 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3753 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3754 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3755 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3756 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3757 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3758 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3759 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3760 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3761 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3762 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3763 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3764 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3765 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3766 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3767 createSMESHAction( 804, "ADD" );
3768 createSMESHAction( 805, "REMOVE" );
3769 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3770 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3771 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3772 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3773 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3774 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3775 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3776 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3777 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3778 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3779 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3780 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3781 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3782 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3783 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3784 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3785 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3786 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3787 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3788 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3789 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3790 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3791 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3792 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3793 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3794 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3795 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3796 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3797 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3798 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3799 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3800 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3801 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3802 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3803 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3804 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3805 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3806 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3807 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3808 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3809 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3810 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3811 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3812 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3813 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3814 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3815 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3816 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3817 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3818 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3819 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3820 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3821 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3822 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3823 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3824 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3825 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3826 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3827 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3828 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3829 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3830 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3831 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3832 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3833 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3834 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3835 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3836 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3837 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3838 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3839 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3840 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3841 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3842 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3843 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3844 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3845 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3846 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3847 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3848 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3849 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3850 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3851 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3852 createSMESHAction( 415, "MAP", "ICON_MAP" );
3853 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3854 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3855 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3856 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3857 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3858 createSMESHAction( 200, "RESET" );
3859 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3860 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3861 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3862 #ifndef DISABLE_PLOT2DVIEWER
3863 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3865 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3866 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3867 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3868 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3869 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3870 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3871 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3872 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3873 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3874 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3875 createSMESHAction( 220, "ALL" );
3876 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3878 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3879 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3881 createSMESHAction( 1100, "EDIT_HYPO" );
3882 createSMESHAction( 1102, "UNASSIGN" );
3883 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3884 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3885 createSMESHAction( 1131, "DISPMODE" );
3886 createSMESHAction( 1132, "COLORS" );
3887 createSMESHAction( 1133, "TRANSP" );
3888 createSMESHAction( 1134, "CLIP" );
3889 createSMESHAction( 1135, "DISP_ENT" );
3890 createSMESHAction( 1136, "AUTO_COLOR" );
3891 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3892 createSMESHAction( 2000, "CTRL" );
3894 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3895 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3896 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3897 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3898 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3900 createSMESHAction( 300, "HIDE" );
3901 createSMESHAction( 301, "SHOW" );
3902 createSMESHAction( 302, "DISPLAY_ONLY" );
3904 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3906 // ----- create menu --------------
3907 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3908 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3909 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3910 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3911 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3912 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3913 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3914 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3916 createMenu( separator(), fileId );
3918 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3919 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3920 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3921 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3922 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3923 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3924 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3925 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3926 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3927 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3928 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3930 //createMenu( 111, importId, -1 );
3931 createMenu( 112, importId, -1 );
3932 createMenu( 113, importId, -1 );
3933 createMenu( 115, importId, -1 );
3935 createMenu( 116, importId, -1 );
3937 createMenu( 117, importId, -1 );
3938 createMenu( 118, importId, -1 );
3939 createMenu( 121, exportId, -1 );
3940 createMenu( 122, exportId, -1 );
3941 createMenu( 123, exportId, -1 );
3942 createMenu( 140, exportId, -1 ); // export to STL
3944 createMenu( 142, exportId, -1 ); // export to CGNS
3946 createMenu( 144, exportId, -1 ); // export to SAUV
3947 createMenu( 146, exportId, -1 ); // export to GMF
3948 createMenu( separator(), fileId, 10 );
3950 createMenu( 33, editId, -1 );
3952 createMenu( 5105, toolsId, -1 );
3954 createMenu( 702, meshId, -1 ); // "Mesh" menu
3955 createMenu( 703, meshId, -1 );
3956 createMenu( 704, meshId, -1 );
3957 createMenu( 710, meshId, -1 );
3958 createMenu( 705, meshId, -1 );
3959 createMenu( separator(), meshId, -1 );
3960 createMenu( 701, meshId, -1 );
3961 createMenu( 711, meshId, -1 );
3962 createMenu( 712, meshId, -1 );
3963 createMenu( 713, meshId, -1 );
3964 createMenu( separator(), meshId, -1 );
3965 createMenu( 801, meshId, -1 );
3966 createMenu( 806, meshId, -1 );
3967 createMenu( 802, meshId, -1 );
3968 createMenu( 803, meshId, -1 );
3969 createMenu( 815, meshId, -1 );
3970 createMenu( separator(), meshId, -1 );
3971 createMenu( 810, meshId, -1 );
3972 createMenu( 811, meshId, -1 );
3973 createMenu( 812, meshId, -1 );
3974 createMenu( separator(), meshId, -1 );
3975 createMenu( 814, meshId, -1 );
3976 createMenu( separator(), meshId, -1 );
3977 createMenu( 900, meshId, -1 );
3978 //createMenu( 902, meshId, -1 );
3979 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3980 createMenu( 904, meshId, -1 );
3981 createMenu( separator(), meshId, -1 );
3983 createMenu( 6005, nodeId, -1 );
3984 createMenu( 6028, nodeId, -1 );
3985 createMenu( 6002, edgeId, -1 );
3986 createMenu( 6003, edgeId, -1 );
3987 createMenu( 6001, edgeId, -1 );
3988 createMenu( 6004, edgeId, -1 );
3989 createMenu( 6029, edgeId, -1 );
3990 createMenu( 6021, faceId, -1 );
3991 createMenu( 6025, faceId, -1 );
3992 createMenu( 6027, faceId, -1 );
3993 createMenu( 6018, faceId, -1 );
3994 createMenu( 6019, faceId, -1 );
3995 createMenu( 6011, faceId, -1 );
3996 createMenu( 6012, faceId, -1 );
3997 createMenu( 6013, faceId, -1 );
3998 createMenu( 6014, faceId, -1 );
3999 createMenu( 6015, faceId, -1 );
4000 createMenu( 6016, faceId, -1 );
4001 createMenu( 6022, faceId, -1 );
4002 createMenu( 6030, faceId, -1 );
4003 createMenu( 6017, volumeId, -1 );
4004 createMenu( 6009, volumeId, -1 );
4005 createMenu( 6023, volumeId, -1 );
4006 createMenu( 6024, volumeId, -1 );
4007 createMenu( 6026, volumeId, -1 );
4008 createMenu( 6031, volumeId, -1 );
4009 createMenu( separator(), ctrlId, -1 );
4010 createMenu( 6032, ctrlId, -1 );
4012 createMenu( 4000, addId, -1 );
4013 createMenu( 4009, addId, -1 );
4014 createMenu( 4070, addId, -1 );
4015 createMenu( 4008, addId, -1 );
4016 createMenu( 4010, addId, -1 );
4017 createMenu( 4021, addId, -1 );
4018 createMenu( 4022, addId, -1 );
4019 createMenu( 4023, addId, -1 );
4020 createMenu( 4031, addId, -1 );
4021 createMenu( 4032, addId, -1 );
4022 createMenu( 4133, addId, -1 );
4023 createMenu( 4134, addId, -1 );
4024 createMenu( 4135, addId, -1 );
4025 createMenu( 4033, addId, -1 );
4026 createMenu( separator(), addId, -1 );
4027 createMenu( 4034, addId, -1 );
4028 createMenu( 4035, addId, -1 );
4029 createMenu( 4137, addId, -1 );
4030 createMenu( 4036, addId, -1 );
4031 createMenu( 4136, addId, -1 );
4032 createMenu( 4037, addId, -1 );
4033 createMenu( 4038, addId, -1 );
4034 createMenu( 4039, addId, -1 );
4035 createMenu( 4040, addId, -1 );
4036 createMenu( 4140, addId, -1 );
4038 createMenu( 4041, removeId, -1 );
4039 createMenu( 4042, removeId, -1 );
4040 createMenu( 4044, removeId, -1 );
4041 createMenu( separator(), removeId, -1 );
4042 createMenu( 813, removeId, -1 );
4043 createMenu( separator(), removeId, -1 );
4044 createMenu( 4043, removeId, -1 );
4046 createMenu( 4051, renumId, -1 );
4047 createMenu( 4052, renumId, -1 );
4049 createMenu( 4061, transfId, -1 );
4050 createMenu( 4062, transfId, -1 );
4051 createMenu( 4063, transfId, -1 );
4052 createMenu( 4068, transfId, -1 );
4053 createMenu( 4064, transfId, -1 );
4054 createMenu( 4065, transfId, -1 );
4055 createMenu( 4066, transfId, -1 );
4056 createMenu( 4069, transfId, -1 );
4058 createMenu( 4067,modifyId, -1 );
4059 createMenu( 407, modifyId, -1 );
4060 createMenu( 408, modifyId, -1 );
4061 createMenu( 409, modifyId, -1 );
4062 createMenu( 420, modifyId, -1 );
4063 createMenu( 410, modifyId, -1 );
4064 createMenu( 411, modifyId, -1 );
4065 createMenu( 419, modifyId, -1 );
4066 createMenu( 412, modifyId, -1 );
4067 createMenu( 413, modifyId, -1 );
4068 createMenu( 416, modifyId, -1 );
4069 createMenu( 414, modifyId, -1 );
4070 createMenu( 415, modifyId, -1 );
4071 createMenu( 417, modifyId, -1 );
4072 createMenu( 418, modifyId, -1 );
4074 createMenu( 501, measureId, -1 );
4075 createMenu( 502, measureId, -1 );
4076 createMenu( 503, basicPropId, -1 );
4077 createMenu( 504, basicPropId, -1 );
4078 createMenu( 505, basicPropId, -1 );
4079 createMenu( 214, viewId, -1 );
4081 // ----- create toolbars --------------
4082 int meshTb = createTool( tr( "TB_MESH" ) ),
4083 info = createTool( tr( "TB_INFO" ) ),
4084 groupTb = createTool( tr( "TB_GROUP" ) ),
4085 ctrl0dTb = createTool( tr( "TB_CTRL0D" ) ),
4086 ctrl1dTb = createTool( tr( "TB_CTRL1D" ) ),
4087 ctrl2dTb = createTool( tr( "TB_CTRL2D" ) ),
4088 ctrl3dTb = createTool( tr( "TB_CTRL3D" ) ),
4089 addElemTb = createTool( tr( "TB_ADD" ) ),
4090 addNonElemTb = createTool( tr( "TB_ADDNON" ) ),
4091 remTb = createTool( tr( "TB_REM" ) ),
4092 renumbTb = createTool( tr( "TB_RENUMBER" ) ),
4093 transformTb = createTool( tr( "TB_TRANSFORM" ) ),
4094 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4095 measuremTb = createTool( tr( "TB_MEASUREM" ) ),
4096 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4098 createTool( 702, meshTb );
4099 createTool( 703, meshTb );
4100 createTool( 704, meshTb );
4101 createTool( 710, meshTb );
4102 createTool( 705, meshTb );
4103 createTool( separator(), meshTb );
4104 createTool( 701, meshTb );
4105 createTool( 711, meshTb );
4106 createTool( 712, meshTb );
4107 createTool( 713, meshTb );
4109 createTool( 801, groupTb );
4110 createTool( 806, groupTb );
4111 createTool( 802, groupTb );
4112 createTool( 803, groupTb );
4114 createTool( 900, info );
4115 //createTool( 902, meshTb );
4116 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4117 createTool( 904, info );
4119 createTool( 6005, ctrl0dTb );
4120 createTool( 6028, ctrl0dTb );
4122 createTool( 6002, ctrl1dTb );
4123 createTool( 6003, ctrl1dTb );
4124 createTool( 6001, ctrl1dTb );
4125 createTool( 6004, ctrl1dTb );
4126 createTool( 6029, ctrl1dTb );
4128 createTool( 6021, ctrl2dTb );
4129 createTool( 6025, ctrl2dTb );
4130 createTool( 6027, ctrl2dTb );
4131 createTool( 6018, ctrl2dTb );
4132 createTool( 6019, ctrl2dTb );
4133 createTool( 6011, ctrl2dTb );
4134 createTool( 6012, ctrl2dTb );
4135 createTool( 6013, ctrl2dTb );
4136 createTool( 6014, ctrl2dTb );
4137 createTool( 6015, ctrl2dTb );
4138 createTool( 6016, ctrl2dTb );
4139 createTool( 6022, ctrl2dTb );
4140 createTool( 6030, ctrl2dTb );
4142 createTool( 6017, ctrl3dTb );
4143 createTool( 6009, ctrl3dTb );
4144 createTool( 6023, ctrl3dTb );
4145 createTool( 6024, ctrl3dTb );
4146 createTool( 6026, ctrl3dTb );
4147 createTool( 6031, ctrl3dTb );
4149 createTool( 4000, addElemTb );
4150 createTool( 4009, addElemTb );
4151 createTool( 4070, addElemTb );
4152 createTool( 4008, addElemTb );
4153 createTool( 4010, addElemTb );
4154 createTool( 4021, addElemTb );
4155 createTool( 4022, addElemTb );
4156 createTool( 4023, addElemTb );
4157 createTool( 4031, addElemTb );
4158 createTool( 4032, addElemTb );
4159 createTool( 4133, addElemTb );
4160 createTool( 4134, addElemTb );
4161 createTool( 4135, addElemTb );
4162 createTool( 4033, addElemTb );
4164 createTool( 4034, addNonElemTb );
4165 createTool( 4035, addNonElemTb );
4166 createTool( 4137, addNonElemTb );
4167 createTool( 4036, addNonElemTb );
4168 createTool( 4136, addNonElemTb );
4169 createTool( 4037, addNonElemTb );
4170 createTool( 4038, addNonElemTb );
4171 createTool( 4039, addNonElemTb );
4172 createTool( 4040, addNonElemTb );
4173 createTool( 4140, addNonElemTb );
4175 createTool( 4041, remTb );
4176 createTool( 4042, remTb );
4177 createTool( 4044, remTb );
4178 createTool( 4043, remTb );
4180 createTool( 4051, renumbTb );
4181 createTool( 4052, renumbTb );
4184 createTool( 4061, transformTb );
4185 createTool( 4062, transformTb );
4186 createTool( 4063, transformTb );
4187 createTool( 4068, transformTb );
4188 createTool( 4064, transformTb );
4189 createTool( 4065, transformTb );
4190 createTool( 4066, transformTb );
4191 createTool( 4069, transformTb );
4193 createTool( 4067,modifyTb );
4194 createTool( 407, modifyTb );
4195 createTool( 408, modifyTb );
4196 createTool( 409, modifyTb );
4197 createTool( 420, modifyTb );
4198 createTool( 410, modifyTb );
4199 createTool( 411, modifyTb );
4200 createTool( 419, modifyTb );
4201 createTool( 412, modifyTb );
4202 createTool( 413, modifyTb );
4203 createTool( 416, modifyTb );
4204 createTool( 414, modifyTb );
4205 createTool( 415, modifyTb );
4206 createTool( 417, modifyTb );
4207 createTool( 418, modifyTb );
4209 createTool( 501, measuremTb );
4211 createTool( 214, dispModeTb );
4213 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4214 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4217 QString OB = "'ObjectBrowser'",
4218 View = "'" + SVTK_Viewer::Type() + "'",
4220 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4221 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4222 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4223 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4224 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4225 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4226 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4227 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4228 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4229 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4230 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4232 mesh_part = mesh + " " + subMesh + " " + group,
4233 mesh_group = mesh + " " + group,
4234 hyp_alg = hypo + " " + algo;
4236 // popup for object browser
4238 isInvisible("not( isVisible )"),
4239 isEmpty("numberOfNodes = 0"),
4240 isNotEmpty("numberOfNodes <> 0"),
4242 // has nodes, edges, etc in VISIBLE! actor
4243 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4244 hasElems("(count( elemTypes ) > 0)"),
4245 hasDifferentElems("(count( elemTypes ) > 1)"),
4246 hasBalls("({'BallElem'} in elemTypes)"),
4247 hasElems0d("({'Elem0d'} in elemTypes)"),
4248 hasEdges("({'Edge'} in elemTypes)"),
4249 hasFaces("({'Face'} in elemTypes)"),
4250 hasVolumes("({'Volume'} in elemTypes)");
4252 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4253 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4254 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4255 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4256 createPopupItem( 803, OB, group ); // EDIT_GROUP
4257 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4259 popupMgr()->insert( separator(), -1, 0 );
4260 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4261 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4262 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4263 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4264 createPopupItem( 214, OB, mesh_part ); // UPDATE
4265 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4266 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4267 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4268 popupMgr()->insert( separator(), -1, 0 );
4269 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4270 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4271 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4272 popupMgr()->insert( separator(), -1, 0 );
4273 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4274 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4275 popupMgr()->insert( separator(), -1, 0 );
4276 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4277 popupMgr()->insert( separator(), -1, 0 );
4278 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4279 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4281 popupMgr()->insert( separator(), -1, 0 );
4283 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4284 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4285 QString only_one_2D = only_one_non_empty + " && dim>1";
4287 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4288 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4289 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4290 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4292 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4294 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4295 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4296 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4297 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4298 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4299 popupMgr()->insert( separator(), -1, 0 );
4302 createPopupItem( 803, View, group ); // EDIT_GROUP
4303 createPopupItem( 804, View, elems ); // ADD
4304 createPopupItem( 805, View, elems ); // REMOVE
4306 popupMgr()->insert( separator(), -1, 0 );
4307 createPopupItem( 214, View, mesh_part ); // UPDATE
4308 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4309 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4310 createPopupItem( 904, View, mesh ); // FIND_ELEM
4311 popupMgr()->insert( separator(), -1, 0 );
4313 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4314 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4315 popupMgr()->insert( separator(), -1, 0 );
4317 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4318 QString aType = QString( "%1type in {%2}" ).arg( lc );
4319 aType = aType.arg( mesh_part );
4320 QString aMeshInVTK = aClient + "&&" + aType;
4322 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4323 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4324 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4326 //-------------------------------------------------
4328 //-------------------------------------------------
4329 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4331 popupMgr()->insert( action( 9010 ), anId, -1 );
4332 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4333 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4335 popupMgr()->insert( action( 9011 ), anId, -1 );
4336 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4337 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4339 popupMgr()->insert( separator(), -1, -1 );
4341 //-------------------------------------------------
4343 //-------------------------------------------------
4344 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4346 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4347 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4348 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4350 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4351 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4352 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4354 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4355 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4356 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4358 popupMgr()->insert( separator(), anId, -1 );
4360 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4361 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4362 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4364 //-------------------------------------------------
4366 //-------------------------------------------------
4367 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4369 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4371 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4372 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4373 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4375 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4376 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4377 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4379 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4380 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4381 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4383 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4384 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4385 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4387 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4388 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4389 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4391 popupMgr()->insert( separator(), anId, -1 );
4393 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4394 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4397 //-------------------------------------------------
4398 // Representation of the 2D Quadratic elements
4399 //-------------------------------------------------
4400 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4401 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4402 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4403 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4405 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4406 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4407 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4409 //-------------------------------------------------
4410 // Orientation of faces
4411 //-------------------------------------------------
4412 popupMgr()->insert( action( 221 ), -1, -1 );
4413 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4414 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4416 //-------------------------------------------------
4418 //-------------------------------------------------
4419 popupMgr()->insert( action( 1132 ), -1, -1 );
4420 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4422 //-------------------------------------------------
4424 //-------------------------------------------------
4425 popupMgr()->insert( action( 1133 ), -1, -1 );
4426 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4428 //-------------------------------------------------
4430 //-------------------------------------------------
4432 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4433 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4434 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4435 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4437 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4439 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4440 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4442 popupMgr()->insert( separator(), anId, -1 );
4444 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4446 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4447 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4448 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4450 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4451 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4452 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4454 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4456 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4457 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4458 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4460 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4461 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4462 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4464 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4465 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4466 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4468 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4469 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4470 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4471 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4472 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4473 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4475 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4477 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4478 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4479 QtxPopupMgr::VisibleRule );
4480 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4482 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4483 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4484 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4486 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4487 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4488 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4490 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4491 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4492 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4494 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4495 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4496 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4498 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4499 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4500 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4502 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4503 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4504 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4506 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4507 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4508 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4510 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4511 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4512 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4514 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4515 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4516 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4518 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4519 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4520 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4522 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4523 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4524 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4525 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4526 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4527 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4529 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4531 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4532 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4533 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4535 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4536 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4537 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4539 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4540 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4541 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4543 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4544 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4545 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4547 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4548 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4549 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4551 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4552 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4553 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4555 popupMgr()->insert( separator(), anId, -1 );
4557 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4558 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4560 popupMgr()->insert( separator(), anId, -1 );
4562 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4564 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4565 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4567 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4568 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4569 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4571 #ifndef DISABLE_PLOT2DVIEWER
4572 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4573 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4576 //-------------------------------------------------
4578 //-------------------------------------------------
4579 popupMgr()->insert( separator(), -1, -1 );
4580 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4581 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4582 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4583 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4585 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4586 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4588 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4589 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4591 popupMgr()->insert( separator(), -1, -1 );
4593 //-------------------------------------------------
4595 //-------------------------------------------------
4596 popupMgr()->insert( action( 1134 ), -1, -1 );
4597 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4599 popupMgr()->insert( separator(), -1, -1 );
4601 popupMgr()->insert( action( 41 ), -1, -1 );
4602 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4603 popupMgr()->insert( separator(), -1, -1 );
4605 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4606 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4608 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4609 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4612 //================================================================================
4614 * \brief Return true if SMESH or GEOM objects are selected.
4615 * Is called form LightApp_Module::activateModule() which clear selection if
4616 * not isSelectionCompatible()
4618 //================================================================================
4620 bool SMESHGUI::isSelectionCompatible()
4622 bool isCompatible = true;
4623 SALOME_ListIO selected;
4624 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4625 Sel->selectedObjects( selected );
4627 SALOME_ListIteratorOfListIO It( selected );
4628 for ( ; isCompatible && It.More(); It.Next())
4630 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4631 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4633 return isCompatible;
4637 bool SMESHGUI::reusableOperation( const int id )
4639 // compute, evaluate and precompute are not reusable operations
4640 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4643 bool SMESHGUI::activateModule( SUIT_Study* study )
4645 bool res = SalomeApp_Module::activateModule( study );
4647 setMenuShown( true );
4648 setToolShown( true );
4650 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4651 PyGILState_STATE gstate = PyGILState_Ensure();
4652 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4653 if ( !pluginsmanager ) {
4657 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4661 PyGILState_Release(gstate);
4662 // end of SMESH plugins loading
4664 // Reset actions accelerator keys
4665 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4666 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4667 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4669 action( 33)->setEnabled(true); // Delete: Key_Delete
4671 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4672 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4673 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4674 if ( _PTR(Study) aStudy = s->studyDS()) {
4675 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4676 updateObjBrowser(); // objects can be removed
4679 // get all view currently opened in the study and connect their signals to
4680 // the corresponding slots of the class.
4681 SUIT_Desktop* aDesk = study->application()->desktop();
4683 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4684 SUIT_ViewWindow* wnd;
4685 foreach ( wnd, wndList )
4692 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4694 setMenuShown( false );
4695 setToolShown( false );
4697 EmitSignalCloseAllDialogs();
4699 // Unset actions accelerator keys
4700 //action(111)->setShortcut(QKeySequence()); // Import DAT
4701 action(112)->setShortcut(QKeySequence()); // Import UNV
4702 action(113)->setShortcut(QKeySequence()); // Import MED
4704 action( 33)->setEnabled(false); // Delete: Key_Delete
4706 return SalomeApp_Module::deactivateModule( study );
4709 void SMESHGUI::studyClosed( SUIT_Study* s )
4711 SMESH::RemoveVisuData( s->id() );
4712 SalomeApp_Module::studyClosed( s );
4715 void SMESHGUI::OnGUIEvent()
4717 const QObject* obj = sender();
4718 if ( !obj || !obj->inherits( "QAction" ) )
4720 int id = actionId((QAction*)obj);
4725 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4727 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4728 if ( CORBA::is_nil( myComponentSMESH ) )
4730 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4732 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4733 return aGUI.myComponentSMESH;
4736 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4737 return myComponentSMESH;
4740 QString SMESHGUI::engineIOR() const
4742 CORBA::ORB_var anORB = getApp()->orb();
4743 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4744 return QString( anIOR.in() );
4747 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4749 SalomeApp_Module::contextMenuPopup( client, menu, title );
4751 selectionMgr()->selectedObjects( lst );
4752 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4753 Handle(SALOME_InteractiveObject) io = lst.First();
4754 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4755 _PTR(Study) study = appStudy->studyDS();
4756 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4758 QString aName = QString( QString::fromUtf8(obj->GetName().c_str()) );
4759 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4760 aName.remove( (aName.length() - 1), 1 );
4766 LightApp_Selection* SMESHGUI::createSelection() const
4768 return new SMESHGUI_Selection();
4771 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4773 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4774 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4775 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4778 void SMESHGUI::viewManagers( QStringList& list ) const
4780 list.append( SVTK_Viewer::Type() );
4783 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4785 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4786 SMESH::UpdateSelectionProp( this );
4788 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4789 for(int i = 0; i < aViews.count() ; i++){
4790 SUIT_ViewWindow *sf = aViews[i];
4796 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4798 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4799 myClippingPlaneInfoMap.erase( theViewManager );
4802 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4804 theActor->AddObserver( SMESH::DeleteActorEvent,
4805 myEventCallbackCommand.GetPointer(),
4809 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4810 unsigned long theEvent,
4811 void* theClientData,
4814 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4815 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4816 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4817 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4818 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4819 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4820 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4821 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4822 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4823 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4824 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4825 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4826 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4827 if( anActor == *anIter3 ) {
4828 anActorList.erase( anIter3 );
4839 void SMESHGUI::createPreferences()
4841 // General tab ------------------------------------------------------------------------
4842 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4844 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4845 setPreferenceProperty( autoUpdate, "columns", 2 );
4846 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4847 setPreferenceProperty( lim, "min", 0 );
4848 setPreferenceProperty( lim, "max", 100000000 );
4849 setPreferenceProperty( lim, "step", 1000 );
4850 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4851 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4853 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4854 setPreferenceProperty( qaGroup, "columns", 2 );
4855 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4856 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4857 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4858 setPreferenceProperty( prec, "min", 0 );
4859 setPreferenceProperty( prec, "max", 16 );
4860 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4861 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4862 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4863 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4864 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4866 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4867 setPreferenceProperty( dispgroup, "columns", 2 );
4868 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4870 modes.append( tr("MEN_WIRE") );
4871 modes.append( tr("MEN_SHADE") );
4872 modes.append( tr("MEN_NODES") );
4873 modes.append( tr("MEN_SHRINK") );
4874 QList<QVariant> indices;
4875 indices.append( 0 );
4876 indices.append( 1 );
4877 indices.append( 2 );
4878 indices.append( 3 );
4879 setPreferenceProperty( dispmode, "strings", modes );
4880 setPreferenceProperty( dispmode, "indexes", indices );
4882 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4883 setPreferenceProperty( arcgroup, "columns", 2 );
4884 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4885 QStringList quadraticModes;
4886 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4887 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4889 indices.append( 0 );
4890 indices.append( 1 );
4891 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4892 setPreferenceProperty( quadraticmode, "indexes", indices );
4894 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4895 "SMESH", "max_angle" );
4896 setPreferenceProperty( maxAngle, "min", 1 );
4897 setPreferenceProperty( maxAngle, "max", 90 );
4901 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4902 setPreferenceProperty( exportgroup, "columns", 2 );
4903 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4904 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4906 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4907 setPreferenceProperty( computeGroup, "columns", 2 );
4908 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4910 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4911 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4912 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4914 indices.append( 0 );
4915 indices.append( 1 );
4916 indices.append( 2 );
4917 setPreferenceProperty( notifyMode, "strings", modes );
4918 setPreferenceProperty( notifyMode, "indexes", indices );
4920 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4921 setPreferenceProperty( infoGroup, "columns", 2 );
4922 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4924 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4925 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4927 indices.append( 0 );
4928 indices.append( 1 );
4929 setPreferenceProperty( elemInfo, "strings", modes );
4930 setPreferenceProperty( elemInfo, "indexes", indices );
4931 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4932 setPreferenceProperty( nodesLim, "min", 0 );
4933 setPreferenceProperty( nodesLim, "max", 10000000 );
4934 setPreferenceProperty( nodesLim, "step", 10000 );
4935 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4936 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4937 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4938 setPreferenceProperty( ctrlLim, "min", 0 );
4939 setPreferenceProperty( ctrlLim, "max", 10000000 );
4940 setPreferenceProperty( ctrlLim, "step", 1000 );
4941 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4942 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4943 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4944 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4945 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4947 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4948 setPreferenceProperty( segGroup, "columns", 2 );
4949 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4950 "SMESH", "segmentation" );
4951 setPreferenceProperty( segLen, "min", 1 );
4952 setPreferenceProperty( segLen, "max", 10000000 );
4953 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4954 "SMESH", "nb_segments_per_edge" );
4955 setPreferenceProperty( nbSeg, "min", 1 );
4956 setPreferenceProperty( nbSeg, "max", 10000000 );
4958 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4959 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4960 "SMESH", "forget_mesh_on_hyp_modif" );
4963 // Quantities with individual precision settings
4964 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4965 setPreferenceProperty( precGroup, "columns", 2 );
4967 const int nbQuantities = 6;
4968 int precs[nbQuantities], ii = 0;
4969 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4970 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4971 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4972 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4973 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4974 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4975 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4976 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4977 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4978 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4979 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4980 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4982 // Set property for precision value for spinboxes
4983 for ( ii = 0; ii < nbQuantities; ii++ ){
4984 setPreferenceProperty( precs[ii], "min", -14 );
4985 setPreferenceProperty( precs[ii], "max", 14 );
4986 setPreferenceProperty( precs[ii], "precision", 2 );
4989 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4990 setPreferenceProperty( previewGroup, "columns", 2 );
4991 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4992 setPreferenceProperty( chunkSize, "min", 1 );
4993 setPreferenceProperty( chunkSize, "max", 1000 );
4994 setPreferenceProperty( chunkSize, "step", 50 );
4996 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4997 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4999 // Mesh tab ------------------------------------------------------------------------
5000 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5001 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5002 setPreferenceProperty( nodeGroup, "columns", 3 );
5004 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5006 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5008 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5009 QList<QVariant> aMarkerTypeIndicesList;
5010 QList<QVariant> aMarkerTypeIconsList;
5011 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5012 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5013 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5014 aMarkerTypeIndicesList << i;
5015 aMarkerTypeIconsList << pixmap;
5017 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5018 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5020 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5022 QList<QVariant> aMarkerScaleIndicesList;
5023 QStringList aMarkerScaleValuesList;
5024 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5025 aMarkerScaleIndicesList << i;
5026 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5028 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5029 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5031 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5032 //setPreferenceProperty( elemGroup, "columns", 2 );
5034 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5035 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5036 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5037 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5038 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5039 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5040 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5041 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5042 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5045 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5046 setPreferenceProperty( grpGroup, "columns", 2 );
5048 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5049 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5051 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5052 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5053 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5054 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5055 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5056 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5057 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5058 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5059 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5060 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5061 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5062 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5064 setPreferenceProperty( size0d, "min", 1 );
5065 setPreferenceProperty( size0d, "max", 10 );
5067 setPreferenceProperty( ballSize, "min", 1 );
5068 setPreferenceProperty( ballSize, "max", 10 );
5070 setPreferenceProperty( ballScale, "min", 1e-2 );
5071 setPreferenceProperty( ballScale, "max", 1e7 );
5072 setPreferenceProperty( ballScale, "step", 0.5 );
5074 setPreferenceProperty( elemW, "min", 1 );
5075 setPreferenceProperty( elemW, "max", 5 );
5077 setPreferenceProperty( outW, "min", 1 );
5078 setPreferenceProperty( outW, "max", 5 );
5080 setPreferenceProperty( shrink, "min", 0 );
5081 setPreferenceProperty( shrink, "max", 100 );
5083 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5084 setPreferenceProperty( numGroup, "columns", 2 );
5086 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5087 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5089 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5090 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5092 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5093 setPreferenceProperty( orientGroup, "columns", 1 );
5095 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5096 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5098 setPreferenceProperty( orientScale, "min", 0.05 );
5099 setPreferenceProperty( orientScale, "max", 0.5 );
5100 setPreferenceProperty( orientScale, "step", 0.05 );
5102 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5104 // Selection tab ------------------------------------------------------------------------
5105 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5107 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5108 setPreferenceProperty( selGroup, "columns", 2 );
5110 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5111 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5113 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5114 setPreferenceProperty( preGroup, "columns", 2 );
5116 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5118 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5119 setPreferenceProperty( precSelGroup, "columns", 2 );
5121 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5122 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5123 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5125 // Scalar Bar tab ------------------------------------------------------------------------
5126 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5127 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5128 setPreferenceProperty( fontGr, "columns", 2 );
5130 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5131 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5133 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5134 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5136 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5137 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5139 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5140 setPreferenceProperty( numcol, "min", 2 );
5141 setPreferenceProperty( numcol, "max", 256 );
5143 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5144 setPreferenceProperty( numlab, "min", 2 );
5145 setPreferenceProperty( numlab, "max", 65 );
5147 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5148 setPreferenceProperty( orientGr, "columns", 2 );
5149 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5150 QStringList orients;
5151 orients.append( tr( "SMESH_VERTICAL" ) );
5152 orients.append( tr( "SMESH_HORIZONTAL" ) );
5153 indices.clear(); indices.append( 0 ); indices.append( 1 );
5154 setPreferenceProperty( orient, "strings", orients );
5155 setPreferenceProperty( orient, "indexes", indices );
5157 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5158 setPreferenceProperty( posVSizeGr, "columns", 2 );
5159 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5160 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5161 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5162 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5163 setPreferenceProperty( xv, "step", 0.1 );
5164 setPreferenceProperty( xv, "min", 0.0 );
5165 setPreferenceProperty( xv, "max", 1.0 );
5166 setPreferenceProperty( yv, "step", 0.1 );
5167 setPreferenceProperty( yv, "min", 0.0 );
5168 setPreferenceProperty( yv, "max", 1.0 );
5169 setPreferenceProperty( wv, "step", 0.1 );
5170 setPreferenceProperty( wv, "min", 0.0 );
5171 setPreferenceProperty( wv, "max", 1.0 );
5172 setPreferenceProperty( hv, "min", 0.0 );
5173 setPreferenceProperty( hv, "max", 1.0 );
5174 setPreferenceProperty( hv, "step", 0.1 );
5176 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5177 setPreferenceProperty( posHSizeGr, "columns", 2 );
5178 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5179 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5180 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5181 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5182 setPreferenceProperty( xv, "min", 0.0 );
5183 setPreferenceProperty( xv, "max", 1.0 );
5184 setPreferenceProperty( xv, "step", 0.1 );
5185 setPreferenceProperty( xh, "min", 0.0 );
5186 setPreferenceProperty( xh, "max", 1.0 );
5187 setPreferenceProperty( xh, "step", 0.1 );
5188 setPreferenceProperty( yh, "min", 0.0 );
5189 setPreferenceProperty( yh, "max", 1.0 );
5190 setPreferenceProperty( yh, "step", 0.1 );
5191 setPreferenceProperty( wh, "min", 0.0 );
5192 setPreferenceProperty( wh, "max", 1.0 );
5193 setPreferenceProperty( wh, "step", 0.1 );
5194 setPreferenceProperty( hh, "min", 0.0 );
5195 setPreferenceProperty( hh, "max", 1.0 );
5196 setPreferenceProperty( hh, "step", 0.1 );
5198 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5199 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5200 setPreferenceProperty( distributionGr, "columns", 3 );
5202 types.append( tr( "SMESH_MONOCOLOR" ) );
5203 types.append( tr( "SMESH_MULTICOLOR" ) );
5204 indices.clear(); indices.append( 0 ); indices.append( 1 );
5205 setPreferenceProperty( coloringType, "strings", types );
5206 setPreferenceProperty( coloringType, "indexes", indices );
5207 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5211 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5213 if( sect=="SMESH" ) {
5214 float sbX1,sbY1,sbW,sbH;
5215 float aTol = 1.00000009999999;
5216 std::string aWarning;
5217 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5218 if( name=="selection_object_color" || name=="selection_element_color" ||
5219 name=="highlight_color" ||
5220 name=="selection_precision_node" || name=="selection_precision_element" ||
5221 name=="selection_precision_object")
5222 SMESH::UpdateSelectionProp( this );
5223 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5224 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5225 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5226 if(sbX1+sbW > aTol){
5227 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5230 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5231 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5234 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5235 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5236 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5237 if(sbY1+sbH > aTol){
5238 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5239 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5240 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5243 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5244 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5245 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5246 if(sbX1+sbW > aTol){
5247 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5250 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5251 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5254 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5255 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5256 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5257 if(sbY1+sbH > aTol){
5258 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5261 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5262 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5265 else if ( name == "segmentation" ) {
5266 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5267 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5269 else if ( name == "nb_segments_per_edge" ) {
5270 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5271 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5273 else if ( name == "historical_python_dump" ||
5274 name == "forget_mesh_on_hyp_modif") {
5275 QString val = aResourceMgr->stringValue( "SMESH", name );
5276 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5278 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5279 SMESH::UpdateFontProp( this );
5281 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5282 SMESH::UpdateFontProp( this );
5285 if(aWarning.size() != 0){
5286 aWarning += "The default values are applied instead.";
5287 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5288 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5289 QObject::tr(aWarning.c_str()));
5294 //================================================================================
5296 * \brief Update something in accordance with update flags
5297 * \param theFlags - update flags
5299 * Update viewer or/and object browser etc. in accordance with update flags ( see
5300 * LightApp_UpdateFlags enumeration ).
5302 //================================================================================
5303 void SMESHGUI::update( const int flags )
5305 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5306 SMESH::UpdateView();
5308 SalomeApp_Module::update( flags );
5311 //================================================================================
5313 * \brief Set default selection mode
5315 * SLOT called when operation commited. Sets default selection mode
5317 //================================================================================
5318 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5320 SVTK_ViewWindow* vtkWnd =
5321 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5323 vtkWnd->SetSelectionMode( ActorSelection );
5326 //================================================================================
5328 * \brief Set default selection mode
5330 * SLOT called when operation aborted. Sets default selection mode
5332 //================================================================================
5333 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5335 SVTK_ViewWindow* vtkWnd =
5336 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5338 vtkWnd->SetSelectionMode( ActorSelection );
5341 //================================================================================
5343 * \brief Creates operation with given identifier
5344 * \param id - identifier of operation to be started
5345 * \return Pointer on created operation or NULL if operation is not created
5347 * Virtual method redefined from the base class creates operation with given id.
5348 * It is called called automatically from startOperation method of base class.
5350 //================================================================================
5351 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5353 LightApp_Operation* op = 0;
5354 // to do : create operation here
5357 case 417: //convert to quadratic
5358 op = new SMESHGUI_ConvToQuadOp();
5360 case 418: // create 2D mesh as boundary on 3D
5361 op = new SMESHGUI_Make2DFrom3DOp();
5363 case 420: // Reorient faces
5364 op = new SMESHGUI_ReorientFacesOp();
5366 case 701: // Compute mesh
5367 op = new SMESHGUI_ComputeOp();
5369 case 702: // Create mesh
5370 op = new SMESHGUI_MeshOp( true, true );
5372 case 703: // Create sub-mesh
5373 op = new SMESHGUI_MeshOp( true, false );
5375 case 704: // Edit mesh/sub-mesh
5376 op = new SMESHGUI_MeshOp( false );
5378 case 711: // Precompute mesh
5379 op = new SMESHGUI_PrecomputeOp();
5381 case 712: // Evaluate mesh
5382 op = new SMESHGUI_EvaluateOp();
5384 case 713: // Evaluate mesh
5385 op = new SMESHGUI_MeshOrderOp();
5387 case 806: // Create group on geom
5388 op = new SMESHGUI_GroupOnShapeOp();
5390 case 904: // Find element
5391 op = new SMESHGUI_FindElemByPointOp();
5393 case 4067: // Make mesh pass through point
5394 op = new SMESHGUI_MakeNodeAtPointOp();
5396 case 4070: // Create 0D elements on all nodes
5397 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5404 op = SalomeApp_Module::createOperation( id );
5408 //================================================================================
5410 * \brief Stops current operations and starts a given one
5411 * \param id - The id of the operation to start
5413 //================================================================================
5415 void SMESHGUI::switchToOperation(int id)
5417 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5418 activeStudy()->abortAllOperations();
5419 startOperation( id );
5422 LightApp_Displayer* SMESHGUI::displayer()
5425 myDisplayer = new SMESHGUI_Displayer( getApp() );
5429 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5432 int aTolerance = 64;
5433 int anIterations = 0;
5439 if( anIterations % aPeriod == 0 )
5442 if( aTolerance < 1 )
5446 aHue = (int)( 360.0 * rand() / RAND_MAX );
5449 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5450 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5451 for( ; it != itEnd; ++it )
5453 SALOMEDS::Color anAutoColor = *it;
5454 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5457 aQColor.getHsv( &h, &s, &v );
5458 if( abs( h - aHue ) < aTolerance )
5470 aColor.setHsv( aHue, 255, 255 );
5472 SALOMEDS::Color aSColor;
5473 aSColor.R = aColor.redF();
5474 aSColor.G = aColor.greenF();
5475 aSColor.B = aColor.blueF();
5480 const char* gSeparator = "_"; // character used to separate parameter names
5481 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5482 const char* gPathSep = "|"; // character used to separate paths
5485 * \brief Store visual parameters
5487 * This method is called just before the study document is saved.
5488 * Store visual parameters in AttributeParameter attribue(s)
5490 void SMESHGUI::storeVisualParameters (int savePoint)
5493 Kernel_Utils::Localizer loc;
5495 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5496 if (!appStudy || !appStudy->studyDS())
5498 _PTR(Study) studyDS = appStudy->studyDS();
5500 // componentName is used for encoding of entries when storing them in IParameters
5501 std::string componentName = myComponentSMESH->ComponentDataType();
5502 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5503 //if (!aSComponent) return;
5506 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5507 componentName.c_str(),
5509 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5511 // store map of custom markers
5512 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5513 if( !aMarkerMap.empty() )
5515 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5516 for( ; anIter != aMarkerMap.end(); anIter++ )
5518 int anId = anIter->first;
5519 VTK::MarkerData aMarkerData = anIter->second;
5520 std::string aMarkerFileName = aMarkerData.first;
5521 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5522 if( aMarkerTexture.size() < 3 )
5523 continue; // should contain at least width, height and the first value
5525 QString aPropertyName( "texture" );
5526 aPropertyName += gSeparator;
5527 aPropertyName += QString::number( anId );
5529 QString aPropertyValue = aMarkerFileName.c_str();
5530 aPropertyValue += gPathSep;
5532 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5533 ushort aWidth = *aTextureIter++;
5534 ushort aHeight = *aTextureIter++;
5535 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5536 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5537 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5538 aPropertyValue += QString::number( *aTextureIter );
5540 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5544 // viewers counters are used for storing view_numbers in IParameters
5547 // main cycle to store parameters of displayed objects
5548 QList<SUIT_ViewManager*> lst;
5549 QList<SUIT_ViewManager*>::Iterator it;
5550 getApp()->viewManagers(lst);
5551 for (it = lst.begin(); it != lst.end(); it++)
5553 SUIT_ViewManager* vman = *it;
5554 QString vType = vman->getType();
5556 // saving VTK actors properties
5557 if (vType == SVTK_Viewer::Type())
5559 // store the clipping planes attached to the view manager
5560 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5561 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5562 if( anIter != myClippingPlaneInfoMap.end() )
5563 aClippingPlaneInfoList = anIter->second;
5565 if( !aClippingPlaneInfoList.empty() ) {
5566 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5567 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5569 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5570 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5572 QString aPropertyName( "ClippingPlane" );
5573 aPropertyName += gSeparator;
5574 aPropertyName += QString::number( vtkViewers );
5575 aPropertyName += gSeparator;
5576 aPropertyName += QString::number( anId );
5578 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5579 aPropertyValue += gDigitsSep;
5580 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5581 aPropertyValue += gDigitsSep;
5582 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5583 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5584 aPropertyValue += gDigitsSep;
5585 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5586 aPropertyValue += gDigitsSep;
5587 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5588 aPropertyValue += gDigitsSep;
5589 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5590 aPropertyValue += gDigitsSep;
5591 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5592 aPropertyValue += gDigitsSep;
5593 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5594 aPropertyValue += gDigitsSep;
5595 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5597 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5598 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5599 aPropertyValue += gDigitsSep;
5600 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5601 aPropertyValue += gDigitsSep;
5602 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5603 aPropertyValue += gDigitsSep;
5604 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5607 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5611 QVector<SUIT_ViewWindow*> views = vman->getViews();
5612 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5614 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5616 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5617 vtkActorCollection* allActors = aCopy.GetActors();
5618 allActors->InitTraversal();
5619 while (vtkActor* actor = allActors->GetNextActor())
5621 if (actor->GetVisibility()) // store only visible actors
5623 SMESH_Actor* aSmeshActor = 0;
5624 if (actor->IsA("SMESH_Actor"))
5625 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5626 if (aSmeshActor && aSmeshActor->hasIO())
5628 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5631 // entry is "encoded" = it does NOT contain component adress,
5632 // since it is a subject to change on next component loading
5633 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5635 std::string param, vtkParam = vType.toLatin1().data();
5636 vtkParam += gSeparator;
5637 vtkParam += QString::number(vtkViewers).toLatin1().data();
5638 vtkParam += gSeparator;
5641 param = vtkParam + "Visibility";
5642 ip->setParameter(entry, param, "On");
5645 param = vtkParam + "Representation";
5646 ip->setParameter(entry, param, QString::number
5647 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5650 param = vtkParam + "IsShrunk";
5651 ip->setParameter(entry, param, QString::number
5652 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5654 // Displayed entities
5655 unsigned int aMode = aSmeshActor->GetEntityMode();
5656 bool isE = aMode & SMESH_Actor::eEdges;
5657 bool isF = aMode & SMESH_Actor::eFaces;
5658 bool isV = aMode & SMESH_Actor::eVolumes;
5659 bool is0d = aMode & SMESH_Actor::e0DElements;
5660 bool isB = aMode & SMESH_Actor::eBallElem;
5662 QString modeStr ("e");
5663 modeStr += gDigitsSep; modeStr += QString::number(isE);
5664 modeStr += gDigitsSep; modeStr += "f";
5665 modeStr += gDigitsSep; modeStr += QString::number(isF);
5666 modeStr += gDigitsSep; modeStr += "v";
5667 modeStr += gDigitsSep; modeStr += QString::number(isV);
5668 modeStr += gDigitsSep; modeStr += "0d";
5669 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5670 modeStr += gDigitsSep; modeStr += "b";
5671 modeStr += gDigitsSep; modeStr += QString::number(isB);
5673 param = vtkParam + "Entities";
5674 ip->setParameter(entry, param, modeStr.toLatin1().data());
5680 aSmeshActor->GetSufaceColor(r, g, b, delta);
5681 QStringList colorStr;
5682 colorStr << "surface";
5683 colorStr << QString::number(r);
5684 colorStr << QString::number(g);
5685 colorStr << QString::number(b);
5687 colorStr << "backsurface";
5688 colorStr << QString::number(delta);
5690 aSmeshActor->GetVolumeColor(r, g, b, delta);
5691 colorStr << "volume";
5692 colorStr << QString::number(r);
5693 colorStr << QString::number(g);
5694 colorStr << QString::number(b);
5695 colorStr << QString::number(delta);
5697 aSmeshActor->GetEdgeColor(r, g, b);
5699 colorStr << QString::number(r);
5700 colorStr << QString::number(g);
5701 colorStr << QString::number(b);
5703 aSmeshActor->GetNodeColor(r, g, b);
5705 colorStr << QString::number(r);
5706 colorStr << QString::number(g);
5707 colorStr << QString::number(b);
5709 aSmeshActor->GetOutlineColor(r, g, b);
5710 colorStr << "outline";
5711 colorStr << QString::number(r);
5712 colorStr << QString::number(g);
5713 colorStr << QString::number(b);
5715 aSmeshActor->Get0DColor(r, g, b);
5716 colorStr << "elem0d";
5717 colorStr << QString::number(r);
5718 colorStr << QString::number(g);
5719 colorStr << QString::number(b);
5721 aSmeshActor->GetBallColor(r, g, b);
5723 colorStr << QString::number(r);
5724 colorStr << QString::number(g);
5725 colorStr << QString::number(b);
5727 aSmeshActor->GetFacesOrientationColor(r, g, b);
5728 colorStr << "orientation";
5729 colorStr << QString::number(r);
5730 colorStr << QString::number(g);
5731 colorStr << QString::number(b);
5733 param = vtkParam + "Colors";
5734 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5737 QStringList sizeStr;
5739 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5740 sizeStr << "outline";
5741 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5742 sizeStr << "elem0d";
5743 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5745 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5746 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5747 sizeStr << "shrink";
5748 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5749 sizeStr << "orientation";
5750 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5751 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5753 param = vtkParam + "Sizes";
5754 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5759 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5760 if( aMarkerType == VTK::MT_USER ) {
5761 markerStr += "custom";
5762 markerStr += gDigitsSep;
5763 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5767 markerStr += gDigitsSep;
5768 markerStr += QString::number( (int)aMarkerType );
5769 markerStr += gDigitsSep;
5770 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5773 param = vtkParam + "PointMarker";
5774 ip->setParameter(entry, param, markerStr.toLatin1().data());
5777 param = vtkParam + "Opacity";
5778 ip->setParameter(entry, param,
5779 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5782 param = vtkParam + "ClippingPlane";
5784 if( !aClippingPlaneInfoList.empty() ) {
5785 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5786 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5788 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5789 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5790 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5791 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5792 if( aSmeshActor == *anIter2 ) {
5793 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5794 QString::number( anId ).toLatin1().constData() );
5801 ip->setParameter( entry, param, "Off" );
5802 } // if (io->hasEntry())
5803 } // SMESH_Actor && hasIO
5805 } // while.. actors traversal
5809 } // if (SVTK view model)
5810 } // for (viewManagers)
5813 // data structures for clipping planes processing
5817 bool isOpenGLClipping;
5818 vtkIdType RelativeOrientation;
5821 int AbsoluteOrientation;
5822 double X, Y, Z, Dx, Dy, Dz;
5824 typedef std::list<TPlaneData> TPlaneDataList;
5825 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5827 typedef std::list<vtkActor*> TActorList;
5830 TActorList ActorList;
5831 SUIT_ViewManager* ViewManager;
5833 typedef std::list<TPlaneInfo> TPlaneInfoList;
5834 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5837 * \brief Restore visual parameters
5839 * This method is called after the study document is opened.
5840 * Restore visual parameters from AttributeParameter attribue(s)
5842 void SMESHGUI::restoreVisualParameters (int savePoint)
5845 Kernel_Utils::Localizer loc;
5847 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5848 if (!appStudy || !appStudy->studyDS())
5850 _PTR(Study) studyDS = appStudy->studyDS();
5852 // componentName is used for encoding of entries when storing them in IParameters
5853 std::string componentName = myComponentSMESH->ComponentDataType();
5854 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5855 //if (!aSComponent) return;
5858 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5859 componentName.c_str(),
5861 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5863 // restore map of custom markers and map of clipping planes
5864 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5865 TPlaneDataMap aPlaneDataMap;
5867 std::vector<std::string> properties = ip->getProperties();
5868 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5870 std::string property = *propIt;
5871 QString aPropertyName( property.c_str() );
5872 QString aPropertyValue( ip->getProperty( property ).c_str() );
5874 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5875 if( aPropertyNameList.isEmpty() )
5878 QString aPropertyType = aPropertyNameList[0];
5879 if( aPropertyType == "texture" )
5881 if( aPropertyNameList.size() != 2 )
5885 int anId = aPropertyNameList[1].toInt( &ok );
5886 if( !ok || anId < 1 )
5889 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5890 if( aPropertyValueList.size() != 2 )
5893 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5894 QString aMarkerTextureString = aPropertyValueList[1];
5895 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5896 if( aMarkerTextureStringList.size() != 3 )
5900 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5905 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5909 VTK::MarkerTexture aMarkerTexture;
5910 aMarkerTexture.push_back( aWidth );
5911 aMarkerTexture.push_back( aHeight );
5913 QString aMarkerTextureData = aMarkerTextureStringList[2];
5914 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5916 QChar aChar = aMarkerTextureData.at( i );
5917 if( aChar.isDigit() )
5918 aMarkerTexture.push_back( aChar.digitValue() );
5921 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5923 else if( aPropertyType == "ClippingPlane" )
5925 if( aPropertyNameList.size() != 3 )
5929 int aViewId = aPropertyNameList[1].toInt( &ok );
5930 if( !ok || aViewId < 0 )
5934 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5935 if( !ok || aClippingPlaneId < 0 )
5938 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5939 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
5942 TPlaneData aPlaneData;
5943 aPlaneData.Id = aClippingPlaneId;
5946 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
5951 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
5955 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
5958 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
5963 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
5968 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
5973 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
5978 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
5983 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
5988 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
5992 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
5994 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
5999 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6004 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6009 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6014 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6015 aPlaneDataList.push_back( aPlaneData );
6019 TPlaneInfoMap aPlaneInfoMap;
6021 std::vector<std::string> entries = ip->getEntries();
6023 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6025 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6026 QString entry (ip->decodeEntry(*entIt).c_str());
6028 // Check that the entry corresponds to a real object in the Study
6029 // as the object may be deleted or modified after the visual state is saved.
6030 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6031 if (!so) continue; //Skip the not existent entry
6033 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6034 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6036 std::vector<std::string>::iterator namesIt = paramNames.begin();
6037 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6039 // actors are stored in a map after displaying of them for
6040 // quicker access in the future: map < viewID to actor >
6041 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6043 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6045 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6046 // '_' is used as separator and should not be used in viewer type or parameter names.
6047 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6048 if (lst.size() != 3)
6051 QString viewerTypStr = lst[0];
6052 QString viewIndexStr = lst[1];
6053 QString paramNameStr = lst[2];
6056 int viewIndex = viewIndexStr.toUInt(&ok);
6057 if (!ok) // bad conversion of view index to integer
6061 if (viewerTypStr == SVTK_Viewer::Type())
6063 SMESH_Actor* aSmeshActor = 0;
6064 if (vtkActors.IsBound(viewIndex))
6065 aSmeshActor = vtkActors.Find(viewIndex);
6067 QList<SUIT_ViewManager*> lst;
6068 getApp()->viewManagers(viewerTypStr, lst);
6070 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6071 SUIT_ViewManager* vman = NULL;
6072 if (viewIndex >= 0 && viewIndex < lst.count())
6073 vman = lst.at(viewIndex);
6075 if (paramNameStr == "Visibility")
6077 if (!aSmeshActor && displayer() && vman)
6079 SUIT_ViewModel* vmodel = vman->getViewModel();
6080 // SVTK view model can be casted to SALOME_View
6081 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6083 // store displayed actor in a temporary map for quicker
6084 // access later when restoring other parameters
6085 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6086 vtkRenderer* Renderer = vtkView->getRenderer();
6087 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6088 vtkActorCollection* theActors = aCopy.GetActors();
6089 theActors->InitTraversal();
6090 bool isFound = false;
6091 vtkActor *ac = theActors->GetNextActor();
6092 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6093 if (ac->IsA("SMESH_Actor")) {
6094 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6095 if (aGeomAc->hasIO()) {
6096 Handle(SALOME_InteractiveObject) io =
6097 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6098 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6100 vtkActors.Bind(viewIndex, aGeomAc);
6106 } // if (paramNameStr == "Visibility")
6109 // the rest properties "work" with SMESH_Actor
6112 QString val ((*valuesIt).c_str());
6115 if (paramNameStr == "Representation") {
6116 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6119 else if (paramNameStr == "IsShrunk") {
6121 if (!aSmeshActor->IsShrunk())
6122 aSmeshActor->SetShrink();
6125 if (aSmeshActor->IsShrunk())
6126 aSmeshActor->UnShrink();
6129 // Displayed entities
6130 else if (paramNameStr == "Entities") {
6131 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6132 int aEntityMode = SMESH_Actor::eAllEntity;
6133 for ( int i = 0; i < mode.count(); i+=2 ) {
6134 if ( i < mode.count()-1 ) {
6135 QString type = mode[i];
6136 bool val = mode[i+1].toInt();
6137 if ( type == "e" && !val )
6138 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6139 else if ( type == "f" && !val )
6140 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6141 else if ( type == "v" && !val )
6142 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6143 else if ( type == "0d" && !val )
6144 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6145 else if ( type == "b" && !val )
6146 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6149 aSmeshActor->SetEntityMode( aEntityMode );
6152 else if (paramNameStr == "Colors") {
6153 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6160 QColor outlineColor;
6161 QColor orientationColor;
6167 // below lines are required to get default values for delta coefficients
6168 // of backface color for faces and color of reversed volumes
6169 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6170 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6171 for ( int i = 0; i < colors.count(); i++ ) {
6172 QString type = colors[i];
6173 if ( type == "surface" ) {
6174 // face color is set by 3 values r:g:b, where
6175 // - r,g,b - is rgb color components
6176 if ( i+1 >= colors.count() ) break; // format error
6177 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6178 if ( i+2 >= colors.count() ) break; // format error
6179 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6180 if ( i+3 >= colors.count() ) break; // format error
6181 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6182 faceColor.setRgbF( r, g, b );
6185 else if ( type == "backsurface" ) {
6186 // backface color can be defined in several ways
6187 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6188 // - in latest versions, it is set as delta coefficient
6189 bool rgbOk = false, deltaOk;
6190 if ( i+1 >= colors.count() ) break; // format error
6191 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6192 int delta = colors[i+1].toInt( &deltaOk );
6194 if ( i+1 < colors.count() ) // index is shifted to 1
6195 g = colors[i+1].toDouble( &rgbOk );
6196 if ( rgbOk ) i++; // shift index
6197 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6198 b = colors[i+1].toDouble( &rgbOk );
6200 // - as currently there's no way to set directly backsurface color as it was before,
6201 // we ignore old dump where r,g,b triple was set
6202 // - also we check that delta parameter is set properly
6203 if ( !rgbOk && deltaOk )
6206 else if ( type == "volume" ) {
6207 // volume color is set by 4 values r:g:b:delta, where
6208 // - r,g,b - is a normal volume rgb color components
6209 // - delta - is a reversed volume color delta coefficient
6210 if ( i+1 >= colors.count() ) break; // format error
6211 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6212 if ( i+2 >= colors.count() ) break; // format error
6213 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6214 if ( i+3 >= colors.count() ) break; // format error
6215 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6216 if ( i+4 >= colors.count() ) break; // format error
6217 int delta = colors[i+4].toInt( &bOk );
6218 if ( !bOk ) break; // format error
6219 volumeColor.setRgbF( r, g, b );
6223 else if ( type == "edge" ) {
6224 // edge color is set by 3 values r:g:b, where
6225 // - r,g,b - is rgb color components
6226 if ( i+1 >= colors.count() ) break; // format error
6227 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6228 if ( i+2 >= colors.count() ) break; // format error
6229 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6230 if ( i+3 >= colors.count() ) break; // format error
6231 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6232 edgeColor.setRgbF( r, g, b );
6235 else if ( type == "node" ) {
6236 // node color is set by 3 values r:g:b, where
6237 // - r,g,b - is rgb color components
6238 if ( i+1 >= colors.count() ) break; // format error
6239 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6240 if ( i+2 >= colors.count() ) break; // format error
6241 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6242 if ( i+3 >= colors.count() ) break; // format error
6243 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6244 nodeColor.setRgbF( r, g, b );
6247 else if ( type == "elem0d" ) {
6248 // 0d element color is set by 3 values r:g:b, where
6249 // - r,g,b - is rgb color components
6250 if ( i+1 >= colors.count() ) break; // format error
6251 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6252 if ( i+2 >= colors.count() ) break; // format error
6253 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6254 if ( i+3 >= colors.count() ) break; // format error
6255 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6256 elem0dColor.setRgbF( r, g, b );
6259 else if ( type == "ball" ) {
6260 // ball color is set by 3 values r:g:b, where
6261 // - r,g,b - is rgb color components
6262 if ( i+1 >= colors.count() ) break; // format error
6263 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6264 if ( i+2 >= colors.count() ) break; // format error
6265 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6266 if ( i+3 >= colors.count() ) break; // format error
6267 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6268 ballColor.setRgbF( r, g, b );
6271 else if ( type == "outline" ) {
6272 // outline color is set by 3 values r:g:b, where
6273 // - r,g,b - is rgb color components
6274 if ( i+1 >= colors.count() ) break; // format error
6275 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6276 if ( i+2 >= colors.count() ) break; // format error
6277 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6278 if ( i+3 >= colors.count() ) break; // format error
6279 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6280 outlineColor.setRgbF( r, g, b );
6283 else if ( type == "orientation" ) {
6284 // orientation color is set by 3 values r:g:b, where
6285 // - r,g,b - is rgb color components
6286 if ( i+1 >= colors.count() ) break; // format error
6287 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6288 if ( i+2 >= colors.count() ) break; // format error
6289 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6290 if ( i+3 >= colors.count() ) break; // format error
6291 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6292 orientationColor.setRgbF( r, g, b );
6297 if ( nodeColor.isValid() )
6298 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6300 if ( edgeColor.isValid() )
6301 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6303 if ( faceColor.isValid() )
6304 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6306 if ( volumeColor.isValid() )
6307 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6308 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6309 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6311 if ( elem0dColor.isValid() )
6312 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6314 if ( ballColor.isValid() )
6315 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6317 if ( outlineColor.isValid() )
6318 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6319 // orientation color
6320 if ( orientationColor.isValid() )
6321 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6324 else if (paramNameStr == "Sizes") {
6325 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6328 int outlineWidth = -1;
6329 int elem0dSize = -1;
6331 double ballScale = -1.0;
6332 double shrinkSize = -1;
6333 double orientationSize = -1;
6334 bool orientation3d = false;
6335 for ( int i = 0; i < sizes.count(); i++ ) {
6336 QString type = sizes[i];
6337 if ( type == "line" ) {
6338 // line (wireframe) width is given as single integer value
6339 if ( i+1 >= sizes.count() ) break; // format error
6340 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6344 if ( type == "outline" ) {
6345 // outline width is given as single integer value
6346 if ( i+1 >= sizes.count() ) break; // format error
6347 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6351 else if ( type == "elem0d" ) {
6352 // 0d element size is given as single integer value
6353 if ( i+1 >= sizes.count() ) break; // format error
6354 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6358 else if ( type == "ball" ) {
6359 // balls are specified by two values: size:scale, where
6360 // - size - is a integer value specifying size
6361 // - scale - is a double value specifying scale factor
6362 if ( i+1 >= sizes.count() ) break; // format error
6363 int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6364 if ( i+2 >= sizes.count() ) break; // format error
6365 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6370 else if ( type == "shrink" ) {
6371 // shrink factor is given as single floating point value
6372 if ( i+1 >= sizes.count() ) break; // format error
6373 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6377 else if ( type == "orientation" ) {
6378 // orientation vectors are specified by two values size:3d, where
6379 // - size - is a floating point value specifying scale factor
6380 // - 3d - is a boolean
6381 if ( i+1 >= sizes.count() ) break; // format error
6382 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6383 if ( i+2 >= sizes.count() ) break; // format error
6384 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6385 orientationSize = v1;
6386 orientation3d = (bool)v2;
6390 // line (wireframe) width
6391 if ( lineWidth > 0 )
6392 aSmeshActor->SetLineWidth( lineWidth );
6394 if ( outlineWidth > 0 )
6395 aSmeshActor->SetOutlineWidth( outlineWidth );
6396 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6397 aSmeshActor->SetOutlineWidth( lineWidth );
6399 if ( elem0dSize > 0 )
6400 aSmeshActor->Set0DSize( elem0dSize );
6403 aSmeshActor->SetBallSize( ballSize );
6405 if ( ballScale > 0.0 )
6406 aSmeshActor->SetBallScale( ballScale );
6408 if ( shrinkSize > 0 )
6409 aSmeshActor->SetShrinkFactor( shrinkSize );
6410 // orientation vectors
6411 if ( orientationSize > 0 ) {
6412 aSmeshActor->SetFacesOrientationScale( orientationSize );
6413 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6417 else if (paramNameStr == "PointMarker") {
6418 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6419 if( data.count() >= 2 ) {
6421 int aParam1 = data[1].toInt( &ok );
6423 if( data[0] == "std" && data.count() == 3 ) {
6424 int aParam2 = data[2].toInt( &ok );
6425 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6427 else if( data[0] == "custom" ) {
6428 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6429 if( markerIt != aMarkerMap.end() ) {
6430 VTK::MarkerData aMarkerData = markerIt->second;
6431 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6438 else if (paramNameStr == "Opacity") {
6439 aSmeshActor->SetOpacity(val.toFloat());
6442 else if (paramNameStr.startsWith("ClippingPlane")) {
6443 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6444 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6445 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6446 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6447 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6448 // new format - val looks like "Off" or "0" (plane id)
6449 // (note: in new format "Off" value is used only for consistency,
6450 // so it is processed together with values in old format)
6451 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6452 if( anIsOldFormat ) {
6453 if (paramNameStr == "ClippingPlane1" || val == "Off")
6454 aSmeshActor->RemoveAllClippingPlanes();
6456 QList<SUIT_ViewManager*> lst;
6457 getApp()->viewManagers(viewerTypStr, lst);
6458 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6459 if (viewIndex >= 0 && viewIndex < lst.count()) {
6460 SUIT_ViewManager* vman = lst.at(viewIndex);
6461 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6463 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6465 SMESH::TActorList anActorList;
6466 anActorList.push_back( aSmeshActor );
6467 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6468 aPlane->myViewWindow = vtkView;
6469 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6470 aPlane->PlaneMode = aMode;
6471 bool isOpenGLClipping = ( bool )vals[1].toInt();
6472 aPlane->IsOpenGLClipping = isOpenGLClipping;
6473 if ( aMode == SMESH::Absolute ) {
6474 aPlane->myAbsoluteOrientation = vals[2].toInt();
6475 aPlane->X = vals[3].toFloat();
6476 aPlane->Y = vals[4].toFloat();
6477 aPlane->Z = vals[5].toFloat();
6478 aPlane->Dx = vals[6].toFloat();
6479 aPlane->Dy = vals[7].toFloat();
6480 aPlane->Dz = vals[8].toFloat();
6482 else if ( aMode == SMESH::Relative ) {
6483 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6484 aPlane->myDistance = vals[3].toFloat();
6485 aPlane->myAngle[0] = vals[4].toFloat();
6486 aPlane->myAngle[1] = vals[5].toFloat();
6490 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6491 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6492 aClippingPlaneInfo.Plane = aPlane;
6493 aClippingPlaneInfo.ActorList = anActorList;
6494 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6502 int aPlaneId = val.toInt( &ok );
6503 if( ok && aPlaneId >= 0 ) {
6504 bool anIsDefinedPlane = false;
6505 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6506 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6507 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6508 TPlaneInfo& aPlaneInfo = *anIter;
6509 if( aPlaneInfo.PlaneId == aPlaneId ) {
6510 aPlaneInfo.ActorList.push_back( aSmeshActor );
6511 anIsDefinedPlane = true;
6515 if( !anIsDefinedPlane ) {
6516 TPlaneInfo aPlaneInfo;
6517 aPlaneInfo.PlaneId = aPlaneId;
6518 aPlaneInfo.ActorList.push_back( aSmeshActor );
6519 aPlaneInfo.ViewManager = vman;
6521 // to make the list sorted by plane id
6522 anIter = aPlaneInfoList.begin();
6523 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6524 const TPlaneInfo& aPlaneInfoRef = *anIter;
6525 if( aPlaneInfoRef.PlaneId > aPlaneId )
6528 aPlaneInfoList.insert( anIter, aPlaneInfo );
6533 } // if (aSmeshActor)
6534 } // other parameters than Visibility
6536 } // for names/parameters iterator
6537 } // for entries iterator
6539 // take into account planes with empty list of actors referred to them
6540 QList<SUIT_ViewManager*> aVMList;
6541 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6543 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6544 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6545 int aViewId = aPlaneDataIter->first;
6546 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6547 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6549 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6551 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6552 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6553 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6554 const TPlaneData& aPlaneData = *anIter2;
6555 int aPlaneId = aPlaneData.Id;
6557 bool anIsFound = false;
6558 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6559 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6560 const TPlaneInfo& aPlaneInfo = *anIter3;
6561 if( aPlaneInfo.PlaneId == aPlaneId ) {
6568 TPlaneInfo aPlaneInfo; // ActorList field is empty
6569 aPlaneInfo.PlaneId = aPlaneId;
6570 aPlaneInfo.ViewManager = aViewManager;
6572 // to make the list sorted by plane id
6573 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6574 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6575 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6576 if( aPlaneInfoRef.PlaneId > aPlaneId )
6579 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6585 // add clipping planes to actors according to the restored parameters
6586 // and update the clipping plane map
6587 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6588 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6589 int aViewId = anIter1->first;
6590 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6592 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6593 if( anIter2 == aPlaneDataMap.end() )
6595 const TPlaneDataList& aPlaneDataList = anIter2->second;
6597 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6598 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6599 const TPlaneInfo& aPlaneInfo = *anIter3;
6600 int aPlaneId = aPlaneInfo.PlaneId;
6601 const TActorList& anActorList = aPlaneInfo.ActorList;
6602 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6606 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6610 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6612 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6613 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6614 const TPlaneData& aPlaneData = *anIter4;
6615 if( aPlaneData.Id == aPlaneId ) {
6616 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6617 aPlane->myViewWindow = aViewWindow;
6618 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6619 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6620 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6621 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6622 aPlane->X = aPlaneData.X;
6623 aPlane->Y = aPlaneData.Y;
6624 aPlane->Z = aPlaneData.Z;
6625 aPlane->Dx = aPlaneData.Dx;
6626 aPlane->Dy = aPlaneData.Dy;
6627 aPlane->Dz = aPlaneData.Dz;
6629 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6630 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6631 aPlane->myDistance = aPlaneData.Distance;
6632 aPlane->myAngle[0] = aPlaneData.Angle[0];
6633 aPlane->myAngle[1] = aPlaneData.Angle[1];
6636 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6637 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6638 aClippingPlaneInfo.Plane = aPlane;
6639 aClippingPlaneInfo.ActorList = anActorList;
6640 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6651 // update all VTK views
6652 QList<SUIT_ViewManager*> lst;
6653 getApp()->viewManagers(lst);
6654 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6655 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6656 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6657 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6658 // set OpenGL clipping planes
6659 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6660 vtkActorCollection* anAllActors = aCopy.GetActors();
6661 anAllActors->InitTraversal();
6662 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6663 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6664 anActor->SetOpenGLClippingPlane();
6666 vtkView->getRenderer()->ResetCameraClippingRange();
6673 \brief Adds preferences for dfont of VTK viewer
6675 \param pIf group identifier
6676 \param param parameter
6677 \return identifier of preferences
6679 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6681 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6683 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6686 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6687 fam.append( tr( "SMESH_FONT_COURIER" ) );
6688 fam.append( tr( "SMESH_FONT_TIMES" ) );
6690 setPreferenceProperty( tfont, "fonts", fam );
6692 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6693 if ( needSize ) f = f | QtxFontEdit::Size;
6694 setPreferenceProperty( tfont, "features", f );
6700 \brief Actions after hypothesis edition
6701 Updates object browser after hypothesis edition
6703 void SMESHGUI::onHypothesisEdit( int result )
6706 SMESHGUI::Modified();
6707 updateObjBrowser( true );
6712 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6713 \param pview view being closed
6715 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6716 #ifndef DISABLE_PLOT2DVIEWER
6717 //Crear all Plot2d Viewers if need.
6718 SMESH::ClearPlot2Viewers(pview);
6722 void SMESHGUI::message( const QString& msg )
6725 QStringList data = msg.split("/");
6726 if ( data.count() > 0 ) {
6727 if ( data.first() == "mesh_loading" ) {
6729 QString entry = data.count() > 1 ? data[1] : QString();
6730 if ( entry.isEmpty() )
6733 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6735 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6738 name = QString::fromUtf8(obj->GetName().c_str());
6739 if ( name.isEmpty() )
6742 if ( data.last() == "stop" )
6743 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6745 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6746 QApplication::processEvents();
6752 \brief Connects or disconnects signals about activating and cloning view on the module slots
6753 \param pview view which is connected/disconnected
6755 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6759 SUIT_ViewManager* viewMgr = pview->getViewManager();
6761 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6762 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6764 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6765 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6770 \brief Return \c true if object can be renamed
6772 bool SMESHGUI::renameAllowed( const QString& entry) const {
6773 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6777 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6781 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6786 if(appStudy->isComponent(entry) || obj->isReference())
6789 // check type to prevent renaming of inappropriate objects
6790 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6791 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6792 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6793 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6794 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6795 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6802 Rename object by entry.
6803 \param entry entry of the object
6804 \param name new name of the object
6805 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6807 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6809 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6813 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6818 _PTR(Study) aStudy = appStudy->studyDS();
6823 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6825 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6830 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6831 _PTR(GenericAttribute) anAttr;
6832 _PTR(AttributeName) aName;
6834 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6836 // check type to prevent renaming of inappropriate objects
6837 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6838 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6839 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6840 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6841 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6842 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6843 if ( !name.isEmpty() ) {
6844 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6846 // update name of group object and its actor
6847 Handle(SALOME_InteractiveObject) IObject =
6848 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6850 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6851 if( !aGroupObject->_is_nil() ) {
6852 aGroupObject->SetName( qPrintable(name) );
6853 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6854 anActor->setName( qPrintable(name) );
6864 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6866 static QList<QColor> colors;
6868 if ( colors.isEmpty() ) {
6870 for (int s = 0; s < 2 ; s++)
6872 for (int v = 100; v >= 40; v = v - 20)
6874 for (int h = 0; h < 359 ; h = h + 60)
6876 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6881 static int currentColor = 0;
6883 SALOMEDS::Color color;
6884 color.R = (double)colors[currentColor].red() / 255.0;
6885 color.G = (double)colors[currentColor].green() / 255.0;
6886 color.B = (double)colors[currentColor].blue() / 255.0;
6888 currentColor = (currentColor+1) % colors.count();