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();
757 SALOME_ListIteratorOfListIO It( selected );
758 for( ; It.More(); It.Next()){
759 Handle(SALOME_InteractiveObject) IObject = It.Value();
760 if(IObject->hasEntry()){
761 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
762 switch(theCommandID){
764 anActor->SetRepresentation(SMESH_Actor::eEdge);
767 anActor->SetRepresentation(SMESH_Actor::eSurface);
770 if(anActor->IsShrunk())
773 anActor->SetShrink();
776 anActor->SetRepresentation(SMESH_Actor::ePoint);
779 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
780 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
783 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
784 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
787 vtkFloatingPointType color[3];
788 anActor->GetSufaceColor(color[0], color[1], color[2]);
789 int c0 = int (color[0] * 255);
790 int c1 = int (color[1] * 255);
791 int c2 = int (color[2] * 255);
792 QColor c(c0, c1, c2);
794 vtkFloatingPointType edgecolor[3];
795 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
796 c0 = int (edgecolor[0] * 255);
797 c1 = int (edgecolor[1] * 255);
798 c2 = int (edgecolor[2] * 255);
799 QColor e(c0, c1, c2);
801 vtkFloatingPointType backfacecolor[3];
802 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
803 c0 = int (backfacecolor[0] * 255);
804 c1 = int (backfacecolor[1] * 255);
805 c2 = int (backfacecolor[2] * 255);
806 QColor b(c0, c1, c2);
808 vtkFloatingPointType nodecolor[3];
809 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
810 c0 = int (nodecolor[0] * 255);
811 c1 = int (nodecolor[1] * 255);
812 c2 = int (nodecolor[2] * 255);
813 QColor n(c0, c1, c2);
815 vtkFloatingPointType color0D[3];
816 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
817 c0 = int (color0D[0] * 255);
818 c1 = int (color0D[1] * 255);
819 c2 = int (color0D[2] * 255);
820 QColor c0D(c0, c1, c2);
822 int size0D = (int)anActor->Get0DSize();
825 int Edgewidth = (int)anActor->GetLineWidth();
828 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
830 vtkFloatingPointType faces_orientation_color[3];
831 anActor->GetFacesOrientationColor(faces_orientation_color);
832 c0 = int (faces_orientation_color[0] * 255);
833 c1 = int (faces_orientation_color[1] * 255);
834 c2 = int (faces_orientation_color[2] * 255);
835 QColor o(c0, c1, c2);
837 vtkFloatingPointType faces_orientation_scale = anActor->GetFacesOrientationScale();
838 bool faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
840 SMESHGUI_Preferences_ColorDlg *aDlg =
841 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
842 aDlg->SetColor(1, c);
843 aDlg->SetColor(2, e);
844 aDlg->SetColor(3, n);
845 aDlg->SetColor(4, b);
846 aDlg->SetColor(5, c0D);
847 aDlg->SetColor(6, o);
848 aDlg->SetIntValue(1, Edgewidth);
849 aDlg->SetIntValue(2, int(Shrink*100.));
850 aDlg->SetIntValue(3, size0D);
851 aDlg->SetDoubleValue(1, faces_orientation_scale);
852 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
854 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
856 VTK::MarkerType aMarkerTypeCurrent = anActor->GetMarkerType();
857 VTK::MarkerScale aMarkerScaleCurrent = anActor->GetMarkerScale();
858 int aMarkerTextureCurrent = anActor->GetMarkerTexture();
859 if( aMarkerTypeCurrent != VTK::MT_USER )
860 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
862 aDlg->setCustomMarker( aMarkerTextureCurrent );
865 QColor color = aDlg->GetColor(1);
866 QColor edgecolor = aDlg->GetColor(2);
867 QColor nodecolor = aDlg->GetColor(3);
868 QColor backfacecolor = aDlg->GetColor(4);
869 QColor color0D = aDlg->GetColor(5);
870 QColor faces_orientation_color = aDlg->GetColor(6);
871 /* actor color and backface color */
872 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
873 vtkFloatingPointType (color.green()) / 255.,
874 vtkFloatingPointType (color.blue()) / 255.);
875 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
876 vtkFloatingPointType (backfacecolor.green()) / 255.,
877 vtkFloatingPointType (backfacecolor.blue()) / 255.);
880 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
881 vtkFloatingPointType (edgecolor.green()) / 255.,
882 vtkFloatingPointType (edgecolor.blue()) / 255.);
884 /* Shrink factor and size edges */
885 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
886 anActor->SetLineWidth(aDlg->GetIntValue(1));
888 /* Nodes color and size */
889 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
890 vtkFloatingPointType (nodecolor.green()) / 255.,
891 vtkFloatingPointType (nodecolor.blue()) / 255.);
894 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
895 vtkFloatingPointType (color0D.green()) / 255.,
896 vtkFloatingPointType (color0D.blue()) / 255.);
897 anActor->Set0DSize(aDlg->GetIntValue(3));
899 /* Faces orientation */
900 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
901 vtkFloatingPointType(faces_orientation_color.greenF()),
902 vtkFloatingPointType(faces_orientation_color.blueF())};
903 anActor->SetFacesOrientationColor(c);
904 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
905 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
908 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
910 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
911 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
912 int aMarkerTextureNew = aDlg->getCustomMarkerID();
913 if( aMarkerTypeNew != VTK::MT_USER )
914 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
916 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
917 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
918 if( anIter != aMarkerMap.end() )
919 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
922 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
923 if( !aGroupObject->_is_nil() )
925 SMESH::ElementType anElementType = aGroupObject->GetType();
927 switch( anElementType )
929 case SMESH::NODE: aColor = nodecolor; break;
930 case SMESH::EDGE: aColor = edgecolor; break;
931 default: aColor = color; break;
934 SALOMEDS::Color aGroupColor;
935 aGroupColor.R = (float)aColor.red() / 255.0;
936 aGroupColor.G = (float)aColor.green() / 255.0;
937 aGroupColor.B = (float)aColor.blue() / 255.0;
938 aGroupObject->SetColor( aGroupColor );
948 SMESH::RepaintCurrentView();
952 void Control( int theCommandID )
954 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
955 SALOME_ListIO selected;
957 aSel->selectedObjects( selected );
959 if( !selected.IsEmpty() ){
960 Handle(SALOME_InteractiveObject) anIO = selected.First();
963 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
964 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
965 switch ( theCommandID ){
967 aTitle = QObject::tr( "LENGTH_EDGES" );
968 aControl = SMESH_Actor::eLength;
971 aTitle = QObject::tr( "LENGTH2D_EDGES" );
972 aControl = SMESH_Actor::eLength2D;
975 aTitle = QObject::tr( "FREE_EDGES" );
976 aControl = SMESH_Actor::eFreeEdges;
979 aTitle = QObject::tr( "FREE_BORDERS" );
980 aControl = SMESH_Actor::eFreeBorders;
983 aTitle = QObject::tr( "MULTI_BORDERS" );
984 aControl = SMESH_Actor::eMultiConnection;
987 aTitle = QObject::tr( "FREE_NODES" );
988 aControl = SMESH_Actor::eFreeNodes;
991 aTitle = QObject::tr( "MULTI2D_BORDERS" );
992 aControl = SMESH_Actor::eMultiConnection2D;
995 aTitle = QObject::tr( "AREA_ELEMENTS" );
996 aControl = SMESH_Actor::eArea;
999 aTitle = QObject::tr( "TAPER_ELEMENTS" );
1000 aControl = SMESH_Actor::eTaper;
1003 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1004 aControl = SMESH_Actor::eAspectRatio;
1007 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1008 aControl = SMESH_Actor::eAspectRatio3D;
1011 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1012 aControl = SMESH_Actor::eMinimumAngle;
1015 aTitle = QObject::tr( "WARP_ELEMENTS" );
1016 aControl = SMESH_Actor::eWarping;
1019 aTitle = QObject::tr( "SKEW_ELEMENTS" );
1020 aControl = SMESH_Actor::eSkew;
1023 aTitle = QObject::tr( "SMESH_VOLUME" );
1024 aControl = SMESH_Actor::eVolume3D;
1027 aTitle = QObject::tr( "FREE_FACES" );
1028 aControl = SMESH_Actor::eFreeFaces;
1031 anActor->SetControlMode(aControl);
1032 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
1033 SMESH::RepaintCurrentView();
1040 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1041 MeshObjectType theType,
1042 const QString theInTypeName,
1043 QString & theOutTypeName)
1045 SMESH_TypeFilter aTypeFilter( theType );
1047 if( !theIO.IsNull() )
1049 entry = theIO->getEntry();
1050 LightApp_DataOwner owner( entry );
1051 if ( aTypeFilter.isOk( &owner )) {
1052 theOutTypeName = theInTypeName;
1060 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1062 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1063 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1065 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1066 CORBA::String_var anID = aSComp->GetID().c_str();
1067 if (!strcmp(anID.in(),theIO->getEntry()))
1073 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1074 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1075 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1076 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1077 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1085 QString CheckHomogeneousSelection()
1087 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1088 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1089 SALOME_ListIO selected;
1091 aSel->selectedObjects( selected );
1093 QString RefType = CheckTypeObject(selected.First());
1094 SALOME_ListIteratorOfListIO It(selected);
1095 for ( ; It.More(); It.Next())
1097 Handle(SALOME_InteractiveObject) IObject = It.Value();
1098 QString Type = CheckTypeObject(IObject);
1099 if (Type.compare(RefType) != 0)
1100 return "Heterogeneous Selection";
1107 void SMESHGUI::OnEditDelete()
1109 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1110 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1111 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1113 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1114 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1115 _PTR(GenericAttribute) anAttr;
1116 _PTR(AttributeIOR) anIOR;
1118 int objectCount = 0;
1120 QString aParentComponent = QString::null;
1121 Handle(SALOME_InteractiveObject) anIO;
1122 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1124 anIO = anIt.Value();
1125 QString cur = anIO->getComponentDataType();
1126 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1128 // check if object is reference
1129 _PTR(SObject) aRefSObj;
1130 aNameList.append("\n - ");
1131 if ( aSO->ReferencedObject( aRefSObj ) ) {
1132 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1133 aNameList.append( aRefName );
1134 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1137 aNameList.append(anIO->getName());
1141 if( aParentComponent.isNull() )
1142 aParentComponent = cur;
1143 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1144 aParentComponent = "";
1147 if ( objectCount == 0 )
1148 return; // No Valid Objects Selected
1150 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1151 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1152 QObject::tr("ERR_ERROR"),
1153 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1156 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1157 if (SUIT_MessageBox::warning
1158 (SMESHGUI::desktop(),
1159 QObject::tr("SMESH_WRN_WARNING"),
1160 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1161 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1162 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1165 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1166 SUIT_ViewManager* vm = anApp->activeViewManager();
1167 int nbSf = vm ? vm->getViewsCount() : 0;
1169 SALOME_ListIteratorOfListIO It(selected);
1171 aStudyBuilder->NewCommand(); // There is a transaction
1172 for( ; It.More(); It.Next()){ // loop on selected IO's
1173 Handle(SALOME_InteractiveObject) IObject = It.Value();
1174 if(IObject->hasEntry()) {
1175 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1177 // disable removal of "SMESH" component object
1178 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1180 if ( engineIOR() == anIOR->Value().c_str() )
1183 //Check the referenced object
1184 _PTR(SObject) aRefSObject;
1185 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1186 aSO = aRefSObject; // Delete main Object instead of reference
1188 // put the whole hierarchy of sub-objects of the selected SO into a list and
1189 // then treat them all starting from the deepest objects (at list back)
1191 std::list< _PTR(SObject) > listSO;
1192 listSO.push_back( aSO );
1193 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1194 for ( ; itSO != listSO.end(); ++itSO ) {
1195 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1196 for (it->InitEx(false); it->More(); it->Next())
1197 listSO.push_back( it->Value() );
1200 // treat SO's in the list starting from the back
1202 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1203 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1204 _PTR(SObject) SO = *ritSO;
1205 if ( !SO ) continue;
1206 std::string anEntry = SO->GetID();
1208 /** Erase graphical object **/
1209 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1210 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1211 for(int i = 0; i < nbSf; i++){
1212 SUIT_ViewWindow *sf = aViews[i];
1213 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1214 SMESH::RemoveActor(sf,anActor);
1219 /** Remove an object from data structures **/
1220 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1221 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1222 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1223 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1224 aMesh->RemoveGroup( aGroup );
1226 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1227 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1228 aMesh->RemoveSubMesh( aSubMesh );
1230 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1232 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1235 IObject = new SALOME_InteractiveObject
1236 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1237 QString objType = CheckTypeObject(IObject);
1238 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1239 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1240 aStudyBuilder->RemoveObjectWithChildren( SO );
1242 else {// default action: remove SObject from the study
1243 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1244 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1246 aStudyBuilder->RemoveObjectWithChildren( SO );
1250 } /* listSO back loop */
1251 } /* IObject->hasEntry() */
1253 aStudyBuilder->CommitCommand();
1255 /* Clear any previous selection */
1257 aSel->setSelectedObjects( l1 );
1259 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1264 SMESHGUI_EXPORT CAM_Module* createModule()
1266 return new SMESHGUI();
1270 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1272 //=============================================================================
1276 //=============================================================================
1277 SMESHGUI::SMESHGUI() :
1278 SalomeApp_Module( "SMESH" ),
1279 LightApp_Module( "SMESH" )
1281 if ( CORBA::is_nil( myComponentSMESH ) )
1283 CORBA::Boolean anIsEmbeddedMode;
1284 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1286 // 0019923: EDF 765 SMESH : default values of hypothesis
1287 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1288 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1289 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1290 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1291 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1294 myActiveDialogBox = 0;
1295 myFilterLibraryDlg = 0;
1299 SMESH::GetFilterManager();
1300 SMESH::GetPattern();
1302 /* load resources for all available meshers */
1303 SMESH::InitAvailableHypotheses();
1306 //=============================================================================
1310 //=============================================================================
1311 SMESHGUI::~SMESHGUI()
1313 #ifdef WITHGENERICOBJ
1314 SMESH::GetFilterManager()->Destroy();
1316 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1319 //=============================================================================
1323 //=============================================================================
1324 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1326 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1328 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1333 //=============================================================================
1337 //=============================================================================
1338 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1340 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1344 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1345 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1346 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1347 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1348 return autoUpdate && !exceeded;
1351 //=============================================================================
1355 //=============================================================================
1356 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1358 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1361 //=============================================================================
1365 //=============================================================================
1366 SMESHGUI* SMESHGUI::GetSMESHGUI()
1368 SMESHGUI* smeshMod = 0;
1369 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1372 CAM_Module* module = app->module( "Mesh" );
1373 smeshMod = dynamic_cast<SMESHGUI*>( module );
1376 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1378 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1381 _PTR(Study) aStudy = study->studyDS();
1383 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1392 Standard_EXPORT SMESHGUI* GetComponentGUI()
1394 return SMESHGUI::GetSMESHGUI();
1398 //=============================================================================
1402 //=============================================================================
1403 void SMESHGUI::SetState(int aState)
1408 //=============================================================================
1412 //=============================================================================
1413 void SMESHGUI::ResetState()
1418 //=============================================================================
1422 //=============================================================================
1423 void SMESHGUI::EmitSignalDeactivateDialog()
1425 emit SignalDeactivateActiveDialog();
1428 //=============================================================================
1432 //=============================================================================
1433 void SMESHGUI::EmitSignalStudyFrameChanged()
1435 emit SignalStudyFrameChanged();
1438 //=============================================================================
1442 //=============================================================================
1443 void SMESHGUI::EmitSignalCloseAllDialogs()
1445 emit SignalCloseAllDialogs();
1448 //=============================================================================
1452 //=============================================================================
1453 void SMESHGUI::EmitSignalVisibilityChanged()
1455 emit SignalVisibilityChanged();
1458 //=============================================================================
1462 //=============================================================================
1463 QDialog *SMESHGUI::GetActiveDialogBox()
1465 return myActiveDialogBox;
1468 //=============================================================================
1472 //=============================================================================
1473 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1475 myActiveDialogBox = (QDialog *) aDlg;
1479 //=============================================================================
1483 //=============================================================================
1484 SUIT_Desktop* SMESHGUI::desktop()
1486 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1488 return app->desktop();
1493 //=============================================================================
1497 //=============================================================================
1498 SalomeApp_Study* SMESHGUI::activeStudy()
1500 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1502 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1507 //=============================================================================
1511 //=============================================================================
1512 void SMESHGUI::Modified( bool theIsUpdateActions )
1514 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1515 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1516 appStudy->Modified();
1517 if( theIsUpdateActions )
1518 app->updateActions();
1523 //=============================================================================
1527 //=============================================================================
1528 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1530 /* Here the position is on the bottom right corner - 10 */
1531 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1533 SUIT_Desktop *PP = desktop();
1534 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1535 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1539 //=============================================================================
1543 //=============================================================================
1544 static int isStudyLocked(_PTR(Study) theStudy){
1545 return theStudy->GetProperties()->IsLocked();
1548 static bool checkLock(_PTR(Study) theStudy) {
1549 if (isStudyLocked(theStudy)) {
1550 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1551 QObject::tr("WRN_WARNING"),
1552 QObject::tr("WRN_STUDY_LOCKED") );
1558 //=======================================================================
1559 //function : CheckActiveStudyLocked
1561 //=======================================================================
1563 bool SMESHGUI::isActiveStudyLocked()
1565 _PTR(Study) aStudy = activeStudy()->studyDS();
1566 return checkLock( aStudy );
1569 //=============================================================================
1573 //=============================================================================
1574 bool SMESHGUI::OnGUIEvent( int theCommandID )
1576 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1580 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1581 SUIT_ResourceMgr* mgr = resourceMgr();
1585 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1586 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1589 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1590 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1592 //QAction* act = action( theCommandID );
1594 switch (theCommandID) {
1596 if(checkLock(aStudy)) break;
1604 if(checkLock(aStudy)) break;
1605 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1609 case 150: //MED FILE INFORMATION
1611 SALOME_ListIO selected;
1612 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1614 aSel->selectedObjects( selected );
1615 if( selected.Extent() )
1617 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1618 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1619 if ( !aMesh->_is_nil() )
1621 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1628 case 122: // EXPORT MED
1637 ::ExportMeshToFile(theCommandID);
1641 case 200: // SCALAR BAR
1643 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1644 SALOME_ListIO selected;
1646 aSel->selectedObjects( selected );
1648 if( selected.Extent() ) {
1649 Handle(SALOME_InteractiveObject) anIO = selected.First();
1650 if( anIO->hasEntry() ) {
1651 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1652 anActor->SetControlMode( SMESH_Actor::eNone );
1660 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1670 ::DisableAutoColor();
1673 case 1134: // Clipping
1674 case 1133: // Tranparency
1675 case 1132: // Colors / Size
1682 ::SetDisplayMode(theCommandID, myMarkerMap);
1685 //2D quadratic representation
1688 ::SetDisplayMode(theCommandID, myMarkerMap);
1692 case 216: // 0D elements
1695 case 219: // Volumes
1696 case 220: // All Entity
1697 ::SetDisplayEntity(theCommandID);
1700 case 221: // Orientation of faces
1702 LightApp_SelectionMgr* mgr = selectionMgr();
1703 SALOME_ListIO selected; mgr->selectedObjects( selected );
1705 SALOME_ListIteratorOfListIO it(selected);
1706 for( ; it.More(); it.Next()) {
1707 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1708 if(anIObject->hasEntry()) {
1709 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1710 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1719 if(checkLock(aStudy)) break;
1721 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1724 SMESH::UpdateView();
1726 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1727 SMESH::OnVisuException();
1729 catch (...) { // PAL16774 (Crash after display of many groups)
1730 SMESH::OnVisuException();
1734 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1735 aSel->selectedObjects( l );
1736 aSel->setSelectedObjects( l );
1741 case 301: // DISPLAY
1742 case 302: // DISPLAY ONLY
1744 SMESH::EDisplaing anAction;
1745 switch (theCommandID) {
1746 case 300: anAction = SMESH::eErase; break;
1747 case 301: anAction = SMESH::eDisplay; break;
1748 case 302: anAction = SMESH::eDisplayOnly; break;
1751 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1752 SALOME_ListIO sel_objects, to_process;
1754 aSel->selectedObjects( sel_objects );
1756 if( theCommandID==302 )
1757 startOperation( myEraseAll );
1759 extractContainers( sel_objects, to_process );
1762 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1766 SALOME_ListIteratorOfListIO It( to_process );
1767 for ( ; It.More(); It.Next()) {
1768 Handle(SALOME_InteractiveObject) IOS = It.Value();
1769 if (IOS->hasEntry()) {
1770 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1771 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1772 break; // PAL16774 (Crash after display of many groups)
1774 if (anAction == SMESH::eDisplayOnly)
1775 anAction = SMESH::eDisplay;
1780 // PAL13338 + PAL15161 -->
1781 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1782 SMESH::UpdateView();
1783 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1785 // PAL13338 + PAL15161 <--
1787 catch (...) { // PAL16774 (Crash after display of many groups)
1788 SMESH::OnVisuException();
1791 if (anAction == SMESH::eErase) {
1793 aSel->setSelectedObjects( l1 );
1796 aSel->setSelectedObjects( to_process );
1803 if(checkLock(aStudy)) break;
1806 EmitSignalDeactivateDialog();
1808 ( new SMESHGUI_NodesDlg( this ) )->show();
1811 SUIT_MessageBox::warning(desktop(),
1812 tr("SMESH_WRN_WARNING"),
1813 tr("SMESH_WRN_VIEWER_VTK"));
1818 case 2151: // FILTER
1822 EmitSignalDeactivateDialog();
1823 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1828 case 701: // COMPUTE MESH
1829 case 711: // PRECOMPUTE MESH
1830 case 712: // EVALUATE MESH
1831 case 713: // MESH ORDER
1833 if (checkLock(aStudy)) break;
1834 startOperation( theCommandID );
1838 case 702: // Create mesh
1839 case 703: // Create sub-mesh
1840 case 704: // Edit mesh/sub-mesh
1841 startOperation( theCommandID );
1843 case 710: // Build compound mesh
1845 if (checkLock(aStudy)) break;
1846 EmitSignalDeactivateDialog();
1847 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1851 case 407: // DIAGONAL INVERSION
1852 case 408: // Delete diagonal
1856 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1857 tr( "NOT_A_VTK_VIEWER" ) );
1861 if ( checkLock( aStudy ) )
1864 /*Standard_Boolean aRes;
1865 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1866 if ( aMesh->_is_nil() )
1868 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1869 tr( "SMESH_BAD_SELECTION" ) );
1873 EmitSignalDeactivateDialog();
1874 if ( theCommandID == 407 )
1875 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1877 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1880 case 409: // Change orientation
1881 case 410: // Union of triangles
1882 case 411: // Cutting of quadrangles
1883 case 419: // Splitting volumes into tetrahedra
1887 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1888 tr( "NOT_A_VTK_VIEWER" ) );
1892 if ( checkLock( aStudy ) )
1895 EmitSignalDeactivateDialog();
1896 SMESHGUI_MultiEditDlg* aDlg = NULL;
1897 if ( theCommandID == 409 )
1898 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1899 else if ( theCommandID == 410 )
1900 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1901 else if ( theCommandID == 419 )
1902 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
1904 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1909 case 412: // Smoothing
1911 if(checkLock(aStudy)) break;
1913 EmitSignalDeactivateDialog();
1914 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1917 SUIT_MessageBox::warning(desktop(),
1918 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1922 case 413: // Extrusion
1924 if (checkLock(aStudy)) break;
1926 EmitSignalDeactivateDialog();
1927 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1929 SUIT_MessageBox::warning(desktop(),
1930 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1934 case 414: // Revolution
1936 if(checkLock(aStudy)) break;
1938 EmitSignalDeactivateDialog();
1939 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1942 SUIT_MessageBox::warning(desktop(),
1943 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1947 case 415: // Pattern mapping
1949 if ( checkLock( aStudy ) )
1953 EmitSignalDeactivateDialog();
1954 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1957 SUIT_MessageBox::warning(desktop(),
1958 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1962 case 416: // Extrusion along a path
1964 if (checkLock(aStudy)) break;
1966 EmitSignalDeactivateDialog();
1967 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1969 SUIT_MessageBox::warning(desktop(),
1970 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1974 case 417: // Convert mesh to quadratic
1976 startOperation( 417 );
1977 /* if (checkLock(aStudy)) break;
1979 EmitSignalDeactivateDialog();
1980 new SMESHGUI_ConvToQuadDlg();
1982 SUIT_MessageBox::warning(desktop(),
1983 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1987 case 418: // create 2D mesh from 3D
1989 startOperation( 418 );
1992 case 806: // CREATE GEO GROUP
1994 startOperation( 806 );
1997 case 801: // CREATE GROUP
2001 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2002 tr( "NOT_A_VTK_VIEWER" ) );
2006 if(checkLock(aStudy)) break;
2007 EmitSignalDeactivateDialog();
2008 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2010 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2011 SALOME_ListIO selected;
2013 aSel->selectedObjects( selected );
2015 int nbSel = selected.Extent();
2017 // check if mesh is selected
2018 aMesh = SMESH::GetMeshByIO( selected.First() );
2020 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2025 case 802: // CONSTRUCT GROUP
2029 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2030 tr( "NOT_A_VTK_VIEWER" ) );
2034 if(checkLock(aStudy)) break;
2035 EmitSignalDeactivateDialog();
2037 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2038 SALOME_ListIO selected;
2040 aSel->selectedObjects( selected );
2042 int nbSel = selected.Extent();
2044 // check if submesh is selected
2045 Handle(SALOME_InteractiveObject) IObject = selected.First();
2046 if (IObject->hasEntry()) {
2047 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2049 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2050 if (!aSubMesh->_is_nil()) {
2052 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2053 // get submesh elements list by types
2054 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2055 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2056 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2057 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2058 // create group for each type o elements
2059 QString aName = IObject->getName();
2060 if (aNodes->length() > 0) {
2061 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2062 aGroup->Add(aNodes.inout());
2064 if (aEdges->length() > 0) {
2065 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2066 aGroup->Add(aEdges.inout());
2068 if (aFaces->length() > 0) {
2069 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2070 aGroup->Add(aFaces.inout());
2072 if (aVolumes->length() > 0) {
2073 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2074 aGroup->Add(aVolumes.inout());
2079 catch(const SALOME::SALOME_Exception & S_ex){
2080 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2087 SUIT_MessageBox::warning(desktop(),
2088 tr("SMESH_WRN_WARNING"),
2089 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2094 case 803: // EDIT GROUP
2098 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2099 tr( "NOT_A_VTK_VIEWER" ) );
2103 if(checkLock(aStudy)) break;
2104 EmitSignalDeactivateDialog();
2106 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2107 SALOME_ListIO selected;
2109 aSel->selectedObjects( selected );
2111 SALOME_ListIteratorOfListIO It (selected);
2112 int nbSelectedGroups = 0;
2113 for ( ; It.More(); It.Next() )
2115 SMESH::SMESH_GroupBase_var aGroup =
2116 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2117 if (!aGroup->_is_nil()) {
2119 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2123 if (nbSelectedGroups == 0)
2125 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2131 case 804: // Add elements to group
2133 if(checkLock(aStudy)) break;
2134 if (myState == 800) {
2135 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2136 if (aDlg) aDlg->onAdd();
2141 case 805: // Remove elements from group
2143 if(checkLock(aStudy)) break;
2144 if (myState == 800) {
2145 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2146 if (aDlg) aDlg->onRemove();
2151 case 815: // Edit GEOM GROUP as standalone
2155 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2156 tr( "NOT_A_VTK_VIEWER" ) );
2160 if(checkLock(aStudy)) break;
2161 EmitSignalDeactivateDialog();
2163 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2164 SALOME_ListIO selected;
2166 aSel->selectedObjects( selected );
2168 SALOME_ListIteratorOfListIO It (selected);
2169 for ( ; It.More(); It.Next() )
2171 SMESH::SMESH_GroupOnGeom_var aGroup =
2172 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2173 if (!aGroup->_is_nil()) {
2174 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2181 case 810: // Union Groups
2182 case 811: // Intersect groups
2183 case 812: // Cut groups
2187 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2188 tr( "NOT_A_VTK_VIEWER" ) );
2192 if ( checkLock( aStudy ) )
2195 EmitSignalDeactivateDialog();
2197 SMESHGUI_GroupOpDlg* aDlg = 0;
2198 if ( theCommandID == 810 )
2199 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2200 else if ( theCommandID == 811 )
2201 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2203 aDlg = new SMESHGUI_CutGroupsDlg( this );
2210 case 814: // Create groups of entities from existing groups of superior dimensions
2212 if ( checkLock( aStudy ) )
2215 EmitSignalDeactivateDialog();
2216 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2222 case 813: // Delete groups with their contents
2226 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2227 tr( "NOT_A_VTK_VIEWER" ) );
2231 if ( checkLock( aStudy ) )
2234 EmitSignalDeactivateDialog();
2236 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2240 case 900: // MESH INFOS
2242 EmitSignalDeactivateDialog();
2243 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2244 SALOME_ListIO selected;
2246 aSel->selectedObjects( selected );
2248 if ( selected.Extent() > 1 ) { // a dlg for each IO
2250 SALOME_ListIteratorOfListIO It (selected);
2251 for ( ; It.More(); It.Next() ) {
2252 IOs.Clear(); IOs.Append( It.Value() );
2253 aSel->setSelectedObjects( IOs );
2254 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2256 // restore selection
2257 aSel->setSelectedObjects( selected );
2260 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2264 case 902: // STANDARD MESH INFOS
2266 EmitSignalDeactivateDialog();
2267 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2268 SALOME_ListIO selected;
2270 aSel->selectedObjects( selected );
2272 if ( selected.Extent() > 1 ) { // a dlg for each IO
2274 SALOME_ListIteratorOfListIO It (selected);
2275 for ( ; It.More(); It.Next() ) {
2277 IOs.Append( It.Value() );
2278 aSel->setSelectedObjects( IOs );
2279 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2281 // restore selection
2282 aSel->setSelectedObjects( selected );
2285 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2289 case 903: // WHAT IS
2291 EmitSignalDeactivateDialog();
2292 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2296 case 904: // FIND ELEM
2298 startOperation( theCommandID );
2302 case 1100: // EDIT HYPOTHESIS
2304 if(checkLock(aStudy)) break;
2306 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2307 SALOME_ListIO selected;
2309 aSel->selectedObjects( selected );
2311 int nbSel = selected.Extent();
2314 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2315 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2317 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2318 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2319 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2320 if ( !aHypothesis->_is_nil() )
2323 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2324 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2326 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2337 case 1101: // RENAME
2339 if ( checkLock( aStudy ) )
2342 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2343 SALOME_ListIO selected;
2345 aSel->selectedObjects( selected );
2347 bool isAny = false; // is there any appropriate object selected
2349 SALOME_ListIteratorOfListIO It( selected );
2350 for ( ; It.More(); It.Next() )
2352 Handle(SALOME_InteractiveObject) IObject = It.Value();
2353 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2354 _PTR(GenericAttribute) anAttr;
2355 _PTR(AttributeName) aName;
2358 if ( obj->FindAttribute(anAttr, "AttributeName") )
2361 QString newName = QString(aName->Value().c_str());
2363 // check type to prevent renaming of inappropriate objects
2364 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2365 if (aType == MESH || aType == GROUP ||
2366 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2367 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2368 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2369 aType == HYPOTHESIS || aType == ALGORITHM)
2372 newName = LightApp_NameDlg::getName(desktop(), newName);
2373 if ( !newName.isEmpty() )
2375 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2377 // update name of group object and its actor
2378 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2379 if( !aGroupObject->_is_nil() )
2381 aGroupObject->SetName( newName.toLatin1().data() );
2382 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2383 anActor->setName( newName.toLatin1().data() );
2394 SUIT_MessageBox::warning(desktop(),
2395 QObject::tr("SMESH_WRN_WARNING"),
2396 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2401 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2403 if(checkLock(aStudy)) break;
2404 SUIT_OverrideCursor wc;
2406 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2407 SALOME_ListIO selected;
2409 aSel->selectedObjects( selected, QString::null, false );
2411 SALOME_ListIteratorOfListIO It(selected);
2412 for (int i = 0; It.More(); It.Next(), i++) {
2413 Handle(SALOME_InteractiveObject) IObject = It.Value();
2414 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2417 aSel->setSelectedObjects( l1 );
2422 case 4009: // ELEM0D
2423 case 4010: // GEOM::EDGE
2424 case 4021: // TRIANGLE
2426 case 4023: // POLYGON
2430 if(checkLock(aStudy)) break;
2432 EmitSignalDeactivateDialog();
2433 SMDSAbs_ElementType type = SMDSAbs_Edge;
2435 switch (theCommandID) {
2436 case 4009: // ELEM0D
2437 type = SMDSAbs_0DElement; nbNodes = 1; break;
2438 case 4021: // TRIANGLE
2439 type = SMDSAbs_Face; nbNodes = 3; break;
2441 type = SMDSAbs_Face; nbNodes = 4; break;
2443 type = SMDSAbs_Volume; nbNodes = 4; break;
2444 case 4023: // POLYGON
2445 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2447 type = SMDSAbs_Volume; nbNodes = 8; break;
2448 case 4033: // POLYHEDRE
2449 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2452 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2455 SUIT_MessageBox::warning(desktop(),
2456 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2460 case 4033: // POLYHEDRON
2462 if(checkLock(aStudy)) break;
2464 EmitSignalDeactivateDialog();
2465 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2468 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2469 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2473 case 4034: // QUADRATIC EDGE
2474 case 4035: // QUADRATIC TRIANGLE
2475 case 4036: // QUADRATIC QUADRANGLE
2476 case 4037: // QUADRATIC TETRAHEDRON
2477 case 4038: // QUADRATIC PYRAMID
2478 case 4039: // QUADRATIC PENTAHEDRON
2479 case 4040: // QUADRATIC HEXAHEDRON
2481 if(checkLock(aStudy)) break;
2483 EmitSignalDeactivateDialog();
2486 switch (theCommandID) {
2488 type = QUAD_EDGE; break;
2490 type = QUAD_TRIANGLE; break;
2492 type = QUAD_QUADRANGLE; break;
2494 type = QUAD_TETRAHEDRON; break;
2496 type = QUAD_PYRAMID; break;
2498 type = QUAD_PENTAHEDRON; break;
2500 type = QUAD_HEXAHEDRON;
2504 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2507 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2508 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2512 case 4041: // REMOVES NODES
2514 if(checkLock(aStudy)) break;
2516 EmitSignalDeactivateDialog();
2517 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2520 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2521 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2525 case 4042: // REMOVES ELEMENTS
2527 if(checkLock(aStudy)) break;
2529 EmitSignalDeactivateDialog();
2530 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2534 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2535 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2539 case 4043: { // CLEAR_MESH
2541 if(checkLock(aStudy)) break;
2543 SALOME_ListIO selected;
2544 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2545 aSel->selectedObjects( selected );
2547 SUIT_OverrideCursor wc;
2548 SALOME_ListIteratorOfListIO It (selected);
2549 for ( ; It.More(); It.Next() )
2551 Handle(SALOME_InteractiveObject) IOS = It.Value();
2552 SMESH::SMESH_Mesh_var aMesh =
2553 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2554 if ( aMesh->_is_nil()) continue;
2556 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2558 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2559 SMESH::ModifiedMesh( aMeshSObj, false, true);
2560 // hide groups and submeshes
2561 _PTR(ChildIterator) anIter =
2562 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2563 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2565 _PTR(SObject) so = anIter->Value();
2566 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2569 catch (const SALOME::SALOME_Exception& S_ex){
2571 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2575 SMESH::UpdateView();
2579 case 4044: // REMOVE ORPHAN NODES
2581 if(checkLock(aStudy)) break;
2582 SALOME_ListIO selected;
2583 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2584 aSel->selectedObjects( selected );
2585 if ( selected.Extent() == 1 ) {
2586 Handle(SALOME_InteractiveObject) anIO = selected.First();
2587 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2588 if ( !aMesh->_is_nil() ) {
2589 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2590 tr( "SMESH_WARNING" ),
2591 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2592 SUIT_MessageBox::Yes |
2593 SUIT_MessageBox::No,
2594 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2597 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2598 int removed = aMeshEditor->RemoveOrphanNodes();
2599 SUIT_MessageBox::information(SMESHGUI::desktop(),
2600 tr("SMESH_INFORMATION"),
2601 tr("NB_NODES_REMOVED").arg(removed));
2602 if ( removed > 0 ) {
2603 SMESH::UpdateView();
2604 SMESHGUI::Modified();
2607 catch (const SALOME::SALOME_Exception& S_ex) {
2608 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2617 case 4051: // RENUMBERING NODES
2619 if(checkLock(aStudy)) break;
2621 EmitSignalDeactivateDialog();
2622 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2626 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2627 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2631 case 4052: // RENUMBERING ELEMENTS
2633 if(checkLock(aStudy)) break;
2635 EmitSignalDeactivateDialog();
2636 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2640 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2641 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2645 case 4061: // TRANSLATION
2647 if(checkLock(aStudy)) break;
2649 EmitSignalDeactivateDialog();
2650 ( new SMESHGUI_TranslationDlg( this ) )->show();
2653 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2654 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2658 case 4062: // ROTATION
2660 if(checkLock(aStudy)) break;
2662 EmitSignalDeactivateDialog();
2663 ( new SMESHGUI_RotationDlg( this ) )->show();
2666 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2667 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2671 case 4063: // SYMMETRY
2673 if(checkLock(aStudy)) break;
2675 EmitSignalDeactivateDialog();
2676 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2679 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2680 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2684 case 4064: // SEWING
2686 if(checkLock(aStudy)) break;
2688 EmitSignalDeactivateDialog();
2689 ( new SMESHGUI_SewingDlg( this ) )->show();
2692 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2693 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2697 case 4065: // MERGE NODES
2699 if(checkLock(aStudy)) break;
2701 EmitSignalDeactivateDialog();
2702 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2705 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2706 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2710 case 4066: // MERGE EQUAL ELEMENTS
2712 if (checkLock(aStudy)) break;
2714 EmitSignalDeactivateDialog();
2715 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2717 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2718 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2723 case 4067: // MAKE MESH PASS THROUGH POINT
2724 startOperation( 4067 );
2729 if(checkLock(aStudy)) break;
2731 EmitSignalDeactivateDialog();
2732 ( new SMESHGUI_ScaleDlg( this ) )->show();
2735 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2736 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2741 case 4069: // DUPLICATE NODES
2743 if(checkLock(aStudy)) break;
2745 EmitSignalDeactivateDialog();
2746 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2749 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2750 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2755 case 5105: // Library of selection filters
2757 static QList<int> aTypes;
2758 if ( aTypes.isEmpty() )
2760 aTypes.append( SMESH::NODE );
2761 aTypes.append( SMESH::EDGE );
2762 aTypes.append( SMESH::FACE );
2763 aTypes.append( SMESH::VOLUME );
2765 if (!myFilterLibraryDlg)
2766 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2767 else if (myFilterLibraryDlg->isHidden())
2768 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2769 myFilterLibraryDlg->raise();
2773 case 6017: // CONTROLS
2791 LightApp_SelectionMgr* mgr = selectionMgr();
2792 SALOME_ListIO selected; mgr->selectedObjects( selected );
2794 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2795 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2797 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2798 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2799 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2800 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2801 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2802 ::Control( theCommandID );
2807 SUIT_MessageBox::warning(desktop(),
2808 tr( "SMESH_WRN_WARNING" ),
2809 tr( "SMESH_BAD_SELECTION" ) );
2813 SUIT_MessageBox::warning(desktop(),
2814 tr( "SMESH_WRN_WARNING" ),
2815 tr( "NOT_A_VTK_VIEWER" ) );
2820 LightApp_SelectionMgr* mgr = selectionMgr();
2821 SALOME_ListIO selected; mgr->selectedObjects( selected );
2823 SALOME_ListIteratorOfListIO it(selected);
2824 for( ; it.More(); it.Next()) {
2825 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2826 if(anIObject->hasEntry()) {
2827 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2828 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2836 LightApp_SelectionMgr* mgr = selectionMgr();
2837 SALOME_ListIO selected; mgr->selectedObjects( selected );
2839 SALOME_ListIteratorOfListIO it(selected);
2840 for( ; it.More(); it.Next()) {
2841 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2842 if(anIObject->hasEntry())
2843 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2844 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2851 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2852 //updateObjBrowser();
2856 //=============================================================================
2860 //=============================================================================
2861 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2866 //=============================================================================
2870 //=============================================================================
2871 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2876 //=============================================================================
2880 //=============================================================================
2881 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2886 //=============================================================================
2887 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2888 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2890 //=============================================================================
2891 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2892 SUIT_ViewWindow* wnd )
2894 if(theIO->hasEntry()){
2895 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2896 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2900 //=======================================================================
2901 // function : createSMESHAction
2903 //=======================================================================
2904 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
2905 const int key, const bool toggle, const QString& shortcutAction )
2908 QWidget* parent = application()->desktop();
2909 SUIT_ResourceMgr* resMgr = resourceMgr();
2911 if ( !icon_id.isEmpty() )
2912 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2914 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2915 if ( !pix.isNull() )
2916 icon = QIcon( pix );
2918 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2919 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2920 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2922 createAction( id, tooltip, icon, menu, status_bar, key, parent,
2923 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
2926 //=======================================================================
2927 // function : createPopupItem
2929 //=======================================================================
2930 void SMESHGUI::createPopupItem( const int id,
2931 const QString& clients,
2932 const QString& types,
2933 const QString& theRule,
2938 parentId = popupMgr()->actionId( action( pId ) );
2940 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2941 popupMgr()->insert( action( id ), parentId, 0 );
2943 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2944 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2945 QString rule = "(%1) and (%2) and (%3)";
2946 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2947 if( clients.isEmpty() )
2948 rule = rule.arg( QString( "true" ) );
2950 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2951 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2954 bool cont = myRules.contains( id );
2956 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2958 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2959 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2962 //=======================================================================
2963 // function : initialize
2965 //=======================================================================
2966 void SMESHGUI::initialize( CAM_Application* app )
2968 SalomeApp_Module::initialize( app );
2970 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2972 /* Automatic Update flag */
2973 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2975 // ----- create actions --------------
2977 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2978 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2979 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2980 createSMESHAction( 114, "NUM" );
2981 createSMESHAction( 121, "DAT" );
2982 createSMESHAction( 122, "MED" );
2983 createSMESHAction( 123, "UNV" );
2984 createSMESHAction( 140, "STL" );
2985 createSMESHAction( 124, "EXPORT_DAT" );
2986 createSMESHAction( 125, "EXPORT_MED" );
2987 createSMESHAction( 126, "EXPORT_UNV" );
2988 createSMESHAction( 141, "EXPORT_STL" );
2989 createSMESHAction( 150, "FILE_INFO" );
2990 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2991 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2992 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2993 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2994 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2995 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2996 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2997 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2998 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2999 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3000 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3001 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3002 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3003 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3004 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3005 createSMESHAction( 804, "ADD" );
3006 createSMESHAction( 805, "REMOVE" );
3007 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3008 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3009 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3010 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3011 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3012 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3013 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3014 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3015 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3016 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3017 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3018 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3019 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3020 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3021 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3022 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3023 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3024 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3025 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3026 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3027 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3028 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3029 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3030 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3031 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3032 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3033 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3034 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3035 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3036 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3037 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3038 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3039 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3040 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3041 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3042 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3043 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3044 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3045 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3046 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3047 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3048 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3049 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3050 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3051 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3052 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3053 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3054 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3055 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3056 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3057 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3058 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3059 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3060 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3061 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3062 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3063 createSMESHAction( 415, "MAP", "ICON_MAP" );
3064 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3065 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3066 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3067 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3068 createSMESHAction( 200, "RESET" );
3069 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3070 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3071 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3072 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3073 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3074 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3075 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3076 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3077 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3078 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3079 createSMESHAction( 220, "ALL" );
3080 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3082 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3083 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3085 createSMESHAction( 1100, "EDIT_HYPO" );
3086 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3087 createSMESHAction( 1102, "UNASSIGN" );
3088 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3089 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3090 createSMESHAction( 1131, "DISPMODE" );
3091 createSMESHAction( 1132, "COLORS" );
3092 createSMESHAction( 1133, "TRANSP" );
3093 createSMESHAction( 1134, "CLIP" );
3094 createSMESHAction( 1135, "DISP_ENT" );
3095 createSMESHAction( 1136, "AUTO_COLOR" );
3096 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3097 createSMESHAction( 2000, "CTRL" );
3099 createSMESHAction( 300, "ERASE" );
3100 createSMESHAction( 301, "DISPLAY" );
3101 createSMESHAction( 302, "DISPLAY_ONLY" );
3102 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3103 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3104 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3105 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3106 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3107 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3108 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3109 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3111 // ----- create menu --------------
3112 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3113 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3114 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3115 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3116 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3117 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3118 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3120 createMenu( separator(), fileId );
3122 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3123 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3124 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3125 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3126 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3127 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3129 createMenu( 111, importId, -1 );
3130 createMenu( 112, importId, -1 );
3131 createMenu( 113, importId, -1 );
3133 createMenu( 121, exportId, -1 );
3134 createMenu( 122, exportId, -1 );
3135 createMenu( 123, exportId, -1 );
3136 createMenu( 140, exportId, -1 ); // export to stl STL
3138 createMenu( separator(), fileId, 10 );
3140 createMenu( 33, editId, -1 );
3142 createMenu( 5105, toolsId, -1 );
3144 createMenu( 702, meshId, -1 ); // "Mesh" menu
3145 createMenu( 703, meshId, -1 );
3146 createMenu( 704, meshId, -1 );
3147 createMenu( 710, meshId, -1 );
3148 createMenu( separator(), meshId, -1 );
3149 createMenu( 701, meshId, -1 );
3150 createMenu( 711, meshId, -1 );
3151 createMenu( 712, meshId, -1 );
3152 createMenu( 713, meshId, -1 );
3153 createMenu( separator(), meshId, -1 );
3154 createMenu( 801, meshId, -1 );
3155 createMenu( 806, meshId, -1 );
3156 createMenu( 802, meshId, -1 );
3157 createMenu( 803, meshId, -1 );
3158 createMenu( 815, meshId, -1 );
3159 createMenu( separator(), meshId, -1 );
3160 createMenu( 810, meshId, -1 );
3161 createMenu( 811, meshId, -1 );
3162 createMenu( 812, meshId, -1 );
3163 createMenu( separator(), meshId, -1 );
3164 createMenu( 814, meshId, -1 );
3165 createMenu( separator(), meshId, -1 );
3166 createMenu( 813, meshId, -1 );
3167 createMenu( separator(), meshId, -1 );
3168 createMenu( 900, meshId, -1 );
3169 createMenu( 902, meshId, -1 );
3170 createMenu( 903, meshId, -1 );
3171 createMenu( 904, meshId, -1 );
3172 createMenu( separator(), meshId, -1 );
3174 createMenu( 6003, ctrlId, -1 );
3175 createMenu( 6001, ctrlId, -1 );
3176 createMenu( 6004, ctrlId, -1 );
3177 createMenu( separator(), ctrlId, -1 );
3178 createMenu( 6005, ctrlId, -1 );
3179 createMenu( 6002, ctrlId, -1 );
3180 createMenu( 6018, ctrlId, -1 );
3181 createMenu( 6019, ctrlId, -1 );
3182 createMenu( 6011, ctrlId, -1 );
3183 createMenu( 6012, ctrlId, -1 );
3184 createMenu( 6013, ctrlId, -1 );
3185 createMenu( 6014, ctrlId, -1 );
3186 createMenu( 6015, ctrlId, -1 );
3187 createMenu( 6016, ctrlId, -1 );
3188 createMenu( separator(), ctrlId, -1 );
3189 createMenu( 6017, ctrlId, -1 );
3190 createMenu( 6009, ctrlId, -1 );
3191 createMenu( 6021, ctrlId, -1 );
3192 createMenu( separator(), ctrlId, -1 );
3194 createMenu( 4000, addId, -1 );
3195 createMenu( 4009, addId, -1 );
3196 createMenu( 4010, addId, -1 );
3197 createMenu( 4021, addId, -1 );
3198 createMenu( 4022, addId, -1 );
3199 createMenu( 4023, addId, -1 );
3200 createMenu( 4031, addId, -1 );
3201 createMenu( 4032, addId, -1 );
3202 createMenu( 4033, addId, -1 );
3203 createMenu( separator(), addId, -1 );
3204 createMenu( 4034, addId, -1 );
3205 createMenu( 4035, addId, -1 );
3206 createMenu( 4036, addId, -1 );
3207 createMenu( 4037, addId, -1 );
3208 createMenu( 4038, addId, -1 );
3209 createMenu( 4039, addId, -1 );
3210 createMenu( 4040, addId, -1 );
3212 createMenu( 4041, removeId, -1 );
3213 createMenu( 4042, removeId, -1 );
3214 createMenu( 4044, removeId, -1 );
3215 createMenu( separator(), removeId, -1 );
3216 createMenu( 4043, removeId, -1 );
3218 createMenu( 4051, renumId, -1 );
3219 createMenu( 4052, renumId, -1 );
3221 createMenu( 4061, transfId, -1 );
3222 createMenu( 4062, transfId, -1 );
3223 createMenu( 4063, transfId, -1 );
3224 createMenu( 4064, transfId, -1 );
3225 createMenu( 4065, transfId, -1 );
3226 createMenu( 4066, transfId, -1 );
3227 createMenu( 4068, transfId, -1 );
3228 createMenu( 4069, transfId, -1 );
3230 createMenu( 4067,modifyId, -1 );
3231 createMenu( 407, modifyId, -1 );
3232 createMenu( 408, modifyId, -1 );
3233 createMenu( 409, modifyId, -1 );
3234 createMenu( 410, modifyId, -1 );
3235 createMenu( 411, modifyId, -1 );
3236 createMenu( 419, modifyId, -1 );
3237 createMenu( 412, modifyId, -1 );
3238 createMenu( 413, modifyId, -1 );
3239 createMenu( 416, modifyId, -1 );
3240 createMenu( 414, modifyId, -1 );
3241 createMenu( 415, modifyId, -1 );
3242 createMenu( 417, modifyId, -1 );
3243 createMenu( 418, modifyId, -1 );
3245 createMenu( 214, viewId, -1 );
3247 // ----- create toolbars --------------
3248 int meshTb = createTool( tr( "TB_MESH" ) ),
3249 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3250 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3251 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3252 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3254 createTool( 702, meshTb );
3255 createTool( 703, meshTb );
3256 createTool( 704, meshTb );
3257 createTool( 710, meshTb );
3258 createTool( separator(), meshTb );
3259 createTool( 701, meshTb );
3260 createTool( 711, meshTb );
3261 createTool( 712, meshTb );
3262 createTool( 713, meshTb );
3263 createTool( separator(), meshTb );
3264 createTool( 801, meshTb );
3265 createTool( 806, meshTb );
3266 createTool( 802, meshTb );
3267 createTool( 803, meshTb );
3268 //createTool( 815, meshTb );
3269 createTool( separator(), meshTb );
3270 createTool( 900, meshTb );
3271 createTool( 902, meshTb );
3272 createTool( 903, meshTb );
3273 createTool( 904, meshTb );
3274 createTool( separator(), meshTb );
3276 createTool( 6001, ctrlTb );
3277 createTool( 6003, ctrlTb );
3278 createTool( 6004, ctrlTb );
3279 createTool( separator(), ctrlTb );
3280 createTool( 6005, ctrlTb );
3281 createTool( 6002, ctrlTb );
3282 createTool( 6018, ctrlTb );
3283 createTool( 6019, ctrlTb );
3284 createTool( 6011, ctrlTb );
3285 createTool( 6012, ctrlTb );
3286 createTool( 6013, ctrlTb );
3287 createTool( 6014, ctrlTb );
3288 createTool( 6015, ctrlTb );
3289 createTool( 6016, ctrlTb );
3290 createTool( separator(), ctrlTb );
3291 createTool( 6017, ctrlTb );
3292 createTool( 6009, ctrlTb );
3293 createTool( 6021, ctrlTb );
3294 createTool( separator(), ctrlTb );
3296 createTool( 4000, addRemTb );
3297 createTool( 4009, addRemTb );
3298 createTool( 4010, addRemTb );
3299 createTool( 4021, addRemTb );
3300 createTool( 4022, addRemTb );
3301 createTool( 4023, addRemTb );
3302 createTool( 4031, addRemTb );
3303 createTool( 4032, addRemTb );
3304 createTool( 4033, addRemTb );
3305 createTool( separator(), addRemTb );
3306 createTool( 4034, addRemTb );
3307 createTool( 4035, addRemTb );
3308 createTool( 4036, addRemTb );
3309 createTool( 4037, addRemTb );
3310 createTool( 4038, addRemTb );
3311 createTool( 4039, addRemTb );
3312 createTool( 4040, addRemTb );
3313 createTool( separator(), addRemTb );
3314 createTool( 4041, addRemTb );
3315 createTool( 4042, addRemTb );
3316 createTool( 4044, addRemTb );
3317 createTool( 4043, addRemTb );
3318 createTool( separator(), addRemTb );
3319 createTool( 4051, addRemTb );
3320 createTool( 4052, addRemTb );
3321 createTool( separator(), addRemTb );
3322 createTool( 4061, addRemTb );
3323 createTool( 4062, addRemTb );
3324 createTool( 4063, addRemTb );
3325 createTool( 4064, addRemTb );
3326 createTool( 4065, addRemTb );
3327 createTool( 4066, addRemTb );
3328 createTool( 4068, addRemTb );
3329 createTool( 4069, addRemTb );
3330 createTool( separator(), addRemTb );
3332 createTool( 4067,modifyTb );
3333 createTool( 407, modifyTb );
3334 createTool( 408, modifyTb );
3335 createTool( 409, modifyTb );
3336 createTool( 410, modifyTb );
3337 createTool( 411, modifyTb );
3338 createTool( 419, modifyTb );
3339 createTool( 412, modifyTb );
3340 createTool( 413, modifyTb );
3341 createTool( 416, modifyTb );
3342 createTool( 414, modifyTb );
3343 createTool( 415, modifyTb );
3344 createTool( 417, modifyTb );
3345 createTool( 418, modifyTb );
3347 createTool( 214, dispModeTb );
3349 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3350 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3353 QString OB = "'ObjectBrowser'",
3354 View = "'" + SVTK_Viewer::Type() + "'",
3356 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3357 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3358 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3359 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3360 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3361 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3362 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3363 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3364 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3365 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3366 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3368 mesh_group = mesh + " " + subMesh + " " + group,
3369 hyp_alg = hypo + " " + algo;
3371 // popup for object browser
3373 isInvisible("not( isVisible )"),
3374 isEmpty("numberOfNodes = 0"),
3375 isNotEmpty("numberOfNodes <> 0"),
3377 // has nodes, edges, etc in VISIBLE! actor
3378 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3379 hasElems("(count( elemTypes ) > 0)"),
3380 hasDifferentElems("(count( elemTypes ) > 1)"),
3381 hasElems0d("({'Elem0d'} in elemTypes)"),
3382 hasEdges("({'Edge'} in elemTypes)"),
3383 hasFaces("({'Face'} in elemTypes)"),
3384 hasVolumes("({'Volume'} in elemTypes)");
3386 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3387 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3388 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3389 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3390 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3391 createPopupItem( 803, OB, group ); // EDIT_GROUP
3392 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3394 popupMgr()->insert( separator(), -1, 0 );
3395 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3396 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3397 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3398 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3399 createPopupItem( 214, OB, mesh_group ); // UPDATE
3400 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3401 createPopupItem( 902, OB, mesh ); // STD_INFO
3402 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3403 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3404 popupMgr()->insert( separator(), -1, 0 );
3405 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3406 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3407 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3408 popupMgr()->insert( separator(), -1, 0 );
3409 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3410 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3411 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3412 popupMgr()->insert( separator(), -1, 0 );
3413 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3414 popupMgr()->insert( separator(), -1, 0 );
3415 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3416 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3417 popupMgr()->insert( separator(), -1, 0 );
3419 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3420 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3422 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3423 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3424 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3425 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3426 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3427 popupMgr()->insert( separator(), -1, 0 );
3430 createPopupItem( 803, View, group ); // EDIT_GROUP
3431 createPopupItem( 804, View, elems ); // ADD
3432 createPopupItem( 805, View, elems ); // REMOVE
3434 popupMgr()->insert( separator(), -1, 0 );
3435 createPopupItem( 214, View, mesh_group ); // UPDATE
3436 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3437 createPopupItem( 902, View, mesh ); // STD_INFO
3438 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3439 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3440 popupMgr()->insert( separator(), -1, 0 );
3442 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3443 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3444 popupMgr()->insert( separator(), -1, 0 );
3447 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3448 QString aType = QString( "%1type in {%2}" ).arg( lc );
3449 aType = aType.arg( mesh_group );
3450 QString aMeshInVTK = aClient + "&&" + aType;
3452 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3453 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3454 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3456 //-------------------------------------------------
3458 //-------------------------------------------------
3459 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3461 popupMgr()->insert( action( 9010 ), anId, -1 );
3462 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3463 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3465 popupMgr()->insert( action( 9011 ), anId, -1 );
3466 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3467 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3469 popupMgr()->insert( separator(), -1, -1 );
3471 //-------------------------------------------------
3473 //-------------------------------------------------
3474 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3476 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3477 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3478 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3480 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3481 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3482 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3484 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3485 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3486 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3488 popupMgr()->insert( separator(), anId, -1 );
3490 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3491 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3492 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3494 //-------------------------------------------------
3496 //-------------------------------------------------
3497 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3499 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3501 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3502 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3503 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3505 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3506 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3507 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3509 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3510 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3511 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3513 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3514 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3515 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3517 popupMgr()->insert( separator(), anId, -1 );
3519 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3520 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3523 //-------------------------------------------------
3524 // Representation of the 2D Quadratic elements
3525 //-------------------------------------------------
3526 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3527 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3528 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3529 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3531 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3532 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3533 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3535 //-------------------------------------------------
3536 // Orientation of faces
3537 //-------------------------------------------------
3538 popupMgr()->insert( action( 221 ), -1, -1 );
3539 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3540 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3542 //-------------------------------------------------
3544 //-------------------------------------------------
3545 popupMgr()->insert( action( 1132 ), -1, -1 );
3546 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3548 //-------------------------------------------------
3550 //-------------------------------------------------
3551 popupMgr()->insert( action( 1133 ), -1, -1 );
3552 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3554 //-------------------------------------------------
3556 //-------------------------------------------------
3557 popupMgr()->insert( action( 1134 ), -1, -1 );
3558 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3560 popupMgr()->insert( separator(), -1, -1 );
3562 //-------------------------------------------------
3564 //-------------------------------------------------
3566 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3567 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3568 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3569 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3571 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3573 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3574 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3576 popupMgr()->insert( separator(), anId, -1 );
3578 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3579 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3580 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3582 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3583 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3584 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3586 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3587 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3588 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3590 popupMgr()->insert( separator(), anId, -1 );
3592 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3593 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3594 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3596 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3597 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3598 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3600 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3601 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3602 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3604 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3605 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3606 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3608 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3609 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3610 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3612 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3613 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3614 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3616 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3617 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3618 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3620 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3621 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3622 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3624 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3625 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3626 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3628 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3629 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3630 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3632 popupMgr()->insert( separator(), anId, -1 );
3634 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3635 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3636 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3638 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3639 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3640 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3642 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3643 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3644 QtxPopupMgr::VisibleRule );
3645 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3647 popupMgr()->insert( separator(), anId, -1 );
3649 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3650 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3652 popupMgr()->insert( separator(), -1, -1 );
3654 //-------------------------------------------------
3656 //-------------------------------------------------
3657 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3658 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3659 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3660 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3662 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3663 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3665 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3666 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3668 popupMgr()->insert( separator(), -1, -1 );
3670 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3671 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3674 //================================================================================
3676 * \brief Return true if SMESH or GEOM objects are selected.
3677 * Is called form LightApp_Module::activateModule() which clear selection if
3678 * not isSelectionCompatible()
3680 //================================================================================
3682 bool SMESHGUI::isSelectionCompatible()
3684 bool isCompatible = true;
3685 SALOME_ListIO selected;
3686 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3687 Sel->selectedObjects( selected );
3689 SALOME_ListIteratorOfListIO It( selected );
3690 for ( ; isCompatible && It.More(); It.Next())
3692 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3693 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3695 return isCompatible;
3699 bool SMESHGUI::reusableOperation( const int id )
3701 // compute, evaluate and precompute are not reusable operations
3702 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3705 bool SMESHGUI::activateModule( SUIT_Study* study )
3707 bool res = SalomeApp_Module::activateModule( study );
3709 setMenuShown( true );
3710 setToolShown( true );
3712 // Reset actions accelerator keys
3713 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3714 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3715 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3717 action( 33)->setEnabled(true); // Delete: Key_Delete
3718 action(1101)->setEnabled(true); // Rename: Key_F2
3720 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3721 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3722 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3723 if ( _PTR(Study) aStudy = s->studyDS()) {
3724 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3725 updateObjBrowser(); // objects can be removed
3731 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3733 setMenuShown( false );
3734 setToolShown( false );
3736 EmitSignalCloseAllDialogs();
3738 // Unset actions accelerator keys
3739 action(111)->setShortcut(QKeySequence()); // Import DAT
3740 action(112)->setShortcut(QKeySequence()); // Import UNV
3741 action(113)->setShortcut(QKeySequence()); // Import MED
3743 action( 33)->setEnabled(false); // Delete: Key_Delete
3744 action(1101)->setEnabled(false); // Rename: Key_F2
3746 return SalomeApp_Module::deactivateModule( study );
3749 void SMESHGUI::studyClosed( SUIT_Study* s )
3751 SMESH::RemoveVisuData( s->id() );
3752 SalomeApp_Module::studyClosed( s );
3755 void SMESHGUI::OnGUIEvent()
3757 const QObject* obj = sender();
3758 if ( !obj || !obj->inherits( "QAction" ) )
3760 int id = actionId((QAction*)obj);
3765 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3767 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3768 if ( CORBA::is_nil( myComponentSMESH ) )
3770 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3772 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3773 return aGUI.myComponentSMESH;
3776 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3777 return myComponentSMESH;
3780 QString SMESHGUI::engineIOR() const
3782 CORBA::ORB_var anORB = getApp()->orb();
3783 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3784 return QString( anIOR.in() );
3787 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3789 SalomeApp_Module::contextMenuPopup( client, menu, title );
3791 selectionMgr()->selectedObjects( lst );
3792 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3793 Handle(SALOME_InteractiveObject) io = lst.First();
3794 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3795 _PTR(Study) study = appStudy->studyDS();
3796 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3798 QString aName = QString( obj->GetName().c_str() );
3799 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3800 aName.remove( (aName.length() - 1), 1 );
3806 LightApp_Selection* SMESHGUI::createSelection() const
3808 return new SMESHGUI_Selection();
3811 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3813 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3814 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3817 void SMESHGUI::viewManagers( QStringList& list ) const
3819 list.append( SVTK_Viewer::Type() );
3822 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3824 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3825 SMESH::UpdateSelectionProp( this );
3828 void SMESHGUI::createPreferences()
3830 // General tab ------------------------------------------------------------------------
3831 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3833 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
3834 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
3835 setPreferenceProperty( lim, "min", 0 );
3836 setPreferenceProperty( lim, "max", 100000000 );
3837 setPreferenceProperty( lim, "step", 1000 );
3838 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
3840 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3841 setPreferenceProperty( qaGroup, "columns", 2 );
3842 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3843 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3844 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3845 setPreferenceProperty( prec, "min", 0 );
3846 setPreferenceProperty( prec, "max", 16 );
3848 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3849 setPreferenceProperty( dispgroup, "columns", 2 );
3850 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3852 modes.append( "Wireframe" );
3853 modes.append( "Shading" );
3854 modes.append( "Nodes" );
3855 modes.append( "Shrink" );
3856 QList<QVariant> indices;
3857 indices.append( 0 );
3858 indices.append( 1 );
3859 indices.append( 2 );
3860 indices.append( 3 );
3861 setPreferenceProperty( dispmode, "strings", modes );
3862 setPreferenceProperty( dispmode, "indexes", indices );
3864 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3865 setPreferenceProperty( arcgroup, "columns", 2 );
3866 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3867 QStringList quadraticModes;
3868 quadraticModes.append("Lines");
3869 quadraticModes.append("Arcs");
3871 indices.append( 0 );
3872 indices.append( 1 );
3873 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3874 setPreferenceProperty( quadraticmode, "indexes", indices );
3876 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3877 "SMESH", "max_angle" );
3878 setPreferenceProperty( maxAngle, "min", 1 );
3879 setPreferenceProperty( maxAngle, "max", 90 );
3883 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3884 setPreferenceProperty( exportgroup, "columns", 2 );
3885 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3886 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3888 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3889 setPreferenceProperty( computeGroup, "columns", 2 );
3890 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3892 modes.append( "Never" );
3893 modes.append( "Errors only" );
3894 modes.append( "Always" );
3896 indices.append( 0 );
3897 indices.append( 1 );
3898 indices.append( 2 );
3899 setPreferenceProperty( notifyMode, "strings", modes );
3900 setPreferenceProperty( notifyMode, "indexes", indices );
3902 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3903 setPreferenceProperty( segGroup, "columns", 2 );
3904 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3905 "SMESH", "segmentation" );
3906 setPreferenceProperty( segLen, "min", 1 );
3907 setPreferenceProperty( segLen, "max", 10000000 );
3908 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3909 "SMESH", "nb_segments_per_edge" );
3910 setPreferenceProperty( nbSeg, "min", 1 );
3911 setPreferenceProperty( nbSeg, "max", 10000000 );
3913 // Quantities with individual precision settings
3914 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
3915 setPreferenceProperty( precGroup, "columns", 2 );
3917 const int nbQuantities = 6;
3918 int precs[nbQuantities], ii = 0;
3919 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
3920 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
3921 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
3922 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
3923 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
3924 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
3925 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
3926 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
3927 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
3928 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
3929 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
3930 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
3932 // Set property for precision value for spinboxes
3933 for ( ii = 0; ii < nbQuantities; ii++ ){
3934 setPreferenceProperty( precs[ii], "min", -14 );
3935 setPreferenceProperty( precs[ii], "max", 14 );
3936 setPreferenceProperty( precs[ii], "precision", 2 );
3939 // Mesh tab ------------------------------------------------------------------------
3940 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3941 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3942 setPreferenceProperty( nodeGroup, "columns", 3 );
3944 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3946 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
3948 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3949 QList<QVariant> aMarkerTypeIndicesList;
3950 QList<QVariant> aMarkerTypeIconsList;
3951 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
3952 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
3953 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
3954 aMarkerTypeIndicesList << i;
3955 aMarkerTypeIconsList << pixmap;
3957 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
3958 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
3960 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
3962 QList<QVariant> aMarkerScaleIndicesList;
3963 QStringList aMarkerScaleValuesList;
3964 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
3965 aMarkerScaleIndicesList << i;
3966 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
3968 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
3969 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
3971 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3972 setPreferenceProperty( elemGroup, "columns", 2 );
3974 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3975 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3976 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3977 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3979 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
3980 setPreferenceProperty( grpGroup, "columns", 2 );
3982 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
3984 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3985 //setPreferenceProperty( sp, "hstretch", 0 );
3986 //setPreferenceProperty( sp, "vstretch", 0 );
3988 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3989 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3990 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3991 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3992 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3993 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3994 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3996 setPreferenceProperty( size0d, "min", 1 );
3997 setPreferenceProperty( size0d, "max", 10 );
3999 setPreferenceProperty( sp, "hstretch", 0 );
4000 setPreferenceProperty( sp, "vstretch", 0 );
4002 setPreferenceProperty( elemW, "min", 1 );
4003 setPreferenceProperty( elemW, "max", 5 );
4005 setPreferenceProperty( shrink, "min", 0 );
4006 setPreferenceProperty( shrink, "max", 100 );
4008 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4009 setPreferenceProperty( orientGroup, "columns", 1 );
4011 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4012 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4014 setPreferenceProperty( orientScale, "min", 0.05 );
4015 setPreferenceProperty( orientScale, "max", 0.5 );
4016 setPreferenceProperty( orientScale, "step", 0.05 );
4018 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4020 // Selection tab ------------------------------------------------------------------------
4021 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4023 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4024 setPreferenceProperty( selGroup, "columns", 2 );
4026 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4027 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4028 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4030 setPreferenceProperty( selW, "min", 1 );
4031 setPreferenceProperty( selW, "max", 5 );
4033 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4034 setPreferenceProperty( preGroup, "columns", 2 );
4036 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4037 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4039 setPreferenceProperty( preW, "min", 1 );
4040 setPreferenceProperty( preW, "max", 5 );
4042 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4043 setPreferenceProperty( precSelGroup, "columns", 2 );
4045 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4046 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4047 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4049 // Scalar Bar tab ------------------------------------------------------------------------
4050 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4051 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4052 setPreferenceProperty( fontGr, "columns", 2 );
4054 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4055 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4057 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4058 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4060 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4061 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4063 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4064 setPreferenceProperty( numcol, "min", 2 );
4065 setPreferenceProperty( numcol, "max", 256 );
4067 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4068 setPreferenceProperty( numlab, "min", 2 );
4069 setPreferenceProperty( numlab, "max", 65 );
4071 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4072 setPreferenceProperty( orientGr, "columns", 2 );
4073 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4074 QStringList orients;
4075 orients.append( tr( "SMESH_VERTICAL" ) );
4076 orients.append( tr( "SMESH_HORIZONTAL" ) );
4077 indices.clear(); indices.append( 0 ); indices.append( 1 );
4078 setPreferenceProperty( orient, "strings", orients );
4079 setPreferenceProperty( orient, "indexes", indices );
4081 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4082 setPreferenceProperty( posVSizeGr, "columns", 2 );
4083 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4084 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4085 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4086 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4087 setPreferenceProperty( xv, "step", 0.1 );
4088 setPreferenceProperty( xv, "min", 0.0 );
4089 setPreferenceProperty( xv, "max", 1.0 );
4090 setPreferenceProperty( yv, "step", 0.1 );
4091 setPreferenceProperty( yv, "min", 0.0 );
4092 setPreferenceProperty( yv, "max", 1.0 );
4093 setPreferenceProperty( wv, "step", 0.1 );
4094 setPreferenceProperty( wv, "min", 0.0 );
4095 setPreferenceProperty( wv, "max", 1.0 );
4096 setPreferenceProperty( hv, "min", 0.0 );
4097 setPreferenceProperty( hv, "max", 1.0 );
4098 setPreferenceProperty( hv, "step", 0.1 );
4100 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4101 setPreferenceProperty( posHSizeGr, "columns", 2 );
4102 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4103 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4104 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4105 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4106 setPreferenceProperty( xv, "min", 0.0 );
4107 setPreferenceProperty( xv, "max", 1.0 );
4108 setPreferenceProperty( xv, "step", 0.1 );
4109 setPreferenceProperty( xh, "min", 0.0 );
4110 setPreferenceProperty( xh, "max", 1.0 );
4111 setPreferenceProperty( xh, "step", 0.1 );
4112 setPreferenceProperty( yh, "min", 0.0 );
4113 setPreferenceProperty( yh, "max", 1.0 );
4114 setPreferenceProperty( yh, "step", 0.1 );
4115 setPreferenceProperty( wh, "min", 0.0 );
4116 setPreferenceProperty( wh, "max", 1.0 );
4117 setPreferenceProperty( wh, "step", 0.1 );
4118 setPreferenceProperty( hh, "min", 0.0 );
4119 setPreferenceProperty( hh, "max", 1.0 );
4120 setPreferenceProperty( hh, "step", 0.1 );
4123 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4125 if( sect=="SMESH" ) {
4126 float sbX1,sbY1,sbW,sbH;
4127 float aTol = 1.00000009999999;
4128 std::string aWarning;
4129 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4130 if( name=="selection_object_color" || name=="selection_element_color" ||
4131 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4132 name=="selection_precision_node" || name=="selection_precision_element" ||
4133 name=="selection_precision_object")
4134 SMESH::UpdateSelectionProp( this );
4135 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4136 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4137 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4138 if(sbX1+sbW > aTol){
4139 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4142 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4143 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4146 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4147 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4148 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4149 if(sbY1+sbH > aTol){
4150 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4151 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4152 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4155 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4156 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4157 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4158 if(sbX1+sbW > aTol){
4159 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4162 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4163 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4166 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4167 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4168 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4169 if(sbY1+sbH > aTol){
4170 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4173 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4174 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4177 else if ( name == "segmentation" ) {
4178 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4179 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4181 else if ( name == "nb_segments_per_edge" ) {
4182 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4183 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4186 if(aWarning.size() != 0){
4187 aWarning += "The default values are applied instead.";
4188 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4189 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4190 QObject::tr(aWarning.c_str()));
4195 //================================================================================
4197 * \brief Update something in accordance with update flags
4198 * \param theFlags - update flags
4200 * Update viewer or/and object browser etc. in accordance with update flags ( see
4201 * LightApp_UpdateFlags enumeration ).
4203 //================================================================================
4204 void SMESHGUI::update( const int flags )
4206 if ( flags & UF_Viewer | flags & UF_Forced )
4207 SMESH::UpdateView();
4209 SalomeApp_Module::update( flags );
4212 //================================================================================
4214 * \brief Set default selection mode
4216 * SLOT called when operation commited. Sets default selection mode
4218 //================================================================================
4219 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4221 SVTK_ViewWindow* vtkWnd =
4222 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4224 vtkWnd->SetSelectionMode( ActorSelection );
4227 //================================================================================
4229 * \brief Set default selection mode
4231 * SLOT called when operation aborted. Sets default selection mode
4233 //================================================================================
4234 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4236 SVTK_ViewWindow* vtkWnd =
4237 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4239 vtkWnd->SetSelectionMode( ActorSelection );
4242 //================================================================================
4244 * \brief Creates operation with given identifier
4245 * \param id - identifier of operation to be started
4246 * \return Pointer on created operation or NULL if operation is not created
4248 * Virtual method redefined from the base class creates operation with given id.
4249 * It is called called automatically from startOperation method of base class.
4251 //================================================================================
4252 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4254 LightApp_Operation* op = 0;
4255 // to do : create operation here
4258 case 417: //convert to quadratic
4259 op = new SMESHGUI_ConvToQuadOp();
4261 case 418: // create 2D mesh as boundary on 3D
4262 op = new SMESHGUI_Make2DFrom3DOp();
4264 case 701: // Compute mesh
4265 op = new SMESHGUI_ComputeOp();
4267 case 702: // Create mesh
4268 op = new SMESHGUI_MeshOp( true, true );
4270 case 703: // Create sub-mesh
4271 op = new SMESHGUI_MeshOp( true, false );
4273 case 704: // Edit mesh/sub-mesh
4274 op = new SMESHGUI_MeshOp( false );
4276 case 711: // Precompute mesh
4277 op = new SMESHGUI_PrecomputeOp();
4279 case 712: // Evaluate mesh
4280 op = new SMESHGUI_EvaluateOp();
4282 case 713: // Evaluate mesh
4283 op = new SMESHGUI_MeshOrderOp();
4285 case 806: // Create group on geom
4286 op = new SMESHGUI_GroupOnShapeOp();
4288 case 904: // Find element
4289 op = new SMESHGUI_FindElemByPointOp();
4291 case 4067: // make mesh pass through point
4292 op = new SMESHGUI_MakeNodeAtPointOp();
4299 op = SalomeApp_Module::createOperation( id );
4303 //================================================================================
4305 * \brief Stops current operations and starts a given one
4306 * \param id - The id of the operation to start
4308 //================================================================================
4310 void SMESHGUI::switchToOperation(int id)
4312 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4313 activeStudy()->abortAllOperations();
4314 startOperation( id );
4317 LightApp_Displayer* SMESHGUI::displayer()
4320 myDisplayer = new SMESHGUI_Displayer( getApp() );
4324 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4327 int aTolerance = 64;
4328 int anIterations = 0;
4334 if( anIterations % aPeriod == 0 )
4337 if( aTolerance < 1 )
4340 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4342 aHue = (int)( 360.0 * rand() / RAND_MAX );
4343 //cout << "Hue = " << aHue << endl;
4345 //cout << "Auto colors : ";
4347 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4348 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4349 for( ; it != itEnd; ++it )
4351 SALOMEDS::Color anAutoColor = *it;
4352 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4355 aQColor.getHsv( &h, &s, &v );
4357 if( abs( h - aHue ) < aTolerance )
4360 //cout << "break (diff = " << abs( h - aHue ) << ")";
4370 //cout << "Hue of the returned color = " << aHue << endl;
4372 aColor.setHsv( aHue, 255, 255 );
4374 SALOMEDS::Color aSColor;
4375 aSColor.R = (double)aColor.red() / 255.0;
4376 aSColor.G = (double)aColor.green() / 255.0;
4377 aSColor.B = (double)aColor.blue() / 255.0;
4382 const char gSeparator = '_'; // character used to separate parameter names
4383 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4384 const char gPathSep = '|'; // character used to separate paths
4387 * \brief Store visual parameters
4389 * This method is called just before the study document is saved.
4390 * Store visual parameters in AttributeParameter attribue(s)
4392 void SMESHGUI::storeVisualParameters (int savePoint)
4394 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4395 if (!appStudy || !appStudy->studyDS())
4397 _PTR(Study) studyDS = appStudy->studyDS();
4399 // componentName is used for encoding of entries when storing them in IParameters
4400 std::string componentName = myComponentSMESH->ComponentDataType();
4401 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4402 //if (!aSComponent) return;
4405 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4406 componentName.c_str(),
4408 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4410 // store map of custom markers
4411 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4412 if( !aMarkerMap.empty() )
4414 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4415 for( ; anIter != aMarkerMap.end(); anIter++ )
4417 int anId = anIter->first;
4418 VTK::MarkerData aMarkerData = anIter->second;
4419 std::string aMarkerFileName = aMarkerData.first;
4420 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4421 if( aMarkerTexture.size() < 3 )
4422 continue; // should contain at least width, height and the first value
4424 QString aPropertyName( "texture" );
4425 aPropertyName += gSeparator;
4426 aPropertyName += QString::number( anId );
4428 QString aPropertyValue = aMarkerFileName.c_str();
4429 aPropertyValue += gPathSep;
4431 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4432 ushort aWidth = *aTextureIter++;
4433 ushort aHeight = *aTextureIter++;
4434 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4435 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4436 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4437 aPropertyValue += QString::number( *aTextureIter );
4439 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4443 // viewers counters are used for storing view_numbers in IParameters
4446 // main cycle to store parameters of displayed objects
4447 QList<SUIT_ViewManager*> lst;
4448 QList<SUIT_ViewManager*>::Iterator it;
4449 getApp()->viewManagers(lst);
4450 for (it = lst.begin(); it != lst.end(); it++)
4452 SUIT_ViewManager* vman = *it;
4453 QString vType = vman->getType();
4455 // saving VTK actors properties
4456 if (vType == SVTK_Viewer::Type())
4458 QVector<SUIT_ViewWindow*> views = vman->getViews();
4459 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4461 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4463 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4464 vtkActorCollection* allActors = aCopy.GetActors();
4465 allActors->InitTraversal();
4466 while (vtkActor* actor = allActors->GetNextActor())
4468 if (actor->GetVisibility()) // store only visible actors
4470 SMESH_Actor* aSmeshActor = 0;
4471 if (actor->IsA("SMESH_Actor"))
4472 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4473 if (aSmeshActor && aSmeshActor->hasIO())
4475 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4478 // entry is "encoded" = it does NOT contain component adress,
4479 // since it is a subject to change on next component loading
4480 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4482 std::string param, vtkParam = vType.toLatin1().data();
4483 vtkParam += gSeparator;
4484 vtkParam += QString::number(vtkViewers).toLatin1().data();
4485 vtkParam += gSeparator;
4488 param = vtkParam + "Visibility";
4489 ip->setParameter(entry, param, "On");
4492 param = vtkParam + "Representation";
4493 ip->setParameter(entry, param, QString::number
4494 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4497 param = vtkParam + "IsShrunk";
4498 ip->setParameter(entry, param, QString::number
4499 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4501 // Displayed entities
4502 unsigned int aMode = aSmeshActor->GetEntityMode();
4503 bool isE = aMode & SMESH_Actor::eEdges;
4504 bool isF = aMode & SMESH_Actor::eFaces;
4505 bool isV = aMode & SMESH_Actor::eVolumes;
4507 QString modeStr ("e");
4508 modeStr += gDigitsSep; modeStr += QString::number(isE);
4509 modeStr += gDigitsSep; modeStr += "f";
4510 modeStr += gDigitsSep; modeStr += QString::number(isF);
4511 modeStr += gDigitsSep; modeStr += "v";
4512 modeStr += gDigitsSep; modeStr += QString::number(isV);
4514 param = vtkParam + "Entities";
4515 ip->setParameter(entry, param, modeStr.toLatin1().data());
4517 // Colors (surface:edge:)
4518 vtkFloatingPointType r, g, b;
4520 aSmeshActor->GetSufaceColor(r, g, b);
4521 QString colorStr ("surface");
4522 colorStr += gDigitsSep; colorStr += QString::number(r);
4523 colorStr += gDigitsSep; colorStr += QString::number(g);
4524 colorStr += gDigitsSep; colorStr += QString::number(b);
4526 aSmeshActor->GetBackSufaceColor(r, g, b);
4527 colorStr += gDigitsSep; colorStr += "backsurface";
4528 colorStr += gDigitsSep; colorStr += QString::number(r);
4529 colorStr += gDigitsSep; colorStr += QString::number(g);
4530 colorStr += gDigitsSep; colorStr += QString::number(b);
4532 aSmeshActor->GetEdgeColor(r, g, b);
4533 colorStr += gDigitsSep; colorStr += "edge";
4534 colorStr += gDigitsSep; colorStr += QString::number(r);
4535 colorStr += gDigitsSep; colorStr += QString::number(g);
4536 colorStr += gDigitsSep; colorStr += QString::number(b);
4538 aSmeshActor->GetNodeColor(r, g, b);
4539 colorStr += gDigitsSep; colorStr += "node";
4540 colorStr += gDigitsSep; colorStr += QString::number(r);
4541 colorStr += gDigitsSep; colorStr += QString::number(g);
4542 colorStr += gDigitsSep; colorStr += QString::number(b);
4544 param = vtkParam + "Colors";
4545 ip->setParameter(entry, param, colorStr.toLatin1().data());
4547 // Sizes of lines and points
4548 QString sizeStr ("line");
4549 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4550 sizeStr += gDigitsSep; sizeStr += "shrink";
4551 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4553 param = vtkParam + "Sizes";
4554 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4559 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4560 if( aMarkerType == VTK::MT_USER ) {
4561 markerStr += "custom";
4562 markerStr += gDigitsSep;
4563 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4567 markerStr += gDigitsSep;
4568 markerStr += QString::number( (int)aMarkerType );
4569 markerStr += gDigitsSep;
4570 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4573 param = vtkParam + "PointMarker";
4574 ip->setParameter(entry, param, markerStr.toLatin1().data());
4577 param = vtkParam + "Opacity";
4578 ip->setParameter(entry, param,
4579 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4582 param = vtkParam + "ClippingPlane";
4583 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4585 ip->setParameter(entry, param, "Off");
4586 for (int ipl = 0; ipl < nPlanes; ipl++) {
4587 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4588 SMESH::Orientation anOrientation;
4590 vtkFloatingPointType anAngle[2];
4591 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4592 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4593 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4594 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4595 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4597 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4599 } // if (io->hasEntry())
4600 } // SMESH_Actor && hasIO
4602 } // while.. actors traversal
4606 } // if (SVTK view model)
4607 } // for (viewManagers)
4611 * \brief Restore visual parameters
4613 * This method is called after the study document is opened.
4614 * Restore visual parameters from AttributeParameter attribue(s)
4616 void SMESHGUI::restoreVisualParameters (int savePoint)
4618 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4619 if (!appStudy || !appStudy->studyDS())
4621 _PTR(Study) studyDS = appStudy->studyDS();
4623 // componentName is used for encoding of entries when storing them in IParameters
4624 std::string componentName = myComponentSMESH->ComponentDataType();
4625 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4626 //if (!aSComponent) return;
4629 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4630 componentName.c_str(),
4632 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4634 // restore map of custom markers
4635 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4637 std::vector<std::string> properties = ip->getProperties();
4638 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4640 std::string property = *propIt;
4641 QString aPropertyName( property.c_str() );
4642 QString aPropertyValue( ip->getProperty( property ).c_str() );
4644 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4645 if( aPropertyNameList.size() != 2 )
4650 if( aPropertyNameList[0] == "texture" )
4651 anId = aPropertyNameList[1].toInt( &ok );
4653 if( !ok || anId < 1 )
4656 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4657 if( aPropertyValueList.size() != 2 )
4660 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4661 QString aMarkerTextureString = aPropertyValueList[1];
4662 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4663 if( aMarkerTextureStringList.size() != 3 )
4667 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4672 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4676 VTK::MarkerTexture aMarkerTexture;
4677 aMarkerTexture.push_back( aWidth );
4678 aMarkerTexture.push_back( aHeight );
4680 QString aMarkerTextureData = aMarkerTextureStringList[2];
4681 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4683 QChar aChar = aMarkerTextureData.at( i );
4684 if( aChar.isDigit() )
4685 aMarkerTexture.push_back( aChar.digitValue() );
4688 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4691 std::vector<std::string> entries = ip->getEntries();
4693 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4695 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4696 QString entry (ip->decodeEntry(*entIt).c_str());
4698 // Check that the entry corresponds to a real object in the Study
4699 // as the object may be deleted or modified after the visual state is saved.
4700 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4701 if (!so) continue; //Skip the not existent entry
4703 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4704 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4706 std::vector<std::string>::iterator namesIt = paramNames.begin();
4707 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4709 // actors are stored in a map after displaying of them for
4710 // quicker access in the future: map < viewID to actor >
4711 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4713 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4715 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4716 // '_' is used as separator and should not be used in viewer type or parameter names.
4717 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4718 if (lst.size() != 3)
4721 QString viewerTypStr = lst[0];
4722 QString viewIndexStr = lst[1];
4723 QString paramNameStr = lst[2];
4726 int viewIndex = viewIndexStr.toUInt(&ok);
4727 if (!ok) // bad conversion of view index to integer
4731 if (viewerTypStr == SVTK_Viewer::Type())
4733 SMESH_Actor* aSmeshActor = 0;
4734 if (vtkActors.IsBound(viewIndex))
4735 aSmeshActor = vtkActors.Find(viewIndex);
4737 if (paramNameStr == "Visibility")
4739 if (!aSmeshActor && displayer())
4741 QList<SUIT_ViewManager*> lst;
4742 getApp()->viewManagers(viewerTypStr, lst);
4744 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4745 if (viewIndex >= 0 && viewIndex < lst.count()) {
4746 SUIT_ViewManager* vman = lst.at(viewIndex);
4747 SUIT_ViewModel* vmodel = vman->getViewModel();
4748 // SVTK view model can be casted to SALOME_View
4749 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4751 // store displayed actor in a temporary map for quicker
4752 // access later when restoring other parameters
4753 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4754 vtkRenderer* Renderer = vtkView->getRenderer();
4755 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4756 vtkActorCollection* theActors = aCopy.GetActors();
4757 theActors->InitTraversal();
4758 bool isFound = false;
4759 vtkActor *ac = theActors->GetNextActor();
4760 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4761 if (ac->IsA("SMESH_Actor")) {
4762 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4763 if (aGeomAc->hasIO()) {
4764 Handle(SALOME_InteractiveObject) io =
4765 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4766 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4768 vtkActors.Bind(viewIndex, aGeomAc);
4775 } // if (paramNameStr == "Visibility")
4778 // the rest properties "work" with SMESH_Actor
4781 QString val ((*valuesIt).c_str());
4784 if (paramNameStr == "Representation") {
4785 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4788 else if (paramNameStr == "IsShrunk") {
4790 if (!aSmeshActor->IsShrunk())
4791 aSmeshActor->SetShrink();
4794 if (aSmeshActor->IsShrunk())
4795 aSmeshActor->UnShrink();
4798 // Displayed entities
4799 else if (paramNameStr == "Entities") {
4800 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4801 if (mode.count() == 6) {
4802 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4803 MESSAGE("Invalid order of data in Entities, must be: "
4804 "e:0/1:f:0/1:v:0/1");
4807 unsigned int aMode = aSmeshActor->GetEntityMode();
4808 unsigned int aNewMode =
4809 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4810 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4811 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4812 if (aNewMode != aMode)
4813 aSmeshActor->SetEntityMode(aNewMode);
4818 else if (paramNameStr == "Colors") {
4819 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4820 if (colors.count() == 16) {
4821 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4822 colors[8] != "edge" || colors[12] != "node") {
4823 MESSAGE("Invalid order of data in Colors, must be: "
4824 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4827 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4828 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4829 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4830 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4834 // Sizes of lines and points
4835 else if (paramNameStr == "Sizes") {
4836 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4837 if (sizes.count() == 4) {
4838 if (sizes[0] != "line" || sizes[2] != "shrink") {
4839 MESSAGE("Invalid order of data in Sizes, must be: "
4840 "line:int:shrink:float");
4843 aSmeshActor->SetLineWidth(sizes[1].toInt());
4844 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4847 else if (sizes.count() == 6) { // just to support old format
4848 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4849 MESSAGE("Invalid order of data in Sizes, must be: "
4850 "line:int:node:int:shrink:float");
4853 aSmeshActor->SetLineWidth(sizes[1].toInt());
4854 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4855 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4860 else if (paramNameStr == "PointMarker") {
4861 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
4862 if( data.count() >= 2 ) {
4864 int aParam1 = data[1].toInt( &ok );
4866 if( data[0] == "std" && data.count() == 3 ) {
4867 int aParam2 = data[2].toInt( &ok );
4868 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
4870 else if( data[0] == "custom" ) {
4871 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
4872 if( markerIt != aMarkerMap.end() ) {
4873 VTK::MarkerData aMarkerData = markerIt->second;
4874 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
4881 else if (paramNameStr == "Opacity") {
4882 aSmeshActor->SetOpacity(val.toFloat());
4885 else if (paramNameStr.startsWith("ClippingPlane")) {
4886 cout << "$$$ ClippingPlane 1" << endl;
4887 if (paramNameStr == "ClippingPlane1" || val == "Off")
4888 aSmeshActor->RemoveAllClippingPlanes();
4890 cout << "$$$ ClippingPlane 2" << endl;
4891 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4892 if (vals.count() == 4) { // format check: 4 values
4893 cout << "$$$ ClippingPlane 3" << endl;
4894 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4895 double aDistance = vals[1].toFloat();
4896 vtkFloatingPointType anAngle[2];
4897 anAngle[0] = vals[2].toFloat();
4898 anAngle[1] = vals[3].toFloat();
4900 QList<SUIT_ViewManager*> lst;
4901 getApp()->viewManagers(viewerTypStr, lst);
4902 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4903 if (viewIndex >= 0 && viewIndex < lst.count()) {
4904 SUIT_ViewManager* vman = lst.at(viewIndex);
4905 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4906 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4907 anOrientation, aDistance, anAngle);
4912 } // if (aSmeshActor)
4913 } // other parameters than Visibility
4915 } // for names/parameters iterator
4916 } // for entries iterator
4918 // update all VTK views
4919 QList<SUIT_ViewManager*> lst;
4920 getApp()->viewManagers(lst);
4921 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4922 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4923 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4924 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4925 vtkView->getRenderer()->ResetCameraClippingRange();
4932 \brief Adds preferences for dfont of VTK viewer
4934 \param pIf group identifier
4935 \param param parameter
4936 \return identifier of preferences
4938 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4940 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4942 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4945 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4946 fam.append( tr( "SMESH_FONT_COURIER" ) );
4947 fam.append( tr( "SMESH_FONT_TIMES" ) );
4949 setPreferenceProperty( tfont, "fonts", fam );
4951 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4952 setPreferenceProperty( tfont, "features", f );
4958 \brief Actions after hypothesis edition
4959 Updates object browser after hypothesis edition
4961 void SMESHGUI::onHypothesisEdit( int result )
4964 SMESHGUI::Modified();
4965 updateObjBrowser( true );