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)" );
202 QString anInitialPath = "";
203 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
204 anInitialPath = QDir::currentPath();
206 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
209 QObject::tr( "SMESH_IMPORT_MESH" ) );
210 if ( filenames.count() > 0 ) {
211 SUIT_OverrideCursor wc;
212 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
215 bool isEmpty = false;
216 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
217 QString filename = *it;
218 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
220 switch ( theCommandID ) {
223 // DAT format (currently unsupported)
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
231 aMeshes->length( 1 );
232 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
233 if ( aMeshes[0]->_is_nil() )
234 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
235 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
241 SMESH::DriverMED_ReadStatus res;
242 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
243 if ( res != SMESH::DRS_OK ) {
244 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
245 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
251 catch ( const SALOME::SALOME_Exception& S_ex ) {
252 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
253 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
256 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
257 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
259 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
260 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
261 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
262 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
263 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
265 #ifdef WITHGENERICOBJ
266 // obj has been published in study. Its refcount has been incremented.
267 // It is safe to decrement its refcount
268 // so that it will be destroyed when the entry in study will be removed
269 aMeshes[i]->Destroy();
278 // update Object browser
279 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
281 // show Error message box if there were errors
282 if ( errors.count() > 0 ) {
283 SUIT_MessageBox::critical( SMESHGUI::desktop(),
284 QObject::tr( "SMESH_ERROR" ),
285 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
288 // show warning message box, if some imported mesh is empty
290 SUIT_MessageBox::warning( SMESHGUI::desktop(),
291 QObject::tr( "SMESH_WRN_WARNING" ),
292 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
297 void ExportMeshToFile( int theCommandID )
299 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
300 SALOME_ListIO selected;
302 aSel->selectedObjects( selected );
304 // actually, the following condition can't be met (added for insurance)
305 if( selected.Extent() == 0 ||
306 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
309 bool hasDuplicatedMeshNames = false;
310 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
311 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
312 SALOME_ListIteratorOfListIO It( selected );
313 for( ; It.More(); It.Next() ) {
314 Handle(SALOME_InteractiveObject) anIObject = It.Value();
315 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
316 if ( aMeshItem->_is_nil() ) {
317 SUIT_MessageBox::warning( SMESHGUI::desktop(),
318 QObject::tr( "SMESH_WRN_WARNING" ),
319 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
323 QString aMeshName = anIObject->getName();
325 // check for duplications
326 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
327 if( aMeshName == (*aMeshIter).second ) {
328 hasDuplicatedMeshNames = true;
333 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
336 if( hasDuplicatedMeshNames ) {
337 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
338 QObject::tr("SMESH_WRN_WARNING"),
339 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
340 QObject::tr("SMESH_BUT_YES"),
341 QObject::tr("SMESH_BUT_NO"), 0, 1);
346 aMeshIter = aMeshList.begin();
347 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
348 QString aMeshName = (*aMeshIter).second;
350 QList<SALOMEDS::Color> aReservedColors;
352 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
353 QMap<QString, SMESH::MED_VERSION> aFilterMap;
354 QMap<QString, int> aFilterMapSTL;
355 switch ( theCommandID ) {
359 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
360 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
361 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
362 int aRet = SUIT_MessageBox::warning
363 (SMESHGUI::desktop(),
364 QObject::tr("SMESH_WRN_WARNING"),
365 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
366 QObject::tr("SMESH_BUT_YES"),
367 QObject::tr("SMESH_BUT_NO"), 0, 1);
373 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
374 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
375 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
376 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
381 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
386 if (aMesh->NbPyramids()) {
387 int aRet = SUIT_MessageBox::warning
388 (SMESHGUI::desktop(),
389 QObject::tr("SMESH_WRN_WARNING"),
390 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
391 QObject::tr("SMESH_BUT_YES"),
392 QObject::tr("SMESH_BUT_NO"), 0, 1);
396 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
404 there must be check on others mesh elements not equal triangles
406 // if (aMesh->NbTriangles() < 1) {
407 // SUIT_MessageBox::warning
408 // (SMESHGUI::desktop(),
409 // QObject::tr("SMESH_WRN_WARNING"),
410 // QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
413 // if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
414 // int aRet = SUIT_MessageBox::warning
415 // (SMESHGUI::desktop(),
416 // QObject::tr("SMESH_WRN_WARNING"),
417 // QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
418 // QObject::tr("SMESH_BUT_YES"),
419 // QObject::tr("SMESH_BUT_NO"), 0, 1);
424 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
425 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
433 SMESH::MED_VERSION aFormat;
434 // Init the parameter with the default value
435 bool aIsASCII_STL = true;
436 bool toCreateGroups = false;
437 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
439 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
440 bool toOverwrite = true;
442 QString anInitialPath = "";
443 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
444 anInitialPath = QDir::currentPath();
446 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
447 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
448 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
449 aFilter, aTitle, false);
451 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
453 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
454 for ( ; it != aFilterMapSTL.end(); ++it )
455 filters.push_back( it.key() );
457 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
458 fd->setWindowTitle( aTitle );
459 fd->setNameFilters( filters );
460 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
461 if ( !anInitialPath.isEmpty() )
462 fd->setDirectory( anInitialPath );
463 fd->selectFile(aMeshName);
467 aFilename = fd->selectedFile();
468 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
473 else { // Export to MED
475 QString aDefaultFilter;
476 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
477 for ( ; it != aFilterMap.end(); ++it ) {
478 filters.push_back( it.key() );
479 if (it.value() == SMESH::MED_V2_2)
480 aDefaultFilter = it.key();
483 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
484 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
485 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
486 fd->setWindowTitle( aTitle );
487 fd->setNameFilters( filters );
488 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
489 fd->selectNameFilter(aDefaultFilter);
490 fd->SetChecked(toCreateGroups);
491 if ( !anInitialPath.isEmpty() )
492 fd->setDirectory( anInitialPath );
493 fd->selectFile(aMeshName);
495 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
496 fd->setValidator( fv );
501 aFilename = fd->selectedFile();
503 aFilename = QString::null;
506 aFormat = aFilterMap[fd->selectedNameFilter()];
507 toOverwrite = fv->isOverwrite();
509 if ( !aFilename.isEmpty() ) {
510 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
511 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
512 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
513 && aFormat==SMESH::MED_V2_1) {
514 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
515 QObject::tr("SMESH_WRN_WARNING"),
516 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
517 QObject::tr("SMESH_BUT_YES"),
518 QObject::tr("SMESH_BUT_NO"), 0, 1);
526 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
527 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
528 if( !isVersionOk || aVersion != aFormat ) {
529 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
530 QObject::tr("SMESH_WRN_WARNING"),
531 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
532 QObject::tr("SMESH_BUT_YES"),
533 QObject::tr("SMESH_BUT_NO"), 0, 1);
540 QStringList aMeshNamesCollisionList;
541 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
542 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
543 QString anExistingMeshName( aMeshNames[ i ] );
544 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
545 QString anExportMeshName = (*aMeshIter).second;
546 if( anExportMeshName == anExistingMeshName ) {
547 aMeshNamesCollisionList.append( anExportMeshName );
553 if( !aMeshNamesCollisionList.isEmpty() ) {
554 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
555 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
556 QObject::tr("SMESH_WRN_WARNING"),
557 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
558 QObject::tr("SMESH_BUT_YES"),
559 QObject::tr("SMESH_BUT_NO"),
560 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
569 toCreateGroups = fd->IsChecked();
572 if ( !aFilename.isEmpty() ) {
573 // Check whether the file already exists and delete it if yes
574 QFile aFile( aFilename );
575 if ( aFile.exists() && toOverwrite )
577 SUIT_OverrideCursor wc;
580 bool Renumber = false;
581 // PAL 14172 : Check of we have to renumber or not from the preferences before export
583 Renumber= resMgr->booleanValue("SMESH","renumbering");
585 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
586 aMeshEditor->RenumberNodes();
587 aMeshEditor->RenumberElements();
588 if ( SMESHGUI::automaticUpdate() )
591 switch ( theCommandID ) {
595 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
596 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
597 if( !aMeshItem->_is_nil() )
598 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
604 aMesh->ExportDAT( aFilename.toLatin1().data() );
608 aMesh->ExportUNV( aFilename.toLatin1().data() );
612 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
618 catch (const SALOME::SALOME_Exception& S_ex){
620 SUIT_MessageBox::warning(SMESHGUI::desktop(),
621 QObject::tr("SMESH_WRN_WARNING"),
622 QObject::tr("SMESH_EXPORT_FAILED"));
628 inline void InverseEntityMode(unsigned int& theOutputMode,
629 unsigned int theMode)
631 bool anIsNotPresent = ~theOutputMode & theMode;
633 theOutputMode |= theMode;
635 theOutputMode &= ~theMode;
638 void SetDisplayEntity(int theCommandID){
639 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
640 SALOME_ListIO selected;
642 aSel->selectedObjects( selected );
644 if(selected.Extent() >= 1){
645 SALOME_ListIteratorOfListIO It( selected );
646 for( ; It.More(); It.Next()){
647 Handle(SALOME_InteractiveObject) IObject = It.Value();
648 if(IObject->hasEntry()){
649 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
650 unsigned int aMode = anActor->GetEntityMode();
651 switch(theCommandID){
653 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
656 InverseEntityMode(aMode,SMESH_Actor::eEdges);
659 InverseEntityMode(aMode,SMESH_Actor::eFaces);
662 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
665 aMode = SMESH_Actor::eAllEntity;
669 anActor->SetEntityMode(aMode);
677 SALOME_ListIO selected;
678 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
682 LightApp_SelectionMgr* aSel = app->selectionMgr();
683 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
684 if( !aSel || !appStudy )
687 aSel->selectedObjects( selected );
688 if( selected.IsEmpty() )
691 Handle(SALOME_InteractiveObject) anIObject = selected.First();
693 _PTR(Study) aStudy = appStudy->studyDS();
694 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
695 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
696 if( aMainObject->_is_nil() )
699 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
701 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
702 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
704 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
705 SALOMEDS::Color aColor = aGroupObject->GetColor();
706 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
708 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
709 if( aGroupObject->GetType() == SMESH::NODE )
710 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
711 else if( aGroupObject->GetType() == SMESH::EDGE )
712 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
713 else if( aGroupObject->GetType() == SMESH::ELEM0D )
714 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
716 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
721 SMESH::RepaintCurrentView();
724 QString functorToString( SMESH::Controls::FunctorPtr f )
726 QString type = QObject::tr( "UNKNOWN_CONTROL" );
727 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
728 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
729 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
730 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
731 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
732 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
733 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
734 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
735 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
736 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
737 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
738 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
739 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
740 type = QObject::tr( "WARP_ELEMENTS" );
741 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
742 type = QObject::tr( "TAPER_ELEMENTS" );
743 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
744 type = QObject::tr( "SKEW_ELEMENTS" );
745 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
746 type = QObject::tr( "AREA_ELEMENTS" );
747 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
748 type = QObject::tr( "LENGTH_EDGES" );
749 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
750 type = QObject::tr( "LENGTH2D_EDGES" );
751 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
752 type = QObject::tr( "MULTI_BORDERS" );
753 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
754 type = QObject::tr( "MULTI2D_BORDERS" );
755 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
756 type = QObject::tr( "FREE_NODES" );
757 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
758 type = QObject::tr( "FREE_EDGES" );
759 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
760 type = QObject::tr( "FREE_BORDERS" );
761 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
762 type = QObject::tr( "FREE_FACES" );
763 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
764 type = QObject::tr( "BARE_BORDER_VOLUME" );
765 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
766 type = QObject::tr( "BARE_BORDER_FACE" );
767 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
768 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
769 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
770 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
774 void SaveDistribution()
776 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
777 SALOME_ListIO selected;
779 aSel->selectedObjects( selected );
781 if ( selected.Extent() == 1 ) {
782 Handle(SALOME_InteractiveObject) anIO = selected.First();
783 if ( anIO->hasEntry() ) {
784 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
785 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
786 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
787 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
788 if ( aScalarBarActor && aFunctor ) {
789 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
791 std::vector<int> elements;
792 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
793 if ( mesh->_is_nil() ) {
794 SMESH::SMESH_IDSource_var idSource =
795 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
796 if ( !idSource->_is_nil() )
798 SMESH::long_array_var ids = idSource->GetIDs();
799 elements.resize( ids->length() );
800 for ( unsigned i = 0; i < elements.size(); ++i )
801 elements[i] = ids[i];
804 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
805 vtkLookupTable* lookupTable =
806 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
807 double * minmax = lookupTable->GetRange();
808 std::vector<int> nbEvents;
809 std::vector<double> funValues;
810 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
811 QString anInitialPath = "";
812 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
813 anInitialPath = QDir::currentPath();
814 QString aMeshName = anIO->getName();
816 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
817 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
818 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
819 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
820 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
823 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
825 if ( !aFilename.isEmpty() ) {
826 QFile f( aFilename );
827 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
828 QTextStream out( &f );
829 out << "# Mesh: " << aMeshName << endl;
830 out << "# Control: " << functorToString( aFunctor ) << endl;
832 out.setFieldWidth( 10 );
833 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
834 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
845 void ShowDistribution() {
846 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
847 SALOME_ListIO selected;
849 aSel->selectedObjects( selected );
851 if ( selected.Extent() == 1 ) {
852 Handle(SALOME_InteractiveObject) anIO = selected.First();
853 if ( anIO->hasEntry() ) {
854 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
855 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
856 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
857 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
863 #ifndef DISABLE_PLOT2DVIEWER
864 void PlotDistribution() {
865 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
869 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
870 SALOME_ListIO selected;
872 aSel->selectedObjects( selected );
874 if ( selected.Extent() == 1 ) {
875 Handle(SALOME_InteractiveObject) anIO = selected.First();
876 if ( anIO->hasEntry() ) {
877 //Find Actor by entry before getting Plot2d viewer,
878 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
879 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
881 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
886 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
890 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
894 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
895 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
896 QString functorName = functorToString( anActor->GetFunctor());
897 QString aHistogramName("%1 : %2");
898 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
899 aHistogram->setName(aHistogramName);
900 aHistogram->setHorTitle(functorName);
901 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
902 aPlot->displayObject(aHistogram, true);
907 #endif //DISABLE_PLOT2DVIEWER
909 void DisableAutoColor(){
910 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
911 SALOME_ListIO selected;
913 aSel->selectedObjects( selected );
915 if(selected.Extent()){
916 Handle(SALOME_InteractiveObject) anIObject = selected.First();
917 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
918 if ( !aMesh->_is_nil() ) {
919 aMesh->SetAutoColor( false );
924 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
925 SALOME_ListIO selected;
926 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
930 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
931 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
932 if( !aSel || !appStudy )
935 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
936 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
937 aModule->EmitSignalDeactivateDialog();
938 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
939 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
944 _PTR(Study) aStudy = appStudy->studyDS();
946 aSel->selectedObjects( selected );
948 if(selected.Extent() >= 1){
949 switch(theCommandID){
951 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
952 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
956 QColor c, e, b, n, c0D, o;
959 vtkFloatingPointType Shrink = 0.0;
960 vtkFloatingPointType faces_orientation_scale = 0.0;
961 bool faces_orientation_3dvectors = false;
963 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
964 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
965 int aMarkerTextureCurrent = 0;
967 SALOME_ListIteratorOfListIO It( selected );
968 for( ; It.More(); It.Next()){
969 Handle(SALOME_InteractiveObject) IObject = It.Value();
970 if(IObject->hasEntry()){
971 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
972 vtkFloatingPointType color[3];
973 anActor->GetSufaceColor(color[0], color[1], color[2]);
974 int c0 = int (color[0] * 255);
975 int c1 = int (color[1] * 255);
976 int c2 = int (color[2] * 255);
977 c.setRgb(c0, c1, c2);
979 vtkFloatingPointType edgecolor[3];
980 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
981 c0 = int (edgecolor[0] * 255);
982 c1 = int (edgecolor[1] * 255);
983 c2 = int (edgecolor[2] * 255);
984 e.setRgb(c0, c1, c2);
986 vtkFloatingPointType backfacecolor[3];
987 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
988 c0 = int (backfacecolor[0] * 255);
989 c1 = int (backfacecolor[1] * 255);
990 c2 = int (backfacecolor[2] * 255);
991 b.setRgb(c0, c1, c2);
993 vtkFloatingPointType nodecolor[3];
994 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
995 c0 = int (nodecolor[0] * 255);
996 c1 = int (nodecolor[1] * 255);
997 c2 = int (nodecolor[2] * 255);
998 n.setRgb(c0, c1, c2);
1000 vtkFloatingPointType color0D[3];
1001 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1002 c0 = int (color0D[0] * 255);
1003 c1 = int (color0D[1] * 255);
1004 c2 = int (color0D[2] * 255);
1005 c0D.setRgb(c0, c1, c2);
1007 size0D = (int)anActor->Get0DSize();
1010 Edgewidth = (int)anActor->GetLineWidth();
1013 Shrink = anActor->GetShrinkFactor();
1015 vtkFloatingPointType faces_orientation_color[3];
1016 anActor->GetFacesOrientationColor(faces_orientation_color);
1017 c0 = int (faces_orientation_color[0] * 255);
1018 c1 = int (faces_orientation_color[1] * 255);
1019 c2 = int (faces_orientation_color[2] * 255);
1020 o.setRgb(c0, c1, c2);
1022 faces_orientation_scale = anActor->GetFacesOrientationScale();
1023 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1025 aMarkerTypeCurrent = anActor->GetMarkerType();
1026 aMarkerScaleCurrent = anActor->GetMarkerScale();
1027 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1029 // even if there are multiple objects in the selection,
1030 // we need only the first one to get values for the dialog
1036 SMESHGUI_Preferences_ColorDlg *aDlg =
1037 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1038 aDlg->SetColor(1, c);
1039 aDlg->SetColor(2, e);
1040 aDlg->SetColor(3, n);
1041 aDlg->SetColor(4, b);
1042 aDlg->SetColor(5, c0D);
1043 aDlg->SetColor(6, o);
1044 aDlg->SetIntValue(1, Edgewidth);
1045 aDlg->SetIntValue(2, int(Shrink*100.));
1046 aDlg->SetIntValue(3, size0D);
1047 aDlg->SetDoubleValue(1, faces_orientation_scale);
1048 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1050 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1052 if( aMarkerTypeCurrent != VTK::MT_USER )
1053 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1055 aDlg->setCustomMarker( aMarkerTextureCurrent );
1058 QColor color = aDlg->GetColor(1);
1059 QColor edgecolor = aDlg->GetColor(2);
1060 QColor nodecolor = aDlg->GetColor(3);
1061 QColor backfacecolor = aDlg->GetColor(4);
1062 QColor color0D = aDlg->GetColor(5);
1063 QColor faces_orientation_color = aDlg->GetColor(6);
1066 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1068 SALOME_ListIteratorOfListIO It( selected );
1069 for( ; It.More(); It.Next()){
1070 Handle(SALOME_InteractiveObject) IObject = It.Value();
1071 if(IObject->hasEntry()){
1072 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1073 /* actor color and backface color */
1074 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1075 vtkFloatingPointType (color.green()) / 255.,
1076 vtkFloatingPointType (color.blue()) / 255.);
1077 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1078 vtkFloatingPointType (backfacecolor.green()) / 255.,
1079 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1082 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1083 vtkFloatingPointType (edgecolor.green()) / 255.,
1084 vtkFloatingPointType (edgecolor.blue()) / 255.);
1086 /* Shrink factor and size edges */
1087 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1088 anActor->SetLineWidth(aDlg->GetIntValue(1));
1090 /* Nodes color and size */
1091 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1092 vtkFloatingPointType (nodecolor.green()) / 255.,
1093 vtkFloatingPointType (nodecolor.blue()) / 255.);
1096 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1097 vtkFloatingPointType (color0D.green()) / 255.,
1098 vtkFloatingPointType (color0D.blue()) / 255.);
1099 anActor->Set0DSize(aDlg->GetIntValue(3));
1101 /* Faces orientation */
1102 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1103 vtkFloatingPointType(faces_orientation_color.greenF()),
1104 vtkFloatingPointType(faces_orientation_color.blueF())};
1105 anActor->SetFacesOrientationColor(c);
1106 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1107 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1109 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1110 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1111 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1112 if( aMarkerTypeNew != VTK::MT_USER )
1113 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1115 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1116 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1117 if( anIter != aMarkerMap.end() )
1118 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1121 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1122 if( !aGroupObject->_is_nil() )
1124 SMESH::ElementType anElementType = aGroupObject->GetType();
1126 switch( anElementType )
1128 case SMESH::NODE: aColor = nodecolor; break;
1129 case SMESH::EDGE: aColor = edgecolor; break;
1130 default: aColor = color; break;
1133 SALOMEDS::Color aGroupColor;
1134 aGroupColor.R = (float)aColor.red() / 255.0;
1135 aGroupColor.G = (float)aColor.green() / 255.0;
1136 aGroupColor.B = (float)aColor.blue() / 255.0;
1137 aGroupObject->SetColor( aGroupColor );
1142 SMESH::RepaintCurrentView();
1148 SALOME_ListIteratorOfListIO It( selected );
1149 for( ; It.More(); It.Next()){
1150 Handle(SALOME_InteractiveObject) IObject = It.Value();
1151 if(IObject->hasEntry()){
1152 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1153 switch(theCommandID){
1155 anActor->SetRepresentation(SMESH_Actor::eEdge);
1158 anActor->SetRepresentation(SMESH_Actor::eSurface);
1161 if(anActor->IsShrunk())
1162 anActor->UnShrink();
1164 anActor->SetShrink();
1167 anActor->SetRepresentation(SMESH_Actor::ePoint);
1170 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1171 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1174 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1175 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1181 SMESH::RepaintCurrentView();
1185 void Control( int theCommandID )
1187 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1188 SALOME_ListIO selected;
1190 aSel->selectedObjects( selected );
1192 if( !selected.IsEmpty() ){
1193 Handle(SALOME_InteractiveObject) anIO = selected.First();
1195 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1196 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1197 switch ( theCommandID ){
1199 aControl = SMESH_Actor::eLength;
1202 aControl = SMESH_Actor::eLength2D;
1205 aControl = SMESH_Actor::eFreeEdges;
1208 aControl = SMESH_Actor::eFreeBorders;
1211 aControl = SMESH_Actor::eMultiConnection;
1214 aControl = SMESH_Actor::eFreeNodes;
1217 aControl = SMESH_Actor::eMultiConnection2D;
1220 aControl = SMESH_Actor::eArea;
1223 aControl = SMESH_Actor::eTaper;
1226 aControl = SMESH_Actor::eAspectRatio;
1229 aControl = SMESH_Actor::eAspectRatio3D;
1232 aControl = SMESH_Actor::eMinimumAngle;
1235 aControl = SMESH_Actor::eWarping;
1238 aControl = SMESH_Actor::eSkew;
1241 aControl = SMESH_Actor::eVolume3D;
1244 aControl = SMESH_Actor::eFreeFaces;
1247 aControl = SMESH_Actor::eMaxElementLength2D;
1250 aControl = SMESH_Actor::eMaxElementLength3D;
1253 aControl = SMESH_Actor::eBareBorderVolume;
1256 aControl = SMESH_Actor::eBareBorderFace;
1259 aControl = SMESH_Actor::eOverConstrainedVolume;
1262 aControl = SMESH_Actor::eOverConstrainedFace;
1265 anActor->SetControlMode(aControl);
1266 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1267 SMESH::RepaintCurrentView();
1268 #ifndef DISABLE_PLOT2DVIEWER
1269 if(anActor->GetPlot2Histogram()) {
1270 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1271 QString functorName = functorToString( anActor->GetFunctor());
1272 QString aHistogramName("%1 : %2");
1273 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1274 aHistogram->setName(aHistogramName);
1275 aHistogram->setHorTitle(functorName);
1276 SMESH::ProcessIn2DViewers(anActor);
1285 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1286 MeshObjectType theType,
1287 const QString theInTypeName,
1288 QString & theOutTypeName)
1290 SMESH_TypeFilter aTypeFilter( theType );
1292 if( !theIO.IsNull() )
1294 entry = theIO->getEntry();
1295 LightApp_DataOwner owner( entry );
1296 if ( aTypeFilter.isOk( &owner )) {
1297 theOutTypeName = theInTypeName;
1305 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1307 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1308 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1310 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1311 CORBA::String_var anID = aSComp->GetID().c_str();
1312 if (!strcmp(anID.in(),theIO->getEntry()))
1318 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1319 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1320 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1321 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1322 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1330 QString CheckHomogeneousSelection()
1332 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1333 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1334 SALOME_ListIO selected;
1336 aSel->selectedObjects( selected );
1338 QString RefType = CheckTypeObject(selected.First());
1339 SALOME_ListIteratorOfListIO It(selected);
1340 for ( ; It.More(); It.Next())
1342 Handle(SALOME_InteractiveObject) IObject = It.Value();
1343 QString Type = CheckTypeObject(IObject);
1344 if (Type.compare(RefType) != 0)
1345 return "Heterogeneous Selection";
1352 void SMESHGUI::OnEditDelete()
1354 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1355 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1356 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1358 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1359 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1360 _PTR(GenericAttribute) anAttr;
1361 _PTR(AttributeIOR) anIOR;
1363 int objectCount = 0;
1365 QString aParentComponent = QString::null;
1366 Handle(SALOME_InteractiveObject) anIO;
1367 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1369 anIO = anIt.Value();
1370 QString cur = anIO->getComponentDataType();
1371 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1373 // check if object is reference
1374 _PTR(SObject) aRefSObj;
1375 aNameList.append("\n - ");
1376 if ( aSO->ReferencedObject( aRefSObj ) ) {
1377 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1378 aNameList.append( aRefName );
1379 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1382 aNameList.append(anIO->getName());
1386 if( aParentComponent.isNull() )
1387 aParentComponent = cur;
1388 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1389 aParentComponent = "";
1392 if ( objectCount == 0 )
1393 return; // No Valid Objects Selected
1395 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1396 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1397 QObject::tr("ERR_ERROR"),
1398 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1401 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1402 if (SUIT_MessageBox::warning
1403 (SMESHGUI::desktop(),
1404 QObject::tr("SMESH_WRN_WARNING"),
1405 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1406 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1407 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1410 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1412 ViewManagerList aViewMenegers = anApp->viewManagers();
1413 ViewManagerList::const_iterator it = aViewMenegers.begin();
1414 for( ; it != aViewMenegers.end(); it++) {
1416 SUIT_ViewManager* vm = *it;
1417 int nbSf = vm ? vm->getViewsCount() : 0;
1419 SALOME_ListIteratorOfListIO It(selected);
1421 aStudyBuilder->NewCommand(); // There is a transaction
1422 for( ; It.More(); It.Next()){ // loop on selected IO's
1423 Handle(SALOME_InteractiveObject) IObject = It.Value();
1424 if(IObject->hasEntry()) {
1425 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1427 // disable removal of "SMESH" component object
1428 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1430 if ( engineIOR() == anIOR->Value().c_str() )
1433 //Check the referenced object
1434 _PTR(SObject) aRefSObject;
1435 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1436 aSO = aRefSObject; // Delete main Object instead of reference
1438 // put the whole hierarchy of sub-objects of the selected SO into a list and
1439 // then treat them all starting from the deepest objects (at list back)
1441 std::list< _PTR(SObject) > listSO;
1442 listSO.push_back( aSO );
1443 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1444 for ( ; itSO != listSO.end(); ++itSO ) {
1445 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1446 for (it->InitEx(false); it->More(); it->Next())
1447 listSO.push_back( it->Value() );
1450 // treat SO's in the list starting from the back
1452 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1453 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1454 _PTR(SObject) SO = *ritSO;
1455 if ( !SO ) continue;
1456 std::string anEntry = SO->GetID();
1458 /** Erase graphical object **/
1459 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1460 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1461 for(int i = 0; i < nbSf; i++){
1462 SUIT_ViewWindow *sf = aViews[i];
1463 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1464 SMESH::RemoveActor(sf,anActor);
1469 /** Remove an object from data structures **/
1470 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1471 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1472 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1473 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1474 aMesh->RemoveGroup( aGroup );
1476 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1477 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1478 aMesh->RemoveSubMesh( aSubMesh );
1480 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1482 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1485 IObject = new SALOME_InteractiveObject
1486 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1487 QString objType = CheckTypeObject(IObject);
1488 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1489 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1490 aStudyBuilder->RemoveObjectWithChildren( SO );
1492 else {// default action: remove SObject from the study
1493 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1494 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1496 aStudyBuilder->RemoveObjectWithChildren( SO );
1500 } /* listSO back loop */
1501 } /* IObject->hasEntry() */
1503 } /* aViewMenegers list loop */
1505 aStudyBuilder->CommitCommand();
1507 /* Clear any previous selection */
1509 aSel->setSelectedObjects( l1 );
1511 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1516 SMESHGUI_EXPORT CAM_Module* createModule()
1518 return new SMESHGUI();
1522 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1524 //=============================================================================
1528 //=============================================================================
1529 SMESHGUI::SMESHGUI() :
1530 SalomeApp_Module( "SMESH" ),
1531 LightApp_Module( "SMESH" )
1533 if ( CORBA::is_nil( myComponentSMESH ) )
1535 CORBA::Boolean anIsEmbeddedMode;
1536 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1537 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1539 // 0019923: EDF 765 SMESH : default values of hypothesis
1540 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1541 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1542 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1543 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1544 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1547 myActiveDialogBox = 0;
1548 myFilterLibraryDlg = 0;
1552 myEventCallbackCommand = vtkCallbackCommand::New();
1553 myEventCallbackCommand->Delete();
1554 myEventCallbackCommand->SetClientData( this );
1555 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1558 SMESH::GetFilterManager();
1559 SMESH::GetPattern();
1560 SMESH::GetMeasurements();
1562 /* load resources for all available meshers */
1563 SMESH::InitAvailableHypotheses();
1566 //=============================================================================
1570 //=============================================================================
1571 SMESHGUI::~SMESHGUI()
1573 #ifdef WITHGENERICOBJ
1574 SMESH::GetFilterManager()->Destroy();
1575 SMESH::GetMeasurements()->Destroy();
1577 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1578 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1581 //=============================================================================
1585 //=============================================================================
1586 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1588 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1590 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1595 //=============================================================================
1599 //=============================================================================
1600 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1602 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1606 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1607 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1608 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1609 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1610 return autoUpdate && !exceeded;
1613 //=============================================================================
1617 //=============================================================================
1618 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1620 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1623 //=============================================================================
1627 //=============================================================================
1628 SMESHGUI* SMESHGUI::GetSMESHGUI()
1630 SMESHGUI* smeshMod = 0;
1631 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1634 CAM_Module* module = app->module( "Mesh" );
1635 smeshMod = dynamic_cast<SMESHGUI*>( module );
1638 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1640 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1643 _PTR(Study) aStudy = study->studyDS();
1645 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1654 Standard_EXPORT SMESHGUI* GetComponentGUI()
1656 return SMESHGUI::GetSMESHGUI();
1660 //=============================================================================
1664 //=============================================================================
1665 void SMESHGUI::SetState(int aState)
1670 //=============================================================================
1674 //=============================================================================
1675 void SMESHGUI::ResetState()
1680 //=============================================================================
1684 //=============================================================================
1685 void SMESHGUI::EmitSignalDeactivateDialog()
1687 emit SignalDeactivateActiveDialog();
1690 //=============================================================================
1694 //=============================================================================
1695 void SMESHGUI::EmitSignalStudyFrameChanged()
1697 emit SignalStudyFrameChanged();
1700 //=============================================================================
1704 //=============================================================================
1705 void SMESHGUI::EmitSignalCloseAllDialogs()
1707 emit SignalCloseAllDialogs();
1710 //=============================================================================
1714 //=============================================================================
1715 void SMESHGUI::EmitSignalVisibilityChanged()
1717 emit SignalVisibilityChanged();
1720 //=============================================================================
1724 //=============================================================================
1725 QDialog *SMESHGUI::GetActiveDialogBox()
1727 return myActiveDialogBox;
1730 //=============================================================================
1734 //=============================================================================
1735 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1737 myActiveDialogBox = (QDialog *) aDlg;
1741 //=============================================================================
1745 //=============================================================================
1746 SUIT_Desktop* SMESHGUI::desktop()
1748 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1750 return app->desktop();
1755 //=============================================================================
1759 //=============================================================================
1760 SalomeApp_Study* SMESHGUI::activeStudy()
1762 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1764 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1769 //=============================================================================
1773 //=============================================================================
1774 void SMESHGUI::Modified( bool theIsUpdateActions )
1776 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1777 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1778 appStudy->Modified();
1779 if( theIsUpdateActions )
1780 app->updateActions();
1785 //=============================================================================
1789 //=============================================================================
1790 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1792 /* Here the position is on the bottom right corner - 10 */
1793 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1795 SUIT_Desktop *PP = desktop();
1796 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1797 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1801 //=============================================================================
1805 //=============================================================================
1806 static int isStudyLocked(_PTR(Study) theStudy){
1807 return theStudy->GetProperties()->IsLocked();
1810 static bool checkLock(_PTR(Study) theStudy) {
1811 if (isStudyLocked(theStudy)) {
1812 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1813 QObject::tr("WRN_WARNING"),
1814 QObject::tr("WRN_STUDY_LOCKED") );
1820 //=======================================================================
1821 //function : CheckActiveStudyLocked
1823 //=======================================================================
1825 bool SMESHGUI::isActiveStudyLocked()
1827 _PTR(Study) aStudy = activeStudy()->studyDS();
1828 return checkLock( aStudy );
1831 //=============================================================================
1835 //=============================================================================
1836 bool SMESHGUI::OnGUIEvent( int theCommandID )
1838 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1842 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1843 SUIT_ResourceMgr* mgr = resourceMgr();
1847 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1848 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1851 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1852 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1854 //QAction* act = action( theCommandID );
1856 switch (theCommandID) {
1858 if(checkLock(aStudy)) break;
1866 if(checkLock(aStudy)) break;
1867 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1871 case 150: //MED FILE INFORMATION
1873 SALOME_ListIO selected;
1874 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1876 aSel->selectedObjects( selected );
1877 if( selected.Extent() )
1879 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1880 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1881 if ( !aMesh->_is_nil() )
1883 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1890 case 122: // EXPORT MED
1899 ::ExportMeshToFile(theCommandID);
1903 case 200: // SCALAR BAR
1905 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1906 SALOME_ListIO selected;
1908 aSel->selectedObjects( selected );
1910 if( selected.Extent() ) {
1911 Handle(SALOME_InteractiveObject) anIO = selected.First();
1912 if( anIO->hasEntry() ) {
1913 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1914 anActor->SetControlMode( SMESH_Actor::eNone );
1915 #ifndef DISABLE_PLOT2DVIEWER
1916 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
1925 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1930 // dump control distribution data to the text file
1931 ::SaveDistribution();
1937 // show/ distribution
1938 ::ShowDistribution();
1942 #ifndef DISABLE_PLOT2DVIEWER
1945 // plot distribution
1946 ::PlotDistribution();
1957 ::DisableAutoColor();
1960 case 1134: // Clipping
1961 case 1133: // Tranparency
1962 case 1132: // Colors / Size
1969 ::SetDisplayMode(theCommandID, myMarkerMap);
1972 //2D quadratic representation
1975 ::SetDisplayMode(theCommandID, myMarkerMap);
1979 case 216: // 0D elements
1982 case 219: // Volumes
1983 case 220: // All Entity
1984 ::SetDisplayEntity(theCommandID);
1987 case 221: // Orientation of faces
1989 LightApp_SelectionMgr* mgr = selectionMgr();
1990 SALOME_ListIO selected; mgr->selectedObjects( selected );
1992 SALOME_ListIteratorOfListIO it(selected);
1993 for( ; it.More(); it.Next()) {
1994 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1995 if(anIObject->hasEntry()) {
1996 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1997 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2006 if(checkLock(aStudy)) break;
2008 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2011 SMESH::UpdateView();
2013 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2014 SMESH::OnVisuException();
2016 catch (...) { // PAL16774 (Crash after display of many groups)
2017 SMESH::OnVisuException();
2021 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2022 aSel->selectedObjects( l );
2023 aSel->setSelectedObjects( l );
2028 case 301: // DISPLAY
2029 case 302: // DISPLAY ONLY
2031 SMESH::EDisplaing anAction;
2032 switch (theCommandID) {
2033 case 300: anAction = SMESH::eErase; break;
2034 case 301: anAction = SMESH::eDisplay; break;
2035 case 302: anAction = SMESH::eDisplayOnly; break;
2038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2039 SALOME_ListIO sel_objects, to_process;
2041 aSel->selectedObjects( sel_objects );
2043 if( theCommandID==302 )
2045 MESSAGE("anAction = SMESH::eDisplayOnly");
2046 startOperation( myEraseAll );
2049 extractContainers( sel_objects, to_process );
2052 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2056 SALOME_ListIteratorOfListIO It( to_process );
2057 for ( ; It.More(); It.Next()) {
2059 Handle(SALOME_InteractiveObject) IOS = It.Value();
2060 if (IOS->hasEntry()) {
2062 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2063 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2064 break; // PAL16774 (Crash after display of many groups)
2066 if (anAction == SMESH::eDisplayOnly)
2068 MESSAGE("anAction = SMESH::eDisplayOnly");
2069 anAction = SMESH::eDisplay;
2075 // PAL13338 + PAL15161 -->
2076 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2077 MESSAGE("anAction = SMESH::eDisplayOnly");
2078 SMESH::UpdateView();
2079 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2081 // PAL13338 + PAL15161 <--
2083 catch (...) { // PAL16774 (Crash after display of many groups)
2084 SMESH::OnVisuException();
2087 if (anAction == SMESH::eErase) {
2088 MESSAGE("anAction == SMESH::eErase");
2090 aSel->setSelectedObjects( l1 );
2093 aSel->setSelectedObjects( to_process );
2100 if(checkLock(aStudy)) break;
2103 EmitSignalDeactivateDialog();
2105 ( new SMESHGUI_NodesDlg( this ) )->show();
2108 SUIT_MessageBox::warning(desktop(),
2109 tr("SMESH_WRN_WARNING"),
2110 tr("SMESH_WRN_VIEWER_VTK"));
2115 case 2151: // FILTER
2119 EmitSignalDeactivateDialog();
2120 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2125 case 701: // COMPUTE MESH
2126 case 711: // PRECOMPUTE MESH
2127 case 712: // EVALUATE MESH
2128 case 713: // MESH ORDER
2130 if (checkLock(aStudy)) break;
2131 startOperation( theCommandID );
2135 case 702: // Create mesh
2136 case 703: // Create sub-mesh
2137 case 704: // Edit mesh/sub-mesh
2138 startOperation( theCommandID );
2140 case 705: // copy mesh
2142 if (checkLock(aStudy)) break;
2143 EmitSignalDeactivateDialog();
2144 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2147 case 710: // Build compound mesh
2149 if (checkLock(aStudy)) break;
2150 EmitSignalDeactivateDialog();
2151 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2155 case 407: // DIAGONAL INVERSION
2156 case 408: // Delete diagonal
2160 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2161 tr( "NOT_A_VTK_VIEWER" ) );
2165 if ( checkLock( aStudy ) )
2168 /*Standard_Boolean aRes;
2169 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2170 if ( aMesh->_is_nil() )
2172 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2173 tr( "SMESH_BAD_SELECTION" ) );
2177 EmitSignalDeactivateDialog();
2178 if ( theCommandID == 407 )
2179 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2181 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2184 case 409: // Change orientation
2185 case 410: // Union of triangles
2186 case 411: // Cutting of quadrangles
2187 case 419: // Splitting volumes into tetrahedra
2191 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2192 tr( "NOT_A_VTK_VIEWER" ) );
2196 if ( checkLock( aStudy ) )
2199 EmitSignalDeactivateDialog();
2200 SMESHGUI_MultiEditDlg* aDlg = NULL;
2201 if ( theCommandID == 409 )
2202 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2203 else if ( theCommandID == 410 )
2204 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2205 else if ( theCommandID == 419 )
2206 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2208 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2213 case 412: // Smoothing
2215 if(checkLock(aStudy)) break;
2217 EmitSignalDeactivateDialog();
2218 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2221 SUIT_MessageBox::warning(desktop(),
2222 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2226 case 413: // Extrusion
2228 if (checkLock(aStudy)) break;
2230 EmitSignalDeactivateDialog();
2231 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2233 SUIT_MessageBox::warning(desktop(),
2234 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2238 case 414: // Revolution
2240 if(checkLock(aStudy)) break;
2242 EmitSignalDeactivateDialog();
2243 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2246 SUIT_MessageBox::warning(desktop(),
2247 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2251 case 415: // Pattern mapping
2253 if ( checkLock( aStudy ) )
2257 EmitSignalDeactivateDialog();
2258 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2261 SUIT_MessageBox::warning(desktop(),
2262 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2266 case 416: // Extrusion along a path
2268 if (checkLock(aStudy)) break;
2270 EmitSignalDeactivateDialog();
2271 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2273 SUIT_MessageBox::warning(desktop(),
2274 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2278 case 417: // Convert mesh to quadratic
2280 startOperation( 417 );
2281 /* if (checkLock(aStudy)) break;
2283 EmitSignalDeactivateDialog();
2284 new SMESHGUI_ConvToQuadDlg();
2286 SUIT_MessageBox::warning(desktop(),
2287 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2291 case 418: // create 2D mesh from 3D
2293 startOperation( 418 );
2296 case 806: // CREATE GEO GROUP
2298 startOperation( 806 );
2301 case 801: // CREATE GROUP
2305 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2306 tr( "NOT_A_VTK_VIEWER" ) );
2310 if(checkLock(aStudy)) break;
2311 EmitSignalDeactivateDialog();
2312 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2314 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2315 SALOME_ListIO selected;
2317 aSel->selectedObjects( selected );
2319 int nbSel = selected.Extent();
2321 // check if mesh is selected
2322 aMesh = SMESH::GetMeshByIO( selected.First() );
2324 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2329 case 802: // CONSTRUCT GROUP
2333 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2334 tr( "NOT_A_VTK_VIEWER" ) );
2338 if(checkLock(aStudy)) break;
2339 EmitSignalDeactivateDialog();
2341 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2342 SALOME_ListIO selected;
2344 aSel->selectedObjects( selected );
2346 int nbSel = selected.Extent();
2348 // check if submesh is selected
2349 Handle(SALOME_InteractiveObject) IObject = selected.First();
2350 if (IObject->hasEntry()) {
2351 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2353 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2354 if (!aSubMesh->_is_nil()) {
2356 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2357 // get submesh elements list by types
2358 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2359 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2360 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2361 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2362 // create group for each type o elements
2363 QString aName = IObject->getName();
2364 if (aNodes->length() > 0) {
2365 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2366 aGroup->Add(aNodes.inout());
2368 if (aEdges->length() > 0) {
2369 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2370 aGroup->Add(aEdges.inout());
2372 if (aFaces->length() > 0) {
2373 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2374 aGroup->Add(aFaces.inout());
2376 if (aVolumes->length() > 0) {
2377 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2378 aGroup->Add(aVolumes.inout());
2383 catch(const SALOME::SALOME_Exception & S_ex){
2384 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2391 SUIT_MessageBox::warning(desktop(),
2392 tr("SMESH_WRN_WARNING"),
2393 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2398 case 803: // EDIT GROUP
2402 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2403 tr( "NOT_A_VTK_VIEWER" ) );
2407 if(checkLock(aStudy)) break;
2408 EmitSignalDeactivateDialog();
2410 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2411 SALOME_ListIO selected;
2413 aSel->selectedObjects( selected );
2415 SALOME_ListIteratorOfListIO It (selected);
2416 int nbSelectedGroups = 0;
2417 for ( ; It.More(); It.Next() )
2419 SMESH::SMESH_GroupBase_var aGroup =
2420 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2421 if (!aGroup->_is_nil()) {
2423 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2427 if (nbSelectedGroups == 0)
2429 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2435 case 804: // Add elements to group
2437 if(checkLock(aStudy)) break;
2438 if (myState == 800) {
2439 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2440 if (aDlg) aDlg->onAdd();
2445 case 805: // Remove elements from group
2447 if(checkLock(aStudy)) break;
2448 if (myState == 800) {
2449 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2450 if (aDlg) aDlg->onRemove();
2455 case 815: // Edit GEOM GROUP as standalone
2459 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2460 tr( "NOT_A_VTK_VIEWER" ) );
2464 if(checkLock(aStudy)) break;
2465 EmitSignalDeactivateDialog();
2467 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2468 SALOME_ListIO selected;
2470 aSel->selectedObjects( selected );
2472 SALOME_ListIteratorOfListIO It (selected);
2473 for ( ; It.More(); It.Next() )
2475 SMESH::SMESH_GroupOnGeom_var aGroup =
2476 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2477 if (!aGroup->_is_nil()) {
2478 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2485 case 810: // Union Groups
2486 case 811: // Intersect groups
2487 case 812: // Cut groups
2491 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2492 tr( "NOT_A_VTK_VIEWER" ) );
2496 if ( checkLock( aStudy ) )
2499 EmitSignalDeactivateDialog();
2501 SMESHGUI_GroupOpDlg* aDlg = 0;
2502 if ( theCommandID == 810 )
2503 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2504 else if ( theCommandID == 811 )
2505 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2507 aDlg = new SMESHGUI_CutGroupsDlg( this );
2514 case 814: // Create groups of entities from existing groups of superior dimensions
2516 if ( checkLock( aStudy ) )
2519 EmitSignalDeactivateDialog();
2520 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2526 case 813: // Delete groups with their contents
2530 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2531 tr( "NOT_A_VTK_VIEWER" ) );
2535 if ( checkLock( aStudy ) )
2538 EmitSignalDeactivateDialog();
2540 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2544 case 900: // MESH INFOS
2545 case 903: // WHAT IS
2547 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2548 EmitSignalDeactivateDialog();
2549 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2550 SALOME_ListIO selected;
2552 aSel->selectedObjects( selected );
2554 if ( selected.Extent() > 1 ) { // a dlg for each IO
2555 SALOME_ListIteratorOfListIO It( selected );
2556 for ( ; It.More(); It.Next() ) {
2557 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2558 dlg->showInfo( It.Value() );
2563 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2569 case 902: // STANDARD MESH INFOS
2571 EmitSignalDeactivateDialog();
2572 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2573 SALOME_ListIO selected;
2575 aSel->selectedObjects( selected );
2577 if ( selected.Extent() > 1 ) { // a dlg for each IO
2579 SALOME_ListIteratorOfListIO It (selected);
2580 for ( ; It.More(); It.Next() ) {
2582 IOs.Append( It.Value() );
2583 aSel->setSelectedObjects( IOs );
2584 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2586 // restore selection
2587 aSel->setSelectedObjects( selected );
2590 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2593 case 903: // WHAT IS
2595 EmitSignalDeactivateDialog();
2596 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2601 case 904: // FIND ELEM
2603 startOperation( theCommandID );
2607 case 1100: // EDIT HYPOTHESIS
2609 if(checkLock(aStudy)) break;
2611 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2612 SALOME_ListIO selected;
2614 aSel->selectedObjects( selected );
2616 int nbSel = selected.Extent();
2619 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2620 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2622 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2623 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2624 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2625 if ( !aHypothesis->_is_nil() )
2628 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2629 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2631 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2642 case 1101: // RENAME
2644 if ( checkLock( aStudy ) )
2647 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2648 SALOME_ListIO selected;
2650 aSel->selectedObjects( selected );
2652 bool isAny = false; // is there any appropriate object selected
2654 SALOME_ListIteratorOfListIO It( selected );
2655 for ( ; It.More(); It.Next() )
2657 Handle(SALOME_InteractiveObject) IObject = It.Value();
2658 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2659 _PTR(GenericAttribute) anAttr;
2660 _PTR(AttributeName) aName;
2663 if ( obj->FindAttribute(anAttr, "AttributeName") )
2666 QString newName = QString(aName->Value().c_str());
2668 // check type to prevent renaming of inappropriate objects
2669 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2670 if (aType == MESH || aType == GROUP ||
2671 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2672 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2673 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2674 aType == HYPOTHESIS || aType == ALGORITHM)
2677 newName = LightApp_NameDlg::getName(desktop(), newName);
2678 if ( !newName.isEmpty() )
2680 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2682 // update name of group object and its actor
2683 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2684 if( !aGroupObject->_is_nil() )
2686 aGroupObject->SetName( newName.toLatin1().data() );
2687 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2688 anActor->setName( newName.toLatin1().data() );
2699 SUIT_MessageBox::warning(desktop(),
2700 QObject::tr("SMESH_WRN_WARNING"),
2701 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2706 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2708 if(checkLock(aStudy)) break;
2709 SUIT_OverrideCursor wc;
2711 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2712 SALOME_ListIO selected;
2714 aSel->selectedObjects( selected, QString::null, false );
2716 SALOME_ListIteratorOfListIO It(selected);
2717 for (int i = 0; It.More(); It.Next(), i++) {
2718 Handle(SALOME_InteractiveObject) IObject = It.Value();
2719 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2722 aSel->setSelectedObjects( l1 );
2727 case 4009: // ELEM0D
2728 case 4010: // GEOM::EDGE
2729 case 4021: // TRIANGLE
2731 case 4023: // POLYGON
2735 if(checkLock(aStudy)) break;
2737 EmitSignalDeactivateDialog();
2738 SMDSAbs_ElementType type = SMDSAbs_Edge;
2740 switch (theCommandID) {
2741 case 4009: // ELEM0D
2742 type = SMDSAbs_0DElement; nbNodes = 1; break;
2743 case 4021: // TRIANGLE
2744 type = SMDSAbs_Face; nbNodes = 3; break;
2746 type = SMDSAbs_Face; nbNodes = 4; break;
2748 type = SMDSAbs_Volume; nbNodes = 4; break;
2749 case 4023: // POLYGON
2750 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2752 type = SMDSAbs_Volume; nbNodes = 8; break;
2753 case 4033: // POLYHEDRE
2754 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2757 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2760 SUIT_MessageBox::warning(desktop(),
2761 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2765 case 4033: // POLYHEDRON
2767 if(checkLock(aStudy)) break;
2769 EmitSignalDeactivateDialog();
2770 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2773 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2774 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2778 case 4034: // QUADRATIC EDGE
2779 case 4035: // QUADRATIC TRIANGLE
2780 case 4036: // QUADRATIC QUADRANGLE
2781 case 4037: // QUADRATIC TETRAHEDRON
2782 case 4038: // QUADRATIC PYRAMID
2783 case 4039: // QUADRATIC PENTAHEDRON
2784 case 4040: // QUADRATIC HEXAHEDRON
2786 if(checkLock(aStudy)) break;
2788 EmitSignalDeactivateDialog();
2791 switch (theCommandID) {
2793 type = QUAD_EDGE; break;
2795 type = QUAD_TRIANGLE; break;
2797 type = QUAD_QUADRANGLE; break;
2799 type = QUAD_TETRAHEDRON; break;
2801 type = QUAD_PYRAMID; break;
2803 type = QUAD_PENTAHEDRON; break;
2805 type = QUAD_HEXAHEDRON;
2809 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2812 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2813 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2817 case 4041: // REMOVES NODES
2819 if(checkLock(aStudy)) break;
2821 EmitSignalDeactivateDialog();
2822 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2825 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2826 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2830 case 4042: // REMOVES ELEMENTS
2832 if(checkLock(aStudy)) break;
2834 EmitSignalDeactivateDialog();
2835 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2839 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2840 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2844 case 4043: { // CLEAR_MESH
2846 if(checkLock(aStudy)) break;
2848 SALOME_ListIO selected;
2849 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2850 aSel->selectedObjects( selected );
2852 SUIT_OverrideCursor wc;
2853 SALOME_ListIteratorOfListIO It (selected);
2854 for ( ; It.More(); It.Next() )
2856 Handle(SALOME_InteractiveObject) IOS = It.Value();
2857 SMESH::SMESH_Mesh_var aMesh =
2858 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2859 if ( aMesh->_is_nil()) continue;
2861 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2863 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2864 SMESH::ModifiedMesh( aMeshSObj, false, true);
2865 // hide groups and submeshes
2866 _PTR(ChildIterator) anIter =
2867 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2868 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2870 _PTR(SObject) so = anIter->Value();
2871 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2874 catch (const SALOME::SALOME_Exception& S_ex){
2876 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2880 SMESH::UpdateView();
2884 case 4044: // REMOVE ORPHAN NODES
2886 if(checkLock(aStudy)) break;
2887 SALOME_ListIO selected;
2888 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2889 aSel->selectedObjects( selected );
2890 if ( selected.Extent() == 1 ) {
2891 Handle(SALOME_InteractiveObject) anIO = selected.First();
2892 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2893 if ( !aMesh->_is_nil() ) {
2894 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2895 tr( "SMESH_WARNING" ),
2896 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2897 SUIT_MessageBox::Yes |
2898 SUIT_MessageBox::No,
2899 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2902 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2903 int removed = aMeshEditor->RemoveOrphanNodes();
2904 SUIT_MessageBox::information(SMESHGUI::desktop(),
2905 tr("SMESH_INFORMATION"),
2906 tr("NB_NODES_REMOVED").arg(removed));
2907 if ( removed > 0 ) {
2908 SMESH::UpdateView();
2909 SMESHGUI::Modified();
2912 catch (const SALOME::SALOME_Exception& S_ex) {
2913 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2922 case 4051: // RENUMBERING NODES
2924 if(checkLock(aStudy)) break;
2926 EmitSignalDeactivateDialog();
2927 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2931 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2932 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2936 case 4052: // RENUMBERING ELEMENTS
2938 if(checkLock(aStudy)) break;
2940 EmitSignalDeactivateDialog();
2941 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2945 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2946 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2950 case 4061: // TRANSLATION
2952 if(checkLock(aStudy)) break;
2954 EmitSignalDeactivateDialog();
2955 ( new SMESHGUI_TranslationDlg( this ) )->show();
2958 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2959 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2963 case 4062: // ROTATION
2965 if(checkLock(aStudy)) break;
2967 EmitSignalDeactivateDialog();
2968 ( new SMESHGUI_RotationDlg( this ) )->show();
2971 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2972 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2976 case 4063: // SYMMETRY
2978 if(checkLock(aStudy)) break;
2980 EmitSignalDeactivateDialog();
2981 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2984 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2985 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2989 case 4064: // SEWING
2991 if(checkLock(aStudy)) break;
2993 EmitSignalDeactivateDialog();
2994 ( new SMESHGUI_SewingDlg( this ) )->show();
2997 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3002 case 4065: // MERGE NODES
3004 if(checkLock(aStudy)) break;
3006 EmitSignalDeactivateDialog();
3007 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3010 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3011 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3015 case 4066: // MERGE EQUAL ELEMENTS
3017 if (checkLock(aStudy)) break;
3019 EmitSignalDeactivateDialog();
3020 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3022 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3023 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3028 case 4067: // MAKE MESH PASS THROUGH POINT
3029 startOperation( 4067 );
3034 if(checkLock(aStudy)) break;
3036 EmitSignalDeactivateDialog();
3037 ( new SMESHGUI_ScaleDlg( this ) )->show();
3040 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3041 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3046 case 4069: // DUPLICATE NODES
3048 if(checkLock(aStudy)) break;
3050 EmitSignalDeactivateDialog();
3051 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3054 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3060 case 5105: // Library of selection filters
3062 static QList<int> aTypes;
3063 if ( aTypes.isEmpty() )
3065 aTypes.append( SMESH::NODE );
3066 aTypes.append( SMESH::EDGE );
3067 aTypes.append( SMESH::FACE );
3068 aTypes.append( SMESH::VOLUME );
3070 if (!myFilterLibraryDlg)
3071 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3072 else if (myFilterLibraryDlg->isHidden())
3073 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3074 myFilterLibraryDlg->raise();
3078 case 6017: // CONTROLS
3102 LightApp_SelectionMgr* mgr = selectionMgr();
3103 SALOME_ListIO selected; mgr->selectedObjects( selected );
3105 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3106 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3108 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3109 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3110 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3111 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3112 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3113 ::Control( theCommandID );
3118 SUIT_MessageBox::warning(desktop(),
3119 tr( "SMESH_WRN_WARNING" ),
3120 tr( "SMESH_BAD_SELECTION" ) );
3124 SUIT_MessageBox::warning(desktop(),
3125 tr( "SMESH_WRN_WARNING" ),
3126 tr( "NOT_A_VTK_VIEWER" ) );
3131 LightApp_SelectionMgr* mgr = selectionMgr();
3132 SALOME_ListIO selected; mgr->selectedObjects( selected );
3134 SALOME_ListIteratorOfListIO it(selected);
3135 for( ; it.More(); it.Next()) {
3136 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3137 if(anIObject->hasEntry()) {
3138 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3139 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3147 LightApp_SelectionMgr* mgr = selectionMgr();
3148 SALOME_ListIO selected; mgr->selectedObjects( selected );
3150 SALOME_ListIteratorOfListIO it(selected);
3151 for( ; it.More(); it.Next()) {
3152 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3153 if(anIObject->hasEntry())
3154 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3155 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3163 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3164 EmitSignalDeactivateDialog();
3165 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3171 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3172 //updateObjBrowser();
3176 //=============================================================================
3180 //=============================================================================
3181 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3186 //=============================================================================
3190 //=============================================================================
3191 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3196 //=============================================================================
3200 //=============================================================================
3201 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3206 //=============================================================================
3207 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3208 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3210 //=============================================================================
3211 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3212 SUIT_ViewWindow* wnd )
3214 if(theIO->hasEntry()){
3215 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3216 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3220 //=======================================================================
3221 // function : createSMESHAction
3223 //=======================================================================
3224 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3225 const int key, const bool toggle, const QString& shortcutAction )
3228 QWidget* parent = application()->desktop();
3229 SUIT_ResourceMgr* resMgr = resourceMgr();
3231 if ( !icon_id.isEmpty() )
3232 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3234 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3235 if ( !pix.isNull() )
3236 icon = QIcon( pix );
3238 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3239 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3240 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3242 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3243 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3246 //=======================================================================
3247 // function : createPopupItem
3249 //=======================================================================
3250 void SMESHGUI::createPopupItem( const int id,
3251 const QString& clients,
3252 const QString& types,
3253 const QString& theRule,
3258 parentId = popupMgr()->actionId( action( pId ) );
3260 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3261 popupMgr()->insert( action( id ), parentId, 0 );
3263 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3264 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3265 QString rule = "(%1) and (%2) and (%3)";
3266 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3267 if( clients.isEmpty() )
3268 rule = rule.arg( QString( "true" ) );
3270 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3271 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3274 bool cont = myRules.contains( id );
3276 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3278 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3279 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3282 //=======================================================================
3283 // function : initialize
3285 //=======================================================================
3286 void SMESHGUI::initialize( CAM_Application* app )
3288 SalomeApp_Module::initialize( app );
3290 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3292 /* Automatic Update flag */
3293 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3295 // ----- create actions --------------
3297 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3298 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3299 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3300 createSMESHAction( 114, "NUM" );
3301 createSMESHAction( 121, "DAT" );
3302 createSMESHAction( 122, "MED" );
3303 createSMESHAction( 123, "UNV" );
3304 createSMESHAction( 140, "STL" );
3305 createSMESHAction( 124, "EXPORT_DAT" );
3306 createSMESHAction( 125, "EXPORT_MED" );
3307 createSMESHAction( 126, "EXPORT_UNV" );
3308 createSMESHAction( 141, "EXPORT_STL" );
3309 createSMESHAction( 150, "FILE_INFO" );
3310 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3311 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3312 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3313 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3314 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3315 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3316 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3317 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3318 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3319 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3320 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3321 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3322 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3323 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3324 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3325 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3326 createSMESHAction( 804, "ADD" );
3327 createSMESHAction( 805, "REMOVE" );
3328 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3329 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3330 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3331 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3332 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3333 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3334 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3335 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3336 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3337 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3338 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3339 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3340 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3341 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3342 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3343 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3344 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3345 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3346 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3347 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3348 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3349 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3350 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3351 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3352 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3353 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3354 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3355 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3356 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3357 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3358 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3359 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3360 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3361 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3362 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3363 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3364 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3365 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3366 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3367 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3368 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3369 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3370 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3371 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3372 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3373 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3374 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3375 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3376 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3377 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3378 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3379 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3380 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3381 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3382 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3383 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3384 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3385 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3386 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3387 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3388 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3389 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3390 createSMESHAction( 415, "MAP", "ICON_MAP" );
3391 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3392 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3393 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3394 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3395 createSMESHAction( 200, "RESET" );
3396 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3397 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3398 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3399 #ifndef DISABLE_PLOT2DVIEWER
3400 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3402 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3403 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3404 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3405 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3406 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3407 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3408 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3409 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3410 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3411 createSMESHAction( 220, "ALL" );
3412 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3414 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3415 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3417 createSMESHAction( 1100, "EDIT_HYPO" );
3418 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3419 createSMESHAction( 1102, "UNASSIGN" );
3420 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3421 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3422 createSMESHAction( 1131, "DISPMODE" );
3423 createSMESHAction( 1132, "COLORS" );
3424 createSMESHAction( 1133, "TRANSP" );
3425 createSMESHAction( 1134, "CLIP" );
3426 createSMESHAction( 1135, "DISP_ENT" );
3427 createSMESHAction( 1136, "AUTO_COLOR" );
3428 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3429 createSMESHAction( 2000, "CTRL" );
3431 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3432 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3434 createSMESHAction( 300, "ERASE" );
3435 createSMESHAction( 301, "DISPLAY" );
3436 createSMESHAction( 302, "DISPLAY_ONLY" );
3437 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3438 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3439 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3440 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3441 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3442 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3443 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3444 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3446 // ----- create menu --------------
3447 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3448 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3449 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3450 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3451 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3452 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3453 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3454 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3456 createMenu( separator(), fileId );
3458 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3459 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3460 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3461 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3462 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3463 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3464 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3465 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3466 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3467 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3469 createMenu( 111, importId, -1 );
3470 createMenu( 112, importId, -1 );
3471 createMenu( 113, importId, -1 );
3473 createMenu( 121, exportId, -1 );
3474 createMenu( 122, exportId, -1 );
3475 createMenu( 123, exportId, -1 );
3476 createMenu( 140, exportId, -1 ); // export to stl STL
3478 createMenu( separator(), fileId, 10 );
3480 createMenu( 33, editId, -1 );
3482 createMenu( 5105, toolsId, -1 );
3484 createMenu( 702, meshId, -1 ); // "Mesh" menu
3485 createMenu( 703, meshId, -1 );
3486 createMenu( 704, meshId, -1 );
3487 createMenu( 710, meshId, -1 );
3488 createMenu( 705, meshId, -1 );
3489 createMenu( separator(), meshId, -1 );
3490 createMenu( 701, meshId, -1 );
3491 createMenu( 711, meshId, -1 );
3492 createMenu( 712, meshId, -1 );
3493 createMenu( 713, meshId, -1 );
3494 createMenu( separator(), meshId, -1 );
3495 createMenu( 801, meshId, -1 );
3496 createMenu( 806, meshId, -1 );
3497 createMenu( 802, meshId, -1 );
3498 createMenu( 803, meshId, -1 );
3499 createMenu( 815, meshId, -1 );
3500 createMenu( separator(), meshId, -1 );
3501 createMenu( 810, meshId, -1 );
3502 createMenu( 811, meshId, -1 );
3503 createMenu( 812, meshId, -1 );
3504 createMenu( separator(), meshId, -1 );
3505 createMenu( 814, meshId, -1 );
3506 createMenu( separator(), meshId, -1 );
3507 createMenu( 900, meshId, -1 );
3508 //createMenu( 902, meshId, -1 );
3509 createMenu( 903, meshId, -1 );
3510 createMenu( 904, meshId, -1 );
3511 createMenu( separator(), meshId, -1 );
3513 createMenu( 6005, nodeId, -1 );
3514 createMenu( 6002, edgeId, -1 );
3515 createMenu( 6003, edgeId, -1 );
3516 createMenu( 6001, edgeId, -1 );
3517 createMenu( 6004, edgeId, -1 );
3518 createMenu( 6021, faceId, -1 );
3519 createMenu( 6025, faceId, -1 );
3520 createMenu( 6027, faceId, -1 );
3521 createMenu( 6018, faceId, -1 );
3522 createMenu( 6019, faceId, -1 );
3523 createMenu( 6011, faceId, -1 );
3524 createMenu( 6012, faceId, -1 );
3525 createMenu( 6013, faceId, -1 );
3526 createMenu( 6014, faceId, -1 );
3527 createMenu( 6015, faceId, -1 );
3528 createMenu( 6016, faceId, -1 );
3529 createMenu( 6022, faceId, -1 );
3530 createMenu( 6017, volumeId, -1 );
3531 createMenu( 6009, volumeId, -1 );
3532 createMenu( 6023, volumeId, -1 );
3533 createMenu( 6024, volumeId, -1 );
3534 createMenu( 6026, volumeId, -1 );
3536 createMenu( 4000, addId, -1 );
3537 createMenu( 4009, addId, -1 );
3538 createMenu( 4010, addId, -1 );
3539 createMenu( 4021, addId, -1 );
3540 createMenu( 4022, addId, -1 );
3541 createMenu( 4023, addId, -1 );
3542 createMenu( 4031, addId, -1 );
3543 createMenu( 4032, addId, -1 );
3544 createMenu( 4033, addId, -1 );
3545 createMenu( separator(), addId, -1 );
3546 createMenu( 4034, addId, -1 );
3547 createMenu( 4035, addId, -1 );
3548 createMenu( 4036, addId, -1 );
3549 createMenu( 4037, addId, -1 );
3550 createMenu( 4038, addId, -1 );
3551 createMenu( 4039, addId, -1 );
3552 createMenu( 4040, addId, -1 );
3554 createMenu( 4041, removeId, -1 );
3555 createMenu( 4042, removeId, -1 );
3556 createMenu( 4044, removeId, -1 );
3557 createMenu( separator(), removeId, -1 );
3558 createMenu( 813, removeId, -1 );
3559 createMenu( separator(), removeId, -1 );
3560 createMenu( 4043, removeId, -1 );
3562 createMenu( 4051, renumId, -1 );
3563 createMenu( 4052, renumId, -1 );
3565 createMenu( 4061, transfId, -1 );
3566 createMenu( 4062, transfId, -1 );
3567 createMenu( 4063, transfId, -1 );
3568 createMenu( 4064, transfId, -1 );
3569 createMenu( 4065, transfId, -1 );
3570 createMenu( 4066, transfId, -1 );
3571 createMenu( 4068, transfId, -1 );
3572 createMenu( 4069, transfId, -1 );
3574 createMenu( 4067,modifyId, -1 );
3575 createMenu( 407, modifyId, -1 );
3576 createMenu( 408, modifyId, -1 );
3577 createMenu( 409, modifyId, -1 );
3578 createMenu( 410, modifyId, -1 );
3579 createMenu( 411, modifyId, -1 );
3580 createMenu( 419, modifyId, -1 );
3581 createMenu( 412, modifyId, -1 );
3582 createMenu( 413, modifyId, -1 );
3583 createMenu( 416, modifyId, -1 );
3584 createMenu( 414, modifyId, -1 );
3585 createMenu( 415, modifyId, -1 );
3586 createMenu( 417, modifyId, -1 );
3587 createMenu( 418, modifyId, -1 );
3589 createMenu( 501, measureId, -1 );
3590 createMenu( 502, measureId, -1 );
3591 createMenu( 214, viewId, -1 );
3593 // ----- create toolbars --------------
3594 int meshTb = createTool( tr( "TB_MESH" ) ),
3595 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3596 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3597 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3598 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3600 createTool( 702, meshTb );
3601 createTool( 703, meshTb );
3602 createTool( 704, meshTb );
3603 createTool( 710, meshTb );
3604 createTool( 705, meshTb );
3605 createTool( separator(), meshTb );
3606 createTool( 701, meshTb );
3607 createTool( 711, meshTb );
3608 createTool( 712, meshTb );
3609 createTool( 713, meshTb );
3610 createTool( separator(), meshTb );
3611 createTool( 801, meshTb );
3612 createTool( 806, meshTb );
3613 createTool( 802, meshTb );
3614 createTool( 803, meshTb );
3615 //createTool( 815, meshTb );
3616 createTool( separator(), meshTb );
3617 createTool( 900, meshTb );
3618 //createTool( 902, meshTb );
3619 createTool( 903, meshTb );
3620 createTool( 904, meshTb );
3621 createTool( separator(), meshTb );
3623 createTool( 6005, ctrlTb );
3624 createTool( separator(), ctrlTb );
3625 createTool( 6002, ctrlTb );
3626 createTool( 6003, ctrlTb );
3627 createTool( 6001, ctrlTb );
3628 createTool( 6004, ctrlTb );
3629 createTool( separator(), ctrlTb );
3630 createTool( 6021, ctrlTb );
3631 createTool( 6025, ctrlTb );
3632 createTool( 6027, ctrlTb );
3633 createTool( 6018, ctrlTb );
3634 createTool( 6019, ctrlTb );
3635 createTool( 6011, ctrlTb );
3636 createTool( 6012, ctrlTb );
3637 createTool( 6013, ctrlTb );
3638 createTool( 6014, ctrlTb );
3639 createTool( 6015, ctrlTb );
3640 createTool( 6016, ctrlTb );
3641 createTool( 6022, ctrlTb );
3642 createTool( separator(), ctrlTb );
3643 createTool( 6017, ctrlTb );
3644 createTool( 6009, ctrlTb );
3645 createTool( 6023, ctrlTb );
3646 createTool( 6024, ctrlTb );
3647 createTool( 6026, ctrlTb );
3648 createTool( separator(), ctrlTb );
3650 createTool( 4000, addRemTb );
3651 createTool( 4009, addRemTb );
3652 createTool( 4010, addRemTb );
3653 createTool( 4021, addRemTb );
3654 createTool( 4022, addRemTb );
3655 createTool( 4023, addRemTb );
3656 createTool( 4031, addRemTb );
3657 createTool( 4032, addRemTb );
3658 createTool( 4033, addRemTb );
3659 createTool( separator(), addRemTb );
3660 createTool( 4034, addRemTb );
3661 createTool( 4035, addRemTb );
3662 createTool( 4036, addRemTb );
3663 createTool( 4037, addRemTb );
3664 createTool( 4038, addRemTb );
3665 createTool( 4039, addRemTb );
3666 createTool( 4040, addRemTb );
3667 createTool( separator(), addRemTb );
3668 createTool( 4041, addRemTb );
3669 createTool( 4042, addRemTb );
3670 createTool( 4044, addRemTb );
3671 createTool( 4043, addRemTb );
3672 createTool( separator(), addRemTb );
3673 createTool( 4051, addRemTb );
3674 createTool( 4052, addRemTb );
3675 createTool( separator(), addRemTb );
3676 createTool( 4061, addRemTb );
3677 createTool( 4062, addRemTb );
3678 createTool( 4063, addRemTb );
3679 createTool( 4064, addRemTb );
3680 createTool( 4065, addRemTb );
3681 createTool( 4066, addRemTb );
3682 createTool( 4068, addRemTb );
3683 createTool( 4069, addRemTb );
3684 createTool( separator(), addRemTb );
3686 createTool( 4067,modifyTb );
3687 createTool( 407, modifyTb );
3688 createTool( 408, modifyTb );
3689 createTool( 409, modifyTb );
3690 createTool( 410, modifyTb );
3691 createTool( 411, modifyTb );
3692 createTool( 419, modifyTb );
3693 createTool( 412, modifyTb );
3694 createTool( 413, modifyTb );
3695 createTool( 416, modifyTb );
3696 createTool( 414, modifyTb );
3697 createTool( 415, modifyTb );
3698 createTool( 417, modifyTb );
3699 createTool( 418, modifyTb );
3701 createTool( 214, dispModeTb );
3703 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3704 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3707 QString OB = "'ObjectBrowser'",
3708 View = "'" + SVTK_Viewer::Type() + "'",
3710 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3711 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3712 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3713 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3714 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3715 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3716 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3717 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3718 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3719 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3720 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3722 mesh_group = mesh + " " + subMesh + " " + group,
3723 hyp_alg = hypo + " " + algo;
3725 // popup for object browser
3727 isInvisible("not( isVisible )"),
3728 isEmpty("numberOfNodes = 0"),
3729 isNotEmpty("numberOfNodes <> 0"),
3731 // has nodes, edges, etc in VISIBLE! actor
3732 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3733 hasElems("(count( elemTypes ) > 0)"),
3734 hasDifferentElems("(count( elemTypes ) > 1)"),
3735 hasElems0d("({'Elem0d'} in elemTypes)"),
3736 hasEdges("({'Edge'} in elemTypes)"),
3737 hasFaces("({'Face'} in elemTypes)"),
3738 hasVolumes("({'Volume'} in elemTypes)");
3740 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3741 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3742 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3743 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3744 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3745 createPopupItem( 803, OB, group ); // EDIT_GROUP
3746 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3748 popupMgr()->insert( separator(), -1, 0 );
3749 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3750 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3751 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3752 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3753 createPopupItem( 214, OB, mesh_group ); // UPDATE
3754 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3755 //createPopupItem( 902, OB, mesh ); // STD_INFO
3756 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3757 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3758 popupMgr()->insert( separator(), -1, 0 );
3759 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3760 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3761 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3762 popupMgr()->insert( separator(), -1, 0 );
3763 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3764 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3765 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3766 popupMgr()->insert( separator(), -1, 0 );
3767 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3768 popupMgr()->insert( separator(), -1, 0 );
3769 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3770 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3771 popupMgr()->insert( separator(), -1, 0 );
3773 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3774 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3776 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3777 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3778 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3779 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3780 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3781 popupMgr()->insert( separator(), -1, 0 );
3784 createPopupItem( 803, View, group ); // EDIT_GROUP
3785 createPopupItem( 804, View, elems ); // ADD
3786 createPopupItem( 805, View, elems ); // REMOVE
3788 popupMgr()->insert( separator(), -1, 0 );
3789 createPopupItem( 214, View, mesh_group ); // UPDATE
3790 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3791 //createPopupItem( 902, View, mesh ); // STD_INFO
3792 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3793 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3794 popupMgr()->insert( separator(), -1, 0 );
3796 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3797 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3798 popupMgr()->insert( separator(), -1, 0 );
3801 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3802 QString aType = QString( "%1type in {%2}" ).arg( lc );
3803 aType = aType.arg( mesh_group );
3804 QString aMeshInVTK = aClient + "&&" + aType;
3806 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3807 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3808 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3810 //-------------------------------------------------
3812 //-------------------------------------------------
3813 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3815 popupMgr()->insert( action( 9010 ), anId, -1 );
3816 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3817 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3819 popupMgr()->insert( action( 9011 ), anId, -1 );
3820 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3821 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3823 popupMgr()->insert( separator(), -1, -1 );
3825 //-------------------------------------------------
3827 //-------------------------------------------------
3828 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3830 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3831 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3832 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3834 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3835 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3836 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3838 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3839 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3840 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3842 popupMgr()->insert( separator(), anId, -1 );
3844 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3845 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3846 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3848 //-------------------------------------------------
3850 //-------------------------------------------------
3851 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3853 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3855 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3856 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3857 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3859 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3860 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3861 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3863 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3864 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3865 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3867 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3868 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3869 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3871 popupMgr()->insert( separator(), anId, -1 );
3873 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3874 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3877 //-------------------------------------------------
3878 // Representation of the 2D Quadratic elements
3879 //-------------------------------------------------
3880 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3881 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3882 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3883 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3885 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3886 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3887 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3889 //-------------------------------------------------
3890 // Orientation of faces
3891 //-------------------------------------------------
3892 popupMgr()->insert( action( 221 ), -1, -1 );
3893 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3894 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3896 //-------------------------------------------------
3898 //-------------------------------------------------
3899 popupMgr()->insert( action( 1132 ), -1, -1 );
3900 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3902 //-------------------------------------------------
3904 //-------------------------------------------------
3905 popupMgr()->insert( action( 1133 ), -1, -1 );
3906 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3908 //-------------------------------------------------
3910 //-------------------------------------------------
3912 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3913 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3914 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3915 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3917 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3919 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3920 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3922 popupMgr()->insert( separator(), anId, -1 );
3924 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3926 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3927 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3928 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3930 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3932 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3933 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3934 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3936 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3937 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3938 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3940 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3941 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3942 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3944 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3945 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3946 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3948 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3950 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3951 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3952 QtxPopupMgr::VisibleRule );
3953 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3955 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3956 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3957 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3959 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3960 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3961 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3963 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3964 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3965 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3967 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3968 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3969 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3971 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3972 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3973 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3975 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3976 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3977 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3979 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3980 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3981 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3983 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3984 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3985 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3987 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3988 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3989 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3991 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3992 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3993 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3995 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
3996 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3997 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
3999 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4001 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4002 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4003 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4005 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4006 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4007 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4009 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4010 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4011 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4013 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4014 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4015 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4017 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4018 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4019 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4021 popupMgr()->insert( separator(), anId, -1 );
4023 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4024 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4026 popupMgr()->insert( separator(), anId, -1 );
4028 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4030 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4031 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4033 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4034 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4035 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4037 #ifndef DISABLE_PLOT2DVIEWER
4038 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4039 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4042 //-------------------------------------------------
4044 //-------------------------------------------------
4045 popupMgr()->insert( separator(), -1, -1 );
4046 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4047 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4048 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4049 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4051 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4052 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4054 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4055 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4057 popupMgr()->insert( separator(), -1, -1 );
4059 //-------------------------------------------------
4061 //-------------------------------------------------
4062 popupMgr()->insert( action( 1134 ), -1, -1 );
4063 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4065 popupMgr()->insert( separator(), -1, -1 );
4067 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4068 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4070 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4071 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4074 //================================================================================
4076 * \brief Return true if SMESH or GEOM objects are selected.
4077 * Is called form LightApp_Module::activateModule() which clear selection if
4078 * not isSelectionCompatible()
4080 //================================================================================
4082 bool SMESHGUI::isSelectionCompatible()
4084 bool isCompatible = true;
4085 SALOME_ListIO selected;
4086 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4087 Sel->selectedObjects( selected );
4089 SALOME_ListIteratorOfListIO It( selected );
4090 for ( ; isCompatible && It.More(); It.Next())
4092 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4093 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4095 return isCompatible;
4099 bool SMESHGUI::reusableOperation( const int id )
4101 // compute, evaluate and precompute are not reusable operations
4102 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4105 bool SMESHGUI::activateModule( SUIT_Study* study )
4107 bool res = SalomeApp_Module::activateModule( study );
4109 setMenuShown( true );
4110 setToolShown( true );
4112 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4113 PyGILState_STATE gstate = PyGILState_Ensure();
4114 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4115 if(pluginsmanager==NULL)
4119 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4124 PyGILState_Release(gstate);
4125 // end of GEOM plugins loading
4127 // Reset actions accelerator keys
4128 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4129 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4130 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4132 action( 33)->setEnabled(true); // Delete: Key_Delete
4133 action(1101)->setEnabled(true); // Rename: Key_F2
4135 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4136 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4137 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4138 if ( _PTR(Study) aStudy = s->studyDS()) {
4139 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4140 updateObjBrowser(); // objects can be removed
4143 // get all view currently opened in the study and connect their signals to
4144 // the corresponding slots of the class.
4145 SUIT_Desktop* aDesk = study->application()->desktop();
4147 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4148 SUIT_ViewWindow* wnd;
4149 foreach ( wnd, wndList )
4156 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4158 setMenuShown( false );
4159 setToolShown( false );
4161 EmitSignalCloseAllDialogs();
4163 // Unset actions accelerator keys
4164 action(111)->setShortcut(QKeySequence()); // Import DAT
4165 action(112)->setShortcut(QKeySequence()); // Import UNV
4166 action(113)->setShortcut(QKeySequence()); // Import MED
4168 action( 33)->setEnabled(false); // Delete: Key_Delete
4169 action(1101)->setEnabled(false); // Rename: Key_F2
4171 return SalomeApp_Module::deactivateModule( study );
4174 void SMESHGUI::studyClosed( SUIT_Study* s )
4176 SMESH::RemoveVisuData( s->id() );
4177 SalomeApp_Module::studyClosed( s );
4180 void SMESHGUI::OnGUIEvent()
4182 const QObject* obj = sender();
4183 if ( !obj || !obj->inherits( "QAction" ) )
4185 int id = actionId((QAction*)obj);
4190 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4193 if ( CORBA::is_nil( myComponentSMESH ) )
4195 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4197 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4198 return aGUI.myComponentSMESH;
4201 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4202 return myComponentSMESH;
4205 QString SMESHGUI::engineIOR() const
4207 CORBA::ORB_var anORB = getApp()->orb();
4208 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4209 return QString( anIOR.in() );
4212 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4214 SalomeApp_Module::contextMenuPopup( client, menu, title );
4216 selectionMgr()->selectedObjects( lst );
4217 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4218 Handle(SALOME_InteractiveObject) io = lst.First();
4219 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4220 _PTR(Study) study = appStudy->studyDS();
4221 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4223 QString aName = QString( obj->GetName().c_str() );
4224 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4225 aName.remove( (aName.length() - 1), 1 );
4231 LightApp_Selection* SMESHGUI::createSelection() const
4233 return new SMESHGUI_Selection();
4236 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4238 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4239 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4242 void SMESHGUI::viewManagers( QStringList& list ) const
4244 list.append( SVTK_Viewer::Type() );
4247 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4249 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4250 SMESH::UpdateSelectionProp( this );
4252 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4253 for(int i = 0; i < aViews.count() ; i++){
4254 SUIT_ViewWindow *sf = aViews[i];
4260 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4262 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4263 myClippingPlaneInfoMap.erase( theViewManager );
4266 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4268 theActor->AddObserver( SMESH::DeleteActorEvent,
4269 myEventCallbackCommand.GetPointer(),
4273 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4274 unsigned long theEvent,
4275 void* theClientData,
4278 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4279 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4280 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4281 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4282 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4283 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4284 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4285 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4286 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4287 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4288 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4289 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4290 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4291 if( anActor == *anIter3 ) {
4292 anActorList.erase( anIter3 );
4303 void SMESHGUI::createPreferences()
4305 // General tab ------------------------------------------------------------------------
4306 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4308 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4309 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4310 setPreferenceProperty( lim, "min", 0 );
4311 setPreferenceProperty( lim, "max", 100000000 );
4312 setPreferenceProperty( lim, "step", 1000 );
4313 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4315 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4316 setPreferenceProperty( qaGroup, "columns", 2 );
4317 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4318 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4319 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4320 setPreferenceProperty( prec, "min", 0 );
4321 setPreferenceProperty( prec, "max", 16 );
4323 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4324 setPreferenceProperty( dispgroup, "columns", 2 );
4325 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4327 modes.append( "Wireframe" );
4328 modes.append( "Shading" );
4329 modes.append( "Nodes" );
4330 modes.append( "Shrink" );
4331 QList<QVariant> indices;
4332 indices.append( 0 );
4333 indices.append( 1 );
4334 indices.append( 2 );
4335 indices.append( 3 );
4336 setPreferenceProperty( dispmode, "strings", modes );
4337 setPreferenceProperty( dispmode, "indexes", indices );
4339 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4340 setPreferenceProperty( arcgroup, "columns", 2 );
4341 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4342 QStringList quadraticModes;
4343 quadraticModes.append("Lines");
4344 quadraticModes.append("Arcs");
4346 indices.append( 0 );
4347 indices.append( 1 );
4348 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4349 setPreferenceProperty( quadraticmode, "indexes", indices );
4351 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4352 "SMESH", "max_angle" );
4353 setPreferenceProperty( maxAngle, "min", 1 );
4354 setPreferenceProperty( maxAngle, "max", 90 );
4358 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4359 setPreferenceProperty( exportgroup, "columns", 2 );
4360 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4361 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4363 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4364 setPreferenceProperty( computeGroup, "columns", 2 );
4365 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4367 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4368 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4369 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4371 indices.append( 0 );
4372 indices.append( 1 );
4373 indices.append( 2 );
4374 setPreferenceProperty( notifyMode, "strings", modes );
4375 setPreferenceProperty( notifyMode, "indexes", indices );
4377 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4378 setPreferenceProperty( computeGroup, "columns", 2 );
4379 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4381 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4382 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4384 indices.append( 0 );
4385 indices.append( 1 );
4386 setPreferenceProperty( elemInfo, "strings", modes );
4387 setPreferenceProperty( elemInfo, "indexes", indices );
4389 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4390 setPreferenceProperty( segGroup, "columns", 2 );
4391 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4392 "SMESH", "segmentation" );
4393 setPreferenceProperty( segLen, "min", 1 );
4394 setPreferenceProperty( segLen, "max", 10000000 );
4395 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4396 "SMESH", "nb_segments_per_edge" );
4397 setPreferenceProperty( nbSeg, "min", 1 );
4398 setPreferenceProperty( nbSeg, "max", 10000000 );
4400 // Quantities with individual precision settings
4401 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4402 setPreferenceProperty( precGroup, "columns", 2 );
4404 const int nbQuantities = 6;
4405 int precs[nbQuantities], ii = 0;
4406 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4407 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4408 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4409 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4410 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4411 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4412 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4413 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4414 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4415 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4416 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4417 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4419 // Set property for precision value for spinboxes
4420 for ( ii = 0; ii < nbQuantities; ii++ ){
4421 setPreferenceProperty( precs[ii], "min", -14 );
4422 setPreferenceProperty( precs[ii], "max", 14 );
4423 setPreferenceProperty( precs[ii], "precision", 2 );
4426 // Mesh tab ------------------------------------------------------------------------
4427 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4428 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4429 setPreferenceProperty( nodeGroup, "columns", 3 );
4431 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4433 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4435 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4436 QList<QVariant> aMarkerTypeIndicesList;
4437 QList<QVariant> aMarkerTypeIconsList;
4438 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4439 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4440 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4441 aMarkerTypeIndicesList << i;
4442 aMarkerTypeIconsList << pixmap;
4444 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4445 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4447 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4449 QList<QVariant> aMarkerScaleIndicesList;
4450 QStringList aMarkerScaleValuesList;
4451 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4452 aMarkerScaleIndicesList << i;
4453 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4455 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4456 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4458 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4459 setPreferenceProperty( elemGroup, "columns", 2 );
4461 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4462 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4463 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4464 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4466 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4467 setPreferenceProperty( grpGroup, "columns", 2 );
4469 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4471 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4472 //setPreferenceProperty( sp, "hstretch", 0 );
4473 //setPreferenceProperty( sp, "vstretch", 0 );
4475 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4476 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4477 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4478 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4479 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4480 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4481 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4483 setPreferenceProperty( size0d, "min", 1 );
4484 setPreferenceProperty( size0d, "max", 10 );
4486 setPreferenceProperty( sp, "hstretch", 0 );
4487 setPreferenceProperty( sp, "vstretch", 0 );
4489 setPreferenceProperty( elemW, "min", 1 );
4490 setPreferenceProperty( elemW, "max", 5 );
4492 setPreferenceProperty( shrink, "min", 0 );
4493 setPreferenceProperty( shrink, "max", 100 );
4495 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4496 setPreferenceProperty( orientGroup, "columns", 1 );
4498 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4499 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4501 setPreferenceProperty( orientScale, "min", 0.05 );
4502 setPreferenceProperty( orientScale, "max", 0.5 );
4503 setPreferenceProperty( orientScale, "step", 0.05 );
4505 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4507 // Selection tab ------------------------------------------------------------------------
4508 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4510 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4511 setPreferenceProperty( selGroup, "columns", 2 );
4513 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4514 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4515 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4517 setPreferenceProperty( selW, "min", 1 );
4518 setPreferenceProperty( selW, "max", 5 );
4520 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4521 setPreferenceProperty( preGroup, "columns", 2 );
4523 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4524 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4526 setPreferenceProperty( preW, "min", 1 );
4527 setPreferenceProperty( preW, "max", 5 );
4529 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4530 setPreferenceProperty( precSelGroup, "columns", 2 );
4532 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4533 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4534 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4536 // Scalar Bar tab ------------------------------------------------------------------------
4537 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4538 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4539 setPreferenceProperty( fontGr, "columns", 2 );
4541 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4542 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4544 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4545 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4547 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4548 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4550 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4551 setPreferenceProperty( numcol, "min", 2 );
4552 setPreferenceProperty( numcol, "max", 256 );
4554 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4555 setPreferenceProperty( numlab, "min", 2 );
4556 setPreferenceProperty( numlab, "max", 65 );
4558 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4559 setPreferenceProperty( orientGr, "columns", 2 );
4560 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4561 QStringList orients;
4562 orients.append( tr( "SMESH_VERTICAL" ) );
4563 orients.append( tr( "SMESH_HORIZONTAL" ) );
4564 indices.clear(); indices.append( 0 ); indices.append( 1 );
4565 setPreferenceProperty( orient, "strings", orients );
4566 setPreferenceProperty( orient, "indexes", indices );
4568 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4569 setPreferenceProperty( posVSizeGr, "columns", 2 );
4570 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4571 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4572 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4573 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4574 setPreferenceProperty( xv, "step", 0.1 );
4575 setPreferenceProperty( xv, "min", 0.0 );
4576 setPreferenceProperty( xv, "max", 1.0 );
4577 setPreferenceProperty( yv, "step", 0.1 );
4578 setPreferenceProperty( yv, "min", 0.0 );
4579 setPreferenceProperty( yv, "max", 1.0 );
4580 setPreferenceProperty( wv, "step", 0.1 );
4581 setPreferenceProperty( wv, "min", 0.0 );
4582 setPreferenceProperty( wv, "max", 1.0 );
4583 setPreferenceProperty( hv, "min", 0.0 );
4584 setPreferenceProperty( hv, "max", 1.0 );
4585 setPreferenceProperty( hv, "step", 0.1 );
4587 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4588 setPreferenceProperty( posHSizeGr, "columns", 2 );
4589 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4590 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4591 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4592 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4593 setPreferenceProperty( xv, "min", 0.0 );
4594 setPreferenceProperty( xv, "max", 1.0 );
4595 setPreferenceProperty( xv, "step", 0.1 );
4596 setPreferenceProperty( xh, "min", 0.0 );
4597 setPreferenceProperty( xh, "max", 1.0 );
4598 setPreferenceProperty( xh, "step", 0.1 );
4599 setPreferenceProperty( yh, "min", 0.0 );
4600 setPreferenceProperty( yh, "max", 1.0 );
4601 setPreferenceProperty( yh, "step", 0.1 );
4602 setPreferenceProperty( wh, "min", 0.0 );
4603 setPreferenceProperty( wh, "max", 1.0 );
4604 setPreferenceProperty( wh, "step", 0.1 );
4605 setPreferenceProperty( hh, "min", 0.0 );
4606 setPreferenceProperty( hh, "max", 1.0 );
4607 setPreferenceProperty( hh, "step", 0.1 );
4609 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4610 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4611 setPreferenceProperty( distributionGr, "columns", 3 );
4613 types.append( tr( "SMESH_MONOCOLOR" ) );
4614 types.append( tr( "SMESH_MULTICOLOR" ) );
4615 indices.clear(); indices.append( 0 ); indices.append( 1 );
4616 setPreferenceProperty( coloringType, "strings", types );
4617 setPreferenceProperty( coloringType, "indexes", indices );
4618 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4622 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4624 if( sect=="SMESH" ) {
4625 float sbX1,sbY1,sbW,sbH;
4626 float aTol = 1.00000009999999;
4627 std::string aWarning;
4628 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4629 if( name=="selection_object_color" || name=="selection_element_color" ||
4630 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4631 name=="selection_precision_node" || name=="selection_precision_element" ||
4632 name=="selection_precision_object")
4633 SMESH::UpdateSelectionProp( this );
4634 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4635 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4636 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4637 if(sbX1+sbW > aTol){
4638 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4641 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4642 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4645 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4646 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4647 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4648 if(sbY1+sbH > aTol){
4649 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4650 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4651 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4654 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4655 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4656 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4657 if(sbX1+sbW > aTol){
4658 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4661 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4662 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4665 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4666 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4667 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4668 if(sbY1+sbH > aTol){
4669 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4672 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4673 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4676 else if ( name == "segmentation" ) {
4677 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4678 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4680 else if ( name == "nb_segments_per_edge" ) {
4681 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4682 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4685 if(aWarning.size() != 0){
4686 aWarning += "The default values are applied instead.";
4687 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4688 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4689 QObject::tr(aWarning.c_str()));
4694 //================================================================================
4696 * \brief Update something in accordance with update flags
4697 * \param theFlags - update flags
4699 * Update viewer or/and object browser etc. in accordance with update flags ( see
4700 * LightApp_UpdateFlags enumeration ).
4702 //================================================================================
4703 void SMESHGUI::update( const int flags )
4705 if ( flags & UF_Viewer | flags & UF_Forced )
4706 SMESH::UpdateView();
4708 SalomeApp_Module::update( flags );
4711 //================================================================================
4713 * \brief Set default selection mode
4715 * SLOT called when operation commited. Sets default selection mode
4717 //================================================================================
4718 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4720 SVTK_ViewWindow* vtkWnd =
4721 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4723 vtkWnd->SetSelectionMode( ActorSelection );
4726 //================================================================================
4728 * \brief Set default selection mode
4730 * SLOT called when operation aborted. Sets default selection mode
4732 //================================================================================
4733 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4735 SVTK_ViewWindow* vtkWnd =
4736 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4738 vtkWnd->SetSelectionMode( ActorSelection );
4741 //================================================================================
4743 * \brief Creates operation with given identifier
4744 * \param id - identifier of operation to be started
4745 * \return Pointer on created operation or NULL if operation is not created
4747 * Virtual method redefined from the base class creates operation with given id.
4748 * It is called called automatically from startOperation method of base class.
4750 //================================================================================
4751 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4753 LightApp_Operation* op = 0;
4754 // to do : create operation here
4757 case 417: //convert to quadratic
4758 op = new SMESHGUI_ConvToQuadOp();
4760 case 418: // create 2D mesh as boundary on 3D
4761 op = new SMESHGUI_Make2DFrom3DOp();
4763 case 701: // Compute mesh
4764 op = new SMESHGUI_ComputeOp();
4766 case 702: // Create mesh
4767 op = new SMESHGUI_MeshOp( true, true );
4769 case 703: // Create sub-mesh
4770 op = new SMESHGUI_MeshOp( true, false );
4772 case 704: // Edit mesh/sub-mesh
4773 op = new SMESHGUI_MeshOp( false );
4775 case 711: // Precompute mesh
4776 op = new SMESHGUI_PrecomputeOp();
4778 case 712: // Evaluate mesh
4779 op = new SMESHGUI_EvaluateOp();
4781 case 713: // Evaluate mesh
4782 op = new SMESHGUI_MeshOrderOp();
4784 case 806: // Create group on geom
4785 op = new SMESHGUI_GroupOnShapeOp();
4787 case 904: // Find element
4788 op = new SMESHGUI_FindElemByPointOp();
4790 case 4067: // make mesh pass through point
4791 op = new SMESHGUI_MakeNodeAtPointOp();
4798 op = SalomeApp_Module::createOperation( id );
4802 //================================================================================
4804 * \brief Stops current operations and starts a given one
4805 * \param id - The id of the operation to start
4807 //================================================================================
4809 void SMESHGUI::switchToOperation(int id)
4811 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4812 activeStudy()->abortAllOperations();
4813 startOperation( id );
4816 LightApp_Displayer* SMESHGUI::displayer()
4819 myDisplayer = new SMESHGUI_Displayer( getApp() );
4823 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4826 int aTolerance = 64;
4827 int anIterations = 0;
4833 if( anIterations % aPeriod == 0 )
4836 if( aTolerance < 1 )
4840 aHue = (int)( 360.0 * rand() / RAND_MAX );
4843 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4844 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4845 for( ; it != itEnd; ++it )
4847 SALOMEDS::Color anAutoColor = *it;
4848 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4851 aQColor.getHsv( &h, &s, &v );
4852 if( abs( h - aHue ) < aTolerance )
4864 aColor.setHsv( aHue, 255, 255 );
4866 SALOMEDS::Color aSColor;
4867 aSColor.R = (double)aColor.red() / 255.0;
4868 aSColor.G = (double)aColor.green() / 255.0;
4869 aSColor.B = (double)aColor.blue() / 255.0;
4874 const char gSeparator = '_'; // character used to separate parameter names
4875 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4876 const char gPathSep = '|'; // character used to separate paths
4879 * \brief Store visual parameters
4881 * This method is called just before the study document is saved.
4882 * Store visual parameters in AttributeParameter attribue(s)
4884 void SMESHGUI::storeVisualParameters (int savePoint)
4886 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4887 if (!appStudy || !appStudy->studyDS())
4889 _PTR(Study) studyDS = appStudy->studyDS();
4891 // componentName is used for encoding of entries when storing them in IParameters
4892 std::string componentName = myComponentSMESH->ComponentDataType();
4893 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4894 //if (!aSComponent) return;
4897 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4898 componentName.c_str(),
4900 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4902 // store map of custom markers
4903 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4904 if( !aMarkerMap.empty() )
4906 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4907 for( ; anIter != aMarkerMap.end(); anIter++ )
4909 int anId = anIter->first;
4910 VTK::MarkerData aMarkerData = anIter->second;
4911 std::string aMarkerFileName = aMarkerData.first;
4912 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4913 if( aMarkerTexture.size() < 3 )
4914 continue; // should contain at least width, height and the first value
4916 QString aPropertyName( "texture" );
4917 aPropertyName += gSeparator;
4918 aPropertyName += QString::number( anId );
4920 QString aPropertyValue = aMarkerFileName.c_str();
4921 aPropertyValue += gPathSep;
4923 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4924 ushort aWidth = *aTextureIter++;
4925 ushort aHeight = *aTextureIter++;
4926 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4927 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4928 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4929 aPropertyValue += QString::number( *aTextureIter );
4931 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4935 // viewers counters are used for storing view_numbers in IParameters
4938 // main cycle to store parameters of displayed objects
4939 QList<SUIT_ViewManager*> lst;
4940 QList<SUIT_ViewManager*>::Iterator it;
4941 getApp()->viewManagers(lst);
4942 for (it = lst.begin(); it != lst.end(); it++)
4944 SUIT_ViewManager* vman = *it;
4945 QString vType = vman->getType();
4947 // saving VTK actors properties
4948 if (vType == SVTK_Viewer::Type())
4950 // store the clipping planes attached to the view manager
4951 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4952 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4953 if( anIter != myClippingPlaneInfoMap.end() )
4954 aClippingPlaneInfoList = anIter->second;
4956 if( !aClippingPlaneInfoList.empty() ) {
4957 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4958 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4960 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4961 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4963 QString aPropertyName( "ClippingPlane" );
4964 aPropertyName += gSeparator;
4965 aPropertyName += QString::number( vtkViewers );
4966 aPropertyName += gSeparator;
4967 aPropertyName += QString::number( anId );
4969 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4970 aPropertyValue += gDigitsSep;
4971 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4972 aPropertyValue += gDigitsSep;
4973 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4974 aPropertyValue += gDigitsSep;
4975 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4977 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4981 QVector<SUIT_ViewWindow*> views = vman->getViews();
4982 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4984 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4986 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4987 vtkActorCollection* allActors = aCopy.GetActors();
4988 allActors->InitTraversal();
4989 while (vtkActor* actor = allActors->GetNextActor())
4991 if (actor->GetVisibility()) // store only visible actors
4993 SMESH_Actor* aSmeshActor = 0;
4994 if (actor->IsA("SMESH_Actor"))
4995 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4996 if (aSmeshActor && aSmeshActor->hasIO())
4998 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5001 // entry is "encoded" = it does NOT contain component adress,
5002 // since it is a subject to change on next component loading
5003 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5005 std::string param, vtkParam = vType.toLatin1().data();
5006 vtkParam += gSeparator;
5007 vtkParam += QString::number(vtkViewers).toLatin1().data();
5008 vtkParam += gSeparator;
5011 param = vtkParam + "Visibility";
5012 ip->setParameter(entry, param, "On");
5015 param = vtkParam + "Representation";
5016 ip->setParameter(entry, param, QString::number
5017 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5020 param = vtkParam + "IsShrunk";
5021 ip->setParameter(entry, param, QString::number
5022 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5024 // Displayed entities
5025 unsigned int aMode = aSmeshActor->GetEntityMode();
5026 bool isE = aMode & SMESH_Actor::eEdges;
5027 bool isF = aMode & SMESH_Actor::eFaces;
5028 bool isV = aMode & SMESH_Actor::eVolumes;
5030 QString modeStr ("e");
5031 modeStr += gDigitsSep; modeStr += QString::number(isE);
5032 modeStr += gDigitsSep; modeStr += "f";
5033 modeStr += gDigitsSep; modeStr += QString::number(isF);
5034 modeStr += gDigitsSep; modeStr += "v";
5035 modeStr += gDigitsSep; modeStr += QString::number(isV);
5037 param = vtkParam + "Entities";
5038 ip->setParameter(entry, param, modeStr.toLatin1().data());
5040 // Colors (surface:edge:)
5041 vtkFloatingPointType r, g, b;
5043 aSmeshActor->GetSufaceColor(r, g, b);
5044 QString colorStr ("surface");
5045 colorStr += gDigitsSep; colorStr += QString::number(r);
5046 colorStr += gDigitsSep; colorStr += QString::number(g);
5047 colorStr += gDigitsSep; colorStr += QString::number(b);
5049 aSmeshActor->GetBackSufaceColor(r, g, b);
5050 colorStr += gDigitsSep; colorStr += "backsurface";
5051 colorStr += gDigitsSep; colorStr += QString::number(r);
5052 colorStr += gDigitsSep; colorStr += QString::number(g);
5053 colorStr += gDigitsSep; colorStr += QString::number(b);
5055 aSmeshActor->GetEdgeColor(r, g, b);
5056 colorStr += gDigitsSep; colorStr += "edge";
5057 colorStr += gDigitsSep; colorStr += QString::number(r);
5058 colorStr += gDigitsSep; colorStr += QString::number(g);
5059 colorStr += gDigitsSep; colorStr += QString::number(b);
5061 aSmeshActor->GetNodeColor(r, g, b);
5062 colorStr += gDigitsSep; colorStr += "node";
5063 colorStr += gDigitsSep; colorStr += QString::number(r);
5064 colorStr += gDigitsSep; colorStr += QString::number(g);
5065 colorStr += gDigitsSep; colorStr += QString::number(b);
5067 param = vtkParam + "Colors";
5068 ip->setParameter(entry, param, colorStr.toLatin1().data());
5070 // Sizes of lines and points
5071 QString sizeStr ("line");
5072 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5073 sizeStr += gDigitsSep; sizeStr += "shrink";
5074 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5076 param = vtkParam + "Sizes";
5077 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5082 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5083 if( aMarkerType == VTK::MT_USER ) {
5084 markerStr += "custom";
5085 markerStr += gDigitsSep;
5086 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5090 markerStr += gDigitsSep;
5091 markerStr += QString::number( (int)aMarkerType );
5092 markerStr += gDigitsSep;
5093 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5096 param = vtkParam + "PointMarker";
5097 ip->setParameter(entry, param, markerStr.toLatin1().data());
5100 param = vtkParam + "Opacity";
5101 ip->setParameter(entry, param,
5102 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5105 param = vtkParam + "ClippingPlane";
5107 if( !aClippingPlaneInfoList.empty() ) {
5108 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5109 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5111 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5112 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5113 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5114 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5115 if( aSmeshActor == *anIter2 ) {
5116 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5117 QString::number( anId ).toLatin1().constData() );
5124 ip->setParameter( entry, param, "Off" );
5125 } // if (io->hasEntry())
5126 } // SMESH_Actor && hasIO
5128 } // while.. actors traversal
5132 } // if (SVTK view model)
5133 } // for (viewManagers)
5136 // data structures for clipping planes processing
5139 vtkIdType Orientation;
5140 vtkFloatingPointType Distance;
5141 vtkFloatingPointType Angle[2];
5143 typedef std::list<TPlaneData> TPlaneDataList;
5144 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5146 typedef std::list<vtkActor*> TActorList;
5149 TActorList ActorList;
5150 SUIT_ViewManager* ViewManager;
5152 typedef std::list<TPlaneInfo> TPlaneInfoList;
5153 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5156 * \brief Restore visual parameters
5158 * This method is called after the study document is opened.
5159 * Restore visual parameters from AttributeParameter attribue(s)
5161 void SMESHGUI::restoreVisualParameters (int savePoint)
5163 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5164 if (!appStudy || !appStudy->studyDS())
5166 _PTR(Study) studyDS = appStudy->studyDS();
5168 // componentName is used for encoding of entries when storing them in IParameters
5169 std::string componentName = myComponentSMESH->ComponentDataType();
5170 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5171 //if (!aSComponent) return;
5174 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5175 componentName.c_str(),
5177 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5179 // restore map of custom markers and map of clipping planes
5180 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5181 TPlaneDataMap aPlaneDataMap;
5183 std::vector<std::string> properties = ip->getProperties();
5184 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5186 std::string property = *propIt;
5187 QString aPropertyName( property.c_str() );
5188 QString aPropertyValue( ip->getProperty( property ).c_str() );
5190 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5191 if( aPropertyNameList.isEmpty() )
5194 QString aPropertyType = aPropertyNameList[0];
5195 if( aPropertyType == "texture" )
5197 if( aPropertyNameList.size() != 2 )
5201 int anId = aPropertyNameList[1].toInt( &ok );
5202 if( !ok || anId < 1 )
5205 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5206 if( aPropertyValueList.size() != 2 )
5209 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5210 QString aMarkerTextureString = aPropertyValueList[1];
5211 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5212 if( aMarkerTextureStringList.size() != 3 )
5216 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5221 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5225 VTK::MarkerTexture aMarkerTexture;
5226 aMarkerTexture.push_back( aWidth );
5227 aMarkerTexture.push_back( aHeight );
5229 QString aMarkerTextureData = aMarkerTextureStringList[2];
5230 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5232 QChar aChar = aMarkerTextureData.at( i );
5233 if( aChar.isDigit() )
5234 aMarkerTexture.push_back( aChar.digitValue() );
5237 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5239 else if( aPropertyType == "ClippingPlane" )
5241 if( aPropertyNameList.size() != 3 )
5245 int aViewId = aPropertyNameList[1].toInt( &ok );
5246 if( !ok || aViewId < 0 )
5250 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5251 if( !ok || aClippingPlaneId < 0 )
5254 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5255 if( aPropertyValueList.size() != 4 )
5258 TPlaneData aPlaneData;
5259 aPlaneData.Id = aClippingPlaneId;
5262 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5267 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5272 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5277 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5281 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5282 aPlaneDataList.push_back( aPlaneData );
5286 TPlaneInfoMap aPlaneInfoMap;
5288 std::vector<std::string> entries = ip->getEntries();
5290 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5292 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5293 QString entry (ip->decodeEntry(*entIt).c_str());
5295 // Check that the entry corresponds to a real object in the Study
5296 // as the object may be deleted or modified after the visual state is saved.
5297 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5298 if (!so) continue; //Skip the not existent entry
5300 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5301 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5303 std::vector<std::string>::iterator namesIt = paramNames.begin();
5304 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5306 // actors are stored in a map after displaying of them for
5307 // quicker access in the future: map < viewID to actor >
5308 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5310 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5312 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5313 // '_' is used as separator and should not be used in viewer type or parameter names.
5314 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5315 if (lst.size() != 3)
5318 QString viewerTypStr = lst[0];
5319 QString viewIndexStr = lst[1];
5320 QString paramNameStr = lst[2];
5323 int viewIndex = viewIndexStr.toUInt(&ok);
5324 if (!ok) // bad conversion of view index to integer
5328 if (viewerTypStr == SVTK_Viewer::Type())
5330 SMESH_Actor* aSmeshActor = 0;
5331 if (vtkActors.IsBound(viewIndex))
5332 aSmeshActor = vtkActors.Find(viewIndex);
5334 QList<SUIT_ViewManager*> lst;
5335 getApp()->viewManagers(viewerTypStr, lst);
5337 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5338 SUIT_ViewManager* vman = NULL;
5339 if (viewIndex >= 0 && viewIndex < lst.count())
5340 vman = lst.at(viewIndex);
5342 if (paramNameStr == "Visibility")
5344 if (!aSmeshActor && displayer() && vman)
5346 SUIT_ViewModel* vmodel = vman->getViewModel();
5347 // SVTK view model can be casted to SALOME_View
5348 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5350 // store displayed actor in a temporary map for quicker
5351 // access later when restoring other parameters
5352 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5353 vtkRenderer* Renderer = vtkView->getRenderer();
5354 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5355 vtkActorCollection* theActors = aCopy.GetActors();
5356 theActors->InitTraversal();
5357 bool isFound = false;
5358 vtkActor *ac = theActors->GetNextActor();
5359 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5360 if (ac->IsA("SMESH_Actor")) {
5361 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5362 if (aGeomAc->hasIO()) {
5363 Handle(SALOME_InteractiveObject) io =
5364 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5365 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5367 vtkActors.Bind(viewIndex, aGeomAc);
5373 } // if (paramNameStr == "Visibility")
5376 // the rest properties "work" with SMESH_Actor
5379 QString val ((*valuesIt).c_str());
5382 if (paramNameStr == "Representation") {
5383 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5386 else if (paramNameStr == "IsShrunk") {
5388 if (!aSmeshActor->IsShrunk())
5389 aSmeshActor->SetShrink();
5392 if (aSmeshActor->IsShrunk())
5393 aSmeshActor->UnShrink();
5396 // Displayed entities
5397 else if (paramNameStr == "Entities") {
5398 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5399 if (mode.count() == 6) {
5400 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5401 MESSAGE("Invalid order of data in Entities, must be: "
5402 "e:0/1:f:0/1:v:0/1");
5405 unsigned int aMode = aSmeshActor->GetEntityMode();
5406 unsigned int aNewMode =
5407 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5408 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5409 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5410 if (aNewMode != aMode)
5411 aSmeshActor->SetEntityMode(aNewMode);
5416 else if (paramNameStr == "Colors") {
5417 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5418 if (colors.count() == 16) {
5419 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5420 colors[8] != "edge" || colors[12] != "node") {
5421 MESSAGE("Invalid order of data in Colors, must be: "
5422 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5425 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5426 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5427 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5428 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5432 // Sizes of lines and points
5433 else if (paramNameStr == "Sizes") {
5434 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5435 if (sizes.count() == 4) {
5436 if (sizes[0] != "line" || sizes[2] != "shrink") {
5437 MESSAGE("Invalid order of data in Sizes, must be: "
5438 "line:int:shrink:float");
5441 aSmeshActor->SetLineWidth(sizes[1].toInt());
5442 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5445 else if (sizes.count() == 6) { // just to support old format
5446 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5447 MESSAGE("Invalid order of data in Sizes, must be: "
5448 "line:int:node:int:shrink:float");
5451 aSmeshActor->SetLineWidth(sizes[1].toInt());
5452 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5453 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5458 else if (paramNameStr == "PointMarker") {
5459 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5460 if( data.count() >= 2 ) {
5462 int aParam1 = data[1].toInt( &ok );
5464 if( data[0] == "std" && data.count() == 3 ) {
5465 int aParam2 = data[2].toInt( &ok );
5466 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5468 else if( data[0] == "custom" ) {
5469 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5470 if( markerIt != aMarkerMap.end() ) {
5471 VTK::MarkerData aMarkerData = markerIt->second;
5472 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5479 else if (paramNameStr == "Opacity") {
5480 aSmeshActor->SetOpacity(val.toFloat());
5483 else if (paramNameStr.startsWith("ClippingPlane")) {
5484 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5485 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5486 // new format - val looks like "Off" or "0" (plane id)
5487 // (note: in new format "Off" value is used only for consistency,
5488 // so it is processed together with values in old format)
5489 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5490 if( anIsOldFormat ) {
5491 if (paramNameStr == "ClippingPlane1" || val == "Off")
5492 aSmeshActor->RemoveAllClippingPlanes();
5494 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5495 double aDistance = vals[1].toFloat();
5496 vtkFloatingPointType anAngle[2];
5497 anAngle[0] = vals[2].toFloat();
5498 anAngle[1] = vals[3].toFloat();
5500 QList<SUIT_ViewManager*> lst;
5501 getApp()->viewManagers(viewerTypStr, lst);
5502 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5503 if (viewIndex >= 0 && viewIndex < lst.count()) {
5504 SUIT_ViewManager* vman = lst.at(viewIndex);
5505 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5507 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5509 SMESH::TActorList anActorList;
5510 anActorList.push_back( aSmeshActor );
5511 SMESH::OrientedPlane* aPlane =
5512 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5514 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5515 aClippingPlaneInfo.Plane = aPlane;
5516 aClippingPlaneInfo.ActorList = anActorList;
5517 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5524 int aPlaneId = val.toInt( &ok );
5525 if( ok && aPlaneId >= 0 ) {
5526 bool anIsDefinedPlane = false;
5527 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5528 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5529 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5530 TPlaneInfo& aPlaneInfo = *anIter;
5531 if( aPlaneInfo.PlaneId == aPlaneId ) {
5532 aPlaneInfo.ActorList.push_back( aSmeshActor );
5533 anIsDefinedPlane = true;
5537 if( !anIsDefinedPlane ) {
5538 TPlaneInfo aPlaneInfo;
5539 aPlaneInfo.PlaneId = aPlaneId;
5540 aPlaneInfo.ActorList.push_back( aSmeshActor );
5541 aPlaneInfo.ViewManager = vman;
5543 // to make the list sorted by plane id
5544 anIter = aPlaneInfoList.begin();
5545 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5546 const TPlaneInfo& aPlaneInfoRef = *anIter;
5547 if( aPlaneInfoRef.PlaneId > aPlaneId )
5550 aPlaneInfoList.insert( anIter, aPlaneInfo );
5555 } // if (aSmeshActor)
5556 } // other parameters than Visibility
5558 } // for names/parameters iterator
5559 } // for entries iterator
5561 // take into account planes with empty list of actors referred to them
5562 QList<SUIT_ViewManager*> aVMList;
5563 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5565 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5566 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5567 int aViewId = aPlaneDataIter->first;
5568 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5569 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5571 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5573 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5574 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5575 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5576 const TPlaneData& aPlaneData = *anIter2;
5577 int aPlaneId = aPlaneData.Id;
5579 bool anIsFound = false;
5580 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5581 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5582 const TPlaneInfo& aPlaneInfo = *anIter3;
5583 if( aPlaneInfo.PlaneId == aPlaneId ) {
5590 TPlaneInfo aPlaneInfo; // ActorList field is empty
5591 aPlaneInfo.PlaneId = aPlaneId;
5592 aPlaneInfo.ViewManager = aViewManager;
5594 // to make the list sorted by plane id
5595 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5596 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5597 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5598 if( aPlaneInfoRef.PlaneId > aPlaneId )
5601 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5607 // add clipping planes to actors according to the restored parameters
5608 // and update the clipping plane map
5609 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5610 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5611 int aViewId = anIter1->first;
5612 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5614 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5615 if( anIter2 == aPlaneDataMap.end() )
5617 const TPlaneDataList& aPlaneDataList = anIter2->second;
5619 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5620 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5621 const TPlaneInfo& aPlaneInfo = *anIter3;
5622 int aPlaneId = aPlaneInfo.PlaneId;
5623 const TActorList& anActorList = aPlaneInfo.ActorList;
5624 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5628 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5632 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5634 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5635 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5636 const TPlaneData& aPlaneData = *anIter4;
5637 if( aPlaneData.Id == aPlaneId ) {
5638 SMESH::OrientedPlane* aPlane =
5639 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5641 (SMESH::Orientation)aPlaneData.Orientation,
5642 aPlaneData.Distance,
5645 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5646 aClippingPlaneInfo.Plane = aPlane;
5647 aClippingPlaneInfo.ActorList = anActorList;
5648 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5656 // update all VTK views
5657 QList<SUIT_ViewManager*> lst;
5658 getApp()->viewManagers(lst);
5659 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5660 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5661 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5662 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5663 vtkView->getRenderer()->ResetCameraClippingRange();
5670 \brief Adds preferences for dfont of VTK viewer
5672 \param pIf group identifier
5673 \param param parameter
5674 \return identifier of preferences
5676 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5678 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5680 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5683 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5684 fam.append( tr( "SMESH_FONT_COURIER" ) );
5685 fam.append( tr( "SMESH_FONT_TIMES" ) );
5687 setPreferenceProperty( tfont, "fonts", fam );
5689 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5690 setPreferenceProperty( tfont, "features", f );
5696 \brief Actions after hypothesis edition
5697 Updates object browser after hypothesis edition
5699 void SMESHGUI::onHypothesisEdit( int result )
5702 SMESHGUI::Modified();
5703 updateObjBrowser( true );
5708 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5709 \param pview view being closed
5711 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5712 #ifndef DISABLE_PLOT2DVIEWER
5713 //Crear all Plot2d Viewers if need.
5714 SMESH::ClearPlot2Viewers(pview);
5719 \brief Connects or disconnects signals about activating and cloning view on the module slots
5720 \param pview view which is connected/disconnected
5722 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5726 SUIT_ViewManager* viewMgr = pview->getViewManager();
5728 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5729 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5731 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5732 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );