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>
165 #include <SALOMEDS_SObject.hxx>
168 #include <Standard_ErrorHandler.hxx>
169 #include <NCollection_DataMap.hxx>
171 #include <Basics_Utils.hxx>
173 //To disable automatic genericobj management, the following line should be commented.
174 //Otherwise, it should be uncommented.
175 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
176 #define WITHGENERICOBJ
178 // Below macro, when uncommented, switches on simplified (more performant) algorithm
179 // of auto-color picking up
180 #define SIMPLE_AUTOCOLOR
184 //=============================================================
185 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
188 void ExportMeshToFile(int theCommandID);
190 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
192 void SetDisplayEntity(int theCommandID);
194 void Control( int theCommandID );
198 //=============================================================
199 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
203 std::string myExtension;
205 if ( theCommandID == 113 ) {
206 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
207 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
209 else if ( theCommandID == 112 ) {
210 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
212 else if ( theCommandID == 111 ) {
213 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
215 else if ( theCommandID == 115 ) {
216 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
218 else if ( theCommandID == 116 ) {
219 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
221 else if ( theCommandID == 117 ) {
222 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
223 filter.append( QObject::tr( "All files (*)" ) );
225 else if ( theCommandID == 118 ) {
226 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
227 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
230 QString anInitialPath = "";
231 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
232 anInitialPath = QDir::currentPath();
234 QStringList filenames;
235 bool toCreateGroups = true;
237 // if ( theCommandID == 118 ) { // GMF
238 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
239 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
240 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
241 // fd->setNameFilters( filter );
242 // fd->SetChecked( true );
244 // filenames << fd->selectedFile();
245 // toCreateGroups = fd->IsChecked();
251 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
254 QObject::tr( "SMESH_IMPORT_MESH" ) );
256 if ( filenames.count() > 0 ) {
257 SUIT_OverrideCursor wc;
258 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
261 QStringList anEntryList;
262 bool isEmpty = false;
263 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
264 QString filename = *it;
265 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
267 switch ( theCommandID ) {
270 // DAT format (currently unsupported)
271 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
272 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
278 aMeshes->length( 1 );
279 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
280 if ( aMeshes[0]->_is_nil() )
281 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
282 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
288 SMESH::DriverMED_ReadStatus res;
289 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
290 if ( res != SMESH::DRS_OK ) {
291 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
292 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
299 aMeshes->length( 1 );
300 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
301 if ( aMeshes[0]->_is_nil() ) {
302 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
303 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
310 SMESH::DriverMED_ReadStatus res;
311 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
312 if ( res != SMESH::DRS_OK ) {
313 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
314 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
321 SMESH::DriverMED_ReadStatus res;
322 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
323 if ( res != SMESH::DRS_OK ) {
324 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
325 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
332 SMESH::ComputeError_var res;
333 aMeshes->length( 1 );
334 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
337 if ( res->code != SMESH::DRS_OK ) {
338 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
339 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
340 if ( strlen( res->comment.in() ) > 0 ) {
341 errors.back() += ": ";
342 errors.back() += res->comment.in();
349 catch ( const SALOME::SALOME_Exception& S_ex ) {
350 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
351 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
354 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
355 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
357 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
358 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
359 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
360 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
361 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
363 anEntryList.append( aMeshSO->GetID().c_str() );
371 // update Object browser
372 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
374 // browse to the published meshes
375 if( LightApp_Application* anApp =
376 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
377 anApp->browseObjects( anEntryList );
379 // show Error message box if there were errors
380 if ( errors.count() > 0 ) {
381 SUIT_MessageBox::critical( SMESHGUI::desktop(),
382 QObject::tr( "SMESH_ERROR" ),
383 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
386 // show warning message box, if some imported mesh is empty
388 SUIT_MessageBox::warning( SMESHGUI::desktop(),
389 QObject::tr( "SMESH_WRN_WARNING" ),
390 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
395 //================================================================================
397 * \brief Export selected meshes or groups into a file
399 //================================================================================
401 void ExportMeshToFile( int theCommandID )
403 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
404 SALOME_ListIO selected;
406 aSel->selectedObjects( selected );
408 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
409 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
410 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
411 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
412 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
413 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
414 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
416 // actually, the following condition can't be met (added for insurance)
417 if( selected.Extent() == 0 ||
418 ( selected.Extent() > 1 && !isMED && !isSTL ))
421 // get mesh object from selection and check duplication of their names
422 bool hasDuplicatedMeshNames = false;
423 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
424 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
425 SALOME_ListIteratorOfListIO It( selected );
426 for( ; It.More(); It.Next() )
428 Handle(SALOME_InteractiveObject) anIObject = It.Value();
429 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
430 if ( aMeshItem->_is_nil() ) {
431 SUIT_MessageBox::warning( SMESHGUI::desktop(),
432 QObject::tr( "SMESH_WRN_WARNING" ),
433 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
437 QString aMeshName = anIObject->getName();
439 // check for name duplications
440 if ( !hasDuplicatedMeshNames )
441 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
442 if( aMeshName == (*aMeshIter).second ) {
443 hasDuplicatedMeshNames = true;
448 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
451 if( hasDuplicatedMeshNames && isMED ) {
452 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
453 QObject::tr("SMESH_WRN_WARNING"),
454 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
455 QObject::tr("SMESH_BUT_YES"),
456 QObject::tr("SMESH_BUT_NO"), 0, 1);
461 aMeshIter = aMeshList.begin();
462 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
463 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
464 QString aMeshName = (*aMeshIter).second;
466 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
468 // check for equal group names within each mesh
469 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
470 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
471 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
472 int aRet = SUIT_MessageBox::warning
473 (SMESHGUI::desktop(),
474 QObject::tr("SMESH_WRN_WARNING"),
475 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
476 QObject::tr("SMESH_BUT_YES"),
477 QObject::tr("SMESH_BUT_NO"), 0, 1);
484 // Warn the user about presence of not supported elements
486 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
490 notSupportedElemTypes.push_back( SMESH::Entity_0D );
491 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
496 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
497 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
498 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
499 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
500 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
501 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
502 notSupportedElemTypes.push_back( SMESH::Entity_0D );
503 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
508 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
509 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
510 notSupportedElemTypes.push_back( SMESH::Entity_0D );
511 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
516 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
517 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
522 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
523 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
524 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
525 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
526 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
527 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
528 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
533 notSupportedElemTypes.push_back( SMESH::Entity_0D );
534 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
535 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
536 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
537 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
538 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
539 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
540 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
541 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
543 if ( ! notSupportedElemTypes.empty() )
545 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
546 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
547 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
548 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
550 if ( !presentNotSupported.empty() )
553 const char* typeMsg[SMESH::Entity_Last] = {
554 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
555 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
556 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
557 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
558 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
559 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
560 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
561 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
563 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
564 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
565 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
566 if ( iType != presentNotSupported.size() - 1 )
567 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
569 int aRet = SUIT_MessageBox::warning
570 (SMESHGUI::desktop(),
571 QObject::tr("SMESH_WRN_WARNING"),
572 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
573 QObject::tr("SMESH_BUT_YES"),
574 QObject::tr("SMESH_BUT_NO"), 0, 1);
579 // Get parameters of export operation
582 SMESH::MED_VERSION aFormat;
583 // Init the parameters with the default values
584 bool aIsASCII_STL = true;
585 bool toCreateGroups = false;
586 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
588 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
589 bool toOverwrite = true;
590 bool toFindOutDim = true;
592 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
593 QString anInitialPath = "";
594 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
595 anInitialPath = QDir::currentPath();
597 // Get a file name to write in and additional otions
598 if ( isUNV || isDAT || isGMF ) // Export w/o options
601 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
603 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
605 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
606 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
607 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
608 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
609 anInitialPath + QString("/") + aMeshName,
610 aFilter, aTitle, false);
612 else if ( isCGNS )// Export to CGNS
614 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
615 fd->setWindowTitle( aTitle );
616 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
617 if ( !anInitialPath.isEmpty() )
618 fd->setDirectory( anInitialPath );
619 fd->selectFile(aMeshName);
620 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
621 fd->setValidator( fv );
624 aFilename = fd->selectedFile();
625 toOverwrite = fv->isOverwrite();
629 else if ( isSTL ) // Export to STL
631 QMap<QString, int> aFilterMap;
632 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
633 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
636 QMap<QString, int>::const_iterator it = aFilterMap.begin();
637 for ( ; it != aFilterMap.end(); ++it )
638 filters.push_back( it.key() );
640 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
641 fd->setWindowTitle( aTitle );
642 fd->setNameFilters( filters );
643 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
644 if ( !anInitialPath.isEmpty() )
645 fd->setDirectory( anInitialPath );
646 fd->selectFile(aMeshName);
650 aFilename = fd->selectedFile();
651 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
656 else if ( isMED || isSAUV ) // Export to MED or SAUV
658 QMap<QString, SMESH::MED_VERSION> aFilterMap;
659 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
661 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
662 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
663 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
666 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
667 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
668 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
672 QString aDefaultFilter;
673 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
674 for ( ; it != aFilterMap.end(); ++it ) {
675 filters.push_back( it.key() );
676 if (it.value() == SMESH::MED_V2_2)
677 aDefaultFilter = it.key();
679 QStringList checkBoxes;
680 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
682 SalomeApp_CheckFileDlg* fd =
683 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
684 fd->setWindowTitle( aTitle );
685 fd->setNameFilters( filters );
686 fd->selectNameFilter(aDefaultFilter);
687 fd->SetChecked(0,toCreateGroups);
688 fd->SetChecked(1,toFindOutDim);
689 if ( !anInitialPath.isEmpty() )
690 fd->setDirectory( anInitialPath );
691 fd->selectFile(aMeshName);
693 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
694 fd->setValidator( fv );
699 aFilename = fd->selectedFile();
701 aFilename = QString::null;
704 aFormat = aFilterMap[fd->selectedNameFilter()];
705 toOverwrite = fv->isOverwrite();
707 if ( !aFilename.isEmpty() ) {
708 // med-2.1 does not support poly elements
709 if ( aFormat==SMESH::MED_V2_1 )
710 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
711 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
712 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
713 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
714 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
716 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
717 QObject::tr("SMESH_WRN_WARNING"),
718 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
719 QObject::tr("SMESH_BUT_YES"),
720 QObject::tr("SMESH_BUT_NO"), 0, 1);
728 // can't append to an existing using other format
729 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
730 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
731 if( !isVersionOk || aVersion != aFormat ) {
732 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
733 QObject::tr("SMESH_WRN_WARNING"),
734 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
735 QObject::tr("SMESH_BUT_YES"),
736 QObject::tr("SMESH_BUT_NO"), 0, 1);
743 QStringList aMeshNamesCollisionList;
744 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
745 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
746 QString anExistingMeshName( aMeshNames[ i ] );
747 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
748 QString anExportMeshName = (*aMeshIter).second;
749 if( anExportMeshName == anExistingMeshName ) {
750 aMeshNamesCollisionList.append( anExportMeshName );
755 if( !aMeshNamesCollisionList.isEmpty() ) {
756 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
757 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
758 QObject::tr("SMESH_WRN_WARNING"),
759 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
760 QObject::tr("SMESH_BUT_YES"),
761 QObject::tr("SMESH_BUT_NO"),
762 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
771 toCreateGroups = fd->IsChecked(0);
772 toFindOutDim = fd->IsChecked(1);
782 if ( !aFilename.isEmpty() ) {
783 // Check whether the file already exists and delete it if yes
784 QFile aFile( aFilename );
785 if ( aFile.exists() && toOverwrite )
787 SUIT_OverrideCursor wc;
790 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
791 // bool Renumber = false;
792 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
794 // Renumber= resMgr->booleanValue("renumbering");
796 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
797 // aMeshEditor->RenumberNodes();
798 // aMeshEditor->RenumberElements();
799 // if ( SMESHGUI::automaticUpdate() )
800 // SMESH::UpdateView();
804 aMeshIter = aMeshList.begin();
805 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
807 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
808 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
809 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
810 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
811 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
813 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
814 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
819 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
821 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
822 if( !aMeshItem->_is_nil() )
823 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
828 if ( aMeshOrGroup->_is_equivalent( aMesh ))
829 aMesh->ExportDAT( aFilename.toUtf8().data() );
831 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
835 if ( aMeshOrGroup->_is_equivalent( aMesh ))
836 aMesh->ExportUNV( aFilename.toUtf8().data() );
838 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
842 if ( aMeshOrGroup->_is_equivalent( aMesh ))
843 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
845 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
849 aMeshIter = aMeshList.begin();
850 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
852 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
853 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
854 aMeshItem->ExportCGNS( aMeshOrGroup,
855 aFilename.toUtf8().data(),
856 toOverwrite && aMeshIndex == 0 );
861 toCreateGroups = true;
862 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
865 catch (const SALOME::SALOME_Exception& S_ex){
867 SUIT_MessageBox::warning(SMESHGUI::desktop(),
868 QObject::tr("SMESH_WRN_WARNING"),
869 QObject::tr("SMESH_EXPORT_FAILED"));
875 inline void InverseEntityMode(unsigned int& theOutputMode,
876 unsigned int theMode)
878 bool anIsNotPresent = ~theOutputMode & theMode;
880 theOutputMode |= theMode;
882 theOutputMode &= ~theMode;
885 void SetDisplayEntity(int theCommandID){
886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
887 SALOME_ListIO selected;
889 aSel->selectedObjects( selected );
891 if(selected.Extent() >= 1){
892 SALOME_ListIteratorOfListIO It( selected );
893 for( ; It.More(); It.Next()){
894 Handle(SALOME_InteractiveObject) IObject = It.Value();
895 if(IObject->hasEntry()){
896 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
897 unsigned int aMode = anActor->GetEntityMode();
898 switch(theCommandID){
900 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
903 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
906 InverseEntityMode(aMode,SMESH_Actor::eEdges);
909 InverseEntityMode(aMode,SMESH_Actor::eFaces);
912 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
915 aMode = SMESH_Actor::eAllEntity;
919 anActor->SetEntityMode(aMode);
928 SALOME_ListIO selected;
929 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
933 LightApp_SelectionMgr* aSel = app->selectionMgr();
934 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
935 if( !aSel || !appStudy )
938 aSel->selectedObjects( selected );
939 if( selected.IsEmpty() )
942 Handle(SALOME_InteractiveObject) anIObject = selected.First();
944 _PTR(Study) aStudy = appStudy->studyDS();
945 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
946 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
947 if( aMainObject->_is_nil() )
950 SUIT_OverrideCursor wc;
952 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
954 QList<SALOMEDS::Color> aReservedColors;
956 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
957 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
959 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
960 //SALOMEDS::Color aColor = aGroupObject->GetColor();
962 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
963 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
964 #else // old algorithm for auto-colors
965 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
966 aReservedColors.append( aColor );
967 #endif // SIMPLE_AUTOCOLOR
968 aGroupObject->SetColor( aColor );
970 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
974 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
975 switch ( aGroupObject->GetType ()) {
977 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
979 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
981 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
983 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
985 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
986 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
989 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
990 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
996 SMESH::RepaintCurrentView();
999 void OverallMeshQuality() {
1000 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1001 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1002 SALOME_ListIO selected;
1004 aSel->selectedObjects( selected );
1006 if ( selected.IsEmpty() ) return;
1007 SALOME_ListIteratorOfListIO It( selected );
1008 for ( ; It.More(); It.Next() ) {
1009 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1010 ctrlDlg->showInfo( It.Value() );
1015 QString functorToString( SMESH::Controls::FunctorPtr f )
1017 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1018 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1019 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1020 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1021 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1022 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1023 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1024 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1025 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1026 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1027 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1028 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1029 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1030 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1031 type = QObject::tr( "WARP_ELEMENTS" );
1032 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1033 type = QObject::tr( "TAPER_ELEMENTS" );
1034 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1035 type = QObject::tr( "SKEW_ELEMENTS" );
1036 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1037 type = QObject::tr( "AREA_ELEMENTS" );
1038 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1039 type = QObject::tr( "LENGTH_EDGES" );
1040 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1041 type = QObject::tr( "LENGTH2D_EDGES" );
1042 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1043 type = QObject::tr( "MULTI_BORDERS" );
1044 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1045 type = QObject::tr( "MULTI2D_BORDERS" );
1046 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1047 type = QObject::tr( "FREE_NODES" );
1048 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1049 type = QObject::tr( "FREE_EDGES" );
1050 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1051 type = QObject::tr( "FREE_BORDERS" );
1052 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1053 type = QObject::tr( "FREE_FACES" );
1054 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1055 type = QObject::tr( "BARE_BORDER_VOLUME" );
1056 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1057 type = QObject::tr( "BARE_BORDER_FACE" );
1058 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1059 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1060 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1061 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1062 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1063 type = QObject::tr( "EQUAL_NODE" );
1064 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1065 type = QObject::tr( "EQUAL_EDGE" );
1066 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1067 type = QObject::tr( "EQUAL_FACE" );
1068 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1069 type = QObject::tr( "EQUAL_VOLUME" );
1073 void SaveDistribution()
1075 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1076 SALOME_ListIO selected;
1078 aSel->selectedObjects( selected );
1080 if ( selected.Extent() == 1 ) {
1081 Handle(SALOME_InteractiveObject) anIO = selected.First();
1082 if ( anIO->hasEntry() ) {
1083 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1084 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1085 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1086 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1087 if ( aScalarBarActor && aFunctor ) {
1088 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1090 std::vector<int> elements;
1091 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1092 if ( mesh->_is_nil() ) {
1093 SMESH::SMESH_IDSource_var idSource =
1094 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1095 if ( !idSource->_is_nil() )
1097 SMESH::long_array_var ids = idSource->GetIDs();
1098 elements.resize( ids->length() );
1099 for ( unsigned i = 0; i < elements.size(); ++i )
1100 elements[i] = ids[i];
1103 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1104 vtkLookupTable* lookupTable =
1105 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1106 double * minmax = lookupTable->GetRange();
1107 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1108 std::vector<int> nbEvents;
1109 std::vector<double> funValues;
1110 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
1111 QString anInitialPath = "";
1112 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1113 anInitialPath = QDir::currentPath();
1114 QString aMeshName = anIO->getName();
1116 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1117 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1118 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1119 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1120 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1123 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1125 if ( !aFilename.isEmpty() ) {
1126 QFile f( aFilename );
1127 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1128 QTextStream out( &f );
1129 out << "# Mesh: " << aMeshName << endl;
1130 out << "# Control: " << functorToString( aFunctor ) << endl;
1132 out.setFieldWidth( 10 );
1133 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1134 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1145 void ShowDistribution() {
1146 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1147 SALOME_ListIO selected;
1149 aSel->selectedObjects( selected );
1151 if ( selected.Extent() == 1 ) {
1152 Handle(SALOME_InteractiveObject) anIO = selected.First();
1153 if ( anIO->hasEntry() ) {
1154 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1155 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1156 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1157 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1163 #ifndef DISABLE_PLOT2DVIEWER
1164 void PlotDistribution() {
1165 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1169 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1170 SALOME_ListIO selected;
1172 aSel->selectedObjects( selected );
1174 if ( selected.Extent() == 1 ) {
1175 Handle(SALOME_InteractiveObject) anIO = selected.First();
1176 if ( anIO->hasEntry() ) {
1177 //Find Actor by entry before getting Plot2d viewer,
1178 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1179 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1181 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1186 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1190 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1194 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1195 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1196 QString functorName = functorToString( anActor->GetFunctor());
1197 QString aHistogramName("%1 : %2");
1198 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1199 aHistogram->setName(aHistogramName);
1200 aHistogram->setHorTitle(functorName);
1201 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1202 aPlot->displayObject(aHistogram, true);
1207 #endif //DISABLE_PLOT2DVIEWER
1209 void DisableAutoColor(){
1210 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1211 SALOME_ListIO selected;
1213 aSel->selectedObjects( selected );
1215 if(selected.Extent()){
1216 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1217 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1218 if ( !aMesh->_is_nil() ) {
1219 aMesh->SetAutoColor( false );
1224 void sortChildren(){
1225 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1226 SALOME_ListIO selected;
1228 aSel->selectedObjects( selected );
1230 if(selected.Extent()){
1231 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1232 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1233 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1235 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1236 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1243 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1245 SALOME_ListIO selected;
1246 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1250 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1251 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1252 if( !aSel || !appStudy )
1255 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1256 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1257 aModule->EmitSignalDeactivateDialog();
1258 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1259 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1264 _PTR(Study) aStudy = appStudy->studyDS();
1266 aSel->selectedObjects( selected );
1268 if(selected.Extent() >= 1){
1269 switch(theCommandID){
1271 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1272 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1277 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1278 QColor orientationColor, outlineColor, volumeColor;
1279 int deltaF = 0, deltaV = 0;
1283 int outlineWidth = 1;
1284 double shrinkCoef = 0.0;
1285 double orientationScale = 0.0;
1286 bool orientation3d = false;
1287 VTK::MarkerType markerType = VTK::MT_NONE;
1288 VTK::MarkerScale markerScale = VTK::MS_NONE;
1290 bool hasNodes = false;
1291 int presentEntities = 0;
1292 bool firstTime = true;
1294 SALOME_ListIteratorOfListIO It( selected );
1295 for ( ; It.More(); It.Next() ) {
1296 Handle(SALOME_InteractiveObject) IObject = It.Value();
1297 if ( !IObject->hasEntry() ) continue;
1298 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1299 if ( !anActor || !anActor->GetObject() ) continue;
1302 // nodes: color, marker
1303 anActor->GetNodeColor( color[0], color[1], color[2] );
1304 nodeColor.setRgbF( color[0], color[1], color[2] );
1305 markerType = anActor->GetMarkerType();
1306 markerScale = anActor->GetMarkerScale();
1307 markerId = anActor->GetMarkerTexture();
1308 // edges: color, width
1309 anActor->GetEdgeColor( color[0], color[1], color[2] );
1310 edgeColor.setRgbF( color[0], color[1], color[2] );
1311 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1312 // faces: front color, back color (delta)
1313 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1314 faceColor.setRgbF( color[0], color[1], color[2] );
1315 // faces: front color, back color (delta)
1316 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1317 volumeColor.setRgbF( color[0], color[1], color[2] );
1318 // 0d elements: color, size
1319 anActor->Get0DColor( color[0], color[1], color[2] );
1320 elem0dColor.setRgbF( color[0], color[1], color[2] );
1321 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1322 // balls: color, size
1323 anActor->GetBallColor( color[0], color[1], color[2] );
1324 ballColor.setRgbF( color[0], color[1], color[2] );
1325 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1327 anActor->GetOutlineColor( color[0], color[1], color[2] );
1328 outlineColor.setRgbF( color[0], color[1], color[2] );
1329 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1330 // orientation vectors: color, scale, 3d flag
1331 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1332 orientationColor.setRgbF( color[0], color[1], color[2] );
1333 orientationScale = anActor->GetFacesOrientationScale();
1334 orientation3d = anActor->GetFacesOrientation3DVectors();
1336 shrinkCoef = anActor->GetShrinkFactor();
1339 firstTime = false; // we only take properties from first object (for performance reasons)
1342 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1343 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1344 presentEntities = presentEntities | SMESH_Actor::eEdges;
1345 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1346 presentEntities = presentEntities | SMESH_Actor::eFaces;
1347 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1348 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1349 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1350 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1351 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1352 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1354 // as we know that all types of elements are present, we can exit the loop
1355 if ( presentEntities == SMESH_Actor::eAllEntity )
1359 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1360 // nodes: color, marker
1361 dlg.setNodeColor( nodeColor );
1362 if( markerType != VTK::MT_USER )
1363 dlg.setNodeMarker( markerType, markerScale );
1365 dlg.setNodeCustomMarker( markerId );
1366 // edges: color, line width
1367 dlg.setEdgeColor( edgeColor );
1368 dlg.setEdgeWidth( edgeWidth );
1369 // faces: front color, back color
1370 dlg.setFaceColor( faceColor, deltaF );
1371 // volumes: normal color, reversed color
1372 dlg.setVolumeColor( volumeColor, deltaV );
1373 // outlines: color, line width
1374 dlg.setOutlineColor( outlineColor );
1375 dlg.setOutlineWidth( outlineWidth );
1376 // 0d elements: color, size
1377 dlg.setElem0dColor( elem0dColor );
1378 dlg.setElem0dSize( elem0dSize );
1379 // balls: color, size
1380 dlg.setBallColor( ballColor );
1381 dlg.setBallSize( ballSize );
1382 // orientation: color, scale, 3d flag
1383 dlg.setOrientationColor( orientationColor );
1384 dlg.setOrientationSize( int( orientationScale * 100. ) );
1385 dlg.setOrientation3d( orientation3d );
1386 // shrink: scale factor
1387 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1388 // hide unused controls
1389 dlg.showControls( presentEntities, hasNodes );
1392 nodeColor = dlg.nodeColor();
1393 markerType = dlg.nodeMarkerType();
1394 markerScale = dlg.nodeMarkerScale();
1395 markerId = dlg.nodeMarkerId();
1396 edgeColor = dlg.edgeColor();
1397 edgeWidth = dlg.edgeWidth();
1398 faceColor = dlg.faceColor();
1399 deltaF = dlg.faceColorDelta();
1400 volumeColor = dlg.volumeColor();
1401 deltaV = dlg.volumeColorDelta();
1402 outlineColor = dlg.outlineColor();
1403 outlineWidth = dlg.outlineWidth();
1404 elem0dColor = dlg.elem0dColor();
1405 elem0dSize = dlg.elem0dSize();
1406 ballColor = dlg.ballColor();
1407 ballSize = dlg.ballSize();
1408 orientationColor = dlg.orientationColor();
1409 orientationScale = dlg.orientationSize() / 100.;
1410 orientation3d = dlg.orientation3d();
1411 shrinkCoef = dlg.shrinkCoef() / 100.;
1413 // store point markers map that might be changed by the user
1414 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1416 // set properties from dialog box to the presentations
1417 SALOME_ListIteratorOfListIO It( selected );
1418 for ( ; It.More(); It.Next() ) {
1419 Handle(SALOME_InteractiveObject) IObject = It.Value();
1420 if ( !IObject->hasEntry() ) continue;
1421 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1422 if ( !anActor ) continue;
1424 // nodes: color, marker
1425 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1426 if ( markerType != VTK::MT_USER ) {
1427 anActor->SetMarkerStd( markerType, markerScale );
1430 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1431 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1432 if ( iter != markerMap.end() )
1433 anActor->SetMarkerTexture( markerId, iter->second.second );
1435 // volumes: normal color, reversed color (delta)
1436 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1437 // faces: front color, back color (delta)
1438 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1439 // edges: color, width
1440 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1441 anActor->SetLineWidth( edgeWidth );
1443 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1444 anActor->SetOutlineWidth( outlineWidth );
1445 // 0D elements: color, size
1446 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1447 anActor->Set0DSize( elem0dSize );
1448 // balls: color, size
1449 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1450 anActor->SetBallSize( ballSize );
1451 // orientation: color, scale, 3d flag
1452 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1453 anActor->SetFacesOrientationScale( orientationScale );
1454 anActor->SetFacesOrientation3DVectors( orientation3d );
1456 anActor->SetShrinkFactor( shrinkCoef );
1458 // for groups, set also proper color
1459 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1460 if ( !aGroupObject->_is_nil() ) {
1461 SMESH::ElementType anElementType = aGroupObject->GetType();
1463 switch( anElementType ) {
1465 aColor = nodeColor; break;
1467 aColor = edgeColor; break;
1469 aColor = faceColor; break;
1471 aColor = volumeColor; break;
1473 aColor = elem0dColor; break;
1475 aColor = ballColor; break;
1479 if ( aColor.isValid() ) {
1480 SALOMEDS::Color aGroupColor;
1481 aGroupColor.R = aColor.redF();
1482 aGroupColor.G = aColor.greenF();
1483 aGroupColor.B = aColor.blueF();
1484 aGroupObject->SetColor( aGroupColor );
1486 } // if ( !aGroupObject->_is_nil() )
1487 } // for ( ; It.More(); It.Next() )
1488 SMESH::RepaintCurrentView();
1489 } // if ( dlg.exec() )
1492 } // switch(theCommandID)
1493 SALOME_ListIteratorOfListIO It( selected );
1494 for( ; It.More(); It.Next()){
1495 Handle(SALOME_InteractiveObject) IObject = It.Value();
1496 if(IObject->hasEntry()){
1497 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1498 switch(theCommandID){
1500 anActor->SetRepresentation(SMESH_Actor::eEdge);
1503 anActor->SetRepresentation(SMESH_Actor::eSurface);
1506 if(anActor->IsShrunk())
1507 anActor->UnShrink();
1509 anActor->SetShrink();
1512 anActor->SetRepresentation(SMESH_Actor::ePoint);
1515 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1516 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1519 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1520 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1526 SMESH::RepaintCurrentView();
1530 void Control( int theCommandID )
1532 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1533 SALOME_ListIO selected;
1535 aSel->selectedObjects( selected );
1537 if( !selected.IsEmpty() ){
1538 Handle(SALOME_InteractiveObject) anIO = selected.First();
1540 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1541 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1542 switch ( theCommandID ){
1544 aControl = SMESH_Actor::eLength;
1547 aControl = SMESH_Actor::eLength2D;
1550 aControl = SMESH_Actor::eFreeEdges;
1553 aControl = SMESH_Actor::eFreeBorders;
1556 aControl = SMESH_Actor::eMultiConnection;
1559 aControl = SMESH_Actor::eFreeNodes;
1562 aControl = SMESH_Actor::eMultiConnection2D;
1565 aControl = SMESH_Actor::eArea;
1568 aControl = SMESH_Actor::eTaper;
1571 aControl = SMESH_Actor::eAspectRatio;
1574 aControl = SMESH_Actor::eAspectRatio3D;
1577 aControl = SMESH_Actor::eMinimumAngle;
1580 aControl = SMESH_Actor::eWarping;
1583 aControl = SMESH_Actor::eSkew;
1586 aControl = SMESH_Actor::eVolume3D;
1589 aControl = SMESH_Actor::eFreeFaces;
1592 aControl = SMESH_Actor::eMaxElementLength2D;
1595 aControl = SMESH_Actor::eMaxElementLength3D;
1598 aControl = SMESH_Actor::eBareBorderVolume;
1601 aControl = SMESH_Actor::eBareBorderFace;
1604 aControl = SMESH_Actor::eOverConstrainedVolume;
1607 aControl = SMESH_Actor::eOverConstrainedFace;
1610 aControl = SMESH_Actor::eCoincidentNodes;
1613 aControl = SMESH_Actor::eCoincidentElems1D;
1616 aControl = SMESH_Actor:: eCoincidentElems2D;
1619 aControl = SMESH_Actor::eCoincidentElems3D;
1623 anActor->SetControlMode(aControl);
1624 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1625 SMESH::RepaintCurrentView();
1626 #ifndef DISABLE_PLOT2DVIEWER
1627 if(anActor->GetPlot2Histogram()) {
1628 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1629 QString functorName = functorToString( anActor->GetFunctor());
1630 QString aHistogramName("%1 : %2");
1631 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1632 aHistogram->setName(aHistogramName);
1633 aHistogram->setHorTitle(functorName);
1634 SMESH::ProcessIn2DViewers(anActor);
1643 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1644 SMESH::MeshObjectType theType,
1645 const QString theInTypeName,
1646 QString & theOutTypeName)
1648 SMESH_TypeFilter aTypeFilter( theType );
1650 if( !theIO.IsNull() )
1652 entry = theIO->getEntry();
1653 LightApp_DataOwner owner( entry );
1654 if ( aTypeFilter.isOk( &owner )) {
1655 theOutTypeName = theInTypeName;
1663 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1665 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1666 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1668 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1669 CORBA::String_var anID = aSComp->GetID().c_str();
1670 if (!strcmp(anID.in(),theIO->getEntry()))
1676 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1677 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1678 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1679 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1680 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1688 QString CheckHomogeneousSelection()
1690 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1691 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1692 SALOME_ListIO selected;
1694 aSel->selectedObjects( selected );
1696 QString RefType = CheckTypeObject(selected.First());
1697 SALOME_ListIteratorOfListIO It(selected);
1698 for ( ; It.More(); It.Next())
1700 Handle(SALOME_InteractiveObject) IObject = It.Value();
1701 QString Type = CheckTypeObject(IObject);
1702 if (Type.compare(RefType) != 0)
1703 return "Heterogeneous Selection";
1710 void SMESHGUI::OnEditDelete()
1712 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1713 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1714 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1716 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1717 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1718 _PTR(GenericAttribute) anAttr;
1719 _PTR(AttributeIOR) anIOR;
1721 int objectCount = 0;
1723 QString aParentComponent = QString::null;
1724 Handle(SALOME_InteractiveObject) anIO;
1725 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1727 anIO = anIt.Value();
1728 QString cur = anIO->getComponentDataType();
1729 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1731 // check if object is reference
1732 _PTR(SObject) aRefSObj;
1733 aNameList.append("\n - ");
1734 if ( aSO->ReferencedObject( aRefSObj ) ) {
1735 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1736 aNameList.append( aRefName );
1737 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1740 aNameList.append(anIO->getName());
1744 if( aParentComponent.isNull() )
1745 aParentComponent = cur;
1746 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1747 aParentComponent = "";
1750 if ( objectCount == 0 )
1751 return; // No Valid Objects Selected
1753 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1754 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1755 QObject::tr("ERR_ERROR"),
1756 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1759 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1760 if (SUIT_MessageBox::warning
1761 (SMESHGUI::desktop(),
1762 QObject::tr("SMESH_WRN_WARNING"),
1763 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1764 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1765 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1768 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1770 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1771 // then treat them all starting from the deepest objects (at list back)
1772 std::list< _PTR(SObject) > listSO;
1773 SALOME_ListIteratorOfListIO It(selected);
1774 for( ; It.More(); It.Next()) // loop on selected IO's
1776 Handle(SALOME_InteractiveObject) IObject = It.Value();
1777 if(IObject->hasEntry()) {
1778 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1780 // disable removal of "SMESH" component object
1781 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1783 if ( engineIOR() == anIOR->Value().c_str() )
1786 //Check the referenced object
1787 _PTR(SObject) aRefSObject;
1788 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1789 aSO = aRefSObject; // Delete main Object instead of reference
1791 listSO.push_back( aSO );
1792 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1793 for ( ; itSO != listSO.end(); ++itSO ) {
1794 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1795 for (it->InitEx(false); it->More(); it->Next())
1796 listSO.push_back( it->Value() );
1800 // Check if none of objects to delete is referred from outside
1801 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1802 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1804 _PTR(SObject) SO = *ritSO;
1805 if ( !SO ) continue;
1806 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1807 for (size_t i = 0; i < aReferences.size(); i++) {
1808 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1809 std::string type = aComponent->ComponentDataType();
1810 if ( type != "SMESH" )
1812 SUIT_MessageBox::warning( anApp->desktop(),
1813 QObject::tr("WRN_WARNING"),
1814 QObject::tr("DEP_OBJECT") );
1815 return; // outside SMESH, there is an object depending on a SMESH object
1820 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1821 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1823 Handle(SALOME_InteractiveObject) IObject = It.Value();
1824 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1825 if ( !mesh->_is_nil() )
1829 // Treat SO's in the list starting from the back
1830 aStudyBuilder->NewCommand(); // There is a transaction
1831 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1833 _PTR(SObject) SO = *ritSO;
1834 if ( !SO ) continue;
1835 std::string anEntry = SO->GetID();
1837 /** Erase graphical object and remove all its data **/
1838 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1839 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1841 /** Remove an object from data structures **/
1842 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1843 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1844 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1845 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1846 aMesh->RemoveGroup( aGroup );
1848 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1849 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1850 aMesh->RemoveSubMesh( aSubMesh );
1852 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1854 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1857 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1858 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1859 QString objType = CheckTypeObject(IObject);
1860 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1861 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1862 aStudyBuilder->RemoveObjectWithChildren( SO );
1864 else {// default action: remove SObject from the study
1865 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1866 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1868 aStudyBuilder->RemoveObjectWithChildren( SO );
1872 } /* listSO back loop */
1874 aStudyBuilder->CommitCommand();
1876 /* Clear any previous selection */
1878 aSel->setSelectedObjects( l1 );
1880 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1885 SMESHGUI_EXPORT CAM_Module* createModule()
1887 return new SMESHGUI();
1890 SMESHGUI_EXPORT char* getModuleVersion() {
1891 return (char*)SMESH_VERSION_STR;
1895 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1897 //=============================================================================
1901 //=============================================================================
1902 SMESHGUI::SMESHGUI() :
1903 SalomeApp_Module( "SMESH" )
1905 if ( CORBA::is_nil( myComponentSMESH ) )
1907 CORBA::Boolean anIsEmbeddedMode;
1908 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1909 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1911 // 0019923: EDF 765 SMESH : default values of hypothesis
1912 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1913 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1914 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1915 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1916 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1918 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1919 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1920 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1922 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1923 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1927 myActiveDialogBox = 0;
1928 myFilterLibraryDlg = 0;
1932 myEventCallbackCommand = vtkCallbackCommand::New();
1933 myEventCallbackCommand->Delete();
1934 myEventCallbackCommand->SetClientData( this );
1935 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1938 /* load resources for all available meshers */
1939 SMESH::InitAvailableHypotheses();
1942 //=============================================================================
1946 //=============================================================================
1947 SMESHGUI::~SMESHGUI()
1951 //=============================================================================
1955 //=============================================================================
1956 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1958 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1960 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1965 //=============================================================================
1969 //=============================================================================
1970 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1972 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1976 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1977 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1978 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1979 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1980 return autoUpdate && !exceeded;
1983 //=============================================================================
1987 //=============================================================================
1988 bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh,
1989 int* entities, bool* limitExceeded, int* hidden )
1991 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1995 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1996 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1997 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
1999 long requestedSize = theMesh->NbElements();
2001 *entities = SMESH_Actor::eAllEntity;
2004 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2006 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2008 if ( incrementalLimit ) {
2009 long nbOdElems = theMesh->Nb0DElements();
2010 long nbEdges = theMesh->NbEdges();
2011 long nbFaces = theMesh->NbFaces();
2012 long nbVolumes = theMesh->NbVolumes();
2013 long nbBalls = theMesh->NbBalls();
2016 if ( nbOdElems > 0 ) {
2017 if ( total + nbOdElems > updateLimit ) {
2018 *entities = *entities & ~SMESH_Actor::e0DElements;
2019 *hidden = *hidden | SMESH_Actor::e0DElements;
2026 if ( nbEdges > 0 ) {
2027 if ( total + nbEdges > updateLimit ) {
2028 *entities = *entities & ~SMESH_Actor::eEdges;
2029 *hidden = *hidden | SMESH_Actor::eEdges;
2036 if ( nbFaces > 0 ) {
2037 if ( total + nbFaces > updateLimit ) {
2038 *entities = *entities & ~SMESH_Actor::eFaces;
2039 *hidden = *hidden | SMESH_Actor::eFaces;
2046 if ( nbVolumes > 0 ) {
2047 if ( total + nbVolumes > updateLimit ) {
2048 *entities = *entities & ~SMESH_Actor::eVolumes;
2049 *hidden = *hidden | SMESH_Actor::eVolumes;
2056 if ( nbBalls > 0 ) {
2057 if ( total + nbBalls > updateLimit ) {
2058 *entities = *entities & ~SMESH_Actor::eBallElem;
2059 *hidden = *hidden | SMESH_Actor::eBallElem;
2067 return autoUpdate && !exceeded;
2070 //=============================================================================
2074 //=============================================================================
2075 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2077 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2080 //=============================================================================
2084 //=============================================================================
2085 SMESHGUI* SMESHGUI::GetSMESHGUI()
2087 SMESHGUI* smeshMod = 0;
2088 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2091 CAM_Module* module = app->module( "Mesh" );
2092 smeshMod = dynamic_cast<SMESHGUI*>( module );
2095 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2097 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2100 _PTR(Study) aStudy = study->studyDS();
2102 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2111 Standard_EXPORT SMESHGUI* GetComponentGUI()
2113 return SMESHGUI::GetSMESHGUI();
2117 //=============================================================================
2121 //=============================================================================
2122 void SMESHGUI::SetState(int aState)
2127 //=============================================================================
2131 //=============================================================================
2132 void SMESHGUI::ResetState()
2137 //=============================================================================
2141 //=============================================================================
2142 void SMESHGUI::EmitSignalDeactivateDialog()
2144 emit SignalDeactivateActiveDialog();
2147 //=============================================================================
2151 //=============================================================================
2152 void SMESHGUI::EmitSignalStudyFrameChanged()
2154 emit SignalStudyFrameChanged();
2157 //=============================================================================
2161 //=============================================================================
2162 void SMESHGUI::EmitSignalCloseAllDialogs()
2164 emit SignalCloseAllDialogs();
2167 //=============================================================================
2171 //=============================================================================
2172 void SMESHGUI::EmitSignalVisibilityChanged()
2174 emit SignalVisibilityChanged();
2177 //=============================================================================
2181 //=============================================================================
2182 QDialog *SMESHGUI::GetActiveDialogBox()
2184 return myActiveDialogBox;
2187 //=============================================================================
2191 //=============================================================================
2192 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2194 myActiveDialogBox = (QDialog *) aDlg;
2198 //=============================================================================
2202 //=============================================================================
2203 SUIT_Desktop* SMESHGUI::desktop()
2205 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2207 return app->desktop();
2212 //=============================================================================
2216 //=============================================================================
2217 SalomeApp_Study* SMESHGUI::activeStudy()
2219 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2221 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2226 //=============================================================================
2230 //=============================================================================
2231 void SMESHGUI::Modified( bool theIsUpdateActions )
2233 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2234 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2235 appStudy->Modified();
2236 if( theIsUpdateActions )
2237 app->updateActions();
2242 //=============================================================================
2246 //=============================================================================
2247 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2249 /* Here the position is on the bottom right corner - 10 */
2250 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2252 SUIT_Desktop *PP = desktop();
2253 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2254 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2258 //=============================================================================
2262 //=============================================================================
2263 static int isStudyLocked(_PTR(Study) theStudy){
2264 return theStudy->GetProperties()->IsLocked();
2267 static bool checkLock(_PTR(Study) theStudy) {
2268 if (isStudyLocked(theStudy)) {
2269 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2270 QObject::tr("WRN_WARNING"),
2271 QObject::tr("WRN_STUDY_LOCKED") );
2277 //=======================================================================
2278 //function : CheckActiveStudyLocked
2280 //=======================================================================
2282 bool SMESHGUI::isActiveStudyLocked()
2284 _PTR(Study) aStudy = activeStudy()->studyDS();
2285 return checkLock( aStudy );
2288 //=============================================================================
2292 //=============================================================================
2293 bool SMESHGUI::OnGUIEvent( int theCommandID )
2295 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2299 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2300 SUIT_ResourceMgr* mgr = resourceMgr();
2304 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2305 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2308 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2309 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2311 //QAction* act = action( theCommandID );
2313 switch (theCommandID) {
2315 if(checkLock(aStudy)) break;
2327 if(checkLock(aStudy)) break;
2328 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2332 case 150: //MED FILE INFORMATION
2334 SALOME_ListIO selected;
2335 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2337 aSel->selectedObjects( selected );
2338 if( selected.Extent() )
2340 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2341 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2342 if ( !aMesh->_is_nil() )
2344 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2351 case 122: // EXPORT MED
2366 ::ExportMeshToFile(theCommandID);
2370 case 200: // SCALAR BAR
2372 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2373 SALOME_ListIO selected;
2375 aSel->selectedObjects( selected );
2377 if( selected.Extent() ) {
2378 Handle(SALOME_InteractiveObject) anIO = selected.First();
2379 if( anIO->hasEntry() ) {
2380 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2381 anActor->SetControlMode( SMESH_Actor::eNone );
2382 #ifndef DISABLE_PLOT2DVIEWER
2383 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2392 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2397 // dump control distribution data to the text file
2398 ::SaveDistribution();
2404 // show/ distribution
2405 ::ShowDistribution();
2409 #ifndef DISABLE_PLOT2DVIEWER
2412 // plot distribution
2413 ::PlotDistribution();
2424 ::DisableAutoColor();
2427 case 1134: // Clipping
2428 case 1133: // Tranparency
2429 case 1132: // Display preferences (colors, shrink size, line width, ...)
2436 ::SetDisplayMode(theCommandID, myMarkerMap);
2439 //2D quadratic representation
2442 ::SetDisplayMode(theCommandID, myMarkerMap);
2446 case 216: // 0D elements
2449 case 219: // Volumes
2450 case 220: // All Entity
2452 ::SetDisplayEntity(theCommandID);
2455 case 221: // Orientation of faces
2457 LightApp_SelectionMgr* mgr = selectionMgr();
2458 SALOME_ListIO selected; mgr->selectedObjects( selected );
2460 SALOME_ListIteratorOfListIO it(selected);
2461 for( ; it.More(); it.Next()) {
2462 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2463 if(anIObject->hasEntry()) {
2464 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2465 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2474 if(checkLock(aStudy)) break;
2475 SUIT_OverrideCursor wc;
2477 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2480 SMESH::UpdateView();
2482 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2483 SMESH::OnVisuException();
2485 catch (...) { // PAL16774 (Crash after display of many groups)
2486 SMESH::OnVisuException();
2490 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2491 aSel->selectedObjects( l );
2492 aSel->setSelectedObjects( l );
2497 case 301: // DISPLAY
2498 case 302: // DISPLAY ONLY
2500 SMESH::EDisplaing anAction;
2501 switch (theCommandID) {
2502 case 300: anAction = SMESH::eErase; break;
2503 case 301: anAction = SMESH::eDisplay; break;
2504 case 302: anAction = SMESH::eDisplayOnly; break;
2507 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2508 SALOME_ListIO sel_objects, to_process;
2510 aSel->selectedObjects( sel_objects );
2512 if( theCommandID==302 )
2514 MESSAGE("anAction = SMESH::eDisplayOnly");
2515 startOperation( myEraseAll );
2518 extractContainers( sel_objects, to_process );
2521 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2525 SALOME_ListIteratorOfListIO It( to_process );
2526 for ( ; It.More(); It.Next()) {
2528 Handle(SALOME_InteractiveObject) IOS = It.Value();
2529 if (IOS->hasEntry()) {
2531 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2532 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2533 break; // PAL16774 (Crash after display of many groups)
2535 if (anAction == SMESH::eDisplayOnly)
2537 MESSAGE("anAction = SMESH::eDisplayOnly");
2538 anAction = SMESH::eDisplay;
2544 // PAL13338 + PAL15161 -->
2545 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2546 MESSAGE("anAction = SMESH::eDisplayOnly");
2547 SMESH::UpdateView();
2548 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2550 // PAL13338 + PAL15161 <--
2552 catch (...) { // PAL16774 (Crash after display of many groups)
2553 SMESH::OnVisuException();
2556 if (anAction == SMESH::eErase) {
2557 MESSAGE("anAction == SMESH::eErase");
2559 aSel->setSelectedObjects( l1 );
2562 aSel->setSelectedObjects( to_process );
2569 if(checkLock(aStudy)) break;
2572 EmitSignalDeactivateDialog();
2574 ( new SMESHGUI_NodesDlg( this ) )->show();
2577 SUIT_MessageBox::warning(desktop(),
2578 tr("SMESH_WRN_WARNING"),
2579 tr("SMESH_WRN_VIEWER_VTK"));
2584 case 2151: // FILTER
2588 EmitSignalDeactivateDialog();
2589 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2594 case 701: // COMPUTE MESH
2595 case 711: // PRECOMPUTE MESH
2596 case 712: // EVALUATE MESH
2597 case 713: // MESH ORDER
2598 case 702: // Create mesh
2599 case 703: // Create sub-mesh
2600 case 704: // Edit mesh/sub-mesh
2601 startOperation( theCommandID );
2603 case 705: // copy mesh
2605 if (checkLock(aStudy)) break;
2606 EmitSignalDeactivateDialog();
2607 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2610 case 710: // Build compound mesh
2612 if (checkLock(aStudy)) break;
2613 EmitSignalDeactivateDialog();
2614 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2618 case 407: // DIAGONAL INVERSION
2619 case 408: // Delete diagonal
2623 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2624 tr( "NOT_A_VTK_VIEWER" ) );
2628 if ( checkLock( aStudy ) )
2631 /*Standard_Boolean aRes;
2632 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2633 if ( aMesh->_is_nil() )
2635 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2636 tr( "SMESH_BAD_SELECTION" ) );
2640 EmitSignalDeactivateDialog();
2641 if ( theCommandID == 407 )
2642 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2644 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2647 case 409: // Change orientation
2648 case 410: // Union of triangles
2649 case 411: // Cutting of quadrangles
2650 case 419: // Splitting volumes into tetrahedra
2654 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2655 tr( "NOT_A_VTK_VIEWER" ) );
2659 if ( checkLock( aStudy ) )
2662 EmitSignalDeactivateDialog();
2663 SMESHGUI_MultiEditDlg* aDlg = NULL;
2664 if ( theCommandID == 409 )
2665 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2666 else if ( theCommandID == 410 )
2667 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2668 else if ( theCommandID == 419 )
2669 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2671 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2676 case 412: // Smoothing
2678 if(checkLock(aStudy)) break;
2680 EmitSignalDeactivateDialog();
2681 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2684 SUIT_MessageBox::warning(desktop(),
2685 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2689 case 413: // Extrusion
2691 if (checkLock(aStudy)) break;
2693 EmitSignalDeactivateDialog();
2694 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2696 SUIT_MessageBox::warning(desktop(),
2697 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2701 case 414: // Revolution
2703 if(checkLock(aStudy)) break;
2705 EmitSignalDeactivateDialog();
2706 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2709 SUIT_MessageBox::warning(desktop(),
2710 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2714 case 415: // Pattern mapping
2716 if ( checkLock( aStudy ) )
2720 EmitSignalDeactivateDialog();
2721 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2724 SUIT_MessageBox::warning(desktop(),
2725 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2729 case 416: // Extrusion along a path
2731 if (checkLock(aStudy)) break;
2733 EmitSignalDeactivateDialog();
2734 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2736 SUIT_MessageBox::warning(desktop(),
2737 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2741 case 417: // Convert mesh to quadratic
2742 case 418: // create 2D mesh from 3D
2743 case 420: // Reorient faces
2744 case 806: // CREATE GEO GROUP
2746 startOperation( theCommandID );
2749 case 801: // CREATE GROUP
2753 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2754 tr( "NOT_A_VTK_VIEWER" ) );
2758 if(checkLock(aStudy)) break;
2759 EmitSignalDeactivateDialog();
2760 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2762 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2763 SALOME_ListIO selected;
2765 aSel->selectedObjects( selected );
2767 int nbSel = selected.Extent();
2769 // check if mesh is selected
2770 aMesh = SMESH::GetMeshByIO( selected.First() );
2772 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2777 case 802: // CONSTRUCT GROUP
2781 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2782 tr( "NOT_A_VTK_VIEWER" ) );
2786 if(checkLock(aStudy)) break;
2787 EmitSignalDeactivateDialog();
2789 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2790 SALOME_ListIO selected;
2792 aSel->selectedObjects( selected );
2794 int nbSel = selected.Extent();
2796 // check if submesh is selected
2797 Handle(SALOME_InteractiveObject) IObject = selected.First();
2798 if (IObject->hasEntry()) {
2799 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2801 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2802 if (!aSubMesh->_is_nil()) {
2804 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2805 // get submesh elements list by types
2806 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2807 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2808 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2809 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2810 // create group for each type o elements
2811 QString aName = IObject->getName();
2812 QStringList anEntryList;
2813 if (aNodes->length() > 0) {
2814 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2815 aGroup->Add(aNodes.inout());
2816 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2817 anEntryList.append( aSObject->GetID().c_str() );
2819 if (aEdges->length() > 0) {
2820 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2821 aGroup->Add(aEdges.inout());
2822 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2823 anEntryList.append( aSObject->GetID().c_str() );
2825 if (aFaces->length() > 0) {
2826 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2827 aGroup->Add(aFaces.inout());
2828 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2829 anEntryList.append( aSObject->GetID().c_str() );
2831 if (aVolumes->length() > 0) {
2832 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2833 aGroup->Add(aVolumes.inout());
2834 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2835 anEntryList.append( aSObject->GetID().c_str() );
2838 anApp->browseObjects( anEntryList );
2840 catch(const SALOME::SALOME_Exception & S_ex){
2841 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2848 SUIT_MessageBox::warning(desktop(),
2849 tr("SMESH_WRN_WARNING"),
2850 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2855 case 803: // EDIT GROUP
2859 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2860 tr( "NOT_A_VTK_VIEWER" ) );
2864 if(checkLock(aStudy)) break;
2865 EmitSignalDeactivateDialog();
2867 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2868 SALOME_ListIO selected;
2870 aSel->selectedObjects( selected );
2872 SALOME_ListIteratorOfListIO It (selected);
2873 int nbSelectedGroups = 0;
2874 for ( ; It.More(); It.Next() )
2876 SMESH::SMESH_GroupBase_var aGroup =
2877 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2878 if (!aGroup->_is_nil()) {
2880 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2884 if (nbSelectedGroups == 0)
2886 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2892 case 804: // Add elements to group
2894 if(checkLock(aStudy)) break;
2895 if (myState == 800) {
2896 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2897 if (aDlg) aDlg->onAdd();
2902 case 805: // Remove elements from group
2904 if(checkLock(aStudy)) break;
2905 if (myState == 800) {
2906 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2907 if (aDlg) aDlg->onRemove();
2912 case 815: // Edit GEOM GROUP as standalone
2916 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2917 tr( "NOT_A_VTK_VIEWER" ) );
2921 if(checkLock(aStudy)) break;
2922 EmitSignalDeactivateDialog();
2924 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2925 SALOME_ListIO selected;
2927 aSel->selectedObjects( selected );
2929 SALOME_ListIteratorOfListIO It (selected);
2930 for ( ; It.More(); It.Next() )
2932 SMESH::SMESH_GroupOnGeom_var aGroup =
2933 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2934 if (!aGroup->_is_nil()) {
2935 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2940 SMESH::SMESH_GroupOnFilter_var aGroup =
2941 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2942 if (!aGroup->_is_nil()) {
2943 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2951 case 810: // Union Groups
2952 case 811: // Intersect groups
2953 case 812: // Cut groups
2957 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2958 tr( "NOT_A_VTK_VIEWER" ) );
2962 if ( checkLock( aStudy ) )
2965 EmitSignalDeactivateDialog();
2967 SMESHGUI_GroupOpDlg* aDlg = 0;
2968 if ( theCommandID == 810 )
2969 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2970 else if ( theCommandID == 811 )
2971 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2973 aDlg = new SMESHGUI_CutGroupsDlg( this );
2980 case 814: // Create groups of entities from existing groups of superior dimensions
2982 if ( checkLock( aStudy ) )
2985 EmitSignalDeactivateDialog();
2986 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2992 case 813: // Delete groups with their contents
2996 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2997 tr( "NOT_A_VTK_VIEWER" ) );
3001 if ( checkLock( aStudy ) )
3004 EmitSignalDeactivateDialog();
3006 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3010 case 900: // MESH INFOS
3011 case 903: // WHAT IS
3013 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3014 EmitSignalDeactivateDialog();
3015 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3016 SALOME_ListIO selected;
3018 aSel->selectedObjects( selected );
3020 if ( selected.Extent() > 1 ) { // a dlg for each IO
3021 SALOME_ListIteratorOfListIO It( selected );
3022 for ( ; It.More(); It.Next() ) {
3023 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3024 dlg->showInfo( It.Value() );
3029 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3035 case 904: // FIND ELEM
3037 startOperation( theCommandID );
3041 case 1100: // EDIT HYPOTHESIS
3043 if(checkLock(aStudy)) break;
3045 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3046 SALOME_ListIO selected;
3048 aSel->selectedObjects( selected );
3050 int nbSel = selected.Extent();
3053 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3054 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3056 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
3057 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
3058 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
3059 if ( !aHypothesis->_is_nil() )
3062 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3063 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
3065 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3075 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
3077 if(checkLock(aStudy)) break;
3078 SUIT_OverrideCursor wc;
3080 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3081 SALOME_ListIO selected;
3083 aSel->selectedObjects( selected, QString::null, false );
3085 SALOME_ListIteratorOfListIO It(selected);
3086 for (int i = 0; It.More(); It.Next(), i++) {
3087 Handle(SALOME_InteractiveObject) IObject = It.Value();
3088 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3091 aSel->setSelectedObjects( l1 );
3097 case 4009: // ELEM0D
3099 case 4021: // TRIANGLE
3101 case 4023: // POLYGON
3105 case 4134: // PYRAMID
3106 case 4135: // OCTA12
3108 if(checkLock(aStudy)) break;
3110 EmitSignalDeactivateDialog();
3111 SMDSAbs_EntityType type = SMDSEntity_Edge;
3112 switch (theCommandID) {
3113 case 4008: type = SMDSEntity_Ball; break;
3114 case 4009: type = SMDSEntity_0D; break;
3115 case 4021: type = SMDSEntity_Triangle; break;
3116 case 4022: type = SMDSEntity_Quadrangle; break;
3117 case 4031: type = SMDSEntity_Tetra; break;
3118 case 4023: type = SMDSEntity_Polygon; break;
3119 case 4032: type = SMDSEntity_Hexa; break;
3120 case 4133: type = SMDSEntity_Penta; break;
3121 case 4134: type = SMDSEntity_Pyramid; break;
3122 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
3125 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3128 SUIT_MessageBox::warning(desktop(),
3129 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3133 case 4033: // POLYHEDRON
3135 if(checkLock(aStudy)) break;
3137 EmitSignalDeactivateDialog();
3138 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3141 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3146 case 4034: // QUADRATIC EDGE
3147 case 4035: // QUADRATIC TRIANGLE
3148 case 4036: // QUADRATIC QUADRANGLE
3149 case 4136: // BIQUADRATIC QUADRANGLE
3150 case 4137: // BIQUADRATIC TRIANGLE
3151 case 4037: // QUADRATIC TETRAHEDRON
3152 case 4038: // QUADRATIC PYRAMID
3153 case 4039: // QUADRATIC PENTAHEDRON
3154 case 4040: // QUADRATIC HEXAHEDRON
3155 case 4140: // TRIQUADRATIC HEXAHEDRON
3157 if(checkLock(aStudy)) break;
3159 EmitSignalDeactivateDialog();
3160 SMDSAbs_EntityType type = SMDSEntity_Last;
3162 switch (theCommandID) {
3163 case 4034: type = SMDSEntity_Quad_Edge; break;
3164 case 4035: type = SMDSEntity_Quad_Triangle; break;
3165 case 4036: type = SMDSEntity_Quad_Quadrangle; break;
3166 case 4136: type = SMDSEntity_BiQuad_Quadrangle; break;
3167 case 4137: type = SMDSEntity_BiQuad_Triangle; break;
3168 case 4037: type = SMDSEntity_Quad_Tetra; break;
3169 case 4038: type = SMDSEntity_Quad_Pyramid; break;
3170 case 4039: type = SMDSEntity_Quad_Penta; break;
3171 case 4040: type = SMDSEntity_Quad_Hexa; break;
3172 case 4140: type = SMDSEntity_TriQuad_Hexa; break;
3175 if ( type != SMDSEntity_Last )
3176 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3179 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3180 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3184 case 4041: // REMOVES NODES
3186 if(checkLock(aStudy)) break;
3188 EmitSignalDeactivateDialog();
3189 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3192 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3193 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3197 case 4042: // REMOVES ELEMENTS
3199 if(checkLock(aStudy)) break;
3201 EmitSignalDeactivateDialog();
3202 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3206 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3207 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3211 case 4043: { // CLEAR_MESH
3213 if(checkLock(aStudy)) break;
3215 SALOME_ListIO selected;
3216 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3217 aSel->selectedObjects( selected );
3219 SUIT_OverrideCursor wc;
3220 SALOME_ListIteratorOfListIO It (selected);
3221 for ( ; It.More(); It.Next() )
3223 Handle(SALOME_InteractiveObject) IOS = It.Value();
3224 SMESH::SMESH_Mesh_var aMesh =
3225 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3226 if ( aMesh->_is_nil()) continue;
3228 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3230 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3231 SMESH::ModifiedMesh( aMeshSObj, false, true);
3232 // hide groups and submeshes
3233 _PTR(ChildIterator) anIter =
3234 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3235 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3237 _PTR(SObject) so = anIter->Value();
3238 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3241 catch (const SALOME::SALOME_Exception& S_ex){
3243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3247 SMESH::UpdateView();
3251 case 4044: // REMOVE ORPHAN NODES
3253 if(checkLock(aStudy)) break;
3254 SALOME_ListIO selected;
3255 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3256 aSel->selectedObjects( selected );
3257 if ( selected.Extent() == 1 ) {
3258 Handle(SALOME_InteractiveObject) anIO = selected.First();
3259 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3260 if ( !aMesh->_is_nil() ) {
3261 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3262 tr( "SMESH_WARNING" ),
3263 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3264 SUIT_MessageBox::Yes |
3265 SUIT_MessageBox::No,
3266 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3269 SUIT_OverrideCursor wc;
3270 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3271 int removed = aMeshEditor->RemoveOrphanNodes();
3272 SUIT_MessageBox::information(SMESHGUI::desktop(),
3273 tr("SMESH_INFORMATION"),
3274 tr("NB_NODES_REMOVED").arg(removed));
3275 if ( removed > 0 ) {
3276 SMESH::UpdateView();
3277 SMESHGUI::Modified();
3280 catch (const SALOME::SALOME_Exception& S_ex) {
3281 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3290 case 4051: // RENUMBERING NODES
3292 if(checkLock(aStudy)) break;
3294 EmitSignalDeactivateDialog();
3295 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3299 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3304 case 4052: // RENUMBERING ELEMENTS
3306 if(checkLock(aStudy)) break;
3308 EmitSignalDeactivateDialog();
3309 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3313 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3318 case 4061: // TRANSLATION
3320 if(checkLock(aStudy)) break;
3322 EmitSignalDeactivateDialog();
3323 ( new SMESHGUI_TranslationDlg( this ) )->show();
3326 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3327 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3331 case 4062: // ROTATION
3333 if(checkLock(aStudy)) break;
3335 EmitSignalDeactivateDialog();
3336 ( new SMESHGUI_RotationDlg( this ) )->show();
3339 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3340 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3344 case 4063: // SYMMETRY
3346 if(checkLock(aStudy)) break;
3348 EmitSignalDeactivateDialog();
3349 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3352 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3353 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3357 case 4064: // SEWING
3359 if(checkLock(aStudy)) break;
3361 EmitSignalDeactivateDialog();
3362 ( new SMESHGUI_SewingDlg( this ) )->show();
3365 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3366 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3370 case 4065: // MERGE NODES
3372 if(checkLock(aStudy)) break;
3374 EmitSignalDeactivateDialog();
3375 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3378 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3379 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3383 case 4066: // MERGE EQUAL ELEMENTS
3385 if (checkLock(aStudy)) break;
3387 EmitSignalDeactivateDialog();
3388 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3390 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3391 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3396 case 4067: // MAKE MESH PASS THROUGH POINT
3397 startOperation( 4067 );
3402 if(checkLock(aStudy)) break;
3404 EmitSignalDeactivateDialog();
3405 ( new SMESHGUI_ScaleDlg( this ) )->show();
3408 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3409 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3414 case 4069: // DUPLICATE NODES
3416 if(checkLock(aStudy)) break;
3418 EmitSignalDeactivateDialog();
3419 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3422 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3423 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3428 case 4070: // 0D_ON_ALL_NODES
3429 startOperation( 4070 );
3432 case 5105: // Library of selection filters
3434 static QList<int> aTypes;
3435 if ( aTypes.isEmpty() )
3437 aTypes.append( SMESH::NODE );
3438 aTypes.append( SMESH::EDGE );
3439 aTypes.append( SMESH::FACE );
3440 aTypes.append( SMESH::VOLUME );
3442 if (!myFilterLibraryDlg)
3443 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3444 else if (myFilterLibraryDlg->isHidden())
3445 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3446 myFilterLibraryDlg->raise();
3450 case 6017: // CONTROLS
3478 LightApp_SelectionMgr* mgr = selectionMgr();
3479 SALOME_ListIO selected; mgr->selectedObjects( selected );
3481 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3482 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3484 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3485 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3486 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3487 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3488 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3489 SUIT_OverrideCursor wc;
3490 ::Control( theCommandID );
3495 SUIT_MessageBox::warning(desktop(),
3496 tr( "SMESH_WRN_WARNING" ),
3497 tr( "SMESH_BAD_SELECTION" ) );
3501 SUIT_MessageBox::warning(desktop(),
3502 tr( "SMESH_WRN_WARNING" ),
3503 tr( "NOT_A_VTK_VIEWER" ) );
3507 OverallMeshQuality();
3511 SUIT_OverrideCursor wc;
3512 LightApp_SelectionMgr* mgr = selectionMgr();
3513 SALOME_ListIO selected; mgr->selectedObjects( selected );
3515 SALOME_ListIteratorOfListIO it(selected);
3516 for( ; it.More(); it.Next()) {
3517 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3518 if(anIObject->hasEntry()) {
3519 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3520 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3528 SUIT_OverrideCursor wc;
3529 LightApp_SelectionMgr* mgr = selectionMgr();
3530 SALOME_ListIO selected; mgr->selectedObjects( selected );
3532 SALOME_ListIteratorOfListIO it(selected);
3533 for( ; it.More(); it.Next()) {
3534 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3535 if(anIObject->hasEntry())
3536 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3537 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3548 int page = SMESHGUI_MeasureDlg::MinDistance;
3549 if ( theCommandID == 502 )
3550 page = SMESHGUI_MeasureDlg::BoundingBox;
3551 else if ( theCommandID == 503 )
3552 page = SMESHGUI_MeasureDlg::Length;
3553 else if ( theCommandID == 504 )
3554 page = SMESHGUI_MeasureDlg::Area;
3555 else if ( theCommandID == 505 )
3556 page = SMESHGUI_MeasureDlg::Volume;
3558 EmitSignalDeactivateDialog();
3559 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3569 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3570 //updateObjBrowser();
3574 //=============================================================================
3578 //=============================================================================
3579 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3584 //=============================================================================
3588 //=============================================================================
3589 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3594 //=============================================================================
3598 //=============================================================================
3599 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3604 //=============================================================================
3605 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3606 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3608 //=============================================================================
3609 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3610 SUIT_ViewWindow* wnd )
3612 if(theIO->hasEntry()){
3613 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3614 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3618 //=======================================================================
3619 // function : createSMESHAction
3621 //=======================================================================
3622 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3623 const int key, const bool toggle, const QString& shortcutAction )
3626 QWidget* parent = application()->desktop();
3627 SUIT_ResourceMgr* resMgr = resourceMgr();
3629 if ( !icon_id.isEmpty() )
3630 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3632 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3633 if ( !pix.isNull() )
3634 icon = QIcon( pix );
3636 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3637 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3638 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3640 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3641 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3644 //=======================================================================
3645 // function : createPopupItem
3647 //=======================================================================
3648 void SMESHGUI::createPopupItem( const int id,
3649 const QString& clients,
3650 const QString& types,
3651 const QString& theRule,
3654 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3655 popupMgr()->insert( action( id ), pId, 0 );
3657 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3658 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3659 QString rule = "(%1) and (%2) and (%3)";
3660 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3661 if( clients.isEmpty() )
3662 rule = rule.arg( QString( "true" ) );
3664 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3665 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3668 bool cont = myRules.contains( id );
3670 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3672 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3673 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3676 //=======================================================================
3677 // function : initialize
3679 //=======================================================================
3680 void SMESHGUI::initialize( CAM_Application* app )
3682 SalomeApp_Module::initialize( app );
3684 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3686 /* Automatic Update flag */
3687 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3689 // ----- create actions --------------
3691 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3692 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3693 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3694 createSMESHAction( 114, "NUM" );
3695 createSMESHAction( 115, "IMPORT_STL" );
3696 createSMESHAction( 116, "IMPORT_CGNS" );
3697 createSMESHAction( 117, "IMPORT_SAUV" );
3698 createSMESHAction( 118, "IMPORT_GMF" );
3699 createSMESHAction( 121, "DAT" );
3700 createSMESHAction( 122, "MED" );
3701 createSMESHAction( 123, "UNV" );
3702 createSMESHAction( 140, "STL" );
3703 createSMESHAction( 142, "CGNS");
3704 createSMESHAction( 144, "SAUV");
3705 createSMESHAction( 146, "GMF" );
3706 createSMESHAction( 124, "DAT" );
3707 createSMESHAction( 125, "MED" );
3708 createSMESHAction( 126, "UNV" );
3709 createSMESHAction( 141, "STL" );
3710 createSMESHAction( 143, "CGNS");
3711 createSMESHAction( 145, "SAUV");
3712 createSMESHAction( 147, "GMF" );
3713 createSMESHAction( 150, "FILE_INFO" );
3714 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3715 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3716 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3717 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3718 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3719 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3720 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3721 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3722 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3723 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3724 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3725 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3726 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3727 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3728 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3729 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3730 createSMESHAction( 804, "ADD" );
3731 createSMESHAction( 805, "REMOVE" );
3732 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3733 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3734 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3735 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3736 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3737 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3738 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3739 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3740 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3741 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3742 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3743 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3744 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3745 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3746 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3747 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3748 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3749 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3750 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3751 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3752 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3753 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3754 createSMESHAction( 6032, "OVERALL_MESH_QUALITY" );
3755 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3756 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3757 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3758 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3759 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3760 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3761 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3762 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3763 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3764 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3765 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3766 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3767 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3768 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3769 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3770 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3771 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3772 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3773 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3774 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3775 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3776 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3777 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3778 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3779 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3780 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3781 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3782 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3783 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3784 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3785 createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3786 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3787 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3788 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3789 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3790 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3791 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3792 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3793 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3794 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3795 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3796 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3797 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3798 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3799 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3800 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3801 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3802 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3803 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3804 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3805 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3806 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3807 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3808 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3809 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3810 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3811 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3812 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3813 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3814 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3815 createSMESHAction( 415, "MAP", "ICON_MAP" );
3816 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3817 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3818 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3819 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3820 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3821 createSMESHAction( 200, "RESET" );
3822 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3823 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3824 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3825 #ifndef DISABLE_PLOT2DVIEWER
3826 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3828 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3829 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3830 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3831 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3832 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3833 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3834 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3835 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3836 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3837 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3838 createSMESHAction( 220, "ALL" );
3839 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3841 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3842 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3844 createSMESHAction( 1100, "EDIT_HYPO" );
3845 createSMESHAction( 1102, "UNASSIGN" );
3846 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3847 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3848 createSMESHAction( 1131, "DISPMODE" );
3849 createSMESHAction( 1132, "COLORS" );
3850 createSMESHAction( 1133, "TRANSP" );
3851 createSMESHAction( 1134, "CLIP" );
3852 createSMESHAction( 1135, "DISP_ENT" );
3853 createSMESHAction( 1136, "AUTO_COLOR" );
3854 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3855 createSMESHAction( 2000, "CTRL" );
3857 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3858 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3859 createSMESHAction( 503, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3860 createSMESHAction( 504, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3861 createSMESHAction( 505, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3863 createSMESHAction( 300, "HIDE" );
3864 createSMESHAction( 301, "SHOW" );
3865 createSMESHAction( 302, "DISPLAY_ONLY" );
3867 createSMESHAction( 41, "SORT_CHILD_ITEMS" );
3869 // ----- create menu --------------
3870 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3871 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3872 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3873 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3874 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3875 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3876 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3877 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3879 createMenu( separator(), fileId );
3881 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3882 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3883 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3884 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3885 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3886 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3887 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3888 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3889 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3890 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
3891 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
3893 //createMenu( 111, importId, -1 );
3894 createMenu( 112, importId, -1 );
3895 createMenu( 113, importId, -1 );
3896 createMenu( 115, importId, -1 );
3898 createMenu( 116, importId, -1 );
3900 createMenu( 117, importId, -1 );
3901 createMenu( 118, importId, -1 );
3902 createMenu( 121, exportId, -1 );
3903 createMenu( 122, exportId, -1 );
3904 createMenu( 123, exportId, -1 );
3905 createMenu( 140, exportId, -1 ); // export to STL
3907 createMenu( 142, exportId, -1 ); // export to CGNS
3909 createMenu( 144, exportId, -1 ); // export to SAUV
3910 createMenu( 146, exportId, -1 ); // export to GMF
3911 createMenu( separator(), fileId, 10 );
3913 createMenu( 33, editId, -1 );
3915 createMenu( 5105, toolsId, -1 );
3917 createMenu( 702, meshId, -1 ); // "Mesh" menu
3918 createMenu( 703, meshId, -1 );
3919 createMenu( 704, meshId, -1 );
3920 createMenu( 710, meshId, -1 );
3921 createMenu( 705, meshId, -1 );
3922 createMenu( separator(), meshId, -1 );
3923 createMenu( 701, meshId, -1 );
3924 createMenu( 711, meshId, -1 );
3925 createMenu( 712, meshId, -1 );
3926 createMenu( 713, meshId, -1 );
3927 createMenu( separator(), meshId, -1 );
3928 createMenu( 801, meshId, -1 );
3929 createMenu( 806, meshId, -1 );
3930 createMenu( 802, meshId, -1 );
3931 createMenu( 803, meshId, -1 );
3932 createMenu( 815, meshId, -1 );
3933 createMenu( separator(), meshId, -1 );
3934 createMenu( 810, meshId, -1 );
3935 createMenu( 811, meshId, -1 );
3936 createMenu( 812, meshId, -1 );
3937 createMenu( separator(), meshId, -1 );
3938 createMenu( 814, meshId, -1 );
3939 createMenu( separator(), meshId, -1 );
3940 createMenu( 900, meshId, -1 );
3941 //createMenu( 902, meshId, -1 );
3942 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3943 createMenu( 904, meshId, -1 );
3944 createMenu( separator(), meshId, -1 );
3946 createMenu( 6005, nodeId, -1 );
3947 createMenu( 6028, nodeId, -1 );
3948 createMenu( 6002, edgeId, -1 );
3949 createMenu( 6003, edgeId, -1 );
3950 createMenu( 6001, edgeId, -1 );
3951 createMenu( 6004, edgeId, -1 );
3952 createMenu( 6029, edgeId, -1 );
3953 createMenu( 6021, faceId, -1 );
3954 createMenu( 6025, faceId, -1 );
3955 createMenu( 6027, faceId, -1 );
3956 createMenu( 6018, faceId, -1 );
3957 createMenu( 6019, faceId, -1 );
3958 createMenu( 6011, faceId, -1 );
3959 createMenu( 6012, faceId, -1 );
3960 createMenu( 6013, faceId, -1 );
3961 createMenu( 6014, faceId, -1 );
3962 createMenu( 6015, faceId, -1 );
3963 createMenu( 6016, faceId, -1 );
3964 createMenu( 6022, faceId, -1 );
3965 createMenu( 6030, faceId, -1 );
3966 createMenu( 6017, volumeId, -1 );
3967 createMenu( 6009, volumeId, -1 );
3968 createMenu( 6023, volumeId, -1 );
3969 createMenu( 6024, volumeId, -1 );
3970 createMenu( 6026, volumeId, -1 );
3971 createMenu( 6031, volumeId, -1 );
3972 createMenu( separator(), ctrlId, -1 );
3973 createMenu( 6032, ctrlId, -1 );
3975 createMenu( 4000, addId, -1 );
3976 createMenu( 4009, addId, -1 );
3977 createMenu( 4070, addId, -1 );
3978 createMenu( 4008, addId, -1 );
3979 createMenu( 4010, addId, -1 );
3980 createMenu( 4021, addId, -1 );
3981 createMenu( 4022, addId, -1 );
3982 createMenu( 4023, addId, -1 );
3983 createMenu( 4031, addId, -1 );
3984 createMenu( 4032, addId, -1 );
3985 createMenu( 4133, addId, -1 );
3986 createMenu( 4134, addId, -1 );
3987 createMenu( 4135, addId, -1 );
3988 createMenu( 4033, addId, -1 );
3989 createMenu( separator(), addId, -1 );
3990 createMenu( 4034, addId, -1 );
3991 createMenu( 4035, addId, -1 );
3992 createMenu( 4137, addId, -1 );
3993 createMenu( 4036, addId, -1 );
3994 createMenu( 4136, addId, -1 );
3995 createMenu( 4037, addId, -1 );
3996 createMenu( 4038, addId, -1 );
3997 createMenu( 4039, addId, -1 );
3998 createMenu( 4040, addId, -1 );
3999 createMenu( 4140, addId, -1 );
4001 createMenu( 4041, removeId, -1 );
4002 createMenu( 4042, removeId, -1 );
4003 createMenu( 4044, removeId, -1 );
4004 createMenu( separator(), removeId, -1 );
4005 createMenu( 813, removeId, -1 );
4006 createMenu( separator(), removeId, -1 );
4007 createMenu( 4043, removeId, -1 );
4009 createMenu( 4051, renumId, -1 );
4010 createMenu( 4052, renumId, -1 );
4012 createMenu( 4061, transfId, -1 );
4013 createMenu( 4062, transfId, -1 );
4014 createMenu( 4063, transfId, -1 );
4015 createMenu( 4068, transfId, -1 );
4016 createMenu( 4064, transfId, -1 );
4017 createMenu( 4065, transfId, -1 );
4018 createMenu( 4066, transfId, -1 );
4019 createMenu( 4069, transfId, -1 );
4021 createMenu( 4067,modifyId, -1 );
4022 createMenu( 407, modifyId, -1 );
4023 createMenu( 408, modifyId, -1 );
4024 createMenu( 409, modifyId, -1 );
4025 createMenu( 420, modifyId, -1 );
4026 createMenu( 410, modifyId, -1 );
4027 createMenu( 411, modifyId, -1 );
4028 createMenu( 419, modifyId, -1 );
4029 createMenu( 412, modifyId, -1 );
4030 createMenu( 413, modifyId, -1 );
4031 createMenu( 416, modifyId, -1 );
4032 createMenu( 414, modifyId, -1 );
4033 createMenu( 415, modifyId, -1 );
4034 createMenu( 417, modifyId, -1 );
4035 createMenu( 418, modifyId, -1 );
4037 createMenu( 501, measureId, -1 );
4038 createMenu( 502, measureId, -1 );
4039 createMenu( 503, basicPropId, -1 );
4040 createMenu( 504, basicPropId, -1 );
4041 createMenu( 505, basicPropId, -1 );
4042 createMenu( 214, viewId, -1 );
4044 // ----- create toolbars --------------
4045 int meshTb = createTool( tr( "TB_MESH" ) ),
4046 ctrlTb = createTool( tr( "TB_CTRL" ) ),
4047 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
4048 modifyTb = createTool( tr( "TB_MODIFY" ) ),
4049 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
4051 createTool( 702, meshTb );
4052 createTool( 703, meshTb );
4053 createTool( 704, meshTb );
4054 createTool( 710, meshTb );
4055 createTool( 705, meshTb );
4056 createTool( separator(), meshTb );
4057 createTool( 701, meshTb );
4058 createTool( 711, meshTb );
4059 createTool( 712, meshTb );
4060 createTool( 713, meshTb );
4061 createTool( separator(), meshTb );
4062 createTool( 801, meshTb );
4063 createTool( 806, meshTb );
4064 createTool( 802, meshTb );
4065 createTool( 803, meshTb );
4066 //createTool( 815, meshTb );
4067 createTool( separator(), meshTb );
4068 createTool( 900, meshTb );
4069 //createTool( 902, meshTb );
4070 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4071 createTool( 904, meshTb );
4072 createTool( separator(), meshTb );
4074 createTool( 6005, ctrlTb );
4075 createTool( 6028, ctrlTb );
4076 createTool( separator(), ctrlTb );
4077 createTool( 6002, ctrlTb );
4078 createTool( 6003, ctrlTb );
4079 createTool( 6001, ctrlTb );
4080 createTool( 6004, ctrlTb );
4081 createTool( 6029, ctrlTb );
4082 createTool( separator(), ctrlTb );
4083 createTool( 6021, ctrlTb );
4084 createTool( 6025, ctrlTb );
4085 createTool( 6027, ctrlTb );
4086 createTool( 6018, ctrlTb );
4087 createTool( 6019, ctrlTb );
4088 createTool( 6011, ctrlTb );
4089 createTool( 6012, ctrlTb );
4090 createTool( 6013, ctrlTb );
4091 createTool( 6014, ctrlTb );
4092 createTool( 6015, ctrlTb );
4093 createTool( 6016, ctrlTb );
4094 createTool( 6022, ctrlTb );
4095 createTool( 6030, ctrlTb );
4096 createTool( separator(), ctrlTb );
4097 createTool( 6017, ctrlTb );
4098 createTool( 6009, ctrlTb );
4099 createTool( 6023, ctrlTb );
4100 createTool( 6024, ctrlTb );
4101 createTool( 6026, ctrlTb );
4102 createTool( 6031, ctrlTb );
4103 createTool( separator(), ctrlTb );
4105 createTool( 4000, addRemTb );
4106 createTool( 4009, addRemTb );
4107 createTool( 4070, addRemTb );
4108 createTool( 4008, addRemTb );
4109 createTool( 4010, addRemTb );
4110 createTool( 4021, addRemTb );
4111 createTool( 4022, addRemTb );
4112 createTool( 4023, addRemTb );
4113 createTool( 4031, addRemTb );
4114 createTool( 4032, addRemTb );
4115 createTool( 4133, addRemTb );
4116 createTool( 4134, addRemTb );
4117 createTool( 4135, addRemTb );
4118 createTool( 4033, addRemTb );
4119 createTool( separator(), addRemTb );
4120 createTool( 4034, addRemTb );
4121 createTool( 4035, addRemTb );
4122 createTool( 4137, addRemTb );
4123 createTool( 4036, addRemTb );
4124 createTool( 4136, addRemTb );
4125 createTool( 4037, addRemTb );
4126 createTool( 4038, addRemTb );
4127 createTool( 4039, addRemTb );
4128 createTool( 4040, addRemTb );
4129 createTool( 4140, addRemTb );
4130 createTool( separator(), addRemTb );
4131 createTool( 4041, addRemTb );
4132 createTool( 4042, addRemTb );
4133 createTool( 4044, addRemTb );
4134 createTool( 4043, addRemTb );
4135 createTool( separator(), addRemTb );
4136 createTool( 4051, addRemTb );
4137 createTool( 4052, addRemTb );
4138 createTool( separator(), addRemTb );
4139 createTool( 4061, addRemTb );
4140 createTool( 4062, addRemTb );
4141 createTool( 4063, addRemTb );
4142 createTool( 4068, addRemTb );
4143 createTool( 4064, addRemTb );
4144 createTool( 4065, addRemTb );
4145 createTool( 4066, addRemTb );
4146 createTool( 4069, addRemTb );
4147 createTool( separator(), addRemTb );
4149 createTool( 4067,modifyTb );
4150 createTool( 407, modifyTb );
4151 createTool( 408, modifyTb );
4152 createTool( 409, modifyTb );
4153 createTool( 420, modifyTb );
4154 createTool( 410, modifyTb );
4155 createTool( 411, modifyTb );
4156 createTool( 419, modifyTb );
4157 createTool( 412, modifyTb );
4158 createTool( 413, modifyTb );
4159 createTool( 416, modifyTb );
4160 createTool( 414, modifyTb );
4161 createTool( 415, modifyTb );
4162 createTool( 417, modifyTb );
4163 createTool( 418, modifyTb );
4165 createTool( 214, dispModeTb );
4167 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4168 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4171 QString OB = "'ObjectBrowser'",
4172 View = "'" + SVTK_Viewer::Type() + "'",
4174 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4175 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4176 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4177 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4178 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4179 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4180 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4181 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4182 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4183 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4184 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4186 mesh_part = mesh + " " + subMesh + " " + group,
4187 mesh_group = mesh + " " + group,
4188 hyp_alg = hypo + " " + algo;
4190 // popup for object browser
4192 isInvisible("not( isVisible )"),
4193 isEmpty("numberOfNodes = 0"),
4194 isNotEmpty("numberOfNodes <> 0"),
4196 // has nodes, edges, etc in VISIBLE! actor
4197 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4198 hasElems("(count( elemTypes ) > 0)"),
4199 hasDifferentElems("(count( elemTypes ) > 1)"),
4200 hasBalls("({'BallElem'} in elemTypes)"),
4201 hasElems0d("({'Elem0d'} in elemTypes)"),
4202 hasEdges("({'Edge'} in elemTypes)"),
4203 hasFaces("({'Face'} in elemTypes)"),
4204 hasVolumes("({'Volume'} in elemTypes)");
4206 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4207 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4208 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4209 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4210 createPopupItem( 803, OB, group ); // EDIT_GROUP
4211 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4213 popupMgr()->insert( separator(), -1, 0 );
4214 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4215 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4216 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4217 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4218 createPopupItem( 214, OB, mesh_part ); // UPDATE
4219 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4220 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4221 createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO
4222 popupMgr()->insert( separator(), -1, 0 );
4223 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4224 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4225 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4226 popupMgr()->insert( separator(), -1, 0 );
4227 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4228 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4229 popupMgr()->insert( separator(), -1, 0 );
4230 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4231 popupMgr()->insert( separator(), -1, 0 );
4232 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4233 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4235 popupMgr()->insert( separator(), -1, 0 );
4237 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4238 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4239 QString only_one_2D = only_one_non_empty + " && dim>1";
4241 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4242 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4243 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4244 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4246 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4248 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4249 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4250 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4251 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4252 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4253 popupMgr()->insert( separator(), -1, 0 );
4256 createPopupItem( 803, View, group ); // EDIT_GROUP
4257 createPopupItem( 804, View, elems ); // ADD
4258 createPopupItem( 805, View, elems ); // REMOVE
4260 popupMgr()->insert( separator(), -1, 0 );
4261 createPopupItem( 214, View, mesh_part ); // UPDATE
4262 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4263 createPopupItem( 6032,View, mesh_part ); // CTRL_INFO
4264 createPopupItem( 904, View, mesh ); // FIND_ELEM
4265 popupMgr()->insert( separator(), -1, 0 );
4267 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4268 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4269 popupMgr()->insert( separator(), -1, 0 );
4271 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4272 QString aType = QString( "%1type in {%2}" ).arg( lc );
4273 aType = aType.arg( mesh_part );
4274 QString aMeshInVTK = aClient + "&&" + aType;
4276 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4277 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4278 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4280 //-------------------------------------------------
4282 //-------------------------------------------------
4283 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4285 popupMgr()->insert( action( 9010 ), anId, -1 );
4286 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4287 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4289 popupMgr()->insert( action( 9011 ), anId, -1 );
4290 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4291 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4293 popupMgr()->insert( separator(), -1, -1 );
4295 //-------------------------------------------------
4297 //-------------------------------------------------
4298 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4300 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4301 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4302 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4304 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4305 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4306 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4308 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4309 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4310 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4312 popupMgr()->insert( separator(), anId, -1 );
4314 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4315 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4316 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4318 //-------------------------------------------------
4320 //-------------------------------------------------
4321 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4323 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4325 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4326 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4327 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4329 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4330 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4331 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4333 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4334 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4335 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4337 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4338 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4339 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4341 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4342 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4343 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4345 popupMgr()->insert( separator(), anId, -1 );
4347 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4348 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4351 //-------------------------------------------------
4352 // Representation of the 2D Quadratic elements
4353 //-------------------------------------------------
4354 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4355 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4356 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4357 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4359 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4360 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4361 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4363 //-------------------------------------------------
4364 // Orientation of faces
4365 //-------------------------------------------------
4366 popupMgr()->insert( action( 221 ), -1, -1 );
4367 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4368 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4370 //-------------------------------------------------
4372 //-------------------------------------------------
4373 popupMgr()->insert( action( 1132 ), -1, -1 );
4374 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4376 //-------------------------------------------------
4378 //-------------------------------------------------
4379 popupMgr()->insert( action( 1133 ), -1, -1 );
4380 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4382 //-------------------------------------------------
4384 //-------------------------------------------------
4386 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4387 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4388 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4389 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4391 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4393 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4394 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4396 popupMgr()->insert( separator(), anId, -1 );
4398 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4400 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4401 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4402 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4404 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4405 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4406 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4408 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4410 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4411 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4412 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4414 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4415 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4416 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4418 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4419 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4420 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4422 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4423 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4424 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4425 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4426 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4427 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4429 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4431 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4432 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4433 QtxPopupMgr::VisibleRule );
4434 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4436 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4437 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4438 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4440 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4441 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4442 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4444 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4445 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4446 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4448 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4449 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4450 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4452 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4453 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4454 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4456 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4457 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4458 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4460 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4461 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4462 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4464 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4465 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4466 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4468 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4469 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4470 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4472 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4473 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4474 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4476 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4477 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4478 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4479 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4480 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4481 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4483 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4485 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4486 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4487 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4489 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4490 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4491 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4493 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4494 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4495 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4497 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4498 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4499 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4501 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4502 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4503 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4505 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4506 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4507 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4509 popupMgr()->insert( separator(), anId, -1 );
4511 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4512 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4514 popupMgr()->insert( separator(), anId, -1 );
4516 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4518 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4519 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4521 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4522 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4523 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4525 #ifndef DISABLE_PLOT2DVIEWER
4526 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4527 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4530 //-------------------------------------------------
4532 //-------------------------------------------------
4533 popupMgr()->insert( separator(), -1, -1 );
4534 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4535 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4536 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4537 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4539 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4540 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4542 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4543 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4545 popupMgr()->insert( separator(), -1, -1 );
4547 //-------------------------------------------------
4549 //-------------------------------------------------
4550 popupMgr()->insert( action( 1134 ), -1, -1 );
4551 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4553 popupMgr()->insert( separator(), -1, -1 );
4555 popupMgr()->insert( action( 41 ), -1, -1 );
4556 popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4557 popupMgr()->insert( separator(), -1, -1 );
4559 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4560 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4562 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4563 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4566 //================================================================================
4568 * \brief Return true if SMESH or GEOM objects are selected.
4569 * Is called form LightApp_Module::activateModule() which clear selection if
4570 * not isSelectionCompatible()
4572 //================================================================================
4574 bool SMESHGUI::isSelectionCompatible()
4576 bool isCompatible = true;
4577 SALOME_ListIO selected;
4578 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4579 Sel->selectedObjects( selected );
4581 SALOME_ListIteratorOfListIO It( selected );
4582 for ( ; isCompatible && It.More(); It.Next())
4584 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4585 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4587 return isCompatible;
4591 bool SMESHGUI::reusableOperation( const int id )
4593 // compute, evaluate and precompute are not reusable operations
4594 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4597 bool SMESHGUI::activateModule( SUIT_Study* study )
4599 bool res = SalomeApp_Module::activateModule( study );
4601 setMenuShown( true );
4602 setToolShown( true );
4604 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4605 PyGILState_STATE gstate = PyGILState_Ensure();
4606 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4607 if(pluginsmanager==NULL)
4611 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4616 PyGILState_Release(gstate);
4617 // end of GEOM plugins loading
4619 // Reset actions accelerator keys
4620 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4621 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4622 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4624 action( 33)->setEnabled(true); // Delete: Key_Delete
4626 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4627 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4628 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4629 if ( _PTR(Study) aStudy = s->studyDS()) {
4630 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4631 updateObjBrowser(); // objects can be removed
4634 // get all view currently opened in the study and connect their signals to
4635 // the corresponding slots of the class.
4636 SUIT_Desktop* aDesk = study->application()->desktop();
4638 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4639 SUIT_ViewWindow* wnd;
4640 foreach ( wnd, wndList )
4647 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4649 setMenuShown( false );
4650 setToolShown( false );
4652 EmitSignalCloseAllDialogs();
4654 // Unset actions accelerator keys
4655 //action(111)->setShortcut(QKeySequence()); // Import DAT
4656 action(112)->setShortcut(QKeySequence()); // Import UNV
4657 action(113)->setShortcut(QKeySequence()); // Import MED
4659 action( 33)->setEnabled(false); // Delete: Key_Delete
4661 return SalomeApp_Module::deactivateModule( study );
4664 void SMESHGUI::studyClosed( SUIT_Study* s )
4666 SMESH::RemoveVisuData( s->id() );
4667 SalomeApp_Module::studyClosed( s );
4670 void SMESHGUI::OnGUIEvent()
4672 const QObject* obj = sender();
4673 if ( !obj || !obj->inherits( "QAction" ) )
4675 int id = actionId((QAction*)obj);
4680 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4682 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4683 if ( CORBA::is_nil( myComponentSMESH ) )
4685 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4687 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4688 return aGUI.myComponentSMESH;
4691 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4692 return myComponentSMESH;
4695 QString SMESHGUI::engineIOR() const
4697 CORBA::ORB_var anORB = getApp()->orb();
4698 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4699 return QString( anIOR.in() );
4702 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4704 SalomeApp_Module::contextMenuPopup( client, menu, title );
4706 selectionMgr()->selectedObjects( lst );
4707 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4708 Handle(SALOME_InteractiveObject) io = lst.First();
4709 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4710 _PTR(Study) study = appStudy->studyDS();
4711 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4713 QString aName = QString( obj->GetName().c_str() );
4714 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4715 aName.remove( (aName.length() - 1), 1 );
4721 LightApp_Selection* SMESHGUI::createSelection() const
4723 return new SMESHGUI_Selection();
4726 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4728 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4729 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4732 void SMESHGUI::viewManagers( QStringList& list ) const
4734 list.append( SVTK_Viewer::Type() );
4737 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4739 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4740 SMESH::UpdateSelectionProp( this );
4742 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4743 for(int i = 0; i < aViews.count() ; i++){
4744 SUIT_ViewWindow *sf = aViews[i];
4750 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4752 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4753 myClippingPlaneInfoMap.erase( theViewManager );
4756 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4758 theActor->AddObserver( SMESH::DeleteActorEvent,
4759 myEventCallbackCommand.GetPointer(),
4763 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4764 unsigned long theEvent,
4765 void* theClientData,
4768 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4769 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4770 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4771 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4772 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4773 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4774 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4775 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4776 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4777 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4778 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4779 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4780 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4781 if( anActor == *anIter3 ) {
4782 anActorList.erase( anIter3 );
4793 void SMESHGUI::createPreferences()
4795 // General tab ------------------------------------------------------------------------
4796 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4798 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4799 setPreferenceProperty( autoUpdate, "columns", 2 );
4800 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4801 setPreferenceProperty( lim, "min", 0 );
4802 setPreferenceProperty( lim, "max", 100000000 );
4803 setPreferenceProperty( lim, "step", 1000 );
4804 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4805 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4807 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4808 setPreferenceProperty( qaGroup, "columns", 2 );
4809 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4810 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4811 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4812 setPreferenceProperty( prec, "min", 0 );
4813 setPreferenceProperty( prec, "max", 16 );
4814 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4815 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4816 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4817 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4818 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4820 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4821 setPreferenceProperty( dispgroup, "columns", 2 );
4822 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4824 modes.append( tr("MEN_WIRE") );
4825 modes.append( tr("MEN_SHADE") );
4826 modes.append( tr("MEN_NODES") );
4827 modes.append( tr("MEN_SHRINK") );
4828 QList<QVariant> indices;
4829 indices.append( 0 );
4830 indices.append( 1 );
4831 indices.append( 2 );
4832 indices.append( 3 );
4833 setPreferenceProperty( dispmode, "strings", modes );
4834 setPreferenceProperty( dispmode, "indexes", indices );
4836 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4837 setPreferenceProperty( arcgroup, "columns", 2 );
4838 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4839 QStringList quadraticModes;
4840 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4841 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4843 indices.append( 0 );
4844 indices.append( 1 );
4845 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4846 setPreferenceProperty( quadraticmode, "indexes", indices );
4848 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4849 "SMESH", "max_angle" );
4850 setPreferenceProperty( maxAngle, "min", 1 );
4851 setPreferenceProperty( maxAngle, "max", 90 );
4855 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4856 setPreferenceProperty( exportgroup, "columns", 2 );
4857 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4858 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4860 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4861 setPreferenceProperty( computeGroup, "columns", 2 );
4862 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4864 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4865 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4866 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4868 indices.append( 0 );
4869 indices.append( 1 );
4870 indices.append( 2 );
4871 setPreferenceProperty( notifyMode, "strings", modes );
4872 setPreferenceProperty( notifyMode, "indexes", indices );
4874 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4875 setPreferenceProperty( infoGroup, "columns", 2 );
4876 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4878 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4879 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4881 indices.append( 0 );
4882 indices.append( 1 );
4883 setPreferenceProperty( elemInfo, "strings", modes );
4884 setPreferenceProperty( elemInfo, "indexes", indices );
4885 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4886 setPreferenceProperty( nodesLim, "min", 0 );
4887 setPreferenceProperty( nodesLim, "max", 10000000 );
4888 setPreferenceProperty( nodesLim, "step", 10000 );
4889 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4890 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
4891 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4892 setPreferenceProperty( ctrlLim, "min", 0 );
4893 setPreferenceProperty( ctrlLim, "max", 10000000 );
4894 setPreferenceProperty( ctrlLim, "step", 1000 );
4895 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
4896 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
4897 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
4898 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
4899 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
4901 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4902 setPreferenceProperty( segGroup, "columns", 2 );
4903 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4904 "SMESH", "segmentation" );
4905 setPreferenceProperty( segLen, "min", 1 );
4906 setPreferenceProperty( segLen, "max", 10000000 );
4907 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4908 "SMESH", "nb_segments_per_edge" );
4909 setPreferenceProperty( nbSeg, "min", 1 );
4910 setPreferenceProperty( nbSeg, "max", 10000000 );
4912 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4913 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4914 "SMESH", "forget_mesh_on_hyp_modif" );
4917 // Quantities with individual precision settings
4918 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4919 setPreferenceProperty( precGroup, "columns", 2 );
4921 const int nbQuantities = 6;
4922 int precs[nbQuantities], ii = 0;
4923 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4924 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4925 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4926 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4927 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4928 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4929 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4930 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4931 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4932 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4933 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4934 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4936 // Set property for precision value for spinboxes
4937 for ( ii = 0; ii < nbQuantities; ii++ ){
4938 setPreferenceProperty( precs[ii], "min", -14 );
4939 setPreferenceProperty( precs[ii], "max", 14 );
4940 setPreferenceProperty( precs[ii], "precision", 2 );
4943 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4944 setPreferenceProperty( previewGroup, "columns", 2 );
4945 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4946 setPreferenceProperty( chunkSize, "min", 1 );
4947 setPreferenceProperty( chunkSize, "max", 1000 );
4948 setPreferenceProperty( chunkSize, "step", 50 );
4950 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4951 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4953 // Mesh tab ------------------------------------------------------------------------
4954 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4955 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4956 setPreferenceProperty( nodeGroup, "columns", 3 );
4958 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4960 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4962 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4963 QList<QVariant> aMarkerTypeIndicesList;
4964 QList<QVariant> aMarkerTypeIconsList;
4965 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4966 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4967 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4968 aMarkerTypeIndicesList << i;
4969 aMarkerTypeIconsList << pixmap;
4971 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4972 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4974 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4976 QList<QVariant> aMarkerScaleIndicesList;
4977 QStringList aMarkerScaleValuesList;
4978 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4979 aMarkerScaleIndicesList << i;
4980 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4982 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4983 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4985 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4986 //setPreferenceProperty( elemGroup, "columns", 2 );
4988 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4989 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4990 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
4991 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
4992 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4993 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
4994 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4995 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4998 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4999 setPreferenceProperty( grpGroup, "columns", 2 );
5001 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5002 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5004 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5005 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5006 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5007 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
5008 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5009 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5010 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5011 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5012 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5013 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5015 setPreferenceProperty( size0d, "min", 1 );
5016 setPreferenceProperty( size0d, "max", 10 );
5018 setPreferenceProperty( ballSize, "min", 1 );
5019 setPreferenceProperty( ballSize, "max", 10 );
5021 setPreferenceProperty( elemW, "min", 1 );
5022 setPreferenceProperty( elemW, "max", 5 );
5024 setPreferenceProperty( outW, "min", 1 );
5025 setPreferenceProperty( outW, "max", 5 );
5027 setPreferenceProperty( shrink, "min", 0 );
5028 setPreferenceProperty( shrink, "max", 100 );
5030 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5031 setPreferenceProperty( numGroup, "columns", 2 );
5033 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5034 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5036 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5037 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5039 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5040 setPreferenceProperty( orientGroup, "columns", 1 );
5042 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5043 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5045 setPreferenceProperty( orientScale, "min", 0.05 );
5046 setPreferenceProperty( orientScale, "max", 0.5 );
5047 setPreferenceProperty( orientScale, "step", 0.05 );
5049 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5051 // Selection tab ------------------------------------------------------------------------
5052 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5054 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5055 setPreferenceProperty( selGroup, "columns", 2 );
5057 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5058 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5060 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5061 setPreferenceProperty( preGroup, "columns", 2 );
5063 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5065 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5066 setPreferenceProperty( precSelGroup, "columns", 2 );
5068 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5069 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5070 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5072 // Scalar Bar tab ------------------------------------------------------------------------
5073 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5074 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5075 setPreferenceProperty( fontGr, "columns", 2 );
5077 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5078 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5080 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5081 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5083 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5084 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5086 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5087 setPreferenceProperty( numcol, "min", 2 );
5088 setPreferenceProperty( numcol, "max", 256 );
5090 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5091 setPreferenceProperty( numlab, "min", 2 );
5092 setPreferenceProperty( numlab, "max", 65 );
5094 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5095 setPreferenceProperty( orientGr, "columns", 2 );
5096 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5097 QStringList orients;
5098 orients.append( tr( "SMESH_VERTICAL" ) );
5099 orients.append( tr( "SMESH_HORIZONTAL" ) );
5100 indices.clear(); indices.append( 0 ); indices.append( 1 );
5101 setPreferenceProperty( orient, "strings", orients );
5102 setPreferenceProperty( orient, "indexes", indices );
5104 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5105 setPreferenceProperty( posVSizeGr, "columns", 2 );
5106 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5107 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5108 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5109 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5110 setPreferenceProperty( xv, "step", 0.1 );
5111 setPreferenceProperty( xv, "min", 0.0 );
5112 setPreferenceProperty( xv, "max", 1.0 );
5113 setPreferenceProperty( yv, "step", 0.1 );
5114 setPreferenceProperty( yv, "min", 0.0 );
5115 setPreferenceProperty( yv, "max", 1.0 );
5116 setPreferenceProperty( wv, "step", 0.1 );
5117 setPreferenceProperty( wv, "min", 0.0 );
5118 setPreferenceProperty( wv, "max", 1.0 );
5119 setPreferenceProperty( hv, "min", 0.0 );
5120 setPreferenceProperty( hv, "max", 1.0 );
5121 setPreferenceProperty( hv, "step", 0.1 );
5123 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5124 setPreferenceProperty( posHSizeGr, "columns", 2 );
5125 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5126 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5127 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5128 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5129 setPreferenceProperty( xv, "min", 0.0 );
5130 setPreferenceProperty( xv, "max", 1.0 );
5131 setPreferenceProperty( xv, "step", 0.1 );
5132 setPreferenceProperty( xh, "min", 0.0 );
5133 setPreferenceProperty( xh, "max", 1.0 );
5134 setPreferenceProperty( xh, "step", 0.1 );
5135 setPreferenceProperty( yh, "min", 0.0 );
5136 setPreferenceProperty( yh, "max", 1.0 );
5137 setPreferenceProperty( yh, "step", 0.1 );
5138 setPreferenceProperty( wh, "min", 0.0 );
5139 setPreferenceProperty( wh, "max", 1.0 );
5140 setPreferenceProperty( wh, "step", 0.1 );
5141 setPreferenceProperty( hh, "min", 0.0 );
5142 setPreferenceProperty( hh, "max", 1.0 );
5143 setPreferenceProperty( hh, "step", 0.1 );
5145 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5146 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5147 setPreferenceProperty( distributionGr, "columns", 3 );
5149 types.append( tr( "SMESH_MONOCOLOR" ) );
5150 types.append( tr( "SMESH_MULTICOLOR" ) );
5151 indices.clear(); indices.append( 0 ); indices.append( 1 );
5152 setPreferenceProperty( coloringType, "strings", types );
5153 setPreferenceProperty( coloringType, "indexes", indices );
5154 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5158 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5160 if( sect=="SMESH" ) {
5161 float sbX1,sbY1,sbW,sbH;
5162 float aTol = 1.00000009999999;
5163 std::string aWarning;
5164 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5165 if( name=="selection_object_color" || name=="selection_element_color" ||
5166 name=="highlight_color" ||
5167 name=="selection_precision_node" || name=="selection_precision_element" ||
5168 name=="selection_precision_object")
5169 SMESH::UpdateSelectionProp( this );
5170 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
5171 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5172 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5173 if(sbX1+sbW > aTol){
5174 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5177 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5178 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5181 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
5182 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5183 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5184 if(sbY1+sbH > aTol){
5185 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5186 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5187 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5190 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5191 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5192 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5193 if(sbX1+sbW > aTol){
5194 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5197 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5198 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5201 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5202 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5203 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5204 if(sbY1+sbH > aTol){
5205 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5208 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5209 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5212 else if ( name == "segmentation" ) {
5213 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5214 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5216 else if ( name == "nb_segments_per_edge" ) {
5217 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5218 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5220 else if ( name == "historical_python_dump" ||
5221 name == "forget_mesh_on_hyp_modif") {
5222 QString val = aResourceMgr->stringValue( "SMESH", name );
5223 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5225 else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
5226 SMESH::UpdateFontProp( this );
5228 else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
5229 SMESH::UpdateFontProp( this );
5232 if(aWarning.size() != 0){
5233 aWarning += "The default values are applied instead.";
5234 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5235 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5236 QObject::tr(aWarning.c_str()));
5241 //================================================================================
5243 * \brief Update something in accordance with update flags
5244 * \param theFlags - update flags
5246 * Update viewer or/and object browser etc. in accordance with update flags ( see
5247 * LightApp_UpdateFlags enumeration ).
5249 //================================================================================
5250 void SMESHGUI::update( const int flags )
5252 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5253 SMESH::UpdateView();
5255 SalomeApp_Module::update( flags );
5258 //================================================================================
5260 * \brief Set default selection mode
5262 * SLOT called when operation commited. Sets default selection mode
5264 //================================================================================
5265 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5267 SVTK_ViewWindow* vtkWnd =
5268 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5270 vtkWnd->SetSelectionMode( ActorSelection );
5273 //================================================================================
5275 * \brief Set default selection mode
5277 * SLOT called when operation aborted. Sets default selection mode
5279 //================================================================================
5280 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5282 SVTK_ViewWindow* vtkWnd =
5283 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5285 vtkWnd->SetSelectionMode( ActorSelection );
5288 //================================================================================
5290 * \brief Creates operation with given identifier
5291 * \param id - identifier of operation to be started
5292 * \return Pointer on created operation or NULL if operation is not created
5294 * Virtual method redefined from the base class creates operation with given id.
5295 * It is called called automatically from startOperation method of base class.
5297 //================================================================================
5298 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5300 LightApp_Operation* op = 0;
5301 // to do : create operation here
5304 case 417: //convert to quadratic
5305 op = new SMESHGUI_ConvToQuadOp();
5307 case 418: // create 2D mesh as boundary on 3D
5308 op = new SMESHGUI_Make2DFrom3DOp();
5310 case 420: // Reorient faces
5311 op = new SMESHGUI_ReorientFacesOp();
5313 case 701: // Compute mesh
5314 op = new SMESHGUI_ComputeOp();
5316 case 702: // Create mesh
5317 op = new SMESHGUI_MeshOp( true, true );
5319 case 703: // Create sub-mesh
5320 op = new SMESHGUI_MeshOp( true, false );
5322 case 704: // Edit mesh/sub-mesh
5323 op = new SMESHGUI_MeshOp( false );
5325 case 711: // Precompute mesh
5326 op = new SMESHGUI_PrecomputeOp();
5328 case 712: // Evaluate mesh
5329 op = new SMESHGUI_EvaluateOp();
5331 case 713: // Evaluate mesh
5332 op = new SMESHGUI_MeshOrderOp();
5334 case 806: // Create group on geom
5335 op = new SMESHGUI_GroupOnShapeOp();
5337 case 904: // Find element
5338 op = new SMESHGUI_FindElemByPointOp();
5340 case 4067: // Make mesh pass through point
5341 op = new SMESHGUI_MakeNodeAtPointOp();
5343 case 4070: // Create 0D elements on all nodes
5344 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5351 op = SalomeApp_Module::createOperation( id );
5355 //================================================================================
5357 * \brief Stops current operations and starts a given one
5358 * \param id - The id of the operation to start
5360 //================================================================================
5362 void SMESHGUI::switchToOperation(int id)
5364 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5365 activeStudy()->abortAllOperations();
5366 startOperation( id );
5369 LightApp_Displayer* SMESHGUI::displayer()
5372 myDisplayer = new SMESHGUI_Displayer( getApp() );
5376 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5379 int aTolerance = 64;
5380 int anIterations = 0;
5386 if( anIterations % aPeriod == 0 )
5389 if( aTolerance < 1 )
5393 aHue = (int)( 360.0 * rand() / RAND_MAX );
5396 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5397 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5398 for( ; it != itEnd; ++it )
5400 SALOMEDS::Color anAutoColor = *it;
5401 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5404 aQColor.getHsv( &h, &s, &v );
5405 if( abs( h - aHue ) < aTolerance )
5417 aColor.setHsv( aHue, 255, 255 );
5419 SALOMEDS::Color aSColor;
5420 aSColor.R = aColor.redF();
5421 aSColor.G = aColor.greenF();
5422 aSColor.B = aColor.blueF();
5427 const char* gSeparator = "_"; // character used to separate parameter names
5428 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5429 const char* gPathSep = "|"; // character used to separate paths
5432 * \brief Store visual parameters
5434 * This method is called just before the study document is saved.
5435 * Store visual parameters in AttributeParameter attribue(s)
5437 void SMESHGUI::storeVisualParameters (int savePoint)
5440 Kernel_Utils::Localizer loc;
5442 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5443 if (!appStudy || !appStudy->studyDS())
5445 _PTR(Study) studyDS = appStudy->studyDS();
5447 // componentName is used for encoding of entries when storing them in IParameters
5448 std::string componentName = myComponentSMESH->ComponentDataType();
5449 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5450 //if (!aSComponent) return;
5453 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5454 componentName.c_str(),
5456 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5458 // store map of custom markers
5459 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5460 if( !aMarkerMap.empty() )
5462 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5463 for( ; anIter != aMarkerMap.end(); anIter++ )
5465 int anId = anIter->first;
5466 VTK::MarkerData aMarkerData = anIter->second;
5467 std::string aMarkerFileName = aMarkerData.first;
5468 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5469 if( aMarkerTexture.size() < 3 )
5470 continue; // should contain at least width, height and the first value
5472 QString aPropertyName( "texture" );
5473 aPropertyName += gSeparator;
5474 aPropertyName += QString::number( anId );
5476 QString aPropertyValue = aMarkerFileName.c_str();
5477 aPropertyValue += gPathSep;
5479 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5480 ushort aWidth = *aTextureIter++;
5481 ushort aHeight = *aTextureIter++;
5482 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5483 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5484 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5485 aPropertyValue += QString::number( *aTextureIter );
5487 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5491 // viewers counters are used for storing view_numbers in IParameters
5494 // main cycle to store parameters of displayed objects
5495 QList<SUIT_ViewManager*> lst;
5496 QList<SUIT_ViewManager*>::Iterator it;
5497 getApp()->viewManagers(lst);
5498 for (it = lst.begin(); it != lst.end(); it++)
5500 SUIT_ViewManager* vman = *it;
5501 QString vType = vman->getType();
5503 // saving VTK actors properties
5504 if (vType == SVTK_Viewer::Type())
5506 // store the clipping planes attached to the view manager
5507 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5508 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5509 if( anIter != myClippingPlaneInfoMap.end() )
5510 aClippingPlaneInfoList = anIter->second;
5512 if( !aClippingPlaneInfoList.empty() ) {
5513 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5514 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5516 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5517 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5519 QString aPropertyName( "ClippingPlane" );
5520 aPropertyName += gSeparator;
5521 aPropertyName += QString::number( vtkViewers );
5522 aPropertyName += gSeparator;
5523 aPropertyName += QString::number( anId );
5525 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5526 aPropertyValue += gDigitsSep;
5527 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5528 aPropertyValue += gDigitsSep;
5529 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5530 aPropertyValue += gDigitsSep;
5531 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5533 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5537 QVector<SUIT_ViewWindow*> views = vman->getViews();
5538 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5540 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5542 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5543 vtkActorCollection* allActors = aCopy.GetActors();
5544 allActors->InitTraversal();
5545 while (vtkActor* actor = allActors->GetNextActor())
5547 if (actor->GetVisibility()) // store only visible actors
5549 SMESH_Actor* aSmeshActor = 0;
5550 if (actor->IsA("SMESH_Actor"))
5551 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5552 if (aSmeshActor && aSmeshActor->hasIO())
5554 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5557 // entry is "encoded" = it does NOT contain component adress,
5558 // since it is a subject to change on next component loading
5559 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5561 std::string param, vtkParam = vType.toLatin1().data();
5562 vtkParam += gSeparator;
5563 vtkParam += QString::number(vtkViewers).toLatin1().data();
5564 vtkParam += gSeparator;
5567 param = vtkParam + "Visibility";
5568 ip->setParameter(entry, param, "On");
5571 param = vtkParam + "Representation";
5572 ip->setParameter(entry, param, QString::number
5573 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5576 param = vtkParam + "IsShrunk";
5577 ip->setParameter(entry, param, QString::number
5578 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5580 // Displayed entities
5581 unsigned int aMode = aSmeshActor->GetEntityMode();
5582 bool isE = aMode & SMESH_Actor::eEdges;
5583 bool isF = aMode & SMESH_Actor::eFaces;
5584 bool isV = aMode & SMESH_Actor::eVolumes;
5585 bool is0d = aMode & SMESH_Actor::e0DElements;
5586 bool isB = aMode & SMESH_Actor::eBallElem;
5588 QString modeStr ("e");
5589 modeStr += gDigitsSep; modeStr += QString::number(isE);
5590 modeStr += gDigitsSep; modeStr += "f";
5591 modeStr += gDigitsSep; modeStr += QString::number(isF);
5592 modeStr += gDigitsSep; modeStr += "v";
5593 modeStr += gDigitsSep; modeStr += QString::number(isV);
5594 modeStr += gDigitsSep; modeStr += "0d";
5595 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5596 modeStr += gDigitsSep; modeStr += "b";
5597 modeStr += gDigitsSep; modeStr += QString::number(isB);
5599 param = vtkParam + "Entities";
5600 ip->setParameter(entry, param, modeStr.toLatin1().data());
5606 aSmeshActor->GetSufaceColor(r, g, b, delta);
5607 QStringList colorStr;
5608 colorStr << "surface";
5609 colorStr << QString::number(r);
5610 colorStr << QString::number(g);
5611 colorStr << QString::number(b);
5613 colorStr << "backsurface";
5614 colorStr << QString::number(delta);
5616 aSmeshActor->GetVolumeColor(r, g, b, delta);
5617 colorStr << "volume";
5618 colorStr << QString::number(r);
5619 colorStr << QString::number(g);
5620 colorStr << QString::number(b);
5621 colorStr << QString::number(delta);
5623 aSmeshActor->GetEdgeColor(r, g, b);
5625 colorStr << QString::number(r);
5626 colorStr << QString::number(g);
5627 colorStr << QString::number(b);
5629 aSmeshActor->GetNodeColor(r, g, b);
5631 colorStr << QString::number(r);
5632 colorStr << QString::number(g);
5633 colorStr << QString::number(b);
5635 aSmeshActor->GetOutlineColor(r, g, b);
5636 colorStr << "outline";
5637 colorStr << QString::number(r);
5638 colorStr << QString::number(g);
5639 colorStr << QString::number(b);
5641 aSmeshActor->Get0DColor(r, g, b);
5642 colorStr << "elem0d";
5643 colorStr << QString::number(r);
5644 colorStr << QString::number(g);
5645 colorStr << QString::number(b);
5647 aSmeshActor->GetBallColor(r, g, b);
5649 colorStr << QString::number(r);
5650 colorStr << QString::number(g);
5651 colorStr << QString::number(b);
5653 aSmeshActor->GetFacesOrientationColor(r, g, b);
5654 colorStr << "orientation";
5655 colorStr << QString::number(r);
5656 colorStr << QString::number(g);
5657 colorStr << QString::number(b);
5659 param = vtkParam + "Colors";
5660 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5663 QStringList sizeStr;
5665 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5666 sizeStr << "outline";
5667 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5668 sizeStr << "elem0d";
5669 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5671 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5672 sizeStr << "shrink";
5673 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5674 sizeStr << "orientation";
5675 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5676 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5678 param = vtkParam + "Sizes";
5679 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5684 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5685 if( aMarkerType == VTK::MT_USER ) {
5686 markerStr += "custom";
5687 markerStr += gDigitsSep;
5688 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5692 markerStr += gDigitsSep;
5693 markerStr += QString::number( (int)aMarkerType );
5694 markerStr += gDigitsSep;
5695 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5698 param = vtkParam + "PointMarker";
5699 ip->setParameter(entry, param, markerStr.toLatin1().data());
5702 param = vtkParam + "Opacity";
5703 ip->setParameter(entry, param,
5704 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5707 param = vtkParam + "ClippingPlane";
5709 if( !aClippingPlaneInfoList.empty() ) {
5710 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5711 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5713 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5714 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5715 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5716 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5717 if( aSmeshActor == *anIter2 ) {
5718 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5719 QString::number( anId ).toLatin1().constData() );
5726 ip->setParameter( entry, param, "Off" );
5727 } // if (io->hasEntry())
5728 } // SMESH_Actor && hasIO
5730 } // while.. actors traversal
5734 } // if (SVTK view model)
5735 } // for (viewManagers)
5738 // data structures for clipping planes processing
5741 vtkIdType Orientation;
5745 typedef std::list<TPlaneData> TPlaneDataList;
5746 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5748 typedef std::list<vtkActor*> TActorList;
5751 TActorList ActorList;
5752 SUIT_ViewManager* ViewManager;
5754 typedef std::list<TPlaneInfo> TPlaneInfoList;
5755 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5758 * \brief Restore visual parameters
5760 * This method is called after the study document is opened.
5761 * Restore visual parameters from AttributeParameter attribue(s)
5763 void SMESHGUI::restoreVisualParameters (int savePoint)
5766 Kernel_Utils::Localizer loc;
5768 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5769 if (!appStudy || !appStudy->studyDS())
5771 _PTR(Study) studyDS = appStudy->studyDS();
5773 // componentName is used for encoding of entries when storing them in IParameters
5774 std::string componentName = myComponentSMESH->ComponentDataType();
5775 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5776 //if (!aSComponent) return;
5779 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5780 componentName.c_str(),
5782 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5784 // restore map of custom markers and map of clipping planes
5785 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5786 TPlaneDataMap aPlaneDataMap;
5788 std::vector<std::string> properties = ip->getProperties();
5789 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5791 std::string property = *propIt;
5792 QString aPropertyName( property.c_str() );
5793 QString aPropertyValue( ip->getProperty( property ).c_str() );
5795 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5796 if( aPropertyNameList.isEmpty() )
5799 QString aPropertyType = aPropertyNameList[0];
5800 if( aPropertyType == "texture" )
5802 if( aPropertyNameList.size() != 2 )
5806 int anId = aPropertyNameList[1].toInt( &ok );
5807 if( !ok || anId < 1 )
5810 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5811 if( aPropertyValueList.size() != 2 )
5814 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5815 QString aMarkerTextureString = aPropertyValueList[1];
5816 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5817 if( aMarkerTextureStringList.size() != 3 )
5821 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5826 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5830 VTK::MarkerTexture aMarkerTexture;
5831 aMarkerTexture.push_back( aWidth );
5832 aMarkerTexture.push_back( aHeight );
5834 QString aMarkerTextureData = aMarkerTextureStringList[2];
5835 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5837 QChar aChar = aMarkerTextureData.at( i );
5838 if( aChar.isDigit() )
5839 aMarkerTexture.push_back( aChar.digitValue() );
5842 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5844 else if( aPropertyType == "ClippingPlane" )
5846 if( aPropertyNameList.size() != 3 )
5850 int aViewId = aPropertyNameList[1].toInt( &ok );
5851 if( !ok || aViewId < 0 )
5855 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5856 if( !ok || aClippingPlaneId < 0 )
5859 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5860 if( aPropertyValueList.size() != 4 )
5863 TPlaneData aPlaneData;
5864 aPlaneData.Id = aClippingPlaneId;
5867 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5872 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5877 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5882 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5886 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5887 aPlaneDataList.push_back( aPlaneData );
5891 TPlaneInfoMap aPlaneInfoMap;
5893 std::vector<std::string> entries = ip->getEntries();
5895 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5897 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5898 QString entry (ip->decodeEntry(*entIt).c_str());
5900 // Check that the entry corresponds to a real object in the Study
5901 // as the object may be deleted or modified after the visual state is saved.
5902 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5903 if (!so) continue; //Skip the not existent entry
5905 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5906 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5908 std::vector<std::string>::iterator namesIt = paramNames.begin();
5909 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5911 // actors are stored in a map after displaying of them for
5912 // quicker access in the future: map < viewID to actor >
5913 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5915 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5917 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5918 // '_' is used as separator and should not be used in viewer type or parameter names.
5919 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5920 if (lst.size() != 3)
5923 QString viewerTypStr = lst[0];
5924 QString viewIndexStr = lst[1];
5925 QString paramNameStr = lst[2];
5928 int viewIndex = viewIndexStr.toUInt(&ok);
5929 if (!ok) // bad conversion of view index to integer
5933 if (viewerTypStr == SVTK_Viewer::Type())
5935 SMESH_Actor* aSmeshActor = 0;
5936 if (vtkActors.IsBound(viewIndex))
5937 aSmeshActor = vtkActors.Find(viewIndex);
5939 QList<SUIT_ViewManager*> lst;
5940 getApp()->viewManagers(viewerTypStr, lst);
5942 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5943 SUIT_ViewManager* vman = NULL;
5944 if (viewIndex >= 0 && viewIndex < lst.count())
5945 vman = lst.at(viewIndex);
5947 if (paramNameStr == "Visibility")
5949 if (!aSmeshActor && displayer() && vman)
5951 SUIT_ViewModel* vmodel = vman->getViewModel();
5952 // SVTK view model can be casted to SALOME_View
5953 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5955 // store displayed actor in a temporary map for quicker
5956 // access later when restoring other parameters
5957 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5958 vtkRenderer* Renderer = vtkView->getRenderer();
5959 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5960 vtkActorCollection* theActors = aCopy.GetActors();
5961 theActors->InitTraversal();
5962 bool isFound = false;
5963 vtkActor *ac = theActors->GetNextActor();
5964 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5965 if (ac->IsA("SMESH_Actor")) {
5966 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5967 if (aGeomAc->hasIO()) {
5968 Handle(SALOME_InteractiveObject) io =
5969 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5970 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5972 vtkActors.Bind(viewIndex, aGeomAc);
5978 } // if (paramNameStr == "Visibility")
5981 // the rest properties "work" with SMESH_Actor
5984 QString val ((*valuesIt).c_str());
5987 if (paramNameStr == "Representation") {
5988 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5991 else if (paramNameStr == "IsShrunk") {
5993 if (!aSmeshActor->IsShrunk())
5994 aSmeshActor->SetShrink();
5997 if (aSmeshActor->IsShrunk())
5998 aSmeshActor->UnShrink();
6001 // Displayed entities
6002 else if (paramNameStr == "Entities") {
6003 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6004 int aEntityMode = SMESH_Actor::eAllEntity;
6005 for ( int i = 0; i < mode.count(); i+=2 ) {
6006 if ( i < mode.count()-1 ) {
6007 QString type = mode[i];
6008 bool val = mode[i+1].toInt();
6009 if ( type == "e" && !val )
6010 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6011 else if ( type == "f" && !val )
6012 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6013 else if ( type == "v" && !val )
6014 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6015 else if ( type == "0d" && !val )
6016 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6017 else if ( type == "b" && !val )
6018 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6021 aSmeshActor->SetEntityMode( aEntityMode );
6024 else if (paramNameStr == "Colors") {
6025 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6032 QColor outlineColor;
6033 QColor orientationColor;
6039 // below lines are required to get default values for delta coefficients
6040 // of backface color for faces and color of reversed volumes
6041 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6042 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6043 for ( int i = 0; i < colors.count(); i++ ) {
6044 QString type = colors[i];
6045 if ( type == "surface" ) {
6046 // face color is set by 3 values r:g:b, where
6047 // - r,g,b - is rgb color components
6048 if ( i+1 >= colors.count() ) break; // format error
6049 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6050 if ( i+2 >= colors.count() ) break; // format error
6051 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6052 if ( i+3 >= colors.count() ) break; // format error
6053 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6054 faceColor.setRgbF( r, g, b );
6057 else if ( type == "backsurface" ) {
6058 // backface color can be defined in several ways
6059 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6060 // - in latest versions, it is set as delta coefficient
6061 bool rgbOk = false, deltaOk;
6062 if ( i+1 >= colors.count() ) break; // format error
6063 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6064 int delta = colors[i+1].toInt( &deltaOk );
6066 if ( i+1 < colors.count() ) // index is shifted to 1
6067 g = colors[i+1].toDouble( &rgbOk );
6068 if ( rgbOk ) i++; // shift index
6069 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6070 b = colors[i+1].toDouble( &rgbOk );
6072 // - as currently there's no way to set directly backsurface color as it was before,
6073 // we ignore old dump where r,g,b triple was set
6074 // - also we check that delta parameter is set properly
6075 if ( !rgbOk && deltaOk )
6078 else if ( type == "volume" ) {
6079 // volume color is set by 4 values r:g:b:delta, where
6080 // - r,g,b - is a normal volume rgb color components
6081 // - delta - is a reversed volume color delta coefficient
6082 if ( i+1 >= colors.count() ) break; // format error
6083 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6084 if ( i+2 >= colors.count() ) break; // format error
6085 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6086 if ( i+3 >= colors.count() ) break; // format error
6087 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6088 if ( i+4 >= colors.count() ) break; // format error
6089 int delta = colors[i+4].toInt( &bOk );
6090 if ( !bOk ) break; // format error
6091 volumeColor.setRgbF( r, g, b );
6095 else if ( type == "edge" ) {
6096 // edge color is set by 3 values r:g:b, where
6097 // - r,g,b - is rgb color components
6098 if ( i+1 >= colors.count() ) break; // format error
6099 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6100 if ( i+2 >= colors.count() ) break; // format error
6101 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6102 if ( i+3 >= colors.count() ) break; // format error
6103 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6104 edgeColor.setRgbF( r, g, b );
6107 else if ( type == "node" ) {
6108 // node color is set by 3 values r:g:b, where
6109 // - r,g,b - is rgb color components
6110 if ( i+1 >= colors.count() ) break; // format error
6111 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6112 if ( i+2 >= colors.count() ) break; // format error
6113 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6114 if ( i+3 >= colors.count() ) break; // format error
6115 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6116 nodeColor.setRgbF( r, g, b );
6119 else if ( type == "elem0d" ) {
6120 // 0d element color is set by 3 values r:g:b, where
6121 // - r,g,b - is rgb color components
6122 if ( i+1 >= colors.count() ) break; // format error
6123 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6124 if ( i+2 >= colors.count() ) break; // format error
6125 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6126 if ( i+3 >= colors.count() ) break; // format error
6127 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6128 elem0dColor.setRgbF( r, g, b );
6131 else if ( type == "ball" ) {
6132 // ball color is set by 3 values r:g:b, where
6133 // - r,g,b - is rgb color components
6134 if ( i+1 >= colors.count() ) break; // format error
6135 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6136 if ( i+2 >= colors.count() ) break; // format error
6137 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6138 if ( i+3 >= colors.count() ) break; // format error
6139 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6140 ballColor.setRgbF( r, g, b );
6143 else if ( type == "outline" ) {
6144 // outline color is set by 3 values r:g:b, where
6145 // - r,g,b - is rgb color components
6146 if ( i+1 >= colors.count() ) break; // format error
6147 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6148 if ( i+2 >= colors.count() ) break; // format error
6149 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6150 if ( i+3 >= colors.count() ) break; // format error
6151 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6152 outlineColor.setRgbF( r, g, b );
6155 else if ( type == "orientation" ) {
6156 // orientation color is set by 3 values r:g:b, where
6157 // - r,g,b - is rgb color components
6158 if ( i+1 >= colors.count() ) break; // format error
6159 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6160 if ( i+2 >= colors.count() ) break; // format error
6161 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6162 if ( i+3 >= colors.count() ) break; // format error
6163 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6164 orientationColor.setRgbF( r, g, b );
6169 if ( nodeColor.isValid() )
6170 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6172 if ( edgeColor.isValid() )
6173 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6175 if ( faceColor.isValid() )
6176 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6178 if ( volumeColor.isValid() )
6179 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6180 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6181 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6183 if ( elem0dColor.isValid() )
6184 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6186 if ( ballColor.isValid() )
6187 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6189 if ( outlineColor.isValid() )
6190 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6191 // orientation color
6192 if ( orientationColor.isValid() )
6193 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6196 else if (paramNameStr == "Sizes") {
6197 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6200 int outlineWidth = -1;
6201 int elem0dSize = -1;
6203 double shrinkSize = -1;
6204 double orientationSize = -1;
6205 bool orientation3d = false;
6206 for ( int i = 0; i < sizes.count(); i++ ) {
6207 QString type = sizes[i];
6208 if ( type == "line" ) {
6209 // line (wireframe) width is given as single integer value
6210 if ( i+1 >= sizes.count() ) break; // format error
6211 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6215 if ( type == "outline" ) {
6216 // outline width is given as single integer value
6217 if ( i+1 >= sizes.count() ) break; // format error
6218 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6222 else if ( type == "elem0d" ) {
6223 // 0d element size is given as single integer value
6224 if ( i+1 >= sizes.count() ) break; // format error
6225 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6229 else if ( type == "ball" ) {
6230 // ball size is given as single integer value
6231 if ( i+1 >= sizes.count() ) break; // format error
6232 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6236 else if ( type == "shrink" ) {
6237 // shrink factor is given as single floating point value
6238 if ( i+1 >= sizes.count() ) break; // format error
6239 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6243 else if ( type == "orientation" ) {
6244 // orientation vectors are specified by two values size:3d, where
6245 // - size - is a floating point value specifying scale factor
6246 // - 3d - is a boolean
6247 if ( i+1 >= sizes.count() ) break; // format error
6248 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6249 if ( i+2 >= sizes.count() ) break; // format error
6250 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6251 orientationSize = v1;
6252 orientation3d = (bool)v2;
6256 // line (wireframe) width
6257 if ( lineWidth > 0 )
6258 aSmeshActor->SetLineWidth( lineWidth );
6260 if ( outlineWidth > 0 )
6261 aSmeshActor->SetOutlineWidth( outlineWidth );
6262 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6263 aSmeshActor->SetOutlineWidth( lineWidth );
6265 if ( elem0dSize > 0 )
6266 aSmeshActor->Set0DSize( elem0dSize );
6269 aSmeshActor->SetBallSize( ballSize );
6271 if ( shrinkSize > 0 )
6272 aSmeshActor->SetShrinkFactor( shrinkSize );
6273 // orientation vectors
6274 if ( orientationSize > 0 ) {
6275 aSmeshActor->SetFacesOrientationScale( orientationSize );
6276 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6280 else if (paramNameStr == "PointMarker") {
6281 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6282 if( data.count() >= 2 ) {
6284 int aParam1 = data[1].toInt( &ok );
6286 if( data[0] == "std" && data.count() == 3 ) {
6287 int aParam2 = data[2].toInt( &ok );
6288 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6290 else if( data[0] == "custom" ) {
6291 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6292 if( markerIt != aMarkerMap.end() ) {
6293 VTK::MarkerData aMarkerData = markerIt->second;
6294 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6301 else if (paramNameStr == "Opacity") {
6302 aSmeshActor->SetOpacity(val.toFloat());
6305 else if (paramNameStr.startsWith("ClippingPlane")) {
6306 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6307 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
6308 // new format - val looks like "Off" or "0" (plane id)
6309 // (note: in new format "Off" value is used only for consistency,
6310 // so it is processed together with values in old format)
6311 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
6312 if( anIsOldFormat ) {
6313 if (paramNameStr == "ClippingPlane1" || val == "Off")
6314 aSmeshActor->RemoveAllClippingPlanes();
6316 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
6317 double aDistance = vals[1].toFloat();
6319 anAngle[0] = vals[2].toFloat();
6320 anAngle[1] = vals[3].toFloat();
6322 QList<SUIT_ViewManager*> lst;
6323 getApp()->viewManagers(viewerTypStr, lst);
6324 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6325 if (viewIndex >= 0 && viewIndex < lst.count()) {
6326 SUIT_ViewManager* vman = lst.at(viewIndex);
6327 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6329 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6331 SMESH::TActorList anActorList;
6332 anActorList.push_back( aSmeshActor );
6333 SMESH::OrientedPlane* aPlane =
6334 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
6336 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6337 aClippingPlaneInfo.Plane = aPlane;
6338 aClippingPlaneInfo.ActorList = anActorList;
6339 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6346 int aPlaneId = val.toInt( &ok );
6347 if( ok && aPlaneId >= 0 ) {
6348 bool anIsDefinedPlane = false;
6349 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6350 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6351 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6352 TPlaneInfo& aPlaneInfo = *anIter;
6353 if( aPlaneInfo.PlaneId == aPlaneId ) {
6354 aPlaneInfo.ActorList.push_back( aSmeshActor );
6355 anIsDefinedPlane = true;
6359 if( !anIsDefinedPlane ) {
6360 TPlaneInfo aPlaneInfo;
6361 aPlaneInfo.PlaneId = aPlaneId;
6362 aPlaneInfo.ActorList.push_back( aSmeshActor );
6363 aPlaneInfo.ViewManager = vman;
6365 // to make the list sorted by plane id
6366 anIter = aPlaneInfoList.begin();
6367 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6368 const TPlaneInfo& aPlaneInfoRef = *anIter;
6369 if( aPlaneInfoRef.PlaneId > aPlaneId )
6372 aPlaneInfoList.insert( anIter, aPlaneInfo );
6377 } // if (aSmeshActor)
6378 } // other parameters than Visibility
6380 } // for names/parameters iterator
6381 } // for entries iterator
6383 // take into account planes with empty list of actors referred to them
6384 QList<SUIT_ViewManager*> aVMList;
6385 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6387 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6388 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6389 int aViewId = aPlaneDataIter->first;
6390 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6391 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6393 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6395 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6396 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6397 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6398 const TPlaneData& aPlaneData = *anIter2;
6399 int aPlaneId = aPlaneData.Id;
6401 bool anIsFound = false;
6402 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6403 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6404 const TPlaneInfo& aPlaneInfo = *anIter3;
6405 if( aPlaneInfo.PlaneId == aPlaneId ) {
6412 TPlaneInfo aPlaneInfo; // ActorList field is empty
6413 aPlaneInfo.PlaneId = aPlaneId;
6414 aPlaneInfo.ViewManager = aViewManager;
6416 // to make the list sorted by plane id
6417 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6418 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6419 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6420 if( aPlaneInfoRef.PlaneId > aPlaneId )
6423 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6429 // add clipping planes to actors according to the restored parameters
6430 // and update the clipping plane map
6431 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6432 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6433 int aViewId = anIter1->first;
6434 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6436 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6437 if( anIter2 == aPlaneDataMap.end() )
6439 const TPlaneDataList& aPlaneDataList = anIter2->second;
6441 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6442 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6443 const TPlaneInfo& aPlaneInfo = *anIter3;
6444 int aPlaneId = aPlaneInfo.PlaneId;
6445 const TActorList& anActorList = aPlaneInfo.ActorList;
6446 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6450 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6454 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6456 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6457 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6458 const TPlaneData& aPlaneData = *anIter4;
6459 if( aPlaneData.Id == aPlaneId ) {
6460 SMESH::OrientedPlane* aPlane =
6461 SMESHGUI_ClippingDlg::AddPlane( anActorList,
6463 (SMESH::Orientation)aPlaneData.Orientation,
6464 aPlaneData.Distance,
6467 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6468 aClippingPlaneInfo.Plane = aPlane;
6469 aClippingPlaneInfo.ActorList = anActorList;
6470 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6478 // update all VTK views
6479 QList<SUIT_ViewManager*> lst;
6480 getApp()->viewManagers(lst);
6481 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6482 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6483 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6484 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6485 vtkView->getRenderer()->ResetCameraClippingRange();
6492 \brief Adds preferences for dfont of VTK viewer
6494 \param pIf group identifier
6495 \param param parameter
6496 \return identifier of preferences
6498 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6500 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6502 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6505 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6506 fam.append( tr( "SMESH_FONT_COURIER" ) );
6507 fam.append( tr( "SMESH_FONT_TIMES" ) );
6509 setPreferenceProperty( tfont, "fonts", fam );
6511 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6512 if ( needSize ) f = f | QtxFontEdit::Size;
6513 setPreferenceProperty( tfont, "features", f );
6519 \brief Actions after hypothesis edition
6520 Updates object browser after hypothesis edition
6522 void SMESHGUI::onHypothesisEdit( int result )
6525 SMESHGUI::Modified();
6526 updateObjBrowser( true );
6531 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6532 \param pview view being closed
6534 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6535 #ifndef DISABLE_PLOT2DVIEWER
6536 //Crear all Plot2d Viewers if need.
6537 SMESH::ClearPlot2Viewers(pview);
6541 void SMESHGUI::message( const QString& msg )
6544 QStringList data = msg.split("/");
6545 if ( data.count() > 0 ) {
6546 if ( data.first() == "mesh_loading" ) {
6548 QString entry = data.count() > 1 ? data[1] : QString();
6549 if ( entry.isEmpty() )
6552 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6554 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6557 name = obj->GetName().c_str();
6558 if ( name.isEmpty() )
6561 if ( data.last() == "stop" )
6562 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6564 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6565 QApplication::processEvents();
6571 \brief Connects or disconnects signals about activating and cloning view on the module slots
6572 \param pview view which is connected/disconnected
6574 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6578 SUIT_ViewManager* viewMgr = pview->getViewManager();
6580 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6581 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6583 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6584 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6589 \brief Return \c true if object can be renamed
6591 bool SMESHGUI::renameAllowed( const QString& entry) const {
6592 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6596 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6600 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6605 if(appStudy->isComponent(entry) || obj->isReference())
6608 // check type to prevent renaming of inappropriate objects
6609 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6610 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6611 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6612 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6613 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6614 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6621 Rename object by entry.
6622 \param entry entry of the object
6623 \param name new name of the object
6624 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6626 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6628 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6632 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6637 _PTR(Study) aStudy = appStudy->studyDS();
6642 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6644 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6649 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6650 _PTR(GenericAttribute) anAttr;
6651 _PTR(AttributeName) aName;
6653 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6655 // check type to prevent renaming of inappropriate objects
6656 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6657 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6658 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6659 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6660 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6661 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6662 if ( !name.isEmpty() ) {
6663 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6665 // update name of group object and its actor
6666 Handle(SALOME_InteractiveObject) IObject =
6667 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6669 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6670 if( !aGroupObject->_is_nil() ) {
6671 aGroupObject->SetName( qPrintable(name) );
6672 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6673 anActor->setName( qPrintable(name) );
6684 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
6686 static QList<QColor> colors;
6688 if ( colors.isEmpty() ) {
6690 for (int s = 0; s < 2 ; s++)
6692 for (int v = 100; v >= 40; v = v - 20)
6694 for (int h = 0; h < 359 ; h = h + 60)
6696 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
6701 static int currentColor = 0;
6703 SALOMEDS::Color color;
6704 color.R = (double)colors[currentColor].red() / 255.0;
6705 color.G = (double)colors[currentColor].green() / 255.0;
6706 color.B = (double)colors[currentColor].blue() / 255.0;
6708 currentColor = (currentColor+1) % colors.count();