1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
68 #include "SMESHGUI_PropertiesDlg.h"
69 #include "SMESHGUI_RemoveElementsDlg.h"
70 #include "SMESHGUI_RemoveNodesDlg.h"
71 #include "SMESHGUI_RenumberingDlg.h"
72 #include "SMESHGUI_ReorientFacesDlg.h"
73 #include "SMESHGUI_RevolutionDlg.h"
74 #include "SMESHGUI_RotationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_Selection.h"
77 #include "SMESHGUI_SewingDlg.h"
78 #include "SMESHGUI_SingleEditDlg.h"
79 #include "SMESHGUI_SmoothingDlg.h"
80 #include "SMESHGUI_SymmetryDlg.h"
81 #include "SMESHGUI_TranslationDlg.h"
82 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
87 #include "SMESHGUI_MeshUtils.h"
88 #include "SMESHGUI_PatternUtils.h"
89 #include "SMESHGUI_Utils.h"
90 #include "SMESHGUI_VTKUtils.h"
92 #include <SMESH_version.h>
94 #include "SMESH_ControlsDef.hxx"
95 #include <SMESH_Actor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_Client.hxx>
98 #include <SMESH_ScalarBarActor.h>
99 #include <SMESH_TypeFilter.hxx>
101 // SALOME GUI includes
102 #include <SalomeApp_Application.h>
103 #include <SalomeApp_CheckFileDlg.h>
104 #include <SalomeApp_DataObject.h>
105 #include <SalomeApp_Study.h>
106 #include <SalomeApp_Tools.h>
108 #include <LightApp_DataOwner.h>
109 #include <LightApp_NameDlg.h>
110 #include <LightApp_Preferences.h>
111 #include <LightApp_SelectionMgr.h>
112 #include <LightApp_UpdateFlags.h>
114 #include <SVTK_ViewManager.h>
115 #include <SVTK_ViewModel.h>
116 #include <SVTK_ViewWindow.h>
118 #include <VTKViewer_Algorithm.h>
120 #include <PyInterp_Interp.h>
122 #include <SUIT_Desktop.h>
123 #include <SUIT_FileDlg.h>
124 #include <SUIT_MessageBox.h>
125 #include <SUIT_OverrideCursor.h>
126 #include <SUIT_ResourceMgr.h>
127 #include <SUIT_Session.h>
129 #include <QtxPopupMgr.h>
130 #include <QtxFontEdit.h>
132 #include <SALOME_ListIO.hxx>
133 #include <SALOME_ListIteratorOfListIO.hxx>
135 #ifndef DISABLE_PLOT2DVIEWER
136 #include <SPlot2d_ViewModel.h>
137 #include <SPlot2d_Histogram.h>
141 #include <SALOMEconfig.h>
142 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
143 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
144 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QTextStream>
153 #include <boost/shared_ptr.hpp>
156 #include <vtkCallbackCommand.h>
157 #include <vtkCamera.h>
158 #include <vtkLookupTable.h>
159 #include <vtkPlane.h>
160 #include <vtkRenderer.h>
162 // SALOME KERNEL includes
163 #include <SALOMEDSClient_ClientFactory.hxx>
164 #include <SALOMEDSClient_IParameters.hxx>
165 #include <SALOMEDSClient_SComponent.hxx>
166 #include <SALOMEDSClient_StudyBuilder.hxx>
167 #include <SALOMEDS_Study.hxx>
168 #include <SALOMEDS_SObject.hxx>
171 #include <Standard_ErrorHandler.hxx>
172 #include <NCollection_DataMap.hxx>
174 #include <Basics_Utils.hxx>
176 //To disable automatic genericobj management, the following line should be commented.
177 //Otherwise, it should be uncommented.
178 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
179 #define WITHGENERICOBJ
181 // Below macro, when uncommented, switches on simplified (more performant) algorithm
182 // of auto-color picking up
183 #define SIMPLE_AUTOCOLOR
185 // REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1
186 #include <vtkMatplotlibMathTextUtilities.h>
189 // Creation of this class disables vtkMatplotlibMathTextUtilities
190 struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities
192 MPLMathText_Disabler()
194 vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
195 vtkMatplotlibMathTextUtilities::UNAVAILABLE;
203 //=============================================================
204 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
207 void ExportMeshToFile(int theCommandID);
209 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
211 void SetDisplayEntity(int theCommandID);
213 void Control( int theCommandID );
216 //================================================================================
218 * \brief Reads meshes from file
220 //================================================================================
222 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
226 std::string myExtension;
228 if ( theCommandID == 113 ) {
229 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
230 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
232 else if ( theCommandID == 112 ) {
233 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
235 else if ( theCommandID == 111 ) {
236 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
238 else if ( theCommandID == 115 ) {
239 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
241 else if ( theCommandID == 116 ) {
242 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
244 else if ( theCommandID == 117 ) {
245 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
246 filter.append( QObject::tr( "All files (*)" ) );
248 else if ( theCommandID == 118 ) {
249 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
250 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
253 QString anInitialPath = "";
254 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
255 anInitialPath = QDir::currentPath();
257 QStringList filenames;
258 bool toCreateGroups = true;
260 // if ( theCommandID == 118 ) { // GMF
261 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
262 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
263 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
264 // fd->setNameFilters( filter );
265 // fd->SetChecked( true );
267 // filenames << fd->selectedFile();
268 // toCreateGroups = fd->IsChecked();
274 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_IMPORT_MESH" ) );
279 if ( filenames.count() > 0 ) {
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
287 QString filename = *it;
288 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
290 switch ( theCommandID ) {
293 // DAT format (currently unsupported)
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
301 aMeshes->length( 1 );
302 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
303 if ( aMeshes[0]->_is_nil() )
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 SMESH::DriverMED_ReadStatus res;
312 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
313 if ( res != SMESH::DRS_OK ) {
314 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
315 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
322 aMeshes->length( 1 );
323 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
324 if ( aMeshes[0]->_is_nil() ) {
325 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
326 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
333 SMESH::DriverMED_ReadStatus res;
334 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
335 if ( res != SMESH::DRS_OK ) {
336 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
337 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 SMESH::DriverMED_ReadStatus res;
345 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
346 if ( res != SMESH::DRS_OK ) {
347 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
348 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
355 SMESH::ComputeError_var res;
356 aMeshes->length( 1 );
357 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
360 if ( res->code != SMESH::DRS_OK ) {
361 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
362 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
363 if ( strlen( res->comment.in() ) > 0 ) {
364 errors.back() += ": ";
365 errors.back() += res->comment.in();
372 catch ( const SALOME::SALOME_Exception& S_ex ) {
373 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
374 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
377 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
378 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
380 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
381 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
382 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
383 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
384 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
386 anEntryList.append( aMeshSO->GetID().c_str() );
394 // update Object browser
395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
397 // browse to the published meshes
398 if( LightApp_Application* anApp =
399 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
400 anApp->browseObjects( anEntryList );
402 // show Error message box if there were errors
403 if ( errors.count() > 0 ) {
404 SUIT_MessageBox::critical( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_ERROR" ),
406 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
409 // show warning message box, if some imported mesh is empty
411 SUIT_MessageBox::warning( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_WRN_WARNING" ),
413 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
418 //================================================================================
420 * \brief Export selected meshes or groups into a file
422 //================================================================================
424 void ExportMeshToFile( int theCommandID )
426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
427 SALOME_ListIO selected;
429 aSel->selectedObjects( selected );
431 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
432 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
433 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
434 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
435 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
436 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
437 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
439 // actually, the following condition can't be met (added for insurance)
440 if( selected.Extent() == 0 ||
441 ( selected.Extent() > 1 && !isMED && !isSTL ))
444 // get mesh object from selection and check duplication of their names
445 bool hasDuplicatedMeshNames = false;
446 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
447 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
448 SALOME_ListIteratorOfListIO It( selected );
449 for( ; It.More(); It.Next() )
451 Handle(SALOME_InteractiveObject) anIObject = It.Value();
452 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
453 if ( aMeshItem->_is_nil() ) {
454 SUIT_MessageBox::warning( SMESHGUI::desktop(),
455 QObject::tr( "SMESH_WRN_WARNING" ),
456 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
460 QString aMeshName = anIObject->getName();
462 // check for name duplications
463 if ( !hasDuplicatedMeshNames )
464 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
465 if( aMeshName == (*aMeshIter).second ) {
466 hasDuplicatedMeshNames = true;
471 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
474 if( hasDuplicatedMeshNames && isMED ) {
475 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
476 QObject::tr("SMESH_WRN_WARNING"),
477 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
478 QObject::tr("SMESH_BUT_YES"),
479 QObject::tr("SMESH_BUT_NO"), 0, 1);
484 aMeshIter = aMeshList.begin();
485 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
486 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
487 QString aMeshName = (*aMeshIter).second;
489 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
491 // check for equal group names within each mesh
492 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
493 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
494 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
495 int aRet = SUIT_MessageBox::warning
496 (SMESHGUI::desktop(),
497 QObject::tr("SMESH_WRN_WARNING"),
498 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
499 QObject::tr("SMESH_BUT_YES"),
500 QObject::tr("SMESH_BUT_NO"), 0, 1);
507 // Warn the user about presence of not supported elements
509 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
513 notSupportedElemTypes.push_back( SMESH::Entity_0D );
514 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
519 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
520 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
522 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
523 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
524 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
525 notSupportedElemTypes.push_back( SMESH::Entity_0D );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
531 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
532 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
533 notSupportedElemTypes.push_back( SMESH::Entity_0D );
534 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
539 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
540 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
546 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
547 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
548 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
549 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
556 notSupportedElemTypes.push_back( SMESH::Entity_0D );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
559 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
561 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
562 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
563 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 if ( ! notSupportedElemTypes.empty() )
568 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
569 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
570 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
571 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
573 if ( !presentNotSupported.empty() )
576 const char* typeMsg[SMESH::Entity_Last] = {
577 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
578 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
579 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
580 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
581 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
582 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
583 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
584 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
586 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
587 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
588 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
589 if ( iType != presentNotSupported.size() - 1 )
590 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
592 int aRet = SUIT_MessageBox::warning
593 (SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
596 QObject::tr("SMESH_BUT_YES"),
597 QObject::tr("SMESH_BUT_NO"), 0, 1);
602 // Get parameters of export operation
605 SMESH::MED_VERSION aFormat;
606 // Init the parameters with the default values
607 bool aIsASCII_STL = true;
608 bool toCreateGroups = false;
609 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
611 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
612 bool toOverwrite = true;
613 bool toFindOutDim = true;
615 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
616 QString anInitialPath = "";
617 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
618 anInitialPath = QDir::currentPath();
620 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
622 // Get a file name to write in and additional otions
623 if ( isUNV || isDAT || isGMF ) // Export w/o options
626 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
628 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
630 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
631 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
632 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
633 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
634 anInitialPath + QString("/") + aMeshName,
635 aFilter, aTitle, false);
637 else if ( isCGNS )// Export to CGNS
639 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
640 fd->setWindowTitle( aTitle );
641 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
642 if ( !anInitialPath.isEmpty() )
643 fd->setDirectory( anInitialPath );
644 fd->selectFile(aMeshName);
645 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
646 fd->setValidator( fv );
649 aFilename = fd->selectedFile();
650 toOverwrite = fv->isOverwrite();
654 else if ( isSTL ) // Export to STL
656 QMap<QString, int> aFilterMap;
657 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
658 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
661 QMap<QString, int>::const_iterator it = aFilterMap.begin();
662 for ( ; it != aFilterMap.end(); ++it )
663 filters.push_back( it.key() );
665 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
666 fd->setWindowTitle( aTitle );
667 fd->setNameFilters( filters );
668 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
669 if ( !anInitialPath.isEmpty() )
670 fd->setDirectory( anInitialPath );
671 fd->selectFile(aMeshName);
675 aFilename = fd->selectedFile();
676 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
681 else if ( isMED || isSAUV ) // Export to MED or SAUV
683 QMap<QString, SMESH::MED_VERSION> aFilterMap;
684 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
686 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
687 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
688 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
691 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
692 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
693 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
697 QString aDefaultFilter;
698 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
699 for ( ; it != aFilterMap.end(); ++it ) {
700 filters.push_back( it.key() );
701 if (it.value() == SMESH::MED_V2_2)
702 aDefaultFilter = it.key();
704 QStringList checkBoxes;
705 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
707 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
708 QList< QWidget* > wdgList;
709 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
710 wdgList.append( fieldSelWdg );
712 SalomeApp_CheckFileDlg* fd =
713 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
714 fd->setWindowTitle( aTitle );
715 fd->setNameFilters( filters );
716 fd->selectNameFilter( aDefaultFilter );
717 fd->SetChecked( toCreateGroups, 0 );
718 fd->SetChecked( toFindOutDim, 1 );
719 if ( !anInitialPath.isEmpty() )
720 fd->setDirectory( anInitialPath );
721 fd->selectFile(aMeshName);
723 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
724 fd->setValidator( fv );
729 aFilename = fd->selectedFile();
731 aFilename = QString::null;
734 aFormat = aFilterMap[fd->selectedNameFilter()];
735 toOverwrite = fv->isOverwrite();
737 if ( !aFilename.isEmpty() ) {
738 // med-2.1 does not support poly elements
739 if ( aFormat==SMESH::MED_V2_1 )
740 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
741 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
742 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
743 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
744 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
746 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
747 QObject::tr("SMESH_WRN_WARNING"),
748 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
749 QObject::tr("SMESH_BUT_YES"),
750 QObject::tr("SMESH_BUT_NO"), 0, 1);
758 // can't append to an existing using other format
759 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
760 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
761 if( !isVersionOk || aVersion != aFormat ) {
762 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
763 QObject::tr("SMESH_WRN_WARNING"),
764 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
765 QObject::tr("SMESH_BUT_YES"),
766 QObject::tr("SMESH_BUT_NO"), 0, 1);
773 QStringList aMeshNamesCollisionList;
774 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
775 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
776 QString anExistingMeshName( aMeshNames[ i ] );
777 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
778 QString anExportMeshName = (*aMeshIter).second;
779 if( anExportMeshName == anExistingMeshName ) {
780 aMeshNamesCollisionList.append( anExportMeshName );
785 if( !aMeshNamesCollisionList.isEmpty() ) {
786 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
787 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
788 QObject::tr("SMESH_WRN_WARNING"),
789 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
790 QObject::tr("SMESH_BUT_YES"),
791 QObject::tr("SMESH_BUT_NO"),
792 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
801 toCreateGroups = fd->IsChecked(0);
802 toFindOutDim = fd->IsChecked(1);
803 fieldSelWdg->GetSelectedFeilds();
804 if ( !fieldSelWdg->parent() )
815 if ( !aFilename.isEmpty() ) {
816 // Check whether the file already exists and delete it if yes
817 QFile aFile( aFilename );
818 if ( aFile.exists() && toOverwrite )
820 SUIT_OverrideCursor wc;
823 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
824 // bool Renumber = false;
825 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
827 // Renumber= resMgr->booleanValue("renumbering");
829 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
830 // aMeshEditor->RenumberNodes();
831 // aMeshEditor->RenumberElements();
832 // if ( SMESHGUI::automaticUpdate() )
833 // SMESH::UpdateView();
837 aMeshIter = aMeshList.begin();
838 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
840 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
841 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
842 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
843 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
844 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
845 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
846 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
847 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
849 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
850 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
851 fields, geoAssFields.toLatin1().data() );
856 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
858 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
859 if( !aMeshItem->_is_nil() )
860 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
865 if ( aMeshOrGroup->_is_equivalent( aMesh ))
866 aMesh->ExportDAT( aFilename.toUtf8().data() );
868 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
872 if ( aMeshOrGroup->_is_equivalent( aMesh ))
873 aMesh->ExportUNV( aFilename.toUtf8().data() );
875 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
879 if ( aMeshOrGroup->_is_equivalent( aMesh ))
880 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
882 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
886 aMeshIter = aMeshList.begin();
887 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
889 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
890 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
891 aMeshItem->ExportCGNS( aMeshOrGroup,
892 aFilename.toUtf8().data(),
893 toOverwrite && aMeshIndex == 0 );
898 toCreateGroups = true;
899 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
902 catch (const SALOME::SALOME_Exception& S_ex){
904 SUIT_MessageBox::warning(SMESHGUI::desktop(),
905 QObject::tr("SMESH_WRN_WARNING"),
906 QObject::tr("SMESH_EXPORT_FAILED"));
912 inline void InverseEntityMode(unsigned int& theOutputMode,
913 unsigned int theMode)
915 bool anIsNotPresent = ~theOutputMode & theMode;
917 theOutputMode |= theMode;
919 theOutputMode &= ~theMode;
922 void SetDisplayEntity(int theCommandID){
923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
924 SALOME_ListIO selected;
926 aSel->selectedObjects( selected );
928 if(selected.Extent() >= 1){
929 SALOME_ListIteratorOfListIO It( selected );
930 for( ; It.More(); It.Next()){
931 Handle(SALOME_InteractiveObject) IObject = It.Value();
932 if(IObject->hasEntry()){
933 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
934 unsigned int aMode = anActor->GetEntityMode();
935 switch(theCommandID){
937 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
940 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
943 InverseEntityMode(aMode,SMESH_Actor::eEdges);
946 InverseEntityMode(aMode,SMESH_Actor::eFaces);
949 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
952 aMode = SMESH_Actor::eAllEntity;
956 anActor->SetEntityMode(aMode);
965 SALOME_ListIO selected;
966 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
970 LightApp_SelectionMgr* aSel = app->selectionMgr();
971 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
972 if( !aSel || !appStudy )
975 aSel->selectedObjects( selected );
976 if( selected.IsEmpty() )
979 Handle(SALOME_InteractiveObject) anIObject = selected.First();
981 _PTR(Study) aStudy = appStudy->studyDS();
982 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
983 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
984 if( aMainObject->_is_nil() )
987 SUIT_OverrideCursor wc;
989 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
991 QList<SALOMEDS::Color> aReservedColors;
993 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
994 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
996 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
997 //SALOMEDS::Color aColor = aGroupObject->GetColor();
999 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1000 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1001 #else // old algorithm for auto-colors
1002 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1003 aReservedColors.append( aColor );
1004 #endif // SIMPLE_AUTOCOLOR
1005 aGroupObject->SetColor( aColor );
1007 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1008 if (aGroupSObject) {
1011 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1012 switch ( aGroupObject->GetType ()) {
1014 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1016 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1018 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1020 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1022 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1023 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1026 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1027 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1033 SMESH::RepaintCurrentView();
1036 void OverallMeshQuality() {
1037 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1039 SALOME_ListIO selected;
1041 aSel->selectedObjects( selected );
1043 if ( selected.IsEmpty() ) return;
1044 SALOME_ListIteratorOfListIO It( selected );
1045 for ( ; It.More(); It.Next() ) {
1046 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1047 ctrlDlg->showInfo( It.Value() );
1052 QString functorToString( SMESH::Controls::FunctorPtr f )
1054 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1055 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1056 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1057 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1058 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1059 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1060 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1061 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1062 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1063 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1064 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1065 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1066 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1067 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1068 type = QObject::tr( "WARP_ELEMENTS" );
1069 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1070 type = QObject::tr( "TAPER_ELEMENTS" );
1071 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1072 type = QObject::tr( "SKEW_ELEMENTS" );
1073 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1074 type = QObject::tr( "AREA_ELEMENTS" );
1075 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1076 type = QObject::tr( "LENGTH_EDGES" );
1077 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1078 type = QObject::tr( "LENGTH2D_EDGES" );
1079 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1080 type = QObject::tr( "MULTI_BORDERS" );
1081 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1082 type = QObject::tr( "MULTI2D_BORDERS" );
1083 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1084 type = QObject::tr( "FREE_NODES" );
1085 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1086 type = QObject::tr( "FREE_EDGES" );
1087 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1088 type = QObject::tr( "FREE_BORDERS" );
1089 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1090 type = QObject::tr( "FREE_FACES" );
1091 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1092 type = QObject::tr( "BARE_BORDER_VOLUME" );
1093 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1094 type = QObject::tr( "BARE_BORDER_FACE" );
1095 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1096 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1097 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1098 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1099 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1100 type = QObject::tr( "EQUAL_NODE" );
1101 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1102 type = QObject::tr( "EQUAL_EDGE" );
1103 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1104 type = QObject::tr( "EQUAL_FACE" );
1105 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1106 type = QObject::tr( "EQUAL_VOLUME" );
1110 void SaveDistribution()
1112 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1113 SALOME_ListIO selected;
1115 aSel->selectedObjects( selected );
1117 if ( selected.Extent() == 1 ) {
1118 Handle(SALOME_InteractiveObject) anIO = selected.First();
1119 if ( anIO->hasEntry() ) {
1120 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1121 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1122 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1123 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1124 if ( aScalarBarActor && aFunctor ) {
1125 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1127 std::vector<int> elements;
1128 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1129 if ( mesh->_is_nil() ) {
1130 SMESH::SMESH_IDSource_var idSource =
1131 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1132 if ( !idSource->_is_nil() )
1134 SMESH::long_array_var ids = idSource->GetIDs();
1135 elements.resize( ids->length() );
1136 for ( unsigned i = 0; i < elements.size(); ++i )
1137 elements[i] = ids[i];
1140 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1141 vtkLookupTable* lookupTable =
1142 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1143 double * minmax = lookupTable->GetRange();
1144 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1145 std::vector<int> nbEvents;
1146 std::vector<double> funValues;
1147 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1148 QString anInitialPath = "";
1149 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1150 anInitialPath = QDir::currentPath();
1151 QString aMeshName = anIO->getName();
1153 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1154 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1155 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1156 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1157 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1160 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1162 if ( !aFilename.isEmpty() ) {
1163 QFile f( aFilename );
1164 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1165 QTextStream out( &f );
1166 out << "# Mesh: " << aMeshName << endl;
1167 out << "# Control: " << functorToString( aFunctor ) << endl;
1169 out.setFieldWidth( 10 );
1170 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1171 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1182 void ShowDistribution() {
1183 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1184 SALOME_ListIO selected;
1186 aSel->selectedObjects( selected );
1188 if ( selected.Extent() == 1 ) {
1189 Handle(SALOME_InteractiveObject) anIO = selected.First();
1190 if ( anIO->hasEntry() ) {
1191 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1192 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1193 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1194 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1200 #ifndef DISABLE_PLOT2DVIEWER
1201 void PlotDistribution() {
1202 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1206 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1207 SALOME_ListIO selected;
1209 aSel->selectedObjects( selected );
1211 if ( selected.Extent() == 1 ) {
1212 Handle(SALOME_InteractiveObject) anIO = selected.First();
1213 if ( anIO->hasEntry() ) {
1214 //Find Actor by entry before getting Plot2d viewer,
1215 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1216 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1218 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1223 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1227 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1231 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1232 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1233 QString functorName = functorToString( anActor->GetFunctor());
1234 QString aHistogramName("%1 : %2");
1235 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1236 aHistogram->setName(aHistogramName);
1237 aHistogram->setHorTitle(functorName);
1238 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1239 aPlot->displayObject(aHistogram, true);
1244 #endif //DISABLE_PLOT2DVIEWER
1246 void DisableAutoColor(){
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if(selected.Extent()){
1253 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1254 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1255 if ( !aMesh->_is_nil() ) {
1256 aMesh->SetAutoColor( false );
1261 void sortChildren(){
1262 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1263 SALOME_ListIO selected;
1265 aSel->selectedObjects( selected );
1267 if(selected.Extent()){
1268 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1269 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1270 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1272 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1273 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1280 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1282 SALOME_ListIO selected;
1283 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1287 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1288 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1289 if( !aSel || !appStudy )
1292 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1293 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1294 aModule->EmitSignalDeactivateDialog();
1295 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1296 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1301 _PTR(Study) aStudy = appStudy->studyDS();
1303 aSel->selectedObjects( selected );
1305 if(selected.Extent() >= 1){
1306 switch(theCommandID){
1308 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1309 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1314 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1315 QColor orientationColor, outlineColor, volumeColor;
1316 int deltaF = 0, deltaV = 0;
1321 int outlineWidth = 1;
1322 double shrinkCoef = 0.0;
1323 double orientationScale = 0.0;
1324 bool orientation3d = false;
1325 VTK::MarkerType markerType = VTK::MT_NONE;
1326 VTK::MarkerScale markerScale = VTK::MS_NONE;
1328 bool hasNodes = false;
1329 int presentEntities = 0;
1330 bool firstTime = true;
1332 SALOME_ListIteratorOfListIO It( selected );
1333 for ( ; It.More(); It.Next() ) {
1334 Handle(SALOME_InteractiveObject) IObject = It.Value();
1335 if ( !IObject->hasEntry() ) continue;
1336 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1337 if ( !anActor || !anActor->GetObject() ) continue;
1340 // nodes: color, marker
1341 anActor->GetNodeColor( color[0], color[1], color[2] );
1342 nodeColor.setRgbF( color[0], color[1], color[2] );
1343 markerType = anActor->GetMarkerType();
1344 markerScale = anActor->GetMarkerScale();
1345 markerId = anActor->GetMarkerTexture();
1346 // edges: color, width
1347 anActor->GetEdgeColor( color[0], color[1], color[2] );
1348 edgeColor.setRgbF( color[0], color[1], color[2] );
1349 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1350 // faces: front color, back color (delta)
1351 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1352 faceColor.setRgbF( color[0], color[1], color[2] );
1353 // faces: front color, back color (delta)
1354 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1355 volumeColor.setRgbF( color[0], color[1], color[2] );
1356 // 0d elements: color, size
1357 anActor->Get0DColor( color[0], color[1], color[2] );
1358 elem0dColor.setRgbF( color[0], color[1], color[2] );
1359 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1360 // balls: color, size
1361 anActor->GetBallColor( color[0], color[1], color[2] );
1362 ballColor.setRgbF( color[0], color[1], color[2] );
1363 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1364 ballScale = qMax( (int)anActor->GetBallScale(), 1 ); // minimum allowed size is 1
1366 anActor->GetOutlineColor( color[0], color[1], color[2] );
1367 outlineColor.setRgbF( color[0], color[1], color[2] );
1368 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1369 // orientation vectors: color, scale, 3d flag
1370 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1371 orientationColor.setRgbF( color[0], color[1], color[2] );
1372 orientationScale = anActor->GetFacesOrientationScale();
1373 orientation3d = anActor->GetFacesOrientation3DVectors();
1375 shrinkCoef = anActor->GetShrinkFactor();
1378 firstTime = false; // we only take properties from first object (for performance reasons)
1381 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1382 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1383 presentEntities = presentEntities | SMESH_Actor::eEdges;
1384 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1385 presentEntities = presentEntities | SMESH_Actor::eFaces;
1386 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1387 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1388 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1389 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1390 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1391 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1393 // as we know that all types of elements are present, we can exit the loop
1394 if ( presentEntities == SMESH_Actor::eAllEntity )
1398 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1399 // nodes: color, marker
1400 dlg.setNodeColor( nodeColor );
1401 if( markerType != VTK::MT_USER )
1402 dlg.setNodeMarker( markerType, markerScale );
1404 dlg.setNodeCustomMarker( markerId );
1405 // edges: color, line width
1406 dlg.setEdgeColor( edgeColor );
1407 dlg.setEdgeWidth( edgeWidth );
1408 // faces: front color, back color
1409 dlg.setFaceColor( faceColor, deltaF );
1410 // volumes: normal color, reversed color
1411 dlg.setVolumeColor( volumeColor, deltaV );
1412 // outlines: color, line width
1413 dlg.setOutlineColor( outlineColor );
1414 dlg.setOutlineWidth( outlineWidth );
1415 // 0d elements: color, size
1416 dlg.setElem0dColor( elem0dColor );
1417 dlg.setElem0dSize( elem0dSize );
1418 // balls: color, size
1419 dlg.setBallColor( ballColor );
1420 dlg.setBallSize( ballSize );
1421 dlg.setBallScale( ballScale );
1422 // orientation: color, scale, 3d flag
1423 dlg.setOrientationColor( orientationColor );
1424 dlg.setOrientationSize( int( orientationScale * 100. ) );
1425 dlg.setOrientation3d( orientation3d );
1426 // shrink: scale factor
1427 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1428 // hide unused controls
1429 dlg.showControls( presentEntities, hasNodes );
1432 nodeColor = dlg.nodeColor();
1433 markerType = dlg.nodeMarkerType();
1434 markerScale = dlg.nodeMarkerScale();
1435 markerId = dlg.nodeMarkerId();
1436 edgeColor = dlg.edgeColor();
1437 edgeWidth = dlg.edgeWidth();
1438 faceColor = dlg.faceColor();
1439 deltaF = dlg.faceColorDelta();
1440 volumeColor = dlg.volumeColor();
1441 deltaV = dlg.volumeColorDelta();
1442 outlineColor = dlg.outlineColor();
1443 outlineWidth = dlg.outlineWidth();
1444 elem0dColor = dlg.elem0dColor();
1445 elem0dSize = dlg.elem0dSize();
1446 ballColor = dlg.ballColor();
1447 ballSize = dlg.ballSize();
1448 ballScale = dlg.ballScale();
1449 orientationColor = dlg.orientationColor();
1450 orientationScale = dlg.orientationSize() / 100.;
1451 orientation3d = dlg.orientation3d();
1452 shrinkCoef = dlg.shrinkCoef() / 100.;
1454 // store point markers map that might be changed by the user
1455 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1457 // set properties from dialog box to the presentations
1458 SALOME_ListIteratorOfListIO It( selected );
1459 for ( ; It.More(); It.Next() ) {
1460 Handle(SALOME_InteractiveObject) IObject = It.Value();
1461 if ( !IObject->hasEntry() ) continue;
1462 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1463 if ( !anActor ) continue;
1465 // nodes: color, marker
1466 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1467 if ( markerType != VTK::MT_USER ) {
1468 anActor->SetMarkerStd( markerType, markerScale );
1471 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1472 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1473 if ( iter != markerMap.end() )
1474 anActor->SetMarkerTexture( markerId, iter->second.second );
1476 // volumes: normal color, reversed color (delta)
1477 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1478 // faces: front color, back color (delta)
1479 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1480 // edges: color, width
1481 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1482 anActor->SetLineWidth( edgeWidth );
1484 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1485 anActor->SetOutlineWidth( outlineWidth );
1486 // 0D elements: color, size
1487 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1488 anActor->Set0DSize( elem0dSize );
1489 // balls: color, size
1490 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1491 anActor->SetBallSize( ballSize );
1492 anActor->SetBallScale( ballScale );
1493 // orientation: color, scale, 3d flag
1494 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1495 anActor->SetFacesOrientationScale( orientationScale );
1496 anActor->SetFacesOrientation3DVectors( orientation3d );
1498 anActor->SetShrinkFactor( shrinkCoef );
1500 // for groups, set also proper color
1501 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1502 if ( !aGroupObject->_is_nil() ) {
1503 SMESH::ElementType anElementType = aGroupObject->GetType();
1505 switch( anElementType ) {
1507 aColor = nodeColor; break;
1509 aColor = edgeColor; break;
1511 aColor = faceColor; break;
1513 aColor = volumeColor; break;
1515 aColor = elem0dColor; break;
1517 aColor = ballColor; break;
1521 if ( aColor.isValid() ) {
1522 SALOMEDS::Color aGroupColor;
1523 aGroupColor.R = aColor.redF();
1524 aGroupColor.G = aColor.greenF();
1525 aGroupColor.B = aColor.blueF();
1526 aGroupObject->SetColor( aGroupColor );
1528 } // if ( !aGroupObject->_is_nil() )
1529 } // for ( ; It.More(); It.Next() )
1530 SMESH::RepaintCurrentView();
1531 } // if ( dlg.exec() )
1534 } // switch(theCommandID)
1535 SALOME_ListIteratorOfListIO It( selected );
1536 for( ; It.More(); It.Next()){
1537 Handle(SALOME_InteractiveObject) IObject = It.Value();
1538 if(IObject->hasEntry()){
1539 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1540 switch(theCommandID){
1542 anActor->SetRepresentation(SMESH_Actor::eEdge);
1545 anActor->SetRepresentation(SMESH_Actor::eSurface);
1548 if(anActor->IsShrunk())
1549 anActor->UnShrink();
1551 anActor->SetShrink();
1554 anActor->SetRepresentation(SMESH_Actor::ePoint);
1557 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1558 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1561 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1562 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1568 SMESH::RepaintCurrentView();
1572 void Control( int theCommandID )
1574 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1575 SALOME_ListIO selected;
1577 aSel->selectedObjects( selected );
1579 if( !selected.IsEmpty() ){
1580 Handle(SALOME_InteractiveObject) anIO = selected.First();
1582 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1583 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1584 switch ( theCommandID ){
1586 aControl = SMESH_Actor::eLength;
1589 aControl = SMESH_Actor::eLength2D;
1592 aControl = SMESH_Actor::eFreeEdges;
1595 aControl = SMESH_Actor::eFreeBorders;
1598 aControl = SMESH_Actor::eMultiConnection;
1601 aControl = SMESH_Actor::eFreeNodes;
1604 aControl = SMESH_Actor::eMultiConnection2D;
1607 aControl = SMESH_Actor::eArea;
1610 aControl = SMESH_Actor::eTaper;
1613 aControl = SMESH_Actor::eAspectRatio;
1616 aControl = SMESH_Actor::eAspectRatio3D;
1619 aControl = SMESH_Actor::eMinimumAngle;
1622 aControl = SMESH_Actor::eWarping;
1625 aControl = SMESH_Actor::eSkew;
1628 aControl = SMESH_Actor::eVolume3D;
1631 aControl = SMESH_Actor::eFreeFaces;
1634 aControl = SMESH_Actor::eMaxElementLength2D;
1637 aControl = SMESH_Actor::eMaxElementLength3D;
1640 aControl = SMESH_Actor::eBareBorderVolume;
1643 aControl = SMESH_Actor::eBareBorderFace;
1646 aControl = SMESH_Actor::eOverConstrainedVolume;
1649 aControl = SMESH_Actor::eOverConstrainedFace;
1652 aControl = SMESH_Actor::eCoincidentNodes;
1655 aControl = SMESH_Actor::eCoincidentElems1D;
1658 aControl = SMESH_Actor:: eCoincidentElems2D;
1661 aControl = SMESH_Actor::eCoincidentElems3D;
1665 anActor->SetControlMode(aControl);
1666 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1667 SMESH::RepaintCurrentView();
1668 #ifndef DISABLE_PLOT2DVIEWER
1669 if(anActor->GetPlot2Histogram()) {
1670 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1671 QString functorName = functorToString( anActor->GetFunctor());
1672 QString aHistogramName("%1 : %2");
1673 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1674 aHistogram->setName(aHistogramName);
1675 aHistogram->setHorTitle(functorName);
1676 SMESH::ProcessIn2DViewers(anActor);
1685 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1686 SMESH::MeshObjectType theType,
1687 const QString theInTypeName,
1688 QString & theOutTypeName)
1690 SMESH_TypeFilter aTypeFilter( theType );
1692 if( !theIO.IsNull() )
1694 entry = theIO->getEntry();
1695 LightApp_DataOwner owner( entry );
1696 if ( aTypeFilter.isOk( &owner )) {
1697 theOutTypeName = theInTypeName;
1705 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1707 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1708 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1710 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1711 CORBA::String_var anID = aSComp->GetID().c_str();
1712 if (!strcmp(anID.in(),theIO->getEntry()))
1718 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1719 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1720 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1721 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1722 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1730 QString CheckHomogeneousSelection()
1732 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1733 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1734 SALOME_ListIO selected;
1736 aSel->selectedObjects( selected );
1738 QString RefType = CheckTypeObject(selected.First());
1739 SALOME_ListIteratorOfListIO It(selected);
1740 for ( ; It.More(); It.Next())
1742 Handle(SALOME_InteractiveObject) IObject = It.Value();
1743 QString Type = CheckTypeObject(IObject);
1744 if (Type.compare(RefType) != 0)
1745 return "Heterogeneous Selection";
1753 void SMESHGUI::OnEditDelete()
1755 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1756 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1757 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1759 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1760 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1761 _PTR(GenericAttribute) anAttr;
1762 _PTR(AttributeIOR) anIOR;
1764 int objectCount = 0;
1766 QString aParentComponent = QString::null;
1767 Handle(SALOME_InteractiveObject) anIO;
1768 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1770 anIO = anIt.Value();
1771 QString cur = anIO->getComponentDataType();
1772 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1774 // check if object is reference
1775 _PTR(SObject) aRefSObj;
1776 aNameList.append("\n - ");
1777 if ( aSO->ReferencedObject( aRefSObj ) ) {
1778 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1779 aNameList.append( aRefName );
1780 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1783 aNameList.append(anIO->getName());
1787 if( aParentComponent.isNull() )
1788 aParentComponent = cur;
1789 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1790 aParentComponent = "";
1793 if ( objectCount == 0 )
1794 return; // No Valid Objects Selected
1796 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1797 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1798 QObject::tr("ERR_ERROR"),
1799 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1802 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1803 if (SUIT_MessageBox::warning
1804 (SMESHGUI::desktop(),
1805 QObject::tr("SMESH_WRN_WARNING"),
1806 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1807 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1808 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1811 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1813 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1814 // then treat them all starting from the deepest objects (at list back)
1815 std::list< _PTR(SObject) > listSO;
1816 SALOME_ListIteratorOfListIO It(selected);
1817 for( ; It.More(); It.Next()) // loop on selected IO's
1819 Handle(SALOME_InteractiveObject) IObject = It.Value();
1820 if(IObject->hasEntry()) {
1821 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1823 // disable removal of "SMESH" component object
1824 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1826 if ( engineIOR() == anIOR->Value().c_str() )
1829 //Check the referenced object
1830 _PTR(SObject) aRefSObject;
1831 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1832 aSO = aRefSObject; // Delete main Object instead of reference
1834 listSO.push_back( aSO );
1835 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1836 for ( ; itSO != listSO.end(); ++itSO ) {
1837 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1838 for (it->InitEx(false); it->More(); it->Next())
1839 listSO.push_back( it->Value() );
1843 // Check if none of objects to delete is referred from outside
1844 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1845 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1847 _PTR(SObject) SO = *ritSO;
1848 if ( !SO ) continue;
1849 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1850 for (size_t i = 0; i < aReferences.size(); i++) {
1851 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1852 std::string type = aComponent->ComponentDataType();
1853 if ( type != "SMESH" )
1855 SUIT_MessageBox::warning( anApp->desktop(),
1856 QObject::tr("WRN_WARNING"),
1857 QObject::tr("DEP_OBJECT") );
1858 return; // outside SMESH, there is an object depending on a SMESH object
1863 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1864 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1866 Handle(SALOME_InteractiveObject) IObject = It.Value();
1867 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1868 if ( !mesh->_is_nil() )
1872 // Treat SO's in the list starting from the back
1873 aStudyBuilder->NewCommand(); // There is a transaction
1874 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1876 _PTR(SObject) SO = *ritSO;
1877 if ( !SO ) continue;
1878 std::string anEntry = SO->GetID();
1880 /** Erase graphical object and remove all its data **/
1881 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1882 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1884 /** Remove an object from data structures **/
1885 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1886 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1887 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1888 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1889 aMesh->RemoveGroup( aGroup );
1891 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1892 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1893 aMesh->RemoveSubMesh( aSubMesh );
1895 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1897 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1900 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1901 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1902 QString objType = CheckTypeObject(IObject);
1903 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1904 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1905 aStudyBuilder->RemoveObjectWithChildren( SO );
1907 else {// default action: remove SObject from the study
1908 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1909 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1911 aStudyBuilder->RemoveObjectWithChildren( SO );
1915 } /* listSO back loop */
1917 aStudyBuilder->CommitCommand();
1919 /* Clear any previous selection */
1921 aSel->setSelectedObjects( l1 );
1923 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1927 SMESHGUI_EXPORT CAM_Module* createModule()
1929 return new SMESHGUI();
1932 SMESHGUI_EXPORT char* getModuleVersion() {
1933 return (char*)SMESH_VERSION_STR;
1937 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1939 //=============================================================================
1943 //=============================================================================
1944 SMESHGUI::SMESHGUI() :
1945 SalomeApp_Module( "SMESH" )
1947 if ( CORBA::is_nil( myComponentSMESH ) )
1949 CORBA::Boolean anIsEmbeddedMode;
1950 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1951 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1953 // 0019923: EDF 765 SMESH : default values of hypothesis
1954 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1955 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1956 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1957 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1958 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1960 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1961 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1962 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1964 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1965 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1969 myActiveDialogBox = 0;
1970 myFilterLibraryDlg = 0;
1974 myEventCallbackCommand = vtkCallbackCommand::New();
1975 myEventCallbackCommand->Delete();
1976 myEventCallbackCommand->SetClientData( this );
1977 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1980 /* load resources for all available meshers */
1981 SMESH::InitAvailableHypotheses();
1983 MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities
1986 //=============================================================================
1990 //=============================================================================
1991 SMESHGUI::~SMESHGUI()
1995 //=============================================================================
1999 //=============================================================================
2000 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2004 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2009 //=============================================================================
2013 //=============================================================================
2014 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2016 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2020 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2021 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2022 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2023 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2024 return autoUpdate && !exceeded;
2027 //=============================================================================
2031 //=============================================================================
2032 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
2033 int* entities, bool* limitExceeded, int* hidden )
2035 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2039 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2040 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2041 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2043 long requestedSize = theMesh->NbElements();
2045 *entities = SMESH_Actor::eAllEntity;
2048 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2050 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2052 if ( incrementalLimit ) {
2053 long nbOdElems = theMesh->Nb0DElements();
2054 long nbEdges = theMesh->NbEdges();
2055 long nbFaces = theMesh->NbFaces();
2056 long nbVolumes = theMesh->NbVolumes();
2057 long nbBalls = theMesh->NbBalls();
2060 if ( nbOdElems > 0 ) {
2061 if ( total + nbOdElems > updateLimit ) {
2062 *entities = *entities & ~SMESH_Actor::e0DElements;
2063 *hidden = *hidden | SMESH_Actor::e0DElements;
2070 if ( nbEdges > 0 ) {
2071 if ( total + nbEdges > updateLimit ) {
2072 *entities = *entities & ~SMESH_Actor::eEdges;
2073 *hidden = *hidden | SMESH_Actor::eEdges;
2080 if ( nbFaces > 0 ) {
2081 if ( total + nbFaces > updateLimit ) {
2082 *entities = *entities & ~SMESH_Actor::eFaces;
2083 *hidden = *hidden | SMESH_Actor::eFaces;
2090 if ( nbVolumes > 0 ) {
2091 if ( total + nbVolumes > updateLimit ) {
2092 *entities = *entities & ~SMESH_Actor::eVolumes;
2093 *hidden = *hidden | SMESH_Actor::eVolumes;
2100 if ( nbBalls > 0 ) {
2101 if ( total + nbBalls > updateLimit ) {
2102 *entities = *entities & ~SMESH_Actor::eBallElem;
2103 *hidden = *hidden | SMESH_Actor::eBallElem;
2111 return autoUpdate && !exceeded;
2114 //=============================================================================
2118 //=============================================================================
2119 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2121 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2124 //=============================================================================
2128 //=============================================================================
2129 SMESHGUI* SMESHGUI::GetSMESHGUI()
2131 SMESHGUI* smeshMod = 0;
2132 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2135 CAM_Module* module = app->module( "Mesh" );
2136 smeshMod = dynamic_cast<SMESHGUI*>( module );
2139 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2141 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2144 _PTR(Study) aStudy = study->studyDS();
2146 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2155 Standard_EXPORT SMESHGUI* GetComponentGUI()
2157 return SMESHGUI::GetSMESHGUI();
2161 //=============================================================================
2165 //=============================================================================
2166 void SMESHGUI::SetState(int aState)
2171 //=============================================================================
2175 //=============================================================================
2176 void SMESHGUI::ResetState()
2181 //=============================================================================
2185 //=============================================================================
2186 void SMESHGUI::EmitSignalDeactivateDialog()
2188 emit SignalDeactivateActiveDialog();
2191 //=============================================================================
2195 //=============================================================================
2196 void SMESHGUI::EmitSignalStudyFrameChanged()
2198 emit SignalStudyFrameChanged();
2201 //=============================================================================
2205 //=============================================================================
2206 void SMESHGUI::EmitSignalCloseAllDialogs()
2208 emit SignalCloseAllDialogs();
2211 //=============================================================================
2215 //=============================================================================
2216 void SMESHGUI::EmitSignalVisibilityChanged()
2218 emit SignalVisibilityChanged();
2221 //=============================================================================
2225 //=============================================================================
2226 QDialog *SMESHGUI::GetActiveDialogBox()
2228 return myActiveDialogBox;
2231 //=============================================================================
2235 //=============================================================================
2236 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2238 myActiveDialogBox = (QDialog *) aDlg;
2242 //=============================================================================
2246 //=============================================================================
2247 SUIT_Desktop* SMESHGUI::desktop()
2249 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2251 return app->desktop();
2256 //=============================================================================
2260 //=============================================================================
2261 SalomeApp_Study* SMESHGUI::activeStudy()
2263 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2265 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2270 //=============================================================================
2274 //=============================================================================
2275 void SMESHGUI::Modified( bool theIsUpdateActions )
2277 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2278 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2279 appStudy->Modified();
2280 if( theIsUpdateActions )
2281 app->updateActions();
2286 //=============================================================================
2290 //=============================================================================
2291 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2293 /* Here the position is on the bottom right corner - 10 */
2294 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2296 SUIT_Desktop *PP = desktop();
2297 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2298 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2302 //=============================================================================
2306 //=============================================================================
2307 static int isStudyLocked(_PTR(Study) theStudy){
2308 return theStudy->GetProperties()->IsLocked();
2311 static bool checkLock(_PTR(Study) theStudy) {
2312 if (isStudyLocked(theStudy)) {
2313 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2314 QObject::tr("WRN_WARNING"),
2315 QObject::tr("WRN_STUDY_LOCKED") );
2321 //=======================================================================
2322 //function : CheckActiveStudyLocked
2324 //=======================================================================
2326 bool SMESHGUI::isActiveStudyLocked()
2328 _PTR(Study) aStudy = activeStudy()->studyDS();
2329 return checkLock( aStudy );
2332 //=============================================================================
2336 //=============================================================================
2337 bool SMESHGUI::OnGUIEvent( int theCommandID )
2339 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2343 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2344 SUIT_ResourceMgr* mgr = resourceMgr();
2348 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2349 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2352 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2353 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2355 //QAction* act = action( theCommandID );
2357 switch (theCommandID) {
2359 if(checkLock(aStudy)) break;
2371 if(checkLock(aStudy)) break;
2372 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2376 case 150: //MED FILE INFORMATION
2378 SALOME_ListIO selected;
2379 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2381 aSel->selectedObjects( selected );
2382 if( selected.Extent() )
2384 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2385 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2386 if ( !aMesh->_is_nil() )
2388 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2395 case 122: // EXPORT MED
2410 ::ExportMeshToFile(theCommandID);
2414 case 200: // SCALAR BAR
2416 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2417 SALOME_ListIO selected;
2419 aSel->selectedObjects( selected );
2421 if( selected.Extent() ) {
2422 Handle(SALOME_InteractiveObject) anIO = selected.First();
2423 if( anIO->hasEntry() ) {
2424 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2425 anActor->SetControlMode( SMESH_Actor::eNone );
2426 #ifndef DISABLE_PLOT2DVIEWER
2427 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2436 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2441 // dump control distribution data to the text file
2442 ::SaveDistribution();
2448 // show/ distribution
2449 ::ShowDistribution();
2453 #ifndef DISABLE_PLOT2DVIEWER
2456 // plot distribution
2457 ::PlotDistribution();
2468 ::DisableAutoColor();
2471 case 1134: // Clipping
2472 case 1133: // Tranparency
2473 case 1132: // Display preferences (colors, shrink size, line width, ...)
2480 ::SetDisplayMode(theCommandID, myMarkerMap);
2483 //2D quadratic representation
2486 ::SetDisplayMode(theCommandID, myMarkerMap);
2490 case 216: // 0D elements
2493 case 219: // Volumes
2494 case 220: // All Entity
2496 ::SetDisplayEntity(theCommandID);
2499 case 221: // Orientation of faces
2501 LightApp_SelectionMgr* mgr = selectionMgr();
2502 SALOME_ListIO selected; mgr->selectedObjects( selected );
2504 SALOME_ListIteratorOfListIO it(selected);
2505 for( ; it.More(); it.Next()) {
2506 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2507 if(anIObject->hasEntry()) {
2508 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2509 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2518 if(checkLock(aStudy)) break;
2519 SUIT_OverrideCursor wc;
2521 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2524 SMESH::UpdateView();
2526 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2527 SMESH::OnVisuException();
2529 catch (...) { // PAL16774 (Crash after display of many groups)
2530 SMESH::OnVisuException();
2534 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2535 aSel->selectedObjects( l );
2536 aSel->setSelectedObjects( l );
2541 case 301: // DISPLAY
2542 case 302: // DISPLAY ONLY
2544 SMESH::EDisplaing anAction;
2545 switch (theCommandID) {
2546 case 300: anAction = SMESH::eErase; break;
2547 case 301: anAction = SMESH::eDisplay; break;
2548 case 302: anAction = SMESH::eDisplayOnly; break;
2551 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2552 SALOME_ListIO sel_objects, to_process;
2554 aSel->selectedObjects( sel_objects );
2556 if( theCommandID==302 )
2558 MESSAGE("anAction = SMESH::eDisplayOnly");
2559 startOperation( myEraseAll );
2562 extractContainers( sel_objects, to_process );
2565 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2569 SALOME_ListIteratorOfListIO It( to_process );
2570 for ( ; It.More(); It.Next()) {
2572 Handle(SALOME_InteractiveObject) IOS = It.Value();
2573 if (IOS->hasEntry()) {
2575 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2576 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2577 break; // PAL16774 (Crash after display of many groups)
2579 if (anAction == SMESH::eDisplayOnly)
2581 MESSAGE("anAction = SMESH::eDisplayOnly");
2582 anAction = SMESH::eDisplay;
2588 // PAL13338 + PAL15161 -->
2589 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2590 MESSAGE("anAction = SMESH::eDisplayOnly");
2591 SMESH::UpdateView();
2592 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2594 // PAL13338 + PAL15161 <--
2596 catch (...) { // PAL16774 (Crash after display of many groups)
2597 SMESH::OnVisuException();
2600 if (anAction == SMESH::eErase) {
2601 MESSAGE("anAction == SMESH::eErase");
2603 aSel->setSelectedObjects( l1 );
2606 aSel->setSelectedObjects( to_process );
2613 if(checkLock(aStudy)) break;
2616 EmitSignalDeactivateDialog();
2618 ( new SMESHGUI_NodesDlg( this ) )->show();
2621 SUIT_MessageBox::warning(desktop(),
2622 tr("SMESH_WRN_WARNING"),
2623 tr("SMESH_WRN_VIEWER_VTK"));
2628 case 2151: // FILTER
2632 EmitSignalDeactivateDialog();
2633 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2638 case 701: // COMPUTE MESH
2639 case 711: // PRECOMPUTE MESH
2640 case 712: // EVALUATE MESH
2641 case 713: // MESH ORDER
2642 case 702: // Create mesh
2643 case 703: // Create sub-mesh
2644 case 704: // Edit mesh/sub-mesh
2645 startOperation( theCommandID );
2647 case 705: // copy mesh
2649 if (checkLock(aStudy)) break;
2650 EmitSignalDeactivateDialog();
2651 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2654 case 710: // Build compound mesh
2656 if (checkLock(aStudy)) break;
2657 EmitSignalDeactivateDialog();
2658 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2662 case 407: // DIAGONAL INVERSION
2663 case 408: // Delete diagonal
2667 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2668 tr( "NOT_A_VTK_VIEWER" ) );
2672 if ( checkLock( aStudy ) )
2675 /*Standard_Boolean aRes;
2676 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2677 if ( aMesh->_is_nil() )
2679 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2680 tr( "SMESH_BAD_SELECTION" ) );
2684 EmitSignalDeactivateDialog();
2685 if ( theCommandID == 407 )
2686 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2688 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2691 case 409: // Change orientation
2692 case 410: // Union of triangles
2693 case 411: // Cutting of quadrangles
2694 case 419: // Splitting volumes into tetrahedra
2698 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2699 tr( "NOT_A_VTK_VIEWER" ) );
2703 if ( checkLock( aStudy ) )
2706 EmitSignalDeactivateDialog();
2707 SMESHGUI_MultiEditDlg* aDlg = NULL;
2708 if ( theCommandID == 409 )
2709 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2710 else if ( theCommandID == 410 )
2711 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2712 else if ( theCommandID == 419 )
2713 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2715 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2720 case 412: // Smoothing
2722 if(checkLock(aStudy)) break;
2724 EmitSignalDeactivateDialog();
2725 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2728 SUIT_MessageBox::warning(desktop(),
2729 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2733 case 413: // Extrusion
2735 if (checkLock(aStudy)) break;
2737 EmitSignalDeactivateDialog();
2738 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2740 SUIT_MessageBox::warning(desktop(),
2741 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2745 case 414: // Revolution
2747 if(checkLock(aStudy)) break;
2749 EmitSignalDeactivateDialog();
2750 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2753 SUIT_MessageBox::warning(desktop(),
2754 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2758 case 415: // Pattern mapping
2760 if ( checkLock( aStudy ) )
2764 EmitSignalDeactivateDialog();
2765 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2768 SUIT_MessageBox::warning(desktop(),
2769 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2773 case 416: // Extrusion along a path
2775 if (checkLock(aStudy)) break;
2777 EmitSignalDeactivateDialog();
2778 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2780 SUIT_MessageBox::warning(desktop(),
2781 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2785 case 417: // Convert mesh to quadratic
2786 case 418: // create 2D mesh from 3D
2787 case 420: // Reorient faces
2788 case 806: // CREATE GEO GROUP
2790 startOperation( theCommandID );
2793 case 801: // CREATE GROUP
2797 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2798 tr( "NOT_A_VTK_VIEWER" ) );
2802 if(checkLock(aStudy)) break;
2803 EmitSignalDeactivateDialog();
2804 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2806 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2807 SALOME_ListIO selected;
2809 aSel->selectedObjects( selected );
2811 int nbSel = selected.Extent();
2813 // check if mesh is selected
2814 aMesh = SMESH::GetMeshByIO( selected.First() );
2816 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2821 case 802: // CONSTRUCT GROUP
2825 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2826 tr( "NOT_A_VTK_VIEWER" ) );
2830 if(checkLock(aStudy)) break;
2831 EmitSignalDeactivateDialog();
2833 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2834 SALOME_ListIO selected;
2836 aSel->selectedObjects( selected );
2838 int nbSel = selected.Extent();
2840 // check if submesh is selected
2841 Handle(SALOME_InteractiveObject) IObject = selected.First();
2842 if (IObject->hasEntry()) {
2843 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2845 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2846 if (!aSubMesh->_is_nil()) {
2848 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2849 // get submesh elements list by types
2850 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2851 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2852 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2853 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2854 // create group for each type o elements
2855 QString aName = IObject->getName();
2856 QStringList anEntryList;
2857 if (aNodes->length() > 0) {
2858 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2859 aGroup->Add(aNodes.inout());
2860 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2861 anEntryList.append( aSObject->GetID().c_str() );
2863 if (aEdges->length() > 0) {
2864 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2865 aGroup->Add(aEdges.inout());
2866 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2867 anEntryList.append( aSObject->GetID().c_str() );
2869 if (aFaces->length() > 0) {
2870 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2871 aGroup->Add(aFaces.inout());
2872 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2873 anEntryList.append( aSObject->GetID().c_str() );
2875 if (aVolumes->length() > 0) {
2876 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2877 aGroup->Add(aVolumes.inout());
2878 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2879 anEntryList.append( aSObject->GetID().c_str() );
2882 anApp->browseObjects( anEntryList );
2884 catch(const SALOME::SALOME_Exception & S_ex){
2885 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2892 SUIT_MessageBox::warning(desktop(),
2893 tr("SMESH_WRN_WARNING"),
2894 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2899 case 803: // EDIT GROUP
2903 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2904 tr( "NOT_A_VTK_VIEWER" ) );
2908 if(checkLock(aStudy)) break;
2909 EmitSignalDeactivateDialog();
2911 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2912 SALOME_ListIO selected;
2914 aSel->selectedObjects( selected );
2916 SALOME_ListIteratorOfListIO It (selected);
2917 int nbSelectedGroups = 0;
2918 for ( ; It.More(); It.Next() )
2920 SMESH::SMESH_GroupBase_var aGroup =
2921 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2922 if (!aGroup->_is_nil()) {
2924 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2928 if (nbSelectedGroups == 0)
2930 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2936 case 804: // Add elements to group
2938 if(checkLock(aStudy)) break;
2939 if (myState == 800) {
2940 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2941 if (aDlg) aDlg->onAdd();
2946 case 805: // Remove elements from group
2948 if(checkLock(aStudy)) break;
2949 if (myState == 800) {
2950 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2951 if (aDlg) aDlg->onRemove();
2956 case 815: // Edit GEOM GROUP as standalone
2960 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2961 tr( "NOT_A_VTK_VIEWER" ) );
2965 if(checkLock(aStudy)) break;
2966 EmitSignalDeactivateDialog();
2968 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2969 SALOME_ListIO selected;
2971 aSel->selectedObjects( selected );
2973 SALOME_ListIteratorOfListIO It (selected);
2974 for ( ; It.More(); It.Next() )
2976 SMESH::SMESH_GroupOnGeom_var aGroup =
2977 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2978 if (!aGroup->_is_nil()) {
2979 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2984 SMESH::SMESH_GroupOnFilter_var aGroup =
2985 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2986 if (!aGroup->_is_nil()) {
2987 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2995 case 810: // Union Groups
2996 case 811: // Intersect groups
2997 case 812: // Cut groups
3001 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3002 tr( "NOT_A_VTK_VIEWER" ) );
3006 if ( checkLock( aStudy ) )
3009 EmitSignalDeactivateDialog();
3011 SMESHGUI_GroupOpDlg* aDlg = 0;
3012 if ( theCommandID == 810 )
3013 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3014 else if ( theCommandID == 811 )
3015 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3017 aDlg = new SMESHGUI_CutGroupsDlg( this );
3024 case 814: // Create groups of entities from existing groups of superior dimensions
3026 if ( checkLock( aStudy ) )
3029 EmitSignalDeactivateDialog();
3030 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3036 case 813: // Delete groups with their contents
3040 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
3041 tr( "NOT_A_VTK_VIEWER" ) );
3045 if ( checkLock( aStudy ) )
3048 EmitSignalDeactivateDialog();
3050 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3054 case 900: // MESH INFOS
3055 case 903: // WHAT IS
3057 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3058 EmitSignalDeactivateDialog();
3059 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3060 SALOME_ListIO selected;
3062 aSel->selectedObjects( selected );
3064 if ( selected.Extent() > 1 ) { // a dlg for each IO
3065 SALOME_ListIteratorOfListIO It( selected );
3066 for ( ; It.More(); It.Next() ) {
3067 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3068 dlg->showInfo( It.Value() );
3073 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3079 case 904: // FIND ELEM
3081 startOperation( theCommandID );
3085 case 1100: // EDIT HYPOTHESIS
3087 if(checkLock(aStudy)) break;
3089 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3090 SALOME_ListIO selected;
3092 aSel->selectedObjects( selected );
3094 int nbSel = selected.Extent();
3097 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3098 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3100 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3101 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3102 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3103 if ( !aHypothesis->_is_nil() )
3106 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3107 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3109 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3119 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3121 if(checkLock(aStudy)) break;
3122 SUIT_OverrideCursor wc;
3124 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3125 SALOME_ListIO selected;
3127 aSel->selectedObjects( selected, QString::null, false );
3129 SALOME_ListIteratorOfListIO It(selected);
3130 for (int i = 0; It.More(); It.Next(), i++) {
3131 Handle(SALOME_InteractiveObject) IObject = It.Value();
3132 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3135 aSel->setSelectedObjects( l1 );
3141 case 4009: // ELEM0D
3143 case 4021: // TRIANGLE
3145 case 4023: // POLYGON
3149 case 4134: // PYRAMID
3150 case 4135: // OCTA12
3152 if(checkLock(aStudy)) break;
3154 EmitSignalDeactivateDialog();
3155 SMDSAbs_EntityType type = SMDSEntity_Edge;
3156 switch (theCommandID) {
3157 case 4008: type = SMDSEntity_Ball; break;
3158 case 4009: type = SMDSEntity_0D; break;
3159 case 4021: type = SMDSEntity_Triangle; break;
3160 case 4022: type = SMDSEntity_Quadrangle; break;
3161 case 4031: type = SMDSEntity_Tetra; break;
3162 case 4023: type = SMDSEntity_Polygon; break;
3163 case 4032: type = SMDSEntity_Hexa; break;
3164 case 4133: type = SMDSEntity_Penta; break;
3165 case 4134: type = SMDSEntity_Pyramid; break;
3166 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3169 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3172 SUIT_MessageBox::warning(desktop(),
3173 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3177 case 4033: // POLYHEDRON
3179 if(checkLock(aStudy)) break;
3181 EmitSignalDeactivateDialog();
3182 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3185 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3186 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3190 case 4034: // QUADRATIC EDGE
3191 case 4035: // QUADRATIC TRIANGLE
3192 case 4036: // QUADRATIC QUADRANGLE
3193 case 4136: // BIQUADRATIC QUADRANGLE
3194 case 4137: // BIQUADRATIC TRIANGLE
3195 case 4037: // QUADRATIC TETRAHEDRON
3196 case 4038: // QUADRATIC PYRAMID
3197 case 4039: // QUADRATIC PENTAHEDRON
3198 case 4040: // QUADRATIC HEXAHEDRON
3199 case 4140: // TRIQUADRATIC HEXAHEDRON
3201 if(checkLock(aStudy)) break;
3203 EmitSignalDeactivateDialog();
3204 SMDSAbs_EntityType type = SMDSEntity_Last;
3206 switch (theCommandID) {
3207 case 4034: type = SMDSEntity_Quad_Edge; break;
3208 case 4035: type = SMDSEntity_Quad_Triangle; break;
3209 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3210 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3211 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3212 case 4037: type = SMDSEntity_Quad_Tetra; break;
3213 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3214 case 4039: type = SMDSEntity_Quad_Penta; break;
3215 case 4040: type = SMDSEntity_Quad_Hexa; break;
3216 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3219 if ( type != SMDSEntity_Last )
3220 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3223 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3224 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3228 case 4041: // REMOVES NODES
3230 if(checkLock(aStudy)) break;
3232 EmitSignalDeactivateDialog();
3233 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3236 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3237 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3241 case 4042: // REMOVES ELEMENTS
3243 if(checkLock(aStudy)) break;
3245 EmitSignalDeactivateDialog();
3246 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3250 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3251 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3255 case 4043: { // CLEAR_MESH
3257 if(checkLock(aStudy)) break;
3259 SALOME_ListIO selected;
3260 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3261 aSel->selectedObjects( selected );
3263 SUIT_OverrideCursor wc;
3264 SALOME_ListIteratorOfListIO It (selected);
3265 for ( ; It.More(); It.Next() )
3267 Handle(SALOME_InteractiveObject) IOS = It.Value();
3268 SMESH::SMESH_Mesh_var aMesh =
3269 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3270 if ( aMesh->_is_nil()) continue;
3272 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3274 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3275 SMESH::ModifiedMesh( aMeshSObj, false, true);
3276 // hide groups and submeshes
3277 _PTR(ChildIterator) anIter =
3278 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3279 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3281 _PTR(SObject) so = anIter->Value();
3282 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3285 catch (const SALOME::SALOME_Exception& S_ex){
3287 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3291 SMESH::UpdateView();
3295 case 4044: // REMOVE ORPHAN NODES
3297 if(checkLock(aStudy)) break;
3298 SALOME_ListIO selected;
3299 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3300 aSel->selectedObjects( selected );
3301 if ( selected.Extent() == 1 ) {
3302 Handle(SALOME_InteractiveObject) anIO = selected.First();
3303 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3304 if ( !aMesh->_is_nil() ) {
3305 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3306 tr( "SMESH_WARNING" ),
3307 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3308 SUIT_MessageBox::Yes |
3309 SUIT_MessageBox::No,
3310 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3313 SUIT_OverrideCursor wc;
3314 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3315 int removed = aMeshEditor->RemoveOrphanNodes();
3316 SUIT_MessageBox::information(SMESHGUI::desktop(),
3317 tr("SMESH_INFORMATION"),
3318 tr("NB_NODES_REMOVED").arg(removed));
3319 if ( removed > 0 ) {
3320 SMESH::UpdateView();
3321 SMESHGUI::Modified();
3324 catch (const SALOME::SALOME_Exception& S_ex) {
3325 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3334 case 4051: // RENUMBERING NODES
3336 if(checkLock(aStudy)) break;
3338 EmitSignalDeactivateDialog();
3339 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3343 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3344 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3348 case 4052: // RENUMBERING ELEMENTS
3350 if(checkLock(aStudy)) break;
3352 EmitSignalDeactivateDialog();
3353 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3357 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3358 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3362 case 4061: // TRANSLATION
3364 if(checkLock(aStudy)) break;
3366 EmitSignalDeactivateDialog();
3367 ( new SMESHGUI_TranslationDlg( this ) )->show();
3370 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3371 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3375 case 4062: // ROTATION
3377 if(checkLock(aStudy)) break;
3379 EmitSignalDeactivateDialog();
3380 ( new SMESHGUI_RotationDlg( this ) )->show();
3383 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3384 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3388 case 4063: // SYMMETRY
3390 if(checkLock(aStudy)) break;
3392 EmitSignalDeactivateDialog();
3393 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3396 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3397 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3401 case 4064: // SEWING
3403 if(checkLock(aStudy)) break;
3405 EmitSignalDeactivateDialog();
3406 ( new SMESHGUI_SewingDlg( this ) )->show();
3409 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3414 case 4065: // MERGE NODES
3416 if(checkLock(aStudy)) break;
3418 EmitSignalDeactivateDialog();
3419 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3422 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3423 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3427 case 4066: // MERGE EQUAL ELEMENTS
3429 if (checkLock(aStudy)) break;
3431 EmitSignalDeactivateDialog();
3432 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3434 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3435 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3440 case 4067: // MAKE MESH PASS THROUGH POINT
3441 startOperation( 4067 );
3446 if(checkLock(aStudy)) break;
3448 EmitSignalDeactivateDialog();
3449 ( new SMESHGUI_ScaleDlg( this ) )->show();
3452 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3453 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3458 case 4069: // DUPLICATE NODES
3460 if(checkLock(aStudy)) break;
3462 EmitSignalDeactivateDialog();
3463 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3466 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3467 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3472 case 4070: // 0D_ON_ALL_NODES
3473 startOperation( 4070 );
3476 case 5105: // Library of selection filters
3478 static QList<int> aTypes;
3479 if ( aTypes.isEmpty() )
3481 aTypes.append( SMESH::NODE );
3482 aTypes.append( SMESH::EDGE );
3483 aTypes.append( SMESH::FACE );
3484 aTypes.append( SMESH::VOLUME );
3486 if (!myFilterLibraryDlg)
3487 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3488 else if (myFilterLibraryDlg->isHidden())
3489 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3490 myFilterLibraryDlg->raise();
3494 case 6017: // CONTROLS
3522 LightApp_SelectionMgr* mgr = selectionMgr();
3523 SALOME_ListIO selected; mgr->selectedObjects( selected );
3525 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3526 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3528 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3529 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3530 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3531 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3532 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3533 SUIT_OverrideCursor wc;
3534 ::Control( theCommandID );
3539 SUIT_MessageBox::warning(desktop(),
3540 tr( "SMESH_WRN_WARNING" ),
3541 tr( "SMESH_BAD_SELECTION" ) );
3545 SUIT_MessageBox::warning(desktop(),
3546 tr( "SMESH_WRN_WARNING" ),
3547 tr( "NOT_A_VTK_VIEWER" ) );
3551 OverallMeshQuality();
3555 SUIT_OverrideCursor wc;
3556 LightApp_SelectionMgr* mgr = selectionMgr();
3557 SALOME_ListIO selected; mgr->selectedObjects( selected );
3559 SALOME_ListIteratorOfListIO it(selected);
3560 for( ; it.More(); it.Next()) {
3561 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3562 if(anIObject->hasEntry()) {
3563 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3564 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3572 SUIT_OverrideCursor wc;
3573 LightApp_SelectionMgr* mgr = selectionMgr();
3574 SALOME_ListIO selected; mgr->selectedObjects( selected );
3576 SALOME_ListIteratorOfListIO it(selected);
3577 for( ; it.More(); it.Next()) {
3578 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3579 if(anIObject->hasEntry())
3580 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3581 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3592 int page = SMESHGUI_MeasureDlg::MinDistance;
3593 if ( theCommandID == 502 )
3594 page = SMESHGUI_MeasureDlg::BoundingBox;
3595 else if ( theCommandID == 503 )
3596 page = SMESHGUI_MeasureDlg::Length;
3597 else if ( theCommandID == 504 )
3598 page = SMESHGUI_MeasureDlg::Area;
3599 else if ( theCommandID == 505 )
3600 page = SMESHGUI_MeasureDlg::Volume;
3602 EmitSignalDeactivateDialog();
3603 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3613 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3614 //updateObjBrowser();
3618 //=============================================================================
3622 //=============================================================================
3623 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3628 //=============================================================================
3632 //=============================================================================
3633 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3638 //=============================================================================
3642 //=============================================================================
3643 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3648 //=============================================================================
3649 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3650 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3652 //=============================================================================
3653 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3654 SUIT_ViewWindow* wnd )
3656 if(theIO->hasEntry()){
3657 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3658 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3662 //=======================================================================
3663 // function : createSMESHAction
3665 //=======================================================================
3666 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3667 const int key, const bool toggle, const QString& shortcutAction )
3670 QWidget* parent = application()->desktop();
3671 SUIT_ResourceMgr* resMgr = resourceMgr();
3673 if ( !icon_id.isEmpty() )
3674 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3676 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3677 if ( !pix.isNull() )
3678 icon = QIcon( pix );
3680 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3681 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3682 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3684 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3685 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3688 //=======================================================================
3689 // function : createPopupItem
3691 //=======================================================================
3692 void SMESHGUI::createPopupItem( const int id,
3693 const QString& clients,
3694 const QString& types,
3695 const QString& theRule,
3698 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3699 popupMgr()->insert( action( id ), pId, 0 );
3701 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3702 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3703 QString rule = "(%1) and (%2) and (%3)";
3704 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3705 if( clients.isEmpty() )
3706 rule = rule.arg( QString( "true" ) );
3708 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3709 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3712 bool cont = myRules.contains( id );
3714 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3716 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3717 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3720 //=======================================================================
3721 // function : initialize
3723 //=======================================================================
3724 void SMESHGUI::initialize( CAM_Application* app )
3726 SalomeApp_Module::initialize( app );
3728 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3730 /* Automatic Update flag */
3731 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3733 // ----- create actions --------------
3735 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3736 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3737 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3738 createSMESHAction( 114, "NUM" );
3739 createSMESHAction( 115, "IMPORT_STL" );
3740 createSMESHAction( 116, "IMPORT_CGNS" );
3741 createSMESHAction( 117, "IMPORT_SAUV" );
3742 createSMESHAction( 118, "IMPORT_GMF" );
3743 createSMESHAction( 121, "DAT" );
3744 createSMESHAction( 122, "MED" );
3745 createSMESHAction( 123, "UNV" );
3746 createSMESHAction( 140, "STL" );
3747 createSMESHAction( 142, "CGNS");
3748 createSMESHAction( 144, "SAUV");
3749 createSMESHAction( 146, "GMF" );
3750 createSMESHAction( 124, "DAT" );
3751 createSMESHAction( 125, "MED" );
3752 createSMESHAction( 126, "UNV" );
3753 createSMESHAction( 141, "STL" );
3754 createSMESHAction( 143, "CGNS");
3755 createSMESHAction( 145, "SAUV");
3756 createSMESHAction( 147, "GMF" );
3757 createSMESHAction( 150, "FILE_INFO" );
3758 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3759 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3760 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3761 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3762 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3763 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3764 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3765 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3766 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3767 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3768 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3769 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3770 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3771 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3772 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3773 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3774 createSMESHAction( 804, "ADD" );
3775 createSMESHAction( 805, "REMOVE" );
3776 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3777 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3778 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3779 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3780 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3781 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3782 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3783 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3784 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3785 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3786 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3787 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3788 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3789 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3790 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3791 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3792 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3793 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3794 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3795 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3796 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3797 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3798 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3799 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3800 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3801 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3802 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3803 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3804 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3805 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3806 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3807 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3808 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3809 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3810 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3811 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3812 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3813 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3814 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3815 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3816 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3817 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3818 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3819 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3820 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3821 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3822 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3823 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3824 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3825 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3826 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3827 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3828 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3829 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3830 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3831 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3832 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3833 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3834 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3835 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3836 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3837 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3838 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3839 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3840 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3841 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3842 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3843 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3844 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3845 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3846 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3847 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3848 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3849 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3850 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3851 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3852 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3853 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3854 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3855 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3856 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3857 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3858 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3859 createSMESHAction( 415, "MAP", "ICON_MAP" );
3860 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3861 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3862 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3863 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3864 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3865 createSMESHAction( 200, "RESET" );
3866 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3867 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3868 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3869 #ifndef DISABLE_PLOT2DVIEWER
3870 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3872 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3873 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3874 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3875 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3876 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3877 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3878 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3879 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3880 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3881 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3882 createSMESHAction( 220, "ALL" );
3883 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3885 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3886 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3888 createSMESHAction( 1100, "EDIT_HYPO" );
3889 createSMESHAction( 1102, "UNASSIGN" );
3890 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3891 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3892 createSMESHAction( 1131, "DISPMODE" );
3893 createSMESHAction( 1132, "COLORS" );
3894 createSMESHAction( 1133, "TRANSP" );
3895 createSMESHAction( 1134, "CLIP" );
3896 createSMESHAction( 1135, "DISP_ENT" );
3897 createSMESHAction( 1136, "AUTO_COLOR" );
3898 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3899 createSMESHAction( 2000, "CTRL" );
3901 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3902 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3903 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3904 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3905 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3907 createSMESHAction( 300, "HIDE" );
3908 createSMESHAction( 301, "SHOW" );
3909 createSMESHAction( 302, "DISPLAY_ONLY" );
3911 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3913 // ----- create menu --------------
3914 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3915 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3916 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3917 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3918 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3919 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3920 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3921 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3923 createMenu( separator(), fileId );
3925 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3926 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3927 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3928 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3929 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3930 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3931 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3932 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3933 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3934 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3935 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3937 //createMenu( 111, importId, -1 );
3938 createMenu( 112, importId, -1 );
3939 createMenu( 113, importId, -1 );
3940 createMenu( 115, importId, -1 );
3942 createMenu( 116, importId, -1 );
3944 createMenu( 117, importId, -1 );
3945 createMenu( 118, importId, -1 );
3946 createMenu( 121, exportId, -1 );
3947 createMenu( 122, exportId, -1 );
3948 createMenu( 123, exportId, -1 );
3949 createMenu( 140, exportId, -1 ); // export to STL
3951 createMenu( 142, exportId, -1 ); // export to CGNS
3953 createMenu( 144, exportId, -1 ); // export to SAUV
3954 createMenu( 146, exportId, -1 ); // export to GMF
3955 createMenu( separator(), fileId, 10 );
3957 createMenu( 33, editId, -1 );
3959 createMenu( 5105, toolsId, -1 );
3961 createMenu( 702, meshId, -1 ); // "Mesh" menu
3962 createMenu( 703, meshId, -1 );
3963 createMenu( 704, meshId, -1 );
3964 createMenu( 710, meshId, -1 );
3965 createMenu( 705, meshId, -1 );
3966 createMenu( separator(), meshId, -1 );
3967 createMenu( 701, meshId, -1 );
3968 createMenu( 711, meshId, -1 );
3969 createMenu( 712, meshId, -1 );
3970 createMenu( 713, meshId, -1 );
3971 createMenu( separator(), meshId, -1 );
3972 createMenu( 801, meshId, -1 );
3973 createMenu( 806, meshId, -1 );
3974 createMenu( 802, meshId, -1 );
3975 createMenu( 803, meshId, -1 );
3976 createMenu( 815, meshId, -1 );
3977 createMenu( separator(), meshId, -1 );
3978 createMenu( 810, meshId, -1 );
3979 createMenu( 811, meshId, -1 );
3980 createMenu( 812, meshId, -1 );
3981 createMenu( separator(), meshId, -1 );
3982 createMenu( 814, meshId, -1 );
3983 createMenu( separator(), meshId, -1 );
3984 createMenu( 900, meshId, -1 );
3985 //createMenu( 902, meshId, -1 );
3986 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3987 createMenu( 904, meshId, -1 );
3988 createMenu( separator(), meshId, -1 );
3990 createMenu( 6005, nodeId, -1 );
3991 createMenu( 6028, nodeId, -1 );
3992 createMenu( 6002, edgeId, -1 );
3993 createMenu( 6003, edgeId, -1 );
3994 createMenu( 6001, edgeId, -1 );
3995 createMenu( 6004, edgeId, -1 );
3996 createMenu( 6029, edgeId, -1 );
3997 createMenu( 6021, faceId, -1 );
3998 createMenu( 6025, faceId, -1 );
3999 createMenu( 6027, faceId, -1 );
4000 createMenu( 6018, faceId, -1 );
4001 createMenu( 6019, faceId, -1 );
4002 createMenu( 6011, faceId, -1 );
4003 createMenu( 6012, faceId, -1 );
4004 createMenu( 6013, faceId, -1 );
4005 createMenu( 6014, faceId, -1 );
4006 createMenu( 6015, faceId, -1 );
4007 createMenu( 6016, faceId, -1 );
4008 createMenu( 6022, faceId, -1 );
4009 createMenu( 6030, faceId, -1 );
4010 createMenu( 6017, volumeId, -1 );
4011 createMenu( 6009, volumeId, -1 );
4012 createMenu( 6023, volumeId, -1 );
4013 createMenu( 6024, volumeId, -1 );
4014 createMenu( 6026, volumeId, -1 );
4015 createMenu( 6031, volumeId, -1 );
4016 createMenu( separator(), ctrlId, -1 );
4017 createMenu( 6032, ctrlId, -1 );
4019 createMenu( 4000, addId, -1 );
4020 createMenu( 4009, addId, -1 );
4021 createMenu( 4070, addId, -1 );
4022 createMenu( 4008, addId, -1 );
4023 createMenu( 4010, addId, -1 );
4024 createMenu( 4021, addId, -1 );
4025 createMenu( 4022, addId, -1 );
4026 createMenu( 4023, addId, -1 );
4027 createMenu( 4031, addId, -1 );
4028 createMenu( 4032, addId, -1 );
4029 createMenu( 4133, addId, -1 );
4030 createMenu( 4134, addId, -1 );
4031 createMenu( 4135, addId, -1 );
4032 createMenu( 4033, addId, -1 );
4033 createMenu( separator(), addId, -1 );
4034 createMenu( 4034, addId, -1 );
4035 createMenu( 4035, addId, -1 );
4036 createMenu( 4137, addId, -1 );
4037 createMenu( 4036, addId, -1 );
4038 createMenu( 4136, addId, -1 );
4039 createMenu( 4037, addId, -1 );
4040 createMenu( 4038, addId, -1 );
4041 createMenu( 4039, addId, -1 );
4042 createMenu( 4040, addId, -1 );
4043 createMenu( 4140, addId, -1 );
4045 createMenu( 4041, removeId, -1 );
4046 createMenu( 4042, removeId, -1 );
4047 createMenu( 4044, removeId, -1 );
4048 createMenu( separator(), removeId, -1 );
4049 createMenu( 813, removeId, -1 );
4050 createMenu( separator(), removeId, -1 );
4051 createMenu( 4043, removeId, -1 );
4053 createMenu( 4051, renumId, -1 );
4054 createMenu( 4052, renumId, -1 );
4056 createMenu( 4061, transfId, -1 );
4057 createMenu( 4062, transfId, -1 );
4058 createMenu( 4063, transfId, -1 );
4059 createMenu( 4068, transfId, -1 );
4060 createMenu( 4064, transfId, -1 );
4061 createMenu( 4065, transfId, -1 );
4062 createMenu( 4066, transfId, -1 );
4063 createMenu( 4069, transfId, -1 );
4065 createMenu( 4067,modifyId, -1 );
4066 createMenu( 407, modifyId, -1 );
4067 createMenu( 408, modifyId, -1 );
4068 createMenu( 409, modifyId, -1 );
4069 createMenu( 420, modifyId, -1 );
4070 createMenu( 410, modifyId, -1 );
4071 createMenu( 411, modifyId, -1 );
4072 createMenu( 419, modifyId, -1 );
4073 createMenu( 412, modifyId, -1 );
4074 createMenu( 413, modifyId, -1 );
4075 createMenu( 416, modifyId, -1 );
4076 createMenu( 414, modifyId, -1 );
4077 createMenu( 415, modifyId, -1 );
4078 createMenu( 417, modifyId, -1 );
4079 createMenu( 418, modifyId, -1 );
4081 createMenu( 501, measureId, -1 );
4082 createMenu( 502, measureId, -1 );
4083 createMenu( 503, basicPropId, -1 );
4084 createMenu( 504, basicPropId, -1 );
4085 createMenu( 505, basicPropId, -1 );
4086 createMenu( 214, viewId, -1 );
4088 // ----- create toolbars --------------
4089 int meshTb = createTool( tr( "TB_MESH" ) ),
4090 info = createTool( tr( "TB_INFO" ) ),
4091 groupTb = createTool( tr( "TB_GROUP" ) ),
4092 ctrl0dTb = createTool( tr( "TB_CTRL0D" ) ),
4093 ctrl1dTb = createTool( tr( "TB_CTRL1D" ) ),
4094 ctrl2dTb = createTool( tr( "TB_CTRL2D" ) ),
4095 ctrl3dTb = createTool( tr( "TB_CTRL3D" ) ),
4096 addElemTb = createTool( tr( "TB_ADD" ) ),
4097 addNonElemTb = createTool( tr( "TB_ADDNON" ) ),
4098 remTb = createTool( tr( "TB_REM" ) ),
4099 renumbTb = createTool( tr( "TB_RENUMBER" ) ),
4100 transformTb = createTool( tr( "TB_TRANSFORM" ) ),
4101 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4102 measuremTb = createTool( tr( "TB_MEASUREM" ) ),
4103 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4105 createTool( 702, meshTb );
4106 createTool( 703, meshTb );
4107 createTool( 704, meshTb );
4108 createTool( 710, meshTb );
4109 createTool( 705, meshTb );
4110 createTool( separator(), meshTb );
4111 createTool( 701, meshTb );
4112 createTool( 711, meshTb );
4113 createTool( 712, meshTb );
4114 createTool( 713, meshTb );
4116 createTool( 801, groupTb );
4117 createTool( 806, groupTb );
4118 createTool( 802, groupTb );
4119 createTool( 803, groupTb );
4121 createTool( 900, info );
4122 //createTool( 902, meshTb );
4123 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4124 createTool( 904, info );
4126 createTool( 6005, ctrl0dTb );
4127 createTool( 6028, ctrl0dTb );
4129 createTool( 6002, ctrl1dTb );
4130 createTool( 6003, ctrl1dTb );
4131 createTool( 6001, ctrl1dTb );
4132 createTool( 6004, ctrl1dTb );
4133 createTool( 6029, ctrl1dTb );
4135 createTool( 6021, ctrl2dTb );
4136 createTool( 6025, ctrl2dTb );
4137 createTool( 6027, ctrl2dTb );
4138 createTool( 6018, ctrl2dTb );
4139 createTool( 6019, ctrl2dTb );
4140 createTool( 6011, ctrl2dTb );
4141 createTool( 6012, ctrl2dTb );
4142 createTool( 6013, ctrl2dTb );
4143 createTool( 6014, ctrl2dTb );
4144 createTool( 6015, ctrl2dTb );
4145 createTool( 6016, ctrl2dTb );
4146 createTool( 6022, ctrl2dTb );
4147 createTool( 6030, ctrl2dTb );
4149 createTool( 6017, ctrl3dTb );
4150 createTool( 6009, ctrl3dTb );
4151 createTool( 6023, ctrl3dTb );
4152 createTool( 6024, ctrl3dTb );
4153 createTool( 6026, ctrl3dTb );
4154 createTool( 6031, ctrl3dTb );
4156 createTool( 4000, addElemTb );
4157 createTool( 4009, addElemTb );
4158 createTool( 4070, addElemTb );
4159 createTool( 4008, addElemTb );
4160 createTool( 4010, addElemTb );
4161 createTool( 4021, addElemTb );
4162 createTool( 4022, addElemTb );
4163 createTool( 4023, addElemTb );
4164 createTool( 4031, addElemTb );
4165 createTool( 4032, addElemTb );
4166 createTool( 4133, addElemTb );
4167 createTool( 4134, addElemTb );
4168 createTool( 4135, addElemTb );
4169 createTool( 4033, addElemTb );
4171 createTool( 4034, addNonElemTb );
4172 createTool( 4035, addNonElemTb );
4173 createTool( 4137, addNonElemTb );
4174 createTool( 4036, addNonElemTb );
4175 createTool( 4136, addNonElemTb );
4176 createTool( 4037, addNonElemTb );
4177 createTool( 4038, addNonElemTb );
4178 createTool( 4039, addNonElemTb );
4179 createTool( 4040, addNonElemTb );
4180 createTool( 4140, addNonElemTb );
4182 createTool( 4041, remTb );
4183 createTool( 4042, remTb );
4184 createTool( 4044, remTb );
4185 createTool( 4043, remTb );
4187 createTool( 4051, renumbTb );
4188 createTool( 4052, renumbTb );
4191 createTool( 4061, transformTb );
4192 createTool( 4062, transformTb );
4193 createTool( 4063, transformTb );
4194 createTool( 4068, transformTb );
4195 createTool( 4064, transformTb );
4196 createTool( 4065, transformTb );
4197 createTool( 4066, transformTb );
4198 createTool( 4069, transformTb );
4200 createTool( 4067,modifyTb );
4201 createTool( 407, modifyTb );
4202 createTool( 408, modifyTb );
4203 createTool( 409, modifyTb );
4204 createTool( 420, modifyTb );
4205 createTool( 410, modifyTb );
4206 createTool( 411, modifyTb );
4207 createTool( 419, modifyTb );
4208 createTool( 412, modifyTb );
4209 createTool( 413, modifyTb );
4210 createTool( 416, modifyTb );
4211 createTool( 414, modifyTb );
4212 createTool( 415, modifyTb );
4213 createTool( 417, modifyTb );
4214 createTool( 418, modifyTb );
4216 createTool( 501, measuremTb );
4218 createTool( 214, dispModeTb );
4220 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4221 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4224 QString OB = "'ObjectBrowser'",
4225 View = "'" + SVTK_Viewer::Type() + "'",
4227 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4228 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4229 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4230 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4231 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4232 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4233 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4234 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4235 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4236 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4237 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4239 mesh_part = mesh + " " + subMesh + " " + group,
4240 mesh_group = mesh + " " + group,
4241 hyp_alg = hypo + " " + algo;
4243 // popup for object browser
4245 isInvisible("not( isVisible )"),
4246 isEmpty("numberOfNodes = 0"),
4247 isNotEmpty("numberOfNodes <> 0"),
4249 // has nodes, edges, etc in VISIBLE! actor
4250 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4251 hasElems("(count( elemTypes ) > 0)"),
4252 hasDifferentElems("(count( elemTypes ) > 1)"),
4253 hasBalls("({'BallElem'} in elemTypes)"),
4254 hasElems0d("({'Elem0d'} in elemTypes)"),
4255 hasEdges("({'Edge'} in elemTypes)"),
4256 hasFaces("({'Face'} in elemTypes)"),
4257 hasVolumes("({'Volume'} in elemTypes)");
4259 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4260 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4261 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4262 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4263 createPopupItem( 803, OB, group ); // EDIT_GROUP
4264 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4266 popupMgr()->insert( separator(), -1, 0 );
4267 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4268 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4269 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4270 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4271 createPopupItem( 214, OB, mesh_part ); // UPDATE
4272 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4273 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4274 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4275 popupMgr()->insert( separator(), -1, 0 );
4276 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4277 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4278 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4279 popupMgr()->insert( separator(), -1, 0 );
4280 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4281 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4282 popupMgr()->insert( separator(), -1, 0 );
4283 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4284 popupMgr()->insert( separator(), -1, 0 );
4285 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4286 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4288 popupMgr()->insert( separator(), -1, 0 );
4290 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4291 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4292 QString only_one_2D = only_one_non_empty + " && dim>1";
4294 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4295 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4296 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4297 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4299 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4301 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4302 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4303 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4304 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4305 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4306 popupMgr()->insert( separator(), -1, 0 );
4309 createPopupItem( 803, View, group ); // EDIT_GROUP
4310 createPopupItem( 804, View, elems ); // ADD
4311 createPopupItem( 805, View, elems ); // REMOVE
4313 popupMgr()->insert( separator(), -1, 0 );
4314 createPopupItem( 214, View, mesh_part ); // UPDATE
4315 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4316 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4317 createPopupItem( 904, View, mesh ); // FIND_ELEM
4318 popupMgr()->insert( separator(), -1, 0 );
4320 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4321 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4322 popupMgr()->insert( separator(), -1, 0 );
4324 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4325 QString aType = QString( "%1type in {%2}" ).arg( lc );
4326 aType = aType.arg( mesh_part );
4327 QString aMeshInVTK = aClient + "&&" + aType;
4329 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4330 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4331 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4333 //-------------------------------------------------
4335 //-------------------------------------------------
4336 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4338 popupMgr()->insert( action( 9010 ), anId, -1 );
4339 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4340 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4342 popupMgr()->insert( action( 9011 ), anId, -1 );
4343 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4344 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4346 popupMgr()->insert( separator(), -1, -1 );
4348 //-------------------------------------------------
4350 //-------------------------------------------------
4351 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4353 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4354 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4355 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4357 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4358 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4359 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4361 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4362 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4363 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4365 popupMgr()->insert( separator(), anId, -1 );
4367 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4368 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4369 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4371 //-------------------------------------------------
4373 //-------------------------------------------------
4374 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4376 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4378 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4379 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4380 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4382 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4383 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4384 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4386 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4387 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4388 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4390 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4391 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4392 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4394 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4395 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4396 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4398 popupMgr()->insert( separator(), anId, -1 );
4400 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4401 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4404 //-------------------------------------------------
4405 // Representation of the 2D Quadratic elements
4406 //-------------------------------------------------
4407 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4408 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4409 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4410 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4412 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4413 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4414 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4416 //-------------------------------------------------
4417 // Orientation of faces
4418 //-------------------------------------------------
4419 popupMgr()->insert( action( 221 ), -1, -1 );
4420 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4421 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4423 //-------------------------------------------------
4425 //-------------------------------------------------
4426 popupMgr()->insert( action( 1132 ), -1, -1 );
4427 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4429 //-------------------------------------------------
4431 //-------------------------------------------------
4432 popupMgr()->insert( action( 1133 ), -1, -1 );
4433 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4435 //-------------------------------------------------
4437 //-------------------------------------------------
4439 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4440 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4441 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4442 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4444 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4446 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4447 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4449 popupMgr()->insert( separator(), anId, -1 );
4451 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4453 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4454 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4455 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4457 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4458 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4459 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4461 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4463 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4464 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4465 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4467 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4468 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4469 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4471 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4472 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4473 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4475 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4476 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4477 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4478 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4479 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4480 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4482 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4484 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4485 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4486 QtxPopupMgr::VisibleRule );
4487 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4489 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4490 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4491 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4493 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4494 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4495 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4497 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4498 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4499 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4501 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4502 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4503 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4505 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4506 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4507 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4509 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4510 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4511 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4513 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4514 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4515 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4517 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4518 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4519 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4521 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4522 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4523 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4525 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4526 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4527 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4529 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4530 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4531 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4532 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4533 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4534 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4536 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4538 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4539 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4540 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4542 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4543 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4544 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4546 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4547 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4548 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4550 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4551 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4552 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4554 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4555 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4556 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4558 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4559 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4560 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4562 popupMgr()->insert( separator(), anId, -1 );
4564 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4565 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4567 popupMgr()->insert( separator(), anId, -1 );
4569 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4571 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4572 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4574 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4575 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4576 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4578 #ifndef DISABLE_PLOT2DVIEWER
4579 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4580 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4583 //-------------------------------------------------
4585 //-------------------------------------------------
4586 popupMgr()->insert( separator(), -1, -1 );
4587 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4588 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4589 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4590 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4592 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4593 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4595 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4596 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4598 popupMgr()->insert( separator(), -1, -1 );
4600 //-------------------------------------------------
4602 //-------------------------------------------------
4603 popupMgr()->insert( action( 1134 ), -1, -1 );
4604 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4606 popupMgr()->insert( separator(), -1, -1 );
4608 popupMgr()->insert( action( 41 ), -1, -1 );
4609 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4610 popupMgr()->insert( separator(), -1, -1 );
4612 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4613 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4615 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4616 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4619 //================================================================================
4621 * \brief Return true if SMESH or GEOM objects are selected.
4622 * Is called form LightApp_Module::activateModule() which clear selection if
4623 * not isSelectionCompatible()
4625 //================================================================================
4627 bool SMESHGUI::isSelectionCompatible()
4629 bool isCompatible = true;
4630 SALOME_ListIO selected;
4631 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4632 Sel->selectedObjects( selected );
4634 SALOME_ListIteratorOfListIO It( selected );
4635 for ( ; isCompatible && It.More(); It.Next())
4637 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4638 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4640 return isCompatible;
4644 bool SMESHGUI::reusableOperation( const int id )
4646 // compute, evaluate and precompute are not reusable operations
4647 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4650 bool SMESHGUI::activateModule( SUIT_Study* study )
4652 bool res = SalomeApp_Module::activateModule( study );
4654 setMenuShown( true );
4655 setToolShown( true );
4657 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4658 PyGILState_STATE gstate = PyGILState_Ensure();
4659 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4660 if ( !pluginsmanager ) {
4664 PyObjWrapper result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4668 PyGILState_Release(gstate);
4669 // end of SMESH plugins loading
4671 // Reset actions accelerator keys
4672 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4673 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4674 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4676 action( 33)->setEnabled(true); // Delete: Key_Delete
4678 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4679 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4680 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4681 if ( _PTR(Study) aStudy = s->studyDS()) {
4682 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4683 updateObjBrowser(); // objects can be removed
4686 // get all view currently opened in the study and connect their signals to
4687 // the corresponding slots of the class.
4688 SUIT_Desktop* aDesk = study->application()->desktop();
4690 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4691 SUIT_ViewWindow* wnd;
4692 foreach ( wnd, wndList )
4699 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4701 setMenuShown( false );
4702 setToolShown( false );
4704 EmitSignalCloseAllDialogs();
4706 // Unset actions accelerator keys
4707 //action(111)->setShortcut(QKeySequence()); // Import DAT
4708 action(112)->setShortcut(QKeySequence()); // Import UNV
4709 action(113)->setShortcut(QKeySequence()); // Import MED
4711 action( 33)->setEnabled(false); // Delete: Key_Delete
4713 return SalomeApp_Module::deactivateModule( study );
4716 void SMESHGUI::studyClosed( SUIT_Study* s )
4718 SMESH::RemoveVisuData( s->id() );
4719 SalomeApp_Module::studyClosed( s );
4722 void SMESHGUI::OnGUIEvent()
4724 const QObject* obj = sender();
4725 if ( !obj || !obj->inherits( "QAction" ) )
4727 int id = actionId((QAction*)obj);
4732 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4734 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4735 if ( CORBA::is_nil( myComponentSMESH ) )
4737 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4739 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4740 return aGUI.myComponentSMESH;
4743 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4744 return myComponentSMESH;
4747 QString SMESHGUI::engineIOR() const
4749 CORBA::ORB_var anORB = getApp()->orb();
4750 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4751 return QString( anIOR.in() );
4754 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4756 SalomeApp_Module::contextMenuPopup( client, menu, title );
4758 selectionMgr()->selectedObjects( lst );
4759 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4760 Handle(SALOME_InteractiveObject) io = lst.First();
4761 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4762 _PTR(Study) study = appStudy->studyDS();
4763 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4765 QString aName = QString( obj->GetName().c_str() );
4766 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4767 aName.remove( (aName.length() - 1), 1 );
4773 LightApp_Selection* SMESHGUI::createSelection() const
4775 return new SMESHGUI_Selection();
4778 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4780 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4781 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4784 void SMESHGUI::viewManagers( QStringList& list ) const
4786 list.append( SVTK_Viewer::Type() );
4789 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4791 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4792 SMESH::UpdateSelectionProp( this );
4794 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4795 for(int i = 0; i < aViews.count() ; i++){
4796 SUIT_ViewWindow *sf = aViews[i];
4802 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4804 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4805 myClippingPlaneInfoMap.erase( theViewManager );
4808 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4810 theActor->AddObserver( SMESH::DeleteActorEvent,
4811 myEventCallbackCommand.GetPointer(),
4815 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4816 unsigned long theEvent,
4817 void* theClientData,
4820 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4821 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4822 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4823 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4824 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4825 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4826 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4827 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4828 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4829 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4830 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4831 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4832 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4833 if( anActor == *anIter3 ) {
4834 anActorList.erase( anIter3 );
4845 void SMESHGUI::createPreferences()
4847 // General tab ------------------------------------------------------------------------
4848 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4850 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4851 setPreferenceProperty( autoUpdate, "columns", 2 );
4852 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4853 setPreferenceProperty( lim, "min", 0 );
4854 setPreferenceProperty( lim, "max", 100000000 );
4855 setPreferenceProperty( lim, "step", 1000 );
4856 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4857 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4859 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4860 setPreferenceProperty( qaGroup, "columns", 2 );
4861 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4862 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4863 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4864 setPreferenceProperty( prec, "min", 0 );
4865 setPreferenceProperty( prec, "max", 16 );
4866 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4867 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4868 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4869 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4870 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4872 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4873 setPreferenceProperty( dispgroup, "columns", 2 );
4874 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4876 modes.append( tr("MEN_WIRE") );
4877 modes.append( tr("MEN_SHADE") );
4878 modes.append( tr("MEN_NODES") );
4879 modes.append( tr("MEN_SHRINK") );
4880 QList<QVariant> indices;
4881 indices.append( 0 );
4882 indices.append( 1 );
4883 indices.append( 2 );
4884 indices.append( 3 );
4885 setPreferenceProperty( dispmode, "strings", modes );
4886 setPreferenceProperty( dispmode, "indexes", indices );
4888 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4889 setPreferenceProperty( arcgroup, "columns", 2 );
4890 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4891 QStringList quadraticModes;
4892 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4893 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4895 indices.append( 0 );
4896 indices.append( 1 );
4897 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4898 setPreferenceProperty( quadraticmode, "indexes", indices );
4900 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4901 "SMESH", "max_angle" );
4902 setPreferenceProperty( maxAngle, "min", 1 );
4903 setPreferenceProperty( maxAngle, "max", 90 );
4907 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4908 setPreferenceProperty( exportgroup, "columns", 2 );
4909 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4910 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4912 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4913 setPreferenceProperty( computeGroup, "columns", 2 );
4914 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4916 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4917 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4918 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4920 indices.append( 0 );
4921 indices.append( 1 );
4922 indices.append( 2 );
4923 setPreferenceProperty( notifyMode, "strings", modes );
4924 setPreferenceProperty( notifyMode, "indexes", indices );
4926 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4927 setPreferenceProperty( infoGroup, "columns", 2 );
4928 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4930 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4931 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4933 indices.append( 0 );
4934 indices.append( 1 );
4935 setPreferenceProperty( elemInfo, "strings", modes );
4936 setPreferenceProperty( elemInfo, "indexes", indices );
4937 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4938 setPreferenceProperty( nodesLim, "min", 0 );
4939 setPreferenceProperty( nodesLim, "max", 10000000 );
4940 setPreferenceProperty( nodesLim, "step", 10000 );
4941 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4942 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4943 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4944 setPreferenceProperty( ctrlLim, "min", 0 );
4945 setPreferenceProperty( ctrlLim, "max", 10000000 );
4946 setPreferenceProperty( ctrlLim, "step", 1000 );
4947 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4948 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4949 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4950 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4951 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4953 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4954 setPreferenceProperty( segGroup, "columns", 2 );
4955 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4956 "SMESH", "segmentation" );
4957 setPreferenceProperty( segLen, "min", 1 );
4958 setPreferenceProperty( segLen, "max", 10000000 );
4959 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4960 "SMESH", "nb_segments_per_edge" );
4961 setPreferenceProperty( nbSeg, "min", 1 );
4962 setPreferenceProperty( nbSeg, "max", 10000000 );
4964 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4965 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4966 "SMESH", "forget_mesh_on_hyp_modif" );
4969 // Quantities with individual precision settings
4970 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4971 setPreferenceProperty( precGroup, "columns", 2 );
4973 const int nbQuantities = 6;
4974 int precs[nbQuantities], ii = 0;
4975 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4976 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4977 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4978 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4979 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4980 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4981 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4982 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4983 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4984 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4985 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4986 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4988 // Set property for precision value for spinboxes
4989 for ( ii = 0; ii < nbQuantities; ii++ ){
4990 setPreferenceProperty( precs[ii], "min", -14 );
4991 setPreferenceProperty( precs[ii], "max", 14 );
4992 setPreferenceProperty( precs[ii], "precision", 2 );
4995 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4996 setPreferenceProperty( previewGroup, "columns", 2 );
4997 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4998 setPreferenceProperty( chunkSize, "min", 1 );
4999 setPreferenceProperty( chunkSize, "max", 1000 );
5000 setPreferenceProperty( chunkSize, "step", 50 );
5002 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5003 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5005 // Mesh tab ------------------------------------------------------------------------
5006 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5007 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5008 setPreferenceProperty( nodeGroup, "columns", 3 );
5010 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5012 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5014 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5015 QList<QVariant> aMarkerTypeIndicesList;
5016 QList<QVariant> aMarkerTypeIconsList;
5017 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5018 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5019 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5020 aMarkerTypeIndicesList << i;
5021 aMarkerTypeIconsList << pixmap;
5023 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5024 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5026 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5028 QList<QVariant> aMarkerScaleIndicesList;
5029 QStringList aMarkerScaleValuesList;
5030 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5031 aMarkerScaleIndicesList << i;
5032 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5034 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5035 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5037 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5038 //setPreferenceProperty( elemGroup, "columns", 2 );
5040 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5041 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5042 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5043 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5044 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5045 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5046 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5047 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5048 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5051 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5052 setPreferenceProperty( grpGroup, "columns", 2 );
5054 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5055 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5057 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5058 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5059 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5060 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5061 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5062 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_scale");
5063 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5064 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5065 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5066 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5067 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5068 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5070 setPreferenceProperty( size0d, "min", 1 );
5071 setPreferenceProperty( size0d, "max", 10 );
5073 setPreferenceProperty( ballSize, "min", 1 );
5074 setPreferenceProperty( ballSize, "max", 10 );
5076 setPreferenceProperty( ballScale, "min", 1 );
5077 setPreferenceProperty( ballScale, "max", 10 );
5079 setPreferenceProperty( elemW, "min", 1 );
5080 setPreferenceProperty( elemW, "max", 5 );
5082 setPreferenceProperty( outW, "min", 1 );
5083 setPreferenceProperty( outW, "max", 5 );
5085 setPreferenceProperty( shrink, "min", 0 );
5086 setPreferenceProperty( shrink, "max", 100 );
5088 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5089 setPreferenceProperty( numGroup, "columns", 2 );
5091 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5092 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5094 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5095 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5097 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5098 setPreferenceProperty( orientGroup, "columns", 1 );
5100 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5101 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5103 setPreferenceProperty( orientScale, "min", 0.05 );
5104 setPreferenceProperty( orientScale, "max", 0.5 );
5105 setPreferenceProperty( orientScale, "step", 0.05 );
5107 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5109 // Selection tab ------------------------------------------------------------------------
5110 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5112 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5113 setPreferenceProperty( selGroup, "columns", 2 );
5115 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5116 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5118 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5119 setPreferenceProperty( preGroup, "columns", 2 );
5121 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5123 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5124 setPreferenceProperty( precSelGroup, "columns", 2 );
5126 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5127 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5128 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5130 // Scalar Bar tab ------------------------------------------------------------------------
5131 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5132 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5133 setPreferenceProperty( fontGr, "columns", 2 );
5135 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5136 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5138 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5139 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5141 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5142 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5144 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5145 setPreferenceProperty( numcol, "min", 2 );
5146 setPreferenceProperty( numcol, "max", 256 );
5148 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5149 setPreferenceProperty( numlab, "min", 2 );
5150 setPreferenceProperty( numlab, "max", 65 );
5152 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5153 setPreferenceProperty( orientGr, "columns", 2 );
5154 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5155 QStringList orients;
5156 orients.append( tr( "SMESH_VERTICAL" ) );
5157 orients.append( tr( "SMESH_HORIZONTAL" ) );
5158 indices.clear(); indices.append( 0 ); indices.append( 1 );
5159 setPreferenceProperty( orient, "strings", orients );
5160 setPreferenceProperty( orient, "indexes", indices );
5162 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5163 setPreferenceProperty( posVSizeGr, "columns", 2 );
5164 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5165 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5166 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5167 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5168 setPreferenceProperty( xv, "step", 0.1 );
5169 setPreferenceProperty( xv, "min", 0.0 );
5170 setPreferenceProperty( xv, "max", 1.0 );
5171 setPreferenceProperty( yv, "step", 0.1 );
5172 setPreferenceProperty( yv, "min", 0.0 );
5173 setPreferenceProperty( yv, "max", 1.0 );
5174 setPreferenceProperty( wv, "step", 0.1 );
5175 setPreferenceProperty( wv, "min", 0.0 );
5176 setPreferenceProperty( wv, "max", 1.0 );
5177 setPreferenceProperty( hv, "min", 0.0 );
5178 setPreferenceProperty( hv, "max", 1.0 );
5179 setPreferenceProperty( hv, "step", 0.1 );
5181 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5182 setPreferenceProperty( posHSizeGr, "columns", 2 );
5183 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5184 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5185 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5186 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5187 setPreferenceProperty( xv, "min", 0.0 );
5188 setPreferenceProperty( xv, "max", 1.0 );
5189 setPreferenceProperty( xv, "step", 0.1 );
5190 setPreferenceProperty( xh, "min", 0.0 );
5191 setPreferenceProperty( xh, "max", 1.0 );
5192 setPreferenceProperty( xh, "step", 0.1 );
5193 setPreferenceProperty( yh, "min", 0.0 );
5194 setPreferenceProperty( yh, "max", 1.0 );
5195 setPreferenceProperty( yh, "step", 0.1 );
5196 setPreferenceProperty( wh, "min", 0.0 );
5197 setPreferenceProperty( wh, "max", 1.0 );
5198 setPreferenceProperty( wh, "step", 0.1 );
5199 setPreferenceProperty( hh, "min", 0.0 );
5200 setPreferenceProperty( hh, "max", 1.0 );
5201 setPreferenceProperty( hh, "step", 0.1 );
5203 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5204 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5205 setPreferenceProperty( distributionGr, "columns", 3 );
5207 types.append( tr( "SMESH_MONOCOLOR" ) );
5208 types.append( tr( "SMESH_MULTICOLOR" ) );
5209 indices.clear(); indices.append( 0 ); indices.append( 1 );
5210 setPreferenceProperty( coloringType, "strings", types );
5211 setPreferenceProperty( coloringType, "indexes", indices );
5212 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5216 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5218 if( sect=="SMESH" ) {
5219 float sbX1,sbY1,sbW,sbH;
5220 float aTol = 1.00000009999999;
5221 std::string aWarning;
5222 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5223 if( name=="selection_object_color" || name=="selection_element_color" ||
5224 name=="highlight_color" ||
5225 name=="selection_precision_node" || name=="selection_precision_element" ||
5226 name=="selection_precision_object")
5227 SMESH::UpdateSelectionProp( this );
5228 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5229 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5230 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5231 if(sbX1+sbW > aTol){
5232 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5235 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5236 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5239 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5240 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5241 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5242 if(sbY1+sbH > aTol){
5243 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5244 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5245 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5248 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5249 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5250 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5251 if(sbX1+sbW > aTol){
5252 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5255 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5256 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5259 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5260 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5261 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5262 if(sbY1+sbH > aTol){
5263 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5266 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5267 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5270 else if ( name == "segmentation" ) {
5271 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5272 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5274 else if ( name == "nb_segments_per_edge" ) {
5275 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5276 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5278 else if ( name == "historical_python_dump" ||
5279 name == "forget_mesh_on_hyp_modif") {
5280 QString val = aResourceMgr->stringValue( "SMESH", name );
5281 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5283 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5284 SMESH::UpdateFontProp( this );
5286 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5287 SMESH::UpdateFontProp( this );
5290 if(aWarning.size() != 0){
5291 aWarning += "The default values are applied instead.";
5292 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5293 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5294 QObject::tr(aWarning.c_str()));
5299 //================================================================================
5301 * \brief Update something in accordance with update flags
5302 * \param theFlags - update flags
5304 * Update viewer or/and object browser etc. in accordance with update flags ( see
5305 * LightApp_UpdateFlags enumeration ).
5307 //================================================================================
5308 void SMESHGUI::update( const int flags )
5310 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5311 SMESH::UpdateView();
5313 SalomeApp_Module::update( flags );
5316 //================================================================================
5318 * \brief Set default selection mode
5320 * SLOT called when operation commited. Sets default selection mode
5322 //================================================================================
5323 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5325 SVTK_ViewWindow* vtkWnd =
5326 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5328 vtkWnd->SetSelectionMode( ActorSelection );
5331 //================================================================================
5333 * \brief Set default selection mode
5335 * SLOT called when operation aborted. Sets default selection mode
5337 //================================================================================
5338 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5340 SVTK_ViewWindow* vtkWnd =
5341 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5343 vtkWnd->SetSelectionMode( ActorSelection );
5346 //================================================================================
5348 * \brief Creates operation with given identifier
5349 * \param id - identifier of operation to be started
5350 * \return Pointer on created operation or NULL if operation is not created
5352 * Virtual method redefined from the base class creates operation with given id.
5353 * It is called called automatically from startOperation method of base class.
5355 //================================================================================
5356 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5358 LightApp_Operation* op = 0;
5359 // to do : create operation here
5362 case 417: //convert to quadratic
5363 op = new SMESHGUI_ConvToQuadOp();
5365 case 418: // create 2D mesh as boundary on 3D
5366 op = new SMESHGUI_Make2DFrom3DOp();
5368 case 420: // Reorient faces
5369 op = new SMESHGUI_ReorientFacesOp();
5371 case 701: // Compute mesh
5372 op = new SMESHGUI_ComputeOp();
5374 case 702: // Create mesh
5375 op = new SMESHGUI_MeshOp( true, true );
5377 case 703: // Create sub-mesh
5378 op = new SMESHGUI_MeshOp( true, false );
5380 case 704: // Edit mesh/sub-mesh
5381 op = new SMESHGUI_MeshOp( false );
5383 case 711: // Precompute mesh
5384 op = new SMESHGUI_PrecomputeOp();
5386 case 712: // Evaluate mesh
5387 op = new SMESHGUI_EvaluateOp();
5389 case 713: // Evaluate mesh
5390 op = new SMESHGUI_MeshOrderOp();
5392 case 806: // Create group on geom
5393 op = new SMESHGUI_GroupOnShapeOp();
5395 case 904: // Find element
5396 op = new SMESHGUI_FindElemByPointOp();
5398 case 4067: // Make mesh pass through point
5399 op = new SMESHGUI_MakeNodeAtPointOp();
5401 case 4070: // Create 0D elements on all nodes
5402 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5409 op = SalomeApp_Module::createOperation( id );
5413 //================================================================================
5415 * \brief Stops current operations and starts a given one
5416 * \param id - The id of the operation to start
5418 //================================================================================
5420 void SMESHGUI::switchToOperation(int id)
5422 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5423 activeStudy()->abortAllOperations();
5424 startOperation( id );
5427 LightApp_Displayer* SMESHGUI::displayer()
5430 myDisplayer = new SMESHGUI_Displayer( getApp() );
5434 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5437 int aTolerance = 64;
5438 int anIterations = 0;
5444 if( anIterations % aPeriod == 0 )
5447 if( aTolerance < 1 )
5451 aHue = (int)( 360.0 * rand() / RAND_MAX );
5454 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5455 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5456 for( ; it != itEnd; ++it )
5458 SALOMEDS::Color anAutoColor = *it;
5459 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5462 aQColor.getHsv( &h, &s, &v );
5463 if( abs( h - aHue ) < aTolerance )
5475 aColor.setHsv( aHue, 255, 255 );
5477 SALOMEDS::Color aSColor;
5478 aSColor.R = aColor.redF();
5479 aSColor.G = aColor.greenF();
5480 aSColor.B = aColor.blueF();
5485 const char* gSeparator = "_"; // character used to separate parameter names
5486 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5487 const char* gPathSep = "|"; // character used to separate paths
5490 * \brief Store visual parameters
5492 * This method is called just before the study document is saved.
5493 * Store visual parameters in AttributeParameter attribue(s)
5495 void SMESHGUI::storeVisualParameters (int savePoint)
5498 Kernel_Utils::Localizer loc;
5500 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5501 if (!appStudy || !appStudy->studyDS())
5503 _PTR(Study) studyDS = appStudy->studyDS();
5505 // componentName is used for encoding of entries when storing them in IParameters
5506 std::string componentName = myComponentSMESH->ComponentDataType();
5507 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5508 //if (!aSComponent) return;
5511 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5512 componentName.c_str(),
5514 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5516 // store map of custom markers
5517 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5518 if( !aMarkerMap.empty() )
5520 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5521 for( ; anIter != aMarkerMap.end(); anIter++ )
5523 int anId = anIter->first;
5524 VTK::MarkerData aMarkerData = anIter->second;
5525 std::string aMarkerFileName = aMarkerData.first;
5526 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5527 if( aMarkerTexture.size() < 3 )
5528 continue; // should contain at least width, height and the first value
5530 QString aPropertyName( "texture" );
5531 aPropertyName += gSeparator;
5532 aPropertyName += QString::number( anId );
5534 QString aPropertyValue = aMarkerFileName.c_str();
5535 aPropertyValue += gPathSep;
5537 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5538 ushort aWidth = *aTextureIter++;
5539 ushort aHeight = *aTextureIter++;
5540 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5541 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5542 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5543 aPropertyValue += QString::number( *aTextureIter );
5545 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5549 // viewers counters are used for storing view_numbers in IParameters
5552 // main cycle to store parameters of displayed objects
5553 QList<SUIT_ViewManager*> lst;
5554 QList<SUIT_ViewManager*>::Iterator it;
5555 getApp()->viewManagers(lst);
5556 for (it = lst.begin(); it != lst.end(); it++)
5558 SUIT_ViewManager* vman = *it;
5559 QString vType = vman->getType();
5561 // saving VTK actors properties
5562 if (vType == SVTK_Viewer::Type())
5564 // store the clipping planes attached to the view manager
5565 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5566 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5567 if( anIter != myClippingPlaneInfoMap.end() )
5568 aClippingPlaneInfoList = anIter->second;
5570 if( !aClippingPlaneInfoList.empty() ) {
5571 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5572 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5574 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5575 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5577 QString aPropertyName( "ClippingPlane" );
5578 aPropertyName += gSeparator;
5579 aPropertyName += QString::number( vtkViewers );
5580 aPropertyName += gSeparator;
5581 aPropertyName += QString::number( anId );
5583 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5584 aPropertyValue += gDigitsSep;
5585 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5586 aPropertyValue += gDigitsSep;
5587 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5588 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5589 aPropertyValue += gDigitsSep;
5590 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5591 aPropertyValue += gDigitsSep;
5592 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5593 aPropertyValue += gDigitsSep;
5594 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5595 aPropertyValue += gDigitsSep;
5596 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5597 aPropertyValue += gDigitsSep;
5598 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5599 aPropertyValue += gDigitsSep;
5600 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5602 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5603 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5604 aPropertyValue += gDigitsSep;
5605 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5606 aPropertyValue += gDigitsSep;
5607 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5608 aPropertyValue += gDigitsSep;
5609 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5612 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5616 QVector<SUIT_ViewWindow*> views = vman->getViews();
5617 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5619 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5621 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5622 vtkActorCollection* allActors = aCopy.GetActors();
5623 allActors->InitTraversal();
5624 while (vtkActor* actor = allActors->GetNextActor())
5626 if (actor->GetVisibility()) // store only visible actors
5628 SMESH_Actor* aSmeshActor = 0;
5629 if (actor->IsA("SMESH_Actor"))
5630 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5631 if (aSmeshActor && aSmeshActor->hasIO())
5633 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5636 // entry is "encoded" = it does NOT contain component adress,
5637 // since it is a subject to change on next component loading
5638 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5640 std::string param, vtkParam = vType.toLatin1().data();
5641 vtkParam += gSeparator;
5642 vtkParam += QString::number(vtkViewers).toLatin1().data();
5643 vtkParam += gSeparator;
5646 param = vtkParam + "Visibility";
5647 ip->setParameter(entry, param, "On");
5650 param = vtkParam + "Representation";
5651 ip->setParameter(entry, param, QString::number
5652 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5655 param = vtkParam + "IsShrunk";
5656 ip->setParameter(entry, param, QString::number
5657 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5659 // Displayed entities
5660 unsigned int aMode = aSmeshActor->GetEntityMode();
5661 bool isE = aMode & SMESH_Actor::eEdges;
5662 bool isF = aMode & SMESH_Actor::eFaces;
5663 bool isV = aMode & SMESH_Actor::eVolumes;
5664 bool is0d = aMode & SMESH_Actor::e0DElements;
5665 bool isB = aMode & SMESH_Actor::eBallElem;
5667 QString modeStr ("e");
5668 modeStr += gDigitsSep; modeStr += QString::number(isE);
5669 modeStr += gDigitsSep; modeStr += "f";
5670 modeStr += gDigitsSep; modeStr += QString::number(isF);
5671 modeStr += gDigitsSep; modeStr += "v";
5672 modeStr += gDigitsSep; modeStr += QString::number(isV);
5673 modeStr += gDigitsSep; modeStr += "0d";
5674 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5675 modeStr += gDigitsSep; modeStr += "b";
5676 modeStr += gDigitsSep; modeStr += QString::number(isB);
5678 param = vtkParam + "Entities";
5679 ip->setParameter(entry, param, modeStr.toLatin1().data());
5685 aSmeshActor->GetSufaceColor(r, g, b, delta);
5686 QStringList colorStr;
5687 colorStr << "surface";
5688 colorStr << QString::number(r);
5689 colorStr << QString::number(g);
5690 colorStr << QString::number(b);
5692 colorStr << "backsurface";
5693 colorStr << QString::number(delta);
5695 aSmeshActor->GetVolumeColor(r, g, b, delta);
5696 colorStr << "volume";
5697 colorStr << QString::number(r);
5698 colorStr << QString::number(g);
5699 colorStr << QString::number(b);
5700 colorStr << QString::number(delta);
5702 aSmeshActor->GetEdgeColor(r, g, b);
5704 colorStr << QString::number(r);
5705 colorStr << QString::number(g);
5706 colorStr << QString::number(b);
5708 aSmeshActor->GetNodeColor(r, g, b);
5710 colorStr << QString::number(r);
5711 colorStr << QString::number(g);
5712 colorStr << QString::number(b);
5714 aSmeshActor->GetOutlineColor(r, g, b);
5715 colorStr << "outline";
5716 colorStr << QString::number(r);
5717 colorStr << QString::number(g);
5718 colorStr << QString::number(b);
5720 aSmeshActor->Get0DColor(r, g, b);
5721 colorStr << "elem0d";
5722 colorStr << QString::number(r);
5723 colorStr << QString::number(g);
5724 colorStr << QString::number(b);
5726 aSmeshActor->GetBallColor(r, g, b);
5728 colorStr << QString::number(r);
5729 colorStr << QString::number(g);
5730 colorStr << QString::number(b);
5732 aSmeshActor->GetFacesOrientationColor(r, g, b);
5733 colorStr << "orientation";
5734 colorStr << QString::number(r);
5735 colorStr << QString::number(g);
5736 colorStr << QString::number(b);
5738 param = vtkParam + "Colors";
5739 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5742 QStringList sizeStr;
5744 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5745 sizeStr << "outline";
5746 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5747 sizeStr << "elem0d";
5748 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5750 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5751 sizeStr << QString::number((int)aSmeshActor->GetBallScale());
5752 sizeStr << "shrink";
5753 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5754 sizeStr << "orientation";
5755 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5756 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5758 param = vtkParam + "Sizes";
5759 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5764 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5765 if( aMarkerType == VTK::MT_USER ) {
5766 markerStr += "custom";
5767 markerStr += gDigitsSep;
5768 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5772 markerStr += gDigitsSep;
5773 markerStr += QString::number( (int)aMarkerType );
5774 markerStr += gDigitsSep;
5775 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5778 param = vtkParam + "PointMarker";
5779 ip->setParameter(entry, param, markerStr.toLatin1().data());
5782 param = vtkParam + "Opacity";
5783 ip->setParameter(entry, param,
5784 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5787 param = vtkParam + "ClippingPlane";
5789 if( !aClippingPlaneInfoList.empty() ) {
5790 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5791 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5793 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5794 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5795 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5796 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5797 if( aSmeshActor == *anIter2 ) {
5798 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5799 QString::number( anId ).toLatin1().constData() );
5806 ip->setParameter( entry, param, "Off" );
5807 } // if (io->hasEntry())
5808 } // SMESH_Actor && hasIO
5810 } // while.. actors traversal
5814 } // if (SVTK view model)
5815 } // for (viewManagers)
5818 // data structures for clipping planes processing
5822 bool isOpenGLClipping;
5823 vtkIdType RelativeOrientation;
5826 int AbsoluteOrientation;
5827 double X, Y, Z, Dx, Dy, Dz;
5829 typedef std::list<TPlaneData> TPlaneDataList;
5830 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5832 typedef std::list<vtkActor*> TActorList;
5835 TActorList ActorList;
5836 SUIT_ViewManager* ViewManager;
5838 typedef std::list<TPlaneInfo> TPlaneInfoList;
5839 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5842 * \brief Restore visual parameters
5844 * This method is called after the study document is opened.
5845 * Restore visual parameters from AttributeParameter attribue(s)
5847 void SMESHGUI::restoreVisualParameters (int savePoint)
5850 Kernel_Utils::Localizer loc;
5852 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5853 if (!appStudy || !appStudy->studyDS())
5855 _PTR(Study) studyDS = appStudy->studyDS();
5857 // componentName is used for encoding of entries when storing them in IParameters
5858 std::string componentName = myComponentSMESH->ComponentDataType();
5859 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5860 //if (!aSComponent) return;
5863 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5864 componentName.c_str(),
5866 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5868 // restore map of custom markers and map of clipping planes
5869 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5870 TPlaneDataMap aPlaneDataMap;
5872 std::vector<std::string> properties = ip->getProperties();
5873 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5875 std::string property = *propIt;
5876 QString aPropertyName( property.c_str() );
5877 QString aPropertyValue( ip->getProperty( property ).c_str() );
5879 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5880 if( aPropertyNameList.isEmpty() )
5883 QString aPropertyType = aPropertyNameList[0];
5884 if( aPropertyType == "texture" )
5886 if( aPropertyNameList.size() != 2 )
5890 int anId = aPropertyNameList[1].toInt( &ok );
5891 if( !ok || anId < 1 )
5894 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5895 if( aPropertyValueList.size() != 2 )
5898 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5899 QString aMarkerTextureString = aPropertyValueList[1];
5900 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5901 if( aMarkerTextureStringList.size() != 3 )
5905 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5910 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5914 VTK::MarkerTexture aMarkerTexture;
5915 aMarkerTexture.push_back( aWidth );
5916 aMarkerTexture.push_back( aHeight );
5918 QString aMarkerTextureData = aMarkerTextureStringList[2];
5919 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5921 QChar aChar = aMarkerTextureData.at( i );
5922 if( aChar.isDigit() )
5923 aMarkerTexture.push_back( aChar.digitValue() );
5926 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5928 else if( aPropertyType == "ClippingPlane" )
5930 if( aPropertyNameList.size() != 3 )
5934 int aViewId = aPropertyNameList[1].toInt( &ok );
5935 if( !ok || aViewId < 0 )
5939 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5940 if( !ok || aClippingPlaneId < 0 )
5943 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5944 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
5947 TPlaneData aPlaneData;
5948 aPlaneData.Id = aClippingPlaneId;
5951 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
5956 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
5960 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
5963 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
5968 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
5973 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
5978 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
5983 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
5988 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
5993 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
5997 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
5999 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6004 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6009 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6014 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6019 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6020 aPlaneDataList.push_back( aPlaneData );
6024 TPlaneInfoMap aPlaneInfoMap;
6026 std::vector<std::string> entries = ip->getEntries();
6028 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6030 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6031 QString entry (ip->decodeEntry(*entIt).c_str());
6033 // Check that the entry corresponds to a real object in the Study
6034 // as the object may be deleted or modified after the visual state is saved.
6035 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6036 if (!so) continue; //Skip the not existent entry
6038 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6039 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6041 std::vector<std::string>::iterator namesIt = paramNames.begin();
6042 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6044 // actors are stored in a map after displaying of them for
6045 // quicker access in the future: map < viewID to actor >
6046 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6048 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6050 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6051 // '_' is used as separator and should not be used in viewer type or parameter names.
6052 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6053 if (lst.size() != 3)
6056 QString viewerTypStr = lst[0];
6057 QString viewIndexStr = lst[1];
6058 QString paramNameStr = lst[2];
6061 int viewIndex = viewIndexStr.toUInt(&ok);
6062 if (!ok) // bad conversion of view index to integer
6066 if (viewerTypStr == SVTK_Viewer::Type())
6068 SMESH_Actor* aSmeshActor = 0;
6069 if (vtkActors.IsBound(viewIndex))
6070 aSmeshActor = vtkActors.Find(viewIndex);
6072 QList<SUIT_ViewManager*> lst;
6073 getApp()->viewManagers(viewerTypStr, lst);
6075 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6076 SUIT_ViewManager* vman = NULL;
6077 if (viewIndex >= 0 && viewIndex < lst.count())
6078 vman = lst.at(viewIndex);
6080 if (paramNameStr == "Visibility")
6082 if (!aSmeshActor && displayer() && vman)
6084 SUIT_ViewModel* vmodel = vman->getViewModel();
6085 // SVTK view model can be casted to SALOME_View
6086 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6088 // store displayed actor in a temporary map for quicker
6089 // access later when restoring other parameters
6090 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6091 vtkRenderer* Renderer = vtkView->getRenderer();
6092 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6093 vtkActorCollection* theActors = aCopy.GetActors();
6094 theActors->InitTraversal();
6095 bool isFound = false;
6096 vtkActor *ac = theActors->GetNextActor();
6097 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6098 if (ac->IsA("SMESH_Actor")) {
6099 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6100 if (aGeomAc->hasIO()) {
6101 Handle(SALOME_InteractiveObject) io =
6102 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
6103 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6105 vtkActors.Bind(viewIndex, aGeomAc);
6111 } // if (paramNameStr == "Visibility")
6114 // the rest properties "work" with SMESH_Actor
6117 QString val ((*valuesIt).c_str());
6120 if (paramNameStr == "Representation") {
6121 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6124 else if (paramNameStr == "IsShrunk") {
6126 if (!aSmeshActor->IsShrunk())
6127 aSmeshActor->SetShrink();
6130 if (aSmeshActor->IsShrunk())
6131 aSmeshActor->UnShrink();
6134 // Displayed entities
6135 else if (paramNameStr == "Entities") {
6136 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6137 int aEntityMode = SMESH_Actor::eAllEntity;
6138 for ( int i = 0; i < mode.count(); i+=2 ) {
6139 if ( i < mode.count()-1 ) {
6140 QString type = mode[i];
6141 bool val = mode[i+1].toInt();
6142 if ( type == "e" && !val )
6143 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6144 else if ( type == "f" && !val )
6145 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6146 else if ( type == "v" && !val )
6147 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6148 else if ( type == "0d" && !val )
6149 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6150 else if ( type == "b" && !val )
6151 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6154 aSmeshActor->SetEntityMode( aEntityMode );
6157 else if (paramNameStr == "Colors") {
6158 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6165 QColor outlineColor;
6166 QColor orientationColor;
6172 // below lines are required to get default values for delta coefficients
6173 // of backface color for faces and color of reversed volumes
6174 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6175 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6176 for ( int i = 0; i < colors.count(); i++ ) {
6177 QString type = colors[i];
6178 if ( type == "surface" ) {
6179 // face color is set by 3 values r:g:b, where
6180 // - r,g,b - is rgb color components
6181 if ( i+1 >= colors.count() ) break; // format error
6182 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6183 if ( i+2 >= colors.count() ) break; // format error
6184 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6185 if ( i+3 >= colors.count() ) break; // format error
6186 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6187 faceColor.setRgbF( r, g, b );
6190 else if ( type == "backsurface" ) {
6191 // backface color can be defined in several ways
6192 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6193 // - in latest versions, it is set as delta coefficient
6194 bool rgbOk = false, deltaOk;
6195 if ( i+1 >= colors.count() ) break; // format error
6196 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6197 int delta = colors[i+1].toInt( &deltaOk );
6199 if ( i+1 < colors.count() ) // index is shifted to 1
6200 g = colors[i+1].toDouble( &rgbOk );
6201 if ( rgbOk ) i++; // shift index
6202 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6203 b = colors[i+1].toDouble( &rgbOk );
6205 // - as currently there's no way to set directly backsurface color as it was before,
6206 // we ignore old dump where r,g,b triple was set
6207 // - also we check that delta parameter is set properly
6208 if ( !rgbOk && deltaOk )
6211 else if ( type == "volume" ) {
6212 // volume color is set by 4 values r:g:b:delta, where
6213 // - r,g,b - is a normal volume rgb color components
6214 // - delta - is a reversed volume color delta coefficient
6215 if ( i+1 >= colors.count() ) break; // format error
6216 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6217 if ( i+2 >= colors.count() ) break; // format error
6218 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6219 if ( i+3 >= colors.count() ) break; // format error
6220 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6221 if ( i+4 >= colors.count() ) break; // format error
6222 int delta = colors[i+4].toInt( &bOk );
6223 if ( !bOk ) break; // format error
6224 volumeColor.setRgbF( r, g, b );
6228 else if ( type == "edge" ) {
6229 // edge color is set by 3 values r:g:b, where
6230 // - r,g,b - is rgb color components
6231 if ( i+1 >= colors.count() ) break; // format error
6232 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6233 if ( i+2 >= colors.count() ) break; // format error
6234 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6235 if ( i+3 >= colors.count() ) break; // format error
6236 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6237 edgeColor.setRgbF( r, g, b );
6240 else if ( type == "node" ) {
6241 // node color is set by 3 values r:g:b, where
6242 // - r,g,b - is rgb color components
6243 if ( i+1 >= colors.count() ) break; // format error
6244 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6245 if ( i+2 >= colors.count() ) break; // format error
6246 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6247 if ( i+3 >= colors.count() ) break; // format error
6248 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6249 nodeColor.setRgbF( r, g, b );
6252 else if ( type == "elem0d" ) {
6253 // 0d element color is set by 3 values r:g:b, where
6254 // - r,g,b - is rgb color components
6255 if ( i+1 >= colors.count() ) break; // format error
6256 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6257 if ( i+2 >= colors.count() ) break; // format error
6258 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6259 if ( i+3 >= colors.count() ) break; // format error
6260 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6261 elem0dColor.setRgbF( r, g, b );
6264 else if ( type == "ball" ) {
6265 // ball color is set by 3 values r:g:b, where
6266 // - r,g,b - is rgb color components
6267 if ( i+1 >= colors.count() ) break; // format error
6268 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6269 if ( i+2 >= colors.count() ) break; // format error
6270 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6271 if ( i+3 >= colors.count() ) break; // format error
6272 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6273 ballColor.setRgbF( r, g, b );
6276 else if ( type == "outline" ) {
6277 // outline color is set by 3 values r:g:b, where
6278 // - r,g,b - is rgb color components
6279 if ( i+1 >= colors.count() ) break; // format error
6280 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6281 if ( i+2 >= colors.count() ) break; // format error
6282 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6283 if ( i+3 >= colors.count() ) break; // format error
6284 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6285 outlineColor.setRgbF( r, g, b );
6288 else if ( type == "orientation" ) {
6289 // orientation color is set by 3 values r:g:b, where
6290 // - r,g,b - is rgb color components
6291 if ( i+1 >= colors.count() ) break; // format error
6292 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6293 if ( i+2 >= colors.count() ) break; // format error
6294 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6295 if ( i+3 >= colors.count() ) break; // format error
6296 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6297 orientationColor.setRgbF( r, g, b );
6302 if ( nodeColor.isValid() )
6303 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6305 if ( edgeColor.isValid() )
6306 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6308 if ( faceColor.isValid() )
6309 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6311 if ( volumeColor.isValid() )
6312 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6313 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6314 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6316 if ( elem0dColor.isValid() )
6317 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6319 if ( ballColor.isValid() )
6320 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6322 if ( outlineColor.isValid() )
6323 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6324 // orientation color
6325 if ( orientationColor.isValid() )
6326 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6329 else if (paramNameStr == "Sizes") {
6330 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6333 int outlineWidth = -1;
6334 int elem0dSize = -1;
6337 double shrinkSize = -1;
6338 double orientationSize = -1;
6339 bool orientation3d = false;
6340 for ( int i = 0; i < sizes.count(); i++ ) {
6341 QString type = sizes[i];
6342 if ( type == "line" ) {
6343 // line (wireframe) width is given as single integer value
6344 if ( i+1 >= sizes.count() ) break; // format error
6345 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6349 if ( type == "outline" ) {
6350 // outline width is given as single integer value
6351 if ( i+1 >= sizes.count() ) break; // format error
6352 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6356 else if ( type == "elem0d" ) {
6357 // 0d element size is given as single integer value
6358 if ( i+1 >= sizes.count() ) break; // format error
6359 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6363 else if ( type == "ball" ) {
6364 // balls are specified by two values: size:scale, where
6365 // - size - is a integer value specifying size
6366 // - scale - is a integer value specifying scale factor
6367 if ( i+1 >= sizes.count() ) break; // format error
6368 int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6369 if ( i+2 >= sizes.count() ) break; // format error
6370 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6375 else if ( type == "shrink" ) {
6376 // shrink factor is given as single floating point value
6377 if ( i+1 >= sizes.count() ) break; // format error
6378 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6382 else if ( type == "orientation" ) {
6383 // orientation vectors are specified by two values size:3d, where
6384 // - size - is a floating point value specifying scale factor
6385 // - 3d - is a boolean
6386 if ( i+1 >= sizes.count() ) break; // format error
6387 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6388 if ( i+2 >= sizes.count() ) break; // format error
6389 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6390 orientationSize = v1;
6391 orientation3d = (bool)v2;
6395 // line (wireframe) width
6396 if ( lineWidth > 0 )
6397 aSmeshActor->SetLineWidth( lineWidth );
6399 if ( outlineWidth > 0 )
6400 aSmeshActor->SetOutlineWidth( outlineWidth );
6401 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6402 aSmeshActor->SetOutlineWidth( lineWidth );
6404 if ( elem0dSize > 0 )
6405 aSmeshActor->Set0DSize( elem0dSize );
6408 aSmeshActor->SetBallSize( ballSize );
6410 if ( ballScale > 0 )
6411 aSmeshActor->SetBallScale( ballScale );
6413 if ( shrinkSize > 0 )
6414 aSmeshActor->SetShrinkFactor( shrinkSize );
6415 // orientation vectors
6416 if ( orientationSize > 0 ) {
6417 aSmeshActor->SetFacesOrientationScale( orientationSize );
6418 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6422 else if (paramNameStr == "PointMarker") {
6423 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6424 if( data.count() >= 2 ) {
6426 int aParam1 = data[1].toInt( &ok );
6428 if( data[0] == "std" && data.count() == 3 ) {
6429 int aParam2 = data[2].toInt( &ok );
6430 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6432 else if( data[0] == "custom" ) {
6433 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6434 if( markerIt != aMarkerMap.end() ) {
6435 VTK::MarkerData aMarkerData = markerIt->second;
6436 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6443 else if (paramNameStr == "Opacity") {
6444 aSmeshActor->SetOpacity(val.toFloat());
6447 else if (paramNameStr.startsWith("ClippingPlane")) {
6448 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6449 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6450 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6451 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6452 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6453 // new format - val looks like "Off" or "0" (plane id)
6454 // (note: in new format "Off" value is used only for consistency,
6455 // so it is processed together with values in old format)
6456 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6457 if( anIsOldFormat ) {
6458 if (paramNameStr == "ClippingPlane1" || val == "Off")
6459 aSmeshActor->RemoveAllClippingPlanes();
6461 QList<SUIT_ViewManager*> lst;
6462 getApp()->viewManagers(viewerTypStr, lst);
6463 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6464 if (viewIndex >= 0 && viewIndex < lst.count()) {
6465 SUIT_ViewManager* vman = lst.at(viewIndex);
6466 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6468 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6470 SMESH::TActorList anActorList;
6471 anActorList.push_back( aSmeshActor );
6472 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6473 aPlane->myViewWindow = vtkView;
6474 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6475 aPlane->PlaneMode = aMode;
6476 bool isOpenGLClipping = ( bool )vals[1].toInt();
6477 aPlane->IsOpenGLClipping = isOpenGLClipping;
6478 if ( aMode == SMESH::Absolute ) {
6479 aPlane->myAbsoluteOrientation = vals[2].toInt();
6480 aPlane->X = vals[3].toFloat();
6481 aPlane->Y = vals[4].toFloat();
6482 aPlane->Z = vals[5].toFloat();
6483 aPlane->Dx = vals[6].toFloat();
6484 aPlane->Dy = vals[7].toFloat();
6485 aPlane->Dz = vals[8].toFloat();
6487 else if ( aMode == SMESH::Relative ) {
6488 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6489 aPlane->myDistance = vals[3].toFloat();
6490 aPlane->myAngle[0] = vals[4].toFloat();
6491 aPlane->myAngle[1] = vals[5].toFloat();
6495 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6496 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6497 aClippingPlaneInfo.Plane = aPlane;
6498 aClippingPlaneInfo.ActorList = anActorList;
6499 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6507 int aPlaneId = val.toInt( &ok );
6508 if( ok && aPlaneId >= 0 ) {
6509 bool anIsDefinedPlane = false;
6510 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6511 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6512 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6513 TPlaneInfo& aPlaneInfo = *anIter;
6514 if( aPlaneInfo.PlaneId == aPlaneId ) {
6515 aPlaneInfo.ActorList.push_back( aSmeshActor );
6516 anIsDefinedPlane = true;
6520 if( !anIsDefinedPlane ) {
6521 TPlaneInfo aPlaneInfo;
6522 aPlaneInfo.PlaneId = aPlaneId;
6523 aPlaneInfo.ActorList.push_back( aSmeshActor );
6524 aPlaneInfo.ViewManager = vman;
6526 // to make the list sorted by plane id
6527 anIter = aPlaneInfoList.begin();
6528 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6529 const TPlaneInfo& aPlaneInfoRef = *anIter;
6530 if( aPlaneInfoRef.PlaneId > aPlaneId )
6533 aPlaneInfoList.insert( anIter, aPlaneInfo );
6538 } // if (aSmeshActor)
6539 } // other parameters than Visibility
6541 } // for names/parameters iterator
6542 } // for entries iterator
6544 // take into account planes with empty list of actors referred to them
6545 QList<SUIT_ViewManager*> aVMList;
6546 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6548 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6549 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6550 int aViewId = aPlaneDataIter->first;
6551 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6552 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6554 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6556 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6557 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6558 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6559 const TPlaneData& aPlaneData = *anIter2;
6560 int aPlaneId = aPlaneData.Id;
6562 bool anIsFound = false;
6563 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6564 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6565 const TPlaneInfo& aPlaneInfo = *anIter3;
6566 if( aPlaneInfo.PlaneId == aPlaneId ) {
6573 TPlaneInfo aPlaneInfo; // ActorList field is empty
6574 aPlaneInfo.PlaneId = aPlaneId;
6575 aPlaneInfo.ViewManager = aViewManager;
6577 // to make the list sorted by plane id
6578 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6579 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6580 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6581 if( aPlaneInfoRef.PlaneId > aPlaneId )
6584 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6590 // add clipping planes to actors according to the restored parameters
6591 // and update the clipping plane map
6592 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6593 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6594 int aViewId = anIter1->first;
6595 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6597 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6598 if( anIter2 == aPlaneDataMap.end() )
6600 const TPlaneDataList& aPlaneDataList = anIter2->second;
6602 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6603 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6604 const TPlaneInfo& aPlaneInfo = *anIter3;
6605 int aPlaneId = aPlaneInfo.PlaneId;
6606 const TActorList& anActorList = aPlaneInfo.ActorList;
6607 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6611 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6615 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6617 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6618 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6619 const TPlaneData& aPlaneData = *anIter4;
6620 if( aPlaneData.Id == aPlaneId ) {
6621 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6622 aPlane->myViewWindow = aViewWindow;
6623 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6624 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6625 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6626 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6627 aPlane->X = aPlaneData.X;
6628 aPlane->Y = aPlaneData.Y;
6629 aPlane->Z = aPlaneData.Z;
6630 aPlane->Dx = aPlaneData.Dx;
6631 aPlane->Dy = aPlaneData.Dy;
6632 aPlane->Dz = aPlaneData.Dz;
6634 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6635 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6636 aPlane->myDistance = aPlaneData.Distance;
6637 aPlane->myAngle[0] = aPlaneData.Angle[0];
6638 aPlane->myAngle[1] = aPlaneData.Angle[1];
6641 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6642 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6643 aClippingPlaneInfo.Plane = aPlane;
6644 aClippingPlaneInfo.ActorList = anActorList;
6645 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6656 // update all VTK views
6657 QList<SUIT_ViewManager*> lst;
6658 getApp()->viewManagers(lst);
6659 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6660 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6661 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6662 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6663 // set OpenGL clipping planes
6664 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6665 vtkActorCollection* anAllActors = aCopy.GetActors();
6666 anAllActors->InitTraversal();
6667 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6668 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6669 anActor->SetOpenGLClippingPlane();
6671 vtkView->getRenderer()->ResetCameraClippingRange();
6678 \brief Adds preferences for dfont of VTK viewer
6680 \param pIf group identifier
6681 \param param parameter
6682 \return identifier of preferences
6684 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6686 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6688 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6691 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6692 fam.append( tr( "SMESH_FONT_COURIER" ) );
6693 fam.append( tr( "SMESH_FONT_TIMES" ) );
6695 setPreferenceProperty( tfont, "fonts", fam );
6697 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6698 if ( needSize ) f = f | QtxFontEdit::Size;
6699 setPreferenceProperty( tfont, "features", f );
6705 \brief Actions after hypothesis edition
6706 Updates object browser after hypothesis edition
6708 void SMESHGUI::onHypothesisEdit( int result )
6711 SMESHGUI::Modified();
6712 updateObjBrowser( true );
6717 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6718 \param pview view being closed
6720 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6721 #ifndef DISABLE_PLOT2DVIEWER
6722 //Crear all Plot2d Viewers if need.
6723 SMESH::ClearPlot2Viewers(pview);
6727 void SMESHGUI::message( const QString& msg )
6730 QStringList data = msg.split("/");
6731 if ( data.count() > 0 ) {
6732 if ( data.first() == "mesh_loading" ) {
6734 QString entry = data.count() > 1 ? data[1] : QString();
6735 if ( entry.isEmpty() )
6738 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6740 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6743 name = obj->GetName().c_str();
6744 if ( name.isEmpty() )
6747 if ( data.last() == "stop" )
6748 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6750 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6751 QApplication::processEvents();
6757 \brief Connects or disconnects signals about activating and cloning view on the module slots
6758 \param pview view which is connected/disconnected
6760 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6764 SUIT_ViewManager* viewMgr = pview->getViewManager();
6766 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6767 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6769 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6770 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6775 \brief Return \c true if object can be renamed
6777 bool SMESHGUI::renameAllowed( const QString& entry) const {
6778 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6782 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6786 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6791 if(appStudy->isComponent(entry) || obj->isReference())
6794 // check type to prevent renaming of inappropriate objects
6795 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6796 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6797 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6798 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6799 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6800 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6807 Rename object by entry.
6808 \param entry entry of the object
6809 \param name new name of the object
6810 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6812 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6814 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6818 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6823 _PTR(Study) aStudy = appStudy->studyDS();
6828 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6830 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6835 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6836 _PTR(GenericAttribute) anAttr;
6837 _PTR(AttributeName) aName;
6839 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6841 // check type to prevent renaming of inappropriate objects
6842 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6843 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6844 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6845 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6846 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6847 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6848 if ( !name.isEmpty() ) {
6849 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6851 // update name of group object and its actor
6852 Handle(SALOME_InteractiveObject) IObject =
6853 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6855 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6856 if( !aGroupObject->_is_nil() ) {
6857 aGroupObject->SetName( qPrintable(name) );
6858 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6859 anActor->setName( qPrintable(name) );
6869 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6871 static QList<QColor> colors;
6873 if ( colors.isEmpty() ) {
6875 for (int s = 0; s < 2 ; s++)
6877 for (int v = 100; v >= 40; v = v - 20)
6879 for (int h = 0; h < 359 ; h = h + 60)
6881 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6886 static int currentColor = 0;
6888 SALOMEDS::Color color;
6889 color.R = (double)colors[currentColor].red() / 255.0;
6890 color.G = (double)colors[currentColor].green() / 255.0;
6891 color.B = (double)colors[currentColor].blue() / 255.0;
6893 currentColor = (currentColor+1) % colors.count();