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.
28 #include "SMESHGUI_AddMeshElementDlg.h"
29 #include "SMESHGUI_AddQuadraticElementDlg.h"
30 #include "SMESHGUI_BuildCompoundDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_ComputeDlg.h"
33 #include "SMESHGUI_ConvToQuadOp.h"
34 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
35 #include "SMESHGUI_DeleteGroupDlg.h"
36 #include "SMESHGUI_Displayer.h"
37 #include "SMESHGUI_MergeDlg.h"
38 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
39 #include "SMESHGUI_ExtrusionDlg.h"
40 #include "SMESHGUI_FileInfoDlg.h"
41 #include "SMESHGUI_FileValidator.h"
42 #include "SMESHGUI_FilterDlg.h"
43 #include "SMESHGUI_FilterLibraryDlg.h"
44 #include "SMESHGUI_FindElemByPointDlg.h"
45 #include "SMESHGUI_GroupDlg.h"
46 #include "SMESHGUI_GroupOnShapeDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_Hypotheses.h"
49 #include "SMESHGUI_Make2DFrom3DOp.h"
50 #include "SMESHGUI_MakeNodeAtPointDlg.h"
51 #include "SMESHGUI_MeshInfosDlg.h"
52 #include "SMESHGUI_MeshOp.h"
53 #include "SMESHGUI_MeshOrderOp.h"
54 #include "SMESHGUI_MeshPatternDlg.h"
55 #include "SMESHGUI_MultiEditDlg.h"
56 #include "SMESHGUI_NodesDlg.h"
57 #include "SMESHGUI_Preferences_ColorDlg.h"
58 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
59 #include "SMESHGUI_RemoveElementsDlg.h"
60 #include "SMESHGUI_RemoveNodesDlg.h"
61 #include "SMESHGUI_RenumberingDlg.h"
62 #include "SMESHGUI_RevolutionDlg.h"
63 #include "SMESHGUI_RotationDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_SewingDlg.h"
66 #include "SMESHGUI_SingleEditDlg.h"
67 #include "SMESHGUI_SmoothingDlg.h"
68 #include "SMESHGUI_StandardMeshInfosDlg.h"
69 #include "SMESHGUI_SymmetryDlg.h"
70 #include "SMESHGUI_TranslationDlg.h"
71 #include "SMESHGUI_ScaleDlg.h"
72 #include "SMESHGUI_TransparencyDlg.h"
73 #include "SMESHGUI_WhatIsDlg.h"
74 #include "SMESHGUI_DuplicateNodesDlg.h"
76 #include "SMESHGUI_Utils.h"
77 #include "SMESHGUI_MeshUtils.h"
78 #include "SMESHGUI_GroupUtils.h"
79 #include "SMESHGUI_FilterUtils.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_VTKUtils.h"
82 #include "SMESHGUI_HypothesesUtils.h"
84 #include <SMESH_Client.hxx>
85 #include <SMESH_Actor.h>
86 #include <SMESH_TypeFilter.hxx>
88 // SALOME GUI includes
89 #include <SalomeApp_Tools.h>
90 #include <SalomeApp_Study.h>
91 #include <SalomeApp_Application.h>
92 #include <SalomeApp_CheckFileDlg.h>
94 #include <LightApp_DataOwner.h>
95 #include <LightApp_Preferences.h>
96 #include <LightApp_SelectionMgr.h>
97 #include <LightApp_UpdateFlags.h>
98 #include <LightApp_NameDlg.h>
100 #include <SVTK_ViewWindow.h>
101 #include <SVTK_ViewModel.h>
102 #include <SVTK_ViewManager.h>
104 #include <VTKViewer_Algorithm.h>
106 #include <SUIT_MessageBox.h>
107 #include <SUIT_ResourceMgr.h>
108 #include <SUIT_FileDlg.h>
109 #include <SUIT_Desktop.h>
110 #include <SUIT_OverrideCursor.h>
111 #include <SUIT_Session.h>
113 #include <QtxPopupMgr.h>
114 #include <QtxFontEdit.h>
116 #include <SALOME_ListIO.hxx>
117 #include <SALOME_ListIteratorOfListIO.hxx>
120 #include <SALOMEconfig.h>
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
125 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
129 #include <boost/shared_ptr.hpp>
132 #include <vtkScalarBarActor.h>
133 #include <vtkCamera.h>
134 #include <vtkRenderer.h>
135 #include <vtkPlane.h>
137 // SALOME KERNEL includes
138 #include <SALOMEDS_Study.hxx>
139 #include <SALOMEDSClient_StudyBuilder.hxx>
140 #include <SALOMEDSClient_SComponent.hxx>
141 #include <SALOMEDSClient_ClientFactory.hxx>
142 #include <SALOMEDSClient_IParameters.hxx>
145 #include <Standard_ErrorHandler.hxx>
146 #include <NCollection_DataMap.hxx>
148 //To disable automatic genericobj management, the following line should be commented.
149 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
150 #define WITHGENERICOBJ
154 //=============================================================
155 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
158 void ExportMeshToFile(int theCommandID);
160 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
162 void SetDisplayEntity(int theCommandID);
164 void Control( int theCommandID );
168 //=============================================================
169 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
173 std::string myExtension;
175 if ( theCommandID == 113 ) {
176 filter.append( QObject::tr( "MED files (*.med)" ) );
177 filter.append( QObject::tr( "All files (*)" ) );
179 else if ( theCommandID == 112 ) {
180 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
182 else if ( theCommandID == 111 ) {
183 filter.append( QObject::tr( "DAT files (*.dat)" ) );
186 QString anInitialPath = "";
187 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
188 anInitialPath = QDir::currentPath();
190 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
193 QObject::tr( "SMESH_IMPORT_MESH" ) );
194 if ( filenames.count() > 0 ) {
195 SUIT_OverrideCursor wc;
196 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
199 bool isEmpty = false;
200 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
201 QString filename = *it;
202 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
204 switch ( theCommandID ) {
207 // DAT format (currently unsupported)
208 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
209 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
215 aMeshes->length( 1 );
216 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
217 if ( aMeshes[0]->_is_nil() )
218 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
219 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
225 SMESH::DriverMED_ReadStatus res;
226 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
227 if ( res != SMESH::DRS_OK ) {
228 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
229 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
235 catch ( const SALOME::SALOME_Exception& S_ex ) {
236 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
237 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
240 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
241 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
243 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
244 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
245 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
246 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
247 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
249 #ifdef WITHGENERICOBJ
250 // obj has been published in study. Its refcount has been incremented.
251 // It is safe to decrement its refcount
252 // so that it will be destroyed when the entry in study will be removed
253 aMeshes[i]->Destroy();
262 // update Object browser
263 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
265 // show Error message box if there were errors
266 if ( errors.count() > 0 ) {
267 SUIT_MessageBox::critical( SMESHGUI::desktop(),
268 QObject::tr( "SMESH_ERROR" ),
269 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
272 // show warning message box, if some imported mesh is empty
274 SUIT_MessageBox::warning( SMESHGUI::desktop(),
275 QObject::tr( "SMESH_WRN_WARNING" ),
276 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
281 void ExportMeshToFile( int theCommandID )
283 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
284 SALOME_ListIO selected;
286 aSel->selectedObjects( selected );
288 // actually, the following condition can't be met (added for insurance)
289 if( selected.Extent() == 0 ||
290 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
293 bool hasDuplicatedMeshNames = false;
294 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
295 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
296 SALOME_ListIteratorOfListIO It( selected );
297 for( ; It.More(); It.Next() ) {
298 Handle(SALOME_InteractiveObject) anIObject = It.Value();
299 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
300 if ( aMeshItem->_is_nil() ) {
301 SUIT_MessageBox::warning( SMESHGUI::desktop(),
302 QObject::tr( "SMESH_WRN_WARNING" ),
303 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
307 QString aMeshName = anIObject->getName();
309 // check for duplications
310 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
311 if( aMeshName == (*aMeshIter).second ) {
312 hasDuplicatedMeshNames = true;
317 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
320 if( hasDuplicatedMeshNames ) {
321 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
322 QObject::tr("SMESH_WRN_WARNING"),
323 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
324 QObject::tr("SMESH_BUT_YES"),
325 QObject::tr("SMESH_BUT_NO"), 0, 1);
330 aMeshIter = aMeshList.begin();
331 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
332 QString aMeshName = (*aMeshIter).second;
334 QList<SALOMEDS::Color> aReservedColors;
336 QString aFilter, aTitle = QObject::tr("Export mesh");
337 QMap<QString, SMESH::MED_VERSION> aFilterMap;
338 QMap<QString, int> aFilterMapSTL;
339 switch ( theCommandID ) {
343 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
344 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
345 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
346 int aRet = SUIT_MessageBox::warning
347 (SMESHGUI::desktop(),
348 QObject::tr("SMESH_WRN_WARNING"),
349 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
350 QObject::tr("SMESH_BUT_YES"),
351 QObject::tr("SMESH_BUT_NO"), 0, 1);
357 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
358 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
359 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
360 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
365 aFilter = QObject::tr("DAT files (*.dat)");
370 if (aMesh->NbPyramids()) {
371 int aRet = SUIT_MessageBox::warning
372 (SMESHGUI::desktop(),
373 QObject::tr("SMESH_WRN_WARNING"),
374 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
375 QObject::tr("SMESH_BUT_YES"),
376 QObject::tr("SMESH_BUT_NO"), 0, 1);
380 aFilter = QObject::tr("IDEAS files (*.unv)");
388 there must be check on others mesh elements not equal triangles
390 if (aMesh->NbTriangles() < 1) {
391 SUIT_MessageBox::warning
392 (SMESHGUI::desktop(),
393 QObject::tr("SMESH_WRN_WARNING"),
394 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
397 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
398 int aRet = SUIT_MessageBox::warning
399 (SMESHGUI::desktop(),
400 QObject::tr("SMESH_WRN_WARNING"),
401 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
402 QObject::tr("SMESH_BUT_YES"),
403 QObject::tr("SMESH_BUT_NO"), 0, 1);
408 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
409 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
417 SMESH::MED_VERSION aFormat;
418 // Init the parameter with the default value
419 bool aIsASCII_STL = true;
420 bool toCreateGroups = false;
421 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
423 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
424 bool toOverwrite = true;
426 QString anInitialPath = "";
427 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
428 anInitialPath = QDir::currentPath();
430 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
431 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
432 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
433 aFilter, aTitle, false);
435 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
437 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
438 for ( ; it != aFilterMapSTL.end(); ++it )
439 filters.push_back( it.key() );
441 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
442 fd->setWindowTitle( aTitle );
443 fd->setNameFilters( filters );
444 fd->selectNameFilter( QObject::tr("STL ASCII (*.stl)") );
445 if ( !anInitialPath.isEmpty() )
446 fd->setDirectory( anInitialPath );
447 fd->selectFile(aMeshName);
451 aFilename = fd->selectedFile();
452 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
457 else { // Export to MED
459 QString aDefaultFilter;
460 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
461 for ( ; it != aFilterMap.end(); ++it ) {
462 filters.push_back( it.key() );
463 if (it.value() == SMESH::MED_V2_2)
464 aDefaultFilter = it.key();
467 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
468 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
469 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
470 fd->setWindowTitle( aTitle );
471 fd->setNameFilters( filters );
472 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
473 fd->selectNameFilter(aDefaultFilter);
474 fd->SetChecked(toCreateGroups);
475 if ( !anInitialPath.isEmpty() )
476 fd->setDirectory( anInitialPath );
477 fd->selectFile(aMeshName);
479 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
480 fd->setValidator( fv );
485 aFilename = fd->selectedFile();
487 aFilename = QString::null;
490 aFormat = aFilterMap[fd->selectedNameFilter()];
491 toOverwrite = fv->isOverwrite();
493 if ( !aFilename.isEmpty() ) {
494 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
495 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
496 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
497 && aFormat==SMESH::MED_V2_1) {
498 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
499 QObject::tr("SMESH_WRN_WARNING"),
500 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
501 QObject::tr("SMESH_BUT_YES"),
502 QObject::tr("SMESH_BUT_NO"), 0, 1);
510 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
511 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
512 if( !isVersionOk || aVersion != aFormat ) {
513 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
514 QObject::tr("SMESH_WRN_WARNING"),
515 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
516 QObject::tr("SMESH_BUT_YES"),
517 QObject::tr("SMESH_BUT_NO"), 0, 1);
524 QStringList aMeshNamesCollisionList;
525 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
526 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
527 QString anExistingMeshName( aMeshNames[ i ] );
528 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
529 QString anExportMeshName = (*aMeshIter).second;
530 if( anExportMeshName == anExistingMeshName ) {
531 aMeshNamesCollisionList.append( anExportMeshName );
537 if( !aMeshNamesCollisionList.isEmpty() ) {
538 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
539 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
540 QObject::tr("SMESH_WRN_WARNING"),
541 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
542 QObject::tr("SMESH_BUT_YES"),
543 QObject::tr("SMESH_BUT_NO"),
544 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
553 toCreateGroups = fd->IsChecked();
556 if ( !aFilename.isEmpty() ) {
557 // Check whether the file already exists and delete it if yes
558 QFile aFile( aFilename );
559 if ( aFile.exists() && toOverwrite )
561 SUIT_OverrideCursor wc;
564 bool Renumber = false;
565 // PAL 14172 : Check of we have to renumber or not from the preferences before export
567 Renumber= resMgr->booleanValue("SMESH","renumbering");
569 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
570 aMeshEditor->RenumberNodes();
571 aMeshEditor->RenumberElements();
572 if ( SMESHGUI::automaticUpdate() )
575 switch ( theCommandID ) {
579 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
580 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
581 if( !aMeshItem->_is_nil() )
582 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
588 aMesh->ExportDAT( aFilename.toLatin1().data() );
592 aMesh->ExportUNV( aFilename.toLatin1().data() );
596 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
602 catch (const SALOME::SALOME_Exception& S_ex){
604 SUIT_MessageBox::warning(SMESHGUI::desktop(),
605 QObject::tr("SMESH_WRN_WARNING"),
606 QObject::tr("SMESH_EXPORT_FAILED"));
612 inline void InverseEntityMode(unsigned int& theOutputMode,
613 unsigned int theMode)
615 bool anIsNotPresent = ~theOutputMode & theMode;
617 theOutputMode |= theMode;
619 theOutputMode &= ~theMode;
622 void SetDisplayEntity(int theCommandID){
623 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
624 SALOME_ListIO selected;
626 aSel->selectedObjects( selected );
628 if(selected.Extent() >= 1){
629 SALOME_ListIteratorOfListIO It( selected );
630 for( ; It.More(); It.Next()){
631 Handle(SALOME_InteractiveObject) IObject = It.Value();
632 if(IObject->hasEntry()){
633 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
634 unsigned int aMode = anActor->GetEntityMode();
635 switch(theCommandID){
637 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
640 InverseEntityMode(aMode,SMESH_Actor::eEdges);
643 InverseEntityMode(aMode,SMESH_Actor::eFaces);
646 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
649 aMode = SMESH_Actor::eAllEntity;
653 anActor->SetEntityMode(aMode);
661 SALOME_ListIO selected;
662 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
666 LightApp_SelectionMgr* aSel = app->selectionMgr();
667 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
668 if( !aSel || !appStudy )
671 aSel->selectedObjects( selected );
672 if( selected.IsEmpty() )
675 Handle(SALOME_InteractiveObject) anIObject = selected.First();
677 _PTR(Study) aStudy = appStudy->studyDS();
678 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
679 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
680 if( aMainObject->_is_nil() )
683 aMainObject->SetAutoColor( true );
685 QList<SALOMEDS::Color> aReservedColors;
687 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
688 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
690 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
691 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
693 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
694 aGroupObject->SetColor( aColor );
695 aReservedColors.append( aColor );
697 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
699 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
700 if( aGroupObject->GetType() == SMESH::NODE )
701 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
702 else if( aGroupObject->GetType() == SMESH::EDGE )
703 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
704 else if( aGroupObject->GetType() == SMESH::ELEM0D )
705 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
707 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
712 SMESH::RepaintCurrentView();
715 void DisableAutoColor(){
716 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
717 SALOME_ListIO selected;
719 aSel->selectedObjects( selected );
721 if(selected.Extent()){
722 Handle(SALOME_InteractiveObject) anIObject = selected.First();
723 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
724 if ( !aMesh->_is_nil() ) {
725 aMesh->SetAutoColor( false );
730 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
731 SALOME_ListIO selected;
732 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
736 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
737 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
738 if( !aSel || !appStudy )
741 _PTR(Study) aStudy = appStudy->studyDS();
743 aSel->selectedObjects( selected );
745 if(selected.Extent() >= 1){
746 switch(theCommandID){
748 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
749 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
753 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
754 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
758 QColor c, e, b, n, c0D, o;
761 vtkFloatingPointType Shrink = 0.0;
762 vtkFloatingPointType faces_orientation_scale = 0.0;
763 bool faces_orientation_3dvectors = false;
765 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
766 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
767 int aMarkerTextureCurrent = 0;
769 SALOME_ListIteratorOfListIO It( selected );
770 for( ; It.More(); It.Next()){
771 Handle(SALOME_InteractiveObject) IObject = It.Value();
772 if(IObject->hasEntry()){
773 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
774 vtkFloatingPointType color[3];
775 anActor->GetSufaceColor(color[0], color[1], color[2]);
776 int c0 = int (color[0] * 255);
777 int c1 = int (color[1] * 255);
778 int c2 = int (color[2] * 255);
779 c.setRgb(c0, c1, c2);
781 vtkFloatingPointType edgecolor[3];
782 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
783 c0 = int (edgecolor[0] * 255);
784 c1 = int (edgecolor[1] * 255);
785 c2 = int (edgecolor[2] * 255);
786 e.setRgb(c0, c1, c2);
788 vtkFloatingPointType backfacecolor[3];
789 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
790 c0 = int (backfacecolor[0] * 255);
791 c1 = int (backfacecolor[1] * 255);
792 c2 = int (backfacecolor[2] * 255);
793 b.setRgb(c0, c1, c2);
795 vtkFloatingPointType nodecolor[3];
796 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
797 c0 = int (nodecolor[0] * 255);
798 c1 = int (nodecolor[1] * 255);
799 c2 = int (nodecolor[2] * 255);
800 n.setRgb(c0, c1, c2);
802 vtkFloatingPointType color0D[3];
803 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
804 c0 = int (color0D[0] * 255);
805 c1 = int (color0D[1] * 255);
806 c2 = int (color0D[2] * 255);
807 c0D.setRgb(c0, c1, c2);
809 size0D = (int)anActor->Get0DSize();
812 Edgewidth = (int)anActor->GetLineWidth();
815 Shrink = anActor->GetShrinkFactor();
817 vtkFloatingPointType faces_orientation_color[3];
818 anActor->GetFacesOrientationColor(faces_orientation_color);
819 c0 = int (faces_orientation_color[0] * 255);
820 c1 = int (faces_orientation_color[1] * 255);
821 c2 = int (faces_orientation_color[2] * 255);
822 o.setRgb(c0, c1, c2);
824 faces_orientation_scale = anActor->GetFacesOrientationScale();
825 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
827 aMarkerTypeCurrent = anActor->GetMarkerType();
828 aMarkerScaleCurrent = anActor->GetMarkerScale();
829 aMarkerTextureCurrent = anActor->GetMarkerTexture();
831 // even if there are multiple objects in the selection,
832 // we need only the first one to get values for the dialog
838 SMESHGUI_Preferences_ColorDlg *aDlg =
839 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
840 aDlg->SetColor(1, c);
841 aDlg->SetColor(2, e);
842 aDlg->SetColor(3, n);
843 aDlg->SetColor(4, b);
844 aDlg->SetColor(5, c0D);
845 aDlg->SetColor(6, o);
846 aDlg->SetIntValue(1, Edgewidth);
847 aDlg->SetIntValue(2, int(Shrink*100.));
848 aDlg->SetIntValue(3, size0D);
849 aDlg->SetDoubleValue(1, faces_orientation_scale);
850 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
852 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
854 if( aMarkerTypeCurrent != VTK::MT_USER )
855 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
857 aDlg->setCustomMarker( aMarkerTextureCurrent );
860 QColor color = aDlg->GetColor(1);
861 QColor edgecolor = aDlg->GetColor(2);
862 QColor nodecolor = aDlg->GetColor(3);
863 QColor backfacecolor = aDlg->GetColor(4);
864 QColor color0D = aDlg->GetColor(5);
865 QColor faces_orientation_color = aDlg->GetColor(6);
868 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
870 SALOME_ListIteratorOfListIO It( selected );
871 for( ; It.More(); It.Next()){
872 Handle(SALOME_InteractiveObject) IObject = It.Value();
873 if(IObject->hasEntry()){
874 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
875 /* actor color and backface color */
876 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
877 vtkFloatingPointType (color.green()) / 255.,
878 vtkFloatingPointType (color.blue()) / 255.);
879 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
880 vtkFloatingPointType (backfacecolor.green()) / 255.,
881 vtkFloatingPointType (backfacecolor.blue()) / 255.);
884 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
885 vtkFloatingPointType (edgecolor.green()) / 255.,
886 vtkFloatingPointType (edgecolor.blue()) / 255.);
888 /* Shrink factor and size edges */
889 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
890 anActor->SetLineWidth(aDlg->GetIntValue(1));
892 /* Nodes color and size */
893 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
894 vtkFloatingPointType (nodecolor.green()) / 255.,
895 vtkFloatingPointType (nodecolor.blue()) / 255.);
898 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
899 vtkFloatingPointType (color0D.green()) / 255.,
900 vtkFloatingPointType (color0D.blue()) / 255.);
901 anActor->Set0DSize(aDlg->GetIntValue(3));
903 /* Faces orientation */
904 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
905 vtkFloatingPointType(faces_orientation_color.greenF()),
906 vtkFloatingPointType(faces_orientation_color.blueF())};
907 anActor->SetFacesOrientationColor(c);
908 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
909 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
911 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
912 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
913 int aMarkerTextureNew = aDlg->getCustomMarkerID();
914 if( aMarkerTypeNew != VTK::MT_USER )
915 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
917 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
918 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
919 if( anIter != aMarkerMap.end() )
920 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
923 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
924 if( !aGroupObject->_is_nil() )
926 SMESH::ElementType anElementType = aGroupObject->GetType();
928 switch( anElementType )
930 case SMESH::NODE: aColor = nodecolor; break;
931 case SMESH::EDGE: aColor = edgecolor; break;
932 default: aColor = color; break;
935 SALOMEDS::Color aGroupColor;
936 aGroupColor.R = (float)aColor.red() / 255.0;
937 aGroupColor.G = (float)aColor.green() / 255.0;
938 aGroupColor.B = (float)aColor.blue() / 255.0;
939 aGroupObject->SetColor( aGroupColor );
944 SMESH::RepaintCurrentView();
950 SALOME_ListIteratorOfListIO It( selected );
951 for( ; It.More(); It.Next()){
952 Handle(SALOME_InteractiveObject) IObject = It.Value();
953 if(IObject->hasEntry()){
954 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
955 switch(theCommandID){
957 anActor->SetRepresentation(SMESH_Actor::eEdge);
960 anActor->SetRepresentation(SMESH_Actor::eSurface);
963 if(anActor->IsShrunk())
966 anActor->SetShrink();
969 anActor->SetRepresentation(SMESH_Actor::ePoint);
972 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
973 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
976 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
977 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
983 SMESH::RepaintCurrentView();
987 void Control( int theCommandID )
989 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
990 SALOME_ListIO selected;
992 aSel->selectedObjects( selected );
994 if( !selected.IsEmpty() ){
995 Handle(SALOME_InteractiveObject) anIO = selected.First();
998 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
999 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1000 switch ( theCommandID ){
1002 aTitle = QObject::tr( "LENGTH_EDGES" );
1003 aControl = SMESH_Actor::eLength;
1006 aTitle = QObject::tr( "LENGTH2D_EDGES" );
1007 aControl = SMESH_Actor::eLength2D;
1010 aTitle = QObject::tr( "FREE_EDGES" );
1011 aControl = SMESH_Actor::eFreeEdges;
1014 aTitle = QObject::tr( "FREE_BORDERS" );
1015 aControl = SMESH_Actor::eFreeBorders;
1018 aTitle = QObject::tr( "MULTI_BORDERS" );
1019 aControl = SMESH_Actor::eMultiConnection;
1022 aTitle = QObject::tr( "FREE_NODES" );
1023 aControl = SMESH_Actor::eFreeNodes;
1026 aTitle = QObject::tr( "MULTI2D_BORDERS" );
1027 aControl = SMESH_Actor::eMultiConnection2D;
1030 aTitle = QObject::tr( "AREA_ELEMENTS" );
1031 aControl = SMESH_Actor::eArea;
1034 aTitle = QObject::tr( "TAPER_ELEMENTS" );
1035 aControl = SMESH_Actor::eTaper;
1038 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1039 aControl = SMESH_Actor::eAspectRatio;
1042 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1043 aControl = SMESH_Actor::eAspectRatio3D;
1046 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1047 aControl = SMESH_Actor::eMinimumAngle;
1050 aTitle = QObject::tr( "WARP_ELEMENTS" );
1051 aControl = SMESH_Actor::eWarping;
1054 aTitle = QObject::tr( "SKEW_ELEMENTS" );
1055 aControl = SMESH_Actor::eSkew;
1058 aTitle = QObject::tr( "SMESH_VOLUME" );
1059 aControl = SMESH_Actor::eVolume3D;
1062 aTitle = QObject::tr( "FREE_FACES" );
1063 aControl = SMESH_Actor::eFreeFaces;
1066 anActor->SetControlMode(aControl);
1067 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
1068 SMESH::RepaintCurrentView();
1075 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1076 MeshObjectType theType,
1077 const QString theInTypeName,
1078 QString & theOutTypeName)
1080 SMESH_TypeFilter aTypeFilter( theType );
1082 if( !theIO.IsNull() )
1084 entry = theIO->getEntry();
1085 LightApp_DataOwner owner( entry );
1086 if ( aTypeFilter.isOk( &owner )) {
1087 theOutTypeName = theInTypeName;
1095 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1097 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1098 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1100 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1101 CORBA::String_var anID = aSComp->GetID().c_str();
1102 if (!strcmp(anID.in(),theIO->getEntry()))
1108 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1109 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1110 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1111 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1112 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1120 QString CheckHomogeneousSelection()
1122 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1123 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1124 SALOME_ListIO selected;
1126 aSel->selectedObjects( selected );
1128 QString RefType = CheckTypeObject(selected.First());
1129 SALOME_ListIteratorOfListIO It(selected);
1130 for ( ; It.More(); It.Next())
1132 Handle(SALOME_InteractiveObject) IObject = It.Value();
1133 QString Type = CheckTypeObject(IObject);
1134 if (Type.compare(RefType) != 0)
1135 return "Heterogeneous Selection";
1142 void SMESHGUI::OnEditDelete()
1144 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1145 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1146 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1148 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1149 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1150 _PTR(GenericAttribute) anAttr;
1151 _PTR(AttributeIOR) anIOR;
1153 int objectCount = 0;
1155 QString aParentComponent = QString::null;
1156 Handle(SALOME_InteractiveObject) anIO;
1157 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1159 anIO = anIt.Value();
1160 QString cur = anIO->getComponentDataType();
1161 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1163 // check if object is reference
1164 _PTR(SObject) aRefSObj;
1165 aNameList.append("\n - ");
1166 if ( aSO->ReferencedObject( aRefSObj ) ) {
1167 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1168 aNameList.append( aRefName );
1169 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1172 aNameList.append(anIO->getName());
1176 if( aParentComponent.isNull() )
1177 aParentComponent = cur;
1178 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1179 aParentComponent = "";
1182 if ( objectCount == 0 )
1183 return; // No Valid Objects Selected
1185 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1186 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1187 QObject::tr("ERR_ERROR"),
1188 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1191 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1192 if (SUIT_MessageBox::warning
1193 (SMESHGUI::desktop(),
1194 QObject::tr("SMESH_WRN_WARNING"),
1195 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1196 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1197 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1200 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1201 SUIT_ViewManager* vm = anApp->activeViewManager();
1202 int nbSf = vm->getViewsCount();
1204 SALOME_ListIteratorOfListIO It(selected);
1206 aStudyBuilder->NewCommand(); // There is a transaction
1207 for( ; It.More(); It.Next()){ // loop on selected IO's
1208 Handle(SALOME_InteractiveObject) IObject = It.Value();
1209 if(IObject->hasEntry()) {
1210 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1212 // disable removal of "SMESH" component object
1213 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1215 if ( engineIOR() == anIOR->Value().c_str() )
1218 //Check the referenced object
1219 _PTR(SObject) aRefSObject;
1220 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1221 aSO = aRefSObject; // Delete main Object instead of reference
1223 // put the whole hierarchy of sub-objects of the selected SO into a list and
1224 // then treat them all starting from the deepest objects (at list back)
1226 std::list< _PTR(SObject) > listSO;
1227 listSO.push_back( aSO );
1228 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1229 for ( ; itSO != listSO.end(); ++itSO ) {
1230 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1231 for (it->InitEx(false); it->More(); it->Next())
1232 listSO.push_back( it->Value() );
1235 // treat SO's in the list starting from the back
1237 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1238 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1239 _PTR(SObject) SO = *ritSO;
1240 if ( !SO ) continue;
1241 std::string anEntry = SO->GetID();
1243 /** Erase graphical object **/
1244 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1245 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1246 for(int i = 0; i < nbSf; i++){
1247 SUIT_ViewWindow *sf = aViews[i];
1248 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1249 SMESH::RemoveActor(sf,anActor);
1254 /** Remove an object from data structures **/
1255 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1256 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1257 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1258 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1259 aMesh->RemoveGroup( aGroup );
1261 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1262 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1263 aMesh->RemoveSubMesh( aSubMesh );
1265 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1267 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1270 IObject = new SALOME_InteractiveObject
1271 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1272 QString objType = CheckTypeObject(IObject);
1273 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1274 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1275 aStudyBuilder->RemoveObjectWithChildren( SO );
1277 else {// default action: remove SObject from the study
1278 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1279 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1281 aStudyBuilder->RemoveObjectWithChildren( SO );
1285 } /* listSO back loop */
1286 } /* IObject->hasEntry() */
1288 aStudyBuilder->CommitCommand();
1290 /* Clear any previous selection */
1292 aSel->setSelectedObjects( l1 );
1294 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1299 SMESHGUI_EXPORT CAM_Module* createModule()
1301 return new SMESHGUI();
1305 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1307 //=============================================================================
1311 //=============================================================================
1312 SMESHGUI::SMESHGUI() :
1313 SalomeApp_Module( "SMESH" ),
1314 LightApp_Module( "SMESH" )
1316 if ( CORBA::is_nil( myComponentSMESH ) )
1318 CORBA::Boolean anIsEmbeddedMode;
1319 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1321 // 0019923: EDF 765 SMESH : default values of hypothesis
1322 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1323 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1324 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1325 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1326 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1329 myActiveDialogBox = 0;
1330 myFilterLibraryDlg = 0;
1334 SMESH::GetFilterManager();
1335 SMESH::GetPattern();
1337 /* load resources for all available meshers */
1338 SMESH::InitAvailableHypotheses();
1341 //=============================================================================
1345 //=============================================================================
1346 SMESHGUI::~SMESHGUI()
1348 #ifdef WITHGENERICOBJ
1349 SMESH::GetFilterManager()->Destroy();
1351 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1354 //=============================================================================
1358 //=============================================================================
1359 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1361 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1363 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1368 bool SMESHGUI::automaticUpdate()
1370 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1374 return resMgr->booleanValue( "SMESH", "auto_update", false );
1377 //=============================================================================
1381 //=============================================================================
1382 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1384 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1387 //=============================================================================
1391 //=============================================================================
1392 SMESHGUI* SMESHGUI::GetSMESHGUI()
1394 SMESHGUI* smeshMod = 0;
1395 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1398 CAM_Module* module = app->module( "Mesh" );
1399 smeshMod = dynamic_cast<SMESHGUI*>( module );
1402 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1404 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1407 _PTR(Study) aStudy = study->studyDS();
1409 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1418 Standard_EXPORT SMESHGUI* GetComponentGUI()
1420 return SMESHGUI::GetSMESHGUI();
1424 //=============================================================================
1428 //=============================================================================
1429 void SMESHGUI::SetState(int aState)
1434 //=============================================================================
1438 //=============================================================================
1439 void SMESHGUI::ResetState()
1444 //=============================================================================
1448 //=============================================================================
1449 void SMESHGUI::EmitSignalDeactivateDialog()
1451 emit SignalDeactivateActiveDialog();
1454 //=============================================================================
1458 //=============================================================================
1459 void SMESHGUI::EmitSignalStudyFrameChanged()
1461 emit SignalStudyFrameChanged();
1464 //=============================================================================
1468 //=============================================================================
1469 void SMESHGUI::EmitSignalCloseAllDialogs()
1471 emit SignalCloseAllDialogs();
1474 //=============================================================================
1478 //=============================================================================
1479 void SMESHGUI::EmitSignalVisibilityChanged()
1481 emit SignalVisibilityChanged();
1484 //=============================================================================
1488 //=============================================================================
1489 QDialog *SMESHGUI::GetActiveDialogBox()
1491 return myActiveDialogBox;
1494 //=============================================================================
1498 //=============================================================================
1499 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1501 myActiveDialogBox = (QDialog *) aDlg;
1505 //=============================================================================
1509 //=============================================================================
1510 SUIT_Desktop* SMESHGUI::desktop()
1512 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1514 return app->desktop();
1519 //=============================================================================
1523 //=============================================================================
1524 SalomeApp_Study* SMESHGUI::activeStudy()
1526 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1528 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1533 //=============================================================================
1537 //=============================================================================
1538 void SMESHGUI::Modified( bool theIsUpdateActions )
1540 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1541 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1542 appStudy->Modified();
1543 if( theIsUpdateActions )
1544 app->updateActions();
1549 //=============================================================================
1553 //=============================================================================
1554 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1556 /* Here the position is on the bottom right corner - 10 */
1557 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1559 SUIT_Desktop *PP = desktop();
1560 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1561 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1565 //=============================================================================
1569 //=============================================================================
1570 static int isStudyLocked(_PTR(Study) theStudy){
1571 return theStudy->GetProperties()->IsLocked();
1574 static bool checkLock(_PTR(Study) theStudy) {
1575 if (isStudyLocked(theStudy)) {
1576 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1577 QObject::tr("WRN_WARNING"),
1578 QObject::tr("WRN_STUDY_LOCKED") );
1584 //=======================================================================
1585 //function : CheckActiveStudyLocked
1587 //=======================================================================
1589 bool SMESHGUI::isActiveStudyLocked()
1591 _PTR(Study) aStudy = activeStudy()->studyDS();
1592 return checkLock( aStudy );
1595 //=============================================================================
1599 //=============================================================================
1600 bool SMESHGUI::OnGUIEvent( int theCommandID )
1602 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1606 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1607 SUIT_ResourceMgr* mgr = resourceMgr();
1611 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1612 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1615 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1616 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1618 //QAction* act = action( theCommandID );
1620 switch (theCommandID) {
1622 if(checkLock(aStudy)) break;
1630 if(checkLock(aStudy)) break;
1631 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1635 case 150: //MED FILE INFORMATION
1637 SALOME_ListIO selected;
1638 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1640 aSel->selectedObjects( selected );
1641 if( selected.Extent() )
1643 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1644 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1645 if ( !aMesh->_is_nil() )
1647 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1654 case 122: // EXPORT MED
1663 ::ExportMeshToFile(theCommandID);
1667 case 200: // SCALAR BAR
1669 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1670 SALOME_ListIO selected;
1672 aSel->selectedObjects( selected );
1674 if( selected.Extent() ) {
1675 Handle(SALOME_InteractiveObject) anIO = selected.First();
1676 if( anIO->hasEntry() ) {
1677 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1678 anActor->SetControlMode( SMESH_Actor::eNone );
1686 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1696 ::DisableAutoColor();
1699 case 1134: // Clipping
1700 case 1133: // Tranparency
1701 case 1132: // Colors / Size
1708 ::SetDisplayMode(theCommandID, myMarkerMap);
1711 //2D quadratic representation
1714 ::SetDisplayMode(theCommandID, myMarkerMap);
1718 case 216: // 0D elements
1721 case 219: // Volumes
1722 case 220: // All Entity
1723 ::SetDisplayEntity(theCommandID);
1726 case 221: // Orientation of faces
1728 LightApp_SelectionMgr* mgr = selectionMgr();
1729 SALOME_ListIO selected; mgr->selectedObjects( selected );
1731 SALOME_ListIteratorOfListIO it(selected);
1732 for( ; it.More(); it.Next()) {
1733 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1734 if(anIObject->hasEntry()) {
1735 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1736 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1745 if(checkLock(aStudy)) break;
1747 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1750 SMESH::UpdateView();
1752 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1753 SMESH::OnVisuException();
1755 catch (...) { // PAL16774 (Crash after display of many groups)
1756 SMESH::OnVisuException();
1760 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1761 aSel->selectedObjects( l );
1762 aSel->setSelectedObjects( l );
1767 case 301: // DISPLAY
1768 case 302: // DISPLAY ONLY
1770 SMESH::EDisplaing anAction;
1771 switch (theCommandID) {
1772 case 300: anAction = SMESH::eErase; break;
1773 case 301: anAction = SMESH::eDisplay; break;
1774 case 302: anAction = SMESH::eDisplayOnly; break;
1777 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1778 SALOME_ListIO sel_objects, to_process;
1780 aSel->selectedObjects( sel_objects );
1782 if( theCommandID==302 )
1783 startOperation( myEraseAll );
1785 extractContainers( sel_objects, to_process );
1788 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1792 SALOME_ListIteratorOfListIO It( to_process );
1793 for ( ; It.More(); It.Next()) {
1794 Handle(SALOME_InteractiveObject) IOS = It.Value();
1795 if (IOS->hasEntry()) {
1796 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1797 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1798 break; // PAL16774 (Crash after display of many groups)
1800 if (anAction == SMESH::eDisplayOnly)
1801 anAction = SMESH::eDisplay;
1806 // PAL13338 + PAL15161 -->
1807 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1808 SMESH::UpdateView();
1809 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1811 // PAL13338 + PAL15161 <--
1813 catch (...) { // PAL16774 (Crash after display of many groups)
1814 SMESH::OnVisuException();
1817 if (anAction == SMESH::eErase) {
1819 aSel->setSelectedObjects( l1 );
1822 aSel->setSelectedObjects( to_process );
1829 if(checkLock(aStudy)) break;
1832 EmitSignalDeactivateDialog();
1834 ( new SMESHGUI_NodesDlg( this ) )->show();
1837 SUIT_MessageBox::warning(desktop(),
1838 tr("SMESH_WRN_WARNING"),
1839 tr("SMESH_WRN_VIEWER_VTK"));
1844 case 2151: // FILTER
1848 EmitSignalDeactivateDialog();
1849 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1854 case 701: // COMPUTE MESH
1855 case 711: // PRECOMPUTE MESH
1856 case 712: // EVALUATE MESH
1857 case 713: // MESH ORDER
1859 if (checkLock(aStudy)) break;
1860 startOperation( theCommandID );
1864 case 702: // Create mesh
1865 case 703: // Create sub-mesh
1866 case 704: // Edit mesh/sub-mesh
1867 startOperation( theCommandID );
1869 case 710: // Build compound mesh
1871 if (checkLock(aStudy)) break;
1872 EmitSignalDeactivateDialog();
1873 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1877 case 407: // DIAGONAL INVERSION
1878 case 408: // Delete diagonal
1882 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1883 tr( "NOT_A_VTK_VIEWER" ) );
1887 if ( checkLock( aStudy ) )
1890 /*Standard_Boolean aRes;
1891 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1892 if ( aMesh->_is_nil() )
1894 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1895 tr( "SMESH_BAD_SELECTION" ) );
1899 EmitSignalDeactivateDialog();
1900 if ( theCommandID == 407 )
1901 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1903 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1906 case 409: // Change orientation
1907 case 410: // Union of triangles
1908 case 411: // Cutting of quadrangles
1909 case 419: // Splitting volumes into tetrahedra
1913 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1914 tr( "NOT_A_VTK_VIEWER" ) );
1918 if ( checkLock( aStudy ) )
1921 EmitSignalDeactivateDialog();
1922 SMESHGUI_MultiEditDlg* aDlg = NULL;
1923 if ( theCommandID == 409 )
1924 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1925 else if ( theCommandID == 410 )
1926 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1927 else if ( theCommandID == 419 )
1928 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
1930 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1935 case 412: // Smoothing
1937 if(checkLock(aStudy)) break;
1939 EmitSignalDeactivateDialog();
1940 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1943 SUIT_MessageBox::warning(desktop(),
1944 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1948 case 413: // Extrusion
1950 if (checkLock(aStudy)) break;
1952 EmitSignalDeactivateDialog();
1953 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1955 SUIT_MessageBox::warning(desktop(),
1956 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1960 case 414: // Revolution
1962 if(checkLock(aStudy)) break;
1964 EmitSignalDeactivateDialog();
1965 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1968 SUIT_MessageBox::warning(desktop(),
1969 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1973 case 415: // Pattern mapping
1975 if ( checkLock( aStudy ) )
1979 EmitSignalDeactivateDialog();
1980 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1983 SUIT_MessageBox::warning(desktop(),
1984 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1988 case 416: // Extrusion along a path
1990 if (checkLock(aStudy)) break;
1992 EmitSignalDeactivateDialog();
1993 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1995 SUIT_MessageBox::warning(desktop(),
1996 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2000 case 417: // Convert mesh to quadratic
2002 startOperation( 417 );
2003 /* if (checkLock(aStudy)) break;
2005 EmitSignalDeactivateDialog();
2006 new SMESHGUI_ConvToQuadDlg();
2008 SUIT_MessageBox::warning(desktop(),
2009 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2013 case 418: // create 2D mesh from 3D
2015 startOperation( 418 );
2018 case 806: // CREATE GEO GROUP
2020 startOperation( 806 );
2023 case 801: // CREATE GROUP
2027 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2028 tr( "NOT_A_VTK_VIEWER" ) );
2032 if(checkLock(aStudy)) break;
2033 EmitSignalDeactivateDialog();
2034 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2036 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2037 SALOME_ListIO selected;
2039 aSel->selectedObjects( selected );
2041 int nbSel = selected.Extent();
2043 // check if mesh is selected
2044 aMesh = SMESH::GetMeshByIO( selected.First() );
2046 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2051 case 802: // CONSTRUCT GROUP
2055 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2056 tr( "NOT_A_VTK_VIEWER" ) );
2060 if(checkLock(aStudy)) break;
2061 EmitSignalDeactivateDialog();
2063 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2064 SALOME_ListIO selected;
2066 aSel->selectedObjects( selected );
2068 int nbSel = selected.Extent();
2070 // check if submesh is selected
2071 Handle(SALOME_InteractiveObject) IObject = selected.First();
2072 if (IObject->hasEntry()) {
2073 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2075 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2076 if (!aSubMesh->_is_nil()) {
2078 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2079 // get submesh elements list by types
2080 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2081 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2082 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2083 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2084 // create group for each type o elements
2085 QString aName = IObject->getName();
2086 if (aNodes->length() > 0) {
2087 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2088 aGroup->Add(aNodes.inout());
2090 if (aEdges->length() > 0) {
2091 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2092 aGroup->Add(aEdges.inout());
2094 if (aFaces->length() > 0) {
2095 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2096 aGroup->Add(aFaces.inout());
2098 if (aVolumes->length() > 0) {
2099 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2100 aGroup->Add(aVolumes.inout());
2105 catch(const SALOME::SALOME_Exception & S_ex){
2106 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2113 SUIT_MessageBox::warning(desktop(),
2114 tr("SMESH_WRN_WARNING"),
2115 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2120 case 803: // EDIT GROUP
2124 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2125 tr( "NOT_A_VTK_VIEWER" ) );
2129 if(checkLock(aStudy)) break;
2130 EmitSignalDeactivateDialog();
2132 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2133 SALOME_ListIO selected;
2135 aSel->selectedObjects( selected );
2137 SALOME_ListIteratorOfListIO It (selected);
2138 int nbSelectedGroups = 0;
2139 for ( ; It.More(); It.Next() )
2141 SMESH::SMESH_GroupBase_var aGroup =
2142 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2143 if (!aGroup->_is_nil()) {
2145 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2149 if (nbSelectedGroups == 0)
2151 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2157 case 804: // Add elements to group
2159 if(checkLock(aStudy)) break;
2160 if (myState == 800) {
2161 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2162 if (aDlg) aDlg->onAdd();
2167 case 805: // Remove elements from group
2169 if(checkLock(aStudy)) break;
2170 if (myState == 800) {
2171 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2172 if (aDlg) aDlg->onRemove();
2177 case 815: // Edit GEOM GROUP as standalone
2181 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2182 tr( "NOT_A_VTK_VIEWER" ) );
2186 if(checkLock(aStudy)) break;
2187 EmitSignalDeactivateDialog();
2189 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2190 SALOME_ListIO selected;
2192 aSel->selectedObjects( selected );
2194 SALOME_ListIteratorOfListIO It (selected);
2195 for ( ; It.More(); It.Next() )
2197 SMESH::SMESH_GroupOnGeom_var aGroup =
2198 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2199 if (!aGroup->_is_nil()) {
2200 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2207 case 810: // Union Groups
2208 case 811: // Intersect groups
2209 case 812: // Cut groups
2213 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2214 tr( "NOT_A_VTK_VIEWER" ) );
2218 if ( checkLock( aStudy ) )
2221 EmitSignalDeactivateDialog();
2223 SMESHGUI_GroupOpDlg* aDlg = 0;
2224 if ( theCommandID == 810 )
2225 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2226 else if ( theCommandID == 811 )
2227 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2229 aDlg = new SMESHGUI_CutGroupsDlg( this );
2236 case 814: // Create groups of entities from existing groups of superior dimensions
2238 if ( checkLock( aStudy ) )
2241 EmitSignalDeactivateDialog();
2242 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2248 case 813: // Delete groups with their contents
2252 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2253 tr( "NOT_A_VTK_VIEWER" ) );
2257 if ( checkLock( aStudy ) )
2260 EmitSignalDeactivateDialog();
2262 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2266 case 900: // MESH INFOS
2268 EmitSignalDeactivateDialog();
2269 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2270 SALOME_ListIO selected;
2272 aSel->selectedObjects( selected );
2274 if ( selected.Extent() > 1 ) { // a dlg for each IO
2276 SALOME_ListIteratorOfListIO It (selected);
2277 for ( ; It.More(); It.Next() ) {
2278 IOs.Clear(); IOs.Append( It.Value() );
2279 aSel->setSelectedObjects( IOs );
2280 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2282 // restore selection
2283 aSel->setSelectedObjects( selected );
2286 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2290 case 902: // STANDARD MESH INFOS
2292 EmitSignalDeactivateDialog();
2293 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2294 SALOME_ListIO selected;
2296 aSel->selectedObjects( selected );
2298 if ( selected.Extent() > 1 ) { // a dlg for each IO
2300 SALOME_ListIteratorOfListIO It (selected);
2301 for ( ; It.More(); It.Next() ) {
2303 IOs.Append( It.Value() );
2304 aSel->setSelectedObjects( IOs );
2305 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2307 // restore selection
2308 aSel->setSelectedObjects( selected );
2311 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2315 case 903: // WHAT IS
2317 EmitSignalDeactivateDialog();
2318 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2322 case 904: // FIND ELEM
2324 startOperation( theCommandID );
2328 case 1100: // EDIT HYPOTHESIS
2330 if(checkLock(aStudy)) break;
2332 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2333 SALOME_ListIO selected;
2335 aSel->selectedObjects( selected );
2337 int nbSel = selected.Extent();
2340 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2341 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2343 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2344 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2345 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2346 if ( !aHypothesis->_is_nil() )
2349 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2350 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2352 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2363 case 1101: // RENAME
2365 if ( checkLock( aStudy ) )
2368 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2369 SALOME_ListIO selected;
2371 aSel->selectedObjects( selected );
2373 bool isAny = false; // is there any appropriate object selected
2375 SALOME_ListIteratorOfListIO It( selected );
2376 for ( ; It.More(); It.Next() )
2378 Handle(SALOME_InteractiveObject) IObject = It.Value();
2379 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2380 _PTR(GenericAttribute) anAttr;
2381 _PTR(AttributeName) aName;
2384 if ( obj->FindAttribute(anAttr, "AttributeName") )
2387 QString newName = QString(aName->Value().c_str());
2389 // check type to prevent renaming of inappropriate objects
2390 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2391 if (aType == MESH || aType == GROUP ||
2392 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2393 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2394 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2395 aType == HYPOTHESIS || aType == ALGORITHM)
2398 newName = LightApp_NameDlg::getName(desktop(), newName);
2399 if ( !newName.isEmpty() )
2401 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2403 // update name of group object and its actor
2404 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2405 if( !aGroupObject->_is_nil() )
2407 aGroupObject->SetName( newName.toLatin1().data() );
2408 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2409 anActor->setName( newName.toLatin1().data() );
2420 SUIT_MessageBox::warning(desktop(),
2421 QObject::tr("SMESH_WRN_WARNING"),
2422 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2427 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2429 if(checkLock(aStudy)) break;
2430 SUIT_OverrideCursor wc;
2432 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2433 SALOME_ListIO selected;
2435 aSel->selectedObjects( selected, QString::null, false );
2437 SALOME_ListIteratorOfListIO It(selected);
2438 for (int i = 0; It.More(); It.Next(), i++) {
2439 Handle(SALOME_InteractiveObject) IObject = It.Value();
2440 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2443 aSel->setSelectedObjects( l1 );
2448 case 4009: // ELEM0D
2449 case 4010: // GEOM::EDGE
2450 case 4021: // TRIANGLE
2452 case 4023: // POLYGON
2456 if(checkLock(aStudy)) break;
2458 EmitSignalDeactivateDialog();
2459 SMDSAbs_ElementType type = SMDSAbs_Edge;
2461 switch (theCommandID) {
2462 case 4009: // ELEM0D
2463 type = SMDSAbs_0DElement; nbNodes = 1; break;
2464 case 4021: // TRIANGLE
2465 type = SMDSAbs_Face; nbNodes = 3; break;
2467 type = SMDSAbs_Face; nbNodes = 4; break;
2469 type = SMDSAbs_Volume; nbNodes = 4; break;
2470 case 4023: // POLYGON
2471 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2473 type = SMDSAbs_Volume; nbNodes = 8; break;
2474 case 4033: // POLYHEDRE
2475 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2478 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2481 SUIT_MessageBox::warning(desktop(),
2482 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2486 case 4033: // POLYHEDRON
2488 if(checkLock(aStudy)) break;
2490 EmitSignalDeactivateDialog();
2491 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2494 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2495 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2499 case 4034: // QUADRATIC EDGE
2500 case 4035: // QUADRATIC TRIANGLE
2501 case 4036: // QUADRATIC QUADRANGLE
2502 case 4037: // QUADRATIC TETRAHEDRON
2503 case 4038: // QUADRATIC PYRAMID
2504 case 4039: // QUADRATIC PENTAHEDRON
2505 case 4040: // QUADRATIC HEXAHEDRON
2507 if(checkLock(aStudy)) break;
2509 EmitSignalDeactivateDialog();
2512 switch (theCommandID) {
2514 type = QUAD_EDGE; break;
2516 type = QUAD_TRIANGLE; break;
2518 type = QUAD_QUADRANGLE; break;
2520 type = QUAD_TETRAHEDRON; break;
2522 type = QUAD_PYRAMID; break;
2524 type = QUAD_PENTAHEDRON; break;
2526 type = QUAD_HEXAHEDRON;
2530 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2533 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2534 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2538 case 4041: // REMOVES NODES
2540 if(checkLock(aStudy)) break;
2542 EmitSignalDeactivateDialog();
2543 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2546 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2547 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2551 case 4042: // REMOVES ELEMENTS
2553 if(checkLock(aStudy)) break;
2555 EmitSignalDeactivateDialog();
2556 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2560 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2561 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2565 case 4043: { // CLEAR_MESH
2567 if(checkLock(aStudy)) break;
2569 SALOME_ListIO selected;
2570 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2571 aSel->selectedObjects( selected );
2573 SUIT_OverrideCursor wc;
2574 SALOME_ListIteratorOfListIO It (selected);
2575 for ( ; It.More(); It.Next() )
2577 Handle(SALOME_InteractiveObject) IOS = It.Value();
2578 SMESH::SMESH_Mesh_var aMesh =
2579 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2580 if ( aMesh->_is_nil()) continue;
2582 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2584 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2585 SMESH::ModifiedMesh( aMeshSObj, false, true);
2586 // hide groups and submeshes
2587 _PTR(ChildIterator) anIter =
2588 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2589 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2591 _PTR(SObject) so = anIter->Value();
2592 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2595 catch (const SALOME::SALOME_Exception& S_ex){
2597 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2601 SMESH::UpdateView();
2605 case 4044: // REMOVE ORPHAN NODES
2607 if(checkLock(aStudy)) break;
2608 SALOME_ListIO selected;
2609 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2610 aSel->selectedObjects( selected );
2611 if ( selected.Extent() == 1 ) {
2612 Handle(SALOME_InteractiveObject) anIO = selected.First();
2613 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2614 if ( !aMesh->_is_nil() ) {
2615 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2616 tr( "SMESH_WARNING" ),
2617 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2618 SUIT_MessageBox::Yes |
2619 SUIT_MessageBox::No,
2620 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2623 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2624 int removed = aMeshEditor->RemoveOrphanNodes();
2625 SUIT_MessageBox::information(SMESHGUI::desktop(),
2626 tr("SMESH_INFORMATION"),
2627 tr("NB_NODES_REMOVED").arg(removed));
2628 if ( removed > 0 ) {
2629 SMESH::UpdateView();
2630 SMESHGUI::Modified();
2633 catch (const SALOME::SALOME_Exception& S_ex) {
2634 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2643 case 4051: // RENUMBERING NODES
2645 if(checkLock(aStudy)) break;
2647 EmitSignalDeactivateDialog();
2648 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2652 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2653 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2657 case 4052: // RENUMBERING ELEMENTS
2659 if(checkLock(aStudy)) break;
2661 EmitSignalDeactivateDialog();
2662 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2666 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2667 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2671 case 4061: // TRANSLATION
2673 if(checkLock(aStudy)) break;
2675 EmitSignalDeactivateDialog();
2676 ( new SMESHGUI_TranslationDlg( this ) )->show();
2679 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2680 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2684 case 4062: // ROTATION
2686 if(checkLock(aStudy)) break;
2688 EmitSignalDeactivateDialog();
2689 ( new SMESHGUI_RotationDlg( this ) )->show();
2692 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2693 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2697 case 4063: // SYMMETRY
2699 if(checkLock(aStudy)) break;
2701 EmitSignalDeactivateDialog();
2702 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2705 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2706 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2710 case 4064: // SEWING
2712 if(checkLock(aStudy)) break;
2714 EmitSignalDeactivateDialog();
2715 ( new SMESHGUI_SewingDlg( this ) )->show();
2718 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2719 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2723 case 4065: // MERGE NODES
2725 if(checkLock(aStudy)) break;
2727 EmitSignalDeactivateDialog();
2728 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2731 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2732 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2736 case 4066: // MERGE EQUAL ELEMENTS
2738 if (checkLock(aStudy)) break;
2740 EmitSignalDeactivateDialog();
2741 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2743 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2744 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2749 case 4067: // MAKE MESH PASS THROUGH POINT
2750 startOperation( 4067 );
2755 if(checkLock(aStudy)) break;
2757 EmitSignalDeactivateDialog();
2758 ( new SMESHGUI_ScaleDlg( this ) )->show();
2761 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2762 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2767 case 4069: // DUPLICATE NODES
2769 if(checkLock(aStudy)) break;
2771 EmitSignalDeactivateDialog();
2772 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2775 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2776 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2781 case 5105: // Library of selection filters
2783 static QList<int> aTypes;
2784 if ( aTypes.isEmpty() )
2786 aTypes.append( SMESH::NODE );
2787 aTypes.append( SMESH::EDGE );
2788 aTypes.append( SMESH::FACE );
2789 aTypes.append( SMESH::VOLUME );
2791 if (!myFilterLibraryDlg)
2792 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2793 else if (myFilterLibraryDlg->isHidden())
2794 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2795 myFilterLibraryDlg->raise();
2799 case 6017: // CONTROLS
2817 LightApp_SelectionMgr* mgr = selectionMgr();
2818 SALOME_ListIO selected; mgr->selectedObjects( selected );
2820 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2821 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2823 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2824 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2825 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2826 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2827 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2828 ::Control( theCommandID );
2833 SUIT_MessageBox::warning(desktop(),
2834 tr( "SMESH_WRN_WARNING" ),
2835 tr( "SMESH_BAD_SELECTION" ) );
2839 SUIT_MessageBox::warning(desktop(),
2840 tr( "SMESH_WRN_WARNING" ),
2841 tr( "NOT_A_VTK_VIEWER" ) );
2846 LightApp_SelectionMgr* mgr = selectionMgr();
2847 SALOME_ListIO selected; mgr->selectedObjects( selected );
2849 SALOME_ListIteratorOfListIO it(selected);
2850 for( ; it.More(); it.Next()) {
2851 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2852 if(anIObject->hasEntry()) {
2853 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2854 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2862 LightApp_SelectionMgr* mgr = selectionMgr();
2863 SALOME_ListIO selected; mgr->selectedObjects( selected );
2865 SALOME_ListIteratorOfListIO it(selected);
2866 for( ; it.More(); it.Next()) {
2867 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2868 if(anIObject->hasEntry())
2869 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2870 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2877 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2878 //updateObjBrowser();
2882 //=============================================================================
2886 //=============================================================================
2887 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2892 //=============================================================================
2896 //=============================================================================
2897 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2902 //=============================================================================
2906 //=============================================================================
2907 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2912 //=============================================================================
2913 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2914 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2916 //=============================================================================
2917 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2918 SUIT_ViewWindow* wnd )
2920 if(theIO->hasEntry()){
2921 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2922 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2926 //=======================================================================
2927 // function : createSMESHAction
2929 //=======================================================================
2930 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
2931 const int key, const bool toggle, const QString& shortcutAction )
2934 QWidget* parent = application()->desktop();
2935 SUIT_ResourceMgr* resMgr = resourceMgr();
2937 if ( !icon_id.isEmpty() )
2938 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2940 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2941 if ( !pix.isNull() )
2942 icon = QIcon( pix );
2944 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2945 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2946 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2948 createAction( id, tooltip, icon, menu, status_bar, key, parent,
2949 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
2952 //=======================================================================
2953 // function : createPopupItem
2955 //=======================================================================
2956 void SMESHGUI::createPopupItem( const int id,
2957 const QString& clients,
2958 const QString& types,
2959 const QString& theRule,
2964 parentId = popupMgr()->actionId( action( pId ) );
2966 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2967 popupMgr()->insert( action( id ), parentId, 0 );
2969 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2970 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2971 QString rule = "(%1) and (%2) and (%3)";
2972 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2973 if( clients.isEmpty() )
2974 rule = rule.arg( QString( "true" ) );
2976 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2977 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2980 bool cont = myRules.contains( id );
2982 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2984 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2985 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2988 //=======================================================================
2989 // function : initialize
2991 //=======================================================================
2992 void SMESHGUI::initialize( CAM_Application* app )
2994 SalomeApp_Module::initialize( app );
2996 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2998 /* Automatic Update flag */
2999 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3001 // ----- create actions --------------
3003 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3004 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3005 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3006 createSMESHAction( 114, "NUM" );
3007 createSMESHAction( 121, "DAT" );
3008 createSMESHAction( 122, "MED" );
3009 createSMESHAction( 123, "UNV" );
3010 createSMESHAction( 140, "STL" );
3011 createSMESHAction( 124, "EXPORT_DAT" );
3012 createSMESHAction( 125, "EXPORT_MED" );
3013 createSMESHAction( 126, "EXPORT_UNV" );
3014 createSMESHAction( 141, "EXPORT_STL" );
3015 createSMESHAction( 150, "FILE_INFO" );
3016 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3017 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3018 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3019 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3020 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3021 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3022 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3023 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3024 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3025 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3026 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3027 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3028 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3029 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3030 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3031 createSMESHAction( 804, "ADD" );
3032 createSMESHAction( 805, "REMOVE" );
3033 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3034 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3035 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3036 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3037 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3038 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3039 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3040 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3041 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3042 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3043 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3044 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3045 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3046 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3047 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3048 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3049 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3050 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3051 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3052 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3053 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3054 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3055 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3056 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3057 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3058 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3059 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3060 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3061 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3062 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3063 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3064 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3065 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3066 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3067 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3068 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3069 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3070 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3071 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3072 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3073 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3074 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3075 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3076 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3077 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3078 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3079 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3080 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3081 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3082 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3083 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3084 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3085 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3086 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3087 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3088 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3089 createSMESHAction( 415, "MAP", "ICON_MAP" );
3090 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3091 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3092 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3093 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3094 createSMESHAction( 200, "RESET" );
3095 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3096 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3097 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3098 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3099 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3100 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3101 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3102 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3103 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3104 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3105 createSMESHAction( 220, "ALL" );
3106 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3108 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3109 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3111 createSMESHAction( 1100, "EDIT_HYPO" );
3112 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3113 createSMESHAction( 1102, "UNASSIGN" );
3114 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3115 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3116 createSMESHAction( 1131, "DISPMODE" );
3117 createSMESHAction( 1132, "COLORS" );
3118 createSMESHAction( 1133, "TRANSP" );
3119 createSMESHAction( 1134, "CLIP" );
3120 createSMESHAction( 1135, "DISP_ENT" );
3121 createSMESHAction( 1136, "AUTO_COLOR" );
3122 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3123 createSMESHAction( 2000, "CTRL" );
3125 createSMESHAction( 300, "ERASE" );
3126 createSMESHAction( 301, "DISPLAY" );
3127 createSMESHAction( 302, "DISPLAY_ONLY" );
3128 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3129 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3130 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3131 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3132 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3133 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3134 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3135 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3137 // ----- create menu --------------
3138 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3139 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3140 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3141 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3142 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3143 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3144 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3146 createMenu( separator(), fileId );
3148 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3149 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3150 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3151 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3152 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3153 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3155 createMenu( 111, importId, -1 );
3156 createMenu( 112, importId, -1 );
3157 createMenu( 113, importId, -1 );
3159 createMenu( 121, exportId, -1 );
3160 createMenu( 122, exportId, -1 );
3161 createMenu( 123, exportId, -1 );
3162 createMenu( 140, exportId, -1 ); // export to stl STL
3164 createMenu( separator(), fileId, 10 );
3166 createMenu( 33, editId, -1 );
3168 createMenu( 5105, toolsId, -1 );
3170 createMenu( 702, meshId, -1 ); // "Mesh" menu
3171 createMenu( 703, meshId, -1 );
3172 createMenu( 704, meshId, -1 );
3173 createMenu( 710, meshId, -1 );
3174 createMenu( separator(), meshId, -1 );
3175 createMenu( 701, meshId, -1 );
3176 createMenu( 711, meshId, -1 );
3177 createMenu( 712, meshId, -1 );
3178 createMenu( 713, meshId, -1 );
3179 createMenu( separator(), meshId, -1 );
3180 createMenu( 801, meshId, -1 );
3181 createMenu( 806, meshId, -1 );
3182 createMenu( 802, meshId, -1 );
3183 createMenu( 803, meshId, -1 );
3184 createMenu( 815, meshId, -1 );
3185 createMenu( separator(), meshId, -1 );
3186 createMenu( 810, meshId, -1 );
3187 createMenu( 811, meshId, -1 );
3188 createMenu( 812, meshId, -1 );
3189 createMenu( separator(), meshId, -1 );
3190 createMenu( 814, meshId, -1 );
3191 createMenu( separator(), meshId, -1 );
3192 createMenu( 813, meshId, -1 );
3193 createMenu( separator(), meshId, -1 );
3194 createMenu( 900, meshId, -1 );
3195 createMenu( 902, meshId, -1 );
3196 createMenu( 903, meshId, -1 );
3197 createMenu( 904, meshId, -1 );
3198 createMenu( separator(), meshId, -1 );
3200 createMenu( 6003, ctrlId, -1 );
3201 createMenu( 6001, ctrlId, -1 );
3202 createMenu( 6004, ctrlId, -1 );
3203 createMenu( separator(), ctrlId, -1 );
3204 createMenu( 6005, ctrlId, -1 );
3205 createMenu( 6002, ctrlId, -1 );
3206 createMenu( 6018, ctrlId, -1 );
3207 createMenu( 6019, ctrlId, -1 );
3208 createMenu( 6011, ctrlId, -1 );
3209 createMenu( 6012, ctrlId, -1 );
3210 createMenu( 6013, ctrlId, -1 );
3211 createMenu( 6014, ctrlId, -1 );
3212 createMenu( 6015, ctrlId, -1 );
3213 createMenu( 6016, ctrlId, -1 );
3214 createMenu( separator(), ctrlId, -1 );
3215 createMenu( 6017, ctrlId, -1 );
3216 createMenu( 6009, ctrlId, -1 );
3217 createMenu( 6021, ctrlId, -1 );
3218 createMenu( separator(), ctrlId, -1 );
3220 createMenu( 4000, addId, -1 );
3221 createMenu( 4009, addId, -1 );
3222 createMenu( 4010, addId, -1 );
3223 createMenu( 4021, addId, -1 );
3224 createMenu( 4022, addId, -1 );
3225 createMenu( 4023, addId, -1 );
3226 createMenu( 4031, addId, -1 );
3227 createMenu( 4032, addId, -1 );
3228 createMenu( 4033, addId, -1 );
3229 createMenu( separator(), addId, -1 );
3230 createMenu( 4034, addId, -1 );
3231 createMenu( 4035, addId, -1 );
3232 createMenu( 4036, addId, -1 );
3233 createMenu( 4037, addId, -1 );
3234 createMenu( 4038, addId, -1 );
3235 createMenu( 4039, addId, -1 );
3236 createMenu( 4040, addId, -1 );
3238 createMenu( 4041, removeId, -1 );
3239 createMenu( 4042, removeId, -1 );
3240 createMenu( 4044, removeId, -1 );
3241 createMenu( separator(), removeId, -1 );
3242 createMenu( 4043, removeId, -1 );
3244 createMenu( 4051, renumId, -1 );
3245 createMenu( 4052, renumId, -1 );
3247 createMenu( 4061, transfId, -1 );
3248 createMenu( 4062, transfId, -1 );
3249 createMenu( 4063, transfId, -1 );
3250 createMenu( 4064, transfId, -1 );
3251 createMenu( 4065, transfId, -1 );
3252 createMenu( 4066, transfId, -1 );
3253 createMenu( 4068, transfId, -1 );
3254 createMenu( 4069, transfId, -1 );
3256 createMenu( 4067,modifyId, -1 );
3257 createMenu( 407, modifyId, -1 );
3258 createMenu( 408, modifyId, -1 );
3259 createMenu( 409, modifyId, -1 );
3260 createMenu( 410, modifyId, -1 );
3261 createMenu( 411, modifyId, -1 );
3262 createMenu( 419, modifyId, -1 );
3263 createMenu( 412, modifyId, -1 );
3264 createMenu( 413, modifyId, -1 );
3265 createMenu( 416, modifyId, -1 );
3266 createMenu( 414, modifyId, -1 );
3267 createMenu( 415, modifyId, -1 );
3268 createMenu( 417, modifyId, -1 );
3269 createMenu( 418, modifyId, -1 );
3271 createMenu( 214, viewId, -1 );
3273 // ----- create toolbars --------------
3274 int meshTb = createTool( tr( "TB_MESH" ) ),
3275 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3276 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3277 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3278 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3280 createTool( 702, meshTb );
3281 createTool( 703, meshTb );
3282 createTool( 704, meshTb );
3283 createTool( 710, meshTb );
3284 createTool( separator(), meshTb );
3285 createTool( 701, meshTb );
3286 createTool( 711, meshTb );
3287 createTool( 712, meshTb );
3288 createTool( 713, meshTb );
3289 createTool( separator(), meshTb );
3290 createTool( 801, meshTb );
3291 createTool( 806, meshTb );
3292 createTool( 802, meshTb );
3293 createTool( 803, meshTb );
3294 //createTool( 815, meshTb );
3295 createTool( separator(), meshTb );
3296 createTool( 900, meshTb );
3297 createTool( 902, meshTb );
3298 createTool( 903, meshTb );
3299 createTool( 904, meshTb );
3300 createTool( separator(), meshTb );
3302 createTool( 6001, ctrlTb );
3303 createTool( 6003, ctrlTb );
3304 createTool( 6004, ctrlTb );
3305 createTool( separator(), ctrlTb );
3306 createTool( 6005, ctrlTb );
3307 createTool( 6002, ctrlTb );
3308 createTool( 6018, ctrlTb );
3309 createTool( 6019, ctrlTb );
3310 createTool( 6011, ctrlTb );
3311 createTool( 6012, ctrlTb );
3312 createTool( 6013, ctrlTb );
3313 createTool( 6014, ctrlTb );
3314 createTool( 6015, ctrlTb );
3315 createTool( 6016, ctrlTb );
3316 createTool( separator(), ctrlTb );
3317 createTool( 6017, ctrlTb );
3318 createTool( 6009, ctrlTb );
3319 createTool( 6021, ctrlTb );
3320 createTool( separator(), ctrlTb );
3322 createTool( 4000, addRemTb );
3323 createTool( 4009, addRemTb );
3324 createTool( 4010, addRemTb );
3325 createTool( 4021, addRemTb );
3326 createTool( 4022, addRemTb );
3327 createTool( 4023, addRemTb );
3328 createTool( 4031, addRemTb );
3329 createTool( 4032, addRemTb );
3330 createTool( 4033, addRemTb );
3331 createTool( separator(), addRemTb );
3332 createTool( 4034, addRemTb );
3333 createTool( 4035, addRemTb );
3334 createTool( 4036, addRemTb );
3335 createTool( 4037, addRemTb );
3336 createTool( 4038, addRemTb );
3337 createTool( 4039, addRemTb );
3338 createTool( 4040, addRemTb );
3339 createTool( separator(), addRemTb );
3340 createTool( 4041, addRemTb );
3341 createTool( 4042, addRemTb );
3342 createTool( 4044, addRemTb );
3343 createTool( 4043, addRemTb );
3344 createTool( separator(), addRemTb );
3345 createTool( 4051, addRemTb );
3346 createTool( 4052, addRemTb );
3347 createTool( separator(), addRemTb );
3348 createTool( 4061, addRemTb );
3349 createTool( 4062, addRemTb );
3350 createTool( 4063, addRemTb );
3351 createTool( 4064, addRemTb );
3352 createTool( 4065, addRemTb );
3353 createTool( 4066, addRemTb );
3354 createTool( 4068, addRemTb );
3355 createTool( 4069, addRemTb );
3356 createTool( separator(), addRemTb );
3358 createTool( 4067,modifyTb );
3359 createTool( 407, modifyTb );
3360 createTool( 408, modifyTb );
3361 createTool( 409, modifyTb );
3362 createTool( 410, modifyTb );
3363 createTool( 411, modifyTb );
3364 createTool( 419, modifyTb );
3365 createTool( 412, modifyTb );
3366 createTool( 413, modifyTb );
3367 createTool( 416, modifyTb );
3368 createTool( 414, modifyTb );
3369 createTool( 415, modifyTb );
3370 createTool( 417, modifyTb );
3371 createTool( 418, modifyTb );
3373 createTool( 214, dispModeTb );
3375 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3376 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3379 QString OB = "'ObjectBrowser'",
3380 View = "'" + SVTK_Viewer::Type() + "'",
3382 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3383 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3384 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3385 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3386 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3387 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3388 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3389 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3390 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3391 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3392 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3394 mesh_group = mesh + " " + subMesh + " " + group,
3395 hyp_alg = hypo + " " + algo;
3397 // popup for object browser
3399 isInvisible("not( isVisible )"),
3400 isEmpty("numberOfNodes = 0"),
3401 isNotEmpty("numberOfNodes <> 0"),
3403 // has nodes, edges, etc in VISIBLE! actor
3404 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3405 hasElems("(count( elemTypes ) > 0)"),
3406 hasDifferentElems("(count( elemTypes ) > 1)"),
3407 hasElems0d("({'Elem0d'} in elemTypes)"),
3408 hasEdges("({'Edge'} in elemTypes)"),
3409 hasFaces("({'Face'} in elemTypes)"),
3410 hasVolumes("({'Volume'} in elemTypes)");
3412 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3413 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3414 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3415 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3416 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3417 createPopupItem( 803, OB, group ); // EDIT_GROUP
3418 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3420 popupMgr()->insert( separator(), -1, 0 );
3421 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3422 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3423 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3424 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3425 createPopupItem( 214, OB, mesh_group ); // UPDATE
3426 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3427 createPopupItem( 902, OB, mesh ); // STD_INFO
3428 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3429 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3430 popupMgr()->insert( separator(), -1, 0 );
3431 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3432 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3433 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3434 popupMgr()->insert( separator(), -1, 0 );
3435 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3436 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3437 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3438 popupMgr()->insert( separator(), -1, 0 );
3439 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3440 popupMgr()->insert( separator(), -1, 0 );
3441 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3442 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3443 popupMgr()->insert( separator(), -1, 0 );
3445 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3446 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3448 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3449 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3450 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3451 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3452 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3453 popupMgr()->insert( separator(), -1, 0 );
3456 createPopupItem( 803, View, group ); // EDIT_GROUP
3457 createPopupItem( 804, View, elems ); // ADD
3458 createPopupItem( 805, View, elems ); // REMOVE
3460 popupMgr()->insert( separator(), -1, 0 );
3461 createPopupItem( 214, View, mesh_group ); // UPDATE
3462 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3463 createPopupItem( 902, View, mesh ); // STD_INFO
3464 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3465 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3466 popupMgr()->insert( separator(), -1, 0 );
3468 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3469 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3470 popupMgr()->insert( separator(), -1, 0 );
3473 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3474 QString aType = QString( "%1type in {%2}" ).arg( lc );
3475 aType = aType.arg( mesh_group );
3476 QString aMeshInVTK = aClient + "&&" + aType;
3478 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3479 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3480 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3482 //-------------------------------------------------
3484 //-------------------------------------------------
3485 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3487 popupMgr()->insert( action( 9010 ), anId, -1 );
3488 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3489 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3491 popupMgr()->insert( action( 9011 ), anId, -1 );
3492 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3493 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3495 popupMgr()->insert( separator(), -1, -1 );
3497 //-------------------------------------------------
3499 //-------------------------------------------------
3500 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3502 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3503 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3504 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3506 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3507 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3508 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3510 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3511 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3512 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3514 popupMgr()->insert( separator(), anId, -1 );
3516 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3517 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3518 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3520 //-------------------------------------------------
3522 //-------------------------------------------------
3523 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3525 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3527 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3528 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3529 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3531 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3532 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3533 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3535 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3536 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3537 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3539 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3540 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3541 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3543 popupMgr()->insert( separator(), anId, -1 );
3545 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3546 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3549 //-------------------------------------------------
3550 // Representation of the 2D Quadratic elements
3551 //-------------------------------------------------
3552 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3553 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3554 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3555 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3557 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3558 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3559 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3561 //-------------------------------------------------
3562 // Orientation of faces
3563 //-------------------------------------------------
3564 popupMgr()->insert( action( 221 ), -1, -1 );
3565 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3566 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3568 //-------------------------------------------------
3570 //-------------------------------------------------
3571 popupMgr()->insert( action( 1132 ), -1, -1 );
3572 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3574 //-------------------------------------------------
3576 //-------------------------------------------------
3577 popupMgr()->insert( action( 1133 ), -1, -1 );
3578 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3580 //-------------------------------------------------
3582 //-------------------------------------------------
3583 popupMgr()->insert( action( 1134 ), -1, -1 );
3584 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3586 popupMgr()->insert( separator(), -1, -1 );
3588 //-------------------------------------------------
3590 //-------------------------------------------------
3592 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3593 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3594 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3595 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3597 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3599 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3600 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3602 popupMgr()->insert( separator(), anId, -1 );
3604 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3605 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3606 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3608 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3609 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3610 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3612 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3613 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3614 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3616 popupMgr()->insert( separator(), anId, -1 );
3618 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3619 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3620 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3622 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3623 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3624 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3626 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3627 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3628 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3630 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3631 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3632 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3634 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3635 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3636 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3638 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3639 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3640 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3642 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3643 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3644 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3646 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3647 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3648 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3650 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3651 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3652 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3654 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3655 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3656 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3658 popupMgr()->insert( separator(), anId, -1 );
3660 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3661 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3662 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3664 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3665 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3666 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3668 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3669 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3670 QtxPopupMgr::VisibleRule );
3671 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3673 popupMgr()->insert( separator(), anId, -1 );
3675 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3676 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3678 popupMgr()->insert( separator(), -1, -1 );
3680 //-------------------------------------------------
3682 //-------------------------------------------------
3683 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3684 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3685 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3686 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3688 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3689 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3691 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3692 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3694 popupMgr()->insert( separator(), -1, -1 );
3696 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3697 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3700 //================================================================================
3702 * \brief Return true if SMESH or GEOM objects are selected.
3703 * Is called form LightApp_Module::activateModule() which clear selection if
3704 * not isSelectionCompatible()
3706 //================================================================================
3708 bool SMESHGUI::isSelectionCompatible()
3710 bool isCompatible = true;
3711 SALOME_ListIO selected;
3712 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3713 Sel->selectedObjects( selected );
3715 SALOME_ListIteratorOfListIO It( selected );
3716 for ( ; isCompatible && It.More(); It.Next())
3718 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3719 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3721 return isCompatible;
3725 bool SMESHGUI::reusableOperation( const int id )
3727 // compute, evaluate and precompute are not reusable operations
3728 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3731 bool SMESHGUI::activateModule( SUIT_Study* study )
3733 bool res = SalomeApp_Module::activateModule( study );
3735 setMenuShown( true );
3736 setToolShown( true );
3738 // Reset actions accelerator keys
3739 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3740 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3741 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3743 action( 33)->setEnabled(true); // Delete: Key_Delete
3744 action(1101)->setEnabled(true); // Rename: Key_F2
3746 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3747 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3748 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3749 if ( _PTR(Study) aStudy = s->studyDS()) {
3750 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3751 updateObjBrowser(); // objects can be removed
3757 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3759 setMenuShown( false );
3760 setToolShown( false );
3762 EmitSignalCloseAllDialogs();
3764 // Unset actions accelerator keys
3765 action(111)->setShortcut(QKeySequence()); // Import DAT
3766 action(112)->setShortcut(QKeySequence()); // Import UNV
3767 action(113)->setShortcut(QKeySequence()); // Import MED
3769 action( 33)->setEnabled(false); // Delete: Key_Delete
3770 action(1101)->setEnabled(false); // Rename: Key_F2
3772 return SalomeApp_Module::deactivateModule( study );
3775 void SMESHGUI::studyClosed( SUIT_Study* s )
3777 SMESH::RemoveVisuData( s->id() );
3778 SalomeApp_Module::studyClosed( s );
3781 void SMESHGUI::OnGUIEvent()
3783 const QObject* obj = sender();
3784 if ( !obj || !obj->inherits( "QAction" ) )
3786 int id = actionId((QAction*)obj);
3791 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3793 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3794 if ( CORBA::is_nil( myComponentSMESH ) )
3796 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3798 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3799 return aGUI.myComponentSMESH;
3802 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3803 return myComponentSMESH;
3806 QString SMESHGUI::engineIOR() const
3808 CORBA::ORB_var anORB = getApp()->orb();
3809 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3810 return QString( anIOR.in() );
3813 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3815 SalomeApp_Module::contextMenuPopup( client, menu, title );
3817 selectionMgr()->selectedObjects( lst );
3818 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3819 Handle(SALOME_InteractiveObject) io = lst.First();
3820 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3821 _PTR(Study) study = appStudy->studyDS();
3822 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3824 QString aName = QString( obj->GetName().c_str() );
3825 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3826 aName.remove( (aName.length() - 1), 1 );
3832 LightApp_Selection* SMESHGUI::createSelection() const
3834 return new SMESHGUI_Selection();
3837 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3839 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3840 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3843 void SMESHGUI::viewManagers( QStringList& list ) const
3845 list.append( SVTK_Viewer::Type() );
3848 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3850 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3851 SMESH::UpdateSelectionProp( this );
3854 void SMESHGUI::createPreferences()
3856 // General tab ------------------------------------------------------------------------
3857 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3859 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3860 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3862 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3863 setPreferenceProperty( qaGroup, "columns", 2 );
3864 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3865 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3866 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3867 setPreferenceProperty( prec, "min", 0 );
3868 setPreferenceProperty( prec, "max", 16 );
3870 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3871 setPreferenceProperty( dispgroup, "columns", 2 );
3872 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3874 modes.append( "Wireframe" );
3875 modes.append( "Shading" );
3876 modes.append( "Nodes" );
3877 modes.append( "Shrink" );
3878 QList<QVariant> indices;
3879 indices.append( 0 );
3880 indices.append( 1 );
3881 indices.append( 2 );
3882 indices.append( 3 );
3883 setPreferenceProperty( dispmode, "strings", modes );
3884 setPreferenceProperty( dispmode, "indexes", indices );
3886 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3887 setPreferenceProperty( arcgroup, "columns", 2 );
3888 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3889 QStringList quadraticModes;
3890 quadraticModes.append("Lines");
3891 quadraticModes.append("Arcs");
3893 indices.append( 0 );
3894 indices.append( 1 );
3895 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3896 setPreferenceProperty( quadraticmode, "indexes", indices );
3898 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3899 "SMESH", "max_angle" );
3900 setPreferenceProperty( maxAngle, "min", 1 );
3901 setPreferenceProperty( maxAngle, "max", 90 );
3905 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3906 setPreferenceProperty( exportgroup, "columns", 2 );
3907 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3908 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3910 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3911 setPreferenceProperty( computeGroup, "columns", 2 );
3912 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3914 modes.append( "Never" );
3915 modes.append( "Errors only" );
3916 modes.append( "Always" );
3918 indices.append( 0 );
3919 indices.append( 1 );
3920 indices.append( 2 );
3921 setPreferenceProperty( notifyMode, "strings", modes );
3922 setPreferenceProperty( notifyMode, "indexes", indices );
3924 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3925 setPreferenceProperty( segGroup, "columns", 2 );
3926 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3927 "SMESH", "segmentation" );
3928 setPreferenceProperty( segLen, "min", 1 );
3929 setPreferenceProperty( segLen, "max", 10000000 );
3930 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3931 "SMESH", "nb_segments_per_edge" );
3932 setPreferenceProperty( nbSeg, "min", 1 );
3933 setPreferenceProperty( nbSeg, "max", 10000000 );
3935 // Quantities with individual precision settings
3936 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
3937 setPreferenceProperty( precGroup, "columns", 2 );
3939 const int nbQuantities = 6;
3940 int precs[nbQuantities], ii = 0;
3941 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
3942 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
3943 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
3944 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
3945 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
3946 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
3947 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
3948 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
3949 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
3950 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
3951 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
3952 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
3954 // Set property for precision value for spinboxes
3955 for ( ii = 0; ii < nbQuantities; ii++ ){
3956 setPreferenceProperty( precs[ii], "min", -14 );
3957 setPreferenceProperty( precs[ii], "max", 14 );
3958 setPreferenceProperty( precs[ii], "precision", 2 );
3961 // Mesh tab ------------------------------------------------------------------------
3962 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3963 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3964 setPreferenceProperty( nodeGroup, "columns", 3 );
3966 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3968 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
3970 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3971 QList<QVariant> aMarkerTypeIndicesList;
3972 QList<QVariant> aMarkerTypeIconsList;
3973 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
3974 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
3975 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
3976 aMarkerTypeIndicesList << i;
3977 aMarkerTypeIconsList << pixmap;
3979 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
3980 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
3982 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
3984 QList<QVariant> aMarkerScaleIndicesList;
3985 QStringList aMarkerScaleValuesList;
3986 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
3987 aMarkerScaleIndicesList << i;
3988 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
3990 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
3991 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
3993 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3994 setPreferenceProperty( elemGroup, "columns", 2 );
3996 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3997 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3998 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3999 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4001 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4002 setPreferenceProperty( grpGroup, "columns", 2 );
4004 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4006 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4007 //setPreferenceProperty( sp, "hstretch", 0 );
4008 //setPreferenceProperty( sp, "vstretch", 0 );
4010 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4011 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4012 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4013 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4014 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4015 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4016 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4018 setPreferenceProperty( size0d, "min", 1 );
4019 setPreferenceProperty( size0d, "max", 10 );
4021 setPreferenceProperty( sp, "hstretch", 0 );
4022 setPreferenceProperty( sp, "vstretch", 0 );
4024 setPreferenceProperty( elemW, "min", 1 );
4025 setPreferenceProperty( elemW, "max", 5 );
4027 setPreferenceProperty( shrink, "min", 0 );
4028 setPreferenceProperty( shrink, "max", 100 );
4030 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4031 setPreferenceProperty( orientGroup, "columns", 1 );
4033 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4034 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4036 setPreferenceProperty( orientScale, "min", 0.05 );
4037 setPreferenceProperty( orientScale, "max", 0.5 );
4038 setPreferenceProperty( orientScale, "step", 0.05 );
4040 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4042 // Selection tab ------------------------------------------------------------------------
4043 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4045 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4046 setPreferenceProperty( selGroup, "columns", 2 );
4048 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4049 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4050 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4052 setPreferenceProperty( selW, "min", 1 );
4053 setPreferenceProperty( selW, "max", 5 );
4055 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4056 setPreferenceProperty( preGroup, "columns", 2 );
4058 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4059 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4061 setPreferenceProperty( preW, "min", 1 );
4062 setPreferenceProperty( preW, "max", 5 );
4064 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4065 setPreferenceProperty( precSelGroup, "columns", 2 );
4067 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4068 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4069 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4071 // Scalar Bar tab ------------------------------------------------------------------------
4072 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4073 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4074 setPreferenceProperty( fontGr, "columns", 2 );
4076 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4077 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4079 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4080 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4082 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4083 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4085 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4086 setPreferenceProperty( numcol, "min", 2 );
4087 setPreferenceProperty( numcol, "max", 256 );
4089 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4090 setPreferenceProperty( numlab, "min", 2 );
4091 setPreferenceProperty( numlab, "max", 65 );
4093 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4094 setPreferenceProperty( orientGr, "columns", 2 );
4095 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4096 QStringList orients;
4097 orients.append( tr( "SMESH_VERTICAL" ) );
4098 orients.append( tr( "SMESH_HORIZONTAL" ) );
4099 indices.clear(); indices.append( 0 ); indices.append( 1 );
4100 setPreferenceProperty( orient, "strings", orients );
4101 setPreferenceProperty( orient, "indexes", indices );
4103 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4104 setPreferenceProperty( posVSizeGr, "columns", 2 );
4105 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4106 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4107 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4108 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4109 setPreferenceProperty( xv, "step", 0.1 );
4110 setPreferenceProperty( xv, "min", 0.0 );
4111 setPreferenceProperty( xv, "max", 1.0 );
4112 setPreferenceProperty( yv, "step", 0.1 );
4113 setPreferenceProperty( yv, "min", 0.0 );
4114 setPreferenceProperty( yv, "max", 1.0 );
4115 setPreferenceProperty( wv, "step", 0.1 );
4116 setPreferenceProperty( wv, "min", 0.0 );
4117 setPreferenceProperty( wv, "max", 1.0 );
4118 setPreferenceProperty( hv, "min", 0.0 );
4119 setPreferenceProperty( hv, "max", 1.0 );
4120 setPreferenceProperty( hv, "step", 0.1 );
4122 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4123 setPreferenceProperty( posHSizeGr, "columns", 2 );
4124 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4125 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4126 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4127 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4128 setPreferenceProperty( xv, "min", 0.0 );
4129 setPreferenceProperty( xv, "max", 1.0 );
4130 setPreferenceProperty( xv, "step", 0.1 );
4131 setPreferenceProperty( xh, "min", 0.0 );
4132 setPreferenceProperty( xh, "max", 1.0 );
4133 setPreferenceProperty( xh, "step", 0.1 );
4134 setPreferenceProperty( yh, "min", 0.0 );
4135 setPreferenceProperty( yh, "max", 1.0 );
4136 setPreferenceProperty( yh, "step", 0.1 );
4137 setPreferenceProperty( wh, "min", 0.0 );
4138 setPreferenceProperty( wh, "max", 1.0 );
4139 setPreferenceProperty( wh, "step", 0.1 );
4140 setPreferenceProperty( hh, "min", 0.0 );
4141 setPreferenceProperty( hh, "max", 1.0 );
4142 setPreferenceProperty( hh, "step", 0.1 );
4145 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4147 if( sect=="SMESH" ) {
4148 float sbX1,sbY1,sbW,sbH;
4149 float aTol = 1.00000009999999;
4150 std::string aWarning;
4151 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4152 if( name=="selection_object_color" || name=="selection_element_color" ||
4153 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4154 name=="selection_precision_node" || name=="selection_precision_element" ||
4155 name=="selection_precision_object")
4156 SMESH::UpdateSelectionProp( this );
4157 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4158 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4159 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4160 if(sbX1+sbW > aTol){
4161 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4164 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4165 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4168 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4169 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4170 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4171 if(sbY1+sbH > aTol){
4172 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4173 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4174 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4177 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4178 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4179 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4180 if(sbX1+sbW > aTol){
4181 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4184 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4185 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4188 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4189 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4190 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4191 if(sbY1+sbH > aTol){
4192 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4195 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4196 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4199 else if ( name == "segmentation" ) {
4200 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4201 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4203 else if ( name == "nb_segments_per_edge" ) {
4204 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4205 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4208 if(aWarning.size() != 0){
4209 aWarning += "The default values are applied instead.";
4210 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4211 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4212 QObject::tr(aWarning.c_str()));
4217 //================================================================================
4219 * \brief Update something in accordance with update flags
4220 * \param theFlags - update flags
4222 * Update viewer or/and object browser etc. in accordance with update flags ( see
4223 * LightApp_UpdateFlags enumeration ).
4225 //================================================================================
4226 void SMESHGUI::update( const int flags )
4228 if ( flags & UF_Viewer | flags & UF_Forced )
4229 SMESH::UpdateView();
4231 SalomeApp_Module::update( flags );
4234 //================================================================================
4236 * \brief Set default selection mode
4238 * SLOT called when operation commited. Sets default selection mode
4240 //================================================================================
4241 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4243 SVTK_ViewWindow* vtkWnd =
4244 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4246 vtkWnd->SetSelectionMode( ActorSelection );
4249 //================================================================================
4251 * \brief Set default selection mode
4253 * SLOT called when operation aborted. Sets default selection mode
4255 //================================================================================
4256 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4258 SVTK_ViewWindow* vtkWnd =
4259 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4261 vtkWnd->SetSelectionMode( ActorSelection );
4264 //================================================================================
4266 * \brief Creates operation with given identifier
4267 * \param id - identifier of operation to be started
4268 * \return Pointer on created operation or NULL if operation is not created
4270 * Virtual method redefined from the base class creates operation with given id.
4271 * It is called called automatically from startOperation method of base class.
4273 //================================================================================
4274 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4276 LightApp_Operation* op = 0;
4277 // to do : create operation here
4280 case 417: //convert to quadratic
4281 op = new SMESHGUI_ConvToQuadOp();
4283 case 418: // create 2D mesh as boundary on 3D
4284 op = new SMESHGUI_Make2DFrom3DOp();
4286 case 701: // Compute mesh
4287 op = new SMESHGUI_ComputeOp();
4289 case 702: // Create mesh
4290 op = new SMESHGUI_MeshOp( true, true );
4292 case 703: // Create sub-mesh
4293 op = new SMESHGUI_MeshOp( true, false );
4295 case 704: // Edit mesh/sub-mesh
4296 op = new SMESHGUI_MeshOp( false );
4298 case 711: // Precompute mesh
4299 op = new SMESHGUI_PrecomputeOp();
4301 case 712: // Evaluate mesh
4302 op = new SMESHGUI_EvaluateOp();
4304 case 713: // Evaluate mesh
4305 op = new SMESHGUI_MeshOrderOp();
4307 case 806: // Create group on geom
4308 op = new SMESHGUI_GroupOnShapeOp();
4310 case 904: // Find element
4311 op = new SMESHGUI_FindElemByPointOp();
4313 case 4067: // make mesh pass through point
4314 op = new SMESHGUI_MakeNodeAtPointOp();
4321 op = SalomeApp_Module::createOperation( id );
4325 //================================================================================
4327 * \brief Stops current operations and starts a given one
4328 * \param id - The id of the operation to start
4330 //================================================================================
4332 void SMESHGUI::switchToOperation(int id)
4334 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4335 activeStudy()->abortAllOperations();
4336 startOperation( id );
4339 LightApp_Displayer* SMESHGUI::displayer()
4342 myDisplayer = new SMESHGUI_Displayer( getApp() );
4346 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4349 int aTolerance = 64;
4350 int anIterations = 0;
4356 if( anIterations % aPeriod == 0 )
4359 if( aTolerance < 1 )
4362 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4364 aHue = (int)( 360.0 * rand() / RAND_MAX );
4365 //cout << "Hue = " << aHue << endl;
4367 //cout << "Auto colors : ";
4369 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4370 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4371 for( ; it != itEnd; ++it )
4373 SALOMEDS::Color anAutoColor = *it;
4374 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4377 aQColor.getHsv( &h, &s, &v );
4379 if( abs( h - aHue ) < aTolerance )
4382 //cout << "break (diff = " << abs( h - aHue ) << ")";
4392 //cout << "Hue of the returned color = " << aHue << endl;
4394 aColor.setHsv( aHue, 255, 255 );
4396 SALOMEDS::Color aSColor;
4397 aSColor.R = (double)aColor.red() / 255.0;
4398 aSColor.G = (double)aColor.green() / 255.0;
4399 aSColor.B = (double)aColor.blue() / 255.0;
4404 const char gSeparator = '_'; // character used to separate parameter names
4405 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4406 const char gPathSep = '|'; // character used to separate paths
4409 * \brief Store visual parameters
4411 * This method is called just before the study document is saved.
4412 * Store visual parameters in AttributeParameter attribue(s)
4414 void SMESHGUI::storeVisualParameters (int savePoint)
4416 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4417 if (!appStudy || !appStudy->studyDS())
4419 _PTR(Study) studyDS = appStudy->studyDS();
4421 // componentName is used for encoding of entries when storing them in IParameters
4422 std::string componentName = myComponentSMESH->ComponentDataType();
4423 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4424 //if (!aSComponent) return;
4427 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4428 componentName.c_str(),
4430 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4432 // store map of custom markers
4433 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4434 if( !aMarkerMap.empty() )
4436 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4437 for( ; anIter != aMarkerMap.end(); anIter++ )
4439 int anId = anIter->first;
4440 VTK::MarkerData aMarkerData = anIter->second;
4441 std::string aMarkerFileName = aMarkerData.first;
4442 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4443 if( aMarkerTexture.size() < 3 )
4444 continue; // should contain at least width, height and the first value
4446 QString aPropertyName( "texture" );
4447 aPropertyName += gSeparator;
4448 aPropertyName += QString::number( anId );
4450 QString aPropertyValue = aMarkerFileName.c_str();
4451 aPropertyValue += gPathSep;
4453 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4454 ushort aWidth = *aTextureIter++;
4455 ushort aHeight = *aTextureIter++;
4456 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4457 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4458 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4459 aPropertyValue += QString::number( *aTextureIter );
4461 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4465 // viewers counters are used for storing view_numbers in IParameters
4468 // main cycle to store parameters of displayed objects
4469 QList<SUIT_ViewManager*> lst;
4470 QList<SUIT_ViewManager*>::Iterator it;
4471 getApp()->viewManagers(lst);
4472 for (it = lst.begin(); it != lst.end(); it++)
4474 SUIT_ViewManager* vman = *it;
4475 QString vType = vman->getType();
4477 // saving VTK actors properties
4478 if (vType == SVTK_Viewer::Type())
4480 QVector<SUIT_ViewWindow*> views = vman->getViews();
4481 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4483 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4485 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4486 vtkActorCollection* allActors = aCopy.GetActors();
4487 allActors->InitTraversal();
4488 while (vtkActor* actor = allActors->GetNextActor())
4490 if (actor->GetVisibility()) // store only visible actors
4492 SMESH_Actor* aSmeshActor = 0;
4493 if (actor->IsA("SMESH_Actor"))
4494 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4495 if (aSmeshActor && aSmeshActor->hasIO())
4497 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4500 // entry is "encoded" = it does NOT contain component adress,
4501 // since it is a subject to change on next component loading
4502 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4504 std::string param, vtkParam = vType.toLatin1().data();
4505 vtkParam += gSeparator;
4506 vtkParam += QString::number(vtkViewers).toLatin1().data();
4507 vtkParam += gSeparator;
4510 param = vtkParam + "Visibility";
4511 ip->setParameter(entry, param, "On");
4514 param = vtkParam + "Representation";
4515 ip->setParameter(entry, param, QString::number
4516 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4519 param = vtkParam + "IsShrunk";
4520 ip->setParameter(entry, param, QString::number
4521 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4523 // Displayed entities
4524 unsigned int aMode = aSmeshActor->GetEntityMode();
4525 bool isE = aMode & SMESH_Actor::eEdges;
4526 bool isF = aMode & SMESH_Actor::eFaces;
4527 bool isV = aMode & SMESH_Actor::eVolumes;
4529 QString modeStr ("e");
4530 modeStr += gDigitsSep; modeStr += QString::number(isE);
4531 modeStr += gDigitsSep; modeStr += "f";
4532 modeStr += gDigitsSep; modeStr += QString::number(isF);
4533 modeStr += gDigitsSep; modeStr += "v";
4534 modeStr += gDigitsSep; modeStr += QString::number(isV);
4536 param = vtkParam + "Entities";
4537 ip->setParameter(entry, param, modeStr.toLatin1().data());
4539 // Colors (surface:edge:)
4540 vtkFloatingPointType r, g, b;
4542 aSmeshActor->GetSufaceColor(r, g, b);
4543 QString colorStr ("surface");
4544 colorStr += gDigitsSep; colorStr += QString::number(r);
4545 colorStr += gDigitsSep; colorStr += QString::number(g);
4546 colorStr += gDigitsSep; colorStr += QString::number(b);
4548 aSmeshActor->GetBackSufaceColor(r, g, b);
4549 colorStr += gDigitsSep; colorStr += "backsurface";
4550 colorStr += gDigitsSep; colorStr += QString::number(r);
4551 colorStr += gDigitsSep; colorStr += QString::number(g);
4552 colorStr += gDigitsSep; colorStr += QString::number(b);
4554 aSmeshActor->GetEdgeColor(r, g, b);
4555 colorStr += gDigitsSep; colorStr += "edge";
4556 colorStr += gDigitsSep; colorStr += QString::number(r);
4557 colorStr += gDigitsSep; colorStr += QString::number(g);
4558 colorStr += gDigitsSep; colorStr += QString::number(b);
4560 aSmeshActor->GetNodeColor(r, g, b);
4561 colorStr += gDigitsSep; colorStr += "node";
4562 colorStr += gDigitsSep; colorStr += QString::number(r);
4563 colorStr += gDigitsSep; colorStr += QString::number(g);
4564 colorStr += gDigitsSep; colorStr += QString::number(b);
4566 param = vtkParam + "Colors";
4567 ip->setParameter(entry, param, colorStr.toLatin1().data());
4569 // Sizes of lines and points
4570 QString sizeStr ("line");
4571 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4572 sizeStr += gDigitsSep; sizeStr += "shrink";
4573 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4575 param = vtkParam + "Sizes";
4576 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4581 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4582 if( aMarkerType == VTK::MT_USER ) {
4583 markerStr += "custom";
4584 markerStr += gDigitsSep;
4585 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4589 markerStr += gDigitsSep;
4590 markerStr += QString::number( (int)aMarkerType );
4591 markerStr += gDigitsSep;
4592 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4595 param = vtkParam + "PointMarker";
4596 ip->setParameter(entry, param, markerStr.toLatin1().data());
4599 param = vtkParam + "Opacity";
4600 ip->setParameter(entry, param,
4601 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4604 param = vtkParam + "ClippingPlane";
4605 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4607 ip->setParameter(entry, param, "Off");
4608 for (int ipl = 0; ipl < nPlanes; ipl++) {
4609 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4610 SMESH::Orientation anOrientation;
4612 vtkFloatingPointType anAngle[2];
4613 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4614 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4615 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4616 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4617 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4619 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4621 } // if (io->hasEntry())
4622 } // SMESH_Actor && hasIO
4624 } // while.. actors traversal
4628 } // if (SVTK view model)
4629 } // for (viewManagers)
4633 * \brief Restore visual parameters
4635 * This method is called after the study document is opened.
4636 * Restore visual parameters from AttributeParameter attribue(s)
4638 void SMESHGUI::restoreVisualParameters (int savePoint)
4640 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4641 if (!appStudy || !appStudy->studyDS())
4643 _PTR(Study) studyDS = appStudy->studyDS();
4645 // componentName is used for encoding of entries when storing them in IParameters
4646 std::string componentName = myComponentSMESH->ComponentDataType();
4647 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4648 //if (!aSComponent) return;
4651 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4652 componentName.c_str(),
4654 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4656 // restore map of custom markers
4657 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4659 std::vector<std::string> properties = ip->getProperties();
4660 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4662 std::string property = *propIt;
4663 QString aPropertyName( property.c_str() );
4664 QString aPropertyValue( ip->getProperty( property ).c_str() );
4666 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4667 if( aPropertyNameList.size() != 2 )
4672 if( aPropertyNameList[0] == "texture" )
4673 anId = aPropertyNameList[1].toInt( &ok );
4675 if( !ok || anId < 1 )
4678 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4679 if( aPropertyValueList.size() != 2 )
4682 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4683 QString aMarkerTextureString = aPropertyValueList[1];
4684 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4685 if( aMarkerTextureStringList.size() != 3 )
4689 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4694 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4698 VTK::MarkerTexture aMarkerTexture;
4699 aMarkerTexture.push_back( aWidth );
4700 aMarkerTexture.push_back( aHeight );
4702 QString aMarkerTextureData = aMarkerTextureStringList[2];
4703 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4705 QChar aChar = aMarkerTextureData.at( i );
4706 if( aChar.isDigit() )
4707 aMarkerTexture.push_back( aChar.digitValue() );
4710 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4713 std::vector<std::string> entries = ip->getEntries();
4715 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4717 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4718 QString entry (ip->decodeEntry(*entIt).c_str());
4720 // Check that the entry corresponds to a real object in the Study
4721 // as the object may be deleted or modified after the visual state is saved.
4722 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4723 if (!so) continue; //Skip the not existent entry
4725 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4726 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4728 std::vector<std::string>::iterator namesIt = paramNames.begin();
4729 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4731 // actors are stored in a map after displaying of them for
4732 // quicker access in the future: map < viewID to actor >
4733 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4735 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4737 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4738 // '_' is used as separator and should not be used in viewer type or parameter names.
4739 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4740 if (lst.size() != 3)
4743 QString viewerTypStr = lst[0];
4744 QString viewIndexStr = lst[1];
4745 QString paramNameStr = lst[2];
4748 int viewIndex = viewIndexStr.toUInt(&ok);
4749 if (!ok) // bad conversion of view index to integer
4753 if (viewerTypStr == SVTK_Viewer::Type())
4755 SMESH_Actor* aSmeshActor = 0;
4756 if (vtkActors.IsBound(viewIndex))
4757 aSmeshActor = vtkActors.Find(viewIndex);
4759 if (paramNameStr == "Visibility")
4761 if (!aSmeshActor && displayer())
4763 QList<SUIT_ViewManager*> lst;
4764 getApp()->viewManagers(viewerTypStr, lst);
4766 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4767 if (viewIndex >= 0 && viewIndex < lst.count()) {
4768 SUIT_ViewManager* vman = lst.at(viewIndex);
4769 SUIT_ViewModel* vmodel = vman->getViewModel();
4770 // SVTK view model can be casted to SALOME_View
4771 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4773 // store displayed actor in a temporary map for quicker
4774 // access later when restoring other parameters
4775 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4776 vtkRenderer* Renderer = vtkView->getRenderer();
4777 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4778 vtkActorCollection* theActors = aCopy.GetActors();
4779 theActors->InitTraversal();
4780 bool isFound = false;
4781 vtkActor *ac = theActors->GetNextActor();
4782 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4783 if (ac->IsA("SMESH_Actor")) {
4784 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4785 if (aGeomAc->hasIO()) {
4786 Handle(SALOME_InteractiveObject) io =
4787 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4788 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4790 vtkActors.Bind(viewIndex, aGeomAc);
4797 } // if (paramNameStr == "Visibility")
4800 // the rest properties "work" with SMESH_Actor
4803 QString val ((*valuesIt).c_str());
4806 if (paramNameStr == "Representation") {
4807 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4810 else if (paramNameStr == "IsShrunk") {
4812 if (!aSmeshActor->IsShrunk())
4813 aSmeshActor->SetShrink();
4816 if (aSmeshActor->IsShrunk())
4817 aSmeshActor->UnShrink();
4820 // Displayed entities
4821 else if (paramNameStr == "Entities") {
4822 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4823 if (mode.count() == 6) {
4824 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4825 MESSAGE("Invalid order of data in Entities, must be: "
4826 "e:0/1:f:0/1:v:0/1");
4829 unsigned int aMode = aSmeshActor->GetEntityMode();
4830 unsigned int aNewMode =
4831 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4832 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4833 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4834 if (aNewMode != aMode)
4835 aSmeshActor->SetEntityMode(aNewMode);
4840 else if (paramNameStr == "Colors") {
4841 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4842 if (colors.count() == 16) {
4843 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4844 colors[8] != "edge" || colors[12] != "node") {
4845 MESSAGE("Invalid order of data in Colors, must be: "
4846 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4849 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4850 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4851 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4852 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4856 // Sizes of lines and points
4857 else if (paramNameStr == "Sizes") {
4858 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4859 if (sizes.count() == 4) {
4860 if (sizes[0] != "line" || sizes[2] != "shrink") {
4861 MESSAGE("Invalid order of data in Sizes, must be: "
4862 "line:int:shrink:float");
4865 aSmeshActor->SetLineWidth(sizes[1].toInt());
4866 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4869 else if (sizes.count() == 6) { // just to support old format
4870 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4871 MESSAGE("Invalid order of data in Sizes, must be: "
4872 "line:int:node:int:shrink:float");
4875 aSmeshActor->SetLineWidth(sizes[1].toInt());
4876 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4877 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4882 else if (paramNameStr == "PointMarker") {
4883 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
4884 if( data.count() >= 2 ) {
4886 int aParam1 = data[1].toInt( &ok );
4888 if( data[0] == "std" && data.count() == 3 ) {
4889 int aParam2 = data[2].toInt( &ok );
4890 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
4892 else if( data[0] == "custom" ) {
4893 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
4894 if( markerIt != aMarkerMap.end() ) {
4895 VTK::MarkerData aMarkerData = markerIt->second;
4896 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
4903 else if (paramNameStr == "Opacity") {
4904 aSmeshActor->SetOpacity(val.toFloat());
4907 else if (paramNameStr.startsWith("ClippingPlane")) {
4908 cout << "$$$ ClippingPlane 1" << endl;
4909 if (paramNameStr == "ClippingPlane1" || val == "Off")
4910 aSmeshActor->RemoveAllClippingPlanes();
4912 cout << "$$$ ClippingPlane 2" << endl;
4913 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4914 if (vals.count() == 4) { // format check: 4 values
4915 cout << "$$$ ClippingPlane 3" << endl;
4916 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4917 double aDistance = vals[1].toFloat();
4918 vtkFloatingPointType anAngle[2];
4919 anAngle[0] = vals[2].toFloat();
4920 anAngle[1] = vals[3].toFloat();
4922 QList<SUIT_ViewManager*> lst;
4923 getApp()->viewManagers(viewerTypStr, lst);
4924 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4925 if (viewIndex >= 0 && viewIndex < lst.count()) {
4926 SUIT_ViewManager* vman = lst.at(viewIndex);
4927 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4928 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4929 anOrientation, aDistance, anAngle);
4934 } // if (aSmeshActor)
4935 } // other parameters than Visibility
4937 } // for names/parameters iterator
4938 } // for entries iterator
4940 // update all VTK views
4941 QList<SUIT_ViewManager*> lst;
4942 getApp()->viewManagers(lst);
4943 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4944 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4945 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4946 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4947 vtkView->getRenderer()->ResetCameraClippingRange();
4954 \brief Adds preferences for dfont of VTK viewer
4956 \param pIf group identifier
4957 \param param parameter
4958 \return identifier of preferences
4960 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4962 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4964 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4967 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4968 fam.append( tr( "SMESH_FONT_COURIER" ) );
4969 fam.append( tr( "SMESH_FONT_TIMES" ) );
4971 setPreferenceProperty( tfont, "fonts", fam );
4973 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4974 setPreferenceProperty( tfont, "features", f );
4980 \brief Actions after hypothesis edition
4981 Updates object browser after hypothesis edition
4983 void SMESHGUI::onHypothesisEdit( int result )
4986 SMESHGUI::Modified();
4987 updateObjBrowser( true );