1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FileInfoDlg.h"
48 #include "SMESHGUI_FileValidator.h"
49 #include "SMESHGUI_FilterDlg.h"
50 #include "SMESHGUI_FilterLibraryDlg.h"
51 #include "SMESHGUI_FindElemByPointDlg.h"
52 #include "SMESHGUI_GroupDlg.h"
53 #include "SMESHGUI_GroupOnShapeDlg.h"
54 #include "SMESHGUI_GroupOpDlg.h"
55 #include "SMESHGUI_Hypotheses.h"
56 #include "SMESHGUI_Make2DFrom3DOp.h"
57 #include "SMESHGUI_MakeNodeAtPointDlg.h"
58 #include "SMESHGUI_Measurements.h"
59 #include "SMESHGUI_MergeDlg.h"
60 #include "SMESHGUI_MeshInfo.h"
61 #include "SMESHGUI_MeshOp.h"
62 #include "SMESHGUI_MeshOrderOp.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_MultiEditDlg.h"
65 #include "SMESHGUI_NodesDlg.h"
66 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
67 #include "SMESHGUI_PropertiesDlg.h"
68 #include "SMESHGUI_RemoveElementsDlg.h"
69 #include "SMESHGUI_RemoveNodesDlg.h"
70 #include "SMESHGUI_RenumberingDlg.h"
71 #include "SMESHGUI_ReorientFacesDlg.h"
72 #include "SMESHGUI_RevolutionDlg.h"
73 #include "SMESHGUI_RotationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_Selection.h"
76 #include "SMESHGUI_SewingDlg.h"
77 #include "SMESHGUI_SingleEditDlg.h"
78 #include "SMESHGUI_SmoothingDlg.h"
79 #include "SMESHGUI_SymmetryDlg.h"
80 #include "SMESHGUI_TranslationDlg.h"
81 #include "SMESHGUI_TransparencyDlg.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_GroupUtils.h"
85 #include "SMESHGUI_HypothesesUtils.h"
86 #include "SMESHGUI_MeshUtils.h"
87 #include "SMESHGUI_PatternUtils.h"
88 #include "SMESHGUI_Utils.h"
89 #include "SMESHGUI_VTKUtils.h"
91 #include <SMESH_version.h>
93 #include "SMESH_ControlsDef.hxx"
94 #include <SMESH_Actor.h>
95 #include <SMESH_ActorUtils.h>
96 #include <SMESH_Client.hxx>
97 #include <SMESH_ScalarBarActor.h>
98 #include <SMESH_TypeFilter.hxx>
100 // SALOME GUI includes
101 #include <SalomeApp_Application.h>
102 #include <SalomeApp_CheckFileDlg.h>
103 #include <SalomeApp_DataObject.h>
104 #include <SalomeApp_Study.h>
105 #include <SalomeApp_Tools.h>
107 #include <LightApp_DataOwner.h>
108 #include <LightApp_NameDlg.h>
109 #include <LightApp_Preferences.h>
110 #include <LightApp_SelectionMgr.h>
111 #include <LightApp_UpdateFlags.h>
113 #include <SVTK_ViewManager.h>
114 #include <SVTK_ViewModel.h>
115 #include <SVTK_ViewWindow.h>
117 #include <VTKViewer_Algorithm.h>
119 #include <SUIT_Desktop.h>
120 #include <SUIT_FileDlg.h>
121 #include <SUIT_MessageBox.h>
122 #include <SUIT_OverrideCursor.h>
123 #include <SUIT_ResourceMgr.h>
124 #include <SUIT_Session.h>
126 #include <QtxPopupMgr.h>
127 #include <QtxFontEdit.h>
129 #include <SALOME_ListIO.hxx>
130 #include <SALOME_ListIteratorOfListIO.hxx>
132 #ifndef DISABLE_PLOT2DVIEWER
133 #include <SPlot2d_ViewModel.h>
134 #include <SPlot2d_Histogram.h>
138 #include <SALOMEconfig.h>
139 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
140 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
141 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
144 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
145 #include <QApplication>
147 #include <QTextStream>
150 #include <boost/shared_ptr.hpp>
153 #include <vtkCallbackCommand.h>
154 #include <vtkCamera.h>
155 #include <vtkLookupTable.h>
156 #include <vtkPlane.h>
157 #include <vtkRenderer.h>
159 // SALOME KERNEL includes
160 #include <SALOMEDSClient_ClientFactory.hxx>
161 #include <SALOMEDSClient_IParameters.hxx>
162 #include <SALOMEDSClient_SComponent.hxx>
163 #include <SALOMEDSClient_StudyBuilder.hxx>
164 #include <SALOMEDS_Study.hxx>
167 #include <Standard_ErrorHandler.hxx>
168 #include <NCollection_DataMap.hxx>
170 #include <Basics_Utils.hxx>
172 //To disable automatic genericobj management, the following line should be commented.
173 //Otherwise, it should be uncommented.
174 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
175 #define WITHGENERICOBJ
177 // Below macro, when uncommented, switches on simplified (more performant) algorithm
178 // of auto-color picking up
179 #define SIMPLE_AUTOCOLOR
183 //=============================================================
184 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
187 void ExportMeshToFile(int theCommandID);
189 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
191 void SetDisplayEntity(int theCommandID);
193 void Control( int theCommandID );
197 //=============================================================
198 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
202 std::string myExtension;
204 if ( theCommandID == 113 ) {
205 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
206 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
208 else if ( theCommandID == 112 ) {
209 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
211 else if ( theCommandID == 111 ) {
212 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
214 else if ( theCommandID == 115 ) {
215 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
217 else if ( theCommandID == 116 ) {
218 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
220 else if ( theCommandID == 117 ) {
221 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
222 filter.append( QObject::tr( "All files (*)" ) );
224 else if ( theCommandID == 118 ) {
225 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
226 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
229 QString anInitialPath = "";
230 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
231 anInitialPath = QDir::currentPath();
233 QStringList filenames;
234 bool toCreateGroups = true;
236 // if ( theCommandID == 118 ) { // GMF
237 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
238 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
239 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
240 // fd->setNameFilters( filter );
241 // fd->SetChecked( true );
243 // filenames << fd->selectedFile();
244 // toCreateGroups = fd->IsChecked();
250 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
253 QObject::tr( "SMESH_IMPORT_MESH" ) );
255 if ( filenames.count() > 0 ) {
256 SUIT_OverrideCursor wc;
257 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
260 QStringList anEntryList;
261 bool isEmpty = false;
262 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
263 QString filename = *it;
264 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
266 switch ( theCommandID ) {
269 // DAT format (currently unsupported)
270 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
271 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
277 aMeshes->length( 1 );
278 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
279 if ( aMeshes[0]->_is_nil() )
280 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
281 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
287 SMESH::DriverMED_ReadStatus res;
288 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
289 if ( res != SMESH::DRS_OK ) {
290 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
291 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
298 aMeshes->length( 1 );
299 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
300 if ( aMeshes[0]->_is_nil() ) {
301 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
302 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
309 SMESH::DriverMED_ReadStatus res;
310 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
311 if ( res != SMESH::DRS_OK ) {
312 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
313 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
320 SMESH::DriverMED_ReadStatus res;
321 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
322 if ( res != SMESH::DRS_OK ) {
323 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
324 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
331 SMESH::ComputeError_var res;
332 aMeshes->length( 1 );
333 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toLatin1().constData(),
336 if ( res->code != SMESH::DRS_OK ) {
337 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
338 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
339 if ( strlen( res->comment.in() ) > 0 ) {
340 errors.back() += ": ";
341 errors.back() += res->comment.in();
348 catch ( const SALOME::SALOME_Exception& S_ex ) {
349 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
350 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
353 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
354 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
356 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
357 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
358 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
359 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
360 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
362 anEntryList.append( aMeshSO->GetID().c_str() );
364 // obj has been published in study. Its refcount has been incremented.
365 // It is safe to decrement its refcount
366 // so that it will be destroyed when the entry in study will be removed
367 aMeshes[i]->UnRegister();
375 // update Object browser
376 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
378 // browse to the published meshes
379 if( LightApp_Application* anApp =
380 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
381 anApp->browseObjects( anEntryList );
383 // show Error message box if there were errors
384 if ( errors.count() > 0 ) {
385 SUIT_MessageBox::critical( SMESHGUI::desktop(),
386 QObject::tr( "SMESH_ERROR" ),
387 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
390 // show warning message box, if some imported mesh is empty
392 SUIT_MessageBox::warning( SMESHGUI::desktop(),
393 QObject::tr( "SMESH_WRN_WARNING" ),
394 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
399 //================================================================================
401 * \brief Export selected meshes or groups into a file
403 //================================================================================
405 void ExportMeshToFile( int theCommandID )
407 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
408 SALOME_ListIO selected;
410 aSel->selectedObjects( selected );
412 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
413 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
414 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
415 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
416 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
417 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
418 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
420 // actually, the following condition can't be met (added for insurance)
421 if( selected.Extent() == 0 ||
422 ( selected.Extent() > 1 && !isMED && !isSTL ))
425 // get mesh object from selection and check duplication of their names
426 bool hasDuplicatedMeshNames = false;
427 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
428 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
429 SALOME_ListIteratorOfListIO It( selected );
430 for( ; It.More(); It.Next() )
432 Handle(SALOME_InteractiveObject) anIObject = It.Value();
433 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
434 if ( aMeshItem->_is_nil() ) {
435 SUIT_MessageBox::warning( SMESHGUI::desktop(),
436 QObject::tr( "SMESH_WRN_WARNING" ),
437 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
441 QString aMeshName = anIObject->getName();
443 // check for name duplications
444 if ( !hasDuplicatedMeshNames )
445 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
446 if( aMeshName == (*aMeshIter).second ) {
447 hasDuplicatedMeshNames = true;
452 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
455 if( hasDuplicatedMeshNames && isMED ) {
456 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
457 QObject::tr("SMESH_WRN_WARNING"),
458 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
459 QObject::tr("SMESH_BUT_YES"),
460 QObject::tr("SMESH_BUT_NO"), 0, 1);
465 aMeshIter = aMeshList.begin();
466 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
467 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
468 QString aMeshName = (*aMeshIter).second;
470 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
472 // check for equal group names within each mesh
473 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
474 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
475 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
476 int aRet = SUIT_MessageBox::warning
477 (SMESHGUI::desktop(),
478 QObject::tr("SMESH_WRN_WARNING"),
479 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
480 QObject::tr("SMESH_BUT_YES"),
481 QObject::tr("SMESH_BUT_NO"), 0, 1);
488 // Warn the user about presence of not supported elements
490 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
494 notSupportedElemTypes.push_back( SMESH::Entity_0D );
495 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
500 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
501 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
502 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
503 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
504 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
505 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
506 notSupportedElemTypes.push_back( SMESH::Entity_0D );
507 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
512 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
513 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
514 notSupportedElemTypes.push_back( SMESH::Entity_0D );
515 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
520 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
521 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
526 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
527 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
528 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
529 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
530 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
531 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
532 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
537 notSupportedElemTypes.push_back( SMESH::Entity_0D );
538 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
539 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
540 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
541 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
542 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
543 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
544 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
547 if ( ! notSupportedElemTypes.empty() )
549 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
550 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
551 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
552 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
554 if ( !presentNotSupported.empty() )
557 const char* typeMsg[SMESH::Entity_Last] = {
558 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
559 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
560 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
561 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
562 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
563 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
564 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
565 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
567 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
568 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
569 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
570 if ( iType != presentNotSupported.size() - 1 )
571 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
573 int aRet = SUIT_MessageBox::warning
574 (SMESHGUI::desktop(),
575 QObject::tr("SMESH_WRN_WARNING"),
576 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
577 QObject::tr("SMESH_BUT_YES"),
578 QObject::tr("SMESH_BUT_NO"), 0, 1);
583 // Get parameters of export operation
586 SMESH::MED_VERSION aFormat;
587 // Init the parameters with the default values
588 bool aIsASCII_STL = true;
589 bool toCreateGroups = false;
590 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
592 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
593 bool toOverwrite = true;
595 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
596 QString anInitialPath = "";
597 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
598 anInitialPath = QDir::currentPath();
600 // Get a file name to write in and additional otions
601 if ( isUNV || isDAT || isGMF ) // Export w/o options
604 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
606 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
608 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
609 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
610 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
611 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
612 anInitialPath + QString("/") + aMeshName,
613 aFilter, aTitle, false);
615 // else if ( isGMF )// Export to GMF
617 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
618 // ( SMESHGUI::desktop(), false, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
619 // QStringList filters;
620 // filters << QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)"
621 // << QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
622 // fd->setWindowTitle( aTitle );
623 // fd->setNameFilters( filters );
625 // if ( !aMeshOrGroup->_is_equivalent( aMesh ))
626 // toCreateGroups = false;
628 // toCreateGroups = ( aMesh->NbGroups() > 0 );
630 // fd->SetChecked( true );
631 // if ( !anInitialPath.isEmpty() )
632 // fd->setDirectory( anInitialPath );
633 // fd->selectFile(aMeshName);
636 // aFilename = fd->selectedFile();
637 // toCreateGroups = fd->IsChecked();
641 else if ( isCGNS )// Export to CGNS
643 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
644 fd->setWindowTitle( aTitle );
645 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
646 if ( !anInitialPath.isEmpty() )
647 fd->setDirectory( anInitialPath );
648 fd->selectFile(aMeshName);
649 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
650 fd->setValidator( fv );
653 aFilename = fd->selectedFile();
654 toOverwrite = fv->isOverwrite();
658 else if ( isSTL ) // Export to STL
660 QMap<QString, int> aFilterMap;
661 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
662 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
665 QMap<QString, int>::const_iterator it = aFilterMap.begin();
666 for ( ; it != aFilterMap.end(); ++it )
667 filters.push_back( it.key() );
669 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
670 fd->setWindowTitle( aTitle );
671 fd->setNameFilters( filters );
672 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
673 if ( !anInitialPath.isEmpty() )
674 fd->setDirectory( anInitialPath );
675 fd->selectFile(aMeshName);
679 aFilename = fd->selectedFile();
680 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
685 else if ( isMED || isSAUV ) // Export to MED or SAUV
687 QMap<QString, SMESH::MED_VERSION> aFilterMap;
688 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
690 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
691 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
692 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
695 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
696 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
697 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
701 QString aDefaultFilter;
702 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
703 for ( ; it != aFilterMap.end(); ++it ) {
704 filters.push_back( it.key() );
705 if (it.value() == SMESH::MED_V2_2)
706 aDefaultFilter = it.key();
709 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
710 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
711 fd->setWindowTitle( aTitle );
712 fd->setNameFilters( filters );
713 fd->selectNameFilter(aDefaultFilter);
714 fd->SetChecked(toCreateGroups);
715 if ( !anInitialPath.isEmpty() )
716 fd->setDirectory( anInitialPath );
717 fd->selectFile(aMeshName);
719 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
720 fd->setValidator( fv );
725 aFilename = fd->selectedFile();
727 aFilename = QString::null;
730 aFormat = aFilterMap[fd->selectedNameFilter()];
731 toOverwrite = fv->isOverwrite();
733 if ( !aFilename.isEmpty() ) {
734 // med-2.1 does not support poly elements
735 if ( aFormat==SMESH::MED_V2_1 )
736 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
737 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
738 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
739 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
740 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
742 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
743 QObject::tr("SMESH_WRN_WARNING"),
744 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
745 QObject::tr("SMESH_BUT_YES"),
746 QObject::tr("SMESH_BUT_NO"), 0, 1);
754 // can't append to an existing using other format
755 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
756 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
757 if( !isVersionOk || aVersion != aFormat ) {
758 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
759 QObject::tr("SMESH_WRN_WARNING"),
760 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
761 QObject::tr("SMESH_BUT_YES"),
762 QObject::tr("SMESH_BUT_NO"), 0, 1);
769 QStringList aMeshNamesCollisionList;
770 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
771 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
772 QString anExistingMeshName( aMeshNames[ i ] );
773 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
774 QString anExportMeshName = (*aMeshIter).second;
775 if( anExportMeshName == anExistingMeshName ) {
776 aMeshNamesCollisionList.append( anExportMeshName );
781 if( !aMeshNamesCollisionList.isEmpty() ) {
782 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
783 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
784 QObject::tr("SMESH_WRN_WARNING"),
785 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
786 QObject::tr("SMESH_BUT_YES"),
787 QObject::tr("SMESH_BUT_NO"),
788 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
797 toCreateGroups = fd->IsChecked();
807 if ( !aFilename.isEmpty() ) {
808 // Check whether the file already exists and delete it if yes
809 QFile aFile( aFilename );
810 if ( aFile.exists() && toOverwrite )
812 SUIT_OverrideCursor wc;
815 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
816 // bool Renumber = false;
817 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
819 // Renumber= resMgr->booleanValue("renumbering");
821 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
822 // aMeshEditor->RenumberNodes();
823 // aMeshEditor->RenumberElements();
824 // if ( SMESHGUI::automaticUpdate() )
825 // SMESH::UpdateView();
829 aMeshIter = aMeshList.begin();
830 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
832 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
833 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
834 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
835 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
836 aFormat, toOverwrite && aMeshIndex == 0 );
838 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
839 aFormat, toOverwrite && aMeshIndex == 0 );
844 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
846 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
847 if( !aMeshItem->_is_nil() )
848 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
853 if ( aMeshOrGroup->_is_equivalent( aMesh ))
854 aMesh->ExportDAT( aFilename.toLatin1().data() );
856 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
860 if ( aMeshOrGroup->_is_equivalent( aMesh ))
861 aMesh->ExportUNV( aFilename.toLatin1().data() );
863 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
867 if ( aMeshOrGroup->_is_equivalent( aMesh ))
868 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
870 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
874 aMeshIter = aMeshList.begin();
875 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
877 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
878 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
879 aMeshItem->ExportCGNS( aMeshOrGroup,
880 aFilename.toLatin1().data(),
881 toOverwrite && aMeshIndex == 0 );
886 toCreateGroups = true;
887 aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups );
890 catch (const SALOME::SALOME_Exception& S_ex){
892 SUIT_MessageBox::warning(SMESHGUI::desktop(),
893 QObject::tr("SMESH_WRN_WARNING"),
894 QObject::tr("SMESH_EXPORT_FAILED"));
900 inline void InverseEntityMode(unsigned int& theOutputMode,
901 unsigned int theMode)
903 bool anIsNotPresent = ~theOutputMode & theMode;
905 theOutputMode |= theMode;
907 theOutputMode &= ~theMode;
910 void SetDisplayEntity(int theCommandID){
911 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
912 SALOME_ListIO selected;
914 aSel->selectedObjects( selected );
916 if(selected.Extent() >= 1){
917 SALOME_ListIteratorOfListIO It( selected );
918 for( ; It.More(); It.Next()){
919 Handle(SALOME_InteractiveObject) IObject = It.Value();
920 if(IObject->hasEntry()){
921 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
922 unsigned int aMode = anActor->GetEntityMode();
923 switch(theCommandID){
925 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
928 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
931 InverseEntityMode(aMode,SMESH_Actor::eEdges);
934 InverseEntityMode(aMode,SMESH_Actor::eFaces);
937 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
940 aMode = SMESH_Actor::eAllEntity;
944 anActor->SetEntityMode(aMode);
952 SALOME_ListIO selected;
953 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
957 LightApp_SelectionMgr* aSel = app->selectionMgr();
958 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
959 if( !aSel || !appStudy )
962 aSel->selectedObjects( selected );
963 if( selected.IsEmpty() )
966 Handle(SALOME_InteractiveObject) anIObject = selected.First();
968 _PTR(Study) aStudy = appStudy->studyDS();
969 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
970 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
971 if( aMainObject->_is_nil() )
974 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
976 QList<SALOMEDS::Color> aReservedColors;
978 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
979 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
981 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
982 //SALOMEDS::Color aColor = aGroupObject->GetColor();
984 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
985 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
986 #else // old algorithm for auto-colors
987 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
988 aReservedColors.append( aColor );
989 #endif // SIMPLE_AUTOCOLOR
991 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
995 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
996 switch ( aGroupObject->GetType ()) {
998 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1000 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1002 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1004 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1006 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1007 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1010 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1011 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1017 SMESH::RepaintCurrentView();
1020 QString functorToString( SMESH::Controls::FunctorPtr f )
1022 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1023 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1024 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1025 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1026 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1027 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1028 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1029 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1030 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1031 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1032 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1033 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1034 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1035 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1036 type = QObject::tr( "WARP_ELEMENTS" );
1037 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1038 type = QObject::tr( "TAPER_ELEMENTS" );
1039 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1040 type = QObject::tr( "SKEW_ELEMENTS" );
1041 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1042 type = QObject::tr( "AREA_ELEMENTS" );
1043 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1044 type = QObject::tr( "LENGTH_EDGES" );
1045 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1046 type = QObject::tr( "LENGTH2D_EDGES" );
1047 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1048 type = QObject::tr( "MULTI_BORDERS" );
1049 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1050 type = QObject::tr( "MULTI2D_BORDERS" );
1051 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1052 type = QObject::tr( "FREE_NODES" );
1053 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1054 type = QObject::tr( "FREE_EDGES" );
1055 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1056 type = QObject::tr( "FREE_BORDERS" );
1057 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1058 type = QObject::tr( "FREE_FACES" );
1059 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1060 type = QObject::tr( "BARE_BORDER_VOLUME" );
1061 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1062 type = QObject::tr( "BARE_BORDER_FACE" );
1063 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1064 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1065 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1066 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1067 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1068 type = QObject::tr( "EQUAL_NODE" );
1069 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1070 type = QObject::tr( "EQUAL_EDGE" );
1071 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1072 type = QObject::tr( "EQUAL_FACE" );
1073 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1074 type = QObject::tr( "EQUAL_VOLUME" );
1078 void SaveDistribution()
1080 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1081 SALOME_ListIO selected;
1083 aSel->selectedObjects( selected );
1085 if ( selected.Extent() == 1 ) {
1086 Handle(SALOME_InteractiveObject) anIO = selected.First();
1087 if ( anIO->hasEntry() ) {
1088 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1089 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1090 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1091 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1092 if ( aScalarBarActor && aFunctor ) {
1093 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1095 std::vector<int> elements;
1096 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1097 if ( mesh->_is_nil() ) {
1098 SMESH::SMESH_IDSource_var idSource =
1099 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1100 if ( !idSource->_is_nil() )
1102 SMESH::long_array_var ids = idSource->GetIDs();
1103 elements.resize( ids->length() );
1104 for ( unsigned i = 0; i < elements.size(); ++i )
1105 elements[i] = ids[i];
1108 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1109 vtkLookupTable* lookupTable =
1110 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1111 double * minmax = lookupTable->GetRange();
1112 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1113 std::vector<int> nbEvents;
1114 std::vector<double> funValues;
1115 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1116 QString anInitialPath = "";
1117 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1118 anInitialPath = QDir::currentPath();
1119 QString aMeshName = anIO->getName();
1121 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1122 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1123 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1124 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1125 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1128 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1130 if ( !aFilename.isEmpty() ) {
1131 QFile f( aFilename );
1132 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1133 QTextStream out( &f );
1134 out << "# Mesh: " << aMeshName << endl;
1135 out << "# Control: " << functorToString( aFunctor ) << endl;
1137 out.setFieldWidth( 10 );
1138 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1139 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1150 void ShowDistribution() {
1151 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1152 SALOME_ListIO selected;
1154 aSel->selectedObjects( selected );
1156 if ( selected.Extent() == 1 ) {
1157 Handle(SALOME_InteractiveObject) anIO = selected.First();
1158 if ( anIO->hasEntry() ) {
1159 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1160 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1161 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1162 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1168 #ifndef DISABLE_PLOT2DVIEWER
1169 void PlotDistribution() {
1170 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1174 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1175 SALOME_ListIO selected;
1177 aSel->selectedObjects( selected );
1179 if ( selected.Extent() == 1 ) {
1180 Handle(SALOME_InteractiveObject) anIO = selected.First();
1181 if ( anIO->hasEntry() ) {
1182 //Find Actor by entry before getting Plot2d viewer,
1183 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1184 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1186 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1191 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1195 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1199 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1200 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1201 QString functorName = functorToString( anActor->GetFunctor());
1202 QString aHistogramName("%1 : %2");
1203 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1204 aHistogram->setName(aHistogramName);
1205 aHistogram->setHorTitle(functorName);
1206 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1207 aPlot->displayObject(aHistogram, true);
1212 #endif //DISABLE_PLOT2DVIEWER
1214 void DisableAutoColor(){
1215 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1216 SALOME_ListIO selected;
1218 aSel->selectedObjects( selected );
1220 if(selected.Extent()){
1221 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1222 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1223 if ( !aMesh->_is_nil() ) {
1224 aMesh->SetAutoColor( false );
1229 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1231 SALOME_ListIO selected;
1232 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1236 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1237 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1238 if( !aSel || !appStudy )
1241 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1242 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1243 aModule->EmitSignalDeactivateDialog();
1244 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1245 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1250 _PTR(Study) aStudy = appStudy->studyDS();
1252 aSel->selectedObjects( selected );
1254 if(selected.Extent() >= 1){
1255 switch(theCommandID){
1257 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1258 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1263 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1264 QColor orientationColor, outlineColor, volumeColor;
1265 int deltaF = 0, deltaV = 0;
1269 int outlineWidth = 1;
1270 double shrinkCoef = 0.0;
1271 double orientationScale = 0.0;
1272 bool orientation3d = false;
1273 VTK::MarkerType markerType = VTK::MT_NONE;
1274 VTK::MarkerScale markerScale = VTK::MS_NONE;
1276 bool hasNodes = false;
1277 int presentEntities = 0;
1278 bool firstTime = true;
1280 SALOME_ListIteratorOfListIO It( selected );
1281 for ( ; It.More(); It.Next() ) {
1282 Handle(SALOME_InteractiveObject) IObject = It.Value();
1283 if ( !IObject->hasEntry() ) continue;
1284 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1285 if ( !anActor || !anActor->GetObject() ) continue;
1288 // nodes: color, marker
1289 anActor->GetNodeColor( color[0], color[1], color[2] );
1290 nodeColor.setRgbF( color[0], color[1], color[2] );
1291 markerType = anActor->GetMarkerType();
1292 markerScale = anActor->GetMarkerScale();
1293 markerId = anActor->GetMarkerTexture();
1294 // edges: color, width
1295 anActor->GetEdgeColor( color[0], color[1], color[2] );
1296 edgeColor.setRgbF( color[0], color[1], color[2] );
1297 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1298 // faces: front color, back color (delta)
1299 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1300 faceColor.setRgbF( color[0], color[1], color[2] );
1301 // faces: front color, back color (delta)
1302 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1303 volumeColor.setRgbF( color[0], color[1], color[2] );
1304 // 0d elements: color, size
1305 anActor->Get0DColor( color[0], color[1], color[2] );
1306 elem0dColor.setRgbF( color[0], color[1], color[2] );
1307 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1308 // balls: color, size
1309 anActor->GetBallColor( color[0], color[1], color[2] );
1310 ballColor.setRgbF( color[0], color[1], color[2] );
1311 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1313 anActor->GetOutlineColor( color[0], color[1], color[2] );
1314 outlineColor.setRgbF( color[0], color[1], color[2] );
1315 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1316 // orientation vectors: color, scale, 3d flag
1317 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1318 orientationColor.setRgbF( color[0], color[1], color[2] );
1319 orientationScale = anActor->GetFacesOrientationScale();
1320 orientation3d = anActor->GetFacesOrientation3DVectors();
1322 shrinkCoef = anActor->GetShrinkFactor();
1325 firstTime = false; // we only take properties from first object (for performance reasons)
1328 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1329 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1330 presentEntities = presentEntities | SMESH_Actor::eEdges;
1331 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1332 presentEntities = presentEntities | SMESH_Actor::eFaces;
1333 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1334 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1335 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1336 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1337 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1338 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1340 // as we know that all types of elements are present, we can exit the loop
1341 if ( presentEntities == SMESH_Actor::eAllEntity )
1345 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1346 // nodes: color, marker
1347 dlg.setNodeColor( nodeColor );
1348 if( markerType != VTK::MT_USER )
1349 dlg.setNodeMarker( markerType, markerScale );
1351 dlg.setNodeCustomMarker( markerId );
1352 // edges: color, line width
1353 dlg.setEdgeColor( edgeColor );
1354 dlg.setEdgeWidth( edgeWidth );
1355 // faces: front color, back color
1356 dlg.setFaceColor( faceColor, deltaF );
1357 // volumes: normal color, reversed color
1358 dlg.setVolumeColor( volumeColor, deltaV );
1359 // outlines: color, line width
1360 dlg.setOutlineColor( outlineColor );
1361 dlg.setOutlineWidth( outlineWidth );
1362 // 0d elements: color, size
1363 dlg.setElem0dColor( elem0dColor );
1364 dlg.setElem0dSize( elem0dSize );
1365 // balls: color, size
1366 dlg.setBallColor( ballColor );
1367 dlg.setBallSize( ballSize );
1368 // orientation: color, scale, 3d flag
1369 dlg.setOrientationColor( orientationColor );
1370 dlg.setOrientationSize( int( orientationScale * 100. ) );
1371 dlg.setOrientation3d( orientation3d );
1372 // shrink: scale factor
1373 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1374 // hide unused controls
1375 dlg.showControls( presentEntities, hasNodes );
1378 nodeColor = dlg.nodeColor();
1379 markerType = dlg.nodeMarkerType();
1380 markerScale = dlg.nodeMarkerScale();
1381 markerId = dlg.nodeMarkerId();
1382 edgeColor = dlg.edgeColor();
1383 edgeWidth = dlg.edgeWidth();
1384 faceColor = dlg.faceColor();
1385 deltaF = dlg.faceColorDelta();
1386 volumeColor = dlg.volumeColor();
1387 deltaV = dlg.volumeColorDelta();
1388 outlineColor = dlg.outlineColor();
1389 outlineWidth = dlg.outlineWidth();
1390 elem0dColor = dlg.elem0dColor();
1391 elem0dSize = dlg.elem0dSize();
1392 ballColor = dlg.ballColor();
1393 ballSize = dlg.ballSize();
1394 orientationColor = dlg.orientationColor();
1395 orientationScale = dlg.orientationSize() / 100.;
1396 orientation3d = dlg.orientation3d();
1397 shrinkCoef = dlg.shrinkCoef() / 100.;
1399 // store point markers map that might be changed by the user
1400 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1402 // set properties from dialog box to the presentations
1403 SALOME_ListIteratorOfListIO It( selected );
1404 for ( ; It.More(); It.Next() ) {
1405 Handle(SALOME_InteractiveObject) IObject = It.Value();
1406 if ( !IObject->hasEntry() ) continue;
1407 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1408 if ( !anActor ) continue;
1410 // nodes: color, marker
1411 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1412 if ( markerType != VTK::MT_USER ) {
1413 anActor->SetMarkerStd( markerType, markerScale );
1416 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1417 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1418 if ( iter != markerMap.end() )
1419 anActor->SetMarkerTexture( markerId, iter->second.second );
1421 // volumes: normal color, reversed color (delta)
1422 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1423 // faces: front color, back color (delta)
1424 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1425 // edges: color, width
1426 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1427 anActor->SetLineWidth( edgeWidth );
1429 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1430 anActor->SetOutlineWidth( outlineWidth );
1431 // 0D elements: color, size
1432 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1433 anActor->Set0DSize( elem0dSize );
1434 // balls: color, size
1435 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1436 anActor->SetBallSize( ballSize );
1437 // orientation: color, scale, 3d flag
1438 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1439 anActor->SetFacesOrientationScale( orientationScale );
1440 anActor->SetFacesOrientation3DVectors( orientation3d );
1442 anActor->SetShrinkFactor( shrinkCoef );
1444 // for groups, set also proper color
1445 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1446 if ( !aGroupObject->_is_nil() ) {
1447 SMESH::ElementType anElementType = aGroupObject->GetType();
1449 switch( anElementType ) {
1451 aColor = nodeColor; break;
1453 aColor = edgeColor; break;
1455 aColor = faceColor; break;
1457 aColor = volumeColor; break;
1459 aColor = elem0dColor; break;
1461 aColor = ballColor; break;
1465 if ( aColor.isValid() ) {
1466 SALOMEDS::Color aGroupColor;
1467 aGroupColor.R = aColor.redF();
1468 aGroupColor.G = aColor.greenF();
1469 aGroupColor.B = aColor.blueF();
1470 aGroupObject->SetColor( aGroupColor );
1472 } // if ( !aGroupObject->_is_nil() )
1473 } // for ( ; It.More(); It.Next() )
1474 SMESH::RepaintCurrentView();
1475 } // if ( dlg.exec() )
1478 } // switch(theCommandID)
1479 SALOME_ListIteratorOfListIO It( selected );
1480 for( ; It.More(); It.Next()){
1481 Handle(SALOME_InteractiveObject) IObject = It.Value();
1482 if(IObject->hasEntry()){
1483 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1484 switch(theCommandID){
1486 anActor->SetRepresentation(SMESH_Actor::eEdge);
1489 anActor->SetRepresentation(SMESH_Actor::eSurface);
1492 if(anActor->IsShrunk())
1493 anActor->UnShrink();
1495 anActor->SetShrink();
1498 anActor->SetRepresentation(SMESH_Actor::ePoint);
1501 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1502 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1505 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1506 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1512 SMESH::RepaintCurrentView();
1516 void Control( int theCommandID )
1518 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1519 SALOME_ListIO selected;
1521 aSel->selectedObjects( selected );
1523 if( !selected.IsEmpty() ){
1524 Handle(SALOME_InteractiveObject) anIO = selected.First();
1526 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1527 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1528 switch ( theCommandID ){
1530 aControl = SMESH_Actor::eLength;
1533 aControl = SMESH_Actor::eLength2D;
1536 aControl = SMESH_Actor::eFreeEdges;
1539 aControl = SMESH_Actor::eFreeBorders;
1542 aControl = SMESH_Actor::eMultiConnection;
1545 aControl = SMESH_Actor::eFreeNodes;
1548 aControl = SMESH_Actor::eMultiConnection2D;
1551 aControl = SMESH_Actor::eArea;
1554 aControl = SMESH_Actor::eTaper;
1557 aControl = SMESH_Actor::eAspectRatio;
1560 aControl = SMESH_Actor::eAspectRatio3D;
1563 aControl = SMESH_Actor::eMinimumAngle;
1566 aControl = SMESH_Actor::eWarping;
1569 aControl = SMESH_Actor::eSkew;
1572 aControl = SMESH_Actor::eVolume3D;
1575 aControl = SMESH_Actor::eFreeFaces;
1578 aControl = SMESH_Actor::eMaxElementLength2D;
1581 aControl = SMESH_Actor::eMaxElementLength3D;
1584 aControl = SMESH_Actor::eBareBorderVolume;
1587 aControl = SMESH_Actor::eBareBorderFace;
1590 aControl = SMESH_Actor::eOverConstrainedVolume;
1593 aControl = SMESH_Actor::eOverConstrainedFace;
1596 aControl = SMESH_Actor::eCoincidentNodes;
1599 aControl = SMESH_Actor::eCoincidentElems1D;
1602 aControl = SMESH_Actor:: eCoincidentElems2D;
1605 aControl = SMESH_Actor::eCoincidentElems3D;
1609 anActor->SetControlMode(aControl);
1610 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1611 SMESH::RepaintCurrentView();
1612 #ifndef DISABLE_PLOT2DVIEWER
1613 if(anActor->GetPlot2Histogram()) {
1614 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1615 QString functorName = functorToString( anActor->GetFunctor());
1616 QString aHistogramName("%1 : %2");
1617 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1618 aHistogram->setName(aHistogramName);
1619 aHistogram->setHorTitle(functorName);
1620 SMESH::ProcessIn2DViewers(anActor);
1629 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1630 SMESH::MeshObjectType theType,
1631 const QString theInTypeName,
1632 QString & theOutTypeName)
1634 SMESH_TypeFilter aTypeFilter( theType );
1636 if( !theIO.IsNull() )
1638 entry = theIO->getEntry();
1639 LightApp_DataOwner owner( entry );
1640 if ( aTypeFilter.isOk( &owner )) {
1641 theOutTypeName = theInTypeName;
1649 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1651 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1652 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1654 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1655 CORBA::String_var anID = aSComp->GetID().c_str();
1656 if (!strcmp(anID.in(),theIO->getEntry()))
1662 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1663 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1664 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1665 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1666 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1674 QString CheckHomogeneousSelection()
1676 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1677 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1678 SALOME_ListIO selected;
1680 aSel->selectedObjects( selected );
1682 QString RefType = CheckTypeObject(selected.First());
1683 SALOME_ListIteratorOfListIO It(selected);
1684 for ( ; It.More(); It.Next())
1686 Handle(SALOME_InteractiveObject) IObject = It.Value();
1687 QString Type = CheckTypeObject(IObject);
1688 if (Type.compare(RefType) != 0)
1689 return "Heterogeneous Selection";
1696 void SMESHGUI::OnEditDelete()
1698 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1699 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1700 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1702 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1703 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1704 _PTR(GenericAttribute) anAttr;
1705 _PTR(AttributeIOR) anIOR;
1707 int objectCount = 0;
1709 QString aParentComponent = QString::null;
1710 Handle(SALOME_InteractiveObject) anIO;
1711 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1713 anIO = anIt.Value();
1714 QString cur = anIO->getComponentDataType();
1715 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1717 // check if object is reference
1718 _PTR(SObject) aRefSObj;
1719 aNameList.append("\n - ");
1720 if ( aSO->ReferencedObject( aRefSObj ) ) {
1721 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1722 aNameList.append( aRefName );
1723 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1726 aNameList.append(anIO->getName());
1730 if( aParentComponent.isNull() )
1731 aParentComponent = cur;
1732 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1733 aParentComponent = "";
1736 if ( objectCount == 0 )
1737 return; // No Valid Objects Selected
1739 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1740 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1741 QObject::tr("ERR_ERROR"),
1742 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1745 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1746 if (SUIT_MessageBox::warning
1747 (SMESHGUI::desktop(),
1748 QObject::tr("SMESH_WRN_WARNING"),
1749 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1750 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1751 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1754 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1756 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1757 // then treat them all starting from the deepest objects (at list back)
1758 std::list< _PTR(SObject) > listSO;
1759 SALOME_ListIteratorOfListIO It(selected);
1760 for( ; It.More(); It.Next()) // loop on selected IO's
1762 Handle(SALOME_InteractiveObject) IObject = It.Value();
1763 if(IObject->hasEntry()) {
1764 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1766 // disable removal of "SMESH" component object
1767 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1769 if ( engineIOR() == anIOR->Value().c_str() )
1772 //Check the referenced object
1773 _PTR(SObject) aRefSObject;
1774 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1775 aSO = aRefSObject; // Delete main Object instead of reference
1777 listSO.push_back( aSO );
1778 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1779 for ( ; itSO != listSO.end(); ++itSO ) {
1780 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1781 for (it->InitEx(false); it->More(); it->Next())
1782 listSO.push_back( it->Value() );
1786 // Check if none of objects to delete is referred from outside
1787 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1788 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1790 _PTR(SObject) SO = *ritSO;
1791 if ( !SO ) continue;
1792 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1793 for (size_t i = 0; i < aReferences.size(); i++) {
1794 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1795 std::string type = aComponent->ComponentDataType();
1796 if ( type != "SMESH" )
1798 SUIT_MessageBox::warning( anApp->desktop(),
1799 QObject::tr("WRN_WARNING"),
1800 QObject::tr("DEP_OBJECT") );
1801 return; // outside SMESH, there is an object depending on a SMESH object
1806 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1807 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1809 Handle(SALOME_InteractiveObject) IObject = It.Value();
1810 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1811 if ( !mesh->_is_nil() )
1815 // Treat SO's in the list starting from the back
1816 aStudyBuilder->NewCommand(); // There is a transaction
1817 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1819 _PTR(SObject) SO = *ritSO;
1820 if ( !SO ) continue;
1821 std::string anEntry = SO->GetID();
1823 /** Erase graphical object **/
1824 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1825 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1826 // ViewManagerList aViewMenegers = anApp->viewManagers();
1827 // ViewManagerList::const_iterator it = aViewMenegers.begin();
1828 // for( ; it != aViewMenegers.end(); it++) {
1829 // SUIT_ViewManager* vm = *it;
1830 // int nbSf = vm ? vm->getViewsCount() : 0;
1832 // QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1833 // for(int i = 0; i < nbSf; i++){
1834 // SUIT_ViewWindow *sf = aViews[i];
1835 // if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1836 // SMESH::RemoveActor(sf,anActor);
1842 /** Remove an object from data structures **/
1843 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1844 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1845 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1846 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1847 aMesh->RemoveGroup( aGroup );
1849 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1850 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1851 aMesh->RemoveSubMesh( aSubMesh );
1853 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1855 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1858 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1859 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1860 QString objType = CheckTypeObject(IObject);
1861 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1862 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1863 aStudyBuilder->RemoveObjectWithChildren( SO );
1865 else {// default action: remove SObject from the study
1866 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1867 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1869 aStudyBuilder->RemoveObjectWithChildren( SO );
1873 } /* listSO back loop */
1875 aStudyBuilder->CommitCommand();
1877 /* Clear any previous selection */
1879 aSel->setSelectedObjects( l1 );
1881 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1886 SMESHGUI_EXPORT CAM_Module* createModule()
1888 return new SMESHGUI();
1891 SMESHGUI_EXPORT char* getModuleVersion() {
1892 return (char*)SMESH_VERSION_STR;
1896 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1898 //=============================================================================
1902 //=============================================================================
1903 SMESHGUI::SMESHGUI() :
1904 SalomeApp_Module( "SMESH" )
1906 if ( CORBA::is_nil( myComponentSMESH ) )
1908 CORBA::Boolean anIsEmbeddedMode;
1909 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1910 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1912 // 0019923: EDF 765 SMESH : default values of hypothesis
1913 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1914 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1915 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1916 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1917 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1919 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1920 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1921 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1923 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1924 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1928 myActiveDialogBox = 0;
1929 myFilterLibraryDlg = 0;
1933 myEventCallbackCommand = vtkCallbackCommand::New();
1934 myEventCallbackCommand->Delete();
1935 myEventCallbackCommand->SetClientData( this );
1936 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1939 /* load resources for all available meshers */
1940 SMESH::InitAvailableHypotheses();
1943 //=============================================================================
1947 //=============================================================================
1948 SMESHGUI::~SMESHGUI()
1952 //=============================================================================
1956 //=============================================================================
1957 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1959 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1961 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1966 //=============================================================================
1970 //=============================================================================
1971 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1973 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1977 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1978 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1979 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1980 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1981 return autoUpdate && !exceeded;
1984 //=============================================================================
1988 //=============================================================================
1989 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1991 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1994 //=============================================================================
1998 //=============================================================================
1999 SMESHGUI* SMESHGUI::GetSMESHGUI()
2001 SMESHGUI* smeshMod = 0;
2002 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2005 CAM_Module* module = app->module( "Mesh" );
2006 smeshMod = dynamic_cast<SMESHGUI*>( module );
2009 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2011 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2014 _PTR(Study) aStudy = study->studyDS();
2016 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2025 Standard_EXPORT SMESHGUI* GetComponentGUI()
2027 return SMESHGUI::GetSMESHGUI();
2031 //=============================================================================
2035 //=============================================================================
2036 void SMESHGUI::SetState(int aState)
2041 //=============================================================================
2045 //=============================================================================
2046 void SMESHGUI::ResetState()
2051 //=============================================================================
2055 //=============================================================================
2056 void SMESHGUI::EmitSignalDeactivateDialog()
2058 emit SignalDeactivateActiveDialog();
2061 //=============================================================================
2065 //=============================================================================
2066 void SMESHGUI::EmitSignalStudyFrameChanged()
2068 emit SignalStudyFrameChanged();
2071 //=============================================================================
2075 //=============================================================================
2076 void SMESHGUI::EmitSignalCloseAllDialogs()
2078 emit SignalCloseAllDialogs();
2081 //=============================================================================
2085 //=============================================================================
2086 void SMESHGUI::EmitSignalVisibilityChanged()
2088 emit SignalVisibilityChanged();
2091 //=============================================================================
2095 //=============================================================================
2096 QDialog *SMESHGUI::GetActiveDialogBox()
2098 return myActiveDialogBox;
2101 //=============================================================================
2105 //=============================================================================
2106 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2108 myActiveDialogBox = (QDialog *) aDlg;
2112 //=============================================================================
2116 //=============================================================================
2117 SUIT_Desktop* SMESHGUI::desktop()
2119 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2121 return app->desktop();
2126 //=============================================================================
2130 //=============================================================================
2131 SalomeApp_Study* SMESHGUI::activeStudy()
2133 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2135 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2140 //=============================================================================
2144 //=============================================================================
2145 void SMESHGUI::Modified( bool theIsUpdateActions )
2147 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2148 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2149 appStudy->Modified();
2150 if( theIsUpdateActions )
2151 app->updateActions();
2156 //=============================================================================
2160 //=============================================================================
2161 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2163 /* Here the position is on the bottom right corner - 10 */
2164 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2166 SUIT_Desktop *PP = desktop();
2167 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2168 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2172 //=============================================================================
2176 //=============================================================================
2177 static int isStudyLocked(_PTR(Study) theStudy){
2178 return theStudy->GetProperties()->IsLocked();
2181 static bool checkLock(_PTR(Study) theStudy) {
2182 if (isStudyLocked(theStudy)) {
2183 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2184 QObject::tr("WRN_WARNING"),
2185 QObject::tr("WRN_STUDY_LOCKED") );
2191 //=======================================================================
2192 //function : CheckActiveStudyLocked
2194 //=======================================================================
2196 bool SMESHGUI::isActiveStudyLocked()
2198 _PTR(Study) aStudy = activeStudy()->studyDS();
2199 return checkLock( aStudy );
2202 //=============================================================================
2206 //=============================================================================
2207 bool SMESHGUI::OnGUIEvent( int theCommandID )
2209 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2213 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2214 SUIT_ResourceMgr* mgr = resourceMgr();
2218 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2219 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2222 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2223 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2225 //QAction* act = action( theCommandID );
2227 switch (theCommandID) {
2229 if(checkLock(aStudy)) break;
2241 if(checkLock(aStudy)) break;
2242 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2246 case 150: //MED FILE INFORMATION
2248 SALOME_ListIO selected;
2249 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2251 aSel->selectedObjects( selected );
2252 if( selected.Extent() )
2254 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2255 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2256 if ( !aMesh->_is_nil() )
2258 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2265 case 122: // EXPORT MED
2280 ::ExportMeshToFile(theCommandID);
2284 case 200: // SCALAR BAR
2286 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2287 SALOME_ListIO selected;
2289 aSel->selectedObjects( selected );
2291 if( selected.Extent() ) {
2292 Handle(SALOME_InteractiveObject) anIO = selected.First();
2293 if( anIO->hasEntry() ) {
2294 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2295 anActor->SetControlMode( SMESH_Actor::eNone );
2296 #ifndef DISABLE_PLOT2DVIEWER
2297 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2306 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2311 // dump control distribution data to the text file
2312 ::SaveDistribution();
2318 // show/ distribution
2319 ::ShowDistribution();
2323 #ifndef DISABLE_PLOT2DVIEWER
2326 // plot distribution
2327 ::PlotDistribution();
2338 ::DisableAutoColor();
2341 case 1134: // Clipping
2342 case 1133: // Tranparency
2343 case 1132: // Display preferences (colors, shrink size, line width, ...)
2350 ::SetDisplayMode(theCommandID, myMarkerMap);
2353 //2D quadratic representation
2356 ::SetDisplayMode(theCommandID, myMarkerMap);
2360 case 216: // 0D elements
2363 case 219: // Volumes
2364 case 220: // All Entity
2366 ::SetDisplayEntity(theCommandID);
2369 case 221: // Orientation of faces
2371 LightApp_SelectionMgr* mgr = selectionMgr();
2372 SALOME_ListIO selected; mgr->selectedObjects( selected );
2374 SALOME_ListIteratorOfListIO it(selected);
2375 for( ; it.More(); it.Next()) {
2376 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2377 if(anIObject->hasEntry()) {
2378 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2379 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2388 if(checkLock(aStudy)) break;
2390 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2393 SMESH::UpdateView();
2395 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2396 SMESH::OnVisuException();
2398 catch (...) { // PAL16774 (Crash after display of many groups)
2399 SMESH::OnVisuException();
2403 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2404 aSel->selectedObjects( l );
2405 aSel->setSelectedObjects( l );
2410 case 301: // DISPLAY
2411 case 302: // DISPLAY ONLY
2413 SMESH::EDisplaing anAction;
2414 switch (theCommandID) {
2415 case 300: anAction = SMESH::eErase; break;
2416 case 301: anAction = SMESH::eDisplay; break;
2417 case 302: anAction = SMESH::eDisplayOnly; break;
2420 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2421 SALOME_ListIO sel_objects, to_process;
2423 aSel->selectedObjects( sel_objects );
2425 if( theCommandID==302 )
2427 MESSAGE("anAction = SMESH::eDisplayOnly");
2428 startOperation( myEraseAll );
2431 extractContainers( sel_objects, to_process );
2434 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2438 SALOME_ListIteratorOfListIO It( to_process );
2439 for ( ; It.More(); It.Next()) {
2441 Handle(SALOME_InteractiveObject) IOS = It.Value();
2442 if (IOS->hasEntry()) {
2444 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2445 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2446 break; // PAL16774 (Crash after display of many groups)
2448 if (anAction == SMESH::eDisplayOnly)
2450 MESSAGE("anAction = SMESH::eDisplayOnly");
2451 anAction = SMESH::eDisplay;
2457 // PAL13338 + PAL15161 -->
2458 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2459 MESSAGE("anAction = SMESH::eDisplayOnly");
2460 SMESH::UpdateView();
2461 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2463 // PAL13338 + PAL15161 <--
2465 catch (...) { // PAL16774 (Crash after display of many groups)
2466 SMESH::OnVisuException();
2469 if (anAction == SMESH::eErase) {
2470 MESSAGE("anAction == SMESH::eErase");
2472 aSel->setSelectedObjects( l1 );
2475 aSel->setSelectedObjects( to_process );
2482 if(checkLock(aStudy)) break;
2485 EmitSignalDeactivateDialog();
2487 ( new SMESHGUI_NodesDlg( this ) )->show();
2490 SUIT_MessageBox::warning(desktop(),
2491 tr("SMESH_WRN_WARNING"),
2492 tr("SMESH_WRN_VIEWER_VTK"));
2497 case 2151: // FILTER
2501 EmitSignalDeactivateDialog();
2502 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2507 case 701: // COMPUTE MESH
2508 case 711: // PRECOMPUTE MESH
2509 case 712: // EVALUATE MESH
2510 case 713: // MESH ORDER
2511 case 702: // Create mesh
2512 case 703: // Create sub-mesh
2513 case 704: // Edit mesh/sub-mesh
2514 startOperation( theCommandID );
2516 case 705: // copy mesh
2518 if (checkLock(aStudy)) break;
2519 EmitSignalDeactivateDialog();
2520 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2523 case 710: // Build compound mesh
2525 if (checkLock(aStudy)) break;
2526 EmitSignalDeactivateDialog();
2527 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2531 case 407: // DIAGONAL INVERSION
2532 case 408: // Delete diagonal
2536 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2537 tr( "NOT_A_VTK_VIEWER" ) );
2541 if ( checkLock( aStudy ) )
2544 /*Standard_Boolean aRes;
2545 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2546 if ( aMesh->_is_nil() )
2548 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2549 tr( "SMESH_BAD_SELECTION" ) );
2553 EmitSignalDeactivateDialog();
2554 if ( theCommandID == 407 )
2555 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2557 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2560 case 409: // Change orientation
2561 case 410: // Union of triangles
2562 case 411: // Cutting of quadrangles
2563 case 419: // Splitting volumes into tetrahedra
2567 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2568 tr( "NOT_A_VTK_VIEWER" ) );
2572 if ( checkLock( aStudy ) )
2575 EmitSignalDeactivateDialog();
2576 SMESHGUI_MultiEditDlg* aDlg = NULL;
2577 if ( theCommandID == 409 )
2578 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2579 else if ( theCommandID == 410 )
2580 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2581 else if ( theCommandID == 419 )
2582 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2584 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2589 case 412: // Smoothing
2591 if(checkLock(aStudy)) break;
2593 EmitSignalDeactivateDialog();
2594 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2597 SUIT_MessageBox::warning(desktop(),
2598 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2602 case 413: // Extrusion
2604 if (checkLock(aStudy)) break;
2606 EmitSignalDeactivateDialog();
2607 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2609 SUIT_MessageBox::warning(desktop(),
2610 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2614 case 414: // Revolution
2616 if(checkLock(aStudy)) break;
2618 EmitSignalDeactivateDialog();
2619 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2622 SUIT_MessageBox::warning(desktop(),
2623 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2627 case 415: // Pattern mapping
2629 if ( checkLock( aStudy ) )
2633 EmitSignalDeactivateDialog();
2634 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2637 SUIT_MessageBox::warning(desktop(),
2638 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2642 case 416: // Extrusion along a path
2644 if (checkLock(aStudy)) break;
2646 EmitSignalDeactivateDialog();
2647 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2649 SUIT_MessageBox::warning(desktop(),
2650 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2654 case 417: // Convert mesh to quadratic
2655 case 418: // create 2D mesh from 3D
2656 case 420: // Reorient faces
2657 case 806: // CREATE GEO GROUP
2659 startOperation( theCommandID );
2662 case 801: // CREATE GROUP
2666 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2667 tr( "NOT_A_VTK_VIEWER" ) );
2671 if(checkLock(aStudy)) break;
2672 EmitSignalDeactivateDialog();
2673 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2675 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2676 SALOME_ListIO selected;
2678 aSel->selectedObjects( selected );
2680 int nbSel = selected.Extent();
2682 // check if mesh is selected
2683 aMesh = SMESH::GetMeshByIO( selected.First() );
2685 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2690 case 802: // CONSTRUCT GROUP
2694 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2695 tr( "NOT_A_VTK_VIEWER" ) );
2699 if(checkLock(aStudy)) break;
2700 EmitSignalDeactivateDialog();
2702 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2703 SALOME_ListIO selected;
2705 aSel->selectedObjects( selected );
2707 int nbSel = selected.Extent();
2709 // check if submesh is selected
2710 Handle(SALOME_InteractiveObject) IObject = selected.First();
2711 if (IObject->hasEntry()) {
2712 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2714 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2715 if (!aSubMesh->_is_nil()) {
2717 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2718 // get submesh elements list by types
2719 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2720 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2721 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2722 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2723 // create group for each type o elements
2724 QString aName = IObject->getName();
2725 QStringList anEntryList;
2726 if (aNodes->length() > 0) {
2727 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2728 aGroup->Add(aNodes.inout());
2729 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2730 anEntryList.append( aSObject->GetID().c_str() );
2732 if (aEdges->length() > 0) {
2733 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2734 aGroup->Add(aEdges.inout());
2735 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2736 anEntryList.append( aSObject->GetID().c_str() );
2738 if (aFaces->length() > 0) {
2739 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2740 aGroup->Add(aFaces.inout());
2741 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2742 anEntryList.append( aSObject->GetID().c_str() );
2744 if (aVolumes->length() > 0) {
2745 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2746 aGroup->Add(aVolumes.inout());
2747 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2748 anEntryList.append( aSObject->GetID().c_str() );
2751 anApp->browseObjects( anEntryList );
2753 catch(const SALOME::SALOME_Exception & S_ex){
2754 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2761 SUIT_MessageBox::warning(desktop(),
2762 tr("SMESH_WRN_WARNING"),
2763 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2768 case 803: // EDIT GROUP
2772 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2773 tr( "NOT_A_VTK_VIEWER" ) );
2777 if(checkLock(aStudy)) break;
2778 EmitSignalDeactivateDialog();
2780 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2781 SALOME_ListIO selected;
2783 aSel->selectedObjects( selected );
2785 SALOME_ListIteratorOfListIO It (selected);
2786 int nbSelectedGroups = 0;
2787 for ( ; It.More(); It.Next() )
2789 SMESH::SMESH_GroupBase_var aGroup =
2790 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2791 if (!aGroup->_is_nil()) {
2793 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2797 if (nbSelectedGroups == 0)
2799 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2805 case 804: // Add elements to group
2807 if(checkLock(aStudy)) break;
2808 if (myState == 800) {
2809 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2810 if (aDlg) aDlg->onAdd();
2815 case 805: // Remove elements from group
2817 if(checkLock(aStudy)) break;
2818 if (myState == 800) {
2819 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2820 if (aDlg) aDlg->onRemove();
2825 case 815: // Edit GEOM GROUP as standalone
2829 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2830 tr( "NOT_A_VTK_VIEWER" ) );
2834 if(checkLock(aStudy)) break;
2835 EmitSignalDeactivateDialog();
2837 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2838 SALOME_ListIO selected;
2840 aSel->selectedObjects( selected );
2842 SALOME_ListIteratorOfListIO It (selected);
2843 for ( ; It.More(); It.Next() )
2845 SMESH::SMESH_GroupOnGeom_var aGroup =
2846 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2847 if (!aGroup->_is_nil()) {
2848 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2853 SMESH::SMESH_GroupOnFilter_var aGroup =
2854 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2855 if (!aGroup->_is_nil()) {
2856 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2864 case 810: // Union Groups
2865 case 811: // Intersect groups
2866 case 812: // Cut groups
2870 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2871 tr( "NOT_A_VTK_VIEWER" ) );
2875 if ( checkLock( aStudy ) )
2878 EmitSignalDeactivateDialog();
2880 SMESHGUI_GroupOpDlg* aDlg = 0;
2881 if ( theCommandID == 810 )
2882 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2883 else if ( theCommandID == 811 )
2884 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2886 aDlg = new SMESHGUI_CutGroupsDlg( this );
2893 case 814: // Create groups of entities from existing groups of superior dimensions
2895 if ( checkLock( aStudy ) )
2898 EmitSignalDeactivateDialog();
2899 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2905 case 813: // Delete groups with their contents
2909 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2910 tr( "NOT_A_VTK_VIEWER" ) );
2914 if ( checkLock( aStudy ) )
2917 EmitSignalDeactivateDialog();
2919 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2923 case 900: // MESH INFOS
2924 case 903: // WHAT IS
2926 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2927 EmitSignalDeactivateDialog();
2928 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2929 SALOME_ListIO selected;
2931 aSel->selectedObjects( selected );
2933 if ( selected.Extent() > 1 ) { // a dlg for each IO
2934 SALOME_ListIteratorOfListIO It( selected );
2935 for ( ; It.More(); It.Next() ) {
2936 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2937 dlg->showInfo( It.Value() );
2942 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2948 case 904: // FIND ELEM
2950 startOperation( theCommandID );
2954 case 1100: // EDIT HYPOTHESIS
2956 if(checkLock(aStudy)) break;
2958 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2959 SALOME_ListIO selected;
2961 aSel->selectedObjects( selected );
2963 int nbSel = selected.Extent();
2966 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2967 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2969 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2970 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2971 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2972 if ( !aHypothesis->_is_nil() )
2975 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2976 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2978 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2988 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2990 if(checkLock(aStudy)) break;
2991 SUIT_OverrideCursor wc;
2993 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2994 SALOME_ListIO selected;
2996 aSel->selectedObjects( selected, QString::null, false );
2998 SALOME_ListIteratorOfListIO It(selected);
2999 for (int i = 0; It.More(); It.Next(), i++) {
3000 Handle(SALOME_InteractiveObject) IObject = It.Value();
3001 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3004 aSel->setSelectedObjects( l1 );
3010 case 4009: // ELEM0D
3012 case 4021: // TRIANGLE
3014 case 4023: // POLYGON
3018 case 4134: // PYRAMID
3019 case 4135: // OCTA12
3021 if(checkLock(aStudy)) break;
3023 EmitSignalDeactivateDialog();
3024 SMDSAbs_EntityType type = SMDSEntity_Edge;
3025 switch (theCommandID) {
3026 case 4008: type = SMDSEntity_Ball; break;
3027 case 4009: type = SMDSEntity_0D; break;
3028 case 4021: type = SMDSEntity_Triangle; break;
3029 case 4022: type = SMDSEntity_Quadrangle; break;
3030 case 4031: type = SMDSEntity_Tetra; break;
3031 case 4023: type = SMDSEntity_Polygon; break;
3032 case 4032: type = SMDSEntity_Hexa; break;
3033 case 4133: type = SMDSEntity_Penta; break;
3034 case 4134: type = SMDSEntity_Pyramid; break;
3035 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3038 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3041 SUIT_MessageBox::warning(desktop(),
3042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3046 case 4033: // POLYHEDRON
3048 if(checkLock(aStudy)) break;
3050 EmitSignalDeactivateDialog();
3051 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3054 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3059 case 4034: // QUADRATIC EDGE
3060 case 4035: // QUADRATIC TRIANGLE
3061 case 4036: // QUADRATIC QUADRANGLE
3062 case 4136: // BIQUADRATIC QUADRANGLE
3063 case 4137: // BIQUADRATIC TRIANGLE
3064 case 4037: // QUADRATIC TETRAHEDRON
3065 case 4038: // QUADRATIC PYRAMID
3066 case 4039: // QUADRATIC PENTAHEDRON
3067 case 4040: // QUADRATIC HEXAHEDRON
3068 case 4140: // TRIQUADRATIC HEXAHEDRON
3070 if(checkLock(aStudy)) break;
3072 EmitSignalDeactivateDialog();
3073 SMDSAbs_EntityType type = SMDSEntity_Last;
3075 switch (theCommandID) {
3077 type = SMDSEntity_Quad_Edge; break;
3079 type = SMDSEntity_Quad_Triangle; break;
3081 type = SMDSEntity_Quad_Quadrangle; break;
3083 type = SMDSEntity_BiQuad_Quadrangle; break;
3085 type = SMDSEntity_BiQuad_Triangle; break;
3087 type = SMDSEntity_Quad_Tetra; break;
3089 type = SMDSEntity_Quad_Pyramid; break;
3091 type = SMDSEntity_Quad_Penta; break;
3093 type = SMDSEntity_Quad_Hexa; break;
3095 type = SMDSEntity_TriQuad_Hexa; break;
3098 if ( type != SMDSEntity_Last )
3099 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3102 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3103 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3107 case 4041: // REMOVES NODES
3109 if(checkLock(aStudy)) break;
3111 EmitSignalDeactivateDialog();
3112 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3115 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3120 case 4042: // REMOVES ELEMENTS
3122 if(checkLock(aStudy)) break;
3124 EmitSignalDeactivateDialog();
3125 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3129 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3134 case 4043: { // CLEAR_MESH
3136 if(checkLock(aStudy)) break;
3138 SALOME_ListIO selected;
3139 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3140 aSel->selectedObjects( selected );
3142 SUIT_OverrideCursor wc;
3143 SALOME_ListIteratorOfListIO It (selected);
3144 for ( ; It.More(); It.Next() )
3146 Handle(SALOME_InteractiveObject) IOS = It.Value();
3147 SMESH::SMESH_Mesh_var aMesh =
3148 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3149 if ( aMesh->_is_nil()) continue;
3151 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3153 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3154 SMESH::ModifiedMesh( aMeshSObj, false, true);
3155 // hide groups and submeshes
3156 _PTR(ChildIterator) anIter =
3157 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3158 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3160 _PTR(SObject) so = anIter->Value();
3161 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3164 catch (const SALOME::SALOME_Exception& S_ex){
3166 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3170 SMESH::UpdateView();
3174 case 4044: // REMOVE ORPHAN NODES
3176 if(checkLock(aStudy)) break;
3177 SALOME_ListIO selected;
3178 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3179 aSel->selectedObjects( selected );
3180 if ( selected.Extent() == 1 ) {
3181 Handle(SALOME_InteractiveObject) anIO = selected.First();
3182 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3183 if ( !aMesh->_is_nil() ) {
3184 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3185 tr( "SMESH_WARNING" ),
3186 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3187 SUIT_MessageBox::Yes |
3188 SUIT_MessageBox::No,
3189 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3192 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3193 int removed = aMeshEditor->RemoveOrphanNodes();
3194 SUIT_MessageBox::information(SMESHGUI::desktop(),
3195 tr("SMESH_INFORMATION"),
3196 tr("NB_NODES_REMOVED").arg(removed));
3197 if ( removed > 0 ) {
3198 SMESH::UpdateView();
3199 SMESHGUI::Modified();
3202 catch (const SALOME::SALOME_Exception& S_ex) {
3203 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3212 case 4051: // RENUMBERING NODES
3214 if(checkLock(aStudy)) break;
3216 EmitSignalDeactivateDialog();
3217 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3221 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3222 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3226 case 4052: // RENUMBERING ELEMENTS
3228 if(checkLock(aStudy)) break;
3230 EmitSignalDeactivateDialog();
3231 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3235 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3236 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3240 case 4061: // TRANSLATION
3242 if(checkLock(aStudy)) break;
3244 EmitSignalDeactivateDialog();
3245 ( new SMESHGUI_TranslationDlg( this ) )->show();
3248 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3249 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3253 case 4062: // ROTATION
3255 if(checkLock(aStudy)) break;
3257 EmitSignalDeactivateDialog();
3258 ( new SMESHGUI_RotationDlg( this ) )->show();
3261 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3262 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3266 case 4063: // SYMMETRY
3268 if(checkLock(aStudy)) break;
3270 EmitSignalDeactivateDialog();
3271 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3274 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3275 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3279 case 4064: // SEWING
3281 if(checkLock(aStudy)) break;
3283 EmitSignalDeactivateDialog();
3284 ( new SMESHGUI_SewingDlg( this ) )->show();
3287 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3288 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3292 case 4065: // MERGE NODES
3294 if(checkLock(aStudy)) break;
3296 EmitSignalDeactivateDialog();
3297 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3300 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3301 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3305 case 4066: // MERGE EQUAL ELEMENTS
3307 if (checkLock(aStudy)) break;
3309 EmitSignalDeactivateDialog();
3310 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3312 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3313 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3318 case 4067: // MAKE MESH PASS THROUGH POINT
3319 startOperation( 4067 );
3324 if(checkLock(aStudy)) break;
3326 EmitSignalDeactivateDialog();
3327 ( new SMESHGUI_ScaleDlg( this ) )->show();
3330 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3331 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3336 case 4069: // DUPLICATE NODES
3338 if(checkLock(aStudy)) break;
3340 EmitSignalDeactivateDialog();
3341 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3344 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3345 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3350 case 4070: // 0D_ON_ALL_NODES
3351 startOperation( 4070 );
3354 case 5105: // Library of selection filters
3356 static QList<int> aTypes;
3357 if ( aTypes.isEmpty() )
3359 aTypes.append( SMESH::NODE );
3360 aTypes.append( SMESH::EDGE );
3361 aTypes.append( SMESH::FACE );
3362 aTypes.append( SMESH::VOLUME );
3364 if (!myFilterLibraryDlg)
3365 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3366 else if (myFilterLibraryDlg->isHidden())
3367 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3368 myFilterLibraryDlg->raise();
3372 case 6017: // CONTROLS
3400 LightApp_SelectionMgr* mgr = selectionMgr();
3401 SALOME_ListIO selected; mgr->selectedObjects( selected );
3403 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3404 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3406 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3407 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3408 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3409 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3410 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3411 ::Control( theCommandID );
3416 SUIT_MessageBox::warning(desktop(),
3417 tr( "SMESH_WRN_WARNING" ),
3418 tr( "SMESH_BAD_SELECTION" ) );
3422 SUIT_MessageBox::warning(desktop(),
3423 tr( "SMESH_WRN_WARNING" ),
3424 tr( "NOT_A_VTK_VIEWER" ) );
3429 LightApp_SelectionMgr* mgr = selectionMgr();
3430 SALOME_ListIO selected; mgr->selectedObjects( selected );
3432 SALOME_ListIteratorOfListIO it(selected);
3433 for( ; it.More(); it.Next()) {
3434 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3435 if(anIObject->hasEntry()) {
3436 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3437 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3445 LightApp_SelectionMgr* mgr = selectionMgr();
3446 SALOME_ListIO selected; mgr->selectedObjects( selected );
3448 SALOME_ListIteratorOfListIO it(selected);
3449 for( ; it.More(); it.Next()) {
3450 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3451 if(anIObject->hasEntry())
3452 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3453 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3461 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3462 EmitSignalDeactivateDialog();
3463 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3469 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3470 //updateObjBrowser();
3474 //=============================================================================
3478 //=============================================================================
3479 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3484 //=============================================================================
3488 //=============================================================================
3489 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3494 //=============================================================================
3498 //=============================================================================
3499 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3504 //=============================================================================
3505 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3506 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3508 //=============================================================================
3509 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3510 SUIT_ViewWindow* wnd )
3512 if(theIO->hasEntry()){
3513 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3514 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3518 //=======================================================================
3519 // function : createSMESHAction
3521 //=======================================================================
3522 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3523 const int key, const bool toggle, const QString& shortcutAction )
3526 QWidget* parent = application()->desktop();
3527 SUIT_ResourceMgr* resMgr = resourceMgr();
3529 if ( !icon_id.isEmpty() )
3530 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3532 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3533 if ( !pix.isNull() )
3534 icon = QIcon( pix );
3536 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3537 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3538 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3540 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3541 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3544 //=======================================================================
3545 // function : createPopupItem
3547 //=======================================================================
3548 void SMESHGUI::createPopupItem( const int id,
3549 const QString& clients,
3550 const QString& types,
3551 const QString& theRule,
3554 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3555 popupMgr()->insert( action( id ), pId, 0 );
3557 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3558 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3559 QString rule = "(%1) and (%2) and (%3)";
3560 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3561 if( clients.isEmpty() )
3562 rule = rule.arg( QString( "true" ) );
3564 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3565 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3568 bool cont = myRules.contains( id );
3570 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3572 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3573 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3576 //=======================================================================
3577 // function : initialize
3579 //=======================================================================
3580 void SMESHGUI::initialize( CAM_Application* app )
3582 SalomeApp_Module::initialize( app );
3584 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3586 /* Automatic Update flag */
3587 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3589 // ----- create actions --------------
3591 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3592 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3593 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3594 createSMESHAction( 114, "NUM" );
3595 createSMESHAction( 115, "IMPORT_STL" );
3596 createSMESHAction( 116, "IMPORT_CGNS" );
3597 createSMESHAction( 117, "IMPORT_SAUV" );
3598 createSMESHAction( 118, "IMPORT_GMF" );
3599 createSMESHAction( 121, "DAT" );
3600 createSMESHAction( 122, "MED" );
3601 createSMESHAction( 123, "UNV" );
3602 createSMESHAction( 140, "STL" );
3603 createSMESHAction( 142, "CGNS");
3604 createSMESHAction( 144, "SAUV");
3605 createSMESHAction( 146, "GMF" );
3606 createSMESHAction( 124, "DAT" );
3607 createSMESHAction( 125, "MED" );
3608 createSMESHAction( 126, "UNV" );
3609 createSMESHAction( 141, "STL" );
3610 createSMESHAction( 143, "CGNS");
3611 createSMESHAction( 145, "SAUV");
3612 createSMESHAction( 147, "GMF" );
3613 createSMESHAction( 150, "FILE_INFO" );
3614 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3615 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3616 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3617 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3618 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3619 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3620 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3621 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3622 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3623 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3624 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3625 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3626 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3627 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3628 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3629 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3630 createSMESHAction( 804, "ADD" );
3631 createSMESHAction( 805, "REMOVE" );
3632 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3633 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3634 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3635 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3636 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3637 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3638 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3639 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3640 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3641 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3642 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3643 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3644 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3645 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3646 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3647 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3648 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3649 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3650 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3651 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3652 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3653 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3654 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3655 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3656 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3657 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3658 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3659 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3660 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3661 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3662 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3663 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3664 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3665 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3666 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3667 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3668 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3669 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3670 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3671 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3672 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3673 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3674 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3675 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3676 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3677 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3678 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3679 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3680 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3681 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3682 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3683 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3684 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3685 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3686 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3687 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3688 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3689 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3690 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3691 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3692 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3693 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3694 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3695 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3696 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3697 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3698 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3699 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3700 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3701 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3702 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3703 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3704 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3705 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3706 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3707 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3708 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3709 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3710 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3711 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3712 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3713 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3714 createSMESHAction( 415, "MAP", "ICON_MAP" );
3715 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3716 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3717 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3718 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3719 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3720 createSMESHAction( 200, "RESET" );
3721 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3722 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3723 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3724 #ifndef DISABLE_PLOT2DVIEWER
3725 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3727 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3728 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3729 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3730 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3731 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3732 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3733 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3734 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3735 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3736 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3737 createSMESHAction( 220, "ALL" );
3738 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3740 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3741 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3743 createSMESHAction( 1100, "EDIT_HYPO" );
3744 createSMESHAction( 1102, "UNASSIGN" );
3745 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3746 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3747 createSMESHAction( 1131, "DISPMODE" );
3748 createSMESHAction( 1132, "COLORS" );
3749 createSMESHAction( 1133, "TRANSP" );
3750 createSMESHAction( 1134, "CLIP" );
3751 createSMESHAction( 1135, "DISP_ENT" );
3752 createSMESHAction( 1136, "AUTO_COLOR" );
3753 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3754 createSMESHAction( 2000, "CTRL" );
3756 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3757 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3759 createSMESHAction( 300, "HIDE" );
3760 createSMESHAction( 301, "SHOW" );
3761 createSMESHAction( 302, "DISPLAY_ONLY" );
3763 // ----- create menu --------------
3764 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3765 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3766 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3767 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3768 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3769 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3770 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3771 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3773 createMenu( separator(), fileId );
3775 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3776 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3777 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3778 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3779 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3780 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3781 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3782 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3783 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3784 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3786 //createMenu( 111, importId, -1 );
3787 createMenu( 112, importId, -1 );
3788 createMenu( 113, importId, -1 );
3789 createMenu( 115, importId, -1 );
3791 createMenu( 116, importId, -1 );
3793 createMenu( 117, importId, -1 );
3794 createMenu( 118, importId, -1 );
3795 createMenu( 121, exportId, -1 );
3796 createMenu( 122, exportId, -1 );
3797 createMenu( 123, exportId, -1 );
3798 createMenu( 140, exportId, -1 ); // export to STL
3800 createMenu( 142, exportId, -1 ); // export to CGNS
3802 createMenu( 144, exportId, -1 ); // export to SAUV
3803 createMenu( 146, exportId, -1 ); // export to GMF
3804 createMenu( separator(), fileId, 10 );
3806 createMenu( 33, editId, -1 );
3808 createMenu( 5105, toolsId, -1 );
3810 createMenu( 702, meshId, -1 ); // "Mesh" menu
3811 createMenu( 703, meshId, -1 );
3812 createMenu( 704, meshId, -1 );
3813 createMenu( 710, meshId, -1 );
3814 createMenu( 705, meshId, -1 );
3815 createMenu( separator(), meshId, -1 );
3816 createMenu( 701, meshId, -1 );
3817 createMenu( 711, meshId, -1 );
3818 createMenu( 712, meshId, -1 );
3819 createMenu( 713, meshId, -1 );
3820 createMenu( separator(), meshId, -1 );
3821 createMenu( 801, meshId, -1 );
3822 createMenu( 806, meshId, -1 );
3823 createMenu( 802, meshId, -1 );
3824 createMenu( 803, meshId, -1 );
3825 createMenu( 815, meshId, -1 );
3826 createMenu( separator(), meshId, -1 );
3827 createMenu( 810, meshId, -1 );
3828 createMenu( 811, meshId, -1 );
3829 createMenu( 812, meshId, -1 );
3830 createMenu( separator(), meshId, -1 );
3831 createMenu( 814, meshId, -1 );
3832 createMenu( separator(), meshId, -1 );
3833 createMenu( 900, meshId, -1 );
3834 //createMenu( 902, meshId, -1 );
3835 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3836 createMenu( 904, meshId, -1 );
3837 createMenu( separator(), meshId, -1 );
3839 createMenu( 6005, nodeId, -1 );
3840 createMenu( 6028, nodeId, -1 );
3841 createMenu( 6002, edgeId, -1 );
3842 createMenu( 6003, edgeId, -1 );
3843 createMenu( 6001, edgeId, -1 );
3844 createMenu( 6004, edgeId, -1 );
3845 createMenu( 6029, edgeId, -1 );
3846 createMenu( 6021, faceId, -1 );
3847 createMenu( 6025, faceId, -1 );
3848 createMenu( 6027, faceId, -1 );
3849 createMenu( 6018, faceId, -1 );
3850 createMenu( 6019, faceId, -1 );
3851 createMenu( 6011, faceId, -1 );
3852 createMenu( 6012, faceId, -1 );
3853 createMenu( 6013, faceId, -1 );
3854 createMenu( 6014, faceId, -1 );
3855 createMenu( 6015, faceId, -1 );
3856 createMenu( 6016, faceId, -1 );
3857 createMenu( 6022, faceId, -1 );
3858 createMenu( 6030, faceId, -1 );
3859 createMenu( 6017, volumeId, -1 );
3860 createMenu( 6009, volumeId, -1 );
3861 createMenu( 6023, volumeId, -1 );
3862 createMenu( 6024, volumeId, -1 );
3863 createMenu( 6026, volumeId, -1 );
3864 createMenu( 6031, volumeId, -1 );
3866 createMenu( 4000, addId, -1 );
3867 createMenu( 4009, addId, -1 );
3868 createMenu( 4070, addId, -1 );
3869 createMenu( 4008, addId, -1 );
3870 createMenu( 4010, addId, -1 );
3871 createMenu( 4021, addId, -1 );
3872 createMenu( 4022, addId, -1 );
3873 createMenu( 4023, addId, -1 );
3874 createMenu( 4031, addId, -1 );
3875 createMenu( 4032, addId, -1 );
3876 createMenu( 4133, addId, -1 );
3877 createMenu( 4134, addId, -1 );
3878 createMenu( 4135, addId, -1 );
3879 createMenu( 4033, addId, -1 );
3880 createMenu( separator(), addId, -1 );
3881 createMenu( 4034, addId, -1 );
3882 createMenu( 4035, addId, -1 );
3883 createMenu( 4137, addId, -1 );
3884 createMenu( 4036, addId, -1 );
3885 createMenu( 4136, addId, -1 );
3886 createMenu( 4037, addId, -1 );
3887 createMenu( 4038, addId, -1 );
3888 createMenu( 4039, addId, -1 );
3889 createMenu( 4040, addId, -1 );
3890 createMenu( 4140, addId, -1 );
3892 createMenu( 4041, removeId, -1 );
3893 createMenu( 4042, removeId, -1 );
3894 createMenu( 4044, removeId, -1 );
3895 createMenu( separator(), removeId, -1 );
3896 createMenu( 813, removeId, -1 );
3897 createMenu( separator(), removeId, -1 );
3898 createMenu( 4043, removeId, -1 );
3900 createMenu( 4051, renumId, -1 );
3901 createMenu( 4052, renumId, -1 );
3903 createMenu( 4061, transfId, -1 );
3904 createMenu( 4062, transfId, -1 );
3905 createMenu( 4063, transfId, -1 );
3906 createMenu( 4068, transfId, -1 );
3907 createMenu( 4064, transfId, -1 );
3908 createMenu( 4065, transfId, -1 );
3909 createMenu( 4066, transfId, -1 );
3910 createMenu( 4069, transfId, -1 );
3912 createMenu( 4067,modifyId, -1 );
3913 createMenu( 407, modifyId, -1 );
3914 createMenu( 408, modifyId, -1 );
3915 createMenu( 409, modifyId, -1 );
3916 createMenu( 420, modifyId, -1 );
3917 createMenu( 410, modifyId, -1 );
3918 createMenu( 411, modifyId, -1 );
3919 createMenu( 419, modifyId, -1 );
3920 createMenu( 412, modifyId, -1 );
3921 createMenu( 413, modifyId, -1 );
3922 createMenu( 416, modifyId, -1 );
3923 createMenu( 414, modifyId, -1 );
3924 createMenu( 415, modifyId, -1 );
3925 createMenu( 417, modifyId, -1 );
3926 createMenu( 418, modifyId, -1 );
3928 createMenu( 501, measureId, -1 );
3929 createMenu( 502, measureId, -1 );
3930 createMenu( 214, viewId, -1 );
3932 // ----- create toolbars --------------
3933 int meshTb = createTool( tr( "TB_MESH" ) ),
3934 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3935 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3936 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3937 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3939 createTool( 702, meshTb );
3940 createTool( 703, meshTb );
3941 createTool( 704, meshTb );
3942 createTool( 710, meshTb );
3943 createTool( 705, meshTb );
3944 createTool( separator(), meshTb );
3945 createTool( 701, meshTb );
3946 createTool( 711, meshTb );
3947 createTool( 712, meshTb );
3948 createTool( 713, meshTb );
3949 createTool( separator(), meshTb );
3950 createTool( 801, meshTb );
3951 createTool( 806, meshTb );
3952 createTool( 802, meshTb );
3953 createTool( 803, meshTb );
3954 //createTool( 815, meshTb );
3955 createTool( separator(), meshTb );
3956 createTool( 900, meshTb );
3957 //createTool( 902, meshTb );
3958 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3959 createTool( 904, meshTb );
3960 createTool( separator(), meshTb );
3962 createTool( 6005, ctrlTb );
3963 createTool( 6028, ctrlTb );
3964 createTool( separator(), ctrlTb );
3965 createTool( 6002, ctrlTb );
3966 createTool( 6003, ctrlTb );
3967 createTool( 6001, ctrlTb );
3968 createTool( 6004, ctrlTb );
3969 createTool( 6029, ctrlTb );
3970 createTool( separator(), ctrlTb );
3971 createTool( 6021, ctrlTb );
3972 createTool( 6025, ctrlTb );
3973 createTool( 6027, ctrlTb );
3974 createTool( 6018, ctrlTb );
3975 createTool( 6019, ctrlTb );
3976 createTool( 6011, ctrlTb );
3977 createTool( 6012, ctrlTb );
3978 createTool( 6013, ctrlTb );
3979 createTool( 6014, ctrlTb );
3980 createTool( 6015, ctrlTb );
3981 createTool( 6016, ctrlTb );
3982 createTool( 6022, ctrlTb );
3983 createTool( 6030, ctrlTb );
3984 createTool( separator(), ctrlTb );
3985 createTool( 6017, ctrlTb );
3986 createTool( 6009, ctrlTb );
3987 createTool( 6023, ctrlTb );
3988 createTool( 6024, ctrlTb );
3989 createTool( 6026, ctrlTb );
3990 createTool( 6031, ctrlTb );
3991 createTool( separator(), ctrlTb );
3993 createTool( 4000, addRemTb );
3994 createTool( 4009, addRemTb );
3995 createTool( 4070, addRemTb );
3996 createTool( 4008, addRemTb );
3997 createTool( 4010, addRemTb );
3998 createTool( 4021, addRemTb );
3999 createTool( 4022, addRemTb );
4000 createTool( 4023, addRemTb );
4001 createTool( 4031, addRemTb );
4002 createTool( 4032, addRemTb );
4003 createTool( 4133, addRemTb );
4004 createTool( 4134, addRemTb );
4005 createTool( 4135, addRemTb );
4006 createTool( 4033, addRemTb );
4007 createTool( separator(), addRemTb );
4008 createTool( 4034, addRemTb );
4009 createTool( 4035, addRemTb );
4010 createTool( 4137, addRemTb );
4011 createTool( 4036, addRemTb );
4012 createTool( 4136, addRemTb );
4013 createTool( 4037, addRemTb );
4014 createTool( 4038, addRemTb );
4015 createTool( 4039, addRemTb );
4016 createTool( 4040, addRemTb );
4017 createTool( 4140, addRemTb );
4018 createTool( separator(), addRemTb );
4019 createTool( 4041, addRemTb );
4020 createTool( 4042, addRemTb );
4021 createTool( 4044, addRemTb );
4022 createTool( 4043, addRemTb );
4023 createTool( separator(), addRemTb );
4024 createTool( 4051, addRemTb );
4025 createTool( 4052, addRemTb );
4026 createTool( separator(), addRemTb );
4027 createTool( 4061, addRemTb );
4028 createTool( 4062, addRemTb );
4029 createTool( 4063, addRemTb );
4030 createTool( 4068, addRemTb );
4031 createTool( 4064, addRemTb );
4032 createTool( 4065, addRemTb );
4033 createTool( 4066, addRemTb );
4034 createTool( 4069, addRemTb );
4035 createTool( separator(), addRemTb );
4037 createTool( 4067,modifyTb );
4038 createTool( 407, modifyTb );
4039 createTool( 408, modifyTb );
4040 createTool( 409, modifyTb );
4041 createTool( 420, modifyTb );
4042 createTool( 410, modifyTb );
4043 createTool( 411, modifyTb );
4044 createTool( 419, modifyTb );
4045 createTool( 412, modifyTb );
4046 createTool( 413, modifyTb );
4047 createTool( 416, modifyTb );
4048 createTool( 414, modifyTb );
4049 createTool( 415, modifyTb );
4050 createTool( 417, modifyTb );
4051 createTool( 418, modifyTb );
4053 createTool( 214, dispModeTb );
4055 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4056 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4059 QString OB = "'ObjectBrowser'",
4060 View = "'" + SVTK_Viewer::Type() + "'",
4062 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4063 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4064 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4065 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4066 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4067 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4068 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4069 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4070 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4071 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4072 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4074 mesh_part = mesh + " " + subMesh + " " + group,
4075 mesh_group = mesh + " " + group,
4076 hyp_alg = hypo + " " + algo;
4078 // popup for object browser
4080 isInvisible("not( isVisible )"),
4081 isEmpty("numberOfNodes = 0"),
4082 isNotEmpty("numberOfNodes <> 0"),
4084 // has nodes, edges, etc in VISIBLE! actor
4085 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4086 hasElems("(count( elemTypes ) > 0)"),
4087 hasDifferentElems("(count( elemTypes ) > 1)"),
4088 hasBalls("({'BallElem'} in elemTypes)"),
4089 hasElems0d("({'Elem0d'} in elemTypes)"),
4090 hasEdges("({'Edge'} in elemTypes)"),
4091 hasFaces("({'Face'} in elemTypes)"),
4092 hasVolumes("({'Volume'} in elemTypes)");
4094 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4095 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4096 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4097 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4098 createPopupItem( 803, OB, group ); // EDIT_GROUP
4099 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4101 popupMgr()->insert( separator(), -1, 0 );
4102 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4103 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4104 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4105 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4106 createPopupItem( 214, OB, mesh_part ); // UPDATE
4107 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4108 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4109 popupMgr()->insert( separator(), -1, 0 );
4110 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4111 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4112 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4113 popupMgr()->insert( separator(), -1, 0 );
4114 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4115 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4116 popupMgr()->insert( separator(), -1, 0 );
4117 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4118 popupMgr()->insert( separator(), -1, 0 );
4119 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4120 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4122 popupMgr()->insert( separator(), -1, 0 );
4124 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4125 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4126 QString only_one_2D = only_one_non_empty + " && dim>1";
4128 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4129 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4130 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4131 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4133 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4135 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4136 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4137 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4138 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4139 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4140 popupMgr()->insert( separator(), -1, 0 );
4143 createPopupItem( 803, View, group ); // EDIT_GROUP
4144 createPopupItem( 804, View, elems ); // ADD
4145 createPopupItem( 805, View, elems ); // REMOVE
4147 popupMgr()->insert( separator(), -1, 0 );
4148 createPopupItem( 214, View, mesh_part ); // UPDATE
4149 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4150 createPopupItem( 904, View, mesh ); // FIND_ELEM
4151 popupMgr()->insert( separator(), -1, 0 );
4153 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4154 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4155 popupMgr()->insert( separator(), -1, 0 );
4157 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4158 QString aType = QString( "%1type in {%2}" ).arg( lc );
4159 aType = aType.arg( mesh_part );
4160 QString aMeshInVTK = aClient + "&&" + aType;
4162 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4163 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4164 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4166 //-------------------------------------------------
4168 //-------------------------------------------------
4169 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4171 popupMgr()->insert( action( 9010 ), anId, -1 );
4172 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4173 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4175 popupMgr()->insert( action( 9011 ), anId, -1 );
4176 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4177 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4179 popupMgr()->insert( separator(), -1, -1 );
4181 //-------------------------------------------------
4183 //-------------------------------------------------
4184 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4186 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4187 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4188 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4190 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4191 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4192 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4194 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4195 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4196 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4198 popupMgr()->insert( separator(), anId, -1 );
4200 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4201 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4202 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4204 //-------------------------------------------------
4206 //-------------------------------------------------
4207 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4209 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4211 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4212 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4213 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4215 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4216 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4217 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4219 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4220 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4221 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4223 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4224 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4225 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4227 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4228 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4229 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4231 popupMgr()->insert( separator(), anId, -1 );
4233 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4234 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4237 //-------------------------------------------------
4238 // Representation of the 2D Quadratic elements
4239 //-------------------------------------------------
4240 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4241 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4242 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4243 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4245 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4246 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4247 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4249 //-------------------------------------------------
4250 // Orientation of faces
4251 //-------------------------------------------------
4252 popupMgr()->insert( action( 221 ), -1, -1 );
4253 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4254 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4256 //-------------------------------------------------
4258 //-------------------------------------------------
4259 popupMgr()->insert( action( 1132 ), -1, -1 );
4260 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4262 //-------------------------------------------------
4264 //-------------------------------------------------
4265 popupMgr()->insert( action( 1133 ), -1, -1 );
4266 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4268 //-------------------------------------------------
4270 //-------------------------------------------------
4272 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4273 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4274 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4275 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4277 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4279 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4280 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4282 popupMgr()->insert( separator(), anId, -1 );
4284 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4286 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4287 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4288 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4290 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4291 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4292 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4294 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4296 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4297 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4298 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4300 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4301 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4302 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4304 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4305 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4306 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4308 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4309 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4310 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4311 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4312 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4313 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4315 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4317 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4318 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4319 QtxPopupMgr::VisibleRule );
4320 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4322 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4323 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4324 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4326 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4327 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4328 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4330 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4331 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4332 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4334 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4335 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4336 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4338 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4339 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4340 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4342 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4343 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4344 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4346 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4347 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4348 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4350 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4351 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4352 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4354 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4355 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4356 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4358 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4359 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4360 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4362 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4363 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4364 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4365 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4366 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4367 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4369 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4371 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4372 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4373 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4375 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4376 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4377 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4379 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4380 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4381 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4383 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4384 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4385 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4387 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4388 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4389 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4391 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4392 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4393 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4395 popupMgr()->insert( separator(), anId, -1 );
4397 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4398 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4400 popupMgr()->insert( separator(), anId, -1 );
4402 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4404 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4405 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4407 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4408 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4409 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4411 #ifndef DISABLE_PLOT2DVIEWER
4412 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4413 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4416 //-------------------------------------------------
4418 //-------------------------------------------------
4419 popupMgr()->insert( separator(), -1, -1 );
4420 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4421 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4422 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4423 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4425 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4426 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4428 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4429 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4431 popupMgr()->insert( separator(), -1, -1 );
4433 //-------------------------------------------------
4435 //-------------------------------------------------
4436 popupMgr()->insert( action( 1134 ), -1, -1 );
4437 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4439 popupMgr()->insert( separator(), -1, -1 );
4441 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4442 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4444 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4445 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4448 //================================================================================
4450 * \brief Return true if SMESH or GEOM objects are selected.
4451 * Is called form LightApp_Module::activateModule() which clear selection if
4452 * not isSelectionCompatible()
4454 //================================================================================
4456 bool SMESHGUI::isSelectionCompatible()
4458 bool isCompatible = true;
4459 SALOME_ListIO selected;
4460 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4461 Sel->selectedObjects( selected );
4463 SALOME_ListIteratorOfListIO It( selected );
4464 for ( ; isCompatible && It.More(); It.Next())
4466 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4467 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4469 return isCompatible;
4473 bool SMESHGUI::reusableOperation( const int id )
4475 // compute, evaluate and precompute are not reusable operations
4476 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4479 bool SMESHGUI::activateModule( SUIT_Study* study )
4481 bool res = SalomeApp_Module::activateModule( study );
4483 setMenuShown( true );
4484 setToolShown( true );
4486 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4487 PyGILState_STATE gstate = PyGILState_Ensure();
4488 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4489 if(pluginsmanager==NULL)
4493 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4498 PyGILState_Release(gstate);
4499 // end of GEOM plugins loading
4501 // Reset actions accelerator keys
4502 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4503 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4504 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4506 action( 33)->setEnabled(true); // Delete: Key_Delete
4508 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4509 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4510 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4511 if ( _PTR(Study) aStudy = s->studyDS()) {
4512 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4513 updateObjBrowser(); // objects can be removed
4516 // get all view currently opened in the study and connect their signals to
4517 // the corresponding slots of the class.
4518 SUIT_Desktop* aDesk = study->application()->desktop();
4520 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4521 SUIT_ViewWindow* wnd;
4522 foreach ( wnd, wndList )
4529 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4531 setMenuShown( false );
4532 setToolShown( false );
4534 EmitSignalCloseAllDialogs();
4536 // Unset actions accelerator keys
4537 //action(111)->setShortcut(QKeySequence()); // Import DAT
4538 action(112)->setShortcut(QKeySequence()); // Import UNV
4539 action(113)->setShortcut(QKeySequence()); // Import MED
4541 action( 33)->setEnabled(false); // Delete: Key_Delete
4543 return SalomeApp_Module::deactivateModule( study );
4546 void SMESHGUI::studyClosed( SUIT_Study* s )
4548 SMESH::RemoveVisuData( s->id() );
4549 SalomeApp_Module::studyClosed( s );
4552 void SMESHGUI::OnGUIEvent()
4554 const QObject* obj = sender();
4555 if ( !obj || !obj->inherits( "QAction" ) )
4557 int id = actionId((QAction*)obj);
4562 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4564 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4565 if ( CORBA::is_nil( myComponentSMESH ) )
4567 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4569 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4570 return aGUI.myComponentSMESH;
4573 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4574 return myComponentSMESH;
4577 QString SMESHGUI::engineIOR() const
4579 CORBA::ORB_var anORB = getApp()->orb();
4580 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4581 return QString( anIOR.in() );
4584 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4586 SalomeApp_Module::contextMenuPopup( client, menu, title );
4588 selectionMgr()->selectedObjects( lst );
4589 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4590 Handle(SALOME_InteractiveObject) io = lst.First();
4591 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4592 _PTR(Study) study = appStudy->studyDS();
4593 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4595 QString aName = QString( obj->GetName().c_str() );
4596 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4597 aName.remove( (aName.length() - 1), 1 );
4603 LightApp_Selection* SMESHGUI::createSelection() const
4605 return new SMESHGUI_Selection();
4608 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4610 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4611 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4614 void SMESHGUI::viewManagers( QStringList& list ) const
4616 list.append( SVTK_Viewer::Type() );
4619 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4621 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4622 SMESH::UpdateSelectionProp( this );
4624 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4625 for(int i = 0; i < aViews.count() ; i++){
4626 SUIT_ViewWindow *sf = aViews[i];
4632 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4634 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4635 myClippingPlaneInfoMap.erase( theViewManager );
4638 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4640 theActor->AddObserver( SMESH::DeleteActorEvent,
4641 myEventCallbackCommand.GetPointer(),
4645 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4646 unsigned long theEvent,
4647 void* theClientData,
4650 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4651 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4652 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4653 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4654 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4655 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4656 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4657 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4658 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4659 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4660 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4661 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4662 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4663 if( anActor == *anIter3 ) {
4664 anActorList.erase( anIter3 );
4675 void SMESHGUI::createPreferences()
4677 // General tab ------------------------------------------------------------------------
4678 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4680 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4681 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4682 setPreferenceProperty( lim, "min", 0 );
4683 setPreferenceProperty( lim, "max", 100000000 );
4684 setPreferenceProperty( lim, "step", 1000 );
4685 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4687 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4688 setPreferenceProperty( qaGroup, "columns", 2 );
4689 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4690 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4691 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4692 setPreferenceProperty( prec, "min", 0 );
4693 setPreferenceProperty( prec, "max", 16 );
4694 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4695 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4696 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4697 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4698 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4700 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4701 setPreferenceProperty( dispgroup, "columns", 2 );
4702 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4704 modes.append( tr("MEN_WIRE") );
4705 modes.append( tr("MEN_SHADE") );
4706 modes.append( tr("MEN_NODES") );
4707 modes.append( tr("MEN_SHRINK") );
4708 QList<QVariant> indices;
4709 indices.append( 0 );
4710 indices.append( 1 );
4711 indices.append( 2 );
4712 indices.append( 3 );
4713 setPreferenceProperty( dispmode, "strings", modes );
4714 setPreferenceProperty( dispmode, "indexes", indices );
4716 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4717 setPreferenceProperty( arcgroup, "columns", 2 );
4718 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4719 QStringList quadraticModes;
4720 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4721 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4723 indices.append( 0 );
4724 indices.append( 1 );
4725 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4726 setPreferenceProperty( quadraticmode, "indexes", indices );
4728 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4729 "SMESH", "max_angle" );
4730 setPreferenceProperty( maxAngle, "min", 1 );
4731 setPreferenceProperty( maxAngle, "max", 90 );
4735 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4736 setPreferenceProperty( exportgroup, "columns", 2 );
4737 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4738 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4740 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4741 setPreferenceProperty( computeGroup, "columns", 2 );
4742 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4744 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4745 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4746 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4748 indices.append( 0 );
4749 indices.append( 1 );
4750 indices.append( 2 );
4751 setPreferenceProperty( notifyMode, "strings", modes );
4752 setPreferenceProperty( notifyMode, "indexes", indices );
4754 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4755 setPreferenceProperty( infoGroup, "columns", 2 );
4756 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4758 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4759 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4761 indices.append( 0 );
4762 indices.append( 1 );
4763 setPreferenceProperty( elemInfo, "strings", modes );
4764 setPreferenceProperty( elemInfo, "indexes", indices );
4765 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4766 setPreferenceProperty( nodesLim, "min", 0 );
4767 setPreferenceProperty( nodesLim, "max", 10000000 );
4768 setPreferenceProperty( nodesLim, "step", 10000 );
4769 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4770 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4771 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4772 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4773 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4775 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4776 setPreferenceProperty( segGroup, "columns", 2 );
4777 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4778 "SMESH", "segmentation" );
4779 setPreferenceProperty( segLen, "min", 1 );
4780 setPreferenceProperty( segLen, "max", 10000000 );
4781 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4782 "SMESH", "nb_segments_per_edge" );
4783 setPreferenceProperty( nbSeg, "min", 1 );
4784 setPreferenceProperty( nbSeg, "max", 10000000 );
4786 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4787 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4788 "SMESH", "forget_mesh_on_hyp_modif" );
4791 // Quantities with individual precision settings
4792 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4793 setPreferenceProperty( precGroup, "columns", 2 );
4795 const int nbQuantities = 6;
4796 int precs[nbQuantities], ii = 0;
4797 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4798 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4799 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4800 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4801 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4802 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4803 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4804 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4805 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4806 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4807 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4808 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4810 // Set property for precision value for spinboxes
4811 for ( ii = 0; ii < nbQuantities; ii++ ){
4812 setPreferenceProperty( precs[ii], "min", -14 );
4813 setPreferenceProperty( precs[ii], "max", 14 );
4814 setPreferenceProperty( precs[ii], "precision", 2 );
4817 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4818 setPreferenceProperty( previewGroup, "columns", 2 );
4819 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4820 setPreferenceProperty( chunkSize, "min", 1 );
4821 setPreferenceProperty( chunkSize, "max", 1000 );
4822 setPreferenceProperty( chunkSize, "step", 50 );
4824 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4825 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4827 // Mesh tab ------------------------------------------------------------------------
4828 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4829 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4830 setPreferenceProperty( nodeGroup, "columns", 3 );
4832 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4834 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4836 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4837 QList<QVariant> aMarkerTypeIndicesList;
4838 QList<QVariant> aMarkerTypeIconsList;
4839 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4840 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4841 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4842 aMarkerTypeIndicesList << i;
4843 aMarkerTypeIconsList << pixmap;
4845 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4846 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4848 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4850 QList<QVariant> aMarkerScaleIndicesList;
4851 QStringList aMarkerScaleValuesList;
4852 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4853 aMarkerScaleIndicesList << i;
4854 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4856 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4857 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4859 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4860 //setPreferenceProperty( elemGroup, "columns", 2 );
4862 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4863 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4864 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
4865 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
4866 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4867 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
4868 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4869 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4872 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4873 setPreferenceProperty( grpGroup, "columns", 2 );
4875 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4876 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
4878 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4879 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4880 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
4881 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
4882 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4883 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4884 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
4885 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
4886 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4887 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4889 setPreferenceProperty( size0d, "min", 1 );
4890 setPreferenceProperty( size0d, "max", 10 );
4892 setPreferenceProperty( ballSize, "min", 1 );
4893 setPreferenceProperty( ballSize, "max", 10 );
4895 setPreferenceProperty( elemW, "min", 1 );
4896 setPreferenceProperty( elemW, "max", 5 );
4898 setPreferenceProperty( outW, "min", 1 );
4899 setPreferenceProperty( outW, "max", 5 );
4901 setPreferenceProperty( shrink, "min", 0 );
4902 setPreferenceProperty( shrink, "max", 100 );
4904 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
4905 setPreferenceProperty( numGroup, "columns", 2 );
4907 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
4908 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
4910 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
4911 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
4913 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4914 setPreferenceProperty( orientGroup, "columns", 1 );
4916 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4917 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4919 setPreferenceProperty( orientScale, "min", 0.05 );
4920 setPreferenceProperty( orientScale, "max", 0.5 );
4921 setPreferenceProperty( orientScale, "step", 0.05 );
4923 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4925 // Selection tab ------------------------------------------------------------------------
4926 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4928 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4929 setPreferenceProperty( selGroup, "columns", 2 );
4931 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4932 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4934 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4935 setPreferenceProperty( preGroup, "columns", 2 );
4937 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4939 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4940 setPreferenceProperty( precSelGroup, "columns", 2 );
4942 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4943 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4944 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4946 // Scalar Bar tab ------------------------------------------------------------------------
4947 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4948 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4949 setPreferenceProperty( fontGr, "columns", 2 );
4951 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4952 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4954 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4955 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4957 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4958 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4960 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4961 setPreferenceProperty( numcol, "min", 2 );
4962 setPreferenceProperty( numcol, "max", 256 );
4964 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4965 setPreferenceProperty( numlab, "min", 2 );
4966 setPreferenceProperty( numlab, "max", 65 );
4968 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4969 setPreferenceProperty( orientGr, "columns", 2 );
4970 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4971 QStringList orients;
4972 orients.append( tr( "SMESH_VERTICAL" ) );
4973 orients.append( tr( "SMESH_HORIZONTAL" ) );
4974 indices.clear(); indices.append( 0 ); indices.append( 1 );
4975 setPreferenceProperty( orient, "strings", orients );
4976 setPreferenceProperty( orient, "indexes", indices );
4978 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4979 setPreferenceProperty( posVSizeGr, "columns", 2 );
4980 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4981 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4982 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4983 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4984 setPreferenceProperty( xv, "step", 0.1 );
4985 setPreferenceProperty( xv, "min", 0.0 );
4986 setPreferenceProperty( xv, "max", 1.0 );
4987 setPreferenceProperty( yv, "step", 0.1 );
4988 setPreferenceProperty( yv, "min", 0.0 );
4989 setPreferenceProperty( yv, "max", 1.0 );
4990 setPreferenceProperty( wv, "step", 0.1 );
4991 setPreferenceProperty( wv, "min", 0.0 );
4992 setPreferenceProperty( wv, "max", 1.0 );
4993 setPreferenceProperty( hv, "min", 0.0 );
4994 setPreferenceProperty( hv, "max", 1.0 );
4995 setPreferenceProperty( hv, "step", 0.1 );
4997 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4998 setPreferenceProperty( posHSizeGr, "columns", 2 );
4999 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5000 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5001 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5002 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5003 setPreferenceProperty( xv, "min", 0.0 );
5004 setPreferenceProperty( xv, "max", 1.0 );
5005 setPreferenceProperty( xv, "step", 0.1 );
5006 setPreferenceProperty( xh, "min", 0.0 );
5007 setPreferenceProperty( xh, "max", 1.0 );
5008 setPreferenceProperty( xh, "step", 0.1 );
5009 setPreferenceProperty( yh, "min", 0.0 );
5010 setPreferenceProperty( yh, "max", 1.0 );
5011 setPreferenceProperty( yh, "step", 0.1 );
5012 setPreferenceProperty( wh, "min", 0.0 );
5013 setPreferenceProperty( wh, "max", 1.0 );
5014 setPreferenceProperty( wh, "step", 0.1 );
5015 setPreferenceProperty( hh, "min", 0.0 );
5016 setPreferenceProperty( hh, "max", 1.0 );
5017 setPreferenceProperty( hh, "step", 0.1 );
5019 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5020 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5021 setPreferenceProperty( distributionGr, "columns", 3 );
5023 types.append( tr( "SMESH_MONOCOLOR" ) );
5024 types.append( tr( "SMESH_MULTICOLOR" ) );
5025 indices.clear(); indices.append( 0 ); indices.append( 1 );
5026 setPreferenceProperty( coloringType, "strings", types );
5027 setPreferenceProperty( coloringType, "indexes", indices );
5028 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5032 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5034 if( sect=="SMESH" ) {
5035 float sbX1,sbY1,sbW,sbH;
5036 float aTol = 1.00000009999999;
5037 std::string aWarning;
5038 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5039 if( name=="selection_object_color" || name=="selection_element_color" ||
5040 name=="highlight_color" ||
5041 name=="selection_precision_node" || name=="selection_precision_element" ||
5042 name=="selection_precision_object")
5043 SMESH::UpdateSelectionProp( this );
5044 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5045 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5046 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5047 if(sbX1+sbW > aTol){
5048 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5051 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5052 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5055 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5056 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5057 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5058 if(sbY1+sbH > aTol){
5059 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5060 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5061 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5064 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5065 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5066 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5067 if(sbX1+sbW > aTol){
5068 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5071 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5072 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5075 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5076 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5077 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5078 if(sbY1+sbH > aTol){
5079 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5082 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5083 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5086 else if ( name == "segmentation" ) {
5087 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5088 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5090 else if ( name == "nb_segments_per_edge" ) {
5091 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5092 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5094 else if ( name == "historical_python_dump" ||
5095 name == "forget_mesh_on_hyp_modif") {
5096 QString val = aResourceMgr->stringValue( "SMESH", name );
5097 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5099 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5100 SMESH::UpdateFontProp( this );
5102 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5103 SMESH::UpdateFontProp( this );
5106 if(aWarning.size() != 0){
5107 aWarning += "The default values are applied instead.";
5108 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5109 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5110 QObject::tr(aWarning.c_str()));
5115 //================================================================================
5117 * \brief Update something in accordance with update flags
5118 * \param theFlags - update flags
5120 * Update viewer or/and object browser etc. in accordance with update flags ( see
5121 * LightApp_UpdateFlags enumeration ).
5123 //================================================================================
5124 void SMESHGUI::update( const int flags )
5126 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5127 SMESH::UpdateView();
5129 SalomeApp_Module::update( flags );
5132 //================================================================================
5134 * \brief Set default selection mode
5136 * SLOT called when operation commited. Sets default selection mode
5138 //================================================================================
5139 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5141 SVTK_ViewWindow* vtkWnd =
5142 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5144 vtkWnd->SetSelectionMode( ActorSelection );
5147 //================================================================================
5149 * \brief Set default selection mode
5151 * SLOT called when operation aborted. Sets default selection mode
5153 //================================================================================
5154 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5156 SVTK_ViewWindow* vtkWnd =
5157 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5159 vtkWnd->SetSelectionMode( ActorSelection );
5162 //================================================================================
5164 * \brief Creates operation with given identifier
5165 * \param id - identifier of operation to be started
5166 * \return Pointer on created operation or NULL if operation is not created
5168 * Virtual method redefined from the base class creates operation with given id.
5169 * It is called called automatically from startOperation method of base class.
5171 //================================================================================
5172 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5174 LightApp_Operation* op = 0;
5175 // to do : create operation here
5178 case 417: //convert to quadratic
5179 op = new SMESHGUI_ConvToQuadOp();
5181 case 418: // create 2D mesh as boundary on 3D
5182 op = new SMESHGUI_Make2DFrom3DOp();
5184 case 420: // Reorient faces
5185 op = new SMESHGUI_ReorientFacesOp();
5187 case 701: // Compute mesh
5188 op = new SMESHGUI_ComputeOp();
5190 case 702: // Create mesh
5191 op = new SMESHGUI_MeshOp( true, true );
5193 case 703: // Create sub-mesh
5194 op = new SMESHGUI_MeshOp( true, false );
5196 case 704: // Edit mesh/sub-mesh
5197 op = new SMESHGUI_MeshOp( false );
5199 case 711: // Precompute mesh
5200 op = new SMESHGUI_PrecomputeOp();
5202 case 712: // Evaluate mesh
5203 op = new SMESHGUI_EvaluateOp();
5205 case 713: // Evaluate mesh
5206 op = new SMESHGUI_MeshOrderOp();
5208 case 806: // Create group on geom
5209 op = new SMESHGUI_GroupOnShapeOp();
5211 case 904: // Find element
5212 op = new SMESHGUI_FindElemByPointOp();
5214 case 4067: // Make mesh pass through point
5215 op = new SMESHGUI_MakeNodeAtPointOp();
5217 case 4070: // Create 0D elements on all nodes
5218 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5225 op = SalomeApp_Module::createOperation( id );
5229 //================================================================================
5231 * \brief Stops current operations and starts a given one
5232 * \param id - The id of the operation to start
5234 //================================================================================
5236 void SMESHGUI::switchToOperation(int id)
5238 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5239 activeStudy()->abortAllOperations();
5240 startOperation( id );
5243 LightApp_Displayer* SMESHGUI::displayer()
5246 myDisplayer = new SMESHGUI_Displayer( getApp() );
5250 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5253 int aTolerance = 64;
5254 int anIterations = 0;
5260 if( anIterations % aPeriod == 0 )
5263 if( aTolerance < 1 )
5267 aHue = (int)( 360.0 * rand() / RAND_MAX );
5270 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5271 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5272 for( ; it != itEnd; ++it )
5274 SALOMEDS::Color anAutoColor = *it;
5275 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5278 aQColor.getHsv( &h, &s, &v );
5279 if( abs( h - aHue ) < aTolerance )
5291 aColor.setHsv( aHue, 255, 255 );
5293 SALOMEDS::Color aSColor;
5294 aSColor.R = aColor.redF();
5295 aSColor.G = aColor.greenF();
5296 aSColor.B = aColor.blueF();
5301 const char* gSeparator = "_"; // character used to separate parameter names
5302 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5303 const char* gPathSep = "|"; // character used to separate paths
5306 * \brief Store visual parameters
5308 * This method is called just before the study document is saved.
5309 * Store visual parameters in AttributeParameter attribue(s)
5311 void SMESHGUI::storeVisualParameters (int savePoint)
5314 Kernel_Utils::Localizer loc;
5316 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5317 if (!appStudy || !appStudy->studyDS())
5319 _PTR(Study) studyDS = appStudy->studyDS();
5321 // componentName is used for encoding of entries when storing them in IParameters
5322 std::string componentName = myComponentSMESH->ComponentDataType();
5323 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5324 //if (!aSComponent) return;
5327 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5328 componentName.c_str(),
5330 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5332 // store map of custom markers
5333 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5334 if( !aMarkerMap.empty() )
5336 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5337 for( ; anIter != aMarkerMap.end(); anIter++ )
5339 int anId = anIter->first;
5340 VTK::MarkerData aMarkerData = anIter->second;
5341 std::string aMarkerFileName = aMarkerData.first;
5342 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5343 if( aMarkerTexture.size() < 3 )
5344 continue; // should contain at least width, height and the first value
5346 QString aPropertyName( "texture" );
5347 aPropertyName += gSeparator;
5348 aPropertyName += QString::number( anId );
5350 QString aPropertyValue = aMarkerFileName.c_str();
5351 aPropertyValue += gPathSep;
5353 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5354 ushort aWidth = *aTextureIter++;
5355 ushort aHeight = *aTextureIter++;
5356 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5357 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5358 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5359 aPropertyValue += QString::number( *aTextureIter );
5361 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5365 // viewers counters are used for storing view_numbers in IParameters
5368 // main cycle to store parameters of displayed objects
5369 QList<SUIT_ViewManager*> lst;
5370 QList<SUIT_ViewManager*>::Iterator it;
5371 getApp()->viewManagers(lst);
5372 for (it = lst.begin(); it != lst.end(); it++)
5374 SUIT_ViewManager* vman = *it;
5375 QString vType = vman->getType();
5377 // saving VTK actors properties
5378 if (vType == SVTK_Viewer::Type())
5380 // store the clipping planes attached to the view manager
5381 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5382 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5383 if( anIter != myClippingPlaneInfoMap.end() )
5384 aClippingPlaneInfoList = anIter->second;
5386 if( !aClippingPlaneInfoList.empty() ) {
5387 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5388 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5390 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5391 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5393 QString aPropertyName( "ClippingPlane" );
5394 aPropertyName += gSeparator;
5395 aPropertyName += QString::number( vtkViewers );
5396 aPropertyName += gSeparator;
5397 aPropertyName += QString::number( anId );
5399 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5400 aPropertyValue += gDigitsSep;
5401 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5402 aPropertyValue += gDigitsSep;
5403 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5404 aPropertyValue += gDigitsSep;
5405 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5407 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5411 QVector<SUIT_ViewWindow*> views = vman->getViews();
5412 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5414 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5416 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5417 vtkActorCollection* allActors = aCopy.GetActors();
5418 allActors->InitTraversal();
5419 while (vtkActor* actor = allActors->GetNextActor())
5421 if (actor->GetVisibility()) // store only visible actors
5423 SMESH_Actor* aSmeshActor = 0;
5424 if (actor->IsA("SMESH_Actor"))
5425 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5426 if (aSmeshActor && aSmeshActor->hasIO())
5428 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5431 // entry is "encoded" = it does NOT contain component adress,
5432 // since it is a subject to change on next component loading
5433 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5435 std::string param, vtkParam = vType.toLatin1().data();
5436 vtkParam += gSeparator;
5437 vtkParam += QString::number(vtkViewers).toLatin1().data();
5438 vtkParam += gSeparator;
5441 param = vtkParam + "Visibility";
5442 ip->setParameter(entry, param, "On");
5445 param = vtkParam + "Representation";
5446 ip->setParameter(entry, param, QString::number
5447 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5450 param = vtkParam + "IsShrunk";
5451 ip->setParameter(entry, param, QString::number
5452 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5454 // Displayed entities
5455 unsigned int aMode = aSmeshActor->GetEntityMode();
5456 bool isE = aMode & SMESH_Actor::eEdges;
5457 bool isF = aMode & SMESH_Actor::eFaces;
5458 bool isV = aMode & SMESH_Actor::eVolumes;
5459 bool is0d = aMode & SMESH_Actor::e0DElements;
5460 bool isB = aMode & SMESH_Actor::eBallElem;
5462 QString modeStr ("e");
5463 modeStr += gDigitsSep; modeStr += QString::number(isE);
5464 modeStr += gDigitsSep; modeStr += "f";
5465 modeStr += gDigitsSep; modeStr += QString::number(isF);
5466 modeStr += gDigitsSep; modeStr += "v";
5467 modeStr += gDigitsSep; modeStr += QString::number(isV);
5468 modeStr += gDigitsSep; modeStr += "0d";
5469 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5470 modeStr += gDigitsSep; modeStr += "b";
5471 modeStr += gDigitsSep; modeStr += QString::number(isB);
5473 param = vtkParam + "Entities";
5474 ip->setParameter(entry, param, modeStr.toLatin1().data());
5480 aSmeshActor->GetSufaceColor(r, g, b, delta);
5481 QStringList colorStr;
5482 colorStr << "surface";
5483 colorStr << QString::number(r);
5484 colorStr << QString::number(g);
5485 colorStr << QString::number(b);
5487 colorStr << "backsurface";
5488 colorStr << QString::number(delta);
5490 aSmeshActor->GetVolumeColor(r, g, b, delta);
5491 colorStr << "volume";
5492 colorStr << QString::number(r);
5493 colorStr << QString::number(g);
5494 colorStr << QString::number(b);
5495 colorStr << QString::number(delta);
5497 aSmeshActor->GetEdgeColor(r, g, b);
5499 colorStr << QString::number(r);
5500 colorStr << QString::number(g);
5501 colorStr << QString::number(b);
5503 aSmeshActor->GetNodeColor(r, g, b);
5505 colorStr << QString::number(r);
5506 colorStr << QString::number(g);
5507 colorStr << QString::number(b);
5509 aSmeshActor->GetOutlineColor(r, g, b);
5510 colorStr << "outline";
5511 colorStr << QString::number(r);
5512 colorStr << QString::number(g);
5513 colorStr << QString::number(b);
5515 aSmeshActor->Get0DColor(r, g, b);
5516 colorStr << "elem0d";
5517 colorStr << QString::number(r);
5518 colorStr << QString::number(g);
5519 colorStr << QString::number(b);
5521 aSmeshActor->GetBallColor(r, g, b);
5523 colorStr << QString::number(r);
5524 colorStr << QString::number(g);
5525 colorStr << QString::number(b);
5527 aSmeshActor->GetFacesOrientationColor(r, g, b);
5528 colorStr << "orientation";
5529 colorStr << QString::number(r);
5530 colorStr << QString::number(g);
5531 colorStr << QString::number(b);
5533 param = vtkParam + "Colors";
5534 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5537 QStringList sizeStr;
5539 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5540 sizeStr << "outline";
5541 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5542 sizeStr << "elem0d";
5543 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5545 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5546 sizeStr << "shrink";
5547 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5548 sizeStr << "orientation";
5549 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5550 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5552 param = vtkParam + "Sizes";
5553 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5558 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5559 if( aMarkerType == VTK::MT_USER ) {
5560 markerStr += "custom";
5561 markerStr += gDigitsSep;
5562 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5566 markerStr += gDigitsSep;
5567 markerStr += QString::number( (int)aMarkerType );
5568 markerStr += gDigitsSep;
5569 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5572 param = vtkParam + "PointMarker";
5573 ip->setParameter(entry, param, markerStr.toLatin1().data());
5576 param = vtkParam + "Opacity";
5577 ip->setParameter(entry, param,
5578 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5581 param = vtkParam + "ClippingPlane";
5583 if( !aClippingPlaneInfoList.empty() ) {
5584 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5585 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5587 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5588 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5589 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5590 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5591 if( aSmeshActor == *anIter2 ) {
5592 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5593 QString::number( anId ).toLatin1().constData() );
5600 ip->setParameter( entry, param, "Off" );
5601 } // if (io->hasEntry())
5602 } // SMESH_Actor && hasIO
5604 } // while.. actors traversal
5608 } // if (SVTK view model)
5609 } // for (viewManagers)
5612 // data structures for clipping planes processing
5615 vtkIdType Orientation;
5619 typedef std::list<TPlaneData> TPlaneDataList;
5620 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5622 typedef std::list<vtkActor*> TActorList;
5625 TActorList ActorList;
5626 SUIT_ViewManager* ViewManager;
5628 typedef std::list<TPlaneInfo> TPlaneInfoList;
5629 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5632 * \brief Restore visual parameters
5634 * This method is called after the study document is opened.
5635 * Restore visual parameters from AttributeParameter attribue(s)
5637 void SMESHGUI::restoreVisualParameters (int savePoint)
5640 Kernel_Utils::Localizer loc;
5642 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5643 if (!appStudy || !appStudy->studyDS())
5645 _PTR(Study) studyDS = appStudy->studyDS();
5647 // componentName is used for encoding of entries when storing them in IParameters
5648 std::string componentName = myComponentSMESH->ComponentDataType();
5649 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5650 //if (!aSComponent) return;
5653 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5654 componentName.c_str(),
5656 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5658 // restore map of custom markers and map of clipping planes
5659 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5660 TPlaneDataMap aPlaneDataMap;
5662 std::vector<std::string> properties = ip->getProperties();
5663 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5665 std::string property = *propIt;
5666 QString aPropertyName( property.c_str() );
5667 QString aPropertyValue( ip->getProperty( property ).c_str() );
5669 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5670 if( aPropertyNameList.isEmpty() )
5673 QString aPropertyType = aPropertyNameList[0];
5674 if( aPropertyType == "texture" )
5676 if( aPropertyNameList.size() != 2 )
5680 int anId = aPropertyNameList[1].toInt( &ok );
5681 if( !ok || anId < 1 )
5684 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5685 if( aPropertyValueList.size() != 2 )
5688 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5689 QString aMarkerTextureString = aPropertyValueList[1];
5690 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5691 if( aMarkerTextureStringList.size() != 3 )
5695 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5700 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5704 VTK::MarkerTexture aMarkerTexture;
5705 aMarkerTexture.push_back( aWidth );
5706 aMarkerTexture.push_back( aHeight );
5708 QString aMarkerTextureData = aMarkerTextureStringList[2];
5709 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5711 QChar aChar = aMarkerTextureData.at( i );
5712 if( aChar.isDigit() )
5713 aMarkerTexture.push_back( aChar.digitValue() );
5716 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5718 else if( aPropertyType == "ClippingPlane" )
5720 if( aPropertyNameList.size() != 3 )
5724 int aViewId = aPropertyNameList[1].toInt( &ok );
5725 if( !ok || aViewId < 0 )
5729 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5730 if( !ok || aClippingPlaneId < 0 )
5733 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5734 if( aPropertyValueList.size() != 4 )
5737 TPlaneData aPlaneData;
5738 aPlaneData.Id = aClippingPlaneId;
5741 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5746 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5751 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5756 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5760 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5761 aPlaneDataList.push_back( aPlaneData );
5765 TPlaneInfoMap aPlaneInfoMap;
5767 std::vector<std::string> entries = ip->getEntries();
5769 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5771 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5772 QString entry (ip->decodeEntry(*entIt).c_str());
5774 // Check that the entry corresponds to a real object in the Study
5775 // as the object may be deleted or modified after the visual state is saved.
5776 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5777 if (!so) continue; //Skip the not existent entry
5779 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5780 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5782 std::vector<std::string>::iterator namesIt = paramNames.begin();
5783 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5785 // actors are stored in a map after displaying of them for
5786 // quicker access in the future: map < viewID to actor >
5787 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5789 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5791 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5792 // '_' is used as separator and should not be used in viewer type or parameter names.
5793 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5794 if (lst.size() != 3)
5797 QString viewerTypStr = lst[0];
5798 QString viewIndexStr = lst[1];
5799 QString paramNameStr = lst[2];
5802 int viewIndex = viewIndexStr.toUInt(&ok);
5803 if (!ok) // bad conversion of view index to integer
5807 if (viewerTypStr == SVTK_Viewer::Type())
5809 SMESH_Actor* aSmeshActor = 0;
5810 if (vtkActors.IsBound(viewIndex))
5811 aSmeshActor = vtkActors.Find(viewIndex);
5813 QList<SUIT_ViewManager*> lst;
5814 getApp()->viewManagers(viewerTypStr, lst);
5816 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5817 SUIT_ViewManager* vman = NULL;
5818 if (viewIndex >= 0 && viewIndex < lst.count())
5819 vman = lst.at(viewIndex);
5821 if (paramNameStr == "Visibility")
5823 if (!aSmeshActor && displayer() && vman)
5825 SUIT_ViewModel* vmodel = vman->getViewModel();
5826 // SVTK view model can be casted to SALOME_View
5827 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5829 // store displayed actor in a temporary map for quicker
5830 // access later when restoring other parameters
5831 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5832 vtkRenderer* Renderer = vtkView->getRenderer();
5833 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5834 vtkActorCollection* theActors = aCopy.GetActors();
5835 theActors->InitTraversal();
5836 bool isFound = false;
5837 vtkActor *ac = theActors->GetNextActor();
5838 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5839 if (ac->IsA("SMESH_Actor")) {
5840 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5841 if (aGeomAc->hasIO()) {
5842 Handle(SALOME_InteractiveObject) io =
5843 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5844 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5846 vtkActors.Bind(viewIndex, aGeomAc);
5852 } // if (paramNameStr == "Visibility")
5855 // the rest properties "work" with SMESH_Actor
5858 QString val ((*valuesIt).c_str());
5861 if (paramNameStr == "Representation") {
5862 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5865 else if (paramNameStr == "IsShrunk") {
5867 if (!aSmeshActor->IsShrunk())
5868 aSmeshActor->SetShrink();
5871 if (aSmeshActor->IsShrunk())
5872 aSmeshActor->UnShrink();
5875 // Displayed entities
5876 else if (paramNameStr == "Entities") {
5877 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5878 int aEntityMode = SMESH_Actor::eAllEntity;
5879 for ( int i = 0; i < mode.count(); i+=2 ) {
5880 if ( i < mode.count()-1 ) {
5881 QString type = mode[i];
5882 bool val = mode[i+1].toInt();
5883 if ( type == "e" && !val )
5884 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
5885 else if ( type == "f" && !val )
5886 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
5887 else if ( type == "v" && !val )
5888 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
5889 else if ( type == "0d" && !val )
5890 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
5891 else if ( type == "b" && !val )
5892 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
5895 aSmeshActor->SetEntityMode( aEntityMode );
5898 else if (paramNameStr == "Colors") {
5899 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5906 QColor outlineColor;
5907 QColor orientationColor;
5913 // below lines are required to get default values for delta coefficients
5914 // of backface color for faces and color of reversed volumes
5915 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
5916 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
5917 for ( int i = 0; i < colors.count(); i++ ) {
5918 QString type = colors[i];
5919 if ( type == "surface" ) {
5920 // face color is set by 3 values r:g:b, where
5921 // - r,g,b - is rgb color components
5922 if ( i+1 >= colors.count() ) break; // format error
5923 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5924 if ( i+2 >= colors.count() ) break; // format error
5925 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5926 if ( i+3 >= colors.count() ) break; // format error
5927 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5928 faceColor.setRgbF( r, g, b );
5931 else if ( type == "backsurface" ) {
5932 // backface color can be defined in several ways
5933 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
5934 // - in latest versions, it is set as delta coefficient
5935 bool rgbOk = false, deltaOk;
5936 if ( i+1 >= colors.count() ) break; // format error
5937 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5938 int delta = colors[i+1].toInt( &deltaOk );
5940 if ( i+1 < colors.count() ) // index is shifted to 1
5941 g = colors[i+1].toDouble( &rgbOk );
5942 if ( rgbOk ) i++; // shift index
5943 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
5944 b = colors[i+1].toDouble( &rgbOk );
5946 // - as currently there's no way to set directly backsurface color as it was before,
5947 // we ignore old dump where r,g,b triple was set
5948 // - also we check that delta parameter is set properly
5949 if ( !rgbOk && deltaOk )
5952 else if ( type == "volume" ) {
5953 // volume color is set by 4 values r:g:b:delta, where
5954 // - r,g,b - is a normal volume rgb color components
5955 // - delta - is a reversed volume color delta coefficient
5956 if ( i+1 >= colors.count() ) break; // format error
5957 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5958 if ( i+2 >= colors.count() ) break; // format error
5959 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5960 if ( i+3 >= colors.count() ) break; // format error
5961 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5962 if ( i+4 >= colors.count() ) break; // format error
5963 int delta = colors[i+4].toInt( &bOk );
5964 if ( !bOk ) break; // format error
5965 volumeColor.setRgbF( r, g, b );
5969 else if ( type == "edge" ) {
5970 // edge color is set by 3 values r:g:b, where
5971 // - r,g,b - is rgb color components
5972 if ( i+1 >= colors.count() ) break; // format error
5973 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5974 if ( i+2 >= colors.count() ) break; // format error
5975 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5976 if ( i+3 >= colors.count() ) break; // format error
5977 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5978 edgeColor.setRgbF( r, g, b );
5981 else if ( type == "node" ) {
5982 // node color is set by 3 values r:g:b, where
5983 // - r,g,b - is rgb color components
5984 if ( i+1 >= colors.count() ) break; // format error
5985 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5986 if ( i+2 >= colors.count() ) break; // format error
5987 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5988 if ( i+3 >= colors.count() ) break; // format error
5989 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5990 nodeColor.setRgbF( r, g, b );
5993 else if ( type == "elem0d" ) {
5994 // 0d element color is set by 3 values r:g:b, where
5995 // - r,g,b - is rgb color components
5996 if ( i+1 >= colors.count() ) break; // format error
5997 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5998 if ( i+2 >= colors.count() ) break; // format error
5999 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6000 if ( i+3 >= colors.count() ) break; // format error
6001 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6002 elem0dColor.setRgbF( r, g, b );
6005 else if ( type == "ball" ) {
6006 // ball color is set by 3 values r:g:b, where
6007 // - r,g,b - is rgb color components
6008 if ( i+1 >= colors.count() ) break; // format error
6009 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6010 if ( i+2 >= colors.count() ) break; // format error
6011 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6012 if ( i+3 >= colors.count() ) break; // format error
6013 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6014 ballColor.setRgbF( r, g, b );
6017 else if ( type == "outline" ) {
6018 // outline color is set by 3 values r:g:b, where
6019 // - r,g,b - is rgb color components
6020 if ( i+1 >= colors.count() ) break; // format error
6021 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6022 if ( i+2 >= colors.count() ) break; // format error
6023 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6024 if ( i+3 >= colors.count() ) break; // format error
6025 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6026 outlineColor.setRgbF( r, g, b );
6029 else if ( type == "orientation" ) {
6030 // orientation color is set by 3 values r:g:b, where
6031 // - r,g,b - is rgb color components
6032 if ( i+1 >= colors.count() ) break; // format error
6033 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6034 if ( i+2 >= colors.count() ) break; // format error
6035 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6036 if ( i+3 >= colors.count() ) break; // format error
6037 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6038 orientationColor.setRgbF( r, g, b );
6043 if ( nodeColor.isValid() )
6044 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6046 if ( edgeColor.isValid() )
6047 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6049 if ( faceColor.isValid() )
6050 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6052 if ( volumeColor.isValid() )
6053 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6054 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6055 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6057 if ( elem0dColor.isValid() )
6058 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6060 if ( ballColor.isValid() )
6061 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6063 if ( outlineColor.isValid() )
6064 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6065 // orientation color
6066 if ( orientationColor.isValid() )
6067 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6070 else if (paramNameStr == "Sizes") {
6071 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6074 int outlineWidth = -1;
6075 int elem0dSize = -1;
6077 double shrinkSize = -1;
6078 double orientationSize = -1;
6079 bool orientation3d = false;
6080 for ( int i = 0; i < sizes.count(); i++ ) {
6081 QString type = sizes[i];
6082 if ( type == "line" ) {
6083 // line (wireframe) width is given as single integer value
6084 if ( i+1 >= sizes.count() ) break; // format error
6085 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6089 if ( type == "outline" ) {
6090 // outline width is given as single integer value
6091 if ( i+1 >= sizes.count() ) break; // format error
6092 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6096 else if ( type == "elem0d" ) {
6097 // 0d element size is given as single integer value
6098 if ( i+1 >= sizes.count() ) break; // format error
6099 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6103 else if ( type == "ball" ) {
6104 // ball size is given as single integer value
6105 if ( i+1 >= sizes.count() ) break; // format error
6106 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6110 else if ( type == "shrink" ) {
6111 // shrink factor is given as single floating point value
6112 if ( i+1 >= sizes.count() ) break; // format error
6113 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6117 else if ( type == "orientation" ) {
6118 // orientation vectors are specified by two values size:3d, where
6119 // - size - is a floating point value specifying scale factor
6120 // - 3d - is a boolean
6121 if ( i+1 >= sizes.count() ) break; // format error
6122 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6123 if ( i+2 >= sizes.count() ) break; // format error
6124 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6125 orientationSize = v1;
6126 orientation3d = (bool)v2;
6130 // line (wireframe) width
6131 if ( lineWidth > 0 )
6132 aSmeshActor->SetLineWidth( lineWidth );
6134 if ( outlineWidth > 0 )
6135 aSmeshActor->SetOutlineWidth( outlineWidth );
6136 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6137 aSmeshActor->SetOutlineWidth( lineWidth );
6139 if ( elem0dSize > 0 )
6140 aSmeshActor->Set0DSize( elem0dSize );
6143 aSmeshActor->SetBallSize( ballSize );
6145 if ( shrinkSize > 0 )
6146 aSmeshActor->SetShrinkFactor( shrinkSize );
6147 // orientation vectors
6148 if ( orientationSize > 0 ) {
6149 aSmeshActor->SetFacesOrientationScale( orientationSize );
6150 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6154 else if (paramNameStr == "PointMarker") {
6155 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6156 if( data.count() >= 2 ) {
6158 int aParam1 = data[1].toInt( &ok );
6160 if( data[0] == "std" && data.count() == 3 ) {
6161 int aParam2 = data[2].toInt( &ok );
6162 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6164 else if( data[0] == "custom" ) {
6165 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6166 if( markerIt != aMarkerMap.end() ) {
6167 VTK::MarkerData aMarkerData = markerIt->second;
6168 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6175 else if (paramNameStr == "Opacity") {
6176 aSmeshActor->SetOpacity(val.toFloat());
6179 else if (paramNameStr.startsWith("ClippingPlane")) {
6180 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6181 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
6182 // new format - val looks like "Off" or "0" (plane id)
6183 // (note: in new format "Off" value is used only for consistency,
6184 // so it is processed together with values in old format)
6185 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
6186 if( anIsOldFormat ) {
6187 if (paramNameStr == "ClippingPlane1" || val == "Off")
6188 aSmeshActor->RemoveAllClippingPlanes();
6190 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
6191 double aDistance = vals[1].toFloat();
6193 anAngle[0] = vals[2].toFloat();
6194 anAngle[1] = vals[3].toFloat();
6196 QList<SUIT_ViewManager*> lst;
6197 getApp()->viewManagers(viewerTypStr, lst);
6198 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6199 if (viewIndex >= 0 && viewIndex < lst.count()) {
6200 SUIT_ViewManager* vman = lst.at(viewIndex);
6201 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6203 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6205 SMESH::TActorList anActorList;
6206 anActorList.push_back( aSmeshActor );
6207 SMESH::OrientedPlane* aPlane =
6208 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
6210 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6211 aClippingPlaneInfo.Plane = aPlane;
6212 aClippingPlaneInfo.ActorList = anActorList;
6213 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6220 int aPlaneId = val.toInt( &ok );
6221 if( ok && aPlaneId >= 0 ) {
6222 bool anIsDefinedPlane = false;
6223 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6224 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6225 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6226 TPlaneInfo& aPlaneInfo = *anIter;
6227 if( aPlaneInfo.PlaneId == aPlaneId ) {
6228 aPlaneInfo.ActorList.push_back( aSmeshActor );
6229 anIsDefinedPlane = true;
6233 if( !anIsDefinedPlane ) {
6234 TPlaneInfo aPlaneInfo;
6235 aPlaneInfo.PlaneId = aPlaneId;
6236 aPlaneInfo.ActorList.push_back( aSmeshActor );
6237 aPlaneInfo.ViewManager = vman;
6239 // to make the list sorted by plane id
6240 anIter = aPlaneInfoList.begin();
6241 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6242 const TPlaneInfo& aPlaneInfoRef = *anIter;
6243 if( aPlaneInfoRef.PlaneId > aPlaneId )
6246 aPlaneInfoList.insert( anIter, aPlaneInfo );
6251 } // if (aSmeshActor)
6252 } // other parameters than Visibility
6254 } // for names/parameters iterator
6255 } // for entries iterator
6257 // take into account planes with empty list of actors referred to them
6258 QList<SUIT_ViewManager*> aVMList;
6259 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6261 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6262 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6263 int aViewId = aPlaneDataIter->first;
6264 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6265 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6267 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6269 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6270 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6271 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6272 const TPlaneData& aPlaneData = *anIter2;
6273 int aPlaneId = aPlaneData.Id;
6275 bool anIsFound = false;
6276 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6277 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6278 const TPlaneInfo& aPlaneInfo = *anIter3;
6279 if( aPlaneInfo.PlaneId == aPlaneId ) {
6286 TPlaneInfo aPlaneInfo; // ActorList field is empty
6287 aPlaneInfo.PlaneId = aPlaneId;
6288 aPlaneInfo.ViewManager = aViewManager;
6290 // to make the list sorted by plane id
6291 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6292 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6293 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6294 if( aPlaneInfoRef.PlaneId > aPlaneId )
6297 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6303 // add clipping planes to actors according to the restored parameters
6304 // and update the clipping plane map
6305 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6306 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6307 int aViewId = anIter1->first;
6308 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6310 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6311 if( anIter2 == aPlaneDataMap.end() )
6313 const TPlaneDataList& aPlaneDataList = anIter2->second;
6315 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6316 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6317 const TPlaneInfo& aPlaneInfo = *anIter3;
6318 int aPlaneId = aPlaneInfo.PlaneId;
6319 const TActorList& anActorList = aPlaneInfo.ActorList;
6320 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6324 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6328 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6330 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6331 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6332 const TPlaneData& aPlaneData = *anIter4;
6333 if( aPlaneData.Id == aPlaneId ) {
6334 SMESH::OrientedPlane* aPlane =
6335 SMESHGUI_ClippingDlg::AddPlane( anActorList,
6337 (SMESH::Orientation)aPlaneData.Orientation,
6338 aPlaneData.Distance,
6341 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6342 aClippingPlaneInfo.Plane = aPlane;
6343 aClippingPlaneInfo.ActorList = anActorList;
6344 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6352 // update all VTK views
6353 QList<SUIT_ViewManager*> lst;
6354 getApp()->viewManagers(lst);
6355 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6356 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6357 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6358 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6359 vtkView->getRenderer()->ResetCameraClippingRange();
6366 \brief Adds preferences for dfont of VTK viewer
6368 \param pIf group identifier
6369 \param param parameter
6370 \return identifier of preferences
6372 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6374 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6376 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6379 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6380 fam.append( tr( "SMESH_FONT_COURIER" ) );
6381 fam.append( tr( "SMESH_FONT_TIMES" ) );
6383 setPreferenceProperty( tfont, "fonts", fam );
6385 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6386 if ( needSize ) f = f | QtxFontEdit::Size;
6387 setPreferenceProperty( tfont, "features", f );
6393 \brief Actions after hypothesis edition
6394 Updates object browser after hypothesis edition
6396 void SMESHGUI::onHypothesisEdit( int result )
6399 SMESHGUI::Modified();
6400 updateObjBrowser( true );
6405 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6406 \param pview view being closed
6408 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6409 #ifndef DISABLE_PLOT2DVIEWER
6410 //Crear all Plot2d Viewers if need.
6411 SMESH::ClearPlot2Viewers(pview);
6415 void SMESHGUI::message( const QString& msg )
6418 QStringList data = msg.split("/");
6419 if ( data.count() > 0 ) {
6420 if ( data.first() == "mesh_loading" ) {
6422 QString entry = data.count() > 1 ? data[1] : QString();
6423 if ( entry.isEmpty() )
6426 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6428 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6431 name = obj->GetName().c_str();
6432 if ( name.isEmpty() )
6435 if ( data.last() == "stop" )
6436 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6438 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6439 QApplication::processEvents();
6445 \brief Connects or disconnects signals about activating and cloning view on the module slots
6446 \param pview view which is connected/disconnected
6448 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6452 SUIT_ViewManager* viewMgr = pview->getViewManager();
6454 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6455 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6457 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6458 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6463 \brief Return \c true if object can be renamed
6465 bool SMESHGUI::renameAllowed( const QString& entry) const {
6466 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6470 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6474 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6479 if(appStudy->isComponent(entry) || obj->isReference())
6482 // check type to prevent renaming of inappropriate objects
6483 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6484 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6485 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6486 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6487 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6488 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6495 Rename object by entry.
6496 \param entry entry of the object
6497 \param name new name of the object
6498 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6500 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6502 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6506 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6511 _PTR(Study) aStudy = appStudy->studyDS();
6516 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6518 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6523 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6524 _PTR(GenericAttribute) anAttr;
6525 _PTR(AttributeName) aName;
6527 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6529 // check type to prevent renaming of inappropriate objects
6530 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6531 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6532 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6533 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6534 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6535 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6536 if ( !name.isEmpty() ) {
6537 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6539 // update name of group object and its actor
6540 Handle(SALOME_InteractiveObject) IObject =
6541 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6543 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6544 if( !aGroupObject->_is_nil() ) {
6545 aGroupObject->SetName( qPrintable(name) );
6546 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6547 anActor->setName( qPrintable(name) );
6558 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6560 static QList<QColor> colors;
6562 if ( colors.isEmpty() ) {
6564 for (int s = 0; s < 2 ; s++)
6566 for (int v = 100; v >= 40; v = v - 20)
6568 for (int h = 0; h < 359 ; h = h + 60)
6570 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6575 static int currentColor = 0;
6577 SALOMEDS::Color color;
6578 color.R = (double)colors[currentColor].red() / 255.0;
6579 color.G = (double)colors[currentColor].green() / 255.0;
6580 color.B = (double)colors[currentColor].blue() / 255.0;
6582 currentColor = (currentColor+1) % colors.count();