1 // Copyright (C) 2007-2010 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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
30 #include "SMESHGUI_AddMeshElementDlg.h"
31 #include "SMESHGUI_AddQuadraticElementDlg.h"
32 #include "SMESHGUI_BuildCompoundDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_ComputeDlg.h"
35 #include "SMESHGUI_ConvToQuadOp.h"
36 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
37 #include "SMESHGUI_DeleteGroupDlg.h"
38 #include "SMESHGUI_Displayer.h"
39 #include "SMESHGUI_MergeDlg.h"
40 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
41 #include "SMESHGUI_ExtrusionDlg.h"
42 #include "SMESHGUI_FileInfoDlg.h"
43 #include "SMESHGUI_FileValidator.h"
44 #include "SMESHGUI_FilterDlg.h"
45 #include "SMESHGUI_FilterLibraryDlg.h"
46 #include "SMESHGUI_FindElemByPointDlg.h"
47 #include "SMESHGUI_GroupDlg.h"
48 #include "SMESHGUI_GroupOnShapeDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_Hypotheses.h"
51 #include "SMESHGUI_Make2DFrom3DOp.h"
52 #include "SMESHGUI_MakeNodeAtPointDlg.h"
53 //#include "SMESHGUI_MeshInfosDlg.h"
54 #include "SMESHGUI_Measurements.h"
55 #include "SMESHGUI_MeshInfo.h"
56 #include "SMESHGUI_MeshOp.h"
57 #include "SMESHGUI_MeshOrderOp.h"
58 #include "SMESHGUI_MeshPatternDlg.h"
59 #include "SMESHGUI_MultiEditDlg.h"
60 #include "SMESHGUI_NodesDlg.h"
61 #include "SMESHGUI_Preferences_ColorDlg.h"
62 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
63 #include "SMESHGUI_RemoveElementsDlg.h"
64 #include "SMESHGUI_RemoveNodesDlg.h"
65 #include "SMESHGUI_RenumberingDlg.h"
66 #include "SMESHGUI_RevolutionDlg.h"
67 #include "SMESHGUI_RotationDlg.h"
68 #include "SMESHGUI_Selection.h"
69 #include "SMESHGUI_SewingDlg.h"
70 #include "SMESHGUI_SingleEditDlg.h"
71 #include "SMESHGUI_SmoothingDlg.h"
72 //#include "SMESHGUI_StandardMeshInfosDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.h"
77 //#include "SMESHGUI_WhatIsDlg.h"
78 #include "SMESHGUI_DuplicateNodesDlg.h"
79 #include "SMESHGUI_CopyMeshDlg.h"
81 #include "SMESHGUI_Utils.h"
82 #include "SMESHGUI_MeshUtils.h"
83 #include "SMESHGUI_GroupUtils.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_PatternUtils.h"
86 #include "SMESHGUI_VTKUtils.h"
87 #include "SMESHGUI_HypothesesUtils.h"
89 #include <SMESH_Client.hxx>
90 #include <SMESH_Actor.h>
91 #include <SMESH_ScalarBarActor.h>
92 #include <SMESH_ActorUtils.h>
93 #include <SMESH_TypeFilter.hxx>
94 #include "SMESH_ControlsDef.hxx"
96 // SALOME GUI includes
97 #include <SalomeApp_Tools.h>
98 #include <SalomeApp_Study.h>
99 #include <SalomeApp_Application.h>
100 #include <SalomeApp_CheckFileDlg.h>
102 #include <LightApp_DataOwner.h>
103 #include <LightApp_Preferences.h>
104 #include <LightApp_SelectionMgr.h>
105 #include <LightApp_UpdateFlags.h>
106 #include <LightApp_NameDlg.h>
108 #include <SVTK_ViewWindow.h>
109 #include <SVTK_ViewModel.h>
110 #include <SVTK_ViewManager.h>
112 #include <VTKViewer_Algorithm.h>
114 #include <SUIT_MessageBox.h>
115 #include <SUIT_ResourceMgr.h>
116 #include <SUIT_FileDlg.h>
117 #include <SUIT_Desktop.h>
118 #include <SUIT_OverrideCursor.h>
119 #include <SUIT_Session.h>
121 #include <QtxPopupMgr.h>
122 #include <QtxFontEdit.h>
124 #include <SALOME_ListIO.hxx>
125 #include <SALOME_ListIteratorOfListIO.hxx>
127 #ifndef DISABLE_PLOT2DVIEWER
128 #include <SPlot2d_ViewModel.h>
129 #include <SPlot2d_Histogram.h>
133 #include <SALOMEconfig.h>
134 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
135 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
136 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
139 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
141 #include <QTextStream>
144 #include <boost/shared_ptr.hpp>
147 #include <vtkCamera.h>
148 #include <vtkRenderer.h>
149 #include <vtkPlane.h>
150 #include <vtkCallbackCommand.h>
151 #include <vtkLookupTable.h>
153 // SALOME KERNEL includes
154 #include <SALOMEDS_Study.hxx>
155 #include <SALOMEDSClient_StudyBuilder.hxx>
156 #include <SALOMEDSClient_SComponent.hxx>
157 #include <SALOMEDSClient_ClientFactory.hxx>
158 #include <SALOMEDSClient_IParameters.hxx>
161 #include <Standard_ErrorHandler.hxx>
162 #include <NCollection_DataMap.hxx>
164 //To disable automatic genericobj management, the following line should be commented.
165 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
166 #define WITHGENERICOBJ
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
174 void ExportMeshToFile(int theCommandID);
176 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
178 void SetDisplayEntity(int theCommandID);
180 void Control( int theCommandID );
184 //=============================================================
185 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
189 std::string myExtension;
191 if ( theCommandID == 113 ) {
192 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
193 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
195 else if ( theCommandID == 112 ) {
196 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
198 else if ( theCommandID == 111 ) {
199 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
201 else if ( theCommandID == 140 ) {
202 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
205 QString anInitialPath = "";
206 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
207 anInitialPath = QDir::currentPath();
209 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
212 QObject::tr( "SMESH_IMPORT_MESH" ) );
213 if ( filenames.count() > 0 ) {
214 SUIT_OverrideCursor wc;
215 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
218 bool isEmpty = false;
219 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
220 QString filename = *it;
221 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
223 switch ( theCommandID ) {
226 // DAT format (currently unsupported)
227 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
228 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
234 aMeshes->length( 1 );
235 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
236 if ( aMeshes[0]->_is_nil() )
237 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
238 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
244 SMESH::DriverMED_ReadStatus res;
245 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
246 if ( res != SMESH::DRS_OK ) {
247 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
248 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
255 aMeshes->length( 1 );
256 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
257 if ( aMeshes[0]->_is_nil() ) {
258 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
259 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
265 catch ( const SALOME::SALOME_Exception& S_ex ) {
266 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
267 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
270 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
271 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
273 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
274 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
275 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
276 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
277 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
279 #ifdef WITHGENERICOBJ
280 // obj has been published in study. Its refcount has been incremented.
281 // It is safe to decrement its refcount
282 // so that it will be destroyed when the entry in study will be removed
283 aMeshes[i]->UnRegister();
292 // update Object browser
293 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
295 // show Error message box if there were errors
296 if ( errors.count() > 0 ) {
297 SUIT_MessageBox::critical( SMESHGUI::desktop(),
298 QObject::tr( "SMESH_ERROR" ),
299 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
302 // show warning message box, if some imported mesh is empty
304 SUIT_MessageBox::warning( SMESHGUI::desktop(),
305 QObject::tr( "SMESH_WRN_WARNING" ),
306 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
311 void ExportMeshToFile( int theCommandID )
313 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
314 SALOME_ListIO selected;
316 aSel->selectedObjects( selected );
318 // actually, the following condition can't be met (added for insurance)
319 if( selected.Extent() == 0 ||
320 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
323 bool hasDuplicatedMeshNames = false;
324 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
325 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
326 SALOME_ListIteratorOfListIO It( selected );
327 for( ; It.More(); It.Next() ) {
328 Handle(SALOME_InteractiveObject) anIObject = It.Value();
329 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
330 if ( aMeshItem->_is_nil() ) {
331 SUIT_MessageBox::warning( SMESHGUI::desktop(),
332 QObject::tr( "SMESH_WRN_WARNING" ),
333 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
337 QString aMeshName = anIObject->getName();
339 // check for duplications
340 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
341 if( aMeshName == (*aMeshIter).second ) {
342 hasDuplicatedMeshNames = true;
347 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
350 if( hasDuplicatedMeshNames ) {
351 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
352 QObject::tr("SMESH_WRN_WARNING"),
353 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
354 QObject::tr("SMESH_BUT_YES"),
355 QObject::tr("SMESH_BUT_NO"), 0, 1);
360 aMeshIter = aMeshList.begin();
361 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
362 QString aMeshName = (*aMeshIter).second;
364 QList<SALOMEDS::Color> aReservedColors;
366 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
367 QMap<QString, SMESH::MED_VERSION> aFilterMap;
368 QMap<QString, int> aFilterMapSTL;
369 switch ( theCommandID ) {
373 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
374 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
375 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
376 int aRet = SUIT_MessageBox::warning
377 (SMESHGUI::desktop(),
378 QObject::tr("SMESH_WRN_WARNING"),
379 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
380 QObject::tr("SMESH_BUT_YES"),
381 QObject::tr("SMESH_BUT_NO"), 0, 1);
387 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
388 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
389 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
390 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
395 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
400 if (aMesh->NbPyramids()) {
401 int aRet = SUIT_MessageBox::warning
402 (SMESHGUI::desktop(),
403 QObject::tr("SMESH_WRN_WARNING"),
404 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
405 QObject::tr("SMESH_BUT_YES"),
406 QObject::tr("SMESH_BUT_NO"), 0, 1);
410 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
417 there must be check on others mesh elements not equal triangles
419 // if (aMesh->NbTriangles() < 1) {
420 // SUIT_MessageBox::warning
421 // (SMESHGUI::desktop(),
422 // QObject::tr("SMESH_WRN_WARNING"),
423 // QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
426 // if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
427 // int aRet = SUIT_MessageBox::warning
428 // (SMESHGUI::desktop(),
429 // QObject::tr("SMESH_WRN_WARNING"),
430 // QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
431 // QObject::tr("SMESH_BUT_YES"),
432 // QObject::tr("SMESH_BUT_NO"), 0, 1);
437 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
438 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
446 SMESH::MED_VERSION aFormat;
447 // Init the parameter with the default value
448 bool aIsASCII_STL = true;
449 bool toCreateGroups = false;
450 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
452 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
453 bool toOverwrite = true;
455 QString anInitialPath = "";
456 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
457 anInitialPath = QDir::currentPath();
459 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 141) {
460 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
461 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
462 aFilter, aTitle, false);
464 else if(theCommandID == 141) { // Export to STL
466 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
467 for ( ; it != aFilterMapSTL.end(); ++it )
468 filters.push_back( it.key() );
470 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
471 fd->setWindowTitle( aTitle );
472 fd->setNameFilters( filters );
473 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
474 if ( !anInitialPath.isEmpty() )
475 fd->setDirectory( anInitialPath );
476 fd->selectFile(aMeshName);
480 aFilename = fd->selectedFile();
481 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
486 else { // Export to MED
488 QString aDefaultFilter;
489 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
490 for ( ; it != aFilterMap.end(); ++it ) {
491 filters.push_back( it.key() );
492 if (it.value() == SMESH::MED_V2_2)
493 aDefaultFilter = it.key();
496 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
497 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
498 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
499 fd->setWindowTitle( aTitle );
500 fd->setNameFilters( filters );
501 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
502 fd->selectNameFilter(aDefaultFilter);
503 fd->SetChecked(toCreateGroups);
504 if ( !anInitialPath.isEmpty() )
505 fd->setDirectory( anInitialPath );
506 fd->selectFile(aMeshName);
508 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
509 fd->setValidator( fv );
514 aFilename = fd->selectedFile();
516 aFilename = QString::null;
519 aFormat = aFilterMap[fd->selectedNameFilter()];
520 toOverwrite = fv->isOverwrite();
522 if ( !aFilename.isEmpty() ) {
523 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
524 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
525 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
526 && aFormat==SMESH::MED_V2_1) {
527 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
528 QObject::tr("SMESH_WRN_WARNING"),
529 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
530 QObject::tr("SMESH_BUT_YES"),
531 QObject::tr("SMESH_BUT_NO"), 0, 1);
539 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
540 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
541 if( !isVersionOk || aVersion != aFormat ) {
542 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
543 QObject::tr("SMESH_WRN_WARNING"),
544 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
545 QObject::tr("SMESH_BUT_YES"),
546 QObject::tr("SMESH_BUT_NO"), 0, 1);
553 QStringList aMeshNamesCollisionList;
554 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
555 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
556 QString anExistingMeshName( aMeshNames[ i ] );
557 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
558 QString anExportMeshName = (*aMeshIter).second;
559 if( anExportMeshName == anExistingMeshName ) {
560 aMeshNamesCollisionList.append( anExportMeshName );
566 if( !aMeshNamesCollisionList.isEmpty() ) {
567 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
568 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
569 QObject::tr("SMESH_WRN_WARNING"),
570 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
571 QObject::tr("SMESH_BUT_YES"),
572 QObject::tr("SMESH_BUT_NO"),
573 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
582 toCreateGroups = fd->IsChecked();
585 if ( !aFilename.isEmpty() ) {
586 // Check whether the file already exists and delete it if yes
587 QFile aFile( aFilename );
588 if ( aFile.exists() && toOverwrite )
590 SUIT_OverrideCursor wc;
593 bool Renumber = false;
594 // PAL 14172 : Check of we have to renumber or not from the preferences before export
596 Renumber= resMgr->booleanValue("SMESH","renumbering");
598 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
599 aMeshEditor->RenumberNodes();
600 aMeshEditor->RenumberElements();
601 if ( SMESHGUI::automaticUpdate() )
604 switch ( theCommandID ) {
608 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
609 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
610 if( !aMeshItem->_is_nil() )
611 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
617 aMesh->ExportDAT( aFilename.toLatin1().data() );
621 aMesh->ExportUNV( aFilename.toLatin1().data() );
624 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
630 catch (const SALOME::SALOME_Exception& S_ex){
632 SUIT_MessageBox::warning(SMESHGUI::desktop(),
633 QObject::tr("SMESH_WRN_WARNING"),
634 QObject::tr("SMESH_EXPORT_FAILED"));
640 inline void InverseEntityMode(unsigned int& theOutputMode,
641 unsigned int theMode)
643 bool anIsNotPresent = ~theOutputMode & theMode;
645 theOutputMode |= theMode;
647 theOutputMode &= ~theMode;
650 void SetDisplayEntity(int theCommandID){
651 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
652 SALOME_ListIO selected;
654 aSel->selectedObjects( selected );
656 if(selected.Extent() >= 1){
657 SALOME_ListIteratorOfListIO It( selected );
658 for( ; It.More(); It.Next()){
659 Handle(SALOME_InteractiveObject) IObject = It.Value();
660 if(IObject->hasEntry()){
661 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
662 unsigned int aMode = anActor->GetEntityMode();
663 switch(theCommandID){
665 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
668 InverseEntityMode(aMode,SMESH_Actor::eEdges);
671 InverseEntityMode(aMode,SMESH_Actor::eFaces);
674 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
677 aMode = SMESH_Actor::eAllEntity;
681 anActor->SetEntityMode(aMode);
689 SALOME_ListIO selected;
690 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
694 LightApp_SelectionMgr* aSel = app->selectionMgr();
695 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
696 if( !aSel || !appStudy )
699 aSel->selectedObjects( selected );
700 if( selected.IsEmpty() )
703 Handle(SALOME_InteractiveObject) anIObject = selected.First();
705 _PTR(Study) aStudy = appStudy->studyDS();
706 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
707 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
708 if( aMainObject->_is_nil() )
711 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
713 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
714 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
716 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
717 SALOMEDS::Color aColor = aGroupObject->GetColor();
718 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
720 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
721 if( aGroupObject->GetType() == SMESH::NODE )
722 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
723 else if( aGroupObject->GetType() == SMESH::EDGE )
724 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
725 else if( aGroupObject->GetType() == SMESH::ELEM0D )
726 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
728 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
733 SMESH::RepaintCurrentView();
736 QString functorToString( SMESH::Controls::FunctorPtr f )
738 QString type = QObject::tr( "UNKNOWN_CONTROL" );
739 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
740 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
741 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
742 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
743 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
744 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
745 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
746 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
747 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
748 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
749 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
750 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
751 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
752 type = QObject::tr( "WARP_ELEMENTS" );
753 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
754 type = QObject::tr( "TAPER_ELEMENTS" );
755 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
756 type = QObject::tr( "SKEW_ELEMENTS" );
757 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
758 type = QObject::tr( "AREA_ELEMENTS" );
759 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
760 type = QObject::tr( "LENGTH_EDGES" );
761 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
762 type = QObject::tr( "LENGTH2D_EDGES" );
763 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
764 type = QObject::tr( "MULTI_BORDERS" );
765 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
766 type = QObject::tr( "MULTI2D_BORDERS" );
767 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
768 type = QObject::tr( "FREE_NODES" );
769 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
770 type = QObject::tr( "FREE_EDGES" );
771 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
772 type = QObject::tr( "FREE_BORDERS" );
773 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
774 type = QObject::tr( "FREE_FACES" );
775 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
776 type = QObject::tr( "BARE_BORDER_VOLUME" );
777 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
778 type = QObject::tr( "BARE_BORDER_FACE" );
779 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
780 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
781 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
782 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
786 void SaveDistribution()
788 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
789 SALOME_ListIO selected;
791 aSel->selectedObjects( selected );
793 if ( selected.Extent() == 1 ) {
794 Handle(SALOME_InteractiveObject) anIO = selected.First();
795 if ( anIO->hasEntry() ) {
796 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
797 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
798 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
799 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
800 if ( aScalarBarActor && aFunctor ) {
801 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
803 std::vector<int> elements;
804 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
805 if ( mesh->_is_nil() ) {
806 SMESH::SMESH_IDSource_var idSource =
807 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
808 if ( !idSource->_is_nil() )
810 SMESH::long_array_var ids = idSource->GetIDs();
811 elements.resize( ids->length() );
812 for ( unsigned i = 0; i < elements.size(); ++i )
813 elements[i] = ids[i];
816 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
817 vtkLookupTable* lookupTable =
818 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
819 double * minmax = lookupTable->GetRange();
820 std::vector<int> nbEvents;
821 std::vector<double> funValues;
822 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
823 QString anInitialPath = "";
824 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
825 anInitialPath = QDir::currentPath();
826 QString aMeshName = anIO->getName();
828 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
829 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
830 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
831 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
832 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
835 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
837 if ( !aFilename.isEmpty() ) {
838 QFile f( aFilename );
839 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
840 QTextStream out( &f );
841 out << "# Mesh: " << aMeshName << endl;
842 out << "# Control: " << functorToString( aFunctor ) << endl;
844 out.setFieldWidth( 10 );
845 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
846 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
857 void ShowDistribution() {
858 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
859 SALOME_ListIO selected;
861 aSel->selectedObjects( selected );
863 if ( selected.Extent() == 1 ) {
864 Handle(SALOME_InteractiveObject) anIO = selected.First();
865 if ( anIO->hasEntry() ) {
866 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
867 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
868 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
869 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
875 #ifndef DISABLE_PLOT2DVIEWER
876 void PlotDistribution() {
877 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
881 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
882 SALOME_ListIO selected;
884 aSel->selectedObjects( selected );
886 if ( selected.Extent() == 1 ) {
887 Handle(SALOME_InteractiveObject) anIO = selected.First();
888 if ( anIO->hasEntry() ) {
889 //Find Actor by entry before getting Plot2d viewer,
890 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
891 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
893 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
898 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
902 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
906 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
907 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
908 QString functorName = functorToString( anActor->GetFunctor());
909 QString aHistogramName("%1 : %2");
910 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
911 aHistogram->setName(aHistogramName);
912 aHistogram->setHorTitle(functorName);
913 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
914 aPlot->displayObject(aHistogram, true);
919 #endif //DISABLE_PLOT2DVIEWER
921 void DisableAutoColor(){
922 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
923 SALOME_ListIO selected;
925 aSel->selectedObjects( selected );
927 if(selected.Extent()){
928 Handle(SALOME_InteractiveObject) anIObject = selected.First();
929 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
930 if ( !aMesh->_is_nil() ) {
931 aMesh->SetAutoColor( false );
936 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
937 SALOME_ListIO selected;
938 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
942 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
943 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
944 if( !aSel || !appStudy )
947 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
948 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
949 aModule->EmitSignalDeactivateDialog();
950 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
951 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
956 _PTR(Study) aStudy = appStudy->studyDS();
958 aSel->selectedObjects( selected );
960 if(selected.Extent() >= 1){
961 switch(theCommandID){
963 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
964 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
968 QColor c, e, b, n, c0D, o;
971 vtkFloatingPointType Shrink = 0.0;
972 vtkFloatingPointType faces_orientation_scale = 0.0;
973 bool faces_orientation_3dvectors = false;
975 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
976 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
977 int aMarkerTextureCurrent = 0;
979 SALOME_ListIteratorOfListIO It( selected );
980 for( ; It.More(); It.Next()){
981 Handle(SALOME_InteractiveObject) IObject = It.Value();
982 if(IObject->hasEntry()){
983 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
984 vtkFloatingPointType color[3];
985 anActor->GetSufaceColor(color[0], color[1], color[2]);
986 int c0 = int (color[0] * 255);
987 int c1 = int (color[1] * 255);
988 int c2 = int (color[2] * 255);
989 c.setRgb(c0, c1, c2);
991 vtkFloatingPointType edgecolor[3];
992 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
993 c0 = int (edgecolor[0] * 255);
994 c1 = int (edgecolor[1] * 255);
995 c2 = int (edgecolor[2] * 255);
996 e.setRgb(c0, c1, c2);
998 vtkFloatingPointType backfacecolor[3];
999 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
1000 c0 = int (backfacecolor[0] * 255);
1001 c1 = int (backfacecolor[1] * 255);
1002 c2 = int (backfacecolor[2] * 255);
1003 b.setRgb(c0, c1, c2);
1005 vtkFloatingPointType nodecolor[3];
1006 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1007 c0 = int (nodecolor[0] * 255);
1008 c1 = int (nodecolor[1] * 255);
1009 c2 = int (nodecolor[2] * 255);
1010 n.setRgb(c0, c1, c2);
1012 vtkFloatingPointType color0D[3];
1013 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1014 c0 = int (color0D[0] * 255);
1015 c1 = int (color0D[1] * 255);
1016 c2 = int (color0D[2] * 255);
1017 c0D.setRgb(c0, c1, c2);
1019 size0D = (int)anActor->Get0DSize();
1022 Edgewidth = (int)anActor->GetLineWidth();
1025 Shrink = anActor->GetShrinkFactor();
1027 vtkFloatingPointType faces_orientation_color[3];
1028 anActor->GetFacesOrientationColor(faces_orientation_color);
1029 c0 = int (faces_orientation_color[0] * 255);
1030 c1 = int (faces_orientation_color[1] * 255);
1031 c2 = int (faces_orientation_color[2] * 255);
1032 o.setRgb(c0, c1, c2);
1034 faces_orientation_scale = anActor->GetFacesOrientationScale();
1035 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1037 aMarkerTypeCurrent = anActor->GetMarkerType();
1038 aMarkerScaleCurrent = anActor->GetMarkerScale();
1039 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1041 // even if there are multiple objects in the selection,
1042 // we need only the first one to get values for the dialog
1048 SMESHGUI_Preferences_ColorDlg *aDlg =
1049 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1050 aDlg->SetColor(1, c);
1051 aDlg->SetColor(2, e);
1052 aDlg->SetColor(3, n);
1053 aDlg->SetColor(4, b);
1054 aDlg->SetColor(5, c0D);
1055 aDlg->SetColor(6, o);
1056 aDlg->SetIntValue(1, Edgewidth);
1057 aDlg->SetIntValue(2, int(Shrink*100.));
1058 aDlg->SetIntValue(3, size0D);
1059 aDlg->SetDoubleValue(1, faces_orientation_scale);
1060 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1062 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1064 if( aMarkerTypeCurrent != VTK::MT_USER )
1065 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1067 aDlg->setCustomMarker( aMarkerTextureCurrent );
1070 QColor color = aDlg->GetColor(1);
1071 QColor edgecolor = aDlg->GetColor(2);
1072 QColor nodecolor = aDlg->GetColor(3);
1073 QColor backfacecolor = aDlg->GetColor(4);
1074 QColor color0D = aDlg->GetColor(5);
1075 QColor faces_orientation_color = aDlg->GetColor(6);
1078 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1080 SALOME_ListIteratorOfListIO It( selected );
1081 for( ; It.More(); It.Next()){
1082 Handle(SALOME_InteractiveObject) IObject = It.Value();
1083 if(IObject->hasEntry()){
1084 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1085 /* actor color and backface color */
1086 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1087 vtkFloatingPointType (color.green()) / 255.,
1088 vtkFloatingPointType (color.blue()) / 255.);
1089 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1090 vtkFloatingPointType (backfacecolor.green()) / 255.,
1091 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1094 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1095 vtkFloatingPointType (edgecolor.green()) / 255.,
1096 vtkFloatingPointType (edgecolor.blue()) / 255.);
1098 /* Shrink factor and size edges */
1099 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1100 anActor->SetLineWidth(aDlg->GetIntValue(1));
1102 /* Nodes color and size */
1103 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1104 vtkFloatingPointType (nodecolor.green()) / 255.,
1105 vtkFloatingPointType (nodecolor.blue()) / 255.);
1108 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1109 vtkFloatingPointType (color0D.green()) / 255.,
1110 vtkFloatingPointType (color0D.blue()) / 255.);
1111 anActor->Set0DSize(aDlg->GetIntValue(3));
1113 /* Faces orientation */
1114 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1115 vtkFloatingPointType(faces_orientation_color.greenF()),
1116 vtkFloatingPointType(faces_orientation_color.blueF())};
1117 anActor->SetFacesOrientationColor(c);
1118 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1119 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1121 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1122 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1123 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1124 if( aMarkerTypeNew != VTK::MT_USER )
1125 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1127 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1128 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1129 if( anIter != aMarkerMap.end() )
1130 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1133 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1134 if( !aGroupObject->_is_nil() )
1136 SMESH::ElementType anElementType = aGroupObject->GetType();
1138 switch( anElementType )
1140 case SMESH::NODE: aColor = nodecolor; break;
1141 case SMESH::EDGE: aColor = edgecolor; break;
1142 default: aColor = color; break;
1145 SALOMEDS::Color aGroupColor;
1146 aGroupColor.R = (float)aColor.red() / 255.0;
1147 aGroupColor.G = (float)aColor.green() / 255.0;
1148 aGroupColor.B = (float)aColor.blue() / 255.0;
1149 aGroupObject->SetColor( aGroupColor );
1154 SMESH::RepaintCurrentView();
1160 SALOME_ListIteratorOfListIO It( selected );
1161 for( ; It.More(); It.Next()){
1162 Handle(SALOME_InteractiveObject) IObject = It.Value();
1163 if(IObject->hasEntry()){
1164 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1165 switch(theCommandID){
1167 anActor->SetRepresentation(SMESH_Actor::eEdge);
1170 anActor->SetRepresentation(SMESH_Actor::eSurface);
1173 if(anActor->IsShrunk())
1174 anActor->UnShrink();
1176 anActor->SetShrink();
1179 anActor->SetRepresentation(SMESH_Actor::ePoint);
1182 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1183 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1186 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1187 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1193 SMESH::RepaintCurrentView();
1197 void Control( int theCommandID )
1199 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1200 SALOME_ListIO selected;
1202 aSel->selectedObjects( selected );
1204 if( !selected.IsEmpty() ){
1205 Handle(SALOME_InteractiveObject) anIO = selected.First();
1207 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1208 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1209 switch ( theCommandID ){
1211 aControl = SMESH_Actor::eLength;
1214 aControl = SMESH_Actor::eLength2D;
1217 aControl = SMESH_Actor::eFreeEdges;
1220 aControl = SMESH_Actor::eFreeBorders;
1223 aControl = SMESH_Actor::eMultiConnection;
1226 aControl = SMESH_Actor::eFreeNodes;
1229 aControl = SMESH_Actor::eMultiConnection2D;
1232 aControl = SMESH_Actor::eArea;
1235 aControl = SMESH_Actor::eTaper;
1238 aControl = SMESH_Actor::eAspectRatio;
1241 aControl = SMESH_Actor::eAspectRatio3D;
1244 aControl = SMESH_Actor::eMinimumAngle;
1247 aControl = SMESH_Actor::eWarping;
1250 aControl = SMESH_Actor::eSkew;
1253 aControl = SMESH_Actor::eVolume3D;
1256 aControl = SMESH_Actor::eFreeFaces;
1259 aControl = SMESH_Actor::eMaxElementLength2D;
1262 aControl = SMESH_Actor::eMaxElementLength3D;
1265 aControl = SMESH_Actor::eBareBorderVolume;
1268 aControl = SMESH_Actor::eBareBorderFace;
1271 aControl = SMESH_Actor::eOverConstrainedVolume;
1274 aControl = SMESH_Actor::eOverConstrainedFace;
1277 anActor->SetControlMode(aControl);
1278 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1279 SMESH::RepaintCurrentView();
1280 #ifndef DISABLE_PLOT2DVIEWER
1281 if(anActor->GetPlot2Histogram()) {
1282 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1283 QString functorName = functorToString( anActor->GetFunctor());
1284 QString aHistogramName("%1 : %2");
1285 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1286 aHistogram->setName(aHistogramName);
1287 aHistogram->setHorTitle(functorName);
1288 SMESH::ProcessIn2DViewers(anActor);
1297 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1298 MeshObjectType theType,
1299 const QString theInTypeName,
1300 QString & theOutTypeName)
1302 SMESH_TypeFilter aTypeFilter( theType );
1304 if( !theIO.IsNull() )
1306 entry = theIO->getEntry();
1307 LightApp_DataOwner owner( entry );
1308 if ( aTypeFilter.isOk( &owner )) {
1309 theOutTypeName = theInTypeName;
1317 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1319 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1320 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1322 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1323 CORBA::String_var anID = aSComp->GetID().c_str();
1324 if (!strcmp(anID.in(),theIO->getEntry()))
1330 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1331 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1332 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1333 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1334 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1342 QString CheckHomogeneousSelection()
1344 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1345 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1346 SALOME_ListIO selected;
1348 aSel->selectedObjects( selected );
1350 QString RefType = CheckTypeObject(selected.First());
1351 SALOME_ListIteratorOfListIO It(selected);
1352 for ( ; It.More(); It.Next())
1354 Handle(SALOME_InteractiveObject) IObject = It.Value();
1355 QString Type = CheckTypeObject(IObject);
1356 if (Type.compare(RefType) != 0)
1357 return "Heterogeneous Selection";
1364 void SMESHGUI::OnEditDelete()
1366 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1367 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1368 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1370 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1371 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1372 _PTR(GenericAttribute) anAttr;
1373 _PTR(AttributeIOR) anIOR;
1375 int objectCount = 0;
1377 QString aParentComponent = QString::null;
1378 Handle(SALOME_InteractiveObject) anIO;
1379 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1381 anIO = anIt.Value();
1382 QString cur = anIO->getComponentDataType();
1383 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1385 // check if object is reference
1386 _PTR(SObject) aRefSObj;
1387 aNameList.append("\n - ");
1388 if ( aSO->ReferencedObject( aRefSObj ) ) {
1389 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1390 aNameList.append( aRefName );
1391 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1394 aNameList.append(anIO->getName());
1398 if( aParentComponent.isNull() )
1399 aParentComponent = cur;
1400 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1401 aParentComponent = "";
1404 if ( objectCount == 0 )
1405 return; // No Valid Objects Selected
1407 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1408 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1409 QObject::tr("ERR_ERROR"),
1410 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1413 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1414 if (SUIT_MessageBox::warning
1415 (SMESHGUI::desktop(),
1416 QObject::tr("SMESH_WRN_WARNING"),
1417 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1418 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1419 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1422 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1424 SALOME_ListIteratorOfListIO It(selected);
1426 aStudyBuilder->NewCommand(); // There is a transaction
1427 for( ; It.More(); It.Next()){ // loop on selected IO's
1428 Handle(SALOME_InteractiveObject) IObject = It.Value();
1429 if(IObject->hasEntry()) {
1430 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1432 // disable removal of "SMESH" component object
1433 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1435 if ( engineIOR() == anIOR->Value().c_str() )
1438 //Check the referenced object
1439 _PTR(SObject) aRefSObject;
1440 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1441 aSO = aRefSObject; // Delete main Object instead of reference
1443 // put the whole hierarchy of sub-objects of the selected SO into a list and
1444 // then treat them all starting from the deepest objects (at list back)
1446 std::list< _PTR(SObject) > listSO;
1447 listSO.push_back( aSO );
1448 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1449 for ( ; itSO != listSO.end(); ++itSO ) {
1450 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1451 for (it->InitEx(false); it->More(); it->Next())
1452 listSO.push_back( it->Value() );
1455 // treat SO's in the list starting from the back
1457 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1458 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1459 _PTR(SObject) SO = *ritSO;
1460 if ( !SO ) continue;
1461 std::string anEntry = SO->GetID();
1463 /** Erase graphical object **/
1464 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1465 ViewManagerList aViewMenegers = anApp->viewManagers();
1466 ViewManagerList::const_iterator it = aViewMenegers.begin();
1467 for( ; it != aViewMenegers.end(); it++) {
1468 SUIT_ViewManager* vm = *it;
1469 int nbSf = vm ? vm->getViewsCount() : 0;
1471 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1472 for(int i = 0; i < nbSf; i++){
1473 SUIT_ViewWindow *sf = aViews[i];
1474 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1475 SMESH::RemoveActor(sf,anActor);
1481 /** Remove an object from data structures **/
1482 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1483 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1484 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1485 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1486 aMesh->RemoveGroup( aGroup );
1488 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1489 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1490 aMesh->RemoveSubMesh( aSubMesh );
1492 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1494 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1497 IObject = new SALOME_InteractiveObject
1498 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1499 QString objType = CheckTypeObject(IObject);
1500 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1501 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1502 aStudyBuilder->RemoveObjectWithChildren( SO );
1504 else {// default action: remove SObject from the study
1505 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1506 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1508 aStudyBuilder->RemoveObjectWithChildren( SO );
1512 } /* listSO back loop */
1513 } /* IObject->hasEntry() */
1516 aStudyBuilder->CommitCommand();
1518 /* Clear any previous selection */
1520 aSel->setSelectedObjects( l1 );
1522 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1527 SMESHGUI_EXPORT CAM_Module* createModule()
1529 return new SMESHGUI();
1533 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1535 //=============================================================================
1539 //=============================================================================
1540 SMESHGUI::SMESHGUI() :
1541 SalomeApp_Module( "SMESH" ),
1542 LightApp_Module( "SMESH" )
1544 if ( CORBA::is_nil( myComponentSMESH ) )
1546 CORBA::Boolean anIsEmbeddedMode;
1547 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1548 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1550 // 0019923: EDF 765 SMESH : default values of hypothesis
1551 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1552 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1553 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1554 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1555 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1558 myActiveDialogBox = 0;
1559 myFilterLibraryDlg = 0;
1563 myEventCallbackCommand = vtkCallbackCommand::New();
1564 myEventCallbackCommand->Delete();
1565 myEventCallbackCommand->SetClientData( this );
1566 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1569 SMESH::GetFilterManager();
1570 SMESH::GetPattern();
1571 SMESH::GetMeasurements();
1573 /* load resources for all available meshers */
1574 SMESH::InitAvailableHypotheses();
1577 //=============================================================================
1581 //=============================================================================
1582 SMESHGUI::~SMESHGUI()
1584 #ifdef WITHGENERICOBJ
1585 SMESH::GetFilterManager()->UnRegister();
1586 SMESH::GetMeasurements()->UnRegister();
1588 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1589 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1592 //=============================================================================
1596 //=============================================================================
1597 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1599 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1601 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1606 //=============================================================================
1610 //=============================================================================
1611 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1613 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1617 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1618 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1619 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1620 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1621 return autoUpdate && !exceeded;
1624 //=============================================================================
1628 //=============================================================================
1629 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1631 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1634 //=============================================================================
1638 //=============================================================================
1639 SMESHGUI* SMESHGUI::GetSMESHGUI()
1641 SMESHGUI* smeshMod = 0;
1642 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1645 CAM_Module* module = app->module( "Mesh" );
1646 smeshMod = dynamic_cast<SMESHGUI*>( module );
1649 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1651 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1654 _PTR(Study) aStudy = study->studyDS();
1656 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1665 Standard_EXPORT SMESHGUI* GetComponentGUI()
1667 return SMESHGUI::GetSMESHGUI();
1671 //=============================================================================
1675 //=============================================================================
1676 void SMESHGUI::SetState(int aState)
1681 //=============================================================================
1685 //=============================================================================
1686 void SMESHGUI::ResetState()
1691 //=============================================================================
1695 //=============================================================================
1696 void SMESHGUI::EmitSignalDeactivateDialog()
1698 emit SignalDeactivateActiveDialog();
1701 //=============================================================================
1705 //=============================================================================
1706 void SMESHGUI::EmitSignalStudyFrameChanged()
1708 emit SignalStudyFrameChanged();
1711 //=============================================================================
1715 //=============================================================================
1716 void SMESHGUI::EmitSignalCloseAllDialogs()
1718 emit SignalCloseAllDialogs();
1721 //=============================================================================
1725 //=============================================================================
1726 void SMESHGUI::EmitSignalVisibilityChanged()
1728 emit SignalVisibilityChanged();
1731 //=============================================================================
1735 //=============================================================================
1736 QDialog *SMESHGUI::GetActiveDialogBox()
1738 return myActiveDialogBox;
1741 //=============================================================================
1745 //=============================================================================
1746 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1748 myActiveDialogBox = (QDialog *) aDlg;
1752 //=============================================================================
1756 //=============================================================================
1757 SUIT_Desktop* SMESHGUI::desktop()
1759 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1761 return app->desktop();
1766 //=============================================================================
1770 //=============================================================================
1771 SalomeApp_Study* SMESHGUI::activeStudy()
1773 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1775 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1780 //=============================================================================
1784 //=============================================================================
1785 void SMESHGUI::Modified( bool theIsUpdateActions )
1787 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1788 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1789 appStudy->Modified();
1790 if( theIsUpdateActions )
1791 app->updateActions();
1796 //=============================================================================
1800 //=============================================================================
1801 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1803 /* Here the position is on the bottom right corner - 10 */
1804 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1806 SUIT_Desktop *PP = desktop();
1807 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1808 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1812 //=============================================================================
1816 //=============================================================================
1817 static int isStudyLocked(_PTR(Study) theStudy){
1818 return theStudy->GetProperties()->IsLocked();
1821 static bool checkLock(_PTR(Study) theStudy) {
1822 if (isStudyLocked(theStudy)) {
1823 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1824 QObject::tr("WRN_WARNING"),
1825 QObject::tr("WRN_STUDY_LOCKED") );
1831 //=======================================================================
1832 //function : CheckActiveStudyLocked
1834 //=======================================================================
1836 bool SMESHGUI::isActiveStudyLocked()
1838 _PTR(Study) aStudy = activeStudy()->studyDS();
1839 return checkLock( aStudy );
1842 //=============================================================================
1846 //=============================================================================
1847 bool SMESHGUI::OnGUIEvent( int theCommandID )
1849 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1853 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1854 SUIT_ResourceMgr* mgr = resourceMgr();
1858 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1859 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1862 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1863 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1865 //QAction* act = action( theCommandID );
1867 switch (theCommandID) {
1869 if(checkLock(aStudy)) break;
1878 if(checkLock(aStudy)) break;
1879 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1883 case 150: //MED FILE INFORMATION
1885 SALOME_ListIO selected;
1886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1888 aSel->selectedObjects( selected );
1889 if( selected.Extent() )
1891 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1892 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1893 if ( !aMesh->_is_nil() )
1895 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1902 case 122: // EXPORT MED
1910 ::ExportMeshToFile(theCommandID);
1914 case 200: // SCALAR BAR
1916 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1917 SALOME_ListIO selected;
1919 aSel->selectedObjects( selected );
1921 if( selected.Extent() ) {
1922 Handle(SALOME_InteractiveObject) anIO = selected.First();
1923 if( anIO->hasEntry() ) {
1924 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1925 anActor->SetControlMode( SMESH_Actor::eNone );
1926 #ifndef DISABLE_PLOT2DVIEWER
1927 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
1936 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1941 // dump control distribution data to the text file
1942 ::SaveDistribution();
1948 // show/ distribution
1949 ::ShowDistribution();
1953 #ifndef DISABLE_PLOT2DVIEWER
1956 // plot distribution
1957 ::PlotDistribution();
1968 ::DisableAutoColor();
1971 case 1134: // Clipping
1972 case 1133: // Tranparency
1973 case 1132: // Colors / Size
1980 ::SetDisplayMode(theCommandID, myMarkerMap);
1983 //2D quadratic representation
1986 ::SetDisplayMode(theCommandID, myMarkerMap);
1990 case 216: // 0D elements
1993 case 219: // Volumes
1994 case 220: // All Entity
1995 ::SetDisplayEntity(theCommandID);
1998 case 221: // Orientation of faces
2000 LightApp_SelectionMgr* mgr = selectionMgr();
2001 SALOME_ListIO selected; mgr->selectedObjects( selected );
2003 SALOME_ListIteratorOfListIO it(selected);
2004 for( ; it.More(); it.Next()) {
2005 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2006 if(anIObject->hasEntry()) {
2007 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2008 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2017 if(checkLock(aStudy)) break;
2019 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2022 SMESH::UpdateView();
2024 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2025 SMESH::OnVisuException();
2027 catch (...) { // PAL16774 (Crash after display of many groups)
2028 SMESH::OnVisuException();
2032 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2033 aSel->selectedObjects( l );
2034 aSel->setSelectedObjects( l );
2039 case 301: // DISPLAY
2040 case 302: // DISPLAY ONLY
2042 SMESH::EDisplaing anAction;
2043 switch (theCommandID) {
2044 case 300: anAction = SMESH::eErase; break;
2045 case 301: anAction = SMESH::eDisplay; break;
2046 case 302: anAction = SMESH::eDisplayOnly; break;
2049 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2050 SALOME_ListIO sel_objects, to_process;
2052 aSel->selectedObjects( sel_objects );
2054 if( theCommandID==302 )
2056 MESSAGE("anAction = SMESH::eDisplayOnly");
2057 startOperation( myEraseAll );
2060 extractContainers( sel_objects, to_process );
2063 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2067 SALOME_ListIteratorOfListIO It( to_process );
2068 for ( ; It.More(); It.Next()) {
2070 Handle(SALOME_InteractiveObject) IOS = It.Value();
2071 if (IOS->hasEntry()) {
2073 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2074 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2075 break; // PAL16774 (Crash after display of many groups)
2077 if (anAction == SMESH::eDisplayOnly)
2079 MESSAGE("anAction = SMESH::eDisplayOnly");
2080 anAction = SMESH::eDisplay;
2086 // PAL13338 + PAL15161 -->
2087 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2088 MESSAGE("anAction = SMESH::eDisplayOnly");
2089 SMESH::UpdateView();
2090 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2092 // PAL13338 + PAL15161 <--
2094 catch (...) { // PAL16774 (Crash after display of many groups)
2095 SMESH::OnVisuException();
2098 if (anAction == SMESH::eErase) {
2099 MESSAGE("anAction == SMESH::eErase");
2101 aSel->setSelectedObjects( l1 );
2104 aSel->setSelectedObjects( to_process );
2111 if(checkLock(aStudy)) break;
2114 EmitSignalDeactivateDialog();
2116 ( new SMESHGUI_NodesDlg( this ) )->show();
2119 SUIT_MessageBox::warning(desktop(),
2120 tr("SMESH_WRN_WARNING"),
2121 tr("SMESH_WRN_VIEWER_VTK"));
2126 case 2151: // FILTER
2130 EmitSignalDeactivateDialog();
2131 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2136 case 701: // COMPUTE MESH
2137 case 711: // PRECOMPUTE MESH
2138 case 712: // EVALUATE MESH
2139 case 713: // MESH ORDER
2141 if (checkLock(aStudy)) break;
2142 startOperation( theCommandID );
2146 case 702: // Create mesh
2147 case 703: // Create sub-mesh
2148 case 704: // Edit mesh/sub-mesh
2149 startOperation( theCommandID );
2151 case 705: // copy mesh
2153 if (checkLock(aStudy)) break;
2154 EmitSignalDeactivateDialog();
2155 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2158 case 710: // Build compound mesh
2160 if (checkLock(aStudy)) break;
2161 EmitSignalDeactivateDialog();
2162 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2166 case 407: // DIAGONAL INVERSION
2167 case 408: // Delete diagonal
2171 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2172 tr( "NOT_A_VTK_VIEWER" ) );
2176 if ( checkLock( aStudy ) )
2179 /*Standard_Boolean aRes;
2180 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2181 if ( aMesh->_is_nil() )
2183 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2184 tr( "SMESH_BAD_SELECTION" ) );
2188 EmitSignalDeactivateDialog();
2189 if ( theCommandID == 407 )
2190 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2192 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2195 case 409: // Change orientation
2196 case 410: // Union of triangles
2197 case 411: // Cutting of quadrangles
2198 case 419: // Splitting volumes into tetrahedra
2202 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2203 tr( "NOT_A_VTK_VIEWER" ) );
2207 if ( checkLock( aStudy ) )
2210 EmitSignalDeactivateDialog();
2211 SMESHGUI_MultiEditDlg* aDlg = NULL;
2212 if ( theCommandID == 409 )
2213 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2214 else if ( theCommandID == 410 )
2215 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2216 else if ( theCommandID == 419 )
2217 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2219 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2224 case 412: // Smoothing
2226 if(checkLock(aStudy)) break;
2228 EmitSignalDeactivateDialog();
2229 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2232 SUIT_MessageBox::warning(desktop(),
2233 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2237 case 413: // Extrusion
2239 if (checkLock(aStudy)) break;
2241 EmitSignalDeactivateDialog();
2242 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2244 SUIT_MessageBox::warning(desktop(),
2245 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2249 case 414: // Revolution
2251 if(checkLock(aStudy)) break;
2253 EmitSignalDeactivateDialog();
2254 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2257 SUIT_MessageBox::warning(desktop(),
2258 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2262 case 415: // Pattern mapping
2264 if ( checkLock( aStudy ) )
2268 EmitSignalDeactivateDialog();
2269 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2272 SUIT_MessageBox::warning(desktop(),
2273 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2277 case 416: // Extrusion along a path
2279 if (checkLock(aStudy)) break;
2281 EmitSignalDeactivateDialog();
2282 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2284 SUIT_MessageBox::warning(desktop(),
2285 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2289 case 417: // Convert mesh to quadratic
2291 startOperation( 417 );
2292 /* if (checkLock(aStudy)) break;
2294 EmitSignalDeactivateDialog();
2295 new SMESHGUI_ConvToQuadDlg();
2297 SUIT_MessageBox::warning(desktop(),
2298 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2302 case 418: // create 2D mesh from 3D
2304 startOperation( 418 );
2307 case 806: // CREATE GEO GROUP
2309 startOperation( 806 );
2312 case 801: // CREATE GROUP
2316 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2317 tr( "NOT_A_VTK_VIEWER" ) );
2321 if(checkLock(aStudy)) break;
2322 EmitSignalDeactivateDialog();
2323 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2325 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2326 SALOME_ListIO selected;
2328 aSel->selectedObjects( selected );
2330 int nbSel = selected.Extent();
2332 // check if mesh is selected
2333 aMesh = SMESH::GetMeshByIO( selected.First() );
2335 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2340 case 802: // CONSTRUCT GROUP
2344 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2345 tr( "NOT_A_VTK_VIEWER" ) );
2349 if(checkLock(aStudy)) break;
2350 EmitSignalDeactivateDialog();
2352 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2353 SALOME_ListIO selected;
2355 aSel->selectedObjects( selected );
2357 int nbSel = selected.Extent();
2359 // check if submesh is selected
2360 Handle(SALOME_InteractiveObject) IObject = selected.First();
2361 if (IObject->hasEntry()) {
2362 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2364 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2365 if (!aSubMesh->_is_nil()) {
2367 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2368 // get submesh elements list by types
2369 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2370 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2371 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2372 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2373 // create group for each type o elements
2374 QString aName = IObject->getName();
2375 if (aNodes->length() > 0) {
2376 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2377 aGroup->Add(aNodes.inout());
2379 if (aEdges->length() > 0) {
2380 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2381 aGroup->Add(aEdges.inout());
2383 if (aFaces->length() > 0) {
2384 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2385 aGroup->Add(aFaces.inout());
2387 if (aVolumes->length() > 0) {
2388 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2389 aGroup->Add(aVolumes.inout());
2394 catch(const SALOME::SALOME_Exception & S_ex){
2395 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2402 SUIT_MessageBox::warning(desktop(),
2403 tr("SMESH_WRN_WARNING"),
2404 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2409 case 803: // EDIT GROUP
2413 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2414 tr( "NOT_A_VTK_VIEWER" ) );
2418 if(checkLock(aStudy)) break;
2419 EmitSignalDeactivateDialog();
2421 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2422 SALOME_ListIO selected;
2424 aSel->selectedObjects( selected );
2426 SALOME_ListIteratorOfListIO It (selected);
2427 int nbSelectedGroups = 0;
2428 for ( ; It.More(); It.Next() )
2430 SMESH::SMESH_GroupBase_var aGroup =
2431 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2432 if (!aGroup->_is_nil()) {
2434 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2438 if (nbSelectedGroups == 0)
2440 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2446 case 804: // Add elements to group
2448 if(checkLock(aStudy)) break;
2449 if (myState == 800) {
2450 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2451 if (aDlg) aDlg->onAdd();
2456 case 805: // Remove elements from group
2458 if(checkLock(aStudy)) break;
2459 if (myState == 800) {
2460 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2461 if (aDlg) aDlg->onRemove();
2466 case 815: // Edit GEOM GROUP as standalone
2470 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2471 tr( "NOT_A_VTK_VIEWER" ) );
2475 if(checkLock(aStudy)) break;
2476 EmitSignalDeactivateDialog();
2478 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2479 SALOME_ListIO selected;
2481 aSel->selectedObjects( selected );
2483 SALOME_ListIteratorOfListIO It (selected);
2484 for ( ; It.More(); It.Next() )
2486 SMESH::SMESH_GroupOnGeom_var aGroup =
2487 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2488 if (!aGroup->_is_nil()) {
2489 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2496 case 810: // Union Groups
2497 case 811: // Intersect groups
2498 case 812: // Cut groups
2502 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2503 tr( "NOT_A_VTK_VIEWER" ) );
2507 if ( checkLock( aStudy ) )
2510 EmitSignalDeactivateDialog();
2512 SMESHGUI_GroupOpDlg* aDlg = 0;
2513 if ( theCommandID == 810 )
2514 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2515 else if ( theCommandID == 811 )
2516 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2518 aDlg = new SMESHGUI_CutGroupsDlg( this );
2525 case 814: // Create groups of entities from existing groups of superior dimensions
2527 if ( checkLock( aStudy ) )
2530 EmitSignalDeactivateDialog();
2531 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2537 case 813: // Delete groups with their contents
2541 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2542 tr( "NOT_A_VTK_VIEWER" ) );
2546 if ( checkLock( aStudy ) )
2549 EmitSignalDeactivateDialog();
2551 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2555 case 900: // MESH INFOS
2556 case 903: // WHAT IS
2558 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2559 EmitSignalDeactivateDialog();
2560 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2561 SALOME_ListIO selected;
2563 aSel->selectedObjects( selected );
2565 if ( selected.Extent() > 1 ) { // a dlg for each IO
2566 SALOME_ListIteratorOfListIO It( selected );
2567 for ( ; It.More(); It.Next() ) {
2568 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2569 dlg->showInfo( It.Value() );
2574 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2580 case 902: // STANDARD MESH INFOS
2582 EmitSignalDeactivateDialog();
2583 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2584 SALOME_ListIO selected;
2586 aSel->selectedObjects( selected );
2588 if ( selected.Extent() > 1 ) { // a dlg for each IO
2590 SALOME_ListIteratorOfListIO It (selected);
2591 for ( ; It.More(); It.Next() ) {
2593 IOs.Append( It.Value() );
2594 aSel->setSelectedObjects( IOs );
2595 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2597 // restore selection
2598 aSel->setSelectedObjects( selected );
2601 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2604 case 903: // WHAT IS
2606 EmitSignalDeactivateDialog();
2607 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2612 case 904: // FIND ELEM
2614 startOperation( theCommandID );
2618 case 1100: // EDIT HYPOTHESIS
2620 if(checkLock(aStudy)) break;
2622 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2623 SALOME_ListIO selected;
2625 aSel->selectedObjects( selected );
2627 int nbSel = selected.Extent();
2630 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2631 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2633 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2634 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2635 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2636 if ( !aHypothesis->_is_nil() )
2639 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2640 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2642 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2653 case 1101: // RENAME
2655 if ( checkLock( aStudy ) )
2658 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2659 SALOME_ListIO selected;
2661 aSel->selectedObjects( selected );
2663 bool isAny = false; // is there any appropriate object selected
2665 SALOME_ListIteratorOfListIO It( selected );
2666 for ( ; It.More(); It.Next() )
2668 Handle(SALOME_InteractiveObject) IObject = It.Value();
2669 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2670 _PTR(GenericAttribute) anAttr;
2671 _PTR(AttributeName) aName;
2674 if ( obj->FindAttribute(anAttr, "AttributeName") )
2677 QString newName = QString(aName->Value().c_str());
2679 // check type to prevent renaming of inappropriate objects
2680 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2681 if (aType == MESH || aType == GROUP ||
2682 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2683 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2684 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2685 aType == HYPOTHESIS || aType == ALGORITHM)
2688 newName = LightApp_NameDlg::getName(desktop(), newName);
2689 if ( !newName.isEmpty() )
2691 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2693 // update name of group object and its actor
2694 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2695 if( !aGroupObject->_is_nil() )
2697 aGroupObject->SetName( newName.toLatin1().data() );
2698 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2699 anActor->setName( newName.toLatin1().data() );
2710 SUIT_MessageBox::warning(desktop(),
2711 QObject::tr("SMESH_WRN_WARNING"),
2712 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2717 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2719 if(checkLock(aStudy)) break;
2720 SUIT_OverrideCursor wc;
2722 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2723 SALOME_ListIO selected;
2725 aSel->selectedObjects( selected, QString::null, false );
2727 SALOME_ListIteratorOfListIO It(selected);
2728 for (int i = 0; It.More(); It.Next(), i++) {
2729 Handle(SALOME_InteractiveObject) IObject = It.Value();
2730 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2733 aSel->setSelectedObjects( l1 );
2738 case 4009: // ELEM0D
2739 case 4010: // GEOM::EDGE
2740 case 4021: // TRIANGLE
2742 case 4023: // POLYGON
2746 if(checkLock(aStudy)) break;
2748 EmitSignalDeactivateDialog();
2749 SMDSAbs_ElementType type = SMDSAbs_Edge;
2751 switch (theCommandID) {
2752 case 4009: // ELEM0D
2753 type = SMDSAbs_0DElement; nbNodes = 1; break;
2754 case 4021: // TRIANGLE
2755 type = SMDSAbs_Face; nbNodes = 3; break;
2757 type = SMDSAbs_Face; nbNodes = 4; break;
2759 type = SMDSAbs_Volume; nbNodes = 4; break;
2760 case 4023: // POLYGON
2761 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2763 type = SMDSAbs_Volume; nbNodes = 8; break;
2764 case 4033: // POLYHEDRE
2765 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2768 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2771 SUIT_MessageBox::warning(desktop(),
2772 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2776 case 4033: // POLYHEDRON
2778 if(checkLock(aStudy)) break;
2780 EmitSignalDeactivateDialog();
2781 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2784 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2785 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2789 case 4034: // QUADRATIC EDGE
2790 case 4035: // QUADRATIC TRIANGLE
2791 case 4036: // QUADRATIC QUADRANGLE
2792 case 4037: // QUADRATIC TETRAHEDRON
2793 case 4038: // QUADRATIC PYRAMID
2794 case 4039: // QUADRATIC PENTAHEDRON
2795 case 4040: // QUADRATIC HEXAHEDRON
2797 if(checkLock(aStudy)) break;
2799 EmitSignalDeactivateDialog();
2802 switch (theCommandID) {
2804 type = QUAD_EDGE; break;
2806 type = QUAD_TRIANGLE; break;
2808 type = QUAD_QUADRANGLE; break;
2810 type = QUAD_TETRAHEDRON; break;
2812 type = QUAD_PYRAMID; break;
2814 type = QUAD_PENTAHEDRON; break;
2816 type = QUAD_HEXAHEDRON;
2820 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2823 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2824 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2828 case 4041: // REMOVES NODES
2830 if(checkLock(aStudy)) break;
2832 EmitSignalDeactivateDialog();
2833 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2836 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2837 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2841 case 4042: // REMOVES ELEMENTS
2843 if(checkLock(aStudy)) break;
2845 EmitSignalDeactivateDialog();
2846 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2850 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2851 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2855 case 4043: { // CLEAR_MESH
2857 if(checkLock(aStudy)) break;
2859 SALOME_ListIO selected;
2860 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2861 aSel->selectedObjects( selected );
2863 SUIT_OverrideCursor wc;
2864 SALOME_ListIteratorOfListIO It (selected);
2865 for ( ; It.More(); It.Next() )
2867 Handle(SALOME_InteractiveObject) IOS = It.Value();
2868 SMESH::SMESH_Mesh_var aMesh =
2869 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2870 if ( aMesh->_is_nil()) continue;
2872 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2874 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2875 SMESH::ModifiedMesh( aMeshSObj, false, true);
2876 // hide groups and submeshes
2877 _PTR(ChildIterator) anIter =
2878 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2879 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2881 _PTR(SObject) so = anIter->Value();
2882 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2885 catch (const SALOME::SALOME_Exception& S_ex){
2887 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2891 SMESH::UpdateView();
2895 case 4044: // REMOVE ORPHAN NODES
2897 if(checkLock(aStudy)) break;
2898 SALOME_ListIO selected;
2899 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2900 aSel->selectedObjects( selected );
2901 if ( selected.Extent() == 1 ) {
2902 Handle(SALOME_InteractiveObject) anIO = selected.First();
2903 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2904 if ( !aMesh->_is_nil() ) {
2905 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2906 tr( "SMESH_WARNING" ),
2907 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2908 SUIT_MessageBox::Yes |
2909 SUIT_MessageBox::No,
2910 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2913 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2914 int removed = aMeshEditor->RemoveOrphanNodes();
2915 SUIT_MessageBox::information(SMESHGUI::desktop(),
2916 tr("SMESH_INFORMATION"),
2917 tr("NB_NODES_REMOVED").arg(removed));
2918 if ( removed > 0 ) {
2919 SMESH::UpdateView();
2920 SMESHGUI::Modified();
2923 catch (const SALOME::SALOME_Exception& S_ex) {
2924 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2933 case 4051: // RENUMBERING NODES
2935 if(checkLock(aStudy)) break;
2937 EmitSignalDeactivateDialog();
2938 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2942 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2943 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2947 case 4052: // RENUMBERING ELEMENTS
2949 if(checkLock(aStudy)) break;
2951 EmitSignalDeactivateDialog();
2952 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2956 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2957 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2961 case 4061: // TRANSLATION
2963 if(checkLock(aStudy)) break;
2965 EmitSignalDeactivateDialog();
2966 ( new SMESHGUI_TranslationDlg( this ) )->show();
2969 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2970 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2974 case 4062: // ROTATION
2976 if(checkLock(aStudy)) break;
2978 EmitSignalDeactivateDialog();
2979 ( new SMESHGUI_RotationDlg( this ) )->show();
2982 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2983 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2987 case 4063: // SYMMETRY
2989 if(checkLock(aStudy)) break;
2991 EmitSignalDeactivateDialog();
2992 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2995 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2996 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3000 case 4064: // SEWING
3002 if(checkLock(aStudy)) break;
3004 EmitSignalDeactivateDialog();
3005 ( new SMESHGUI_SewingDlg( this ) )->show();
3008 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3009 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3013 case 4065: // MERGE NODES
3015 if(checkLock(aStudy)) break;
3017 EmitSignalDeactivateDialog();
3018 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3021 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3022 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3026 case 4066: // MERGE EQUAL ELEMENTS
3028 if (checkLock(aStudy)) break;
3030 EmitSignalDeactivateDialog();
3031 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3033 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3034 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3039 case 4067: // MAKE MESH PASS THROUGH POINT
3040 startOperation( 4067 );
3045 if(checkLock(aStudy)) break;
3047 EmitSignalDeactivateDialog();
3048 ( new SMESHGUI_ScaleDlg( this ) )->show();
3051 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3052 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3057 case 4069: // DUPLICATE NODES
3059 if(checkLock(aStudy)) break;
3061 EmitSignalDeactivateDialog();
3062 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3065 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3066 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3071 case 5105: // Library of selection filters
3073 static QList<int> aTypes;
3074 if ( aTypes.isEmpty() )
3076 aTypes.append( SMESH::NODE );
3077 aTypes.append( SMESH::EDGE );
3078 aTypes.append( SMESH::FACE );
3079 aTypes.append( SMESH::VOLUME );
3081 if (!myFilterLibraryDlg)
3082 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3083 else if (myFilterLibraryDlg->isHidden())
3084 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3085 myFilterLibraryDlg->raise();
3089 case 6017: // CONTROLS
3113 LightApp_SelectionMgr* mgr = selectionMgr();
3114 SALOME_ListIO selected; mgr->selectedObjects( selected );
3116 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3117 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3119 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3120 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3121 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3122 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3123 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3124 ::Control( theCommandID );
3129 SUIT_MessageBox::warning(desktop(),
3130 tr( "SMESH_WRN_WARNING" ),
3131 tr( "SMESH_BAD_SELECTION" ) );
3135 SUIT_MessageBox::warning(desktop(),
3136 tr( "SMESH_WRN_WARNING" ),
3137 tr( "NOT_A_VTK_VIEWER" ) );
3142 LightApp_SelectionMgr* mgr = selectionMgr();
3143 SALOME_ListIO selected; mgr->selectedObjects( selected );
3145 SALOME_ListIteratorOfListIO it(selected);
3146 for( ; it.More(); it.Next()) {
3147 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3148 if(anIObject->hasEntry()) {
3149 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3150 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3158 LightApp_SelectionMgr* mgr = selectionMgr();
3159 SALOME_ListIO selected; mgr->selectedObjects( selected );
3161 SALOME_ListIteratorOfListIO it(selected);
3162 for( ; it.More(); it.Next()) {
3163 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3164 if(anIObject->hasEntry())
3165 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3166 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3174 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3175 EmitSignalDeactivateDialog();
3176 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3182 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3183 //updateObjBrowser();
3187 //=============================================================================
3191 //=============================================================================
3192 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3197 //=============================================================================
3201 //=============================================================================
3202 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3207 //=============================================================================
3211 //=============================================================================
3212 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3217 //=============================================================================
3218 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3219 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3221 //=============================================================================
3222 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3223 SUIT_ViewWindow* wnd )
3225 if(theIO->hasEntry()){
3226 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3227 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3231 //=======================================================================
3232 // function : createSMESHAction
3234 //=======================================================================
3235 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3236 const int key, const bool toggle, const QString& shortcutAction )
3239 QWidget* parent = application()->desktop();
3240 SUIT_ResourceMgr* resMgr = resourceMgr();
3242 if ( !icon_id.isEmpty() )
3243 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3245 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3246 if ( !pix.isNull() )
3247 icon = QIcon( pix );
3249 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3250 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3251 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3253 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3254 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3257 //=======================================================================
3258 // function : createPopupItem
3260 //=======================================================================
3261 void SMESHGUI::createPopupItem( const int id,
3262 const QString& clients,
3263 const QString& types,
3264 const QString& theRule,
3269 parentId = popupMgr()->actionId( action( pId ) );
3271 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3272 popupMgr()->insert( action( id ), parentId, 0 );
3274 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3275 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3276 QString rule = "(%1) and (%2) and (%3)";
3277 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3278 if( clients.isEmpty() )
3279 rule = rule.arg( QString( "true" ) );
3281 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3282 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3285 bool cont = myRules.contains( id );
3287 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3289 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3290 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3293 //=======================================================================
3294 // function : initialize
3296 //=======================================================================
3297 void SMESHGUI::initialize( CAM_Application* app )
3299 SalomeApp_Module::initialize( app );
3301 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3303 /* Automatic Update flag */
3304 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3306 // ----- create actions --------------
3308 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3309 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3310 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3311 createSMESHAction( 114, "NUM" );
3312 createSMESHAction( 121, "DAT" );
3313 createSMESHAction( 122, "MED" );
3314 createSMESHAction( 123, "UNV" );
3315 createSMESHAction( 140, "STL" );
3316 createSMESHAction( 124, "EXPORT_DAT" );
3317 createSMESHAction( 125, "EXPORT_MED" );
3318 createSMESHAction( 126, "EXPORT_UNV" );
3319 createSMESHAction( 141, "EXPORT_STL" );
3320 createSMESHAction( 150, "FILE_INFO" );
3321 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3322 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3323 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3324 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3325 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3326 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3327 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3328 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3329 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3330 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3331 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3332 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3333 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3334 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3335 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3336 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3337 createSMESHAction( 804, "ADD" );
3338 createSMESHAction( 805, "REMOVE" );
3339 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3340 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3341 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3342 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3343 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3344 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3345 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3346 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3347 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3348 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3349 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3350 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3351 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3352 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3353 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3354 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3355 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3356 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3357 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3358 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3359 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3360 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3361 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3362 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3363 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3364 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3365 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3366 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3367 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3368 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3369 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3370 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3371 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3372 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3373 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3374 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3375 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3376 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3377 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3378 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3379 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3380 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3381 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3382 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3383 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3384 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3385 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3386 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3387 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3388 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3389 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3390 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3391 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3392 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3393 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3394 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3395 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3396 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3397 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3398 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3399 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3400 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3401 createSMESHAction( 415, "MAP", "ICON_MAP" );
3402 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3403 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3404 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3405 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3406 createSMESHAction( 200, "RESET" );
3407 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3408 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3409 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3410 #ifndef DISABLE_PLOT2DVIEWER
3411 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3413 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3414 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3415 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3416 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3417 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3418 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3419 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3420 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3421 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3422 createSMESHAction( 220, "ALL" );
3423 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3425 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3426 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3428 createSMESHAction( 1100, "EDIT_HYPO" );
3429 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3430 createSMESHAction( 1102, "UNASSIGN" );
3431 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3432 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3433 createSMESHAction( 1131, "DISPMODE" );
3434 createSMESHAction( 1132, "COLORS" );
3435 createSMESHAction( 1133, "TRANSP" );
3436 createSMESHAction( 1134, "CLIP" );
3437 createSMESHAction( 1135, "DISP_ENT" );
3438 createSMESHAction( 1136, "AUTO_COLOR" );
3439 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3440 createSMESHAction( 2000, "CTRL" );
3442 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3443 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3445 createSMESHAction( 300, "ERASE" );
3446 createSMESHAction( 301, "DISPLAY" );
3447 createSMESHAction( 302, "DISPLAY_ONLY" );
3448 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3449 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3450 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3451 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3452 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3453 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3454 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3455 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3457 // ----- create menu --------------
3458 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3459 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3460 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3461 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3462 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3463 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3464 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3465 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3467 createMenu( separator(), fileId );
3469 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3470 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3471 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3472 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3473 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3474 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3475 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3476 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3477 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3478 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3480 createMenu( 111, importId, -1 );
3481 createMenu( 112, importId, -1 );
3482 createMenu( 113, importId, -1 );
3483 createMenu( 140, importId, -1 );
3485 createMenu( 121, exportId, -1 );
3486 createMenu( 122, exportId, -1 );
3487 createMenu( 123, exportId, -1 );
3488 createMenu( 141, exportId, -1 ); // export to stl STL
3490 createMenu( separator(), fileId, 10 );
3492 createMenu( 33, editId, -1 );
3494 createMenu( 5105, toolsId, -1 );
3496 createMenu( 702, meshId, -1 ); // "Mesh" menu
3497 createMenu( 703, meshId, -1 );
3498 createMenu( 704, meshId, -1 );
3499 createMenu( 710, meshId, -1 );
3500 createMenu( 705, meshId, -1 );
3501 createMenu( separator(), meshId, -1 );
3502 createMenu( 701, meshId, -1 );
3503 createMenu( 711, meshId, -1 );
3504 createMenu( 712, meshId, -1 );
3505 createMenu( 713, meshId, -1 );
3506 createMenu( separator(), meshId, -1 );
3507 createMenu( 801, meshId, -1 );
3508 createMenu( 806, meshId, -1 );
3509 createMenu( 802, meshId, -1 );
3510 createMenu( 803, meshId, -1 );
3511 createMenu( 815, meshId, -1 );
3512 createMenu( separator(), meshId, -1 );
3513 createMenu( 810, meshId, -1 );
3514 createMenu( 811, meshId, -1 );
3515 createMenu( 812, meshId, -1 );
3516 createMenu( separator(), meshId, -1 );
3517 createMenu( 814, meshId, -1 );
3518 createMenu( separator(), meshId, -1 );
3519 createMenu( 900, meshId, -1 );
3520 //createMenu( 902, meshId, -1 );
3521 createMenu( 903, meshId, -1 );
3522 createMenu( 904, meshId, -1 );
3523 createMenu( separator(), meshId, -1 );
3525 createMenu( 6005, nodeId, -1 );
3526 createMenu( 6002, edgeId, -1 );
3527 createMenu( 6003, edgeId, -1 );
3528 createMenu( 6001, edgeId, -1 );
3529 createMenu( 6004, edgeId, -1 );
3530 createMenu( 6021, faceId, -1 );
3531 createMenu( 6025, faceId, -1 );
3532 createMenu( 6027, faceId, -1 );
3533 createMenu( 6018, faceId, -1 );
3534 createMenu( 6019, faceId, -1 );
3535 createMenu( 6011, faceId, -1 );
3536 createMenu( 6012, faceId, -1 );
3537 createMenu( 6013, faceId, -1 );
3538 createMenu( 6014, faceId, -1 );
3539 createMenu( 6015, faceId, -1 );
3540 createMenu( 6016, faceId, -1 );
3541 createMenu( 6022, faceId, -1 );
3542 createMenu( 6017, volumeId, -1 );
3543 createMenu( 6009, volumeId, -1 );
3544 createMenu( 6023, volumeId, -1 );
3545 createMenu( 6024, volumeId, -1 );
3546 createMenu( 6026, volumeId, -1 );
3548 createMenu( 4000, addId, -1 );
3549 createMenu( 4009, addId, -1 );
3550 createMenu( 4010, addId, -1 );
3551 createMenu( 4021, addId, -1 );
3552 createMenu( 4022, addId, -1 );
3553 createMenu( 4023, addId, -1 );
3554 createMenu( 4031, addId, -1 );
3555 createMenu( 4032, addId, -1 );
3556 createMenu( 4033, addId, -1 );
3557 createMenu( separator(), addId, -1 );
3558 createMenu( 4034, addId, -1 );
3559 createMenu( 4035, addId, -1 );
3560 createMenu( 4036, addId, -1 );
3561 createMenu( 4037, addId, -1 );
3562 createMenu( 4038, addId, -1 );
3563 createMenu( 4039, addId, -1 );
3564 createMenu( 4040, addId, -1 );
3566 createMenu( 4041, removeId, -1 );
3567 createMenu( 4042, removeId, -1 );
3568 createMenu( 4044, removeId, -1 );
3569 createMenu( separator(), removeId, -1 );
3570 createMenu( 813, removeId, -1 );
3571 createMenu( separator(), removeId, -1 );
3572 createMenu( 4043, removeId, -1 );
3574 createMenu( 4051, renumId, -1 );
3575 createMenu( 4052, renumId, -1 );
3577 createMenu( 4061, transfId, -1 );
3578 createMenu( 4062, transfId, -1 );
3579 createMenu( 4063, transfId, -1 );
3580 createMenu( 4064, transfId, -1 );
3581 createMenu( 4065, transfId, -1 );
3582 createMenu( 4066, transfId, -1 );
3583 createMenu( 4068, transfId, -1 );
3584 createMenu( 4069, transfId, -1 );
3586 createMenu( 4067,modifyId, -1 );
3587 createMenu( 407, modifyId, -1 );
3588 createMenu( 408, modifyId, -1 );
3589 createMenu( 409, modifyId, -1 );
3590 createMenu( 410, modifyId, -1 );
3591 createMenu( 411, modifyId, -1 );
3592 createMenu( 419, modifyId, -1 );
3593 createMenu( 412, modifyId, -1 );
3594 createMenu( 413, modifyId, -1 );
3595 createMenu( 416, modifyId, -1 );
3596 createMenu( 414, modifyId, -1 );
3597 createMenu( 415, modifyId, -1 );
3598 createMenu( 417, modifyId, -1 );
3599 createMenu( 418, modifyId, -1 );
3601 createMenu( 501, measureId, -1 );
3602 createMenu( 502, measureId, -1 );
3603 createMenu( 214, viewId, -1 );
3605 // ----- create toolbars --------------
3606 int meshTb = createTool( tr( "TB_MESH" ) ),
3607 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3608 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3609 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3610 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3612 createTool( 702, meshTb );
3613 createTool( 703, meshTb );
3614 createTool( 704, meshTb );
3615 createTool( 710, meshTb );
3616 createTool( 705, meshTb );
3617 createTool( separator(), meshTb );
3618 createTool( 701, meshTb );
3619 createTool( 711, meshTb );
3620 createTool( 712, meshTb );
3621 createTool( 713, meshTb );
3622 createTool( separator(), meshTb );
3623 createTool( 801, meshTb );
3624 createTool( 806, meshTb );
3625 createTool( 802, meshTb );
3626 createTool( 803, meshTb );
3627 //createTool( 815, meshTb );
3628 createTool( separator(), meshTb );
3629 createTool( 900, meshTb );
3630 //createTool( 902, meshTb );
3631 createTool( 903, meshTb );
3632 createTool( 904, meshTb );
3633 createTool( separator(), meshTb );
3635 createTool( 6005, ctrlTb );
3636 createTool( separator(), ctrlTb );
3637 createTool( 6002, ctrlTb );
3638 createTool( 6003, ctrlTb );
3639 createTool( 6001, ctrlTb );
3640 createTool( 6004, ctrlTb );
3641 createTool( separator(), ctrlTb );
3642 createTool( 6021, ctrlTb );
3643 createTool( 6025, ctrlTb );
3644 createTool( 6027, ctrlTb );
3645 createTool( 6018, ctrlTb );
3646 createTool( 6019, ctrlTb );
3647 createTool( 6011, ctrlTb );
3648 createTool( 6012, ctrlTb );
3649 createTool( 6013, ctrlTb );
3650 createTool( 6014, ctrlTb );
3651 createTool( 6015, ctrlTb );
3652 createTool( 6016, ctrlTb );
3653 createTool( 6022, ctrlTb );
3654 createTool( separator(), ctrlTb );
3655 createTool( 6017, ctrlTb );
3656 createTool( 6009, ctrlTb );
3657 createTool( 6023, ctrlTb );
3658 createTool( 6024, ctrlTb );
3659 createTool( 6026, ctrlTb );
3660 createTool( separator(), ctrlTb );
3662 createTool( 4000, addRemTb );
3663 createTool( 4009, addRemTb );
3664 createTool( 4010, addRemTb );
3665 createTool( 4021, addRemTb );
3666 createTool( 4022, addRemTb );
3667 createTool( 4023, addRemTb );
3668 createTool( 4031, addRemTb );
3669 createTool( 4032, addRemTb );
3670 createTool( 4033, addRemTb );
3671 createTool( separator(), addRemTb );
3672 createTool( 4034, addRemTb );
3673 createTool( 4035, addRemTb );
3674 createTool( 4036, addRemTb );
3675 createTool( 4037, addRemTb );
3676 createTool( 4038, addRemTb );
3677 createTool( 4039, addRemTb );
3678 createTool( 4040, addRemTb );
3679 createTool( separator(), addRemTb );
3680 createTool( 4041, addRemTb );
3681 createTool( 4042, addRemTb );
3682 createTool( 4044, addRemTb );
3683 createTool( 4043, addRemTb );
3684 createTool( separator(), addRemTb );
3685 createTool( 4051, addRemTb );
3686 createTool( 4052, addRemTb );
3687 createTool( separator(), addRemTb );
3688 createTool( 4061, addRemTb );
3689 createTool( 4062, addRemTb );
3690 createTool( 4063, addRemTb );
3691 createTool( 4064, addRemTb );
3692 createTool( 4065, addRemTb );
3693 createTool( 4066, addRemTb );
3694 createTool( 4068, addRemTb );
3695 createTool( 4069, addRemTb );
3696 createTool( separator(), addRemTb );
3698 createTool( 4067,modifyTb );
3699 createTool( 407, modifyTb );
3700 createTool( 408, modifyTb );
3701 createTool( 409, modifyTb );
3702 createTool( 410, modifyTb );
3703 createTool( 411, modifyTb );
3704 createTool( 419, modifyTb );
3705 createTool( 412, modifyTb );
3706 createTool( 413, modifyTb );
3707 createTool( 416, modifyTb );
3708 createTool( 414, modifyTb );
3709 createTool( 415, modifyTb );
3710 createTool( 417, modifyTb );
3711 createTool( 418, modifyTb );
3713 createTool( 214, dispModeTb );
3715 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3716 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3719 QString OB = "'ObjectBrowser'",
3720 View = "'" + SVTK_Viewer::Type() + "'",
3722 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3723 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3724 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3725 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3726 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3727 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3728 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3729 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3730 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3731 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3732 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3734 mesh_group = mesh + " " + subMesh + " " + group,
3735 hyp_alg = hypo + " " + algo;
3737 // popup for object browser
3739 isInvisible("not( isVisible )"),
3740 isEmpty("numberOfNodes = 0"),
3741 isNotEmpty("numberOfNodes <> 0"),
3743 // has nodes, edges, etc in VISIBLE! actor
3744 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3745 hasElems("(count( elemTypes ) > 0)"),
3746 hasDifferentElems("(count( elemTypes ) > 1)"),
3747 hasElems0d("({'Elem0d'} in elemTypes)"),
3748 hasEdges("({'Edge'} in elemTypes)"),
3749 hasFaces("({'Face'} in elemTypes)"),
3750 hasVolumes("({'Volume'} in elemTypes)");
3752 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3753 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3754 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3755 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3756 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3757 createPopupItem( 803, OB, group ); // EDIT_GROUP
3758 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3760 popupMgr()->insert( separator(), -1, 0 );
3761 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3762 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3763 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3764 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3765 createPopupItem( 214, OB, mesh_group ); // UPDATE
3766 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3767 //createPopupItem( 902, OB, mesh ); // STD_INFO
3768 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3769 createPopupItem( 904, OB, mesh ); // FIND_ELEM
3770 popupMgr()->insert( separator(), -1, 0 );
3771 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3772 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3773 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3774 popupMgr()->insert( separator(), -1, 0 );
3775 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3776 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3777 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3778 popupMgr()->insert( separator(), -1, 0 );
3779 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3780 popupMgr()->insert( separator(), -1, 0 );
3781 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3782 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3783 popupMgr()->insert( separator(), -1, 0 );
3785 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3786 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3788 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3789 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3790 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3791 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3792 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3793 popupMgr()->insert( separator(), -1, 0 );
3796 createPopupItem( 803, View, group ); // EDIT_GROUP
3797 createPopupItem( 804, View, elems ); // ADD
3798 createPopupItem( 805, View, elems ); // REMOVE
3800 popupMgr()->insert( separator(), -1, 0 );
3801 createPopupItem( 214, View, mesh_group ); // UPDATE
3802 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3803 //createPopupItem( 902, View, mesh ); // STD_INFO
3804 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3805 createPopupItem( 904, View, mesh ); // FIND_ELEM
3806 popupMgr()->insert( separator(), -1, 0 );
3808 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3809 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3810 popupMgr()->insert( separator(), -1, 0 );
3813 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3814 QString aType = QString( "%1type in {%2}" ).arg( lc );
3815 aType = aType.arg( mesh_group );
3816 QString aMeshInVTK = aClient + "&&" + aType;
3818 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3819 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3820 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3822 //-------------------------------------------------
3824 //-------------------------------------------------
3825 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3827 popupMgr()->insert( action( 9010 ), anId, -1 );
3828 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3829 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3831 popupMgr()->insert( action( 9011 ), anId, -1 );
3832 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3833 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3835 popupMgr()->insert( separator(), -1, -1 );
3837 //-------------------------------------------------
3839 //-------------------------------------------------
3840 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3842 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3843 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3844 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3846 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3847 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3848 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3850 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3851 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3852 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3854 popupMgr()->insert( separator(), anId, -1 );
3856 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3857 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3858 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3860 //-------------------------------------------------
3862 //-------------------------------------------------
3863 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3865 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3867 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3868 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3869 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3871 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3872 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3873 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3875 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3876 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3877 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3879 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3880 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3881 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3883 popupMgr()->insert( separator(), anId, -1 );
3885 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3886 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3889 //-------------------------------------------------
3890 // Representation of the 2D Quadratic elements
3891 //-------------------------------------------------
3892 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3893 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3894 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3895 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3897 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3898 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3899 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3901 //-------------------------------------------------
3902 // Orientation of faces
3903 //-------------------------------------------------
3904 popupMgr()->insert( action( 221 ), -1, -1 );
3905 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3906 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3908 //-------------------------------------------------
3910 //-------------------------------------------------
3911 popupMgr()->insert( action( 1132 ), -1, -1 );
3912 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3914 //-------------------------------------------------
3916 //-------------------------------------------------
3917 popupMgr()->insert( action( 1133 ), -1, -1 );
3918 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3920 //-------------------------------------------------
3922 //-------------------------------------------------
3924 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3925 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3926 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3927 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3929 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3931 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3932 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3934 popupMgr()->insert( separator(), anId, -1 );
3936 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3938 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3939 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3940 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3942 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3944 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3945 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3946 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3948 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3949 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3950 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3952 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3953 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3954 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3956 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3957 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3958 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3960 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3962 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3963 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3964 QtxPopupMgr::VisibleRule );
3965 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3967 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3968 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3969 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3971 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3972 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3973 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3975 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3976 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3977 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3979 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3980 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3981 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3983 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3984 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3985 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3987 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3988 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3989 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3991 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3992 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3993 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3995 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3996 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3997 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3999 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4000 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4001 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4003 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4004 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4007 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4008 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4009 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4011 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4013 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4014 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4015 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4017 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4018 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4019 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4021 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4022 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4023 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4025 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4026 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4027 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4029 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4030 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4031 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4033 popupMgr()->insert( separator(), anId, -1 );
4035 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4036 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4038 popupMgr()->insert( separator(), anId, -1 );
4040 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4042 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4043 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4045 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4046 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4049 #ifndef DISABLE_PLOT2DVIEWER
4050 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4051 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4054 //-------------------------------------------------
4056 //-------------------------------------------------
4057 popupMgr()->insert( separator(), -1, -1 );
4058 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4059 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4060 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4061 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4063 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4064 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4066 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4067 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4069 popupMgr()->insert( separator(), -1, -1 );
4071 //-------------------------------------------------
4073 //-------------------------------------------------
4074 popupMgr()->insert( action( 1134 ), -1, -1 );
4075 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4077 popupMgr()->insert( separator(), -1, -1 );
4079 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4080 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4082 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4083 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4086 //================================================================================
4088 * \brief Return true if SMESH or GEOM objects are selected.
4089 * Is called form LightApp_Module::activateModule() which clear selection if
4090 * not isSelectionCompatible()
4092 //================================================================================
4094 bool SMESHGUI::isSelectionCompatible()
4096 bool isCompatible = true;
4097 SALOME_ListIO selected;
4098 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4099 Sel->selectedObjects( selected );
4101 SALOME_ListIteratorOfListIO It( selected );
4102 for ( ; isCompatible && It.More(); It.Next())
4104 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4105 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4107 return isCompatible;
4111 bool SMESHGUI::reusableOperation( const int id )
4113 // compute, evaluate and precompute are not reusable operations
4114 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4117 bool SMESHGUI::activateModule( SUIT_Study* study )
4119 bool res = SalomeApp_Module::activateModule( study );
4121 setMenuShown( true );
4122 setToolShown( true );
4124 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4125 PyGILState_STATE gstate = PyGILState_Ensure();
4126 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4127 if(pluginsmanager==NULL)
4131 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4136 PyGILState_Release(gstate);
4137 // end of GEOM plugins loading
4139 // Reset actions accelerator keys
4140 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4141 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4142 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4144 action( 33)->setEnabled(true); // Delete: Key_Delete
4145 action(1101)->setEnabled(true); // Rename: Key_F2
4147 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4148 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4149 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4150 if ( _PTR(Study) aStudy = s->studyDS()) {
4151 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4152 updateObjBrowser(); // objects can be removed
4155 // get all view currently opened in the study and connect their signals to
4156 // the corresponding slots of the class.
4157 SUIT_Desktop* aDesk = study->application()->desktop();
4159 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4160 SUIT_ViewWindow* wnd;
4161 foreach ( wnd, wndList )
4168 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4170 setMenuShown( false );
4171 setToolShown( false );
4173 EmitSignalCloseAllDialogs();
4175 // Unset actions accelerator keys
4176 action(111)->setShortcut(QKeySequence()); // Import DAT
4177 action(112)->setShortcut(QKeySequence()); // Import UNV
4178 action(113)->setShortcut(QKeySequence()); // Import MED
4180 action( 33)->setEnabled(false); // Delete: Key_Delete
4181 action(1101)->setEnabled(false); // Rename: Key_F2
4183 return SalomeApp_Module::deactivateModule( study );
4186 void SMESHGUI::studyClosed( SUIT_Study* s )
4188 SMESH::RemoveVisuData( s->id() );
4189 SalomeApp_Module::studyClosed( s );
4192 void SMESHGUI::OnGUIEvent()
4194 const QObject* obj = sender();
4195 if ( !obj || !obj->inherits( "QAction" ) )
4197 int id = actionId((QAction*)obj);
4202 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4204 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4205 if ( CORBA::is_nil( myComponentSMESH ) )
4207 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4209 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4210 return aGUI.myComponentSMESH;
4213 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4214 return myComponentSMESH;
4217 QString SMESHGUI::engineIOR() const
4219 CORBA::ORB_var anORB = getApp()->orb();
4220 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4221 return QString( anIOR.in() );
4224 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4226 SalomeApp_Module::contextMenuPopup( client, menu, title );
4228 selectionMgr()->selectedObjects( lst );
4229 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4230 Handle(SALOME_InteractiveObject) io = lst.First();
4231 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4232 _PTR(Study) study = appStudy->studyDS();
4233 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4235 QString aName = QString( obj->GetName().c_str() );
4236 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4237 aName.remove( (aName.length() - 1), 1 );
4243 LightApp_Selection* SMESHGUI::createSelection() const
4245 return new SMESHGUI_Selection();
4248 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4250 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4251 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4254 void SMESHGUI::viewManagers( QStringList& list ) const
4256 list.append( SVTK_Viewer::Type() );
4259 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4261 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4262 SMESH::UpdateSelectionProp( this );
4264 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4265 for(int i = 0; i < aViews.count() ; i++){
4266 SUIT_ViewWindow *sf = aViews[i];
4272 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4274 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4275 myClippingPlaneInfoMap.erase( theViewManager );
4278 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4280 theActor->AddObserver( SMESH::DeleteActorEvent,
4281 myEventCallbackCommand.GetPointer(),
4285 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4286 unsigned long theEvent,
4287 void* theClientData,
4290 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4291 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4292 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4293 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4294 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4295 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4296 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4297 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4298 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4299 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4300 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4301 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4302 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4303 if( anActor == *anIter3 ) {
4304 anActorList.erase( anIter3 );
4315 void SMESHGUI::createPreferences()
4317 // General tab ------------------------------------------------------------------------
4318 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4320 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4321 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4322 setPreferenceProperty( lim, "min", 0 );
4323 setPreferenceProperty( lim, "max", 100000000 );
4324 setPreferenceProperty( lim, "step", 1000 );
4325 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4327 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4328 setPreferenceProperty( qaGroup, "columns", 2 );
4329 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4330 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4331 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4332 setPreferenceProperty( prec, "min", 0 );
4333 setPreferenceProperty( prec, "max", 16 );
4335 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4336 setPreferenceProperty( dispgroup, "columns", 2 );
4337 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4339 modes.append( "Wireframe" );
4340 modes.append( "Shading" );
4341 modes.append( "Nodes" );
4342 modes.append( "Shrink" );
4343 QList<QVariant> indices;
4344 indices.append( 0 );
4345 indices.append( 1 );
4346 indices.append( 2 );
4347 indices.append( 3 );
4348 setPreferenceProperty( dispmode, "strings", modes );
4349 setPreferenceProperty( dispmode, "indexes", indices );
4351 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4352 setPreferenceProperty( arcgroup, "columns", 2 );
4353 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4354 QStringList quadraticModes;
4355 quadraticModes.append("Lines");
4356 quadraticModes.append("Arcs");
4358 indices.append( 0 );
4359 indices.append( 1 );
4360 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4361 setPreferenceProperty( quadraticmode, "indexes", indices );
4363 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4364 "SMESH", "max_angle" );
4365 setPreferenceProperty( maxAngle, "min", 1 );
4366 setPreferenceProperty( maxAngle, "max", 90 );
4370 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4371 setPreferenceProperty( exportgroup, "columns", 2 );
4372 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4373 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4375 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4376 setPreferenceProperty( computeGroup, "columns", 2 );
4377 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4379 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4380 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4381 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4383 indices.append( 0 );
4384 indices.append( 1 );
4385 indices.append( 2 );
4386 setPreferenceProperty( notifyMode, "strings", modes );
4387 setPreferenceProperty( notifyMode, "indexes", indices );
4389 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4390 setPreferenceProperty( computeGroup, "columns", 2 );
4391 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4393 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4394 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4396 indices.append( 0 );
4397 indices.append( 1 );
4398 setPreferenceProperty( elemInfo, "strings", modes );
4399 setPreferenceProperty( elemInfo, "indexes", indices );
4401 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4402 setPreferenceProperty( segGroup, "columns", 2 );
4403 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4404 "SMESH", "segmentation" );
4405 setPreferenceProperty( segLen, "min", 1 );
4406 setPreferenceProperty( segLen, "max", 10000000 );
4407 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4408 "SMESH", "nb_segments_per_edge" );
4409 setPreferenceProperty( nbSeg, "min", 1 );
4410 setPreferenceProperty( nbSeg, "max", 10000000 );
4412 // Quantities with individual precision settings
4413 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4414 setPreferenceProperty( precGroup, "columns", 2 );
4416 const int nbQuantities = 6;
4417 int precs[nbQuantities], ii = 0;
4418 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4419 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4420 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4421 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4422 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4423 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4424 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4425 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4426 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4427 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4428 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4429 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4431 // Set property for precision value for spinboxes
4432 for ( ii = 0; ii < nbQuantities; ii++ ){
4433 setPreferenceProperty( precs[ii], "min", -14 );
4434 setPreferenceProperty( precs[ii], "max", 14 );
4435 setPreferenceProperty( precs[ii], "precision", 2 );
4438 // Mesh tab ------------------------------------------------------------------------
4439 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4440 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4441 setPreferenceProperty( nodeGroup, "columns", 3 );
4443 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4445 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4447 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4448 QList<QVariant> aMarkerTypeIndicesList;
4449 QList<QVariant> aMarkerTypeIconsList;
4450 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4451 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4452 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4453 aMarkerTypeIndicesList << i;
4454 aMarkerTypeIconsList << pixmap;
4456 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4457 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4459 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4461 QList<QVariant> aMarkerScaleIndicesList;
4462 QStringList aMarkerScaleValuesList;
4463 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4464 aMarkerScaleIndicesList << i;
4465 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4467 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4468 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4470 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4471 setPreferenceProperty( elemGroup, "columns", 2 );
4473 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4474 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4475 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4476 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4478 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4479 setPreferenceProperty( grpGroup, "columns", 2 );
4481 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4483 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4484 //setPreferenceProperty( sp, "hstretch", 0 );
4485 //setPreferenceProperty( sp, "vstretch", 0 );
4487 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4488 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4489 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4490 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4491 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4492 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4493 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4495 setPreferenceProperty( size0d, "min", 1 );
4496 setPreferenceProperty( size0d, "max", 10 );
4498 setPreferenceProperty( sp, "hstretch", 0 );
4499 setPreferenceProperty( sp, "vstretch", 0 );
4501 setPreferenceProperty( elemW, "min", 1 );
4502 setPreferenceProperty( elemW, "max", 5 );
4504 setPreferenceProperty( shrink, "min", 0 );
4505 setPreferenceProperty( shrink, "max", 100 );
4507 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4508 setPreferenceProperty( orientGroup, "columns", 1 );
4510 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4511 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4513 setPreferenceProperty( orientScale, "min", 0.05 );
4514 setPreferenceProperty( orientScale, "max", 0.5 );
4515 setPreferenceProperty( orientScale, "step", 0.05 );
4517 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4519 // Selection tab ------------------------------------------------------------------------
4520 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4522 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4523 setPreferenceProperty( selGroup, "columns", 2 );
4525 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4526 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4527 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4529 setPreferenceProperty( selW, "min", 1 );
4530 setPreferenceProperty( selW, "max", 5 );
4532 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4533 setPreferenceProperty( preGroup, "columns", 2 );
4535 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4536 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4538 setPreferenceProperty( preW, "min", 1 );
4539 setPreferenceProperty( preW, "max", 5 );
4541 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4542 setPreferenceProperty( precSelGroup, "columns", 2 );
4544 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4545 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4546 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4548 // Scalar Bar tab ------------------------------------------------------------------------
4549 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4550 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4551 setPreferenceProperty( fontGr, "columns", 2 );
4553 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4554 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4556 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4557 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4559 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4560 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4562 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4563 setPreferenceProperty( numcol, "min", 2 );
4564 setPreferenceProperty( numcol, "max", 256 );
4566 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4567 setPreferenceProperty( numlab, "min", 2 );
4568 setPreferenceProperty( numlab, "max", 65 );
4570 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4571 setPreferenceProperty( orientGr, "columns", 2 );
4572 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4573 QStringList orients;
4574 orients.append( tr( "SMESH_VERTICAL" ) );
4575 orients.append( tr( "SMESH_HORIZONTAL" ) );
4576 indices.clear(); indices.append( 0 ); indices.append( 1 );
4577 setPreferenceProperty( orient, "strings", orients );
4578 setPreferenceProperty( orient, "indexes", indices );
4580 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4581 setPreferenceProperty( posVSizeGr, "columns", 2 );
4582 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4583 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4584 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4585 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4586 setPreferenceProperty( xv, "step", 0.1 );
4587 setPreferenceProperty( xv, "min", 0.0 );
4588 setPreferenceProperty( xv, "max", 1.0 );
4589 setPreferenceProperty( yv, "step", 0.1 );
4590 setPreferenceProperty( yv, "min", 0.0 );
4591 setPreferenceProperty( yv, "max", 1.0 );
4592 setPreferenceProperty( wv, "step", 0.1 );
4593 setPreferenceProperty( wv, "min", 0.0 );
4594 setPreferenceProperty( wv, "max", 1.0 );
4595 setPreferenceProperty( hv, "min", 0.0 );
4596 setPreferenceProperty( hv, "max", 1.0 );
4597 setPreferenceProperty( hv, "step", 0.1 );
4599 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4600 setPreferenceProperty( posHSizeGr, "columns", 2 );
4601 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4602 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4603 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4604 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4605 setPreferenceProperty( xv, "min", 0.0 );
4606 setPreferenceProperty( xv, "max", 1.0 );
4607 setPreferenceProperty( xv, "step", 0.1 );
4608 setPreferenceProperty( xh, "min", 0.0 );
4609 setPreferenceProperty( xh, "max", 1.0 );
4610 setPreferenceProperty( xh, "step", 0.1 );
4611 setPreferenceProperty( yh, "min", 0.0 );
4612 setPreferenceProperty( yh, "max", 1.0 );
4613 setPreferenceProperty( yh, "step", 0.1 );
4614 setPreferenceProperty( wh, "min", 0.0 );
4615 setPreferenceProperty( wh, "max", 1.0 );
4616 setPreferenceProperty( wh, "step", 0.1 );
4617 setPreferenceProperty( hh, "min", 0.0 );
4618 setPreferenceProperty( hh, "max", 1.0 );
4619 setPreferenceProperty( hh, "step", 0.1 );
4621 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4622 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4623 setPreferenceProperty( distributionGr, "columns", 3 );
4625 types.append( tr( "SMESH_MONOCOLOR" ) );
4626 types.append( tr( "SMESH_MULTICOLOR" ) );
4627 indices.clear(); indices.append( 0 ); indices.append( 1 );
4628 setPreferenceProperty( coloringType, "strings", types );
4629 setPreferenceProperty( coloringType, "indexes", indices );
4630 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4634 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4636 if( sect=="SMESH" ) {
4637 float sbX1,sbY1,sbW,sbH;
4638 float aTol = 1.00000009999999;
4639 std::string aWarning;
4640 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4641 if( name=="selection_object_color" || name=="selection_element_color" ||
4642 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4643 name=="selection_precision_node" || name=="selection_precision_element" ||
4644 name=="selection_precision_object")
4645 SMESH::UpdateSelectionProp( this );
4646 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4647 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4648 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4649 if(sbX1+sbW > aTol){
4650 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4653 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4654 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4657 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4658 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4659 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4660 if(sbY1+sbH > aTol){
4661 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4662 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4663 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4666 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4667 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4668 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4669 if(sbX1+sbW > aTol){
4670 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4673 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4674 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4677 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4678 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4679 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4680 if(sbY1+sbH > aTol){
4681 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4684 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4685 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4688 else if ( name == "segmentation" ) {
4689 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4690 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4692 else if ( name == "nb_segments_per_edge" ) {
4693 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4694 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4697 if(aWarning.size() != 0){
4698 aWarning += "The default values are applied instead.";
4699 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4700 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4701 QObject::tr(aWarning.c_str()));
4706 //================================================================================
4708 * \brief Update something in accordance with update flags
4709 * \param theFlags - update flags
4711 * Update viewer or/and object browser etc. in accordance with update flags ( see
4712 * LightApp_UpdateFlags enumeration ).
4714 //================================================================================
4715 void SMESHGUI::update( const int flags )
4717 if ( flags & UF_Viewer | flags & UF_Forced )
4718 SMESH::UpdateView();
4720 SalomeApp_Module::update( flags );
4723 //================================================================================
4725 * \brief Set default selection mode
4727 * SLOT called when operation commited. Sets default selection mode
4729 //================================================================================
4730 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4732 SVTK_ViewWindow* vtkWnd =
4733 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4735 vtkWnd->SetSelectionMode( ActorSelection );
4738 //================================================================================
4740 * \brief Set default selection mode
4742 * SLOT called when operation aborted. Sets default selection mode
4744 //================================================================================
4745 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4747 SVTK_ViewWindow* vtkWnd =
4748 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4750 vtkWnd->SetSelectionMode( ActorSelection );
4753 //================================================================================
4755 * \brief Creates operation with given identifier
4756 * \param id - identifier of operation to be started
4757 * \return Pointer on created operation or NULL if operation is not created
4759 * Virtual method redefined from the base class creates operation with given id.
4760 * It is called called automatically from startOperation method of base class.
4762 //================================================================================
4763 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4765 LightApp_Operation* op = 0;
4766 // to do : create operation here
4769 case 417: //convert to quadratic
4770 op = new SMESHGUI_ConvToQuadOp();
4772 case 418: // create 2D mesh as boundary on 3D
4773 op = new SMESHGUI_Make2DFrom3DOp();
4775 case 701: // Compute mesh
4776 op = new SMESHGUI_ComputeOp();
4778 case 702: // Create mesh
4779 op = new SMESHGUI_MeshOp( true, true );
4781 case 703: // Create sub-mesh
4782 op = new SMESHGUI_MeshOp( true, false );
4784 case 704: // Edit mesh/sub-mesh
4785 op = new SMESHGUI_MeshOp( false );
4787 case 711: // Precompute mesh
4788 op = new SMESHGUI_PrecomputeOp();
4790 case 712: // Evaluate mesh
4791 op = new SMESHGUI_EvaluateOp();
4793 case 713: // Evaluate mesh
4794 op = new SMESHGUI_MeshOrderOp();
4796 case 806: // Create group on geom
4797 op = new SMESHGUI_GroupOnShapeOp();
4799 case 904: // Find element
4800 op = new SMESHGUI_FindElemByPointOp();
4802 case 4067: // make mesh pass through point
4803 op = new SMESHGUI_MakeNodeAtPointOp();
4810 op = SalomeApp_Module::createOperation( id );
4814 //================================================================================
4816 * \brief Stops current operations and starts a given one
4817 * \param id - The id of the operation to start
4819 //================================================================================
4821 void SMESHGUI::switchToOperation(int id)
4823 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4824 activeStudy()->abortAllOperations();
4825 startOperation( id );
4828 LightApp_Displayer* SMESHGUI::displayer()
4831 myDisplayer = new SMESHGUI_Displayer( getApp() );
4835 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4838 int aTolerance = 64;
4839 int anIterations = 0;
4845 if( anIterations % aPeriod == 0 )
4848 if( aTolerance < 1 )
4852 aHue = (int)( 360.0 * rand() / RAND_MAX );
4855 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4856 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4857 for( ; it != itEnd; ++it )
4859 SALOMEDS::Color anAutoColor = *it;
4860 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4863 aQColor.getHsv( &h, &s, &v );
4864 if( abs( h - aHue ) < aTolerance )
4876 aColor.setHsv( aHue, 255, 255 );
4878 SALOMEDS::Color aSColor;
4879 aSColor.R = (double)aColor.red() / 255.0;
4880 aSColor.G = (double)aColor.green() / 255.0;
4881 aSColor.B = (double)aColor.blue() / 255.0;
4886 const char gSeparator = '_'; // character used to separate parameter names
4887 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4888 const char gPathSep = '|'; // character used to separate paths
4891 * \brief Store visual parameters
4893 * This method is called just before the study document is saved.
4894 * Store visual parameters in AttributeParameter attribue(s)
4896 void SMESHGUI::storeVisualParameters (int savePoint)
4898 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4899 if (!appStudy || !appStudy->studyDS())
4901 _PTR(Study) studyDS = appStudy->studyDS();
4903 // componentName is used for encoding of entries when storing them in IParameters
4904 std::string componentName = myComponentSMESH->ComponentDataType();
4905 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4906 //if (!aSComponent) return;
4909 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4910 componentName.c_str(),
4912 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4914 // store map of custom markers
4915 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4916 if( !aMarkerMap.empty() )
4918 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4919 for( ; anIter != aMarkerMap.end(); anIter++ )
4921 int anId = anIter->first;
4922 VTK::MarkerData aMarkerData = anIter->second;
4923 std::string aMarkerFileName = aMarkerData.first;
4924 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4925 if( aMarkerTexture.size() < 3 )
4926 continue; // should contain at least width, height and the first value
4928 QString aPropertyName( "texture" );
4929 aPropertyName += gSeparator;
4930 aPropertyName += QString::number( anId );
4932 QString aPropertyValue = aMarkerFileName.c_str();
4933 aPropertyValue += gPathSep;
4935 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4936 ushort aWidth = *aTextureIter++;
4937 ushort aHeight = *aTextureIter++;
4938 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4939 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4940 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4941 aPropertyValue += QString::number( *aTextureIter );
4943 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4947 // viewers counters are used for storing view_numbers in IParameters
4950 // main cycle to store parameters of displayed objects
4951 QList<SUIT_ViewManager*> lst;
4952 QList<SUIT_ViewManager*>::Iterator it;
4953 getApp()->viewManagers(lst);
4954 for (it = lst.begin(); it != lst.end(); it++)
4956 SUIT_ViewManager* vman = *it;
4957 QString vType = vman->getType();
4959 // saving VTK actors properties
4960 if (vType == SVTK_Viewer::Type())
4962 // store the clipping planes attached to the view manager
4963 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4964 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4965 if( anIter != myClippingPlaneInfoMap.end() )
4966 aClippingPlaneInfoList = anIter->second;
4968 if( !aClippingPlaneInfoList.empty() ) {
4969 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4970 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4972 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4973 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4975 QString aPropertyName( "ClippingPlane" );
4976 aPropertyName += gSeparator;
4977 aPropertyName += QString::number( vtkViewers );
4978 aPropertyName += gSeparator;
4979 aPropertyName += QString::number( anId );
4981 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4982 aPropertyValue += gDigitsSep;
4983 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4984 aPropertyValue += gDigitsSep;
4985 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4986 aPropertyValue += gDigitsSep;
4987 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4989 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4993 QVector<SUIT_ViewWindow*> views = vman->getViews();
4994 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4996 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4998 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4999 vtkActorCollection* allActors = aCopy.GetActors();
5000 allActors->InitTraversal();
5001 while (vtkActor* actor = allActors->GetNextActor())
5003 if (actor->GetVisibility()) // store only visible actors
5005 SMESH_Actor* aSmeshActor = 0;
5006 if (actor->IsA("SMESH_Actor"))
5007 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5008 if (aSmeshActor && aSmeshActor->hasIO())
5010 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5013 // entry is "encoded" = it does NOT contain component adress,
5014 // since it is a subject to change on next component loading
5015 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5017 std::string param, vtkParam = vType.toLatin1().data();
5018 vtkParam += gSeparator;
5019 vtkParam += QString::number(vtkViewers).toLatin1().data();
5020 vtkParam += gSeparator;
5023 param = vtkParam + "Visibility";
5024 ip->setParameter(entry, param, "On");
5027 param = vtkParam + "Representation";
5028 ip->setParameter(entry, param, QString::number
5029 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5032 param = vtkParam + "IsShrunk";
5033 ip->setParameter(entry, param, QString::number
5034 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5036 // Displayed entities
5037 unsigned int aMode = aSmeshActor->GetEntityMode();
5038 bool isE = aMode & SMESH_Actor::eEdges;
5039 bool isF = aMode & SMESH_Actor::eFaces;
5040 bool isV = aMode & SMESH_Actor::eVolumes;
5042 QString modeStr ("e");
5043 modeStr += gDigitsSep; modeStr += QString::number(isE);
5044 modeStr += gDigitsSep; modeStr += "f";
5045 modeStr += gDigitsSep; modeStr += QString::number(isF);
5046 modeStr += gDigitsSep; modeStr += "v";
5047 modeStr += gDigitsSep; modeStr += QString::number(isV);
5049 param = vtkParam + "Entities";
5050 ip->setParameter(entry, param, modeStr.toLatin1().data());
5052 // Colors (surface:edge:)
5053 vtkFloatingPointType r, g, b;
5055 aSmeshActor->GetSufaceColor(r, g, b);
5056 QString colorStr ("surface");
5057 colorStr += gDigitsSep; colorStr += QString::number(r);
5058 colorStr += gDigitsSep; colorStr += QString::number(g);
5059 colorStr += gDigitsSep; colorStr += QString::number(b);
5061 aSmeshActor->GetBackSufaceColor(r, g, b);
5062 colorStr += gDigitsSep; colorStr += "backsurface";
5063 colorStr += gDigitsSep; colorStr += QString::number(r);
5064 colorStr += gDigitsSep; colorStr += QString::number(g);
5065 colorStr += gDigitsSep; colorStr += QString::number(b);
5067 aSmeshActor->GetEdgeColor(r, g, b);
5068 colorStr += gDigitsSep; colorStr += "edge";
5069 colorStr += gDigitsSep; colorStr += QString::number(r);
5070 colorStr += gDigitsSep; colorStr += QString::number(g);
5071 colorStr += gDigitsSep; colorStr += QString::number(b);
5073 aSmeshActor->GetNodeColor(r, g, b);
5074 colorStr += gDigitsSep; colorStr += "node";
5075 colorStr += gDigitsSep; colorStr += QString::number(r);
5076 colorStr += gDigitsSep; colorStr += QString::number(g);
5077 colorStr += gDigitsSep; colorStr += QString::number(b);
5079 param = vtkParam + "Colors";
5080 ip->setParameter(entry, param, colorStr.toLatin1().data());
5082 // Sizes of lines and points
5083 QString sizeStr ("line");
5084 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5085 sizeStr += gDigitsSep; sizeStr += "shrink";
5086 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5088 param = vtkParam + "Sizes";
5089 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5094 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5095 if( aMarkerType == VTK::MT_USER ) {
5096 markerStr += "custom";
5097 markerStr += gDigitsSep;
5098 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5102 markerStr += gDigitsSep;
5103 markerStr += QString::number( (int)aMarkerType );
5104 markerStr += gDigitsSep;
5105 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5108 param = vtkParam + "PointMarker";
5109 ip->setParameter(entry, param, markerStr.toLatin1().data());
5112 param = vtkParam + "Opacity";
5113 ip->setParameter(entry, param,
5114 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5117 param = vtkParam + "ClippingPlane";
5119 if( !aClippingPlaneInfoList.empty() ) {
5120 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5121 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5123 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5124 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5125 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5126 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5127 if( aSmeshActor == *anIter2 ) {
5128 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5129 QString::number( anId ).toLatin1().constData() );
5136 ip->setParameter( entry, param, "Off" );
5137 } // if (io->hasEntry())
5138 } // SMESH_Actor && hasIO
5140 } // while.. actors traversal
5144 } // if (SVTK view model)
5145 } // for (viewManagers)
5148 // data structures for clipping planes processing
5151 vtkIdType Orientation;
5152 vtkFloatingPointType Distance;
5153 vtkFloatingPointType Angle[2];
5155 typedef std::list<TPlaneData> TPlaneDataList;
5156 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5158 typedef std::list<vtkActor*> TActorList;
5161 TActorList ActorList;
5162 SUIT_ViewManager* ViewManager;
5164 typedef std::list<TPlaneInfo> TPlaneInfoList;
5165 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5168 * \brief Restore visual parameters
5170 * This method is called after the study document is opened.
5171 * Restore visual parameters from AttributeParameter attribue(s)
5173 void SMESHGUI::restoreVisualParameters (int savePoint)
5175 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5176 if (!appStudy || !appStudy->studyDS())
5178 _PTR(Study) studyDS = appStudy->studyDS();
5180 // componentName is used for encoding of entries when storing them in IParameters
5181 std::string componentName = myComponentSMESH->ComponentDataType();
5182 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5183 //if (!aSComponent) return;
5186 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5187 componentName.c_str(),
5189 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5191 // restore map of custom markers and map of clipping planes
5192 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5193 TPlaneDataMap aPlaneDataMap;
5195 std::vector<std::string> properties = ip->getProperties();
5196 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5198 std::string property = *propIt;
5199 QString aPropertyName( property.c_str() );
5200 QString aPropertyValue( ip->getProperty( property ).c_str() );
5202 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5203 if( aPropertyNameList.isEmpty() )
5206 QString aPropertyType = aPropertyNameList[0];
5207 if( aPropertyType == "texture" )
5209 if( aPropertyNameList.size() != 2 )
5213 int anId = aPropertyNameList[1].toInt( &ok );
5214 if( !ok || anId < 1 )
5217 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5218 if( aPropertyValueList.size() != 2 )
5221 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5222 QString aMarkerTextureString = aPropertyValueList[1];
5223 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5224 if( aMarkerTextureStringList.size() != 3 )
5228 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5233 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5237 VTK::MarkerTexture aMarkerTexture;
5238 aMarkerTexture.push_back( aWidth );
5239 aMarkerTexture.push_back( aHeight );
5241 QString aMarkerTextureData = aMarkerTextureStringList[2];
5242 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5244 QChar aChar = aMarkerTextureData.at( i );
5245 if( aChar.isDigit() )
5246 aMarkerTexture.push_back( aChar.digitValue() );
5249 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5251 else if( aPropertyType == "ClippingPlane" )
5253 if( aPropertyNameList.size() != 3 )
5257 int aViewId = aPropertyNameList[1].toInt( &ok );
5258 if( !ok || aViewId < 0 )
5262 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5263 if( !ok || aClippingPlaneId < 0 )
5266 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5267 if( aPropertyValueList.size() != 4 )
5270 TPlaneData aPlaneData;
5271 aPlaneData.Id = aClippingPlaneId;
5274 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5279 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5284 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5289 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5293 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5294 aPlaneDataList.push_back( aPlaneData );
5298 TPlaneInfoMap aPlaneInfoMap;
5300 std::vector<std::string> entries = ip->getEntries();
5302 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5304 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5305 QString entry (ip->decodeEntry(*entIt).c_str());
5307 // Check that the entry corresponds to a real object in the Study
5308 // as the object may be deleted or modified after the visual state is saved.
5309 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5310 if (!so) continue; //Skip the not existent entry
5312 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5313 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5315 std::vector<std::string>::iterator namesIt = paramNames.begin();
5316 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5318 // actors are stored in a map after displaying of them for
5319 // quicker access in the future: map < viewID to actor >
5320 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5322 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5324 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5325 // '_' is used as separator and should not be used in viewer type or parameter names.
5326 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5327 if (lst.size() != 3)
5330 QString viewerTypStr = lst[0];
5331 QString viewIndexStr = lst[1];
5332 QString paramNameStr = lst[2];
5335 int viewIndex = viewIndexStr.toUInt(&ok);
5336 if (!ok) // bad conversion of view index to integer
5340 if (viewerTypStr == SVTK_Viewer::Type())
5342 SMESH_Actor* aSmeshActor = 0;
5343 if (vtkActors.IsBound(viewIndex))
5344 aSmeshActor = vtkActors.Find(viewIndex);
5346 QList<SUIT_ViewManager*> lst;
5347 getApp()->viewManagers(viewerTypStr, lst);
5349 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5350 SUIT_ViewManager* vman = NULL;
5351 if (viewIndex >= 0 && viewIndex < lst.count())
5352 vman = lst.at(viewIndex);
5354 if (paramNameStr == "Visibility")
5356 if (!aSmeshActor && displayer() && vman)
5358 SUIT_ViewModel* vmodel = vman->getViewModel();
5359 // SVTK view model can be casted to SALOME_View
5360 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5362 // store displayed actor in a temporary map for quicker
5363 // access later when restoring other parameters
5364 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5365 vtkRenderer* Renderer = vtkView->getRenderer();
5366 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5367 vtkActorCollection* theActors = aCopy.GetActors();
5368 theActors->InitTraversal();
5369 bool isFound = false;
5370 vtkActor *ac = theActors->GetNextActor();
5371 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5372 if (ac->IsA("SMESH_Actor")) {
5373 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5374 if (aGeomAc->hasIO()) {
5375 Handle(SALOME_InteractiveObject) io =
5376 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5377 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5379 vtkActors.Bind(viewIndex, aGeomAc);
5385 } // if (paramNameStr == "Visibility")
5388 // the rest properties "work" with SMESH_Actor
5391 QString val ((*valuesIt).c_str());
5394 if (paramNameStr == "Representation") {
5395 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5398 else if (paramNameStr == "IsShrunk") {
5400 if (!aSmeshActor->IsShrunk())
5401 aSmeshActor->SetShrink();
5404 if (aSmeshActor->IsShrunk())
5405 aSmeshActor->UnShrink();
5408 // Displayed entities
5409 else if (paramNameStr == "Entities") {
5410 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5411 if (mode.count() == 6) {
5412 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5413 MESSAGE("Invalid order of data in Entities, must be: "
5414 "e:0/1:f:0/1:v:0/1");
5417 unsigned int aMode = aSmeshActor->GetEntityMode();
5418 unsigned int aNewMode =
5419 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5420 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5421 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5422 if (aNewMode != aMode)
5423 aSmeshActor->SetEntityMode(aNewMode);
5428 else if (paramNameStr == "Colors") {
5429 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5430 if (colors.count() == 16) {
5431 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5432 colors[8] != "edge" || colors[12] != "node") {
5433 MESSAGE("Invalid order of data in Colors, must be: "
5434 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5437 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5438 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5439 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5440 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5444 // Sizes of lines and points
5445 else if (paramNameStr == "Sizes") {
5446 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5447 if (sizes.count() == 4) {
5448 if (sizes[0] != "line" || sizes[2] != "shrink") {
5449 MESSAGE("Invalid order of data in Sizes, must be: "
5450 "line:int:shrink:float");
5453 aSmeshActor->SetLineWidth(sizes[1].toInt());
5454 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5457 else if (sizes.count() == 6) { // just to support old format
5458 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5459 MESSAGE("Invalid order of data in Sizes, must be: "
5460 "line:int:node:int:shrink:float");
5463 aSmeshActor->SetLineWidth(sizes[1].toInt());
5464 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5465 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5470 else if (paramNameStr == "PointMarker") {
5471 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5472 if( data.count() >= 2 ) {
5474 int aParam1 = data[1].toInt( &ok );
5476 if( data[0] == "std" && data.count() == 3 ) {
5477 int aParam2 = data[2].toInt( &ok );
5478 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5480 else if( data[0] == "custom" ) {
5481 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5482 if( markerIt != aMarkerMap.end() ) {
5483 VTK::MarkerData aMarkerData = markerIt->second;
5484 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5491 else if (paramNameStr == "Opacity") {
5492 aSmeshActor->SetOpacity(val.toFloat());
5495 else if (paramNameStr.startsWith("ClippingPlane")) {
5496 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5497 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5498 // new format - val looks like "Off" or "0" (plane id)
5499 // (note: in new format "Off" value is used only for consistency,
5500 // so it is processed together with values in old format)
5501 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5502 if( anIsOldFormat ) {
5503 if (paramNameStr == "ClippingPlane1" || val == "Off")
5504 aSmeshActor->RemoveAllClippingPlanes();
5506 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5507 double aDistance = vals[1].toFloat();
5508 vtkFloatingPointType anAngle[2];
5509 anAngle[0] = vals[2].toFloat();
5510 anAngle[1] = vals[3].toFloat();
5512 QList<SUIT_ViewManager*> lst;
5513 getApp()->viewManagers(viewerTypStr, lst);
5514 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5515 if (viewIndex >= 0 && viewIndex < lst.count()) {
5516 SUIT_ViewManager* vman = lst.at(viewIndex);
5517 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5519 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5521 SMESH::TActorList anActorList;
5522 anActorList.push_back( aSmeshActor );
5523 SMESH::OrientedPlane* aPlane =
5524 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5526 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5527 aClippingPlaneInfo.Plane = aPlane;
5528 aClippingPlaneInfo.ActorList = anActorList;
5529 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5536 int aPlaneId = val.toInt( &ok );
5537 if( ok && aPlaneId >= 0 ) {
5538 bool anIsDefinedPlane = false;
5539 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5540 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5541 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5542 TPlaneInfo& aPlaneInfo = *anIter;
5543 if( aPlaneInfo.PlaneId == aPlaneId ) {
5544 aPlaneInfo.ActorList.push_back( aSmeshActor );
5545 anIsDefinedPlane = true;
5549 if( !anIsDefinedPlane ) {
5550 TPlaneInfo aPlaneInfo;
5551 aPlaneInfo.PlaneId = aPlaneId;
5552 aPlaneInfo.ActorList.push_back( aSmeshActor );
5553 aPlaneInfo.ViewManager = vman;
5555 // to make the list sorted by plane id
5556 anIter = aPlaneInfoList.begin();
5557 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5558 const TPlaneInfo& aPlaneInfoRef = *anIter;
5559 if( aPlaneInfoRef.PlaneId > aPlaneId )
5562 aPlaneInfoList.insert( anIter, aPlaneInfo );
5567 } // if (aSmeshActor)
5568 } // other parameters than Visibility
5570 } // for names/parameters iterator
5571 } // for entries iterator
5573 // take into account planes with empty list of actors referred to them
5574 QList<SUIT_ViewManager*> aVMList;
5575 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5577 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5578 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5579 int aViewId = aPlaneDataIter->first;
5580 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5581 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5583 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5585 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5586 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5587 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5588 const TPlaneData& aPlaneData = *anIter2;
5589 int aPlaneId = aPlaneData.Id;
5591 bool anIsFound = false;
5592 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5593 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5594 const TPlaneInfo& aPlaneInfo = *anIter3;
5595 if( aPlaneInfo.PlaneId == aPlaneId ) {
5602 TPlaneInfo aPlaneInfo; // ActorList field is empty
5603 aPlaneInfo.PlaneId = aPlaneId;
5604 aPlaneInfo.ViewManager = aViewManager;
5606 // to make the list sorted by plane id
5607 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5608 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5609 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5610 if( aPlaneInfoRef.PlaneId > aPlaneId )
5613 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5619 // add clipping planes to actors according to the restored parameters
5620 // and update the clipping plane map
5621 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5622 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5623 int aViewId = anIter1->first;
5624 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5626 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5627 if( anIter2 == aPlaneDataMap.end() )
5629 const TPlaneDataList& aPlaneDataList = anIter2->second;
5631 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5632 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5633 const TPlaneInfo& aPlaneInfo = *anIter3;
5634 int aPlaneId = aPlaneInfo.PlaneId;
5635 const TActorList& anActorList = aPlaneInfo.ActorList;
5636 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5640 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5644 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5646 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5647 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5648 const TPlaneData& aPlaneData = *anIter4;
5649 if( aPlaneData.Id == aPlaneId ) {
5650 SMESH::OrientedPlane* aPlane =
5651 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5653 (SMESH::Orientation)aPlaneData.Orientation,
5654 aPlaneData.Distance,
5657 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5658 aClippingPlaneInfo.Plane = aPlane;
5659 aClippingPlaneInfo.ActorList = anActorList;
5660 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5668 // update all VTK views
5669 QList<SUIT_ViewManager*> lst;
5670 getApp()->viewManagers(lst);
5671 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5672 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5673 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5674 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5675 vtkView->getRenderer()->ResetCameraClippingRange();
5682 \brief Adds preferences for dfont of VTK viewer
5684 \param pIf group identifier
5685 \param param parameter
5686 \return identifier of preferences
5688 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5690 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5692 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5695 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5696 fam.append( tr( "SMESH_FONT_COURIER" ) );
5697 fam.append( tr( "SMESH_FONT_TIMES" ) );
5699 setPreferenceProperty( tfont, "fonts", fam );
5701 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5702 setPreferenceProperty( tfont, "features", f );
5708 \brief Actions after hypothesis edition
5709 Updates object browser after hypothesis edition
5711 void SMESHGUI::onHypothesisEdit( int result )
5714 SMESHGUI::Modified();
5715 updateObjBrowser( true );
5720 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5721 \param pview view being closed
5723 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5724 #ifndef DISABLE_PLOT2DVIEWER
5725 //Crear all Plot2d Viewers if need.
5726 SMESH::ClearPlot2Viewers(pview);
5731 \brief Connects or disconnects signals about activating and cloning view on the module slots
5732 \param pview view which is connected/disconnected
5734 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5738 SUIT_ViewManager* viewMgr = pview->getViewManager();
5740 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5741 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5743 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5744 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );