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_EditMeshDlg.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->getViewsCount();
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")){
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 bool SMESHGUI::automaticUpdate()
1335 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1339 return resMgr->booleanValue( "SMESH", "auto_update", false );
1342 //=============================================================================
1346 //=============================================================================
1347 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1349 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1352 //=============================================================================
1356 //=============================================================================
1357 SMESHGUI* SMESHGUI::GetSMESHGUI()
1359 SMESHGUI* smeshMod = 0;
1360 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1363 CAM_Module* module = app->module( "Mesh" );
1364 smeshMod = dynamic_cast<SMESHGUI*>( module );
1367 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1369 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1372 _PTR(Study) aStudy = study->studyDS();
1374 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1383 Standard_EXPORT SMESHGUI* GetComponentGUI()
1385 return SMESHGUI::GetSMESHGUI();
1389 //=============================================================================
1393 //=============================================================================
1394 void SMESHGUI::SetState(int aState)
1399 //=============================================================================
1403 //=============================================================================
1404 void SMESHGUI::ResetState()
1409 //=============================================================================
1413 //=============================================================================
1414 void SMESHGUI::EmitSignalDeactivateDialog()
1416 emit SignalDeactivateActiveDialog();
1419 //=============================================================================
1423 //=============================================================================
1424 void SMESHGUI::EmitSignalStudyFrameChanged()
1426 emit SignalStudyFrameChanged();
1429 //=============================================================================
1433 //=============================================================================
1434 void SMESHGUI::EmitSignalCloseAllDialogs()
1436 emit SignalCloseAllDialogs();
1439 //=============================================================================
1443 //=============================================================================
1444 void SMESHGUI::EmitSignalVisibilityChanged()
1446 emit SignalVisibilityChanged();
1449 //=============================================================================
1453 //=============================================================================
1454 QDialog *SMESHGUI::GetActiveDialogBox()
1456 return myActiveDialogBox;
1459 //=============================================================================
1463 //=============================================================================
1464 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1466 myActiveDialogBox = (QDialog *) aDlg;
1470 //=============================================================================
1474 //=============================================================================
1475 SUIT_Desktop* SMESHGUI::desktop()
1477 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1479 return app->desktop();
1484 //=============================================================================
1488 //=============================================================================
1489 SalomeApp_Study* SMESHGUI::activeStudy()
1491 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1493 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1498 //=============================================================================
1502 //=============================================================================
1503 void SMESHGUI::Modified( bool theIsUpdateActions )
1505 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1506 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1507 appStudy->Modified();
1508 if( theIsUpdateActions )
1509 app->updateActions();
1514 //=============================================================================
1518 //=============================================================================
1519 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1521 /* Here the position is on the bottom right corner - 10 */
1522 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1524 SUIT_Desktop *PP = desktop();
1525 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1526 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1530 //=============================================================================
1534 //=============================================================================
1535 static int isStudyLocked(_PTR(Study) theStudy){
1536 return theStudy->GetProperties()->IsLocked();
1539 static bool checkLock(_PTR(Study) theStudy) {
1540 if (isStudyLocked(theStudy)) {
1541 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1542 QObject::tr("WRN_WARNING"),
1543 QObject::tr("WRN_STUDY_LOCKED") );
1549 //=======================================================================
1550 //function : CheckActiveStudyLocked
1552 //=======================================================================
1554 bool SMESHGUI::isActiveStudyLocked()
1556 _PTR(Study) aStudy = activeStudy()->studyDS();
1557 return checkLock( aStudy );
1560 //=============================================================================
1564 //=============================================================================
1565 bool SMESHGUI::OnGUIEvent( int theCommandID )
1567 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1571 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1572 SUIT_ResourceMgr* mgr = resourceMgr();
1576 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1577 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1580 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1581 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1583 //QAction* act = action( theCommandID );
1585 switch (theCommandID) {
1587 if(checkLock(aStudy)) break;
1595 if(checkLock(aStudy)) break;
1596 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1600 case 150: //MED FILE INFORMATION
1602 SALOME_ListIO selected;
1603 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1605 aSel->selectedObjects( selected );
1606 if( selected.Extent() )
1608 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1609 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1610 if ( !aMesh->_is_nil() )
1612 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1619 case 122: // EXPORT MED
1628 ::ExportMeshToFile(theCommandID);
1632 case 200: // SCALAR BAR
1634 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1635 SALOME_ListIO selected;
1637 aSel->selectedObjects( selected );
1639 if( selected.Extent() ) {
1640 Handle(SALOME_InteractiveObject) anIO = selected.First();
1641 if( anIO->hasEntry() ) {
1642 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1643 anActor->SetControlMode( SMESH_Actor::eNone );
1651 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1661 ::DisableAutoColor();
1664 case 1134: // Clipping
1665 case 1133: // Tranparency
1666 case 1132: // Colors / Size
1673 ::SetDisplayMode(theCommandID, myMarkerMap);
1676 //2D quadratic representation
1679 ::SetDisplayMode(theCommandID, myMarkerMap);
1683 case 216: // 0D elements
1686 case 219: // Volumes
1687 case 220: // All Entity
1688 ::SetDisplayEntity(theCommandID);
1691 case 221: // Orientation of faces
1693 LightApp_SelectionMgr* mgr = selectionMgr();
1694 SALOME_ListIO selected; mgr->selectedObjects( selected );
1696 SALOME_ListIteratorOfListIO it(selected);
1697 for( ; it.More(); it.Next()) {
1698 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1699 if(anIObject->hasEntry()) {
1700 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1701 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1710 if(checkLock(aStudy)) break;
1712 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1715 SMESH::UpdateView();
1717 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1718 SMESH::OnVisuException();
1720 catch (...) { // PAL16774 (Crash after display of many groups)
1721 SMESH::OnVisuException();
1725 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1726 aSel->selectedObjects( l );
1727 aSel->setSelectedObjects( l );
1732 case 301: // DISPLAY
1733 case 302: // DISPLAY ONLY
1735 SMESH::EDisplaing anAction;
1736 switch (theCommandID) {
1737 case 300: anAction = SMESH::eErase; break;
1738 case 301: anAction = SMESH::eDisplay; break;
1739 case 302: anAction = SMESH::eDisplayOnly; break;
1742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1743 SALOME_ListIO sel_objects, to_process;
1745 aSel->selectedObjects( sel_objects );
1747 if( theCommandID==302 )
1748 startOperation( myEraseAll );
1750 extractContainers( sel_objects, to_process );
1753 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1757 SALOME_ListIteratorOfListIO It( to_process );
1758 for ( ; It.More(); It.Next()) {
1759 Handle(SALOME_InteractiveObject) IOS = It.Value();
1760 if (IOS->hasEntry()) {
1761 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1762 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1763 break; // PAL16774 (Crash after display of many groups)
1765 if (anAction == SMESH::eDisplayOnly)
1766 anAction = SMESH::eDisplay;
1771 // PAL13338 + PAL15161 -->
1772 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1773 SMESH::UpdateView();
1774 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1776 // PAL13338 + PAL15161 <--
1778 catch (...) { // PAL16774 (Crash after display of many groups)
1779 SMESH::OnVisuException();
1782 if (anAction == SMESH::eErase) {
1784 aSel->setSelectedObjects( l1 );
1787 aSel->setSelectedObjects( to_process );
1794 if(checkLock(aStudy)) break;
1797 EmitSignalDeactivateDialog();
1799 ( new SMESHGUI_NodesDlg( this ) )->show();
1802 SUIT_MessageBox::warning(desktop(),
1803 tr("SMESH_WRN_WARNING"),
1804 tr("SMESH_WRN_VIEWER_VTK"));
1809 case 2151: // FILTER
1813 EmitSignalDeactivateDialog();
1814 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1819 case 701: // COMPUTE MESH
1820 case 711: // PRECOMPUTE MESH
1821 case 712: // EVALUATE MESH
1822 case 713: // MESH ORDER
1824 if (checkLock(aStudy)) break;
1825 startOperation( theCommandID );
1829 case 702: // Create mesh
1830 case 703: // Create sub-mesh
1831 case 704: // Edit mesh/sub-mesh
1832 startOperation( theCommandID );
1834 case 710: // Build compound mesh
1836 if (checkLock(aStudy)) break;
1837 EmitSignalDeactivateDialog();
1838 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1842 case 407: // DIAGONAL INVERSION
1843 case 408: // Delete diagonal
1847 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1848 tr( "NOT_A_VTK_VIEWER" ) );
1852 if ( checkLock( aStudy ) )
1855 /*Standard_Boolean aRes;
1856 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1857 if ( aMesh->_is_nil() )
1859 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1860 tr( "SMESH_BAD_SELECTION" ) );
1864 EmitSignalDeactivateDialog();
1865 if ( theCommandID == 407 )
1866 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1868 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1871 case 409: // Change orientation
1872 case 410: // Union of triangles
1873 case 411: // Cutting of quadrangles
1874 case 419: // Splitting volumes into tetrahedra
1878 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1879 tr( "NOT_A_VTK_VIEWER" ) );
1883 if ( checkLock( aStudy ) )
1886 EmitSignalDeactivateDialog();
1887 SMESHGUI_MultiEditDlg* aDlg = NULL;
1888 if ( theCommandID == 409 )
1889 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1890 else if ( theCommandID == 410 )
1891 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1892 else if ( theCommandID == 419 )
1893 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
1895 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1900 case 412: // Smoothing
1902 if(checkLock(aStudy)) break;
1904 EmitSignalDeactivateDialog();
1905 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1908 SUIT_MessageBox::warning(desktop(),
1909 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1913 case 413: // Extrusion
1915 if (checkLock(aStudy)) break;
1917 EmitSignalDeactivateDialog();
1918 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1920 SUIT_MessageBox::warning(desktop(),
1921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1925 case 414: // Revolution
1927 if(checkLock(aStudy)) break;
1929 EmitSignalDeactivateDialog();
1930 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1933 SUIT_MessageBox::warning(desktop(),
1934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1938 case 415: // Pattern mapping
1940 if ( checkLock( aStudy ) )
1944 EmitSignalDeactivateDialog();
1945 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1948 SUIT_MessageBox::warning(desktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1953 case 416: // Extrusion along a path
1955 if (checkLock(aStudy)) break;
1957 EmitSignalDeactivateDialog();
1958 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1960 SUIT_MessageBox::warning(desktop(),
1961 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1965 case 417: // Convert mesh to quadratic
1967 startOperation( 417 );
1968 /* if (checkLock(aStudy)) break;
1970 EmitSignalDeactivateDialog();
1971 new SMESHGUI_ConvToQuadDlg();
1973 SUIT_MessageBox::warning(desktop(),
1974 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1978 case 418: // create 2D mesh from 3D
1980 startOperation( 418 );
1983 case 806: // CREATE GEO GROUP
1985 startOperation( 806 );
1988 case 801: // CREATE GROUP
1992 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1993 tr( "NOT_A_VTK_VIEWER" ) );
1997 if(checkLock(aStudy)) break;
1998 EmitSignalDeactivateDialog();
1999 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2001 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2002 SALOME_ListIO selected;
2004 aSel->selectedObjects( selected );
2006 int nbSel = selected.Extent();
2008 // check if mesh is selected
2009 aMesh = SMESH::GetMeshByIO( selected.First() );
2011 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2016 case 802: // CONSTRUCT GROUP
2020 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2021 tr( "NOT_A_VTK_VIEWER" ) );
2025 if(checkLock(aStudy)) break;
2026 EmitSignalDeactivateDialog();
2028 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2029 SALOME_ListIO selected;
2031 aSel->selectedObjects( selected );
2033 int nbSel = selected.Extent();
2035 // check if submesh is selected
2036 Handle(SALOME_InteractiveObject) IObject = selected.First();
2037 if (IObject->hasEntry()) {
2038 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2040 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2041 if (!aSubMesh->_is_nil()) {
2043 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2044 // get submesh elements list by types
2045 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2046 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2047 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2048 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2049 // create group for each type o elements
2050 QString aName = IObject->getName();
2051 if (aNodes->length() > 0) {
2052 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2053 aGroup->Add(aNodes.inout());
2055 if (aEdges->length() > 0) {
2056 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2057 aGroup->Add(aEdges.inout());
2059 if (aFaces->length() > 0) {
2060 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2061 aGroup->Add(aFaces.inout());
2063 if (aVolumes->length() > 0) {
2064 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2065 aGroup->Add(aVolumes.inout());
2070 catch(const SALOME::SALOME_Exception & S_ex){
2071 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2078 SUIT_MessageBox::warning(desktop(),
2079 tr("SMESH_WRN_WARNING"),
2080 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2085 case 803: // EDIT GROUP
2089 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2090 tr( "NOT_A_VTK_VIEWER" ) );
2094 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2097 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2098 SALOME_ListIO selected;
2100 aSel->selectedObjects( selected );
2102 SALOME_ListIteratorOfListIO It (selected);
2103 int nbSelectedGroups = 0;
2104 for ( ; It.More(); It.Next() )
2106 SMESH::SMESH_GroupBase_var aGroup =
2107 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2108 if (!aGroup->_is_nil()) {
2110 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2114 if (nbSelectedGroups == 0)
2116 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2122 case 804: // Add elements to group
2124 if(checkLock(aStudy)) break;
2125 if (myState == 800) {
2126 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2127 if (aDlg) aDlg->onAdd();
2132 case 805: // Remove elements from group
2134 if(checkLock(aStudy)) break;
2135 if (myState == 800) {
2136 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2137 if (aDlg) aDlg->onRemove();
2142 case 815: // Edit GEOM GROUP as standalone
2146 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2147 tr( "NOT_A_VTK_VIEWER" ) );
2151 if(checkLock(aStudy)) break;
2152 EmitSignalDeactivateDialog();
2154 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2155 SALOME_ListIO selected;
2157 aSel->selectedObjects( selected );
2159 SALOME_ListIteratorOfListIO It (selected);
2160 for ( ; It.More(); It.Next() )
2162 SMESH::SMESH_GroupOnGeom_var aGroup =
2163 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2164 if (!aGroup->_is_nil()) {
2165 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2172 case 810: // Union Groups
2173 case 811: // Intersect groups
2174 case 812: // Cut groups
2178 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2179 tr( "NOT_A_VTK_VIEWER" ) );
2183 if ( checkLock( aStudy ) )
2186 EmitSignalDeactivateDialog();
2188 SMESHGUI_GroupOpDlg* aDlg = 0;
2189 if ( theCommandID == 810 )
2190 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2191 else if ( theCommandID == 811 )
2192 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2194 aDlg = new SMESHGUI_CutGroupsDlg( this );
2201 case 814: // Create groups of entities from existing groups of superior dimensions
2203 if ( checkLock( aStudy ) )
2206 EmitSignalDeactivateDialog();
2207 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2213 case 813: // Delete groups with their contents
2217 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2218 tr( "NOT_A_VTK_VIEWER" ) );
2222 if ( checkLock( aStudy ) )
2225 EmitSignalDeactivateDialog();
2227 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2231 case 900: // MESH INFOS
2233 EmitSignalDeactivateDialog();
2234 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2235 SALOME_ListIO selected;
2237 aSel->selectedObjects( selected );
2239 if ( selected.Extent() > 1 ) { // a dlg for each IO
2241 SALOME_ListIteratorOfListIO It (selected);
2242 for ( ; It.More(); It.Next() ) {
2243 IOs.Clear(); IOs.Append( It.Value() );
2244 aSel->setSelectedObjects( IOs );
2245 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2247 // restore selection
2248 aSel->setSelectedObjects( selected );
2251 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2255 case 902: // STANDARD MESH INFOS
2257 EmitSignalDeactivateDialog();
2258 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2259 SALOME_ListIO selected;
2261 aSel->selectedObjects( selected );
2263 if ( selected.Extent() > 1 ) { // a dlg for each IO
2265 SALOME_ListIteratorOfListIO It (selected);
2266 for ( ; It.More(); It.Next() ) {
2268 IOs.Append( It.Value() );
2269 aSel->setSelectedObjects( IOs );
2270 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2272 // restore selection
2273 aSel->setSelectedObjects( selected );
2276 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2280 case 903: // WHAT IS
2282 EmitSignalDeactivateDialog();
2283 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2287 case 904: // FIND ELEM
2289 startOperation( theCommandID );
2293 case 1100: // EDIT HYPOTHESIS
2295 if(checkLock(aStudy)) break;
2297 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2298 SALOME_ListIO selected;
2300 aSel->selectedObjects( selected );
2302 int nbSel = selected.Extent();
2305 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2306 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2308 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2309 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2310 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2311 if ( !aHypothesis->_is_nil() )
2314 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2315 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2317 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2328 case 1101: // RENAME
2330 if ( checkLock( aStudy ) )
2333 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2334 SALOME_ListIO selected;
2336 aSel->selectedObjects( selected );
2338 bool isAny = false; // is there any appropriate object selected
2340 SALOME_ListIteratorOfListIO It( selected );
2341 for ( ; It.More(); It.Next() )
2343 Handle(SALOME_InteractiveObject) IObject = It.Value();
2344 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2345 _PTR(GenericAttribute) anAttr;
2346 _PTR(AttributeName) aName;
2349 if ( obj->FindAttribute(anAttr, "AttributeName") )
2352 QString newName = QString(aName->Value().c_str());
2354 // check type to prevent renaming of inappropriate objects
2355 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2356 if (aType == MESH || aType == GROUP ||
2357 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2358 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2359 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2360 aType == HYPOTHESIS || aType == ALGORITHM)
2363 newName = LightApp_NameDlg::getName(desktop(), newName);
2364 if ( !newName.isEmpty() )
2366 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2368 // update name of group object and its actor
2369 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2370 if( !aGroupObject->_is_nil() )
2372 aGroupObject->SetName( newName.toLatin1().data() );
2373 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2374 anActor->setName( newName.toLatin1().data() );
2385 SUIT_MessageBox::warning(desktop(),
2386 QObject::tr("SMESH_WRN_WARNING"),
2387 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2392 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2394 if(checkLock(aStudy)) break;
2395 SUIT_OverrideCursor wc;
2397 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2398 SALOME_ListIO selected;
2400 aSel->selectedObjects( selected, QString::null, false );
2402 SALOME_ListIteratorOfListIO It(selected);
2403 for (int i = 0; It.More(); It.Next(), i++) {
2404 Handle(SALOME_InteractiveObject) IObject = It.Value();
2405 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2408 aSel->setSelectedObjects( l1 );
2413 case 4009: // ELEM0D
2414 case 4010: // GEOM::EDGE
2415 case 4021: // TRIANGLE
2417 case 4023: // POLYGON
2421 if(checkLock(aStudy)) break;
2423 EmitSignalDeactivateDialog();
2424 SMDSAbs_ElementType type = SMDSAbs_Edge;
2426 switch (theCommandID) {
2427 case 4009: // ELEM0D
2428 type = SMDSAbs_0DElement; nbNodes = 1; break;
2429 case 4021: // TRIANGLE
2430 type = SMDSAbs_Face; nbNodes = 3; break;
2432 type = SMDSAbs_Face; nbNodes = 4; break;
2434 type = SMDSAbs_Volume; nbNodes = 4; break;
2435 case 4023: // POLYGON
2436 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2438 type = SMDSAbs_Volume; nbNodes = 8; break;
2439 case 4033: // POLYHEDRE
2440 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2443 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2446 SUIT_MessageBox::warning(desktop(),
2447 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2451 case 4033: // POLYHEDRON
2453 if(checkLock(aStudy)) break;
2455 EmitSignalDeactivateDialog();
2456 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2459 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2460 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2464 case 4034: // QUADRATIC EDGE
2465 case 4035: // QUADRATIC TRIANGLE
2466 case 4036: // QUADRATIC QUADRANGLE
2467 case 4037: // QUADRATIC TETRAHEDRON
2468 case 4038: // QUADRATIC PYRAMID
2469 case 4039: // QUADRATIC PENTAHEDRON
2470 case 4040: // QUADRATIC HEXAHEDRON
2472 if(checkLock(aStudy)) break;
2474 EmitSignalDeactivateDialog();
2477 switch (theCommandID) {
2479 type = QUAD_EDGE; break;
2481 type = QUAD_TRIANGLE; break;
2483 type = QUAD_QUADRANGLE; break;
2485 type = QUAD_TETRAHEDRON; break;
2487 type = QUAD_PYRAMID; break;
2489 type = QUAD_PENTAHEDRON; break;
2491 type = QUAD_HEXAHEDRON;
2495 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2498 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2499 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2503 case 4041: // REMOVES NODES
2505 if(checkLock(aStudy)) break;
2507 EmitSignalDeactivateDialog();
2508 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2511 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2512 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2516 case 4042: // REMOVES ELEMENTS
2518 if(checkLock(aStudy)) break;
2520 EmitSignalDeactivateDialog();
2521 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2525 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2526 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2530 case 4043: { // CLEAR_MESH
2532 if(checkLock(aStudy)) break;
2534 SALOME_ListIO selected;
2535 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2536 aSel->selectedObjects( selected );
2538 SUIT_OverrideCursor wc;
2539 SALOME_ListIteratorOfListIO It (selected);
2540 for ( ; It.More(); It.Next() )
2542 Handle(SALOME_InteractiveObject) IOS = It.Value();
2543 SMESH::SMESH_Mesh_var aMesh =
2544 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2545 if ( aMesh->_is_nil()) continue;
2547 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2549 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2550 SMESH::ModifiedMesh( aMeshSObj, false, true);
2551 // hide groups and submeshes
2552 _PTR(ChildIterator) anIter =
2553 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2554 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2556 _PTR(SObject) so = anIter->Value();
2557 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2560 catch (const SALOME::SALOME_Exception& S_ex){
2562 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2566 SMESH::UpdateView();
2570 case 4044: // REMOVE ORPHAN NODES
2572 if(checkLock(aStudy)) break;
2573 SALOME_ListIO selected;
2574 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2575 aSel->selectedObjects( selected );
2576 if ( selected.Extent() == 1 ) {
2577 Handle(SALOME_InteractiveObject) anIO = selected.First();
2578 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2579 if ( !aMesh->_is_nil() ) {
2580 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2581 tr( "SMESH_WARNING" ),
2582 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2583 SUIT_MessageBox::Yes |
2584 SUIT_MessageBox::No,
2585 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2588 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2589 int removed = aMeshEditor->RemoveOrphanNodes();
2590 SUIT_MessageBox::information(SMESHGUI::desktop(),
2591 tr("SMESH_INFORMATION"),
2592 tr("NB_NODES_REMOVED").arg(removed));
2593 if ( removed > 0 ) {
2594 SMESH::UpdateView();
2595 SMESHGUI::Modified();
2598 catch (const SALOME::SALOME_Exception& S_ex) {
2599 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2608 case 4051: // RENUMBERING NODES
2610 if(checkLock(aStudy)) break;
2612 EmitSignalDeactivateDialog();
2613 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2617 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2618 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2622 case 4052: // RENUMBERING ELEMENTS
2624 if(checkLock(aStudy)) break;
2626 EmitSignalDeactivateDialog();
2627 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2631 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2632 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2636 case 4061: // TRANSLATION
2638 if(checkLock(aStudy)) break;
2640 EmitSignalDeactivateDialog();
2641 ( new SMESHGUI_TranslationDlg( this ) )->show();
2644 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2649 case 4062: // ROTATION
2651 if(checkLock(aStudy)) break;
2653 EmitSignalDeactivateDialog();
2654 ( new SMESHGUI_RotationDlg( this ) )->show();
2657 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2658 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2662 case 4063: // SYMMETRY
2664 if(checkLock(aStudy)) break;
2666 EmitSignalDeactivateDialog();
2667 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2670 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2671 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2675 case 4064: // SEWING
2677 if(checkLock(aStudy)) break;
2679 EmitSignalDeactivateDialog();
2680 ( new SMESHGUI_SewingDlg( this ) )->show();
2683 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2684 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2688 case 4065: // MERGE NODES
2690 if(checkLock(aStudy)) break;
2692 EmitSignalDeactivateDialog();
2693 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2696 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2697 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2701 case 4066: // MERGE EQUAL ELEMENTS
2703 if (checkLock(aStudy)) break;
2705 EmitSignalDeactivateDialog();
2706 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2708 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2709 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2714 case 4067: // MAKE MESH PASS THROUGH POINT
2715 startOperation( 4067 );
2720 if(checkLock(aStudy)) break;
2722 EmitSignalDeactivateDialog();
2723 ( new SMESHGUI_ScaleDlg( this ) )->show();
2726 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2727 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2732 case 4069: // DUPLICATE NODES
2734 if(checkLock(aStudy)) break;
2736 EmitSignalDeactivateDialog();
2737 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2740 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2741 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2746 case 5105: // Library of selection filters
2748 static QList<int> aTypes;
2749 if ( aTypes.isEmpty() )
2751 aTypes.append( SMESH::NODE );
2752 aTypes.append( SMESH::EDGE );
2753 aTypes.append( SMESH::FACE );
2754 aTypes.append( SMESH::VOLUME );
2756 if (!myFilterLibraryDlg)
2757 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2758 else if (myFilterLibraryDlg->isHidden())
2759 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2760 myFilterLibraryDlg->raise();
2764 case 6017: // CONTROLS
2782 LightApp_SelectionMgr* mgr = selectionMgr();
2783 SALOME_ListIO selected; mgr->selectedObjects( selected );
2785 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2786 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2788 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2789 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2790 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2791 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2792 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2793 ::Control( theCommandID );
2798 SUIT_MessageBox::warning(desktop(),
2799 tr( "SMESH_WRN_WARNING" ),
2800 tr( "SMESH_BAD_SELECTION" ) );
2804 SUIT_MessageBox::warning(desktop(),
2805 tr( "SMESH_WRN_WARNING" ),
2806 tr( "NOT_A_VTK_VIEWER" ) );
2811 LightApp_SelectionMgr* mgr = selectionMgr();
2812 SALOME_ListIO selected; mgr->selectedObjects( selected );
2814 SALOME_ListIteratorOfListIO it(selected);
2815 for( ; it.More(); it.Next()) {
2816 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2817 if(anIObject->hasEntry()) {
2818 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2819 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2827 LightApp_SelectionMgr* mgr = selectionMgr();
2828 SALOME_ListIO selected; mgr->selectedObjects( selected );
2830 if (selected.Extent() == 1) {
2831 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2832 if(anIObject->hasEntry())
2833 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2834 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2841 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2842 //updateObjBrowser();
2846 //=============================================================================
2850 //=============================================================================
2851 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2856 //=============================================================================
2860 //=============================================================================
2861 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2866 //=============================================================================
2870 //=============================================================================
2871 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2876 //=============================================================================
2877 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2878 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2880 //=============================================================================
2881 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2882 SUIT_ViewWindow* wnd )
2884 if(theIO->hasEntry()){
2885 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2886 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2890 //=======================================================================
2891 // function : createSMESHAction
2893 //=======================================================================
2894 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
2895 const int key, const bool toggle, const QString& shortcutAction )
2898 QWidget* parent = application()->desktop();
2899 SUIT_ResourceMgr* resMgr = resourceMgr();
2901 if ( !icon_id.isEmpty() )
2902 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2904 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2905 if ( !pix.isNull() )
2906 icon = QIcon( pix );
2908 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2909 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2910 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2912 createAction( id, tooltip, icon, menu, status_bar, key, parent,
2913 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
2916 //=======================================================================
2917 // function : createPopupItem
2919 //=======================================================================
2920 void SMESHGUI::createPopupItem( const int id,
2921 const QString& clients,
2922 const QString& types,
2923 const QString& theRule,
2928 parentId = popupMgr()->actionId( action( pId ) );
2930 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2931 popupMgr()->insert( action( id ), parentId, 0 );
2933 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2934 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2935 QString rule = "(%1) and (%2) and (%3)";
2936 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2937 if( clients.isEmpty() )
2938 rule = rule.arg( QString( "true" ) );
2940 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2941 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2944 bool cont = myRules.contains( id );
2946 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2948 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2949 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2952 //=======================================================================
2953 // function : initialize
2955 //=======================================================================
2956 void SMESHGUI::initialize( CAM_Application* app )
2958 SalomeApp_Module::initialize( app );
2960 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2962 /* Automatic Update flag */
2963 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2965 // ----- create actions --------------
2967 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2968 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2969 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2970 createSMESHAction( 114, "NUM" );
2971 createSMESHAction( 121, "DAT" );
2972 createSMESHAction( 122, "MED" );
2973 createSMESHAction( 123, "UNV" );
2974 createSMESHAction( 140, "STL" );
2975 createSMESHAction( 124, "EXPORT_DAT" );
2976 createSMESHAction( 125, "EXPORT_MED" );
2977 createSMESHAction( 126, "EXPORT_UNV" );
2978 createSMESHAction( 141, "EXPORT_STL" );
2979 createSMESHAction( 150, "FILE_INFO" );
2980 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2981 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2982 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2983 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2984 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2985 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2986 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2987 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2988 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2989 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2990 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2991 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2992 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2993 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2994 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2995 createSMESHAction( 804, "ADD" );
2996 createSMESHAction( 805, "REMOVE" );
2997 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2998 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2999 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3000 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3001 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3002 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3003 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3004 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3005 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3006 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3007 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3008 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3009 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3010 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3011 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3012 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3013 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3014 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3015 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3016 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3017 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3018 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3019 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3020 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3021 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3022 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3023 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3024 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3025 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3026 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3027 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3028 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3029 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3030 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3031 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3032 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3033 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3034 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3035 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3036 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3037 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3038 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3039 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3040 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3041 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3042 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3043 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3044 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3045 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3046 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3047 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3048 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3049 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3050 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3051 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3052 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3053 createSMESHAction( 415, "MAP", "ICON_MAP" );
3054 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3055 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3056 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3057 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3058 createSMESHAction( 200, "RESET" );
3059 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3060 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3061 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3062 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3063 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3064 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3065 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3066 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3067 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3068 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3069 createSMESHAction( 220, "ALL" );
3070 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3072 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3073 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3075 createSMESHAction( 1100, "EDIT_HYPO" );
3076 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3077 createSMESHAction( 1102, "UNASSIGN" );
3078 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3079 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3080 createSMESHAction( 1131, "DISPMODE" );
3081 createSMESHAction( 1132, "COLORS" );
3082 createSMESHAction( 1133, "TRANSP" );
3083 createSMESHAction( 1134, "CLIP" );
3084 createSMESHAction( 1135, "DISP_ENT" );
3085 createSMESHAction( 1136, "AUTO_COLOR" );
3086 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3087 createSMESHAction( 2000, "CTRL" );
3089 createSMESHAction( 300, "ERASE" );
3090 createSMESHAction( 301, "DISPLAY" );
3091 createSMESHAction( 302, "DISPLAY_ONLY" );
3092 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3093 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3094 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3095 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3096 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3097 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3098 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3099 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3101 // ----- create menu --------------
3102 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3103 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3104 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3105 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3106 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3107 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3108 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3110 createMenu( separator(), fileId );
3112 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3113 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3114 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3115 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3116 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3117 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3119 createMenu( 111, importId, -1 );
3120 createMenu( 112, importId, -1 );
3121 createMenu( 113, importId, -1 );
3123 createMenu( 121, exportId, -1 );
3124 createMenu( 122, exportId, -1 );
3125 createMenu( 123, exportId, -1 );
3126 createMenu( 140, exportId, -1 ); // export to stl STL
3128 createMenu( separator(), fileId, 10 );
3130 createMenu( 33, editId, -1 );
3132 createMenu( 5105, toolsId, -1 );
3134 createMenu( 702, meshId, -1 ); // "Mesh" menu
3135 createMenu( 703, meshId, -1 );
3136 createMenu( 704, meshId, -1 );
3137 createMenu( 710, meshId, -1 );
3138 createMenu( separator(), meshId, -1 );
3139 createMenu( 701, meshId, -1 );
3140 createMenu( 711, meshId, -1 );
3141 createMenu( 712, meshId, -1 );
3142 createMenu( 713, meshId, -1 );
3143 createMenu( separator(), meshId, -1 );
3144 createMenu( 801, meshId, -1 );
3145 createMenu( 806, meshId, -1 );
3146 createMenu( 802, meshId, -1 );
3147 createMenu( 803, meshId, -1 );
3148 createMenu( 815, meshId, -1 );
3149 createMenu( separator(), meshId, -1 );
3150 createMenu( 810, meshId, -1 );
3151 createMenu( 811, meshId, -1 );
3152 createMenu( 812, meshId, -1 );
3153 createMenu( separator(), meshId, -1 );
3154 createMenu( 814, meshId, -1 );
3155 createMenu( separator(), meshId, -1 );
3156 createMenu( 813, meshId, -1 );
3157 createMenu( separator(), meshId, -1 );
3158 createMenu( 900, meshId, -1 );
3159 createMenu( 902, meshId, -1 );
3160 createMenu( 903, meshId, -1 );
3161 createMenu( 904, meshId, -1 );
3162 createMenu( separator(), meshId, -1 );
3164 createMenu( 6003, ctrlId, -1 );
3165 createMenu( 6001, ctrlId, -1 );
3166 createMenu( 6004, ctrlId, -1 );
3167 createMenu( separator(), ctrlId, -1 );
3168 createMenu( 6005, ctrlId, -1 );
3169 createMenu( 6002, ctrlId, -1 );
3170 createMenu( 6018, ctrlId, -1 );
3171 createMenu( 6019, ctrlId, -1 );
3172 createMenu( 6011, ctrlId, -1 );
3173 createMenu( 6012, ctrlId, -1 );
3174 createMenu( 6013, ctrlId, -1 );
3175 createMenu( 6014, ctrlId, -1 );
3176 createMenu( 6015, ctrlId, -1 );
3177 createMenu( 6016, ctrlId, -1 );
3178 createMenu( separator(), ctrlId, -1 );
3179 createMenu( 6017, ctrlId, -1 );
3180 createMenu( 6009, ctrlId, -1 );
3181 createMenu( 6021, ctrlId, -1 );
3182 createMenu( separator(), ctrlId, -1 );
3184 createMenu( 4000, addId, -1 );
3185 createMenu( 4009, addId, -1 );
3186 createMenu( 4010, addId, -1 );
3187 createMenu( 4021, addId, -1 );
3188 createMenu( 4022, addId, -1 );
3189 createMenu( 4023, addId, -1 );
3190 createMenu( 4031, addId, -1 );
3191 createMenu( 4032, addId, -1 );
3192 createMenu( 4033, addId, -1 );
3193 createMenu( separator(), addId, -1 );
3194 createMenu( 4034, addId, -1 );
3195 createMenu( 4035, addId, -1 );
3196 createMenu( 4036, addId, -1 );
3197 createMenu( 4037, addId, -1 );
3198 createMenu( 4038, addId, -1 );
3199 createMenu( 4039, addId, -1 );
3200 createMenu( 4040, addId, -1 );
3202 createMenu( 4041, removeId, -1 );
3203 createMenu( 4042, removeId, -1 );
3204 createMenu( 4044, removeId, -1 );
3205 createMenu( separator(), removeId, -1 );
3206 createMenu( 4043, removeId, -1 );
3208 createMenu( 4051, renumId, -1 );
3209 createMenu( 4052, renumId, -1 );
3211 createMenu( 4061, transfId, -1 );
3212 createMenu( 4062, transfId, -1 );
3213 createMenu( 4063, transfId, -1 );
3214 createMenu( 4064, transfId, -1 );
3215 createMenu( 4065, transfId, -1 );
3216 createMenu( 4066, transfId, -1 );
3217 createMenu( 4068, transfId, -1 );
3218 createMenu( 4069, transfId, -1 );
3220 createMenu( 4067,modifyId, -1 );
3221 createMenu( 407, modifyId, -1 );
3222 createMenu( 408, modifyId, -1 );
3223 createMenu( 409, modifyId, -1 );
3224 createMenu( 410, modifyId, -1 );
3225 createMenu( 411, modifyId, -1 );
3226 createMenu( 419, modifyId, -1 );
3227 createMenu( 412, modifyId, -1 );
3228 createMenu( 413, modifyId, -1 );
3229 createMenu( 416, modifyId, -1 );
3230 createMenu( 414, modifyId, -1 );
3231 createMenu( 415, modifyId, -1 );
3232 createMenu( 417, modifyId, -1 );
3233 createMenu( 418, modifyId, -1 );
3235 createMenu( 214, viewId, -1 );
3237 // ----- create toolbars --------------
3238 int meshTb = createTool( tr( "TB_MESH" ) ),
3239 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3240 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3241 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3242 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3244 createTool( 702, meshTb );
3245 createTool( 703, meshTb );
3246 createTool( 704, meshTb );
3247 createTool( 710, meshTb );
3248 createTool( separator(), meshTb );
3249 createTool( 701, meshTb );
3250 createTool( 711, meshTb );
3251 createTool( 712, meshTb );
3252 createTool( 713, meshTb );
3253 createTool( separator(), meshTb );
3254 createTool( 801, meshTb );
3255 createTool( 806, meshTb );
3256 createTool( 802, meshTb );
3257 createTool( 803, meshTb );
3258 //createTool( 815, meshTb );
3259 createTool( separator(), meshTb );
3260 createTool( 900, meshTb );
3261 createTool( 902, meshTb );
3262 createTool( 903, meshTb );
3263 createTool( 904, meshTb );
3264 createTool( separator(), meshTb );
3266 createTool( 6001, ctrlTb );
3267 createTool( 6003, ctrlTb );
3268 createTool( 6004, ctrlTb );
3269 createTool( separator(), ctrlTb );
3270 createTool( 6005, ctrlTb );
3271 createTool( 6002, ctrlTb );
3272 createTool( 6018, ctrlTb );
3273 createTool( 6019, ctrlTb );
3274 createTool( 6011, ctrlTb );
3275 createTool( 6012, ctrlTb );
3276 createTool( 6013, ctrlTb );
3277 createTool( 6014, ctrlTb );
3278 createTool( 6015, ctrlTb );
3279 createTool( 6016, ctrlTb );
3280 createTool( separator(), ctrlTb );
3281 createTool( 6017, ctrlTb );
3282 createTool( 6009, ctrlTb );
3283 createTool( 6021, ctrlTb );
3284 createTool( separator(), ctrlTb );
3286 createTool( 4000, addRemTb );
3287 createTool( 4009, addRemTb );
3288 createTool( 4010, addRemTb );
3289 createTool( 4021, addRemTb );
3290 createTool( 4022, addRemTb );
3291 createTool( 4023, addRemTb );
3292 createTool( 4031, addRemTb );
3293 createTool( 4032, addRemTb );
3294 createTool( 4033, addRemTb );
3295 createTool( separator(), addRemTb );
3296 createTool( 4034, addRemTb );
3297 createTool( 4035, addRemTb );
3298 createTool( 4036, addRemTb );
3299 createTool( 4037, addRemTb );
3300 createTool( 4038, addRemTb );
3301 createTool( 4039, addRemTb );
3302 createTool( 4040, addRemTb );
3303 createTool( separator(), addRemTb );
3304 createTool( 4041, addRemTb );
3305 createTool( 4042, addRemTb );
3306 createTool( 4044, addRemTb );
3307 createTool( 4043, addRemTb );
3308 createTool( separator(), addRemTb );
3309 createTool( 4051, addRemTb );
3310 createTool( 4052, addRemTb );
3311 createTool( separator(), addRemTb );
3312 createTool( 4061, addRemTb );
3313 createTool( 4062, addRemTb );
3314 createTool( 4063, addRemTb );
3315 createTool( 4064, addRemTb );
3316 createTool( 4065, addRemTb );
3317 createTool( 4066, addRemTb );
3318 createTool( 4068, addRemTb );
3319 createTool( 4069, addRemTb );
3320 createTool( separator(), addRemTb );
3322 createTool( 4067,modifyTb );
3323 createTool( 407, modifyTb );
3324 createTool( 408, modifyTb );
3325 createTool( 409, modifyTb );
3326 createTool( 410, modifyTb );
3327 createTool( 411, modifyTb );
3328 createTool( 419, modifyTb );
3329 createTool( 412, modifyTb );
3330 createTool( 413, modifyTb );
3331 createTool( 416, modifyTb );
3332 createTool( 414, modifyTb );
3333 createTool( 415, modifyTb );
3334 createTool( 417, modifyTb );
3335 createTool( 418, modifyTb );
3337 createTool( 214, dispModeTb );
3339 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3340 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3343 QString OB = "'ObjectBrowser'",
3344 View = "'" + SVTK_Viewer::Type() + "'",
3346 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3347 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3348 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3349 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3350 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3351 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3352 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3353 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3354 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3355 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3356 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3358 mesh_group = mesh + " " + subMesh + " " + group,
3359 hyp_alg = hypo + " " + algo;
3361 // popup for object browser
3363 isInvisible("not( isVisible )"),
3364 isEmpty("numberOfNodes = 0"),
3365 isNotEmpty("numberOfNodes <> 0"),
3367 // has nodes, edges, etc in VISIBLE! actor
3368 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3369 hasElems("(count( elemTypes ) > 0)"),
3370 hasDifferentElems("(count( elemTypes ) > 1)"),
3371 hasElems0d("({'Elem0d'} in elemTypes)"),
3372 hasEdges("({'Edge'} in elemTypes)"),
3373 hasFaces("({'Face'} in elemTypes)"),
3374 hasVolumes("({'Volume'} in elemTypes)");
3376 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3377 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3378 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3379 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3380 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3381 createPopupItem( 803, OB, group ); // EDIT_GROUP
3382 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3384 popupMgr()->insert( separator(), -1, 0 );
3385 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3386 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3387 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3388 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3389 createPopupItem( 214, OB, mesh_group ); // UPDATE
3390 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3391 createPopupItem( 902, OB, mesh ); // STD_INFO
3392 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3393 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3394 popupMgr()->insert( separator(), -1, 0 );
3395 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3396 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3397 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3398 popupMgr()->insert( separator(), -1, 0 );
3399 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3400 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3401 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3402 popupMgr()->insert( separator(), -1, 0 );
3403 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3404 popupMgr()->insert( separator(), -1, 0 );
3405 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3406 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3407 popupMgr()->insert( separator(), -1, 0 );
3409 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3410 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3412 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3413 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3414 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3415 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3416 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3417 popupMgr()->insert( separator(), -1, 0 );
3420 createPopupItem( 803, View, group ); // EDIT_GROUP
3421 createPopupItem( 804, View, elems ); // ADD
3422 createPopupItem( 805, View, elems ); // REMOVE
3424 popupMgr()->insert( separator(), -1, 0 );
3425 createPopupItem( 214, View, mesh_group ); // UPDATE
3426 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3427 createPopupItem( 902, View, mesh ); // STD_INFO
3428 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3429 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3430 popupMgr()->insert( separator(), -1, 0 );
3432 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3433 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3434 popupMgr()->insert( separator(), -1, 0 );
3437 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3438 QString aType = QString( "%1type in {%2}" ).arg( lc );
3439 aType = aType.arg( mesh_group );
3440 QString aMeshInVTK = aClient + "&&" + aType;
3442 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3443 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3444 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3446 //-------------------------------------------------
3448 //-------------------------------------------------
3449 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3451 popupMgr()->insert( action( 9010 ), anId, -1 );
3452 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3453 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3455 popupMgr()->insert( action( 9011 ), anId, -1 );
3456 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3457 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3459 popupMgr()->insert( separator(), -1, -1 );
3461 //-------------------------------------------------
3463 //-------------------------------------------------
3464 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3466 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3467 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3468 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3470 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3471 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3472 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3474 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3475 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3476 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3478 popupMgr()->insert( separator(), anId, -1 );
3480 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3481 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3482 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3484 //-------------------------------------------------
3486 //-------------------------------------------------
3487 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3489 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3491 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3492 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3493 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3495 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3496 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3497 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3499 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3500 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3501 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3503 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3504 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3505 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3507 popupMgr()->insert( separator(), anId, -1 );
3509 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3510 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3513 //-------------------------------------------------
3514 // Representation of the 2D Quadratic elements
3515 //-------------------------------------------------
3516 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3517 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3518 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3519 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3521 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3522 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3523 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3525 //-------------------------------------------------
3526 // Orientation of faces
3527 //-------------------------------------------------
3528 popupMgr()->insert( action( 221 ), -1, -1 );
3529 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3530 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3532 //-------------------------------------------------
3534 //-------------------------------------------------
3535 popupMgr()->insert( action( 1132 ), -1, -1 );
3536 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3538 //-------------------------------------------------
3540 //-------------------------------------------------
3541 popupMgr()->insert( action( 1133 ), -1, -1 );
3542 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3544 //-------------------------------------------------
3546 //-------------------------------------------------
3547 popupMgr()->insert( action( 1134 ), -1, -1 );
3548 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3550 popupMgr()->insert( separator(), -1, -1 );
3552 //-------------------------------------------------
3554 //-------------------------------------------------
3556 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3557 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3558 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3559 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3561 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3563 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3564 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3566 popupMgr()->insert( separator(), anId, -1 );
3568 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3569 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3570 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3572 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3573 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3574 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3576 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3577 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3578 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3580 popupMgr()->insert( separator(), anId, -1 );
3582 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3583 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3584 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3586 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3587 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3588 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3590 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3591 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3592 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3594 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3595 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3596 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3598 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3599 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3600 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3602 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3603 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3604 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3606 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3607 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3608 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3610 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3611 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3612 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3614 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3615 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3616 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3618 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3619 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3620 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3622 popupMgr()->insert( separator(), anId, -1 );
3624 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3625 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3626 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3628 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3629 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3630 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3632 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3633 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3634 QtxPopupMgr::VisibleRule );
3635 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3637 popupMgr()->insert( separator(), anId, -1 );
3639 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3640 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3642 popupMgr()->insert( separator(), -1, -1 );
3644 //-------------------------------------------------
3646 //-------------------------------------------------
3647 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3648 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3649 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3650 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3652 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3653 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3655 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3656 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3658 popupMgr()->insert( separator(), -1, -1 );
3660 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3661 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3664 //================================================================================
3666 * \brief Return true if SMESH or GEOM objects are selected.
3667 * Is called form LightApp_Module::activateModule() which clear selection if
3668 * not isSelectionCompatible()
3670 //================================================================================
3672 bool SMESHGUI::isSelectionCompatible()
3674 bool isCompatible = true;
3675 SALOME_ListIO selected;
3676 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3677 Sel->selectedObjects( selected );
3679 SALOME_ListIteratorOfListIO It( selected );
3680 for ( ; isCompatible && It.More(); It.Next())
3682 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3683 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3685 return isCompatible;
3689 bool SMESHGUI::reusableOperation( const int id )
3691 // compute, evaluate and precompute are not reusable operations
3692 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3695 bool SMESHGUI::activateModule( SUIT_Study* study )
3697 bool res = SalomeApp_Module::activateModule( study );
3699 setMenuShown( true );
3700 setToolShown( true );
3702 // Reset actions accelerator keys
3703 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3704 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3705 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3707 action( 33)->setEnabled(true); // Delete: Key_Delete
3708 action(1101)->setEnabled(true); // Rename: Key_F2
3710 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3711 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3712 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3713 if ( _PTR(Study) aStudy = s->studyDS()) {
3714 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3715 updateObjBrowser(); // objects can be removed
3721 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3723 setMenuShown( false );
3724 setToolShown( false );
3726 EmitSignalCloseAllDialogs();
3728 // Unset actions accelerator keys
3729 action(111)->setShortcut(QKeySequence()); // Import DAT
3730 action(112)->setShortcut(QKeySequence()); // Import UNV
3731 action(113)->setShortcut(QKeySequence()); // Import MED
3733 action( 33)->setEnabled(false); // Delete: Key_Delete
3734 action(1101)->setEnabled(false); // Rename: Key_F2
3736 return SalomeApp_Module::deactivateModule( study );
3739 void SMESHGUI::studyClosed( SUIT_Study* s )
3741 SMESH::RemoveVisuData( s->id() );
3742 SalomeApp_Module::studyClosed( s );
3745 void SMESHGUI::OnGUIEvent()
3747 const QObject* obj = sender();
3748 if ( !obj || !obj->inherits( "QAction" ) )
3750 int id = actionId((QAction*)obj);
3755 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3757 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3758 if ( CORBA::is_nil( myComponentSMESH ) )
3760 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3762 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3763 return aGUI.myComponentSMESH;
3766 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3767 return myComponentSMESH;
3770 QString SMESHGUI::engineIOR() const
3772 CORBA::ORB_var anORB = getApp()->orb();
3773 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3774 return QString( anIOR.in() );
3777 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3779 SalomeApp_Module::contextMenuPopup( client, menu, title );
3781 selectionMgr()->selectedObjects( lst );
3782 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3783 Handle(SALOME_InteractiveObject) io = lst.First();
3784 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3785 _PTR(Study) study = appStudy->studyDS();
3786 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3788 QString aName = QString( obj->GetName().c_str() );
3789 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3790 aName.remove( (aName.length() - 1), 1 );
3796 LightApp_Selection* SMESHGUI::createSelection() const
3798 return new SMESHGUI_Selection();
3801 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3803 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3804 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3807 void SMESHGUI::viewManagers( QStringList& list ) const
3809 list.append( SVTK_Viewer::Type() );
3812 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3814 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3815 SMESH::UpdateSelectionProp( this );
3818 void SMESHGUI::createPreferences()
3820 // General tab ------------------------------------------------------------------------
3821 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3823 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3824 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3826 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3827 setPreferenceProperty( qaGroup, "columns", 2 );
3828 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3829 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3830 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3831 setPreferenceProperty( prec, "min", 0 );
3832 setPreferenceProperty( prec, "max", 16 );
3834 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3835 setPreferenceProperty( dispgroup, "columns", 2 );
3836 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3838 modes.append( "Wireframe" );
3839 modes.append( "Shading" );
3840 modes.append( "Nodes" );
3841 modes.append( "Shrink" );
3842 QList<QVariant> indices;
3843 indices.append( 0 );
3844 indices.append( 1 );
3845 indices.append( 2 );
3846 indices.append( 3 );
3847 setPreferenceProperty( dispmode, "strings", modes );
3848 setPreferenceProperty( dispmode, "indexes", indices );
3850 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3851 setPreferenceProperty( arcgroup, "columns", 2 );
3852 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3853 QStringList quadraticModes;
3854 quadraticModes.append("Lines");
3855 quadraticModes.append("Arcs");
3857 indices.append( 0 );
3858 indices.append( 1 );
3859 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3860 setPreferenceProperty( quadraticmode, "indexes", indices );
3862 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3863 "SMESH", "max_angle" );
3864 setPreferenceProperty( maxAngle, "min", 1 );
3865 setPreferenceProperty( maxAngle, "max", 90 );
3869 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3870 setPreferenceProperty( exportgroup, "columns", 2 );
3871 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3872 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3874 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3875 setPreferenceProperty( computeGroup, "columns", 2 );
3876 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3878 modes.append( "Never" );
3879 modes.append( "Errors only" );
3880 modes.append( "Always" );
3882 indices.append( 0 );
3883 indices.append( 1 );
3884 indices.append( 2 );
3885 setPreferenceProperty( notifyMode, "strings", modes );
3886 setPreferenceProperty( notifyMode, "indexes", indices );
3888 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3889 setPreferenceProperty( segGroup, "columns", 2 );
3890 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3891 "SMESH", "segmentation" );
3892 setPreferenceProperty( segLen, "min", 1 );
3893 setPreferenceProperty( segLen, "max", 10000000 );
3894 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3895 "SMESH", "nb_segments_per_edge" );
3896 setPreferenceProperty( nbSeg, "min", 1 );
3897 setPreferenceProperty( nbSeg, "max", 10000000 );
3899 // Quantities with individual precision settings
3900 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
3901 setPreferenceProperty( precGroup, "columns", 2 );
3903 const int nbQuantities = 6;
3904 int precs[nbQuantities], ii = 0;
3905 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
3906 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
3907 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
3908 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
3909 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
3910 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
3911 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
3912 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
3913 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
3914 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
3915 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
3916 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
3918 // Set property for precision value for spinboxes
3919 for ( ii = 0; ii < nbQuantities; ii++ ){
3920 setPreferenceProperty( precs[ii], "min", -14 );
3921 setPreferenceProperty( precs[ii], "max", 14 );
3922 setPreferenceProperty( precs[ii], "precision", 2 );
3925 // Mesh tab ------------------------------------------------------------------------
3926 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3927 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3928 setPreferenceProperty( nodeGroup, "columns", 3 );
3930 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3932 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
3934 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3935 QList<QVariant> aMarkerTypeIndicesList;
3936 QList<QVariant> aMarkerTypeIconsList;
3937 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
3938 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
3939 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
3940 aMarkerTypeIndicesList << i;
3941 aMarkerTypeIconsList << pixmap;
3943 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
3944 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
3946 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
3948 QList<QVariant> aMarkerScaleIndicesList;
3949 QStringList aMarkerScaleValuesList;
3950 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
3951 aMarkerScaleIndicesList << i;
3952 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
3954 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
3955 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
3957 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3958 setPreferenceProperty( elemGroup, "columns", 2 );
3960 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3961 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3962 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3963 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3965 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
3966 setPreferenceProperty( grpGroup, "columns", 2 );
3968 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
3970 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3971 //setPreferenceProperty( sp, "hstretch", 0 );
3972 //setPreferenceProperty( sp, "vstretch", 0 );
3974 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3975 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3976 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3977 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3978 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3979 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3980 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3982 setPreferenceProperty( size0d, "min", 1 );
3983 setPreferenceProperty( size0d, "max", 10 );
3985 setPreferenceProperty( sp, "hstretch", 0 );
3986 setPreferenceProperty( sp, "vstretch", 0 );
3988 setPreferenceProperty( elemW, "min", 1 );
3989 setPreferenceProperty( elemW, "max", 5 );
3991 setPreferenceProperty( shrink, "min", 0 );
3992 setPreferenceProperty( shrink, "max", 100 );
3994 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3995 setPreferenceProperty( orientGroup, "columns", 1 );
3997 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3998 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4000 setPreferenceProperty( orientScale, "min", 0.05 );
4001 setPreferenceProperty( orientScale, "max", 0.5 );
4002 setPreferenceProperty( orientScale, "step", 0.05 );
4004 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4006 // Selection tab ------------------------------------------------------------------------
4007 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4009 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4010 setPreferenceProperty( selGroup, "columns", 2 );
4012 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4013 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4014 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4016 setPreferenceProperty( selW, "min", 1 );
4017 setPreferenceProperty( selW, "max", 5 );
4019 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4020 setPreferenceProperty( preGroup, "columns", 2 );
4022 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4023 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4025 setPreferenceProperty( preW, "min", 1 );
4026 setPreferenceProperty( preW, "max", 5 );
4028 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4029 setPreferenceProperty( precSelGroup, "columns", 2 );
4031 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4032 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4033 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4035 // Scalar Bar tab ------------------------------------------------------------------------
4036 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4037 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4038 setPreferenceProperty( fontGr, "columns", 2 );
4040 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4041 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4043 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4044 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4046 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4047 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4049 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4050 setPreferenceProperty( numcol, "min", 2 );
4051 setPreferenceProperty( numcol, "max", 256 );
4053 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4054 setPreferenceProperty( numlab, "min", 2 );
4055 setPreferenceProperty( numlab, "max", 65 );
4057 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4058 setPreferenceProperty( orientGr, "columns", 2 );
4059 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4060 QStringList orients;
4061 orients.append( tr( "SMESH_VERTICAL" ) );
4062 orients.append( tr( "SMESH_HORIZONTAL" ) );
4063 indices.clear(); indices.append( 0 ); indices.append( 1 );
4064 setPreferenceProperty( orient, "strings", orients );
4065 setPreferenceProperty( orient, "indexes", indices );
4067 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4068 setPreferenceProperty( posVSizeGr, "columns", 2 );
4069 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4070 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4071 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4072 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4073 setPreferenceProperty( xv, "step", 0.1 );
4074 setPreferenceProperty( xv, "min", 0.0 );
4075 setPreferenceProperty( xv, "max", 1.0 );
4076 setPreferenceProperty( yv, "step", 0.1 );
4077 setPreferenceProperty( yv, "min", 0.0 );
4078 setPreferenceProperty( yv, "max", 1.0 );
4079 setPreferenceProperty( wv, "step", 0.1 );
4080 setPreferenceProperty( wv, "min", 0.0 );
4081 setPreferenceProperty( wv, "max", 1.0 );
4082 setPreferenceProperty( hv, "min", 0.0 );
4083 setPreferenceProperty( hv, "max", 1.0 );
4084 setPreferenceProperty( hv, "step", 0.1 );
4086 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4087 setPreferenceProperty( posHSizeGr, "columns", 2 );
4088 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4089 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4090 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4091 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4092 setPreferenceProperty( xv, "min", 0.0 );
4093 setPreferenceProperty( xv, "max", 1.0 );
4094 setPreferenceProperty( xv, "step", 0.1 );
4095 setPreferenceProperty( xh, "min", 0.0 );
4096 setPreferenceProperty( xh, "max", 1.0 );
4097 setPreferenceProperty( xh, "step", 0.1 );
4098 setPreferenceProperty( yh, "min", 0.0 );
4099 setPreferenceProperty( yh, "max", 1.0 );
4100 setPreferenceProperty( yh, "step", 0.1 );
4101 setPreferenceProperty( wh, "min", 0.0 );
4102 setPreferenceProperty( wh, "max", 1.0 );
4103 setPreferenceProperty( wh, "step", 0.1 );
4104 setPreferenceProperty( hh, "min", 0.0 );
4105 setPreferenceProperty( hh, "max", 1.0 );
4106 setPreferenceProperty( hh, "step", 0.1 );
4109 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4111 if( sect=="SMESH" ) {
4112 float sbX1,sbY1,sbW,sbH;
4113 float aTol = 1.00000009999999;
4114 std::string aWarning;
4115 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4116 if( name=="selection_object_color" || name=="selection_element_color" ||
4117 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4118 name=="selection_precision_node" || name=="selection_precision_element" ||
4119 name=="selection_precision_object")
4120 SMESH::UpdateSelectionProp( this );
4121 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4122 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4123 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4124 if(sbX1+sbW > aTol){
4125 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4128 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4129 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4132 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4133 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4134 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4135 if(sbY1+sbH > aTol){
4136 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4137 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4138 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4141 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4142 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4143 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4144 if(sbX1+sbW > aTol){
4145 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4148 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4149 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4152 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4153 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4154 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4155 if(sbY1+sbH > aTol){
4156 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4159 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4160 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4163 else if ( name == "segmentation" ) {
4164 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4165 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4167 else if ( name == "nb_segments_per_edge" ) {
4168 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4169 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4172 if(aWarning.size() != 0){
4173 aWarning += "The default values are applied instead.";
4174 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4175 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4176 QObject::tr(aWarning.c_str()));
4181 //================================================================================
4183 * \brief Update something in accordance with update flags
4184 * \param theFlags - update flags
4186 * Update viewer or/and object browser etc. in accordance with update flags ( see
4187 * LightApp_UpdateFlags enumeration ).
4189 //================================================================================
4190 void SMESHGUI::update( const int flags )
4192 if ( flags & UF_Viewer | flags & UF_Forced )
4193 SMESH::UpdateView();
4195 SalomeApp_Module::update( flags );
4198 //================================================================================
4200 * \brief Set default selection mode
4202 * SLOT called when operation commited. Sets default selection mode
4204 //================================================================================
4205 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4207 SVTK_ViewWindow* vtkWnd =
4208 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4210 vtkWnd->SetSelectionMode( ActorSelection );
4213 //================================================================================
4215 * \brief Set default selection mode
4217 * SLOT called when operation aborted. Sets default selection mode
4219 //================================================================================
4220 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4222 SVTK_ViewWindow* vtkWnd =
4223 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4225 vtkWnd->SetSelectionMode( ActorSelection );
4228 //================================================================================
4230 * \brief Creates operation with given identifier
4231 * \param id - identifier of operation to be started
4232 * \return Pointer on created operation or NULL if operation is not created
4234 * Virtual method redefined from the base class creates operation with given id.
4235 * It is called called automatically from startOperation method of base class.
4237 //================================================================================
4238 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4240 LightApp_Operation* op = 0;
4241 // to do : create operation here
4244 case 417: //convert to quadratic
4245 op = new SMESHGUI_ConvToQuadOp();
4247 case 418: // create 2D mesh as boundary on 3D
4248 op = new SMESHGUI_Make2DFrom3DOp();
4250 case 701: // Compute mesh
4251 op = new SMESHGUI_ComputeOp();
4253 case 702: // Create mesh
4254 op = new SMESHGUI_MeshOp( true, true );
4256 case 703: // Create sub-mesh
4257 op = new SMESHGUI_MeshOp( true, false );
4259 case 704: // Edit mesh/sub-mesh
4260 op = new SMESHGUI_MeshOp( false );
4262 case 711: // Precompute mesh
4263 op = new SMESHGUI_PrecomputeOp();
4265 case 712: // Evaluate mesh
4266 op = new SMESHGUI_EvaluateOp();
4268 case 713: // Evaluate mesh
4269 op = new SMESHGUI_MeshOrderOp();
4271 case 806: // Create group on geom
4272 op = new SMESHGUI_GroupOnShapeOp();
4274 case 904: // Find element
4275 op = new SMESHGUI_FindElemByPointOp();
4277 case 4067: // make mesh pass through point
4278 op = new SMESHGUI_MakeNodeAtPointOp();
4285 op = SalomeApp_Module::createOperation( id );
4289 //================================================================================
4291 * \brief Stops current operations and starts a given one
4292 * \param id - The id of the operation to start
4294 //================================================================================
4296 void SMESHGUI::switchToOperation(int id)
4298 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4299 activeStudy()->abortAllOperations();
4300 startOperation( id );
4303 LightApp_Displayer* SMESHGUI::displayer()
4306 myDisplayer = new SMESHGUI_Displayer( getApp() );
4310 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4313 int aTolerance = 64;
4314 int anIterations = 0;
4320 if( anIterations % aPeriod == 0 )
4323 if( aTolerance < 1 )
4326 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4328 aHue = (int)( 360.0 * rand() / RAND_MAX );
4329 //cout << "Hue = " << aHue << endl;
4331 //cout << "Auto colors : ";
4333 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4334 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4335 for( ; it != itEnd; ++it )
4337 SALOMEDS::Color anAutoColor = *it;
4338 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4341 aQColor.getHsv( &h, &s, &v );
4343 if( abs( h - aHue ) < aTolerance )
4346 //cout << "break (diff = " << abs( h - aHue ) << ")";
4356 //cout << "Hue of the returned color = " << aHue << endl;
4358 aColor.setHsv( aHue, 255, 255 );
4360 SALOMEDS::Color aSColor;
4361 aSColor.R = (double)aColor.red() / 255.0;
4362 aSColor.G = (double)aColor.green() / 255.0;
4363 aSColor.B = (double)aColor.blue() / 255.0;
4368 const char gSeparator = '_'; // character used to separate parameter names
4369 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4370 const char gPathSep = '|'; // character used to separate paths
4373 * \brief Store visual parameters
4375 * This method is called just before the study document is saved.
4376 * Store visual parameters in AttributeParameter attribue(s)
4378 void SMESHGUI::storeVisualParameters (int savePoint)
4380 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4381 if (!appStudy || !appStudy->studyDS())
4383 _PTR(Study) studyDS = appStudy->studyDS();
4385 // componentName is used for encoding of entries when storing them in IParameters
4386 std::string componentName = myComponentSMESH->ComponentDataType();
4387 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4388 //if (!aSComponent) return;
4391 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4392 componentName.c_str(),
4394 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4396 // store map of custom markers
4397 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4398 if( !aMarkerMap.empty() )
4400 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4401 for( ; anIter != aMarkerMap.end(); anIter++ )
4403 int anId = anIter->first;
4404 VTK::MarkerData aMarkerData = anIter->second;
4405 std::string aMarkerFileName = aMarkerData.first;
4406 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4407 if( aMarkerTexture.size() < 3 )
4408 continue; // should contain at least width, height and the first value
4410 QString aPropertyName( "texture" );
4411 aPropertyName += gSeparator;
4412 aPropertyName += QString::number( anId );
4414 QString aPropertyValue = aMarkerFileName.c_str();
4415 aPropertyValue += gPathSep;
4417 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4418 ushort aWidth = *aTextureIter++;
4419 ushort aHeight = *aTextureIter++;
4420 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4421 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4422 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4423 aPropertyValue += QString::number( *aTextureIter );
4425 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4429 // viewers counters are used for storing view_numbers in IParameters
4432 // main cycle to store parameters of displayed objects
4433 QList<SUIT_ViewManager*> lst;
4434 QList<SUIT_ViewManager*>::Iterator it;
4435 getApp()->viewManagers(lst);
4436 for (it = lst.begin(); it != lst.end(); it++)
4438 SUIT_ViewManager* vman = *it;
4439 QString vType = vman->getType();
4441 // saving VTK actors properties
4442 if (vType == SVTK_Viewer::Type())
4444 QVector<SUIT_ViewWindow*> views = vman->getViews();
4445 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4447 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4449 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4450 vtkActorCollection* allActors = aCopy.GetActors();
4451 allActors->InitTraversal();
4452 while (vtkActor* actor = allActors->GetNextActor())
4454 if (actor->GetVisibility()) // store only visible actors
4456 SMESH_Actor* aSmeshActor = 0;
4457 if (actor->IsA("SMESH_Actor"))
4458 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4459 if (aSmeshActor && aSmeshActor->hasIO())
4461 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4464 // entry is "encoded" = it does NOT contain component adress,
4465 // since it is a subject to change on next component loading
4466 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4468 std::string param, vtkParam = vType.toLatin1().data();
4469 vtkParam += gSeparator;
4470 vtkParam += QString::number(vtkViewers).toLatin1().data();
4471 vtkParam += gSeparator;
4474 param = vtkParam + "Visibility";
4475 ip->setParameter(entry, param, "On");
4478 param = vtkParam + "Representation";
4479 ip->setParameter(entry, param, QString::number
4480 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4483 param = vtkParam + "IsShrunk";
4484 ip->setParameter(entry, param, QString::number
4485 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4487 // Displayed entities
4488 unsigned int aMode = aSmeshActor->GetEntityMode();
4489 bool isE = aMode & SMESH_Actor::eEdges;
4490 bool isF = aMode & SMESH_Actor::eFaces;
4491 bool isV = aMode & SMESH_Actor::eVolumes;
4493 QString modeStr ("e");
4494 modeStr += gDigitsSep; modeStr += QString::number(isE);
4495 modeStr += gDigitsSep; modeStr += "f";
4496 modeStr += gDigitsSep; modeStr += QString::number(isF);
4497 modeStr += gDigitsSep; modeStr += "v";
4498 modeStr += gDigitsSep; modeStr += QString::number(isV);
4500 param = vtkParam + "Entities";
4501 ip->setParameter(entry, param, modeStr.toLatin1().data());
4503 // Colors (surface:edge:)
4504 vtkFloatingPointType r, g, b;
4506 aSmeshActor->GetSufaceColor(r, g, b);
4507 QString colorStr ("surface");
4508 colorStr += gDigitsSep; colorStr += QString::number(r);
4509 colorStr += gDigitsSep; colorStr += QString::number(g);
4510 colorStr += gDigitsSep; colorStr += QString::number(b);
4512 aSmeshActor->GetBackSufaceColor(r, g, b);
4513 colorStr += gDigitsSep; colorStr += "backsurface";
4514 colorStr += gDigitsSep; colorStr += QString::number(r);
4515 colorStr += gDigitsSep; colorStr += QString::number(g);
4516 colorStr += gDigitsSep; colorStr += QString::number(b);
4518 aSmeshActor->GetEdgeColor(r, g, b);
4519 colorStr += gDigitsSep; colorStr += "edge";
4520 colorStr += gDigitsSep; colorStr += QString::number(r);
4521 colorStr += gDigitsSep; colorStr += QString::number(g);
4522 colorStr += gDigitsSep; colorStr += QString::number(b);
4524 aSmeshActor->GetNodeColor(r, g, b);
4525 colorStr += gDigitsSep; colorStr += "node";
4526 colorStr += gDigitsSep; colorStr += QString::number(r);
4527 colorStr += gDigitsSep; colorStr += QString::number(g);
4528 colorStr += gDigitsSep; colorStr += QString::number(b);
4530 param = vtkParam + "Colors";
4531 ip->setParameter(entry, param, colorStr.toLatin1().data());
4533 // Sizes of lines and points
4534 QString sizeStr ("line");
4535 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4536 sizeStr += gDigitsSep; sizeStr += "shrink";
4537 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4539 param = vtkParam + "Sizes";
4540 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4545 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4546 if( aMarkerType == VTK::MT_USER ) {
4547 markerStr += "custom";
4548 markerStr += gDigitsSep;
4549 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4553 markerStr += gDigitsSep;
4554 markerStr += QString::number( (int)aMarkerType );
4555 markerStr += gDigitsSep;
4556 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4559 param = vtkParam + "PointMarker";
4560 ip->setParameter(entry, param, markerStr.toLatin1().data());
4563 param = vtkParam + "Opacity";
4564 ip->setParameter(entry, param,
4565 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4568 param = vtkParam + "ClippingPlane";
4569 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4571 ip->setParameter(entry, param, "Off");
4572 for (int ipl = 0; ipl < nPlanes; ipl++) {
4573 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4574 SMESH::Orientation anOrientation;
4576 vtkFloatingPointType anAngle[2];
4577 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4578 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4579 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4580 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4581 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4583 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4585 } // if (io->hasEntry())
4586 } // SMESH_Actor && hasIO
4588 } // while.. actors traversal
4592 } // if (SVTK view model)
4593 } // for (viewManagers)
4597 * \brief Restore visual parameters
4599 * This method is called after the study document is opened.
4600 * Restore visual parameters from AttributeParameter attribue(s)
4602 void SMESHGUI::restoreVisualParameters (int savePoint)
4604 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4605 if (!appStudy || !appStudy->studyDS())
4607 _PTR(Study) studyDS = appStudy->studyDS();
4609 // componentName is used for encoding of entries when storing them in IParameters
4610 std::string componentName = myComponentSMESH->ComponentDataType();
4611 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4612 //if (!aSComponent) return;
4615 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4616 componentName.c_str(),
4618 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4620 // restore map of custom markers
4621 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4623 std::vector<std::string> properties = ip->getProperties();
4624 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4626 std::string property = *propIt;
4627 QString aPropertyName( property.c_str() );
4628 QString aPropertyValue( ip->getProperty( property ).c_str() );
4630 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4631 if( aPropertyNameList.size() != 2 )
4636 if( aPropertyNameList[0] == "texture" )
4637 anId = aPropertyNameList[1].toInt( &ok );
4639 if( !ok || anId < 1 )
4642 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4643 if( aPropertyValueList.size() != 2 )
4646 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4647 QString aMarkerTextureString = aPropertyValueList[1];
4648 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4649 if( aMarkerTextureStringList.size() != 3 )
4653 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4658 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4662 VTK::MarkerTexture aMarkerTexture;
4663 aMarkerTexture.push_back( aWidth );
4664 aMarkerTexture.push_back( aHeight );
4666 QString aMarkerTextureData = aMarkerTextureStringList[2];
4667 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4669 QChar aChar = aMarkerTextureData.at( i );
4670 if( aChar.isDigit() )
4671 aMarkerTexture.push_back( aChar.digitValue() );
4674 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4677 std::vector<std::string> entries = ip->getEntries();
4679 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4681 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4682 QString entry (ip->decodeEntry(*entIt).c_str());
4684 // Check that the entry corresponds to a real object in the Study
4685 // as the object may be deleted or modified after the visual state is saved.
4686 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4687 if (!so) continue; //Skip the not existent entry
4689 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4690 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4692 std::vector<std::string>::iterator namesIt = paramNames.begin();
4693 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4695 // actors are stored in a map after displaying of them for
4696 // quicker access in the future: map < viewID to actor >
4697 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4699 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4701 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4702 // '_' is used as separator and should not be used in viewer type or parameter names.
4703 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4704 if (lst.size() != 3)
4707 QString viewerTypStr = lst[0];
4708 QString viewIndexStr = lst[1];
4709 QString paramNameStr = lst[2];
4712 int viewIndex = viewIndexStr.toUInt(&ok);
4713 if (!ok) // bad conversion of view index to integer
4717 if (viewerTypStr == SVTK_Viewer::Type())
4719 SMESH_Actor* aSmeshActor = 0;
4720 if (vtkActors.IsBound(viewIndex))
4721 aSmeshActor = vtkActors.Find(viewIndex);
4723 if (paramNameStr == "Visibility")
4725 if (!aSmeshActor && displayer())
4727 QList<SUIT_ViewManager*> lst;
4728 getApp()->viewManagers(viewerTypStr, lst);
4730 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4731 if (viewIndex >= 0 && viewIndex < lst.count()) {
4732 SUIT_ViewManager* vman = lst.at(viewIndex);
4733 SUIT_ViewModel* vmodel = vman->getViewModel();
4734 // SVTK view model can be casted to SALOME_View
4735 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4737 // store displayed actor in a temporary map for quicker
4738 // access later when restoring other parameters
4739 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4740 vtkRenderer* Renderer = vtkView->getRenderer();
4741 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4742 vtkActorCollection* theActors = aCopy.GetActors();
4743 theActors->InitTraversal();
4744 bool isFound = false;
4745 vtkActor *ac = theActors->GetNextActor();
4746 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4747 if (ac->IsA("SMESH_Actor")) {
4748 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4749 if (aGeomAc->hasIO()) {
4750 Handle(SALOME_InteractiveObject) io =
4751 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4752 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4754 vtkActors.Bind(viewIndex, aGeomAc);
4761 } // if (paramNameStr == "Visibility")
4764 // the rest properties "work" with SMESH_Actor
4767 QString val ((*valuesIt).c_str());
4770 if (paramNameStr == "Representation") {
4771 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4774 else if (paramNameStr == "IsShrunk") {
4776 if (!aSmeshActor->IsShrunk())
4777 aSmeshActor->SetShrink();
4780 if (aSmeshActor->IsShrunk())
4781 aSmeshActor->UnShrink();
4784 // Displayed entities
4785 else if (paramNameStr == "Entities") {
4786 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4787 if (mode.count() == 6) {
4788 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4789 MESSAGE("Invalid order of data in Entities, must be: "
4790 "e:0/1:f:0/1:v:0/1");
4793 unsigned int aMode = aSmeshActor->GetEntityMode();
4794 unsigned int aNewMode =
4795 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4796 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4797 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4798 if (aNewMode != aMode)
4799 aSmeshActor->SetEntityMode(aNewMode);
4804 else if (paramNameStr == "Colors") {
4805 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4806 if (colors.count() == 16) {
4807 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4808 colors[8] != "edge" || colors[12] != "node") {
4809 MESSAGE("Invalid order of data in Colors, must be: "
4810 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4813 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4814 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4815 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4816 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4820 // Sizes of lines and points
4821 else if (paramNameStr == "Sizes") {
4822 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4823 if (sizes.count() == 4) {
4824 if (sizes[0] != "line" || sizes[2] != "shrink") {
4825 MESSAGE("Invalid order of data in Sizes, must be: "
4826 "line:int:shrink:float");
4829 aSmeshActor->SetLineWidth(sizes[1].toInt());
4830 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4833 else if (sizes.count() == 6) { // just to support old format
4834 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4835 MESSAGE("Invalid order of data in Sizes, must be: "
4836 "line:int:node:int:shrink:float");
4839 aSmeshActor->SetLineWidth(sizes[1].toInt());
4840 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4841 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4846 else if (paramNameStr == "PointMarker") {
4847 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
4848 if( data.count() >= 2 ) {
4850 int aParam1 = data[1].toInt( &ok );
4852 if( data[0] == "std" && data.count() == 3 ) {
4853 int aParam2 = data[2].toInt( &ok );
4854 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
4856 else if( data[0] == "custom" ) {
4857 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
4858 if( markerIt != aMarkerMap.end() ) {
4859 VTK::MarkerData aMarkerData = markerIt->second;
4860 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
4867 else if (paramNameStr == "Opacity") {
4868 aSmeshActor->SetOpacity(val.toFloat());
4871 else if (paramNameStr.startsWith("ClippingPlane")) {
4872 cout << "$$$ ClippingPlane 1" << endl;
4873 if (paramNameStr == "ClippingPlane1" || val == "Off")
4874 aSmeshActor->RemoveAllClippingPlanes();
4876 cout << "$$$ ClippingPlane 2" << endl;
4877 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4878 if (vals.count() == 4) { // format check: 4 values
4879 cout << "$$$ ClippingPlane 3" << endl;
4880 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4881 double aDistance = vals[1].toFloat();
4882 vtkFloatingPointType anAngle[2];
4883 anAngle[0] = vals[2].toFloat();
4884 anAngle[1] = vals[3].toFloat();
4886 QList<SUIT_ViewManager*> lst;
4887 getApp()->viewManagers(viewerTypStr, lst);
4888 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4889 if (viewIndex >= 0 && viewIndex < lst.count()) {
4890 SUIT_ViewManager* vman = lst.at(viewIndex);
4891 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4892 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4893 anOrientation, aDistance, anAngle);
4898 } // if (aSmeshActor)
4899 } // other parameters than Visibility
4901 } // for names/parameters iterator
4902 } // for entries iterator
4904 // update all VTK views
4905 QList<SUIT_ViewManager*> lst;
4906 getApp()->viewManagers(lst);
4907 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4908 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4909 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4910 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4911 vtkView->getRenderer()->ResetCameraClippingRange();
4918 \brief Adds preferences for dfont of VTK viewer
4920 \param pIf group identifier
4921 \param param parameter
4922 \return identifier of preferences
4924 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4926 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4928 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4931 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4932 fam.append( tr( "SMESH_FONT_COURIER" ) );
4933 fam.append( tr( "SMESH_FONT_TIMES" ) );
4935 setPreferenceProperty( tfont, "fonts", fam );
4937 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4938 setPreferenceProperty( tfont, "features", f );
4944 \brief Actions after hypothesis edition
4945 Updates object browser after hypothesis edition
4947 void SMESHGUI::onHypothesisEdit( int result )
4950 SMESHGUI::Modified();
4951 updateObjBrowser( true );