1 // Copyright (C) 2007-2011 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
29 #include "SMESHGUI_AddMeshElementDlg.h"
30 #include "SMESHGUI_AddQuadraticElementDlg.h"
31 #include "SMESHGUI_BuildCompoundDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_ComputeDlg.h"
34 #include "SMESHGUI_ConvToQuadOp.h"
35 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
36 #include "SMESHGUI_DeleteGroupDlg.h"
37 #include "SMESHGUI_Displayer.h"
38 #include "SMESHGUI_MergeDlg.h"
39 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
40 #include "SMESHGUI_ExtrusionDlg.h"
41 #include "SMESHGUI_FileInfoDlg.h"
42 #include "SMESHGUI_FileValidator.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_FindElemByPointDlg.h"
46 #include "SMESHGUI_GroupDlg.h"
47 #include "SMESHGUI_GroupOnShapeDlg.h"
48 #include "SMESHGUI_GroupOpDlg.h"
49 #include "SMESHGUI_Hypotheses.h"
50 #include "SMESHGUI_Make2DFrom3DOp.h"
51 #include "SMESHGUI_MakeNodeAtPointDlg.h"
52 //#include "SMESHGUI_MeshInfosDlg.h"
53 #include "SMESHGUI_Measurements.h"
54 #include "SMESHGUI_MeshInfo.h"
55 #include "SMESHGUI_MeshOp.h"
56 #include "SMESHGUI_MeshOrderOp.h"
57 #include "SMESHGUI_MeshPatternDlg.h"
58 #include "SMESHGUI_MultiEditDlg.h"
59 #include "SMESHGUI_NodesDlg.h"
60 #include "SMESHGUI_Preferences_ColorDlg.h"
61 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
62 #include "SMESHGUI_RemoveElementsDlg.h"
63 #include "SMESHGUI_RemoveNodesDlg.h"
64 #include "SMESHGUI_RenumberingDlg.h"
65 #include "SMESHGUI_RevolutionDlg.h"
66 #include "SMESHGUI_RotationDlg.h"
67 #include "SMESHGUI_Selection.h"
68 #include "SMESHGUI_SewingDlg.h"
69 #include "SMESHGUI_SingleEditDlg.h"
70 #include "SMESHGUI_SmoothingDlg.h"
71 //#include "SMESHGUI_StandardMeshInfosDlg.h"
72 #include "SMESHGUI_SymmetryDlg.h"
73 #include "SMESHGUI_TranslationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_TransparencyDlg.h"
76 //#include "SMESHGUI_WhatIsDlg.h"
77 #include "SMESHGUI_DuplicateNodesDlg.h"
78 #include "SMESHGUI_CopyMeshDlg.h"
80 #include "SMESHGUI_Utils.h"
81 #include "SMESHGUI_MeshUtils.h"
82 #include "SMESHGUI_GroupUtils.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_PatternUtils.h"
85 #include "SMESHGUI_VTKUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
88 #include <SMESH_version.h>
90 #include <SMESH_Client.hxx>
91 #include <SMESH_Actor.h>
92 #include <SMESH_ScalarBarActor.h>
93 #include <SMESH_ActorUtils.h>
94 #include <SMESH_TypeFilter.hxx>
95 #include "SMESH_ControlsDef.hxx"
97 // SALOME GUI includes
98 #include <SalomeApp_Tools.h>
99 #include <SalomeApp_Study.h>
100 #include <SalomeApp_Application.h>
101 #include <SalomeApp_CheckFileDlg.h>
103 #include <LightApp_DataOwner.h>
104 #include <LightApp_Preferences.h>
105 #include <LightApp_SelectionMgr.h>
106 #include <LightApp_UpdateFlags.h>
107 #include <LightApp_NameDlg.h>
109 #include <SVTK_ViewWindow.h>
110 #include <SVTK_ViewModel.h>
111 #include <SVTK_ViewManager.h>
113 #include <VTKViewer_Algorithm.h>
115 #include <SUIT_MessageBox.h>
116 #include <SUIT_ResourceMgr.h>
117 #include <SUIT_FileDlg.h>
118 #include <SUIT_Desktop.h>
119 #include <SUIT_OverrideCursor.h>
120 #include <SUIT_Session.h>
122 #include <QtxPopupMgr.h>
123 #include <QtxFontEdit.h>
125 #include <SALOME_ListIO.hxx>
126 #include <SALOME_ListIteratorOfListIO.hxx>
128 #ifndef DISABLE_PLOT2DVIEWER
129 #include <SPlot2d_ViewModel.h>
130 #include <SPlot2d_Histogram.h>
134 #include <SALOMEconfig.h>
135 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
136 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
137 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
140 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
142 #include <QTextStream>
145 #include <boost/shared_ptr.hpp>
148 #include <vtkCamera.h>
149 #include <vtkRenderer.h>
150 #include <vtkPlane.h>
151 #include <vtkCallbackCommand.h>
152 #include <vtkLookupTable.h>
154 // SALOME KERNEL includes
155 #include <SALOMEDS_Study.hxx>
156 #include <SALOMEDSClient_StudyBuilder.hxx>
157 #include <SALOMEDSClient_SComponent.hxx>
158 #include <SALOMEDSClient_ClientFactory.hxx>
159 #include <SALOMEDSClient_IParameters.hxx>
162 #include <Standard_ErrorHandler.hxx>
163 #include <NCollection_DataMap.hxx>
165 //To disable automatic genericobj management, the following line should be commented.
166 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
167 #define WITHGENERICOBJ
171 //=============================================================
172 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
175 void ExportMeshToFile(int theCommandID);
177 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
179 void SetDisplayEntity(int theCommandID);
181 void Control( int theCommandID );
185 //=============================================================
186 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
190 std::string myExtension;
192 if ( theCommandID == 113 ) {
193 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
194 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
196 else if ( theCommandID == 112 ) {
197 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
199 else if ( theCommandID == 111 ) {
200 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
202 else if ( theCommandID == 115 ) {
203 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
205 else if ( theCommandID == 116 ) {
206 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
209 QString anInitialPath = "";
210 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
211 anInitialPath = QDir::currentPath();
213 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
216 QObject::tr( "SMESH_IMPORT_MESH" ) );
217 if ( filenames.count() > 0 ) {
218 SUIT_OverrideCursor wc;
219 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
222 QStringList anEntryList;
223 bool isEmpty = false;
224 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
225 QString filename = *it;
226 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
228 switch ( theCommandID ) {
231 // DAT format (currently unsupported)
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
239 aMeshes->length( 1 );
240 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
241 if ( aMeshes[0]->_is_nil() )
242 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
243 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
249 SMESH::DriverMED_ReadStatus res;
250 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
251 if ( res != SMESH::DRS_OK ) {
252 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
253 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
260 aMeshes->length( 1 );
261 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
262 if ( aMeshes[0]->_is_nil() ) {
263 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
264 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
271 SMESH::DriverMED_ReadStatus res;
272 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
273 if ( res != SMESH::DRS_OK ) {
274 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
275 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
281 catch ( const SALOME::SALOME_Exception& S_ex ) {
282 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
283 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
286 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
287 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
289 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
290 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
291 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
292 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
293 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
295 anEntryList.append( aMeshSO->GetID().c_str() );
297 #ifdef WITHGENERICOBJ
298 // obj has been published in study. Its refcount has been incremented.
299 // It is safe to decrement its refcount
300 // so that it will be destroyed when the entry in study will be removed
301 aMeshes[i]->UnRegister();
310 // update Object browser
311 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
313 // browse to the published meshes
314 if( LightApp_Application* anApp =
315 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
316 anApp->browseObjects( anEntryList );
318 // show Error message box if there were errors
319 if ( errors.count() > 0 ) {
320 SUIT_MessageBox::critical( SMESHGUI::desktop(),
321 QObject::tr( "SMESH_ERROR" ),
322 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
325 // show warning message box, if some imported mesh is empty
327 SUIT_MessageBox::warning( SMESHGUI::desktop(),
328 QObject::tr( "SMESH_WRN_WARNING" ),
329 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
334 //================================================================================
336 * \brief Export selected meshes or groups into a file
338 //================================================================================
340 void ExportMeshToFile( int theCommandID )
342 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
343 SALOME_ListIO selected;
345 aSel->selectedObjects( selected );
347 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
348 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
349 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
350 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
351 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
353 // actually, the following condition can't be met (added for insurance)
354 if( selected.Extent() == 0 ||
355 ( selected.Extent() > 1 && !isMED && !isSTL ))
358 // get mesh object from selection and check duplication of their names
359 bool hasDuplicatedMeshNames = false;
360 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
361 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
362 SALOME_ListIteratorOfListIO It( selected );
363 for( ; It.More(); It.Next() )
365 Handle(SALOME_InteractiveObject) anIObject = It.Value();
366 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
367 if ( aMeshItem->_is_nil() ) {
368 SUIT_MessageBox::warning( SMESHGUI::desktop(),
369 QObject::tr( "SMESH_WRN_WARNING" ),
370 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
374 QString aMeshName = anIObject->getName();
376 // check for name duplications
377 if ( !hasDuplicatedMeshNames )
378 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
379 if( aMeshName == (*aMeshIter).second ) {
380 hasDuplicatedMeshNames = true;
385 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
388 if( hasDuplicatedMeshNames && isMED ) {
389 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
390 QObject::tr("SMESH_WRN_WARNING"),
391 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
392 QObject::tr("SMESH_BUT_YES"),
393 QObject::tr("SMESH_BUT_NO"), 0, 1);
398 aMeshIter = aMeshList.begin();
399 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
400 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
401 QString aMeshName = (*aMeshIter).second;
403 if ( isMED || isCGNS )
405 // check for equal group names within each mesh
406 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
407 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
408 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
409 int aRet = SUIT_MessageBox::warning
410 (SMESHGUI::desktop(),
411 QObject::tr("SMESH_WRN_WARNING"),
412 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
413 QObject::tr("SMESH_BUT_YES"),
414 QObject::tr("SMESH_BUT_NO"), 0, 1);
422 // warn the user about presence of not supported elements
423 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
424 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
425 if ( nbPyramids > 0 ) {
426 int aRet = SUIT_MessageBox::warning
427 (SMESHGUI::desktop(),
428 QObject::tr("SMESH_WRN_WARNING"),
429 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
430 QObject::tr("SMESH_BUT_YES"),
431 QObject::tr("SMESH_BUT_NO"), 0, 1);
437 // Get parameters of export operation
440 SMESH::MED_VERSION aFormat;
441 // Init the parameters with the default values
442 bool aIsASCII_STL = true;
443 bool toCreateGroups = false;
444 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
446 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
447 bool toOverwrite = true;
449 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
450 QString anInitialPath = "";
451 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
452 anInitialPath = QDir::currentPath();
454 if ( isUNV || isDAT )
457 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
459 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
460 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
461 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
462 anInitialPath + QString("/") + aMeshName,
463 aFilter, aTitle, false);
465 else if ( isCGNS )// Export to CGNS
467 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
468 fd->setWindowTitle( aTitle );
469 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
470 if ( !anInitialPath.isEmpty() )
471 fd->setDirectory( anInitialPath );
472 fd->selectFile(aMeshName);
473 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
474 fd->setValidator( fv );
477 aFilename = fd->selectedFile();
478 toOverwrite = fv->isOverwrite();
482 else if ( isSTL ) // Export to STL
484 QMap<QString, int> aFilterMap;
485 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
486 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
489 QMap<QString, int>::const_iterator it = aFilterMap.begin();
490 for ( ; it != aFilterMap.end(); ++it )
491 filters.push_back( it.key() );
493 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
494 fd->setWindowTitle( aTitle );
495 fd->setNameFilters( filters );
496 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
497 if ( !anInitialPath.isEmpty() )
498 fd->setDirectory( anInitialPath );
499 fd->selectFile(aMeshName);
503 aFilename = fd->selectedFile();
504 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
509 else if ( isMED ) // Export to MED
511 QMap<QString, SMESH::MED_VERSION> aFilterMap;
512 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
513 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
514 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
515 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
518 QString aDefaultFilter;
519 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
520 for ( ; it != aFilterMap.end(); ++it ) {
521 filters.push_back( it.key() );
522 if (it.value() == SMESH::MED_V2_2)
523 aDefaultFilter = it.key();
526 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
527 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
528 fd->setWindowTitle( aTitle );
529 fd->setNameFilters( filters );
530 fd->selectNameFilter(aDefaultFilter);
531 fd->SetChecked(toCreateGroups);
532 if ( !anInitialPath.isEmpty() )
533 fd->setDirectory( anInitialPath );
534 fd->selectFile(aMeshName);
536 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
537 fd->setValidator( fv );
542 aFilename = fd->selectedFile();
544 aFilename = QString::null;
547 aFormat = aFilterMap[fd->selectedNameFilter()];
548 toOverwrite = fv->isOverwrite();
550 if ( !aFilename.isEmpty() ) {
551 // med-2.1 does not support poly elements
552 if ( aFormat==SMESH::MED_V2_1 )
553 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
554 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
555 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
556 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
557 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
559 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
560 QObject::tr("SMESH_WRN_WARNING"),
561 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
562 QObject::tr("SMESH_BUT_YES"),
563 QObject::tr("SMESH_BUT_NO"), 0, 1);
571 // can't append to an existing using other format
572 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
573 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
574 if( !isVersionOk || aVersion != aFormat ) {
575 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
576 QObject::tr("SMESH_WRN_WARNING"),
577 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
578 QObject::tr("SMESH_BUT_YES"),
579 QObject::tr("SMESH_BUT_NO"), 0, 1);
586 QStringList aMeshNamesCollisionList;
587 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
588 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
589 QString anExistingMeshName( aMeshNames[ i ] );
590 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
591 QString anExportMeshName = (*aMeshIter).second;
592 if( anExportMeshName == anExistingMeshName ) {
593 aMeshNamesCollisionList.append( anExportMeshName );
598 if( !aMeshNamesCollisionList.isEmpty() ) {
599 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
600 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
601 QObject::tr("SMESH_WRN_WARNING"),
602 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
603 QObject::tr("SMESH_BUT_YES"),
604 QObject::tr("SMESH_BUT_NO"),
605 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
614 toCreateGroups = fd->IsChecked();
624 if ( !aFilename.isEmpty() ) {
625 // Check whether the file already exists and delete it if yes
626 QFile aFile( aFilename );
627 if ( aFile.exists() && toOverwrite )
629 SUIT_OverrideCursor wc;
632 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
633 // bool Renumber = false;
634 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
636 // Renumber= resMgr->booleanValue("SMESH","renumbering");
638 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
639 // aMeshEditor->RenumberNodes();
640 // aMeshEditor->RenumberElements();
641 // if ( SMESHGUI::automaticUpdate() )
642 // SMESH::UpdateView();
646 aMeshIter = aMeshList.begin();
647 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
649 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
650 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
651 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
652 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
653 aFormat, toOverwrite && aMeshIndex == 0 );
655 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
656 aFormat, toOverwrite && aMeshIndex == 0 );
661 if ( aMeshOrGroup->_is_equivalent( aMesh ))
662 aMesh->ExportDAT( aFilename.toLatin1().data() );
664 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
668 if ( aMeshOrGroup->_is_equivalent( aMesh ))
669 aMesh->ExportUNV( aFilename.toLatin1().data() );
671 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
675 if ( aMeshOrGroup->_is_equivalent( aMesh ))
676 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
678 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
682 aMeshIter = aMeshList.begin();
683 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
685 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
686 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
687 aMeshItem->ExportCGNS( aMeshOrGroup,
688 aFilename.toLatin1().data(),
689 toOverwrite && aMeshIndex == 0 );
693 catch (const SALOME::SALOME_Exception& S_ex){
695 SUIT_MessageBox::warning(SMESHGUI::desktop(),
696 QObject::tr("SMESH_WRN_WARNING"),
697 QObject::tr("SMESH_EXPORT_FAILED"));
703 inline void InverseEntityMode(unsigned int& theOutputMode,
704 unsigned int theMode)
706 bool anIsNotPresent = ~theOutputMode & theMode;
708 theOutputMode |= theMode;
710 theOutputMode &= ~theMode;
713 void SetDisplayEntity(int theCommandID){
714 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
715 SALOME_ListIO selected;
717 aSel->selectedObjects( selected );
719 if(selected.Extent() >= 1){
720 SALOME_ListIteratorOfListIO It( selected );
721 for( ; It.More(); It.Next()){
722 Handle(SALOME_InteractiveObject) IObject = It.Value();
723 if(IObject->hasEntry()){
724 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
725 unsigned int aMode = anActor->GetEntityMode();
726 switch(theCommandID){
728 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
731 InverseEntityMode(aMode,SMESH_Actor::eEdges);
734 InverseEntityMode(aMode,SMESH_Actor::eFaces);
737 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
740 aMode = SMESH_Actor::eAllEntity;
744 anActor->SetEntityMode(aMode);
752 SALOME_ListIO selected;
753 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
757 LightApp_SelectionMgr* aSel = app->selectionMgr();
758 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
759 if( !aSel || !appStudy )
762 aSel->selectedObjects( selected );
763 if( selected.IsEmpty() )
766 Handle(SALOME_InteractiveObject) anIObject = selected.First();
768 _PTR(Study) aStudy = appStudy->studyDS();
769 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
770 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
771 if( aMainObject->_is_nil() )
774 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
776 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
777 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
779 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
780 SALOMEDS::Color aColor = aGroupObject->GetColor();
781 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
783 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
784 if( aGroupObject->GetType() == SMESH::NODE )
785 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
786 else if( aGroupObject->GetType() == SMESH::EDGE )
787 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
788 else if( aGroupObject->GetType() == SMESH::ELEM0D )
789 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
793 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
794 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
800 SMESH::RepaintCurrentView();
803 QString functorToString( SMESH::Controls::FunctorPtr f )
805 QString type = QObject::tr( "UNKNOWN_CONTROL" );
806 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
807 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
808 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
809 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
810 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
811 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
812 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
813 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
814 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
815 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
816 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
817 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
818 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
819 type = QObject::tr( "WARP_ELEMENTS" );
820 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
821 type = QObject::tr( "TAPER_ELEMENTS" );
822 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
823 type = QObject::tr( "SKEW_ELEMENTS" );
824 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
825 type = QObject::tr( "AREA_ELEMENTS" );
826 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
827 type = QObject::tr( "LENGTH_EDGES" );
828 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
829 type = QObject::tr( "LENGTH2D_EDGES" );
830 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
831 type = QObject::tr( "MULTI_BORDERS" );
832 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
833 type = QObject::tr( "MULTI2D_BORDERS" );
834 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
835 type = QObject::tr( "FREE_NODES" );
836 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
837 type = QObject::tr( "FREE_EDGES" );
838 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
839 type = QObject::tr( "FREE_BORDERS" );
840 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
841 type = QObject::tr( "FREE_FACES" );
842 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
843 type = QObject::tr( "BARE_BORDER_VOLUME" );
844 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
845 type = QObject::tr( "BARE_BORDER_FACE" );
846 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
847 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
848 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
849 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
853 void SaveDistribution()
855 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
856 SALOME_ListIO selected;
858 aSel->selectedObjects( selected );
860 if ( selected.Extent() == 1 ) {
861 Handle(SALOME_InteractiveObject) anIO = selected.First();
862 if ( anIO->hasEntry() ) {
863 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
864 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
865 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
866 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
867 if ( aScalarBarActor && aFunctor ) {
868 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
870 std::vector<int> elements;
871 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
872 if ( mesh->_is_nil() ) {
873 SMESH::SMESH_IDSource_var idSource =
874 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
875 if ( !idSource->_is_nil() )
877 SMESH::long_array_var ids = idSource->GetIDs();
878 elements.resize( ids->length() );
879 for ( unsigned i = 0; i < elements.size(); ++i )
880 elements[i] = ids[i];
883 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
884 vtkLookupTable* lookupTable =
885 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
886 double * minmax = lookupTable->GetRange();
887 std::vector<int> nbEvents;
888 std::vector<double> funValues;
889 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
890 QString anInitialPath = "";
891 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
892 anInitialPath = QDir::currentPath();
893 QString aMeshName = anIO->getName();
895 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
896 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
897 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
898 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
899 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
902 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
904 if ( !aFilename.isEmpty() ) {
905 QFile f( aFilename );
906 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
907 QTextStream out( &f );
908 out << "# Mesh: " << aMeshName << endl;
909 out << "# Control: " << functorToString( aFunctor ) << endl;
911 out.setFieldWidth( 10 );
912 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
913 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
924 void ShowDistribution() {
925 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
926 SALOME_ListIO selected;
928 aSel->selectedObjects( selected );
930 if ( selected.Extent() == 1 ) {
931 Handle(SALOME_InteractiveObject) anIO = selected.First();
932 if ( anIO->hasEntry() ) {
933 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
934 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
935 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
936 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
942 #ifndef DISABLE_PLOT2DVIEWER
943 void PlotDistribution() {
944 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
948 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
949 SALOME_ListIO selected;
951 aSel->selectedObjects( selected );
953 if ( selected.Extent() == 1 ) {
954 Handle(SALOME_InteractiveObject) anIO = selected.First();
955 if ( anIO->hasEntry() ) {
956 //Find Actor by entry before getting Plot2d viewer,
957 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
958 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
960 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
965 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
969 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
973 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
974 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
975 QString functorName = functorToString( anActor->GetFunctor());
976 QString aHistogramName("%1 : %2");
977 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
978 aHistogram->setName(aHistogramName);
979 aHistogram->setHorTitle(functorName);
980 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
981 aPlot->displayObject(aHistogram, true);
986 #endif //DISABLE_PLOT2DVIEWER
988 void DisableAutoColor(){
989 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
990 SALOME_ListIO selected;
992 aSel->selectedObjects( selected );
994 if(selected.Extent()){
995 Handle(SALOME_InteractiveObject) anIObject = selected.First();
996 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
997 if ( !aMesh->_is_nil() ) {
998 aMesh->SetAutoColor( false );
1003 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1004 SALOME_ListIO selected;
1005 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1009 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1010 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1011 if( !aSel || !appStudy )
1014 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1015 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1016 aModule->EmitSignalDeactivateDialog();
1017 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1018 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1023 _PTR(Study) aStudy = appStudy->studyDS();
1025 aSel->selectedObjects( selected );
1027 if(selected.Extent() >= 1){
1028 switch(theCommandID){
1030 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1031 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1035 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1039 vtkFloatingPointType Shrink = 0.0;
1040 vtkFloatingPointType faces_orientation_scale = 0.0;
1041 bool faces_orientation_3dvectors = false;
1043 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1044 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1045 int aMarkerTextureCurrent = 0;
1047 SALOME_ListIteratorOfListIO It( selected );
1048 for( ; It.More(); It.Next()){
1049 Handle(SALOME_InteractiveObject) IObject = It.Value();
1050 if(IObject->hasEntry()){
1051 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1052 vtkFloatingPointType color[3];
1053 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1054 int c0 = int (color[0] * 255);
1055 int c1 = int (color[1] * 255);
1056 int c2 = int (color[2] * 255);
1057 c.setRgb(c0, c1, c2);
1059 vtkFloatingPointType edgecolor[3];
1060 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1061 c0 = int (edgecolor[0] * 255);
1062 c1 = int (edgecolor[1] * 255);
1063 c2 = int (edgecolor[2] * 255);
1064 e.setRgb(c0, c1, c2);
1066 vtkFloatingPointType nodecolor[3];
1067 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1068 c0 = int (nodecolor[0] * 255);
1069 c1 = int (nodecolor[1] * 255);
1070 c2 = int (nodecolor[2] * 255);
1071 n.setRgb(c0, c1, c2);
1073 vtkFloatingPointType color0D[3];
1074 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1075 c0 = int (color0D[0] * 255);
1076 c1 = int (color0D[1] * 255);
1077 c2 = int (color0D[2] * 255);
1078 c0D.setRgb(c0, c1, c2);
1080 vtkFloatingPointType outlineColor[3];
1081 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1082 c0 = int (outlineColor[0] * 255);
1083 c1 = int (outlineColor[1] * 255);
1084 c2 = int (outlineColor[2] * 255);
1085 outl.setRgb(c0, c1, c2);
1087 vtkFloatingPointType hColor[3];
1088 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1089 c0 = int (hColor[0] * 255);
1090 c1 = int (hColor[1] * 255);
1091 c2 = int (hColor[2] * 255);
1092 selection.setRgb(c0, c1, c2);
1094 vtkFloatingPointType phColor[3];
1095 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1096 c0 = int (phColor[0] * 255);
1097 c1 = int (phColor[1] * 255);
1098 c2 = int (phColor[2] * 255);
1099 preselection.setRgb(c0, c1, c2);
1101 size0D = (int)anActor->Get0DSize();
1104 Edgewidth = (int)anActor->GetLineWidth();
1107 Shrink = anActor->GetShrinkFactor();
1109 vtkFloatingPointType faces_orientation_color[3];
1110 anActor->GetFacesOrientationColor(faces_orientation_color);
1111 c0 = int (faces_orientation_color[0] * 255);
1112 c1 = int (faces_orientation_color[1] * 255);
1113 c2 = int (faces_orientation_color[2] * 255);
1114 o.setRgb(c0, c1, c2);
1116 faces_orientation_scale = anActor->GetFacesOrientationScale();
1117 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1119 aMarkerTypeCurrent = anActor->GetMarkerType();
1120 aMarkerScaleCurrent = anActor->GetMarkerScale();
1121 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1123 // even if there are multiple objects in the selection,
1124 // we need only the first one to get values for the dialog
1130 SMESHGUI_Preferences_ColorDlg *aDlg =
1131 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1132 aDlg->SetColor(1, c);
1133 aDlg->SetColor(2, e);
1134 aDlg->SetColor(3, n);
1135 aDlg->SetColor(4, outl);
1136 aDlg->SetDeltaBrightness(delta);
1137 aDlg->SetColor(5, c0D);
1138 aDlg->SetColor(6, o);
1139 aDlg->SetIntValue(1, Edgewidth);
1140 aDlg->SetIntValue(2, int(Shrink*100.));
1141 aDlg->SetIntValue(3, size0D);
1142 aDlg->SetDoubleValue(1, faces_orientation_scale);
1143 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1144 aDlg->SetColor(7, selection);
1145 aDlg->SetColor(8, preselection);
1147 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1149 if( aMarkerTypeCurrent != VTK::MT_USER )
1150 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1152 aDlg->setCustomMarker( aMarkerTextureCurrent );
1155 QColor color = aDlg->GetColor(1);
1156 QColor edgecolor = aDlg->GetColor(2);
1157 QColor nodecolor = aDlg->GetColor(3);
1158 QColor outlinecolor = aDlg->GetColor(4);
1159 QColor color0D = aDlg->GetColor(5);
1160 QColor faces_orientation_color = aDlg->GetColor(6);
1161 QColor selectioncolor = aDlg->GetColor(7);
1162 QColor preSelectioncolor = aDlg->GetColor(8);
1163 int delta = aDlg->GetDeltaBrightness();
1166 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1168 SALOME_ListIteratorOfListIO It( selected );
1169 for( ; It.More(); It.Next()){
1170 Handle(SALOME_InteractiveObject) IObject = It.Value();
1171 if(IObject->hasEntry()){
1172 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1173 /* actor color and backface color */
1174 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1175 vtkFloatingPointType (color.green()) / 255.,
1176 vtkFloatingPointType (color.blue()) / 255.,
1179 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1180 vtkFloatingPointType (edgecolor.green()) / 255.,
1181 vtkFloatingPointType (edgecolor.blue()) / 255.);
1183 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1184 vtkFloatingPointType (outlinecolor.green()) / 255.,
1185 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1188 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1189 vtkFloatingPointType (selectioncolor.green()) / 255.,
1190 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1192 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1193 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1194 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1197 /* Shrink factor and size edges */
1198 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1199 anActor->SetLineWidth(aDlg->GetIntValue(1));
1201 /* Nodes color and size */
1202 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1203 vtkFloatingPointType (nodecolor.green()) / 255.,
1204 vtkFloatingPointType (nodecolor.blue()) / 255.);
1207 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1208 vtkFloatingPointType (color0D.green()) / 255.,
1209 vtkFloatingPointType (color0D.blue()) / 255.);
1210 anActor->Set0DSize(aDlg->GetIntValue(3));
1212 /* Faces orientation */
1213 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1214 vtkFloatingPointType(faces_orientation_color.greenF()),
1215 vtkFloatingPointType(faces_orientation_color.blueF())};
1216 anActor->SetFacesOrientationColor(c);
1217 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1218 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1220 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1221 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1222 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1223 if( aMarkerTypeNew != VTK::MT_USER )
1224 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1226 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1227 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1228 if( anIter != aMarkerMap.end() )
1229 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1232 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1233 if( !aGroupObject->_is_nil() )
1235 SMESH::ElementType anElementType = aGroupObject->GetType();
1237 switch( anElementType )
1239 case SMESH::NODE: aColor = nodecolor; break;
1240 case SMESH::EDGE: aColor = edgecolor; break;
1241 default: aColor = color; break;
1244 SALOMEDS::Color aGroupColor;
1245 aGroupColor.R = (float)aColor.red() / 255.0;
1246 aGroupColor.G = (float)aColor.green() / 255.0;
1247 aGroupColor.B = (float)aColor.blue() / 255.0;
1248 aGroupObject->SetColor( aGroupColor );
1253 SMESH::RepaintCurrentView();
1259 SALOME_ListIteratorOfListIO It( selected );
1260 for( ; It.More(); It.Next()){
1261 Handle(SALOME_InteractiveObject) IObject = It.Value();
1262 if(IObject->hasEntry()){
1263 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1264 switch(theCommandID){
1266 anActor->SetRepresentation(SMESH_Actor::eEdge);
1269 anActor->SetRepresentation(SMESH_Actor::eSurface);
1272 if(anActor->IsShrunk())
1273 anActor->UnShrink();
1275 anActor->SetShrink();
1278 anActor->SetRepresentation(SMESH_Actor::ePoint);
1281 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1282 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1285 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1286 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1292 SMESH::RepaintCurrentView();
1296 void Control( int theCommandID )
1298 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1299 SALOME_ListIO selected;
1301 aSel->selectedObjects( selected );
1303 if( !selected.IsEmpty() ){
1304 Handle(SALOME_InteractiveObject) anIO = selected.First();
1306 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1307 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1308 switch ( theCommandID ){
1310 aControl = SMESH_Actor::eLength;
1313 aControl = SMESH_Actor::eLength2D;
1316 aControl = SMESH_Actor::eFreeEdges;
1319 aControl = SMESH_Actor::eFreeBorders;
1322 aControl = SMESH_Actor::eMultiConnection;
1325 aControl = SMESH_Actor::eFreeNodes;
1328 aControl = SMESH_Actor::eMultiConnection2D;
1331 aControl = SMESH_Actor::eArea;
1334 aControl = SMESH_Actor::eTaper;
1337 aControl = SMESH_Actor::eAspectRatio;
1340 aControl = SMESH_Actor::eAspectRatio3D;
1343 aControl = SMESH_Actor::eMinimumAngle;
1346 aControl = SMESH_Actor::eWarping;
1349 aControl = SMESH_Actor::eSkew;
1352 aControl = SMESH_Actor::eVolume3D;
1355 aControl = SMESH_Actor::eFreeFaces;
1358 aControl = SMESH_Actor::eMaxElementLength2D;
1361 aControl = SMESH_Actor::eMaxElementLength3D;
1364 aControl = SMESH_Actor::eBareBorderVolume;
1367 aControl = SMESH_Actor::eBareBorderFace;
1370 aControl = SMESH_Actor::eOverConstrainedVolume;
1373 aControl = SMESH_Actor::eOverConstrainedFace;
1376 anActor->SetControlMode(aControl);
1377 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1378 SMESH::RepaintCurrentView();
1379 #ifndef DISABLE_PLOT2DVIEWER
1380 if(anActor->GetPlot2Histogram()) {
1381 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1382 QString functorName = functorToString( anActor->GetFunctor());
1383 QString aHistogramName("%1 : %2");
1384 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1385 aHistogram->setName(aHistogramName);
1386 aHistogram->setHorTitle(functorName);
1387 SMESH::ProcessIn2DViewers(anActor);
1396 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1397 MeshObjectType theType,
1398 const QString theInTypeName,
1399 QString & theOutTypeName)
1401 SMESH_TypeFilter aTypeFilter( theType );
1403 if( !theIO.IsNull() )
1405 entry = theIO->getEntry();
1406 LightApp_DataOwner owner( entry );
1407 if ( aTypeFilter.isOk( &owner )) {
1408 theOutTypeName = theInTypeName;
1416 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1418 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1419 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1421 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1422 CORBA::String_var anID = aSComp->GetID().c_str();
1423 if (!strcmp(anID.in(),theIO->getEntry()))
1429 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1430 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1431 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1432 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1433 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1441 QString CheckHomogeneousSelection()
1443 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1444 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1445 SALOME_ListIO selected;
1447 aSel->selectedObjects( selected );
1449 QString RefType = CheckTypeObject(selected.First());
1450 SALOME_ListIteratorOfListIO It(selected);
1451 for ( ; It.More(); It.Next())
1453 Handle(SALOME_InteractiveObject) IObject = It.Value();
1454 QString Type = CheckTypeObject(IObject);
1455 if (Type.compare(RefType) != 0)
1456 return "Heterogeneous Selection";
1463 void SMESHGUI::OnEditDelete()
1465 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1466 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1467 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1469 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1470 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1471 _PTR(GenericAttribute) anAttr;
1472 _PTR(AttributeIOR) anIOR;
1474 int objectCount = 0;
1476 QString aParentComponent = QString::null;
1477 Handle(SALOME_InteractiveObject) anIO;
1478 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1480 anIO = anIt.Value();
1481 QString cur = anIO->getComponentDataType();
1482 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1484 // check if object is reference
1485 _PTR(SObject) aRefSObj;
1486 aNameList.append("\n - ");
1487 if ( aSO->ReferencedObject( aRefSObj ) ) {
1488 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1489 aNameList.append( aRefName );
1490 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1493 aNameList.append(anIO->getName());
1497 if( aParentComponent.isNull() )
1498 aParentComponent = cur;
1499 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1500 aParentComponent = "";
1503 if ( objectCount == 0 )
1504 return; // No Valid Objects Selected
1506 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1507 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1508 QObject::tr("ERR_ERROR"),
1509 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1512 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1513 if (SUIT_MessageBox::warning
1514 (SMESHGUI::desktop(),
1515 QObject::tr("SMESH_WRN_WARNING"),
1516 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1517 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1518 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1521 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1523 SALOME_ListIteratorOfListIO It(selected);
1525 aStudyBuilder->NewCommand(); // There is a transaction
1526 for( ; It.More(); It.Next()){ // loop on selected IO's
1527 Handle(SALOME_InteractiveObject) IObject = It.Value();
1528 if(IObject->hasEntry()) {
1529 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1531 // disable removal of "SMESH" component object
1532 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1534 if ( engineIOR() == anIOR->Value().c_str() )
1537 //Check the referenced object
1538 _PTR(SObject) aRefSObject;
1539 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1540 aSO = aRefSObject; // Delete main Object instead of reference
1542 // put the whole hierarchy of sub-objects of the selected SO into a list and
1543 // then treat them all starting from the deepest objects (at list back)
1545 std::list< _PTR(SObject) > listSO;
1546 listSO.push_back( aSO );
1547 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1548 for ( ; itSO != listSO.end(); ++itSO ) {
1549 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1550 for (it->InitEx(false); it->More(); it->Next())
1551 listSO.push_back( it->Value() );
1554 // treat SO's in the list starting from the back
1556 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1557 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1558 _PTR(SObject) SO = *ritSO;
1559 if ( !SO ) continue;
1560 std::string anEntry = SO->GetID();
1562 /** Erase graphical object **/
1563 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1564 ViewManagerList aViewMenegers = anApp->viewManagers();
1565 ViewManagerList::const_iterator it = aViewMenegers.begin();
1566 for( ; it != aViewMenegers.end(); it++) {
1567 SUIT_ViewManager* vm = *it;
1568 int nbSf = vm ? vm->getViewsCount() : 0;
1570 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1571 for(int i = 0; i < nbSf; i++){
1572 SUIT_ViewWindow *sf = aViews[i];
1573 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1574 SMESH::RemoveActor(sf,anActor);
1580 /** Remove an object from data structures **/
1581 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1582 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1583 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1584 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1585 aMesh->RemoveGroup( aGroup );
1587 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1588 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1589 aMesh->RemoveSubMesh( aSubMesh );
1591 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1593 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1596 IObject = new SALOME_InteractiveObject
1597 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1598 QString objType = CheckTypeObject(IObject);
1599 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1600 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1601 aStudyBuilder->RemoveObjectWithChildren( SO );
1603 else {// default action: remove SObject from the study
1604 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1605 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1607 aStudyBuilder->RemoveObjectWithChildren( SO );
1611 } /* listSO back loop */
1612 } /* IObject->hasEntry() */
1615 aStudyBuilder->CommitCommand();
1617 /* Clear any previous selection */
1619 aSel->setSelectedObjects( l1 );
1621 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1626 SMESHGUI_EXPORT CAM_Module* createModule()
1628 return new SMESHGUI();
1631 SMESHGUI_EXPORT char* getModuleVersion() {
1632 return (char*)SMESH_VERSION_STR;
1636 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1638 //=============================================================================
1642 //=============================================================================
1643 SMESHGUI::SMESHGUI() :
1644 SalomeApp_Module( "SMESH" ),
1645 LightApp_Module( "SMESH" )
1647 if ( CORBA::is_nil( myComponentSMESH ) )
1649 CORBA::Boolean anIsEmbeddedMode;
1650 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1651 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1653 // 0019923: EDF 765 SMESH : default values of hypothesis
1654 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1655 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1656 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1657 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1658 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1661 myActiveDialogBox = 0;
1662 myFilterLibraryDlg = 0;
1666 myEventCallbackCommand = vtkCallbackCommand::New();
1667 myEventCallbackCommand->Delete();
1668 myEventCallbackCommand->SetClientData( this );
1669 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1672 SMESH::GetFilterManager();
1673 SMESH::GetPattern();
1674 SMESH::GetMeasurements();
1676 /* load resources for all available meshers */
1677 SMESH::InitAvailableHypotheses();
1680 //=============================================================================
1684 //=============================================================================
1685 SMESHGUI::~SMESHGUI()
1687 #ifdef WITHGENERICOBJ
1688 SMESH::GetFilterManager()->UnRegister();
1689 SMESH::GetMeasurements()->UnRegister();
1691 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1692 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1695 //=============================================================================
1699 //=============================================================================
1700 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1702 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1704 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1709 //=============================================================================
1713 //=============================================================================
1714 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1716 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1720 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1721 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1722 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1723 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1724 return autoUpdate && !exceeded;
1727 //=============================================================================
1731 //=============================================================================
1732 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1734 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1737 //=============================================================================
1741 //=============================================================================
1742 SMESHGUI* SMESHGUI::GetSMESHGUI()
1744 SMESHGUI* smeshMod = 0;
1745 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1748 CAM_Module* module = app->module( "Mesh" );
1749 smeshMod = dynamic_cast<SMESHGUI*>( module );
1752 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1754 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1757 _PTR(Study) aStudy = study->studyDS();
1759 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1768 Standard_EXPORT SMESHGUI* GetComponentGUI()
1770 return SMESHGUI::GetSMESHGUI();
1774 //=============================================================================
1778 //=============================================================================
1779 void SMESHGUI::SetState(int aState)
1784 //=============================================================================
1788 //=============================================================================
1789 void SMESHGUI::ResetState()
1794 //=============================================================================
1798 //=============================================================================
1799 void SMESHGUI::EmitSignalDeactivateDialog()
1801 emit SignalDeactivateActiveDialog();
1804 //=============================================================================
1808 //=============================================================================
1809 void SMESHGUI::EmitSignalStudyFrameChanged()
1811 emit SignalStudyFrameChanged();
1814 //=============================================================================
1818 //=============================================================================
1819 void SMESHGUI::EmitSignalCloseAllDialogs()
1821 emit SignalCloseAllDialogs();
1824 //=============================================================================
1828 //=============================================================================
1829 void SMESHGUI::EmitSignalVisibilityChanged()
1831 emit SignalVisibilityChanged();
1834 //=============================================================================
1838 //=============================================================================
1839 QDialog *SMESHGUI::GetActiveDialogBox()
1841 return myActiveDialogBox;
1844 //=============================================================================
1848 //=============================================================================
1849 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1851 myActiveDialogBox = (QDialog *) aDlg;
1855 //=============================================================================
1859 //=============================================================================
1860 SUIT_Desktop* SMESHGUI::desktop()
1862 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1864 return app->desktop();
1869 //=============================================================================
1873 //=============================================================================
1874 SalomeApp_Study* SMESHGUI::activeStudy()
1876 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1878 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1883 //=============================================================================
1887 //=============================================================================
1888 void SMESHGUI::Modified( bool theIsUpdateActions )
1890 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1891 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1892 appStudy->Modified();
1893 if( theIsUpdateActions )
1894 app->updateActions();
1899 //=============================================================================
1903 //=============================================================================
1904 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1906 /* Here the position is on the bottom right corner - 10 */
1907 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1909 SUIT_Desktop *PP = desktop();
1910 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1911 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1915 //=============================================================================
1919 //=============================================================================
1920 static int isStudyLocked(_PTR(Study) theStudy){
1921 return theStudy->GetProperties()->IsLocked();
1924 static bool checkLock(_PTR(Study) theStudy) {
1925 if (isStudyLocked(theStudy)) {
1926 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1927 QObject::tr("WRN_WARNING"),
1928 QObject::tr("WRN_STUDY_LOCKED") );
1934 //=======================================================================
1935 //function : CheckActiveStudyLocked
1937 //=======================================================================
1939 bool SMESHGUI::isActiveStudyLocked()
1941 _PTR(Study) aStudy = activeStudy()->studyDS();
1942 return checkLock( aStudy );
1945 //=============================================================================
1949 //=============================================================================
1950 bool SMESHGUI::OnGUIEvent( int theCommandID )
1952 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1956 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1957 SUIT_ResourceMgr* mgr = resourceMgr();
1961 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1962 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1965 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1966 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1968 //QAction* act = action( theCommandID );
1970 switch (theCommandID) {
1972 if(checkLock(aStudy)) break;
1982 if(checkLock(aStudy)) break;
1983 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1987 case 150: //MED FILE INFORMATION
1989 SALOME_ListIO selected;
1990 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1992 aSel->selectedObjects( selected );
1993 if( selected.Extent() )
1995 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1996 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1997 if ( !aMesh->_is_nil() )
1999 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2006 case 122: // EXPORT MED
2017 ::ExportMeshToFile(theCommandID);
2021 case 200: // SCALAR BAR
2023 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2024 SALOME_ListIO selected;
2026 aSel->selectedObjects( selected );
2028 if( selected.Extent() ) {
2029 Handle(SALOME_InteractiveObject) anIO = selected.First();
2030 if( anIO->hasEntry() ) {
2031 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2032 anActor->SetControlMode( SMESH_Actor::eNone );
2033 #ifndef DISABLE_PLOT2DVIEWER
2034 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2043 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2048 // dump control distribution data to the text file
2049 ::SaveDistribution();
2055 // show/ distribution
2056 ::ShowDistribution();
2060 #ifndef DISABLE_PLOT2DVIEWER
2063 // plot distribution
2064 ::PlotDistribution();
2075 ::DisableAutoColor();
2078 case 1134: // Clipping
2079 case 1133: // Tranparency
2080 case 1132: // Colors / Size
2087 ::SetDisplayMode(theCommandID, myMarkerMap);
2090 //2D quadratic representation
2093 ::SetDisplayMode(theCommandID, myMarkerMap);
2097 case 216: // 0D elements
2100 case 219: // Volumes
2101 case 220: // All Entity
2102 ::SetDisplayEntity(theCommandID);
2105 case 221: // Orientation of faces
2107 LightApp_SelectionMgr* mgr = selectionMgr();
2108 SALOME_ListIO selected; mgr->selectedObjects( selected );
2110 SALOME_ListIteratorOfListIO it(selected);
2111 for( ; it.More(); it.Next()) {
2112 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2113 if(anIObject->hasEntry()) {
2114 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2115 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2124 if(checkLock(aStudy)) break;
2126 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2129 SMESH::UpdateView();
2131 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2132 SMESH::OnVisuException();
2134 catch (...) { // PAL16774 (Crash after display of many groups)
2135 SMESH::OnVisuException();
2139 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2140 aSel->selectedObjects( l );
2141 aSel->setSelectedObjects( l );
2146 case 301: // DISPLAY
2147 case 302: // DISPLAY ONLY
2149 SMESH::EDisplaing anAction;
2150 switch (theCommandID) {
2151 case 300: anAction = SMESH::eErase; break;
2152 case 301: anAction = SMESH::eDisplay; break;
2153 case 302: anAction = SMESH::eDisplayOnly; break;
2156 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2157 SALOME_ListIO sel_objects, to_process;
2159 aSel->selectedObjects( sel_objects );
2161 if( theCommandID==302 )
2163 MESSAGE("anAction = SMESH::eDisplayOnly");
2164 startOperation( myEraseAll );
2167 extractContainers( sel_objects, to_process );
2170 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2174 SALOME_ListIteratorOfListIO It( to_process );
2175 for ( ; It.More(); It.Next()) {
2177 Handle(SALOME_InteractiveObject) IOS = It.Value();
2178 if (IOS->hasEntry()) {
2180 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2181 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2182 break; // PAL16774 (Crash after display of many groups)
2184 if (anAction == SMESH::eDisplayOnly)
2186 MESSAGE("anAction = SMESH::eDisplayOnly");
2187 anAction = SMESH::eDisplay;
2193 // PAL13338 + PAL15161 -->
2194 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2195 MESSAGE("anAction = SMESH::eDisplayOnly");
2196 SMESH::UpdateView();
2197 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2199 // PAL13338 + PAL15161 <--
2201 catch (...) { // PAL16774 (Crash after display of many groups)
2202 SMESH::OnVisuException();
2205 if (anAction == SMESH::eErase) {
2206 MESSAGE("anAction == SMESH::eErase");
2208 aSel->setSelectedObjects( l1 );
2211 aSel->setSelectedObjects( to_process );
2218 if(checkLock(aStudy)) break;
2221 EmitSignalDeactivateDialog();
2223 ( new SMESHGUI_NodesDlg( this ) )->show();
2226 SUIT_MessageBox::warning(desktop(),
2227 tr("SMESH_WRN_WARNING"),
2228 tr("SMESH_WRN_VIEWER_VTK"));
2233 case 2151: // FILTER
2237 EmitSignalDeactivateDialog();
2238 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2243 case 701: // COMPUTE MESH
2244 case 711: // PRECOMPUTE MESH
2245 case 712: // EVALUATE MESH
2246 case 713: // MESH ORDER
2248 if (checkLock(aStudy)) break;
2249 startOperation( theCommandID );
2253 case 702: // Create mesh
2254 case 703: // Create sub-mesh
2255 case 704: // Edit mesh/sub-mesh
2256 startOperation( theCommandID );
2258 case 705: // copy mesh
2260 if (checkLock(aStudy)) break;
2261 EmitSignalDeactivateDialog();
2262 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2265 case 710: // Build compound mesh
2267 if (checkLock(aStudy)) break;
2268 EmitSignalDeactivateDialog();
2269 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2273 case 407: // DIAGONAL INVERSION
2274 case 408: // Delete diagonal
2278 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2279 tr( "NOT_A_VTK_VIEWER" ) );
2283 if ( checkLock( aStudy ) )
2286 /*Standard_Boolean aRes;
2287 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2288 if ( aMesh->_is_nil() )
2290 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2291 tr( "SMESH_BAD_SELECTION" ) );
2295 EmitSignalDeactivateDialog();
2296 if ( theCommandID == 407 )
2297 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2299 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2302 case 409: // Change orientation
2303 case 410: // Union of triangles
2304 case 411: // Cutting of quadrangles
2305 case 419: // Splitting volumes into tetrahedra
2309 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2310 tr( "NOT_A_VTK_VIEWER" ) );
2314 if ( checkLock( aStudy ) )
2317 EmitSignalDeactivateDialog();
2318 SMESHGUI_MultiEditDlg* aDlg = NULL;
2319 if ( theCommandID == 409 )
2320 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2321 else if ( theCommandID == 410 )
2322 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2323 else if ( theCommandID == 419 )
2324 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2326 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2331 case 412: // Smoothing
2333 if(checkLock(aStudy)) break;
2335 EmitSignalDeactivateDialog();
2336 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2339 SUIT_MessageBox::warning(desktop(),
2340 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2344 case 413: // Extrusion
2346 if (checkLock(aStudy)) break;
2348 EmitSignalDeactivateDialog();
2349 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2351 SUIT_MessageBox::warning(desktop(),
2352 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2356 case 414: // Revolution
2358 if(checkLock(aStudy)) break;
2360 EmitSignalDeactivateDialog();
2361 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2364 SUIT_MessageBox::warning(desktop(),
2365 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2369 case 415: // Pattern mapping
2371 if ( checkLock( aStudy ) )
2375 EmitSignalDeactivateDialog();
2376 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2379 SUIT_MessageBox::warning(desktop(),
2380 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2384 case 416: // Extrusion along a path
2386 if (checkLock(aStudy)) break;
2388 EmitSignalDeactivateDialog();
2389 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2391 SUIT_MessageBox::warning(desktop(),
2392 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2396 case 417: // Convert mesh to quadratic
2398 startOperation( 417 );
2399 /* if (checkLock(aStudy)) break;
2401 EmitSignalDeactivateDialog();
2402 new SMESHGUI_ConvToQuadDlg();
2404 SUIT_MessageBox::warning(desktop(),
2405 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2409 case 418: // create 2D mesh from 3D
2411 startOperation( 418 );
2414 case 806: // CREATE GEO GROUP
2416 startOperation( 806 );
2419 case 801: // CREATE GROUP
2423 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2424 tr( "NOT_A_VTK_VIEWER" ) );
2428 if(checkLock(aStudy)) break;
2429 EmitSignalDeactivateDialog();
2430 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2432 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2433 SALOME_ListIO selected;
2435 aSel->selectedObjects( selected );
2437 int nbSel = selected.Extent();
2439 // check if mesh is selected
2440 aMesh = SMESH::GetMeshByIO( selected.First() );
2442 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2447 case 802: // CONSTRUCT GROUP
2451 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2452 tr( "NOT_A_VTK_VIEWER" ) );
2456 if(checkLock(aStudy)) break;
2457 EmitSignalDeactivateDialog();
2459 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2460 SALOME_ListIO selected;
2462 aSel->selectedObjects( selected );
2464 int nbSel = selected.Extent();
2466 // check if submesh is selected
2467 Handle(SALOME_InteractiveObject) IObject = selected.First();
2468 if (IObject->hasEntry()) {
2469 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2471 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2472 if (!aSubMesh->_is_nil()) {
2474 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2475 // get submesh elements list by types
2476 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2477 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2478 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2479 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2480 // create group for each type o elements
2481 QString aName = IObject->getName();
2482 QStringList anEntryList;
2483 if (aNodes->length() > 0) {
2484 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2485 aGroup->Add(aNodes.inout());
2486 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2487 anEntryList.append( aSObject->GetID().c_str() );
2489 if (aEdges->length() > 0) {
2490 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2491 aGroup->Add(aEdges.inout());
2492 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2493 anEntryList.append( aSObject->GetID().c_str() );
2495 if (aFaces->length() > 0) {
2496 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2497 aGroup->Add(aFaces.inout());
2498 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2499 anEntryList.append( aSObject->GetID().c_str() );
2501 if (aVolumes->length() > 0) {
2502 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2503 aGroup->Add(aVolumes.inout());
2504 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2505 anEntryList.append( aSObject->GetID().c_str() );
2508 anApp->browseObjects( anEntryList );
2510 catch(const SALOME::SALOME_Exception & S_ex){
2511 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2518 SUIT_MessageBox::warning(desktop(),
2519 tr("SMESH_WRN_WARNING"),
2520 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2525 case 803: // EDIT GROUP
2529 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2530 tr( "NOT_A_VTK_VIEWER" ) );
2534 if(checkLock(aStudy)) break;
2535 EmitSignalDeactivateDialog();
2537 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2538 SALOME_ListIO selected;
2540 aSel->selectedObjects( selected );
2542 SALOME_ListIteratorOfListIO It (selected);
2543 int nbSelectedGroups = 0;
2544 for ( ; It.More(); It.Next() )
2546 SMESH::SMESH_GroupBase_var aGroup =
2547 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2548 if (!aGroup->_is_nil()) {
2550 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2554 if (nbSelectedGroups == 0)
2556 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2562 case 804: // Add elements to group
2564 if(checkLock(aStudy)) break;
2565 if (myState == 800) {
2566 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2567 if (aDlg) aDlg->onAdd();
2572 case 805: // Remove elements from group
2574 if(checkLock(aStudy)) break;
2575 if (myState == 800) {
2576 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2577 if (aDlg) aDlg->onRemove();
2582 case 815: // Edit GEOM GROUP as standalone
2586 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2587 tr( "NOT_A_VTK_VIEWER" ) );
2591 if(checkLock(aStudy)) break;
2592 EmitSignalDeactivateDialog();
2594 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2595 SALOME_ListIO selected;
2597 aSel->selectedObjects( selected );
2599 SALOME_ListIteratorOfListIO It (selected);
2600 for ( ; It.More(); It.Next() )
2602 SMESH::SMESH_GroupOnGeom_var aGroup =
2603 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2604 if (!aGroup->_is_nil()) {
2605 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2610 SMESH::SMESH_GroupOnFilter_var aGroup =
2611 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2612 if (!aGroup->_is_nil()) {
2613 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2621 case 810: // Union Groups
2622 case 811: // Intersect groups
2623 case 812: // Cut groups
2627 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2628 tr( "NOT_A_VTK_VIEWER" ) );
2632 if ( checkLock( aStudy ) )
2635 EmitSignalDeactivateDialog();
2637 SMESHGUI_GroupOpDlg* aDlg = 0;
2638 if ( theCommandID == 810 )
2639 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2640 else if ( theCommandID == 811 )
2641 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2643 aDlg = new SMESHGUI_CutGroupsDlg( this );
2650 case 814: // Create groups of entities from existing groups of superior dimensions
2652 if ( checkLock( aStudy ) )
2655 EmitSignalDeactivateDialog();
2656 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2662 case 813: // Delete groups with their contents
2666 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2667 tr( "NOT_A_VTK_VIEWER" ) );
2671 if ( checkLock( aStudy ) )
2674 EmitSignalDeactivateDialog();
2676 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2680 case 900: // MESH INFOS
2681 case 903: // WHAT IS
2683 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2684 EmitSignalDeactivateDialog();
2685 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2686 SALOME_ListIO selected;
2688 aSel->selectedObjects( selected );
2690 if ( selected.Extent() > 1 ) { // a dlg for each IO
2691 SALOME_ListIteratorOfListIO It( selected );
2692 for ( ; It.More(); It.Next() ) {
2693 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2694 dlg->showInfo( It.Value() );
2699 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2705 case 902: // STANDARD MESH INFOS
2707 EmitSignalDeactivateDialog();
2708 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2709 SALOME_ListIO selected;
2711 aSel->selectedObjects( selected );
2713 if ( selected.Extent() > 1 ) { // a dlg for each IO
2715 SALOME_ListIteratorOfListIO It (selected);
2716 for ( ; It.More(); It.Next() ) {
2718 IOs.Append( It.Value() );
2719 aSel->setSelectedObjects( IOs );
2720 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2722 // restore selection
2723 aSel->setSelectedObjects( selected );
2726 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2729 case 903: // WHAT IS
2731 EmitSignalDeactivateDialog();
2732 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2737 case 904: // FIND ELEM
2739 startOperation( theCommandID );
2743 case 1100: // EDIT HYPOTHESIS
2745 if(checkLock(aStudy)) break;
2747 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2748 SALOME_ListIO selected;
2750 aSel->selectedObjects( selected );
2752 int nbSel = selected.Extent();
2755 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2756 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2758 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2759 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2760 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2761 if ( !aHypothesis->_is_nil() )
2764 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2765 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2767 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2777 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2779 if(checkLock(aStudy)) break;
2780 SUIT_OverrideCursor wc;
2782 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2783 SALOME_ListIO selected;
2785 aSel->selectedObjects( selected, QString::null, false );
2787 SALOME_ListIteratorOfListIO It(selected);
2788 for (int i = 0; It.More(); It.Next(), i++) {
2789 Handle(SALOME_InteractiveObject) IObject = It.Value();
2790 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2793 aSel->setSelectedObjects( l1 );
2798 case 4009: // ELEM0D
2799 case 4010: // GEOM::EDGE
2800 case 4021: // TRIANGLE
2802 case 4023: // POLYGON
2806 if(checkLock(aStudy)) break;
2808 EmitSignalDeactivateDialog();
2809 SMDSAbs_ElementType type = SMDSAbs_Edge;
2811 switch (theCommandID) {
2812 case 4009: // ELEM0D
2813 type = SMDSAbs_0DElement; nbNodes = 1; break;
2814 case 4021: // TRIANGLE
2815 type = SMDSAbs_Face; nbNodes = 3; break;
2817 type = SMDSAbs_Face; nbNodes = 4; break;
2819 type = SMDSAbs_Volume; nbNodes = 4; break;
2820 case 4023: // POLYGON
2821 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2823 type = SMDSAbs_Volume; nbNodes = 8; break;
2824 case 4033: // POLYHEDRE
2825 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2828 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2831 SUIT_MessageBox::warning(desktop(),
2832 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2836 case 4033: // POLYHEDRON
2838 if(checkLock(aStudy)) break;
2840 EmitSignalDeactivateDialog();
2841 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2844 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2845 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2849 case 4034: // QUADRATIC EDGE
2850 case 4035: // QUADRATIC TRIANGLE
2851 case 4036: // QUADRATIC QUADRANGLE
2852 case 4037: // QUADRATIC TETRAHEDRON
2853 case 4038: // QUADRATIC PYRAMID
2854 case 4039: // QUADRATIC PENTAHEDRON
2855 case 4040: // QUADRATIC HEXAHEDRON
2857 if(checkLock(aStudy)) break;
2859 EmitSignalDeactivateDialog();
2862 switch (theCommandID) {
2864 type = QUAD_EDGE; break;
2866 type = QUAD_TRIANGLE; break;
2868 type = QUAD_QUADRANGLE; break;
2870 type = QUAD_TETRAHEDRON; break;
2872 type = QUAD_PYRAMID; break;
2874 type = QUAD_PENTAHEDRON; break;
2876 type = QUAD_HEXAHEDRON;
2880 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2883 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2884 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2888 case 4041: // REMOVES NODES
2890 if(checkLock(aStudy)) break;
2892 EmitSignalDeactivateDialog();
2893 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2896 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2897 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2901 case 4042: // REMOVES ELEMENTS
2903 if(checkLock(aStudy)) break;
2905 EmitSignalDeactivateDialog();
2906 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2910 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2911 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2915 case 4043: { // CLEAR_MESH
2917 if(checkLock(aStudy)) break;
2919 SALOME_ListIO selected;
2920 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2921 aSel->selectedObjects( selected );
2923 SUIT_OverrideCursor wc;
2924 SALOME_ListIteratorOfListIO It (selected);
2925 for ( ; It.More(); It.Next() )
2927 Handle(SALOME_InteractiveObject) IOS = It.Value();
2928 SMESH::SMESH_Mesh_var aMesh =
2929 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2930 if ( aMesh->_is_nil()) continue;
2932 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2934 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2935 SMESH::ModifiedMesh( aMeshSObj, false, true);
2936 // hide groups and submeshes
2937 _PTR(ChildIterator) anIter =
2938 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2939 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2941 _PTR(SObject) so = anIter->Value();
2942 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2945 catch (const SALOME::SALOME_Exception& S_ex){
2947 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2951 SMESH::UpdateView();
2955 case 4044: // REMOVE ORPHAN NODES
2957 if(checkLock(aStudy)) break;
2958 SALOME_ListIO selected;
2959 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2960 aSel->selectedObjects( selected );
2961 if ( selected.Extent() == 1 ) {
2962 Handle(SALOME_InteractiveObject) anIO = selected.First();
2963 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2964 if ( !aMesh->_is_nil() ) {
2965 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2966 tr( "SMESH_WARNING" ),
2967 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2968 SUIT_MessageBox::Yes |
2969 SUIT_MessageBox::No,
2970 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2973 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2974 int removed = aMeshEditor->RemoveOrphanNodes();
2975 SUIT_MessageBox::information(SMESHGUI::desktop(),
2976 tr("SMESH_INFORMATION"),
2977 tr("NB_NODES_REMOVED").arg(removed));
2978 if ( removed > 0 ) {
2979 SMESH::UpdateView();
2980 SMESHGUI::Modified();
2983 catch (const SALOME::SALOME_Exception& S_ex) {
2984 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2993 case 4051: // RENUMBERING NODES
2995 if(checkLock(aStudy)) break;
2997 EmitSignalDeactivateDialog();
2998 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3002 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3007 case 4052: // RENUMBERING ELEMENTS
3009 if(checkLock(aStudy)) break;
3011 EmitSignalDeactivateDialog();
3012 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3016 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3017 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3021 case 4061: // TRANSLATION
3023 if(checkLock(aStudy)) break;
3025 EmitSignalDeactivateDialog();
3026 ( new SMESHGUI_TranslationDlg( this ) )->show();
3029 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3030 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3034 case 4062: // ROTATION
3036 if(checkLock(aStudy)) break;
3038 EmitSignalDeactivateDialog();
3039 ( new SMESHGUI_RotationDlg( this ) )->show();
3042 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3043 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3047 case 4063: // SYMMETRY
3049 if(checkLock(aStudy)) break;
3051 EmitSignalDeactivateDialog();
3052 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3055 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3056 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3060 case 4064: // SEWING
3062 if(checkLock(aStudy)) break;
3064 EmitSignalDeactivateDialog();
3065 ( new SMESHGUI_SewingDlg( this ) )->show();
3068 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3069 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3073 case 4065: // MERGE NODES
3075 if(checkLock(aStudy)) break;
3077 EmitSignalDeactivateDialog();
3078 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3081 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3082 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3086 case 4066: // MERGE EQUAL ELEMENTS
3088 if (checkLock(aStudy)) break;
3090 EmitSignalDeactivateDialog();
3091 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3093 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3094 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3099 case 4067: // MAKE MESH PASS THROUGH POINT
3100 startOperation( 4067 );
3105 if(checkLock(aStudy)) break;
3107 EmitSignalDeactivateDialog();
3108 ( new SMESHGUI_ScaleDlg( this ) )->show();
3111 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3112 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3117 case 4069: // DUPLICATE NODES
3119 if(checkLock(aStudy)) break;
3121 EmitSignalDeactivateDialog();
3122 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3125 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3126 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3131 case 5105: // Library of selection filters
3133 static QList<int> aTypes;
3134 if ( aTypes.isEmpty() )
3136 aTypes.append( SMESH::NODE );
3137 aTypes.append( SMESH::EDGE );
3138 aTypes.append( SMESH::FACE );
3139 aTypes.append( SMESH::VOLUME );
3141 if (!myFilterLibraryDlg)
3142 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3143 else if (myFilterLibraryDlg->isHidden())
3144 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3145 myFilterLibraryDlg->raise();
3149 case 6017: // CONTROLS
3173 LightApp_SelectionMgr* mgr = selectionMgr();
3174 SALOME_ListIO selected; mgr->selectedObjects( selected );
3176 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3177 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3179 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3180 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3181 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3182 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3183 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3184 ::Control( theCommandID );
3189 SUIT_MessageBox::warning(desktop(),
3190 tr( "SMESH_WRN_WARNING" ),
3191 tr( "SMESH_BAD_SELECTION" ) );
3195 SUIT_MessageBox::warning(desktop(),
3196 tr( "SMESH_WRN_WARNING" ),
3197 tr( "NOT_A_VTK_VIEWER" ) );
3202 LightApp_SelectionMgr* mgr = selectionMgr();
3203 SALOME_ListIO selected; mgr->selectedObjects( selected );
3205 SALOME_ListIteratorOfListIO it(selected);
3206 for( ; it.More(); it.Next()) {
3207 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3208 if(anIObject->hasEntry()) {
3209 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3210 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3218 LightApp_SelectionMgr* mgr = selectionMgr();
3219 SALOME_ListIO selected; mgr->selectedObjects( selected );
3221 SALOME_ListIteratorOfListIO it(selected);
3222 for( ; it.More(); it.Next()) {
3223 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3224 if(anIObject->hasEntry())
3225 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3226 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3234 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3235 EmitSignalDeactivateDialog();
3236 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3242 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3243 //updateObjBrowser();
3247 //=============================================================================
3251 //=============================================================================
3252 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3257 //=============================================================================
3261 //=============================================================================
3262 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3267 //=============================================================================
3271 //=============================================================================
3272 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3277 //=============================================================================
3278 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3279 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3281 //=============================================================================
3282 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3283 SUIT_ViewWindow* wnd )
3285 if(theIO->hasEntry()){
3286 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3287 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3291 //=======================================================================
3292 // function : createSMESHAction
3294 //=======================================================================
3295 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3296 const int key, const bool toggle, const QString& shortcutAction )
3299 QWidget* parent = application()->desktop();
3300 SUIT_ResourceMgr* resMgr = resourceMgr();
3302 if ( !icon_id.isEmpty() )
3303 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3305 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3306 if ( !pix.isNull() )
3307 icon = QIcon( pix );
3309 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3310 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3311 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3313 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3314 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3317 //=======================================================================
3318 // function : createPopupItem
3320 //=======================================================================
3321 void SMESHGUI::createPopupItem( const int id,
3322 const QString& clients,
3323 const QString& types,
3324 const QString& theRule,
3329 parentId = popupMgr()->actionId( action( pId ) );
3331 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3332 popupMgr()->insert( action( id ), parentId, 0 );
3334 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3335 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3336 QString rule = "(%1) and (%2) and (%3)";
3337 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3338 if( clients.isEmpty() )
3339 rule = rule.arg( QString( "true" ) );
3341 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3342 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3345 bool cont = myRules.contains( id );
3347 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3349 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3350 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3353 //=======================================================================
3354 // function : initialize
3356 //=======================================================================
3357 void SMESHGUI::initialize( CAM_Application* app )
3359 SalomeApp_Module::initialize( app );
3361 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3363 /* Automatic Update flag */
3364 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3366 // ----- create actions --------------
3368 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3369 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3370 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3371 createSMESHAction( 114, "NUM" );
3372 createSMESHAction( 115, "STL" );
3373 createSMESHAction( 116, "CGNS" );
3374 createSMESHAction( 121, "DAT" );
3375 createSMESHAction( 122, "MED" );
3376 createSMESHAction( 123, "UNV" );
3377 createSMESHAction( 140, "STL" );
3378 createSMESHAction( 142, "CGNS" );
3379 createSMESHAction( 124, "EXPORT_DAT" );
3380 createSMESHAction( 125, "EXPORT_MED" );
3381 createSMESHAction( 126, "EXPORT_UNV" );
3382 createSMESHAction( 141, "EXPORT_STL" );
3383 createSMESHAction( 143, "EXPORT_CGNS" );
3384 createSMESHAction( 150, "FILE_INFO" );
3385 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3386 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3387 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3388 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3389 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3390 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3391 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3392 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3393 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3394 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3395 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3396 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3397 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3398 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3399 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3400 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3401 createSMESHAction( 804, "ADD" );
3402 createSMESHAction( 805, "REMOVE" );
3403 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3404 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3405 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3406 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3407 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3408 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3409 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3410 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3411 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3412 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3413 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3414 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3415 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3416 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3417 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3418 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3419 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3420 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3421 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3422 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3423 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3424 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3425 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3426 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3427 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3428 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3429 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3430 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3431 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3432 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3433 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3434 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3435 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3436 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3437 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3438 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3439 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3440 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3441 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3442 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3443 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3444 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3445 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3446 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3447 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3448 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3449 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3450 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3451 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3452 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3453 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3454 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3455 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3456 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3457 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3458 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3459 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3460 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3461 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3462 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3463 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3464 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3465 createSMESHAction( 415, "MAP", "ICON_MAP" );
3466 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3467 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3468 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3469 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3470 createSMESHAction( 200, "RESET" );
3471 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3472 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3473 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3474 #ifndef DISABLE_PLOT2DVIEWER
3475 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3477 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3478 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3479 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3480 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3481 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3482 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3483 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3484 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3485 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3486 createSMESHAction( 220, "ALL" );
3487 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3489 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3490 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3492 createSMESHAction( 1100, "EDIT_HYPO" );
3493 createSMESHAction( 1102, "UNASSIGN" );
3494 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3495 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3496 createSMESHAction( 1131, "DISPMODE" );
3497 createSMESHAction( 1132, "COLORS" );
3498 createSMESHAction( 1133, "TRANSP" );
3499 createSMESHAction( 1134, "CLIP" );
3500 createSMESHAction( 1135, "DISP_ENT" );
3501 createSMESHAction( 1136, "AUTO_COLOR" );
3502 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3503 createSMESHAction( 2000, "CTRL" );
3505 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3506 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3508 createSMESHAction( 300, "ERASE" );
3509 createSMESHAction( 301, "DISPLAY" );
3510 createSMESHAction( 302, "DISPLAY_ONLY" );
3511 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3512 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3513 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3514 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3515 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3516 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3517 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3518 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3520 // ----- create menu --------------
3521 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3522 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3523 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3524 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3525 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3526 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3527 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3528 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3530 createMenu( separator(), fileId );
3532 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3533 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3534 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3535 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3536 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3537 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3538 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3539 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3540 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3541 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3543 createMenu( 111, importId, -1 );
3544 createMenu( 112, importId, -1 );
3545 createMenu( 113, importId, -1 );
3546 createMenu( 115, importId, -1 );
3548 createMenu( 116, importId, -1 );
3550 createMenu( 121, exportId, -1 );
3551 createMenu( 122, exportId, -1 );
3552 createMenu( 123, exportId, -1 );
3553 createMenu( 140, exportId, -1 ); // export to STL
3555 createMenu( 142, exportId, -1 ); // export to CGNS
3557 createMenu( separator(), fileId, 10 );
3559 createMenu( 33, editId, -1 );
3561 createMenu( 5105, toolsId, -1 );
3563 createMenu( 702, meshId, -1 ); // "Mesh" menu
3564 createMenu( 703, meshId, -1 );
3565 createMenu( 704, meshId, -1 );
3566 createMenu( 710, meshId, -1 );
3567 createMenu( 705, meshId, -1 );
3568 createMenu( separator(), meshId, -1 );
3569 createMenu( 701, meshId, -1 );
3570 createMenu( 711, meshId, -1 );
3571 createMenu( 712, meshId, -1 );
3572 createMenu( 713, meshId, -1 );
3573 createMenu( separator(), meshId, -1 );
3574 createMenu( 801, meshId, -1 );
3575 createMenu( 806, meshId, -1 );
3576 createMenu( 802, meshId, -1 );
3577 createMenu( 803, meshId, -1 );
3578 createMenu( 815, meshId, -1 );
3579 createMenu( separator(), meshId, -1 );
3580 createMenu( 810, meshId, -1 );
3581 createMenu( 811, meshId, -1 );
3582 createMenu( 812, meshId, -1 );
3583 createMenu( separator(), meshId, -1 );
3584 createMenu( 814, meshId, -1 );
3585 createMenu( separator(), meshId, -1 );
3586 createMenu( 900, meshId, -1 );
3587 //createMenu( 902, meshId, -1 );
3588 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3589 createMenu( 904, meshId, -1 );
3590 createMenu( separator(), meshId, -1 );
3592 createMenu( 6005, nodeId, -1 );
3593 createMenu( 6002, edgeId, -1 );
3594 createMenu( 6003, edgeId, -1 );
3595 createMenu( 6001, edgeId, -1 );
3596 createMenu( 6004, edgeId, -1 );
3597 createMenu( 6021, faceId, -1 );
3598 createMenu( 6025, faceId, -1 );
3599 createMenu( 6027, faceId, -1 );
3600 createMenu( 6018, faceId, -1 );
3601 createMenu( 6019, faceId, -1 );
3602 createMenu( 6011, faceId, -1 );
3603 createMenu( 6012, faceId, -1 );
3604 createMenu( 6013, faceId, -1 );
3605 createMenu( 6014, faceId, -1 );
3606 createMenu( 6015, faceId, -1 );
3607 createMenu( 6016, faceId, -1 );
3608 createMenu( 6022, faceId, -1 );
3609 createMenu( 6017, volumeId, -1 );
3610 createMenu( 6009, volumeId, -1 );
3611 createMenu( 6023, volumeId, -1 );
3612 createMenu( 6024, volumeId, -1 );
3613 createMenu( 6026, volumeId, -1 );
3615 createMenu( 4000, addId, -1 );
3616 createMenu( 4009, addId, -1 );
3617 createMenu( 4010, addId, -1 );
3618 createMenu( 4021, addId, -1 );
3619 createMenu( 4022, addId, -1 );
3620 createMenu( 4023, addId, -1 );
3621 createMenu( 4031, addId, -1 );
3622 createMenu( 4032, addId, -1 );
3623 createMenu( 4033, addId, -1 );
3624 createMenu( separator(), addId, -1 );
3625 createMenu( 4034, addId, -1 );
3626 createMenu( 4035, addId, -1 );
3627 createMenu( 4036, addId, -1 );
3628 createMenu( 4037, addId, -1 );
3629 createMenu( 4038, addId, -1 );
3630 createMenu( 4039, addId, -1 );
3631 createMenu( 4040, addId, -1 );
3633 createMenu( 4041, removeId, -1 );
3634 createMenu( 4042, removeId, -1 );
3635 createMenu( 4044, removeId, -1 );
3636 createMenu( separator(), removeId, -1 );
3637 createMenu( 813, removeId, -1 );
3638 createMenu( separator(), removeId, -1 );
3639 createMenu( 4043, removeId, -1 );
3641 createMenu( 4051, renumId, -1 );
3642 createMenu( 4052, renumId, -1 );
3644 createMenu( 4061, transfId, -1 );
3645 createMenu( 4062, transfId, -1 );
3646 createMenu( 4063, transfId, -1 );
3647 createMenu( 4068, transfId, -1 );
3648 createMenu( 4064, transfId, -1 );
3649 createMenu( 4065, transfId, -1 );
3650 createMenu( 4066, transfId, -1 );
3651 createMenu( 4069, transfId, -1 );
3653 createMenu( 4067,modifyId, -1 );
3654 createMenu( 407, modifyId, -1 );
3655 createMenu( 408, modifyId, -1 );
3656 createMenu( 409, modifyId, -1 );
3657 createMenu( 410, modifyId, -1 );
3658 createMenu( 411, modifyId, -1 );
3659 createMenu( 419, modifyId, -1 );
3660 createMenu( 412, modifyId, -1 );
3661 createMenu( 413, modifyId, -1 );
3662 createMenu( 416, modifyId, -1 );
3663 createMenu( 414, modifyId, -1 );
3664 createMenu( 415, modifyId, -1 );
3665 createMenu( 417, modifyId, -1 );
3666 createMenu( 418, modifyId, -1 );
3668 createMenu( 501, measureId, -1 );
3669 createMenu( 502, measureId, -1 );
3670 createMenu( 214, viewId, -1 );
3672 // ----- create toolbars --------------
3673 int meshTb = createTool( tr( "TB_MESH" ) ),
3674 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3675 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3676 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3677 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3679 createTool( 702, meshTb );
3680 createTool( 703, meshTb );
3681 createTool( 704, meshTb );
3682 createTool( 710, meshTb );
3683 createTool( 705, meshTb );
3684 createTool( separator(), meshTb );
3685 createTool( 701, meshTb );
3686 createTool( 711, meshTb );
3687 createTool( 712, meshTb );
3688 createTool( 713, meshTb );
3689 createTool( separator(), meshTb );
3690 createTool( 801, meshTb );
3691 createTool( 806, meshTb );
3692 createTool( 802, meshTb );
3693 createTool( 803, meshTb );
3694 //createTool( 815, meshTb );
3695 createTool( separator(), meshTb );
3696 createTool( 900, meshTb );
3697 //createTool( 902, meshTb );
3698 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3699 createTool( 904, meshTb );
3700 createTool( separator(), meshTb );
3702 createTool( 6005, ctrlTb );
3703 createTool( separator(), ctrlTb );
3704 createTool( 6002, ctrlTb );
3705 createTool( 6003, ctrlTb );
3706 createTool( 6001, ctrlTb );
3707 createTool( 6004, ctrlTb );
3708 createTool( separator(), ctrlTb );
3709 createTool( 6021, ctrlTb );
3710 createTool( 6025, ctrlTb );
3711 createTool( 6027, ctrlTb );
3712 createTool( 6018, ctrlTb );
3713 createTool( 6019, ctrlTb );
3714 createTool( 6011, ctrlTb );
3715 createTool( 6012, ctrlTb );
3716 createTool( 6013, ctrlTb );
3717 createTool( 6014, ctrlTb );
3718 createTool( 6015, ctrlTb );
3719 createTool( 6016, ctrlTb );
3720 createTool( 6022, ctrlTb );
3721 createTool( separator(), ctrlTb );
3722 createTool( 6017, ctrlTb );
3723 createTool( 6009, ctrlTb );
3724 createTool( 6023, ctrlTb );
3725 createTool( 6024, ctrlTb );
3726 createTool( 6026, ctrlTb );
3727 createTool( separator(), ctrlTb );
3729 createTool( 4000, addRemTb );
3730 createTool( 4009, addRemTb );
3731 createTool( 4010, addRemTb );
3732 createTool( 4021, addRemTb );
3733 createTool( 4022, addRemTb );
3734 createTool( 4023, addRemTb );
3735 createTool( 4031, addRemTb );
3736 createTool( 4032, addRemTb );
3737 createTool( 4033, addRemTb );
3738 createTool( separator(), addRemTb );
3739 createTool( 4034, addRemTb );
3740 createTool( 4035, addRemTb );
3741 createTool( 4036, addRemTb );
3742 createTool( 4037, addRemTb );
3743 createTool( 4038, addRemTb );
3744 createTool( 4039, addRemTb );
3745 createTool( 4040, addRemTb );
3746 createTool( separator(), addRemTb );
3747 createTool( 4041, addRemTb );
3748 createTool( 4042, addRemTb );
3749 createTool( 4044, addRemTb );
3750 createTool( 4043, addRemTb );
3751 createTool( separator(), addRemTb );
3752 createTool( 4051, addRemTb );
3753 createTool( 4052, addRemTb );
3754 createTool( separator(), addRemTb );
3755 createTool( 4061, addRemTb );
3756 createTool( 4062, addRemTb );
3757 createTool( 4063, addRemTb );
3758 createTool( 4068, addRemTb );
3759 createTool( 4064, addRemTb );
3760 createTool( 4065, addRemTb );
3761 createTool( 4066, addRemTb );
3762 createTool( 4069, addRemTb );
3763 createTool( separator(), addRemTb );
3765 createTool( 4067,modifyTb );
3766 createTool( 407, modifyTb );
3767 createTool( 408, modifyTb );
3768 createTool( 409, modifyTb );
3769 createTool( 410, modifyTb );
3770 createTool( 411, modifyTb );
3771 createTool( 419, modifyTb );
3772 createTool( 412, modifyTb );
3773 createTool( 413, modifyTb );
3774 createTool( 416, modifyTb );
3775 createTool( 414, modifyTb );
3776 createTool( 415, modifyTb );
3777 createTool( 417, modifyTb );
3778 createTool( 418, modifyTb );
3780 createTool( 214, dispModeTb );
3782 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3783 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3786 QString OB = "'ObjectBrowser'",
3787 View = "'" + SVTK_Viewer::Type() + "'",
3789 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3790 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3791 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3792 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3793 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3794 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3795 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3796 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3797 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3798 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3799 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3801 mesh_part = mesh + " " + subMesh + " " + group,
3802 mesh_group = mesh + " " + group,
3803 hyp_alg = hypo + " " + algo;
3805 // popup for object browser
3807 isInvisible("not( isVisible )"),
3808 isEmpty("numberOfNodes = 0"),
3809 isNotEmpty("numberOfNodes <> 0"),
3811 // has nodes, edges, etc in VISIBLE! actor
3812 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3813 hasElems("(count( elemTypes ) > 0)"),
3814 hasDifferentElems("(count( elemTypes ) > 1)"),
3815 hasElems0d("({'Elem0d'} in elemTypes)"),
3816 hasEdges("({'Edge'} in elemTypes)"),
3817 hasFaces("({'Face'} in elemTypes)"),
3818 hasVolumes("({'Volume'} in elemTypes)");
3820 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3821 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3822 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3823 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3824 createPopupItem( 803, OB, group ); // EDIT_GROUP
3825 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3827 popupMgr()->insert( separator(), -1, 0 );
3828 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3829 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3830 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3831 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3832 createPopupItem( 214, OB, mesh_part ); // UPDATE
3833 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3834 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3835 popupMgr()->insert( separator(), -1, 0 );
3836 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3837 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3838 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3839 popupMgr()->insert( separator(), -1, 0 );
3840 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3841 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3842 popupMgr()->insert( separator(), -1, 0 );
3843 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3844 popupMgr()->insert( separator(), -1, 0 );
3845 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3846 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3848 popupMgr()->insert( separator(), -1, 0 );
3850 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3851 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3852 QString only_one_2D = only_one_non_empty + " && dim>1";
3854 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3855 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3856 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3858 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3860 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3861 popupMgr()->insert( separator(), -1, 0 );
3864 createPopupItem( 803, View, group ); // EDIT_GROUP
3865 createPopupItem( 804, View, elems ); // ADD
3866 createPopupItem( 805, View, elems ); // REMOVE
3868 popupMgr()->insert( separator(), -1, 0 );
3869 createPopupItem( 214, View, mesh_part ); // UPDATE
3870 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3871 createPopupItem( 904, View, mesh ); // FIND_ELEM
3872 popupMgr()->insert( separator(), -1, 0 );
3874 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3875 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3876 popupMgr()->insert( separator(), -1, 0 );
3879 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3880 QString aType = QString( "%1type in {%2}" ).arg( lc );
3881 aType = aType.arg( mesh_part );
3882 QString aMeshInVTK = aClient + "&&" + aType;
3884 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3885 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3886 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3888 //-------------------------------------------------
3890 //-------------------------------------------------
3891 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3893 popupMgr()->insert( action( 9010 ), anId, -1 );
3894 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3895 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3897 popupMgr()->insert( action( 9011 ), anId, -1 );
3898 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3899 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3901 popupMgr()->insert( separator(), -1, -1 );
3903 //-------------------------------------------------
3905 //-------------------------------------------------
3906 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3908 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3909 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3910 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3912 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3913 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3914 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3916 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3917 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3918 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3920 popupMgr()->insert( separator(), anId, -1 );
3922 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3923 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3924 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3926 //-------------------------------------------------
3928 //-------------------------------------------------
3929 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3931 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3933 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3934 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3935 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3937 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3938 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3939 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3941 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3942 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3943 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3945 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3946 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3947 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3949 popupMgr()->insert( separator(), anId, -1 );
3951 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3952 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3955 //-------------------------------------------------
3956 // Representation of the 2D Quadratic elements
3957 //-------------------------------------------------
3958 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3959 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3960 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3961 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3963 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3964 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3965 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3967 //-------------------------------------------------
3968 // Orientation of faces
3969 //-------------------------------------------------
3970 popupMgr()->insert( action( 221 ), -1, -1 );
3971 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3972 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3974 //-------------------------------------------------
3976 //-------------------------------------------------
3977 popupMgr()->insert( action( 1132 ), -1, -1 );
3978 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3980 //-------------------------------------------------
3982 //-------------------------------------------------
3983 popupMgr()->insert( action( 1133 ), -1, -1 );
3984 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3986 //-------------------------------------------------
3988 //-------------------------------------------------
3990 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3991 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3992 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3993 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3995 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3997 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3998 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4000 popupMgr()->insert( separator(), anId, -1 );
4002 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4004 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4005 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4006 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4008 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4010 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4011 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4012 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4014 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4015 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4016 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4018 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4019 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4020 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4022 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4023 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4024 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4026 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4028 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4029 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4030 QtxPopupMgr::VisibleRule );
4031 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4033 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4034 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4035 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4037 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4038 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4039 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4041 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4042 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4043 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4045 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4046 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4049 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4050 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4051 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4053 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4054 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4055 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4057 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4058 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4059 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4061 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4062 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4063 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4065 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4066 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4067 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4069 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4070 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4071 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4073 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4074 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4075 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4077 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4079 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4080 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4081 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4083 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4084 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4085 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4087 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4088 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4089 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4091 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4092 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4093 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4095 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4096 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4097 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4099 popupMgr()->insert( separator(), anId, -1 );
4101 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4102 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4104 popupMgr()->insert( separator(), anId, -1 );
4106 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4108 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4109 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4111 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4112 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4113 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4115 #ifndef DISABLE_PLOT2DVIEWER
4116 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4117 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4120 //-------------------------------------------------
4122 //-------------------------------------------------
4123 popupMgr()->insert( separator(), -1, -1 );
4124 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4125 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4126 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4127 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4129 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4130 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4132 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4133 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4135 popupMgr()->insert( separator(), -1, -1 );
4137 //-------------------------------------------------
4139 //-------------------------------------------------
4140 popupMgr()->insert( action( 1134 ), -1, -1 );
4141 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4143 popupMgr()->insert( separator(), -1, -1 );
4145 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4146 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4148 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4149 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4152 //================================================================================
4154 * \brief Return true if SMESH or GEOM objects are selected.
4155 * Is called form LightApp_Module::activateModule() which clear selection if
4156 * not isSelectionCompatible()
4158 //================================================================================
4160 bool SMESHGUI::isSelectionCompatible()
4162 bool isCompatible = true;
4163 SALOME_ListIO selected;
4164 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4165 Sel->selectedObjects( selected );
4167 SALOME_ListIteratorOfListIO It( selected );
4168 for ( ; isCompatible && It.More(); It.Next())
4170 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4171 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4173 return isCompatible;
4177 bool SMESHGUI::reusableOperation( const int id )
4179 // compute, evaluate and precompute are not reusable operations
4180 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4183 bool SMESHGUI::activateModule( SUIT_Study* study )
4185 bool res = SalomeApp_Module::activateModule( study );
4187 setMenuShown( true );
4188 setToolShown( true );
4190 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4191 PyGILState_STATE gstate = PyGILState_Ensure();
4192 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4193 if(pluginsmanager==NULL)
4197 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4202 PyGILState_Release(gstate);
4203 // end of GEOM plugins loading
4205 // Reset actions accelerator keys
4206 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4207 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4208 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4210 action( 33)->setEnabled(true); // Delete: Key_Delete
4212 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4213 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4214 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4215 if ( _PTR(Study) aStudy = s->studyDS()) {
4216 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4217 updateObjBrowser(); // objects can be removed
4220 // get all view currently opened in the study and connect their signals to
4221 // the corresponding slots of the class.
4222 SUIT_Desktop* aDesk = study->application()->desktop();
4224 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4225 SUIT_ViewWindow* wnd;
4226 foreach ( wnd, wndList )
4233 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4235 setMenuShown( false );
4236 setToolShown( false );
4238 EmitSignalCloseAllDialogs();
4240 // Unset actions accelerator keys
4241 action(111)->setShortcut(QKeySequence()); // Import DAT
4242 action(112)->setShortcut(QKeySequence()); // Import UNV
4243 action(113)->setShortcut(QKeySequence()); // Import MED
4245 action( 33)->setEnabled(false); // Delete: Key_Delete
4247 return SalomeApp_Module::deactivateModule( study );
4250 void SMESHGUI::studyClosed( SUIT_Study* s )
4252 SMESH::RemoveVisuData( s->id() );
4253 SalomeApp_Module::studyClosed( s );
4256 void SMESHGUI::OnGUIEvent()
4258 const QObject* obj = sender();
4259 if ( !obj || !obj->inherits( "QAction" ) )
4261 int id = actionId((QAction*)obj);
4266 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4268 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4269 if ( CORBA::is_nil( myComponentSMESH ) )
4271 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4273 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4274 return aGUI.myComponentSMESH;
4277 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4278 return myComponentSMESH;
4281 QString SMESHGUI::engineIOR() const
4283 CORBA::ORB_var anORB = getApp()->orb();
4284 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4285 return QString( anIOR.in() );
4288 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4290 SalomeApp_Module::contextMenuPopup( client, menu, title );
4292 selectionMgr()->selectedObjects( lst );
4293 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4294 Handle(SALOME_InteractiveObject) io = lst.First();
4295 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4296 _PTR(Study) study = appStudy->studyDS();
4297 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4299 QString aName = QString( obj->GetName().c_str() );
4300 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4301 aName.remove( (aName.length() - 1), 1 );
4307 LightApp_Selection* SMESHGUI::createSelection() const
4309 return new SMESHGUI_Selection();
4312 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4314 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4315 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4318 void SMESHGUI::viewManagers( QStringList& list ) const
4320 list.append( SVTK_Viewer::Type() );
4323 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4325 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4326 SMESH::UpdateSelectionProp( this );
4328 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4329 for(int i = 0; i < aViews.count() ; i++){
4330 SUIT_ViewWindow *sf = aViews[i];
4336 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4338 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4339 myClippingPlaneInfoMap.erase( theViewManager );
4342 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4344 theActor->AddObserver( SMESH::DeleteActorEvent,
4345 myEventCallbackCommand.GetPointer(),
4349 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4350 unsigned long theEvent,
4351 void* theClientData,
4354 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4355 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4356 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4357 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4358 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4359 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4360 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4361 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4362 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4363 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4364 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4365 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4366 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4367 if( anActor == *anIter3 ) {
4368 anActorList.erase( anIter3 );
4379 void SMESHGUI::createPreferences()
4381 // General tab ------------------------------------------------------------------------
4382 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4384 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4385 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4386 setPreferenceProperty( lim, "min", 0 );
4387 setPreferenceProperty( lim, "max", 100000000 );
4388 setPreferenceProperty( lim, "step", 1000 );
4389 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4391 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4392 setPreferenceProperty( qaGroup, "columns", 2 );
4393 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4394 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4395 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4396 setPreferenceProperty( prec, "min", 0 );
4397 setPreferenceProperty( prec, "max", 16 );
4399 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4400 setPreferenceProperty( dispgroup, "columns", 2 );
4401 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4403 modes.append( tr("MEN_WIRE") );
4404 modes.append( tr("MEN_SHADE") );
4405 modes.append( tr("MEN_NODES") );
4406 modes.append( tr("MEN_SHRINK") );
4407 QList<QVariant> indices;
4408 indices.append( 0 );
4409 indices.append( 1 );
4410 indices.append( 2 );
4411 indices.append( 3 );
4412 setPreferenceProperty( dispmode, "strings", modes );
4413 setPreferenceProperty( dispmode, "indexes", indices );
4415 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4416 setPreferenceProperty( arcgroup, "columns", 2 );
4417 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4418 QStringList quadraticModes;
4419 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4420 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4422 indices.append( 0 );
4423 indices.append( 1 );
4424 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4425 setPreferenceProperty( quadraticmode, "indexes", indices );
4427 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4428 "SMESH", "max_angle" );
4429 setPreferenceProperty( maxAngle, "min", 1 );
4430 setPreferenceProperty( maxAngle, "max", 90 );
4434 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4435 setPreferenceProperty( exportgroup, "columns", 2 );
4436 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4437 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4439 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4440 setPreferenceProperty( computeGroup, "columns", 2 );
4441 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4443 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4444 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4445 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4447 indices.append( 0 );
4448 indices.append( 1 );
4449 indices.append( 2 );
4450 setPreferenceProperty( notifyMode, "strings", modes );
4451 setPreferenceProperty( notifyMode, "indexes", indices );
4453 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4454 setPreferenceProperty( computeGroup, "columns", 2 );
4455 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4457 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4458 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4460 indices.append( 0 );
4461 indices.append( 1 );
4462 setPreferenceProperty( elemInfo, "strings", modes );
4463 setPreferenceProperty( elemInfo, "indexes", indices );
4465 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4466 setPreferenceProperty( segGroup, "columns", 2 );
4467 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4468 "SMESH", "segmentation" );
4469 setPreferenceProperty( segLen, "min", 1 );
4470 setPreferenceProperty( segLen, "max", 10000000 );
4471 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4472 "SMESH", "nb_segments_per_edge" );
4473 setPreferenceProperty( nbSeg, "min", 1 );
4474 setPreferenceProperty( nbSeg, "max", 10000000 );
4476 // Quantities with individual precision settings
4477 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4478 setPreferenceProperty( precGroup, "columns", 2 );
4480 const int nbQuantities = 6;
4481 int precs[nbQuantities], ii = 0;
4482 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4483 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4484 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4485 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4486 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4487 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4488 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4489 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4490 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4491 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4492 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4493 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4495 // Set property for precision value for spinboxes
4496 for ( ii = 0; ii < nbQuantities; ii++ ){
4497 setPreferenceProperty( precs[ii], "min", -14 );
4498 setPreferenceProperty( precs[ii], "max", 14 );
4499 setPreferenceProperty( precs[ii], "precision", 2 );
4502 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4503 setPreferenceProperty( previewGroup, "columns", 2 );
4504 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4505 setPreferenceProperty( chunkSize, "min", 0 );
4506 setPreferenceProperty( chunkSize, "max", 1000 );
4507 setPreferenceProperty( chunkSize, "step", 50 );
4509 // Mesh tab ------------------------------------------------------------------------
4510 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4511 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4512 setPreferenceProperty( nodeGroup, "columns", 3 );
4514 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4516 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4518 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4519 QList<QVariant> aMarkerTypeIndicesList;
4520 QList<QVariant> aMarkerTypeIconsList;
4521 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4522 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4523 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4524 aMarkerTypeIndicesList << i;
4525 aMarkerTypeIconsList << pixmap;
4527 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4528 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4530 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4532 QList<QVariant> aMarkerScaleIndicesList;
4533 QStringList aMarkerScaleValuesList;
4534 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4535 aMarkerScaleIndicesList << i;
4536 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4538 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4539 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4541 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4542 setPreferenceProperty( elemGroup, "columns", 2 );
4544 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4545 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4547 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4548 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4550 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4552 int grpSelection = addPreference( tr( "PREF_GROUP_SELECTION" ), meshTab );
4553 setPreferenceProperty( grpSelection, "columns", 2 );
4554 addPreference( tr( "PREF_SELECTION" ), grpSelection, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4555 addPreference( tr( "PREF_PRE_SELECTION" ), grpSelection, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4557 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4558 setPreferenceProperty( grpGroup, "columns", 2 );
4560 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4562 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4563 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4564 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4565 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4566 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4567 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4569 setPreferenceProperty( size0d, "min", 1 );
4570 setPreferenceProperty( size0d, "max", 10 );
4572 setPreferenceProperty( elemW, "min", 1 );
4573 setPreferenceProperty( elemW, "max", 5 );
4575 setPreferenceProperty( shrink, "min", 0 );
4576 setPreferenceProperty( shrink, "max", 100 );
4578 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4579 setPreferenceProperty( orientGroup, "columns", 1 );
4581 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4582 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4584 setPreferenceProperty( orientScale, "min", 0.05 );
4585 setPreferenceProperty( orientScale, "max", 0.5 );
4586 setPreferenceProperty( orientScale, "step", 0.05 );
4588 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4590 // Selection tab ------------------------------------------------------------------------
4591 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4593 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4594 setPreferenceProperty( selGroup, "columns", 2 );
4596 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4597 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4598 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4600 setPreferenceProperty( selW, "min", 1 );
4601 setPreferenceProperty( selW, "max", 5 );
4603 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4604 setPreferenceProperty( preGroup, "columns", 2 );
4606 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4607 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4609 setPreferenceProperty( preW, "min", 1 );
4610 setPreferenceProperty( preW, "max", 5 );
4612 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4613 setPreferenceProperty( precSelGroup, "columns", 2 );
4615 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4616 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4617 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4619 // Scalar Bar tab ------------------------------------------------------------------------
4620 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4621 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4622 setPreferenceProperty( fontGr, "columns", 2 );
4624 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4625 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4627 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4628 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4630 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4631 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4633 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4634 setPreferenceProperty( numcol, "min", 2 );
4635 setPreferenceProperty( numcol, "max", 256 );
4637 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4638 setPreferenceProperty( numlab, "min", 2 );
4639 setPreferenceProperty( numlab, "max", 65 );
4641 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4642 setPreferenceProperty( orientGr, "columns", 2 );
4643 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4644 QStringList orients;
4645 orients.append( tr( "SMESH_VERTICAL" ) );
4646 orients.append( tr( "SMESH_HORIZONTAL" ) );
4647 indices.clear(); indices.append( 0 ); indices.append( 1 );
4648 setPreferenceProperty( orient, "strings", orients );
4649 setPreferenceProperty( orient, "indexes", indices );
4651 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4652 setPreferenceProperty( posVSizeGr, "columns", 2 );
4653 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4654 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4655 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4656 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4657 setPreferenceProperty( xv, "step", 0.1 );
4658 setPreferenceProperty( xv, "min", 0.0 );
4659 setPreferenceProperty( xv, "max", 1.0 );
4660 setPreferenceProperty( yv, "step", 0.1 );
4661 setPreferenceProperty( yv, "min", 0.0 );
4662 setPreferenceProperty( yv, "max", 1.0 );
4663 setPreferenceProperty( wv, "step", 0.1 );
4664 setPreferenceProperty( wv, "min", 0.0 );
4665 setPreferenceProperty( wv, "max", 1.0 );
4666 setPreferenceProperty( hv, "min", 0.0 );
4667 setPreferenceProperty( hv, "max", 1.0 );
4668 setPreferenceProperty( hv, "step", 0.1 );
4670 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4671 setPreferenceProperty( posHSizeGr, "columns", 2 );
4672 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4673 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4674 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4675 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4676 setPreferenceProperty( xv, "min", 0.0 );
4677 setPreferenceProperty( xv, "max", 1.0 );
4678 setPreferenceProperty( xv, "step", 0.1 );
4679 setPreferenceProperty( xh, "min", 0.0 );
4680 setPreferenceProperty( xh, "max", 1.0 );
4681 setPreferenceProperty( xh, "step", 0.1 );
4682 setPreferenceProperty( yh, "min", 0.0 );
4683 setPreferenceProperty( yh, "max", 1.0 );
4684 setPreferenceProperty( yh, "step", 0.1 );
4685 setPreferenceProperty( wh, "min", 0.0 );
4686 setPreferenceProperty( wh, "max", 1.0 );
4687 setPreferenceProperty( wh, "step", 0.1 );
4688 setPreferenceProperty( hh, "min", 0.0 );
4689 setPreferenceProperty( hh, "max", 1.0 );
4690 setPreferenceProperty( hh, "step", 0.1 );
4692 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4693 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4694 setPreferenceProperty( distributionGr, "columns", 3 );
4696 types.append( tr( "SMESH_MONOCOLOR" ) );
4697 types.append( tr( "SMESH_MULTICOLOR" ) );
4698 indices.clear(); indices.append( 0 ); indices.append( 1 );
4699 setPreferenceProperty( coloringType, "strings", types );
4700 setPreferenceProperty( coloringType, "indexes", indices );
4701 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4705 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4707 if( sect=="SMESH" ) {
4708 float sbX1,sbY1,sbW,sbH;
4709 float aTol = 1.00000009999999;
4710 std::string aWarning;
4711 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4712 if( name=="selection_object_color" || name=="selection_element_color" ||
4713 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4714 name=="selection_precision_node" || name=="selection_precision_element" ||
4715 name=="selection_precision_object")
4716 SMESH::UpdateSelectionProp( this );
4717 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4718 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4719 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4720 if(sbX1+sbW > aTol){
4721 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4724 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4725 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4728 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4729 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4730 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4731 if(sbY1+sbH > aTol){
4732 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4733 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4734 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4737 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4738 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4739 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4740 if(sbX1+sbW > aTol){
4741 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4744 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4745 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4748 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4749 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4750 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4751 if(sbY1+sbH > aTol){
4752 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4755 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4756 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4759 else if ( name == "segmentation" ) {
4760 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4761 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4763 else if ( name == "nb_segments_per_edge" ) {
4764 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4765 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4768 if(aWarning.size() != 0){
4769 aWarning += "The default values are applied instead.";
4770 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4771 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4772 QObject::tr(aWarning.c_str()));
4777 //================================================================================
4779 * \brief Update something in accordance with update flags
4780 * \param theFlags - update flags
4782 * Update viewer or/and object browser etc. in accordance with update flags ( see
4783 * LightApp_UpdateFlags enumeration ).
4785 //================================================================================
4786 void SMESHGUI::update( const int flags )
4788 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4789 SMESH::UpdateView();
4791 SalomeApp_Module::update( flags );
4794 //================================================================================
4796 * \brief Set default selection mode
4798 * SLOT called when operation commited. Sets default selection mode
4800 //================================================================================
4801 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4803 SVTK_ViewWindow* vtkWnd =
4804 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4806 vtkWnd->SetSelectionMode( ActorSelection );
4809 //================================================================================
4811 * \brief Set default selection mode
4813 * SLOT called when operation aborted. Sets default selection mode
4815 //================================================================================
4816 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4818 SVTK_ViewWindow* vtkWnd =
4819 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4821 vtkWnd->SetSelectionMode( ActorSelection );
4824 //================================================================================
4826 * \brief Creates operation with given identifier
4827 * \param id - identifier of operation to be started
4828 * \return Pointer on created operation or NULL if operation is not created
4830 * Virtual method redefined from the base class creates operation with given id.
4831 * It is called called automatically from startOperation method of base class.
4833 //================================================================================
4834 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4836 LightApp_Operation* op = 0;
4837 // to do : create operation here
4840 case 417: //convert to quadratic
4841 op = new SMESHGUI_ConvToQuadOp();
4843 case 418: // create 2D mesh as boundary on 3D
4844 op = new SMESHGUI_Make2DFrom3DOp();
4846 case 701: // Compute mesh
4847 op = new SMESHGUI_ComputeOp();
4849 case 702: // Create mesh
4850 op = new SMESHGUI_MeshOp( true, true );
4852 case 703: // Create sub-mesh
4853 op = new SMESHGUI_MeshOp( true, false );
4855 case 704: // Edit mesh/sub-mesh
4856 op = new SMESHGUI_MeshOp( false );
4858 case 711: // Precompute mesh
4859 op = new SMESHGUI_PrecomputeOp();
4861 case 712: // Evaluate mesh
4862 op = new SMESHGUI_EvaluateOp();
4864 case 713: // Evaluate mesh
4865 op = new SMESHGUI_MeshOrderOp();
4867 case 806: // Create group on geom
4868 op = new SMESHGUI_GroupOnShapeOp();
4870 case 904: // Find element
4871 op = new SMESHGUI_FindElemByPointOp();
4873 case 4067: // make mesh pass through point
4874 op = new SMESHGUI_MakeNodeAtPointOp();
4881 op = SalomeApp_Module::createOperation( id );
4885 //================================================================================
4887 * \brief Stops current operations and starts a given one
4888 * \param id - The id of the operation to start
4890 //================================================================================
4892 void SMESHGUI::switchToOperation(int id)
4894 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4895 activeStudy()->abortAllOperations();
4896 startOperation( id );
4899 LightApp_Displayer* SMESHGUI::displayer()
4902 myDisplayer = new SMESHGUI_Displayer( getApp() );
4906 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4909 int aTolerance = 64;
4910 int anIterations = 0;
4916 if( anIterations % aPeriod == 0 )
4919 if( aTolerance < 1 )
4923 aHue = (int)( 360.0 * rand() / RAND_MAX );
4926 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4927 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4928 for( ; it != itEnd; ++it )
4930 SALOMEDS::Color anAutoColor = *it;
4931 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4934 aQColor.getHsv( &h, &s, &v );
4935 if( abs( h - aHue ) < aTolerance )
4947 aColor.setHsv( aHue, 255, 255 );
4949 SALOMEDS::Color aSColor;
4950 aSColor.R = (double)aColor.red() / 255.0;
4951 aSColor.G = (double)aColor.green() / 255.0;
4952 aSColor.B = (double)aColor.blue() / 255.0;
4957 const char gSeparator = '_'; // character used to separate parameter names
4958 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4959 const char gPathSep = '|'; // character used to separate paths
4962 * \brief Store visual parameters
4964 * This method is called just before the study document is saved.
4965 * Store visual parameters in AttributeParameter attribue(s)
4967 void SMESHGUI::storeVisualParameters (int savePoint)
4969 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4970 if (!appStudy || !appStudy->studyDS())
4972 _PTR(Study) studyDS = appStudy->studyDS();
4974 // componentName is used for encoding of entries when storing them in IParameters
4975 std::string componentName = myComponentSMESH->ComponentDataType();
4976 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4977 //if (!aSComponent) return;
4980 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4981 componentName.c_str(),
4983 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4985 // store map of custom markers
4986 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4987 if( !aMarkerMap.empty() )
4989 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4990 for( ; anIter != aMarkerMap.end(); anIter++ )
4992 int anId = anIter->first;
4993 VTK::MarkerData aMarkerData = anIter->second;
4994 std::string aMarkerFileName = aMarkerData.first;
4995 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4996 if( aMarkerTexture.size() < 3 )
4997 continue; // should contain at least width, height and the first value
4999 QString aPropertyName( "texture" );
5000 aPropertyName += gSeparator;
5001 aPropertyName += QString::number( anId );
5003 QString aPropertyValue = aMarkerFileName.c_str();
5004 aPropertyValue += gPathSep;
5006 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5007 ushort aWidth = *aTextureIter++;
5008 ushort aHeight = *aTextureIter++;
5009 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5010 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5011 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5012 aPropertyValue += QString::number( *aTextureIter );
5014 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5018 // viewers counters are used for storing view_numbers in IParameters
5021 // main cycle to store parameters of displayed objects
5022 QList<SUIT_ViewManager*> lst;
5023 QList<SUIT_ViewManager*>::Iterator it;
5024 getApp()->viewManagers(lst);
5025 for (it = lst.begin(); it != lst.end(); it++)
5027 SUIT_ViewManager* vman = *it;
5028 QString vType = vman->getType();
5030 // saving VTK actors properties
5031 if (vType == SVTK_Viewer::Type())
5033 // store the clipping planes attached to the view manager
5034 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5035 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5036 if( anIter != myClippingPlaneInfoMap.end() )
5037 aClippingPlaneInfoList = anIter->second;
5039 if( !aClippingPlaneInfoList.empty() ) {
5040 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5041 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5043 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5044 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5046 QString aPropertyName( "ClippingPlane" );
5047 aPropertyName += gSeparator;
5048 aPropertyName += QString::number( vtkViewers );
5049 aPropertyName += gSeparator;
5050 aPropertyName += QString::number( anId );
5052 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5053 aPropertyValue += gDigitsSep;
5054 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5055 aPropertyValue += gDigitsSep;
5056 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5057 aPropertyValue += gDigitsSep;
5058 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5060 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5064 QVector<SUIT_ViewWindow*> views = vman->getViews();
5065 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5067 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5069 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5070 vtkActorCollection* allActors = aCopy.GetActors();
5071 allActors->InitTraversal();
5072 while (vtkActor* actor = allActors->GetNextActor())
5074 if (actor->GetVisibility()) // store only visible actors
5076 SMESH_Actor* aSmeshActor = 0;
5077 if (actor->IsA("SMESH_Actor"))
5078 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5079 if (aSmeshActor && aSmeshActor->hasIO())
5081 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5084 // entry is "encoded" = it does NOT contain component adress,
5085 // since it is a subject to change on next component loading
5086 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5088 std::string param, vtkParam = vType.toLatin1().data();
5089 vtkParam += gSeparator;
5090 vtkParam += QString::number(vtkViewers).toLatin1().data();
5091 vtkParam += gSeparator;
5094 param = vtkParam + "Visibility";
5095 ip->setParameter(entry, param, "On");
5098 param = vtkParam + "Representation";
5099 ip->setParameter(entry, param, QString::number
5100 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5103 param = vtkParam + "IsShrunk";
5104 ip->setParameter(entry, param, QString::number
5105 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5107 // Displayed entities
5108 unsigned int aMode = aSmeshActor->GetEntityMode();
5109 bool isE = aMode & SMESH_Actor::eEdges;
5110 bool isF = aMode & SMESH_Actor::eFaces;
5111 bool isV = aMode & SMESH_Actor::eVolumes;
5113 QString modeStr ("e");
5114 modeStr += gDigitsSep; modeStr += QString::number(isE);
5115 modeStr += gDigitsSep; modeStr += "f";
5116 modeStr += gDigitsSep; modeStr += QString::number(isF);
5117 modeStr += gDigitsSep; modeStr += "v";
5118 modeStr += gDigitsSep; modeStr += QString::number(isV);
5120 param = vtkParam + "Entities";
5121 ip->setParameter(entry, param, modeStr.toLatin1().data());
5123 // Colors (surface:edge:)
5124 vtkFloatingPointType r, g, b;
5127 aSmeshActor->GetSufaceColor(r, g, b, delta);
5128 QString colorStr ("surface");
5129 colorStr += gDigitsSep; colorStr += QString::number(r);
5130 colorStr += gDigitsSep; colorStr += QString::number(g);
5131 colorStr += gDigitsSep; colorStr += QString::number(b);
5133 colorStr += gDigitsSep; colorStr += "backsurface";
5134 colorStr += gDigitsSep; colorStr += QString::number(delta);
5137 aSmeshActor->GetEdgeColor(r, g, b);
5138 colorStr += gDigitsSep; colorStr += "edge";
5139 colorStr += gDigitsSep; colorStr += QString::number(r);
5140 colorStr += gDigitsSep; colorStr += QString::number(g);
5141 colorStr += gDigitsSep; colorStr += QString::number(b);
5143 aSmeshActor->GetOutlineColor(r, g, b);
5144 colorStr += gDigitsSep; colorStr += "outline";
5145 colorStr += gDigitsSep; colorStr += QString::number(r);
5146 colorStr += gDigitsSep; colorStr += QString::number(g);
5147 colorStr += gDigitsSep; colorStr += QString::number(b);
5149 aSmeshActor->GetNodeColor(r, g, b);
5150 colorStr += gDigitsSep; colorStr += "node";
5151 colorStr += gDigitsSep; colorStr += QString::number(r);
5152 colorStr += gDigitsSep; colorStr += QString::number(g);
5153 colorStr += gDigitsSep; colorStr += QString::number(b);
5155 param = vtkParam + "Colors";
5156 ip->setParameter(entry, param, colorStr.toLatin1().data());
5158 // Sizes of lines and points
5159 QString sizeStr ("line");
5160 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5161 sizeStr += gDigitsSep; sizeStr += "shrink";
5162 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5164 param = vtkParam + "Sizes";
5165 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5170 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5171 if( aMarkerType == VTK::MT_USER ) {
5172 markerStr += "custom";
5173 markerStr += gDigitsSep;
5174 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5178 markerStr += gDigitsSep;
5179 markerStr += QString::number( (int)aMarkerType );
5180 markerStr += gDigitsSep;
5181 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5184 param = vtkParam + "PointMarker";
5185 ip->setParameter(entry, param, markerStr.toLatin1().data());
5188 param = vtkParam + "Opacity";
5189 ip->setParameter(entry, param,
5190 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5193 param = vtkParam + "ClippingPlane";
5195 if( !aClippingPlaneInfoList.empty() ) {
5196 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5197 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5199 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5200 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5201 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5202 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5203 if( aSmeshActor == *anIter2 ) {
5204 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5205 QString::number( anId ).toLatin1().constData() );
5212 ip->setParameter( entry, param, "Off" );
5213 } // if (io->hasEntry())
5214 } // SMESH_Actor && hasIO
5216 } // while.. actors traversal
5220 } // if (SVTK view model)
5221 } // for (viewManagers)
5224 // data structures for clipping planes processing
5227 vtkIdType Orientation;
5228 vtkFloatingPointType Distance;
5229 vtkFloatingPointType Angle[2];
5231 typedef std::list<TPlaneData> TPlaneDataList;
5232 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5234 typedef std::list<vtkActor*> TActorList;
5237 TActorList ActorList;
5238 SUIT_ViewManager* ViewManager;
5240 typedef std::list<TPlaneInfo> TPlaneInfoList;
5241 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5244 * \brief Restore visual parameters
5246 * This method is called after the study document is opened.
5247 * Restore visual parameters from AttributeParameter attribue(s)
5249 void SMESHGUI::restoreVisualParameters (int savePoint)
5251 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5252 if (!appStudy || !appStudy->studyDS())
5254 _PTR(Study) studyDS = appStudy->studyDS();
5256 // componentName is used for encoding of entries when storing them in IParameters
5257 std::string componentName = myComponentSMESH->ComponentDataType();
5258 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5259 //if (!aSComponent) return;
5262 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5263 componentName.c_str(),
5265 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5267 // restore map of custom markers and map of clipping planes
5268 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5269 TPlaneDataMap aPlaneDataMap;
5271 std::vector<std::string> properties = ip->getProperties();
5272 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5274 std::string property = *propIt;
5275 QString aPropertyName( property.c_str() );
5276 QString aPropertyValue( ip->getProperty( property ).c_str() );
5278 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5279 if( aPropertyNameList.isEmpty() )
5282 QString aPropertyType = aPropertyNameList[0];
5283 if( aPropertyType == "texture" )
5285 if( aPropertyNameList.size() != 2 )
5289 int anId = aPropertyNameList[1].toInt( &ok );
5290 if( !ok || anId < 1 )
5293 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5294 if( aPropertyValueList.size() != 2 )
5297 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5298 QString aMarkerTextureString = aPropertyValueList[1];
5299 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5300 if( aMarkerTextureStringList.size() != 3 )
5304 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5309 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5313 VTK::MarkerTexture aMarkerTexture;
5314 aMarkerTexture.push_back( aWidth );
5315 aMarkerTexture.push_back( aHeight );
5317 QString aMarkerTextureData = aMarkerTextureStringList[2];
5318 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5320 QChar aChar = aMarkerTextureData.at( i );
5321 if( aChar.isDigit() )
5322 aMarkerTexture.push_back( aChar.digitValue() );
5325 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5327 else if( aPropertyType == "ClippingPlane" )
5329 if( aPropertyNameList.size() != 3 )
5333 int aViewId = aPropertyNameList[1].toInt( &ok );
5334 if( !ok || aViewId < 0 )
5338 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5339 if( !ok || aClippingPlaneId < 0 )
5342 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5343 if( aPropertyValueList.size() != 4 )
5346 TPlaneData aPlaneData;
5347 aPlaneData.Id = aClippingPlaneId;
5350 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5355 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5360 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5365 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5369 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5370 aPlaneDataList.push_back( aPlaneData );
5374 TPlaneInfoMap aPlaneInfoMap;
5376 std::vector<std::string> entries = ip->getEntries();
5378 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5380 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5381 QString entry (ip->decodeEntry(*entIt).c_str());
5383 // Check that the entry corresponds to a real object in the Study
5384 // as the object may be deleted or modified after the visual state is saved.
5385 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5386 if (!so) continue; //Skip the not existent entry
5388 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5389 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5391 std::vector<std::string>::iterator namesIt = paramNames.begin();
5392 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5394 // actors are stored in a map after displaying of them for
5395 // quicker access in the future: map < viewID to actor >
5396 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5398 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5400 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5401 // '_' is used as separator and should not be used in viewer type or parameter names.
5402 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5403 if (lst.size() != 3)
5406 QString viewerTypStr = lst[0];
5407 QString viewIndexStr = lst[1];
5408 QString paramNameStr = lst[2];
5411 int viewIndex = viewIndexStr.toUInt(&ok);
5412 if (!ok) // bad conversion of view index to integer
5416 if (viewerTypStr == SVTK_Viewer::Type())
5418 SMESH_Actor* aSmeshActor = 0;
5419 if (vtkActors.IsBound(viewIndex))
5420 aSmeshActor = vtkActors.Find(viewIndex);
5422 QList<SUIT_ViewManager*> lst;
5423 getApp()->viewManagers(viewerTypStr, lst);
5425 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5426 SUIT_ViewManager* vman = NULL;
5427 if (viewIndex >= 0 && viewIndex < lst.count())
5428 vman = lst.at(viewIndex);
5430 if (paramNameStr == "Visibility")
5432 if (!aSmeshActor && displayer() && vman)
5434 SUIT_ViewModel* vmodel = vman->getViewModel();
5435 // SVTK view model can be casted to SALOME_View
5436 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5438 // store displayed actor in a temporary map for quicker
5439 // access later when restoring other parameters
5440 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5441 vtkRenderer* Renderer = vtkView->getRenderer();
5442 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5443 vtkActorCollection* theActors = aCopy.GetActors();
5444 theActors->InitTraversal();
5445 bool isFound = false;
5446 vtkActor *ac = theActors->GetNextActor();
5447 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5448 if (ac->IsA("SMESH_Actor")) {
5449 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5450 if (aGeomAc->hasIO()) {
5451 Handle(SALOME_InteractiveObject) io =
5452 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5453 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5455 vtkActors.Bind(viewIndex, aGeomAc);
5461 } // if (paramNameStr == "Visibility")
5464 // the rest properties "work" with SMESH_Actor
5467 QString val ((*valuesIt).c_str());
5470 if (paramNameStr == "Representation") {
5471 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5474 else if (paramNameStr == "IsShrunk") {
5476 if (!aSmeshActor->IsShrunk())
5477 aSmeshActor->SetShrink();
5480 if (aSmeshActor->IsShrunk())
5481 aSmeshActor->UnShrink();
5484 // Displayed entities
5485 else if (paramNameStr == "Entities") {
5486 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5487 if (mode.count() == 6) {
5488 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5489 MESSAGE("Invalid order of data in Entities, must be: "
5490 "e:0/1:f:0/1:v:0/1");
5493 unsigned int aMode = aSmeshActor->GetEntityMode();
5494 unsigned int aNewMode =
5495 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5496 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5497 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5498 if (aNewMode != aMode)
5499 aSmeshActor->SetEntityMode(aNewMode);
5504 else if (paramNameStr == "Colors") {
5505 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5506 if (colors.count() == 16 || colors.count() == 17 ) {
5507 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5508 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node")) {
5509 MESSAGE("Invalid order of data in Colors, must be: "
5510 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b or surface:r:g:b:backsurface:delta:edge:r:g:b:node:r:g:b:outline:r:g:b");
5516 vtkFloatingPointType otr,otg,otb;
5517 //Old case backsurface color is independent
5518 if( colors.count() == 16 ) {
5520 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5521 er = colors[9].toFloat();
5522 eg = colors[10].toFloat();
5523 eb = colors[11].toFloat();
5525 nr = colors[13].toFloat();
5526 ng = colors[14].toFloat();
5527 nb = colors[15].toFloat();
5528 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5530 //New case backsurface color depends on surface color
5531 delta = colors[5].toInt();
5533 er = colors[7].toFloat();
5534 eg = colors[8].toFloat();
5535 eb = colors[9].toFloat();
5537 nr = colors[11].toFloat();
5538 ng = colors[12].toFloat();
5539 nb = colors[13].toFloat();
5541 otr = colors[14].toFloat();
5542 otg = colors[15].toFloat();
5543 otb = colors[16].toFloat();
5545 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5546 aSmeshActor->SetEdgeColor(er,eg,eb);
5547 aSmeshActor->SetNodeColor(nr,ng,nb);
5548 aSmeshActor->SetOutlineColor(otr,otg,otb);
5552 // Sizes of lines and points
5553 else if (paramNameStr == "Sizes") {
5554 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5555 if (sizes.count() == 4) {
5556 if (sizes[0] != "line" || sizes[2] != "shrink") {
5557 MESSAGE("Invalid order of data in Sizes, must be: "
5558 "line:int:shrink:float");
5561 aSmeshActor->SetLineWidth(sizes[1].toInt());
5562 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5565 else if (sizes.count() == 6) { // just to support old format
5566 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5567 MESSAGE("Invalid order of data in Sizes, must be: "
5568 "line:int:node:int:shrink:float");
5571 aSmeshActor->SetLineWidth(sizes[1].toInt());
5572 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5573 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5578 else if (paramNameStr == "PointMarker") {
5579 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5580 if( data.count() >= 2 ) {
5582 int aParam1 = data[1].toInt( &ok );
5584 if( data[0] == "std" && data.count() == 3 ) {
5585 int aParam2 = data[2].toInt( &ok );
5586 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5588 else if( data[0] == "custom" ) {
5589 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5590 if( markerIt != aMarkerMap.end() ) {
5591 VTK::MarkerData aMarkerData = markerIt->second;
5592 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5599 else if (paramNameStr == "Opacity") {
5600 aSmeshActor->SetOpacity(val.toFloat());
5603 else if (paramNameStr.startsWith("ClippingPlane")) {
5604 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5605 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5606 // new format - val looks like "Off" or "0" (plane id)
5607 // (note: in new format "Off" value is used only for consistency,
5608 // so it is processed together with values in old format)
5609 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5610 if( anIsOldFormat ) {
5611 if (paramNameStr == "ClippingPlane1" || val == "Off")
5612 aSmeshActor->RemoveAllClippingPlanes();
5614 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5615 double aDistance = vals[1].toFloat();
5616 vtkFloatingPointType anAngle[2];
5617 anAngle[0] = vals[2].toFloat();
5618 anAngle[1] = vals[3].toFloat();
5620 QList<SUIT_ViewManager*> lst;
5621 getApp()->viewManagers(viewerTypStr, lst);
5622 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5623 if (viewIndex >= 0 && viewIndex < lst.count()) {
5624 SUIT_ViewManager* vman = lst.at(viewIndex);
5625 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5627 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5629 SMESH::TActorList anActorList;
5630 anActorList.push_back( aSmeshActor );
5631 SMESH::OrientedPlane* aPlane =
5632 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5634 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5635 aClippingPlaneInfo.Plane = aPlane;
5636 aClippingPlaneInfo.ActorList = anActorList;
5637 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5644 int aPlaneId = val.toInt( &ok );
5645 if( ok && aPlaneId >= 0 ) {
5646 bool anIsDefinedPlane = false;
5647 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5648 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5649 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5650 TPlaneInfo& aPlaneInfo = *anIter;
5651 if( aPlaneInfo.PlaneId == aPlaneId ) {
5652 aPlaneInfo.ActorList.push_back( aSmeshActor );
5653 anIsDefinedPlane = true;
5657 if( !anIsDefinedPlane ) {
5658 TPlaneInfo aPlaneInfo;
5659 aPlaneInfo.PlaneId = aPlaneId;
5660 aPlaneInfo.ActorList.push_back( aSmeshActor );
5661 aPlaneInfo.ViewManager = vman;
5663 // to make the list sorted by plane id
5664 anIter = aPlaneInfoList.begin();
5665 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5666 const TPlaneInfo& aPlaneInfoRef = *anIter;
5667 if( aPlaneInfoRef.PlaneId > aPlaneId )
5670 aPlaneInfoList.insert( anIter, aPlaneInfo );
5675 } // if (aSmeshActor)
5676 } // other parameters than Visibility
5678 } // for names/parameters iterator
5679 } // for entries iterator
5681 // take into account planes with empty list of actors referred to them
5682 QList<SUIT_ViewManager*> aVMList;
5683 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5685 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5686 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5687 int aViewId = aPlaneDataIter->first;
5688 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5689 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5691 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5693 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5694 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5695 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5696 const TPlaneData& aPlaneData = *anIter2;
5697 int aPlaneId = aPlaneData.Id;
5699 bool anIsFound = false;
5700 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5701 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5702 const TPlaneInfo& aPlaneInfo = *anIter3;
5703 if( aPlaneInfo.PlaneId == aPlaneId ) {
5710 TPlaneInfo aPlaneInfo; // ActorList field is empty
5711 aPlaneInfo.PlaneId = aPlaneId;
5712 aPlaneInfo.ViewManager = aViewManager;
5714 // to make the list sorted by plane id
5715 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5716 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5717 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5718 if( aPlaneInfoRef.PlaneId > aPlaneId )
5721 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5727 // add clipping planes to actors according to the restored parameters
5728 // and update the clipping plane map
5729 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5730 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5731 int aViewId = anIter1->first;
5732 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5734 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5735 if( anIter2 == aPlaneDataMap.end() )
5737 const TPlaneDataList& aPlaneDataList = anIter2->second;
5739 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5740 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5741 const TPlaneInfo& aPlaneInfo = *anIter3;
5742 int aPlaneId = aPlaneInfo.PlaneId;
5743 const TActorList& anActorList = aPlaneInfo.ActorList;
5744 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5748 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5752 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5754 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5755 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5756 const TPlaneData& aPlaneData = *anIter4;
5757 if( aPlaneData.Id == aPlaneId ) {
5758 SMESH::OrientedPlane* aPlane =
5759 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5761 (SMESH::Orientation)aPlaneData.Orientation,
5762 aPlaneData.Distance,
5765 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5766 aClippingPlaneInfo.Plane = aPlane;
5767 aClippingPlaneInfo.ActorList = anActorList;
5768 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5776 // update all VTK views
5777 QList<SUIT_ViewManager*> lst;
5778 getApp()->viewManagers(lst);
5779 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5780 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5781 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5782 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5783 vtkView->getRenderer()->ResetCameraClippingRange();
5790 \brief Adds preferences for dfont of VTK viewer
5792 \param pIf group identifier
5793 \param param parameter
5794 \return identifier of preferences
5796 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5798 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5800 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5803 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5804 fam.append( tr( "SMESH_FONT_COURIER" ) );
5805 fam.append( tr( "SMESH_FONT_TIMES" ) );
5807 setPreferenceProperty( tfont, "fonts", fam );
5809 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5810 setPreferenceProperty( tfont, "features", f );
5816 \brief Actions after hypothesis edition
5817 Updates object browser after hypothesis edition
5819 void SMESHGUI::onHypothesisEdit( int result )
5822 SMESHGUI::Modified();
5823 updateObjBrowser( true );
5828 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5829 \param pview view being closed
5831 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5832 #ifndef DISABLE_PLOT2DVIEWER
5833 //Crear all Plot2d Viewers if need.
5834 SMESH::ClearPlot2Viewers(pview);
5839 \brief Connects or disconnects signals about activating and cloning view on the module slots
5840 \param pview view which is connected/disconnected
5842 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5846 SUIT_ViewManager* viewMgr = pview->getViewManager();
5848 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5849 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5851 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5852 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5857 \brief Return \c true if object can be renamed
5859 bool SMESHGUI::renameAllowed( const QString& entry) const {
5860 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5864 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5868 bool appRes = SalomeApp_Module::renameAllowed(entry);
5872 // check type to prevent renaming of inappropriate objects
5873 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5874 if (aType == MESH || aType == GROUP ||
5875 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5876 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5877 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5878 aType == HYPOTHESIS || aType == ALGORITHM)
5885 Rename object by entry.
5886 \param entry entry of the object
5887 \param name new name of the object
5888 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5890 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5892 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5896 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5900 bool appRes = SalomeApp_Module::renameObject(entry,name);
5904 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5905 _PTR(GenericAttribute) anAttr;
5906 _PTR(AttributeName) aName;
5908 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5910 // check type to prevent renaming of inappropriate objects
5911 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5912 if (aType == MESH || aType == GROUP ||
5913 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5914 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5915 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5916 aType == HYPOTHESIS || aType == ALGORITHM) {
5917 if ( !name.isEmpty() ) {
5918 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5920 // update name of group object and its actor
5921 Handle(SALOME_InteractiveObject) IObject =
5922 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5924 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5925 if( !aGroupObject->_is_nil() ) {
5926 aGroupObject->SetName( qPrintable(name) );
5927 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5928 anActor->setName( qPrintable(name) );