1 // Copyright (C) 2007-2008 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_MoveNodesDlg.h"
56 #include "SMESHGUI_MultiEditDlg.h"
57 #include "SMESHGUI_NodesDlg.h"
58 #include "SMESHGUI_Preferences_ColorDlg.h"
59 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
60 #include "SMESHGUI_RemoveElementsDlg.h"
61 #include "SMESHGUI_RemoveNodesDlg.h"
62 #include "SMESHGUI_RenumberingDlg.h"
63 #include "SMESHGUI_RevolutionDlg.h"
64 #include "SMESHGUI_RotationDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_SewingDlg.h"
67 #include "SMESHGUI_SingleEditDlg.h"
68 #include "SMESHGUI_SmoothingDlg.h"
69 #include "SMESHGUI_StandardMeshInfosDlg.h"
70 #include "SMESHGUI_SymmetryDlg.h"
71 #include "SMESHGUI_TranslationDlg.h"
72 #include "SMESHGUI_ScaleDlg.h"
73 #include "SMESHGUI_TransparencyDlg.h"
74 #include "SMESHGUI_WhatIsDlg.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>
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
169 std::string myExtension;
171 if ( theCommandID == 113 ) {
172 filter.append( QObject::tr( "MED files (*.med)" ) );
173 filter.append( QObject::tr( "All files (*)" ) );
175 else if ( theCommandID == 112 ) {
176 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
178 else if ( theCommandID == 111 ) {
179 filter.append( QObject::tr( "DAT files (*.dat)" ) );
182 QString anInitialPath = "";
183 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
184 anInitialPath = QDir::currentPath();
186 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
189 QObject::tr( "SMESH_IMPORT_MESH" ) );
190 if ( filenames.count() > 0 ) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 bool isEmpty = false;
196 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
197 QString filename = *it;
198 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
200 switch ( theCommandID ) {
203 // DAT format (currently unsupported)
204 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
205 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
211 aMeshes->length( 1 );
212 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
213 if ( aMeshes[0]->_is_nil() )
214 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
215 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
221 SMESH::DriverMED_ReadStatus res;
222 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
223 if ( res != SMESH::DRS_OK ) {
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
231 catch ( const SALOME::SALOME_Exception& S_ex ) {
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
236 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
237 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
239 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
240 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
241 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
242 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
243 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
251 // update Object browser
252 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
254 // show Error message box if there were errors
255 if ( errors.count() > 0 ) {
256 SUIT_MessageBox::critical( SMESHGUI::desktop(),
257 QObject::tr( "SMESH_ERROR" ),
258 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
261 // show warning message box, if some imported mesh is empty
263 SUIT_MessageBox::warning( SMESHGUI::desktop(),
264 QObject::tr( "SMESH_WRN_WARNING" ),
265 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
270 void ExportMeshToFile( int theCommandID )
272 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
273 SALOME_ListIO selected;
275 aSel->selectedObjects( selected );
277 // actually, the following condition can't be met (added for insurance)
278 if( selected.Extent() == 0 ||
279 selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 )
282 bool hasDuplicatedMeshNames = false;
283 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
284 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
285 SALOME_ListIteratorOfListIO It( selected );
286 for( ; It.More(); It.Next() ) {
287 Handle(SALOME_InteractiveObject) anIObject = It.Value();
288 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
289 if ( aMeshItem->_is_nil() ) {
290 SUIT_MessageBox::warning( SMESHGUI::desktop(),
291 QObject::tr( "SMESH_WRN_WARNING" ),
292 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
296 QString aMeshName = anIObject->getName();
298 // check for duplications
299 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
300 if( aMeshName == (*aMeshIter).second ) {
301 hasDuplicatedMeshNames = true;
306 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
309 if( hasDuplicatedMeshNames ) {
310 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
311 QObject::tr("SMESH_WRN_WARNING"),
312 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
313 QObject::tr("SMESH_BUT_YES"),
314 QObject::tr("SMESH_BUT_NO"), 0, 1);
319 aMeshIter = aMeshList.begin();
320 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
321 QString aMeshName = (*aMeshIter).second;
323 QList<SALOMEDS::Color> aReservedColors;
325 QString aFilter, aTitle = QObject::tr("Export mesh");
326 QMap<QString, SMESH::MED_VERSION> aFilterMap;
327 QMap<QString, int> aFilterMapSTL;
328 switch ( theCommandID ) {
332 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
333 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
334 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
335 int aRet = SUIT_MessageBox::warning
336 (SMESHGUI::desktop(),
337 QObject::tr("SMESH_WRN_WARNING"),
338 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
339 QObject::tr("SMESH_BUT_YES"),
340 QObject::tr("SMESH_BUT_NO"), 0, 1);
346 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
347 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
348 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
349 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
354 aFilter = QObject::tr("DAT files (*.dat)");
359 if (aMesh->NbPyramids()) {
360 int aRet = SUIT_MessageBox::warning
361 (SMESHGUI::desktop(),
362 QObject::tr("SMESH_WRN_WARNING"),
363 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
364 QObject::tr("SMESH_BUT_YES"),
365 QObject::tr("SMESH_BUT_NO"), 0, 1);
369 aFilter = QObject::tr("IDEAS files (*.unv)");
377 there must be check on others mesh elements not equal triangles
379 if (aMesh->NbTriangles() < 1) {
380 SUIT_MessageBox::warning
381 (SMESHGUI::desktop(),
382 QObject::tr("SMESH_WRN_WARNING"),
383 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
386 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
387 int aRet = SUIT_MessageBox::warning
388 (SMESHGUI::desktop(),
389 QObject::tr("SMESH_WRN_WARNING"),
390 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
391 QObject::tr("SMESH_BUT_YES"),
392 QObject::tr("SMESH_BUT_NO"), 0, 1);
397 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
398 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
406 SMESH::MED_VERSION aFormat;
407 // Init the parameter with the default value
408 bool aIsASCII_STL = true;
409 bool toCreateGroups = false;
410 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
412 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
413 bool toOverwrite = true;
415 QString anInitialPath = "";
416 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
417 anInitialPath = QDir::currentPath();
419 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
420 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
421 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
422 aFilter, aTitle, false);
424 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
426 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
427 for ( ; it != aFilterMapSTL.end(); ++it )
428 filters.push_back( it.key() );
430 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
431 fd->setWindowTitle( aTitle );
432 fd->setNameFilters( filters );
433 fd->selectNameFilter( QObject::tr("STL ASCII (*.stl)") );
434 if ( !anInitialPath.isEmpty() )
435 fd->setDirectory( anInitialPath );
436 fd->selectFile(aMeshName);
440 aFilename = fd->selectedFile();
441 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
446 else { // Export to MED
448 QString aDefaultFilter;
449 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
450 for ( ; it != aFilterMap.end(); ++it ) {
451 filters.push_back( it.key() );
452 if (it.value() == SMESH::MED_V2_2)
453 aDefaultFilter = it.key();
456 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
457 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
458 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
459 fd->setWindowTitle( aTitle );
460 fd->setNameFilters( filters );
461 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
462 fd->selectNameFilter(aDefaultFilter);
463 fd->SetChecked(toCreateGroups);
464 if ( !anInitialPath.isEmpty() )
465 fd->setDirectory( anInitialPath );
466 fd->selectFile(aMeshName);
468 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
469 fd->setValidator( fv );
474 aFilename = fd->selectedFile();
476 aFilename = QString::null;
479 aFormat = aFilterMap[fd->selectedNameFilter()];
480 toOverwrite = fv->isOverwrite();
482 if ( !aFilename.isEmpty() ) {
483 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
484 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
485 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
486 && aFormat==SMESH::MED_V2_1) {
487 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
488 QObject::tr("SMESH_WRN_WARNING"),
489 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
490 QObject::tr("SMESH_BUT_YES"),
491 QObject::tr("SMESH_BUT_NO"), 0, 1);
499 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
500 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
501 if( !isVersionOk || aVersion != aFormat ) {
502 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
503 QObject::tr("SMESH_WRN_WARNING"),
504 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
505 QObject::tr("SMESH_BUT_YES"),
506 QObject::tr("SMESH_BUT_NO"), 0, 1);
513 QStringList aMeshNamesCollisionList;
514 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
515 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
516 QString anExistingMeshName( aMeshNames[ i ] );
517 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
518 QString anExportMeshName = (*aMeshIter).second;
519 if( anExportMeshName == anExistingMeshName ) {
520 aMeshNamesCollisionList.append( anExportMeshName );
526 if( !aMeshNamesCollisionList.isEmpty() ) {
527 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
528 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
529 QObject::tr("SMESH_WRN_WARNING"),
530 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
531 QObject::tr("SMESH_BUT_YES"),
532 QObject::tr("SMESH_BUT_NO"),
533 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
542 toCreateGroups = fd->IsChecked();
545 if ( !aFilename.isEmpty() ) {
546 // Check whether the file already exists and delete it if yes
547 QFile aFile( aFilename );
548 if ( aFile.exists() && toOverwrite )
550 SUIT_OverrideCursor wc;
553 bool Renumber = false;
554 // PAL 14172 : Check of we have to renumber or not from the preferences before export
556 Renumber= resMgr->booleanValue("SMESH","renumbering");
558 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
559 aMeshEditor->RenumberNodes();
560 aMeshEditor->RenumberElements();
561 if ( SMESHGUI::automaticUpdate() )
564 switch ( theCommandID ) {
568 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
569 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
570 if( !aMeshItem->_is_nil() )
571 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
577 aMesh->ExportDAT( aFilename.toLatin1().data() );
581 aMesh->ExportUNV( aFilename.toLatin1().data() );
585 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
591 catch (const SALOME::SALOME_Exception& S_ex){
593 SUIT_MessageBox::warning(SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("SMESH_EXPORT_FAILED"));
601 inline void InverseEntityMode(unsigned int& theOutputMode,
602 unsigned int theMode)
604 bool anIsNotPresent = ~theOutputMode & theMode;
606 theOutputMode |= theMode;
608 theOutputMode &= ~theMode;
611 void SetDisplayEntity(int theCommandID){
612 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
613 SALOME_ListIO selected;
615 aSel->selectedObjects( selected );
617 if(selected.Extent() >= 1){
618 SALOME_ListIteratorOfListIO It( selected );
619 for( ; It.More(); It.Next()){
620 Handle(SALOME_InteractiveObject) IObject = It.Value();
621 if(IObject->hasEntry()){
622 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
623 unsigned int aMode = anActor->GetEntityMode();
624 switch(theCommandID){
626 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
629 InverseEntityMode(aMode,SMESH_Actor::eEdges);
632 InverseEntityMode(aMode,SMESH_Actor::eFaces);
635 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
638 aMode = SMESH_Actor::eAllEntity;
642 anActor->SetEntityMode(aMode);
650 SALOME_ListIO selected;
651 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
655 LightApp_SelectionMgr* aSel = app->selectionMgr();
656 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
657 if( !aSel || !appStudy )
660 aSel->selectedObjects( selected );
661 if( selected.IsEmpty() )
664 Handle(SALOME_InteractiveObject) anIObject = selected.First();
666 _PTR(Study) aStudy = appStudy->studyDS();
667 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
668 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
669 if( aMainObject->_is_nil() )
672 aMainObject->SetAutoColor( true );
674 QList<SALOMEDS::Color> aReservedColors;
676 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
677 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
679 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
680 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
682 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
683 aGroupObject->SetColor( aColor );
684 aReservedColors.append( aColor );
686 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
688 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
689 if( aGroupObject->GetType() == SMESH::NODE )
690 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
691 else if( aGroupObject->GetType() == SMESH::EDGE )
692 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
693 else if( aGroupObject->GetType() == SMESH::ELEM0D )
694 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
696 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
701 SMESH::RepaintCurrentView();
704 void DisableAutoColor(){
705 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
706 SALOME_ListIO selected;
708 aSel->selectedObjects( selected );
710 if(selected.Extent()){
711 Handle(SALOME_InteractiveObject) anIObject = selected.First();
712 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
713 if ( !aMesh->_is_nil() ) {
714 aMesh->SetAutoColor( false );
719 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
720 SALOME_ListIO selected;
721 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
725 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
726 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
727 if( !aSel || !appStudy )
730 _PTR(Study) aStudy = appStudy->studyDS();
732 aSel->selectedObjects( selected );
734 if(selected.Extent() >= 1){
735 switch(theCommandID){
737 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
738 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
742 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
743 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
746 SALOME_ListIteratorOfListIO It( selected );
747 for( ; It.More(); It.Next()){
748 Handle(SALOME_InteractiveObject) IObject = It.Value();
749 if(IObject->hasEntry()){
750 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
751 switch(theCommandID){
753 anActor->SetRepresentation(SMESH_Actor::eEdge);
756 anActor->SetRepresentation(SMESH_Actor::eSurface);
759 if(anActor->IsShrunk())
762 anActor->SetShrink();
765 anActor->SetRepresentation(SMESH_Actor::ePoint);
768 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
769 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
772 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
773 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
776 vtkFloatingPointType color[3];
777 anActor->GetSufaceColor(color[0], color[1], color[2]);
778 int c0 = int (color[0] * 255);
779 int c1 = int (color[1] * 255);
780 int c2 = int (color[2] * 255);
781 QColor c(c0, c1, c2);
783 vtkFloatingPointType edgecolor[3];
784 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
785 c0 = int (edgecolor[0] * 255);
786 c1 = int (edgecolor[1] * 255);
787 c2 = int (edgecolor[2] * 255);
788 QColor e(c0, c1, c2);
790 vtkFloatingPointType backfacecolor[3];
791 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
792 c0 = int (backfacecolor[0] * 255);
793 c1 = int (backfacecolor[1] * 255);
794 c2 = int (backfacecolor[2] * 255);
795 QColor b(c0, c1, c2);
797 vtkFloatingPointType nodecolor[3];
798 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
799 c0 = int (nodecolor[0] * 255);
800 c1 = int (nodecolor[1] * 255);
801 c2 = int (nodecolor[2] * 255);
802 QColor n(c0, c1, c2);
804 vtkFloatingPointType color0D[3];
805 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
806 c0 = int (color0D[0] * 255);
807 c1 = int (color0D[1] * 255);
808 c2 = int (color0D[2] * 255);
809 QColor c0D(c0, c1, c2);
811 int size0D = (int)anActor->Get0DSize();
814 int Edgewidth = (int)anActor->GetLineWidth();
817 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
819 vtkFloatingPointType faces_orientation_color[3];
820 anActor->GetFacesOrientationColor(faces_orientation_color);
821 c0 = int (faces_orientation_color[0] * 255);
822 c1 = int (faces_orientation_color[1] * 255);
823 c2 = int (faces_orientation_color[2] * 255);
824 QColor o(c0, c1, c2);
826 vtkFloatingPointType faces_orientation_scale = anActor->GetFacesOrientationScale();
827 bool faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
829 SMESHGUI_Preferences_ColorDlg *aDlg =
830 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
831 aDlg->SetColor(1, c);
832 aDlg->SetColor(2, e);
833 aDlg->SetColor(3, n);
834 aDlg->SetColor(4, b);
835 aDlg->SetColor(5, c0D);
836 aDlg->SetColor(6, o);
837 aDlg->SetIntValue(1, Edgewidth);
838 aDlg->SetIntValue(2, int(Shrink*100.));
839 aDlg->SetIntValue(3, size0D);
840 aDlg->SetDoubleValue(1, faces_orientation_scale);
841 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
843 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
845 VTK::MarkerType aMarkerTypeCurrent = anActor->GetMarkerType();
846 VTK::MarkerScale aMarkerScaleCurrent = anActor->GetMarkerScale();
847 int aMarkerTextureCurrent = anActor->GetMarkerTexture();
848 if( aMarkerTypeCurrent != VTK::MT_USER )
849 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
851 aDlg->setCustomMarker( aMarkerTextureCurrent );
854 QColor color = aDlg->GetColor(1);
855 QColor edgecolor = aDlg->GetColor(2);
856 QColor nodecolor = aDlg->GetColor(3);
857 QColor backfacecolor = aDlg->GetColor(4);
858 QColor color0D = aDlg->GetColor(5);
859 QColor faces_orientation_color = aDlg->GetColor(6);
860 /* actor color and backface color */
861 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
862 vtkFloatingPointType (color.green()) / 255.,
863 vtkFloatingPointType (color.blue()) / 255.);
864 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
865 vtkFloatingPointType (backfacecolor.green()) / 255.,
866 vtkFloatingPointType (backfacecolor.blue()) / 255.);
869 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
870 vtkFloatingPointType (edgecolor.green()) / 255.,
871 vtkFloatingPointType (edgecolor.blue()) / 255.);
873 /* Shrink factor and size edges */
874 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
875 anActor->SetLineWidth(aDlg->GetIntValue(1));
877 /* Nodes color and size */
878 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
879 vtkFloatingPointType (nodecolor.green()) / 255.,
880 vtkFloatingPointType (nodecolor.blue()) / 255.);
883 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
884 vtkFloatingPointType (color0D.green()) / 255.,
885 vtkFloatingPointType (color0D.blue()) / 255.);
886 anActor->Set0DSize(aDlg->GetIntValue(3));
888 /* Faces orientation */
889 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
890 vtkFloatingPointType(faces_orientation_color.greenF()),
891 vtkFloatingPointType(faces_orientation_color.blueF())};
892 anActor->SetFacesOrientationColor(c);
893 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
894 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
897 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
899 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
900 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
901 int aMarkerTextureNew = aDlg->getCustomMarkerID();
902 if( aMarkerTypeNew != VTK::MT_USER )
903 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
905 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
906 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
907 if( anIter != aMarkerMap.end() )
908 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
911 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
912 if( !aGroupObject->_is_nil() )
914 SMESH::ElementType anElementType = aGroupObject->GetType();
916 switch( anElementType )
918 case SMESH::NODE: aColor = nodecolor; break;
919 case SMESH::EDGE: aColor = edgecolor; break;
920 default: aColor = color; break;
923 SALOMEDS::Color aGroupColor;
924 aGroupColor.R = (float)aColor.red() / 255.0;
925 aGroupColor.G = (float)aColor.green() / 255.0;
926 aGroupColor.B = (float)aColor.blue() / 255.0;
927 aGroupObject->SetColor( aGroupColor );
937 SMESH::RepaintCurrentView();
941 void Control( int theCommandID )
943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
944 SALOME_ListIO selected;
946 aSel->selectedObjects( selected );
948 if( !selected.IsEmpty() ){
949 Handle(SALOME_InteractiveObject) anIO = selected.First();
952 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
953 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
954 switch ( theCommandID ){
956 aTitle = QObject::tr( "LENGTH_EDGES" );
957 aControl = SMESH_Actor::eLength;
960 aTitle = QObject::tr( "LENGTH2D_EDGES" );
961 aControl = SMESH_Actor::eLength2D;
964 aTitle = QObject::tr( "FREE_EDGES" );
965 aControl = SMESH_Actor::eFreeEdges;
968 aTitle = QObject::tr( "FREE_BORDERS" );
969 aControl = SMESH_Actor::eFreeBorders;
972 aTitle = QObject::tr( "MULTI_BORDERS" );
973 aControl = SMESH_Actor::eMultiConnection;
976 aTitle = QObject::tr( "FREE_NODES" );
977 aControl = SMESH_Actor::eFreeNodes;
980 aTitle = QObject::tr( "MULTI2D_BORDERS" );
981 aControl = SMESH_Actor::eMultiConnection2D;
984 aTitle = QObject::tr( "AREA_ELEMENTS" );
985 aControl = SMESH_Actor::eArea;
988 aTitle = QObject::tr( "TAPER_ELEMENTS" );
989 aControl = SMESH_Actor::eTaper;
992 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
993 aControl = SMESH_Actor::eAspectRatio;
996 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
997 aControl = SMESH_Actor::eAspectRatio3D;
1000 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1001 aControl = SMESH_Actor::eMinimumAngle;
1004 aTitle = QObject::tr( "WARP_ELEMENTS" );
1005 aControl = SMESH_Actor::eWarping;
1008 aTitle = QObject::tr( "SKEW_ELEMENTS" );
1009 aControl = SMESH_Actor::eSkew;
1012 aTitle = QObject::tr( "SMESH_VOLUME" );
1013 aControl = SMESH_Actor::eVolume3D;
1016 aTitle = QObject::tr( "FREE_FACES" );
1017 aControl = SMESH_Actor::eFreeFaces;
1020 anActor->SetControlMode(aControl);
1021 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
1022 SMESH::RepaintCurrentView();
1029 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1030 MeshObjectType theType,
1031 const QString theInTypeName,
1032 QString & theOutTypeName)
1034 SMESH_TypeFilter aTypeFilter( theType );
1036 if( !theIO.IsNull() )
1038 entry = theIO->getEntry();
1039 LightApp_DataOwner owner( entry );
1040 if ( aTypeFilter.isOk( &owner )) {
1041 theOutTypeName = theInTypeName;
1049 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1051 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1052 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1054 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1055 CORBA::String_var anID = aSComp->GetID().c_str();
1056 if (!strcmp(anID.in(),theIO->getEntry()))
1062 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1063 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1064 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1065 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1066 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1074 QString CheckHomogeneousSelection()
1076 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1077 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1078 SALOME_ListIO selected;
1080 aSel->selectedObjects( selected );
1082 QString RefType = CheckTypeObject(selected.First());
1083 SALOME_ListIteratorOfListIO It(selected);
1084 for ( ; It.More(); It.Next())
1086 Handle(SALOME_InteractiveObject) IObject = It.Value();
1087 QString Type = CheckTypeObject(IObject);
1088 if (Type.compare(RefType) != 0)
1089 return "Heterogeneous Selection";
1096 void SMESHGUI::OnEditDelete()
1098 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1099 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1100 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1102 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1103 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1104 _PTR(GenericAttribute) anAttr;
1105 _PTR(AttributeIOR) anIOR;
1107 int objectCount = 0;
1109 QString aParentComponent = QString::null;
1110 Handle(SALOME_InteractiveObject) anIO;
1111 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1113 anIO = anIt.Value();
1114 QString cur = anIO->getComponentDataType();
1115 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1117 // check if object is reference
1118 _PTR(SObject) aRefSObj;
1119 aNameList.append("\n - ");
1120 if ( aSO->ReferencedObject( aRefSObj ) ) {
1121 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1122 aNameList.append( aRefName );
1123 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1126 aNameList.append(anIO->getName());
1130 if( aParentComponent.isNull() )
1131 aParentComponent = cur;
1132 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1133 aParentComponent = "";
1136 if ( objectCount == 0 )
1137 return; // No Valid Objects Selected
1139 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1140 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1141 QObject::tr("ERR_ERROR"),
1142 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1145 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1146 if (SUIT_MessageBox::warning
1147 (SMESHGUI::desktop(),
1148 QObject::tr("SMESH_WRN_WARNING"),
1149 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1150 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1151 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1154 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1155 SUIT_ViewManager* vm = anApp->activeViewManager();
1156 int nbSf = vm->getViewsCount();
1158 SALOME_ListIteratorOfListIO It(selected);
1160 aStudyBuilder->NewCommand(); // There is a transaction
1161 for( ; It.More(); It.Next()){ // loop on selected IO's
1162 Handle(SALOME_InteractiveObject) IObject = It.Value();
1163 if(IObject->hasEntry()) {
1164 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1166 // disable removal of "SMESH" component object
1167 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1169 if ( engineIOR() == anIOR->Value().c_str() )
1172 //Check the referenced object
1173 _PTR(SObject) aRefSObject;
1174 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1175 aSO = aRefSObject; // Delete main Object instead of reference
1177 // put the whole hierarchy of sub-objects of the selected SO into a list and
1178 // then treat them all starting from the deepest objects (at list back)
1180 std::list< _PTR(SObject) > listSO;
1181 listSO.push_back( aSO );
1182 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1183 for ( ; itSO != listSO.end(); ++itSO ) {
1184 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1185 for (it->InitEx(false); it->More(); it->Next())
1186 listSO.push_back( it->Value() );
1189 // treat SO's in the list starting from the back
1191 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1192 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1193 _PTR(SObject) SO = *ritSO;
1194 if ( !SO ) continue;
1195 std::string anEntry = SO->GetID();
1197 /** Erase graphical object **/
1198 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1199 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1200 for(int i = 0; i < nbSf; i++){
1201 SUIT_ViewWindow *sf = aViews[i];
1202 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1203 SMESH::RemoveActor(sf,anActor);
1208 /** Remove an object from data structures **/
1209 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1210 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1211 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1212 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1213 aMesh->RemoveGroup( aGroup );
1215 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1216 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1217 aMesh->RemoveSubMesh( aSubMesh );
1219 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1221 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1224 IObject = new SALOME_InteractiveObject
1225 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1226 QString objType = CheckTypeObject(IObject);
1227 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1228 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1229 aStudyBuilder->RemoveObjectWithChildren( SO );
1231 else {// default action: remove SObject from the study
1232 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1233 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1235 aStudyBuilder->RemoveObjectWithChildren( SO );
1239 } /* listSO back loop */
1240 } /* IObject->hasEntry() */
1242 aStudyBuilder->CommitCommand();
1244 /* Clear any previous selection */
1246 aSel->setSelectedObjects( l1 );
1248 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1253 SMESHGUI_EXPORT CAM_Module* createModule()
1255 return new SMESHGUI();
1259 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1261 //=============================================================================
1265 //=============================================================================
1266 SMESHGUI::SMESHGUI() :
1267 SalomeApp_Module( "SMESH" ),
1268 LightApp_Module( "SMESH" )
1270 if ( CORBA::is_nil( myComponentSMESH ) )
1272 CORBA::Boolean anIsEmbeddedMode;
1273 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1275 // 0019923: EDF 765 SMESH : default values of hypothesis
1276 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1277 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1278 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1279 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1280 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1283 myActiveDialogBox = 0;
1284 myFilterLibraryDlg = 0;
1288 SMESH::GetFilterManager();
1289 SMESH::GetPattern();
1291 /* load resources for all available meshers */
1292 SMESH::InitAvailableHypotheses();
1295 //=============================================================================
1299 //=============================================================================
1300 SMESHGUI::~SMESHGUI()
1302 SMESH::GetFilterManager()->Destroy();
1303 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1306 //=============================================================================
1310 //=============================================================================
1311 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1313 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1315 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1320 bool SMESHGUI::automaticUpdate()
1322 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1326 return resMgr->booleanValue( "SMESH", "auto_update", false );
1329 //=============================================================================
1333 //=============================================================================
1334 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1336 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1339 //=============================================================================
1343 //=============================================================================
1344 SMESHGUI* SMESHGUI::GetSMESHGUI()
1346 SMESHGUI* smeshMod = 0;
1347 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1350 CAM_Module* module = app->module( "Mesh" );
1351 smeshMod = dynamic_cast<SMESHGUI*>( module );
1354 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1356 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1359 _PTR(Study) aStudy = study->studyDS();
1361 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1370 Standard_EXPORT SMESHGUI* GetComponentGUI()
1372 return SMESHGUI::GetSMESHGUI();
1376 //=============================================================================
1380 //=============================================================================
1381 void SMESHGUI::SetState(int aState)
1386 //=============================================================================
1390 //=============================================================================
1391 void SMESHGUI::ResetState()
1396 //=============================================================================
1400 //=============================================================================
1401 void SMESHGUI::EmitSignalDeactivateDialog()
1403 emit SignalDeactivateActiveDialog();
1406 //=============================================================================
1410 //=============================================================================
1411 void SMESHGUI::EmitSignalStudyFrameChanged()
1413 emit SignalStudyFrameChanged();
1416 //=============================================================================
1420 //=============================================================================
1421 void SMESHGUI::EmitSignalCloseAllDialogs()
1423 emit SignalCloseAllDialogs();
1426 //=============================================================================
1430 //=============================================================================
1431 void SMESHGUI::EmitSignalVisibilityChanged()
1433 emit SignalVisibilityChanged();
1436 //=============================================================================
1440 //=============================================================================
1441 QDialog *SMESHGUI::GetActiveDialogBox()
1443 return myActiveDialogBox;
1446 //=============================================================================
1450 //=============================================================================
1451 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1453 myActiveDialogBox = (QDialog *) aDlg;
1457 //=============================================================================
1461 //=============================================================================
1462 SUIT_Desktop* SMESHGUI::desktop()
1464 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1466 return app->desktop();
1471 //=============================================================================
1475 //=============================================================================
1476 SalomeApp_Study* SMESHGUI::activeStudy()
1478 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1480 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1485 //=============================================================================
1489 //=============================================================================
1490 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1492 /* Here the position is on the bottom right corner - 10 */
1493 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1495 SUIT_Desktop *PP = desktop();
1496 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1497 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1501 //=============================================================================
1505 //=============================================================================
1506 static int isStudyLocked(_PTR(Study) theStudy){
1507 return theStudy->GetProperties()->IsLocked();
1510 static bool checkLock(_PTR(Study) theStudy) {
1511 if (isStudyLocked(theStudy)) {
1512 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1513 QObject::tr("WRN_WARNING"),
1514 QObject::tr("WRN_STUDY_LOCKED") );
1520 //=======================================================================
1521 //function : CheckActiveStudyLocked
1523 //=======================================================================
1525 bool SMESHGUI::isActiveStudyLocked()
1527 _PTR(Study) aStudy = activeStudy()->studyDS();
1528 return checkLock( aStudy );
1531 //=============================================================================
1535 //=============================================================================
1536 bool SMESHGUI::OnGUIEvent( int theCommandID )
1538 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1542 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1543 SUIT_ResourceMgr* mgr = resourceMgr();
1547 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1548 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1551 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1552 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1554 //QAction* act = action( theCommandID );
1556 switch (theCommandID) {
1558 if(checkLock(aStudy)) break;
1566 if(checkLock(aStudy)) break;
1567 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1571 case 150: //MED FILE INFORMATION
1573 SALOME_ListIO selected;
1574 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1576 aSel->selectedObjects( selected );
1577 if( selected.Extent() )
1579 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1580 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1581 if ( !aMesh->_is_nil() )
1583 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1590 case 122: // EXPORT MED
1599 ::ExportMeshToFile(theCommandID);
1603 case 200: // SCALAR BAR
1605 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1606 SALOME_ListIO selected;
1608 aSel->selectedObjects( selected );
1610 if( selected.Extent() ) {
1611 Handle(SALOME_InteractiveObject) anIO = selected.First();
1612 if( anIO->hasEntry() ) {
1613 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1614 anActor->SetControlMode( SMESH_Actor::eNone );
1622 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1632 ::DisableAutoColor();
1635 case 1134: // Clipping
1636 case 1133: // Tranparency
1637 case 1132: // Colors / Size
1644 ::SetDisplayMode(theCommandID, myMarkerMap);
1647 //2D quadratic representation
1650 ::SetDisplayMode(theCommandID, myMarkerMap);
1654 case 216: // 0D elements
1657 case 219: // Volumes
1658 case 220: // All Entity
1659 ::SetDisplayEntity(theCommandID);
1662 case 221: // Orientation of faces
1664 LightApp_SelectionMgr* mgr = selectionMgr();
1665 SALOME_ListIO selected; mgr->selectedObjects( selected );
1667 SALOME_ListIteratorOfListIO it(selected);
1668 for( ; it.More(); it.Next()) {
1669 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1670 if(anIObject->hasEntry()) {
1671 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1672 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1681 if(checkLock(aStudy)) break;
1683 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1686 SMESH::UpdateView();
1688 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1689 SMESH::OnVisuException();
1691 catch (...) { // PAL16774 (Crash after display of many groups)
1692 SMESH::OnVisuException();
1696 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1697 aSel->selectedObjects( l );
1698 aSel->setSelectedObjects( l );
1703 case 301: // DISPLAY
1704 case 302: // DISPLAY ONLY
1706 SMESH::EDisplaing anAction;
1707 switch (theCommandID) {
1708 case 300: anAction = SMESH::eErase; break;
1709 case 301: anAction = SMESH::eDisplay; break;
1710 case 302: anAction = SMESH::eDisplayOnly; break;
1713 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1714 SALOME_ListIO sel_objects, to_process;
1716 aSel->selectedObjects( sel_objects );
1718 if( theCommandID==302 )
1719 startOperation( myEraseAll );
1721 extractContainers( sel_objects, to_process );
1724 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1728 SALOME_ListIteratorOfListIO It( to_process );
1729 for ( ; It.More(); It.Next()) {
1730 Handle(SALOME_InteractiveObject) IOS = It.Value();
1731 if (IOS->hasEntry()) {
1732 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1733 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1734 break; // PAL16774 (Crash after display of many groups)
1736 if (anAction == SMESH::eDisplayOnly)
1737 anAction = SMESH::eDisplay;
1742 // PAL13338 + PAL15161 -->
1743 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1744 SMESH::UpdateView();
1745 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1747 // PAL13338 + PAL15161 <--
1749 catch (...) { // PAL16774 (Crash after display of many groups)
1750 SMESH::OnVisuException();
1753 if (anAction == SMESH::eErase) {
1755 aSel->setSelectedObjects( l1 );
1758 aSel->setSelectedObjects( to_process );
1765 if(checkLock(aStudy)) break;
1768 EmitSignalDeactivateDialog();
1770 ( new SMESHGUI_NodesDlg( this ) )->show();
1773 SUIT_MessageBox::warning(desktop(),
1774 tr("SMESH_WRN_WARNING"),
1775 tr("SMESH_WRN_VIEWER_VTK"));
1780 case 2151: // FILTER
1784 EmitSignalDeactivateDialog();
1785 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1790 case 406: // MOVE NODE
1794 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1795 tr( "NOT_A_VTK_VIEWER" ) );
1799 if(checkLock(aStudy)) break;
1800 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1804 case 701: // COMPUTE MESH
1805 case 711: // PRECOMPUTE MESH
1806 case 712: // EVALUATE MESH
1807 case 713: // MESH ORDER
1809 if (checkLock(aStudy)) break;
1810 startOperation( theCommandID );
1814 case 702: // Create mesh
1815 case 703: // Create sub-mesh
1816 case 704: // Edit mesh/sub-mesh
1817 startOperation( theCommandID );
1819 case 710: // Build compound mesh
1821 if (checkLock(aStudy)) break;
1822 EmitSignalDeactivateDialog();
1823 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1827 case 407: // DIAGONAL INVERSION
1828 case 408: // Delete diagonal
1832 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1833 tr( "NOT_A_VTK_VIEWER" ) );
1837 if ( checkLock( aStudy ) )
1840 /*Standard_Boolean aRes;
1841 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1842 if ( aMesh->_is_nil() )
1844 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1845 tr( "SMESH_BAD_SELECTION" ) );
1849 EmitSignalDeactivateDialog();
1850 if ( theCommandID == 407 )
1851 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1853 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1856 case 409: // Change orientation
1857 case 410: // Union of triangles
1858 case 411: // Cutting of quadrangles
1862 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1863 tr( "NOT_A_VTK_VIEWER" ) );
1867 if ( checkLock( aStudy ) )
1870 EmitSignalDeactivateDialog();
1871 SMESHGUI_MultiEditDlg* aDlg = NULL;
1872 if ( theCommandID == 409 )
1873 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1874 else if ( theCommandID == 410 )
1875 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1877 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1882 case 412: // Smoothing
1884 if(checkLock(aStudy)) break;
1886 EmitSignalDeactivateDialog();
1887 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1890 SUIT_MessageBox::warning(desktop(),
1891 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1895 case 413: // Extrusion
1897 if (checkLock(aStudy)) break;
1899 EmitSignalDeactivateDialog();
1900 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1902 SUIT_MessageBox::warning(desktop(),
1903 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1907 case 414: // Revolution
1909 if(checkLock(aStudy)) break;
1911 EmitSignalDeactivateDialog();
1912 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1915 SUIT_MessageBox::warning(desktop(),
1916 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1920 case 415: // Pattern mapping
1922 if ( checkLock( aStudy ) )
1926 EmitSignalDeactivateDialog();
1927 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1930 SUIT_MessageBox::warning(desktop(),
1931 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1935 case 416: // Extrusion along a path
1937 if (checkLock(aStudy)) break;
1939 EmitSignalDeactivateDialog();
1940 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1942 SUIT_MessageBox::warning(desktop(),
1943 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1947 case 417: // Convert mesh to quadratic
1949 startOperation( 417 );
1950 /* if (checkLock(aStudy)) break;
1952 EmitSignalDeactivateDialog();
1953 new SMESHGUI_ConvToQuadDlg();
1955 SUIT_MessageBox::warning(desktop(),
1956 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1960 case 418: // create 2D mesh from 3D
1962 startOperation( 418 );
1965 case 806: // CREATE GEO GROUP
1967 startOperation( 806 );
1970 case 801: // CREATE GROUP
1974 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1975 tr( "NOT_A_VTK_VIEWER" ) );
1979 if(checkLock(aStudy)) break;
1980 EmitSignalDeactivateDialog();
1981 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1983 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1984 SALOME_ListIO selected;
1986 aSel->selectedObjects( selected );
1988 int nbSel = selected.Extent();
1990 // check if mesh is selected
1991 aMesh = SMESH::GetMeshByIO( selected.First() );
1993 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1998 case 802: // CONSTRUCT GROUP
2002 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2003 tr( "NOT_A_VTK_VIEWER" ) );
2007 if(checkLock(aStudy)) break;
2008 EmitSignalDeactivateDialog();
2010 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2011 SALOME_ListIO selected;
2013 aSel->selectedObjects( selected );
2015 int nbSel = selected.Extent();
2017 // check if submesh is selected
2018 Handle(SALOME_InteractiveObject) IObject = selected.First();
2019 if (IObject->hasEntry()) {
2020 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2022 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2023 if (!aSubMesh->_is_nil()) {
2025 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2026 // get submesh elements list by types
2027 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2028 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2029 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2030 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2031 // create group for each type o elements
2032 QString aName = IObject->getName();
2033 if (aNodes->length() > 0) {
2034 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2035 aGroup->Add(aNodes.inout());
2037 if (aEdges->length() > 0) {
2038 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2039 aGroup->Add(aEdges.inout());
2041 if (aFaces->length() > 0) {
2042 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2043 aGroup->Add(aFaces.inout());
2045 if (aVolumes->length() > 0) {
2046 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2047 aGroup->Add(aVolumes.inout());
2052 catch(const SALOME::SALOME_Exception & S_ex){
2053 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2060 SUIT_MessageBox::warning(desktop(),
2061 tr("SMESH_WRN_WARNING"),
2062 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2067 case 803: // EDIT GROUP
2071 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2072 tr( "NOT_A_VTK_VIEWER" ) );
2076 if(checkLock(aStudy)) break;
2077 EmitSignalDeactivateDialog();
2079 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2080 SALOME_ListIO selected;
2082 aSel->selectedObjects( selected );
2084 SALOME_ListIteratorOfListIO It (selected);
2085 int nbSelectedGroups = 0;
2086 for ( ; It.More(); It.Next() )
2088 SMESH::SMESH_GroupBase_var aGroup =
2089 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2090 if (!aGroup->_is_nil()) {
2092 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2096 if (nbSelectedGroups == 0)
2098 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2104 case 804: // Add elements to group
2106 if(checkLock(aStudy)) break;
2107 if (myState == 800) {
2108 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2109 if (aDlg) aDlg->onAdd();
2114 case 805: // Remove elements from group
2116 if(checkLock(aStudy)) break;
2117 if (myState == 800) {
2118 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2119 if (aDlg) aDlg->onRemove();
2124 case 815: // Edit GEOM GROUP as standalone
2128 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2129 tr( "NOT_A_VTK_VIEWER" ) );
2133 if(checkLock(aStudy)) break;
2134 EmitSignalDeactivateDialog();
2136 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2137 SALOME_ListIO selected;
2139 aSel->selectedObjects( selected );
2141 SALOME_ListIteratorOfListIO It (selected);
2142 for ( ; It.More(); It.Next() )
2144 SMESH::SMESH_GroupOnGeom_var aGroup =
2145 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2146 if (!aGroup->_is_nil()) {
2147 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2154 case 810: // Union Groups
2155 case 811: // Intersect groups
2156 case 812: // Cut groups
2160 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2161 tr( "NOT_A_VTK_VIEWER" ) );
2165 if ( checkLock( aStudy ) )
2168 EmitSignalDeactivateDialog();
2170 SMESHGUI_GroupOpDlg* aDlg = 0;
2171 if ( theCommandID == 810 )
2172 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2173 else if ( theCommandID == 811 )
2174 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2176 aDlg = new SMESHGUI_CutGroupsDlg( this );
2183 case 814: // Create groups of entities from existing groups of superior dimensions
2185 if ( checkLock( aStudy ) )
2188 EmitSignalDeactivateDialog();
2189 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2195 case 813: // Delete groups with their contents
2199 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2200 tr( "NOT_A_VTK_VIEWER" ) );
2204 if ( checkLock( aStudy ) )
2207 EmitSignalDeactivateDialog();
2209 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2213 case 900: // MESH INFOS
2215 EmitSignalDeactivateDialog();
2216 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2217 SALOME_ListIO selected;
2219 aSel->selectedObjects( selected );
2221 if ( selected.Extent() > 1 ) { // a dlg for each IO
2223 SALOME_ListIteratorOfListIO It (selected);
2224 for ( ; It.More(); It.Next() ) {
2225 IOs.Clear(); IOs.Append( It.Value() );
2226 aSel->setSelectedObjects( IOs );
2227 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2229 // restore selection
2230 aSel->setSelectedObjects( selected );
2233 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2237 case 902: // STANDARD MESH INFOS
2239 EmitSignalDeactivateDialog();
2240 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2241 SALOME_ListIO selected;
2243 aSel->selectedObjects( selected );
2245 if ( selected.Extent() > 1 ) { // a dlg for each IO
2247 SALOME_ListIteratorOfListIO It (selected);
2248 for ( ; It.More(); It.Next() ) {
2250 IOs.Append( It.Value() );
2251 aSel->setSelectedObjects( IOs );
2252 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2254 // restore selection
2255 aSel->setSelectedObjects( selected );
2258 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2262 case 903: // WHAT IS
2264 EmitSignalDeactivateDialog();
2265 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2269 case 904: // FIND ELEM
2271 startOperation( theCommandID );
2275 case 1100: // EDIT HYPOTHESIS
2277 if(checkLock(aStudy)) break;
2279 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2280 SALOME_ListIO selected;
2282 aSel->selectedObjects( selected );
2284 int nbSel = selected.Extent();
2287 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2288 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2290 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2291 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2292 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2293 if ( !aHypothesis->_is_nil() )
2296 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2297 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2299 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2310 case 1101: // RENAME
2312 if ( checkLock( aStudy ) )
2315 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2316 SALOME_ListIO selected;
2318 aSel->selectedObjects( selected );
2320 bool isAny = false; // is there any appropriate object selected
2322 SALOME_ListIteratorOfListIO It( selected );
2323 for ( ; It.More(); It.Next() )
2325 Handle(SALOME_InteractiveObject) IObject = It.Value();
2326 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2327 _PTR(GenericAttribute) anAttr;
2328 _PTR(AttributeName) aName;
2331 if ( obj->FindAttribute(anAttr, "AttributeName") )
2334 QString newName = QString(aName->Value().c_str());
2336 // check type to prevent renaming of inappropriate objects
2337 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2338 if (aType == MESH || aType == GROUP ||
2339 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2340 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2341 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2342 aType == HYPOTHESIS || aType == ALGORITHM)
2345 newName = LightApp_NameDlg::getName(desktop(), newName);
2346 if ( !newName.isEmpty() )
2348 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2350 // update name of group object and its actor
2351 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2352 if( !aGroupObject->_is_nil() )
2354 aGroupObject->SetName( newName.toLatin1().data() );
2355 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2356 anActor->setName( newName.toLatin1().data() );
2367 SUIT_MessageBox::warning(desktop(),
2368 QObject::tr("SMESH_WRN_WARNING"),
2369 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2374 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2376 if(checkLock(aStudy)) break;
2377 SUIT_OverrideCursor wc;
2379 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2380 SALOME_ListIO selected;
2382 aSel->selectedObjects( selected, QString::null, false );
2384 SALOME_ListIteratorOfListIO It(selected);
2385 for (int i = 0; It.More(); It.Next(), i++) {
2386 Handle(SALOME_InteractiveObject) IObject = It.Value();
2387 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2390 aSel->setSelectedObjects( l1 );
2395 case 4009: // ELEM0D
2396 case 4010: // GEOM::EDGE
2397 case 4021: // TRIANGLE
2399 case 4023: // POLYGON
2403 if(checkLock(aStudy)) break;
2405 EmitSignalDeactivateDialog();
2406 SMDSAbs_ElementType type = SMDSAbs_Edge;
2408 switch (theCommandID) {
2409 case 4009: // ELEM0D
2410 type = SMDSAbs_0DElement; nbNodes = 1; break;
2411 case 4021: // TRIANGLE
2412 type = SMDSAbs_Face; nbNodes = 3; break;
2414 type = SMDSAbs_Face; nbNodes = 4; break;
2416 type = SMDSAbs_Volume; nbNodes = 4; break;
2417 case 4023: // POLYGON
2418 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2420 type = SMDSAbs_Volume; nbNodes = 8; break;
2421 case 4033: // POLYHEDRE
2422 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2425 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2428 SUIT_MessageBox::warning(desktop(),
2429 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2433 case 4033: // POLYHEDRON
2435 if(checkLock(aStudy)) break;
2437 EmitSignalDeactivateDialog();
2438 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2441 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2442 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2446 case 4034: // QUADRATIC EDGE
2447 case 4035: // QUADRATIC TRIANGLE
2448 case 4036: // QUADRATIC QUADRANGLE
2449 case 4037: // QUADRATIC TETRAHEDRON
2450 case 4038: // QUADRATIC PYRAMID
2451 case 4039: // QUADRATIC PENTAHEDRON
2452 case 4040: // QUADRATIC HEXAHEDRON
2454 if(checkLock(aStudy)) break;
2456 EmitSignalDeactivateDialog();
2459 switch (theCommandID) {
2461 type = QUAD_EDGE; break;
2463 type = QUAD_TRIANGLE; break;
2465 type = QUAD_QUADRANGLE; break;
2467 type = QUAD_TETRAHEDRON; break;
2469 type = QUAD_PYRAMID; break;
2471 type = QUAD_PENTAHEDRON; break;
2473 type = QUAD_HEXAHEDRON;
2477 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2480 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2485 case 4041: // REMOVES NODES
2487 if(checkLock(aStudy)) break;
2489 EmitSignalDeactivateDialog();
2490 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2493 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2498 case 4042: // REMOVES ELEMENTS
2500 if(checkLock(aStudy)) break;
2502 EmitSignalDeactivateDialog();
2503 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2507 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2508 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2512 case 4043: { // CLEAR_MESH
2514 if(checkLock(aStudy)) break;
2516 SALOME_ListIO selected;
2517 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2518 aSel->selectedObjects( selected );
2520 SUIT_OverrideCursor wc;
2521 SALOME_ListIteratorOfListIO It (selected);
2522 for ( ; It.More(); It.Next() )
2524 Handle(SALOME_InteractiveObject) IOS = It.Value();
2525 SMESH::SMESH_Mesh_var aMesh =
2526 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2527 if ( aMesh->_is_nil()) continue;
2529 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2531 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2532 SMESH::ModifiedMesh( aMeshSObj, false, true);
2533 // hide groups and submeshes
2534 _PTR(ChildIterator) anIter =
2535 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2536 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2538 _PTR(SObject) so = anIter->Value();
2539 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2542 catch (const SALOME::SALOME_Exception& S_ex){
2544 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2548 SMESH::UpdateView();
2552 case 4051: // RENUMBERING NODES
2554 if(checkLock(aStudy)) break;
2556 EmitSignalDeactivateDialog();
2557 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2561 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2562 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2566 case 4052: // RENUMBERING ELEMENTS
2568 if(checkLock(aStudy)) break;
2570 EmitSignalDeactivateDialog();
2571 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2575 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2576 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2580 case 4061: // TRANSLATION
2582 if(checkLock(aStudy)) break;
2584 EmitSignalDeactivateDialog();
2585 ( new SMESHGUI_TranslationDlg( this ) )->show();
2588 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2589 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2593 case 4062: // ROTATION
2595 if(checkLock(aStudy)) break;
2597 EmitSignalDeactivateDialog();
2598 ( new SMESHGUI_RotationDlg( this ) )->show();
2601 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2602 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2606 case 4063: // SYMMETRY
2608 if(checkLock(aStudy)) break;
2610 EmitSignalDeactivateDialog();
2611 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2614 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2615 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2619 case 4064: // SEWING
2621 if(checkLock(aStudy)) break;
2623 EmitSignalDeactivateDialog();
2624 ( new SMESHGUI_SewingDlg( this ) )->show();
2627 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2628 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2632 case 4065: // MERGE NODES
2634 if(checkLock(aStudy)) break;
2636 EmitSignalDeactivateDialog();
2637 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2640 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2641 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2645 case 4066: // MERGE EQUAL ELEMENTS
2647 if (checkLock(aStudy)) break;
2649 EmitSignalDeactivateDialog();
2650 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2652 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2653 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2658 case 4067: // MAKE MESH PASS THROUGH POINT
2659 startOperation( 4067 );
2664 if(checkLock(aStudy)) break;
2666 EmitSignalDeactivateDialog();
2667 ( new SMESHGUI_ScaleDlg( this ) )->show();
2670 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2671 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2676 case 5105: // Library of selection filters
2678 static QList<int> aTypes;
2679 if ( aTypes.isEmpty() )
2681 aTypes.append( SMESH::NODE );
2682 aTypes.append( SMESH::EDGE );
2683 aTypes.append( SMESH::FACE );
2684 aTypes.append( SMESH::VOLUME );
2686 if (!myFilterLibraryDlg)
2687 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2688 else if (myFilterLibraryDlg->isHidden())
2689 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2690 myFilterLibraryDlg->raise();
2694 case 6017: // CONTROLS
2712 LightApp_SelectionMgr* mgr = selectionMgr();
2713 SALOME_ListIO selected; mgr->selectedObjects( selected );
2715 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2716 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2718 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2719 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2720 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2721 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2722 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2723 ::Control( theCommandID );
2728 SUIT_MessageBox::warning(desktop(),
2729 tr( "SMESH_WRN_WARNING" ),
2730 tr( "SMESH_BAD_SELECTION" ) );
2734 SUIT_MessageBox::warning(desktop(),
2735 tr( "SMESH_WRN_WARNING" ),
2736 tr( "NOT_A_VTK_VIEWER" ) );
2741 LightApp_SelectionMgr* mgr = selectionMgr();
2742 SALOME_ListIO selected; mgr->selectedObjects( selected );
2744 SALOME_ListIteratorOfListIO it(selected);
2745 for( ; it.More(); it.Next()) {
2746 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2747 if(anIObject->hasEntry()) {
2748 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2749 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2757 LightApp_SelectionMgr* mgr = selectionMgr();
2758 SALOME_ListIO selected; mgr->selectedObjects( selected );
2760 if (selected.Extent() == 1) {
2761 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2762 if(anIObject->hasEntry())
2763 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2764 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2771 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2772 //updateObjBrowser();
2776 //=============================================================================
2780 //=============================================================================
2781 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2786 //=============================================================================
2790 //=============================================================================
2791 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2796 //=============================================================================
2800 //=============================================================================
2801 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2806 //=============================================================================
2807 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2808 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2810 //=============================================================================
2811 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2812 SUIT_ViewWindow* wnd )
2814 if(theIO->hasEntry()){
2815 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2816 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2820 //=======================================================================
2821 // function : createSMESHAction
2823 //=======================================================================
2824 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2827 QWidget* parent = application()->desktop();
2828 SUIT_ResourceMgr* resMgr = resourceMgr();
2830 if ( !icon_id.isEmpty() )
2831 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2833 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2834 if ( !pix.isNull() )
2835 icon = QIcon( pix );
2837 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2838 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2839 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2841 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2844 //=======================================================================
2845 // function : createPopupItem
2847 //=======================================================================
2848 void SMESHGUI::createPopupItem( const int id,
2849 const QString& clients,
2850 const QString& types,
2851 const QString& theRule,
2856 parentId = popupMgr()->actionId( action( pId ) );
2858 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2859 popupMgr()->insert( action( id ), parentId, 0 );
2861 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2862 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2863 QString rule = "(%1) and (%2) and (%3)";
2864 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2865 if( clients.isEmpty() )
2866 rule = rule.arg( QString( "true" ) );
2868 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2869 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2872 bool cont = myRules.contains( id );
2874 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2876 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2877 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2880 //=======================================================================
2881 // function : initialize
2883 //=======================================================================
2884 void SMESHGUI::initialize( CAM_Application* app )
2886 SalomeApp_Module::initialize( app );
2888 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2890 /* Automatic Update flag */
2891 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2893 // ----- create actions --------------
2895 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2896 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2897 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2898 createSMESHAction( 114, "NUM" );
2899 createSMESHAction( 121, "DAT" );
2900 createSMESHAction( 122, "MED" );
2901 createSMESHAction( 123, "UNV" );
2902 createSMESHAction( 140, "STL" );
2903 createSMESHAction( 124, "EXPORT_DAT" );
2904 createSMESHAction( 125, "EXPORT_MED" );
2905 createSMESHAction( 126, "EXPORT_UNV" );
2906 createSMESHAction( 141, "EXPORT_STL" );
2907 createSMESHAction( 150, "FILE_INFO" );
2908 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2909 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2910 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2911 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2912 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2913 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2914 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2915 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2916 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2917 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2918 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2919 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2920 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2921 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2922 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2923 createSMESHAction( 804, "ADD" );
2924 createSMESHAction( 805, "REMOVE" );
2925 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2926 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2927 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2928 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2929 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2930 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2931 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2932 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2933 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2934 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2935 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2936 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2937 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2938 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2939 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2940 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2941 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2942 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2943 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2944 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2945 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2946 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2947 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2948 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2949 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2950 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2951 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2952 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2953 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2954 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2955 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2956 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2957 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2958 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2959 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2960 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2961 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2962 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2963 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2964 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2965 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2966 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2967 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2968 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2969 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2970 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
2971 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2972 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2973 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2974 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2975 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2976 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2977 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2978 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2979 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2980 createSMESHAction( 415, "MAP", "ICON_MAP" );
2981 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2982 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2983 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2984 createSMESHAction( 200, "RESET" );
2985 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2986 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2987 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2988 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2989 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2990 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2991 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2992 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2993 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2994 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2995 createSMESHAction( 220, "ALL" );
2996 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2998 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2999 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3001 createSMESHAction( 1100, "EDIT_HYPO" );
3002 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3003 createSMESHAction( 1102, "UNASSIGN" );
3004 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3005 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3006 createSMESHAction( 1131, "DISPMODE" );
3007 createSMESHAction( 1132, "COLORS" );
3008 createSMESHAction( 1133, "TRANSP" );
3009 createSMESHAction( 1134, "CLIP" );
3010 createSMESHAction( 1135, "DISP_ENT" );
3011 createSMESHAction( 1136, "AUTO_COLOR" );
3012 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3013 createSMESHAction( 2000, "CTRL" );
3015 createSMESHAction( 300, "ERASE" );
3016 createSMESHAction( 301, "DISPLAY" );
3017 createSMESHAction( 302, "DISPLAY_ONLY" );
3018 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3019 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3020 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3021 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3022 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3023 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3024 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3025 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3027 // ----- create menu --------------
3028 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3029 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3030 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3031 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3032 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3033 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3034 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3036 createMenu( separator(), fileId );
3038 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3039 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3040 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3041 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3042 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3043 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3045 createMenu( 111, importId, -1 );
3046 createMenu( 112, importId, -1 );
3047 createMenu( 113, importId, -1 );
3049 createMenu( 121, exportId, -1 );
3050 createMenu( 122, exportId, -1 );
3051 createMenu( 123, exportId, -1 );
3052 createMenu( 140, exportId, -1 ); // export to stl STL
3054 createMenu( separator(), fileId, 10 );
3056 createMenu( 33, editId, -1 );
3058 createMenu( 5105, toolsId, -1 );
3060 createMenu( 702, meshId, -1 ); // "Mesh" menu
3061 createMenu( 703, meshId, -1 );
3062 createMenu( 704, meshId, -1 );
3063 createMenu( 710, meshId, -1 );
3064 createMenu( separator(), meshId, -1 );
3065 createMenu( 701, meshId, -1 );
3066 createMenu( 711, meshId, -1 );
3067 createMenu( 712, meshId, -1 );
3068 createMenu( 713, meshId, -1 );
3069 createMenu( separator(), meshId, -1 );
3070 createMenu( 801, meshId, -1 );
3071 createMenu( 806, meshId, -1 );
3072 createMenu( 802, meshId, -1 );
3073 createMenu( 803, meshId, -1 );
3074 createMenu( 815, meshId, -1 );
3075 createMenu( separator(), meshId, -1 );
3076 createMenu( 810, meshId, -1 );
3077 createMenu( 811, meshId, -1 );
3078 createMenu( 812, meshId, -1 );
3079 createMenu( separator(), meshId, -1 );
3080 createMenu( 814, meshId, -1 );
3081 createMenu( separator(), meshId, -1 );
3082 createMenu( 813, meshId, -1 );
3083 createMenu( separator(), meshId, -1 );
3084 createMenu( 900, meshId, -1 );
3085 createMenu( 902, meshId, -1 );
3086 createMenu( 903, meshId, -1 );
3087 createMenu( 904, meshId, -1 );
3088 createMenu( separator(), meshId, -1 );
3090 createMenu( 6003, ctrlId, -1 );
3091 createMenu( 6001, ctrlId, -1 );
3092 createMenu( 6004, ctrlId, -1 );
3093 createMenu( separator(), ctrlId, -1 );
3094 createMenu( 6005, ctrlId, -1 );
3095 createMenu( 6002, ctrlId, -1 );
3096 createMenu( 6018, ctrlId, -1 );
3097 createMenu( 6019, ctrlId, -1 );
3098 createMenu( 6011, ctrlId, -1 );
3099 createMenu( 6012, ctrlId, -1 );
3100 createMenu( 6013, ctrlId, -1 );
3101 createMenu( 6014, ctrlId, -1 );
3102 createMenu( 6015, ctrlId, -1 );
3103 createMenu( 6016, ctrlId, -1 );
3104 createMenu( separator(), ctrlId, -1 );
3105 createMenu( 6017, ctrlId, -1 );
3106 createMenu( 6009, ctrlId, -1 );
3107 createMenu( 6021, ctrlId, -1 );
3108 createMenu( separator(), ctrlId, -1 );
3110 createMenu( 4000, addId, -1 );
3111 createMenu( 4009, addId, -1 );
3112 createMenu( 4010, addId, -1 );
3113 createMenu( 4021, addId, -1 );
3114 createMenu( 4022, addId, -1 );
3115 createMenu( 4023, addId, -1 );
3116 createMenu( 4031, addId, -1 );
3117 createMenu( 4032, addId, -1 );
3118 createMenu( 4033, addId, -1 );
3119 createMenu( separator(), addId, -1 );
3120 createMenu( 4034, addId, -1 );
3121 createMenu( 4035, addId, -1 );
3122 createMenu( 4036, addId, -1 );
3123 createMenu( 4037, addId, -1 );
3124 createMenu( 4038, addId, -1 );
3125 createMenu( 4039, addId, -1 );
3126 createMenu( 4040, addId, -1 );
3128 createMenu( 4041, removeId, -1 );
3129 createMenu( 4042, removeId, -1 );
3130 createMenu( 4043, removeId, -1 );
3132 createMenu( 4051, renumId, -1 );
3133 createMenu( 4052, renumId, -1 );
3135 createMenu( 4061, transfId, -1 );
3136 createMenu( 4062, transfId, -1 );
3137 createMenu( 4063, transfId, -1 );
3138 createMenu( 4064, transfId, -1 );
3139 createMenu( 4065, transfId, -1 );
3140 createMenu( 4066, transfId, -1 );
3141 createMenu( 4068, transfId, -1 );
3143 createMenu( 406, modifyId, -1 );
3144 createMenu( 4067,modifyId, -1 );
3145 createMenu( 407, modifyId, -1 );
3146 createMenu( 408, modifyId, -1 );
3147 createMenu( 409, modifyId, -1 );
3148 createMenu( 410, modifyId, -1 );
3149 createMenu( 411, modifyId, -1 );
3150 createMenu( 412, modifyId, -1 );
3151 createMenu( 413, modifyId, -1 );
3152 createMenu( 416, modifyId, -1 );
3153 createMenu( 414, modifyId, -1 );
3154 createMenu( 415, modifyId, -1 );
3155 createMenu( 417, modifyId, -1 );
3156 createMenu( 418, modifyId, -1 );
3158 createMenu( 214, viewId, -1 );
3160 // ----- create toolbars --------------
3161 int meshTb = createTool( tr( "TB_MESH" ) ),
3162 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3163 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3164 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3165 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3167 createTool( 702, meshTb );
3168 createTool( 703, meshTb );
3169 createTool( 704, meshTb );
3170 createTool( 710, meshTb );
3171 createTool( separator(), meshTb );
3172 createTool( 701, meshTb );
3173 createTool( 711, meshTb );
3174 createTool( 712, meshTb );
3175 createTool( 713, meshTb );
3176 createTool( separator(), meshTb );
3177 createTool( 801, meshTb );
3178 createTool( 806, meshTb );
3179 createTool( 802, meshTb );
3180 createTool( 803, meshTb );
3181 //createTool( 815, meshTb );
3182 createTool( separator(), meshTb );
3183 createTool( 900, meshTb );
3184 createTool( 902, meshTb );
3185 createTool( 903, meshTb );
3186 createTool( 904, meshTb );
3187 createTool( separator(), meshTb );
3189 createTool( 6001, ctrlTb );
3190 createTool( 6003, ctrlTb );
3191 createTool( 6004, ctrlTb );
3192 createTool( separator(), ctrlTb );
3193 createTool( 6005, ctrlTb );
3194 createTool( 6002, ctrlTb );
3195 createTool( 6018, ctrlTb );
3196 createTool( 6019, ctrlTb );
3197 createTool( 6011, ctrlTb );
3198 createTool( 6012, ctrlTb );
3199 createTool( 6013, ctrlTb );
3200 createTool( 6014, ctrlTb );
3201 createTool( 6015, ctrlTb );
3202 createTool( 6016, ctrlTb );
3203 createTool( separator(), ctrlTb );
3204 createTool( 6017, ctrlTb );
3205 createTool( 6009, ctrlTb );
3206 createTool( 6021, ctrlTb );
3207 createTool( separator(), ctrlTb );
3209 createTool( 4000, addRemTb );
3210 createTool( 4009, addRemTb );
3211 createTool( 4010, addRemTb );
3212 createTool( 4021, addRemTb );
3213 createTool( 4022, addRemTb );
3214 createTool( 4023, addRemTb );
3215 createTool( 4031, addRemTb );
3216 createTool( 4032, addRemTb );
3217 createTool( 4033, addRemTb );
3218 createTool( separator(), addRemTb );
3219 createTool( 4034, addRemTb );
3220 createTool( 4035, addRemTb );
3221 createTool( 4036, addRemTb );
3222 createTool( 4037, addRemTb );
3223 createTool( 4038, addRemTb );
3224 createTool( 4039, addRemTb );
3225 createTool( 4040, addRemTb );
3226 createTool( separator(), addRemTb );
3227 createTool( 4041, addRemTb );
3228 createTool( 4042, addRemTb );
3229 createTool( 4043, addRemTb );
3230 createTool( separator(), addRemTb );
3231 createTool( 4051, addRemTb );
3232 createTool( 4052, addRemTb );
3233 createTool( separator(), addRemTb );
3234 createTool( 4061, addRemTb );
3235 createTool( 4062, addRemTb );
3236 createTool( 4063, addRemTb );
3237 createTool( 4064, addRemTb );
3238 createTool( 4065, addRemTb );
3239 createTool( 4066, addRemTb );
3240 createTool( 4068, addRemTb );
3241 createTool( separator(), addRemTb );
3243 createTool( 406, modifyTb );
3244 createTool( 4067,modifyTb );
3245 createTool( 407, modifyTb );
3246 createTool( 408, modifyTb );
3247 createTool( 409, modifyTb );
3248 createTool( 410, modifyTb );
3249 createTool( 411, modifyTb );
3250 createTool( 412, modifyTb );
3251 createTool( 413, modifyTb );
3252 createTool( 416, modifyTb );
3253 createTool( 414, modifyTb );
3254 createTool( 415, modifyTb );
3255 createTool( 417, modifyTb );
3256 createTool( 418, modifyTb );
3258 createTool( 214, dispModeTb );
3260 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3261 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3264 QString OB = "'ObjectBrowser'",
3265 View = "'" + SVTK_Viewer::Type() + "'",
3267 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3268 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3269 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3270 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3271 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3272 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3273 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3274 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3275 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3276 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3277 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3279 mesh_group = mesh + " " + subMesh + " " + group,
3280 hyp_alg = hypo + " " + algo;
3282 // popup for object browser
3284 isInvisible("not( isVisible )"),
3285 isEmpty("numberOfNodes = 0"),
3286 isNotEmpty("numberOfNodes <> 0"),
3288 // has nodes, edges, etc in VISIBLE! actor
3289 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3290 hasElems("(count( elemTypes ) > 0)"),
3291 hasDifferentElems("(count( elemTypes ) > 1)"),
3292 hasElems0d("({'Elem0d'} in elemTypes)"),
3293 hasEdges("({'Edge'} in elemTypes)"),
3294 hasFaces("({'Face'} in elemTypes)"),
3295 hasVolumes("({'Volume'} in elemTypes)");
3297 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3298 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3299 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3300 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3301 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3302 createPopupItem( 803, OB, group ); // EDIT_GROUP
3303 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3305 popupMgr()->insert( separator(), -1, 0 );
3306 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3307 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3308 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3309 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3310 createPopupItem( 214, OB, mesh_group ); // UPDATE
3311 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3312 createPopupItem( 902, OB, mesh ); // STD_INFO
3313 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3314 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3315 popupMgr()->insert( separator(), -1, 0 );
3316 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3317 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3318 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3319 popupMgr()->insert( separator(), -1, 0 );
3320 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3321 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3322 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3323 popupMgr()->insert( separator(), -1, 0 );
3324 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3325 popupMgr()->insert( separator(), -1, 0 );
3326 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3327 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3328 popupMgr()->insert( separator(), -1, 0 );
3330 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3331 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3333 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3334 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3335 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3336 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3337 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3338 popupMgr()->insert( separator(), -1, 0 );
3341 createPopupItem( 803, View, group ); // EDIT_GROUP
3342 createPopupItem( 804, View, elems ); // ADD
3343 createPopupItem( 805, View, elems ); // REMOVE
3345 popupMgr()->insert( separator(), -1, 0 );
3346 createPopupItem( 214, View, mesh_group ); // UPDATE
3347 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3348 createPopupItem( 902, View, mesh ); // STD_INFO
3349 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3350 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3351 popupMgr()->insert( separator(), -1, 0 );
3353 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3354 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3355 popupMgr()->insert( separator(), -1, 0 );
3358 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3359 QString aType = QString( "%1type in {%2}" ).arg( lc );
3360 aType = aType.arg( mesh_group );
3361 QString aMeshInVTK = aClient + "&&" + aType;
3363 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3364 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3365 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3367 //-------------------------------------------------
3369 //-------------------------------------------------
3370 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3372 popupMgr()->insert( action( 9010 ), anId, -1 );
3373 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3374 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3376 popupMgr()->insert( action( 9011 ), anId, -1 );
3377 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3378 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3380 popupMgr()->insert( separator(), -1, -1 );
3382 //-------------------------------------------------
3384 //-------------------------------------------------
3385 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3387 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3388 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3389 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3391 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3392 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3393 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3395 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3396 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3397 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3399 popupMgr()->insert( separator(), anId, -1 );
3401 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3402 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3403 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3405 //-------------------------------------------------
3407 //-------------------------------------------------
3408 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3410 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3412 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3413 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3414 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3416 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3417 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3418 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3420 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3421 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3422 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3424 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3425 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3426 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3428 popupMgr()->insert( separator(), anId, -1 );
3430 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3431 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3434 //-------------------------------------------------
3435 // Representation of the 2D Quadratic elements
3436 //-------------------------------------------------
3437 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3438 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3439 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3440 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3442 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3443 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3444 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3446 //-------------------------------------------------
3447 // Orientation of faces
3448 //-------------------------------------------------
3449 popupMgr()->insert( action( 221 ), -1, -1 );
3450 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3451 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3453 //-------------------------------------------------
3455 //-------------------------------------------------
3456 popupMgr()->insert( action( 1132 ), -1, -1 );
3457 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3459 //-------------------------------------------------
3461 //-------------------------------------------------
3462 popupMgr()->insert( action( 1133 ), -1, -1 );
3463 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3465 //-------------------------------------------------
3467 //-------------------------------------------------
3468 popupMgr()->insert( action( 1134 ), -1, -1 );
3469 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3471 popupMgr()->insert( separator(), -1, -1 );
3473 //-------------------------------------------------
3475 //-------------------------------------------------
3477 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3478 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3479 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3480 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3482 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3484 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3485 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3487 popupMgr()->insert( separator(), anId, -1 );
3489 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3490 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3491 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3493 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3494 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3495 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3497 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3498 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3499 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3501 popupMgr()->insert( separator(), anId, -1 );
3503 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3504 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3505 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3507 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3508 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3509 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3511 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3512 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3513 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3515 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3516 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3517 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3519 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3520 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3521 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3523 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3524 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3525 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3527 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3528 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3529 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3531 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3532 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3533 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3535 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3536 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3537 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3539 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3540 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3541 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3543 popupMgr()->insert( separator(), anId, -1 );
3545 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3546 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3547 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3549 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3550 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3551 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3553 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3554 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3555 QtxPopupMgr::VisibleRule );
3556 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3558 popupMgr()->insert( separator(), anId, -1 );
3560 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3561 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3563 popupMgr()->insert( separator(), -1, -1 );
3565 //-------------------------------------------------
3567 //-------------------------------------------------
3568 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3569 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3570 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3571 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3573 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3574 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3576 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3577 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3579 popupMgr()->insert( separator(), -1, -1 );
3581 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3582 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3585 //================================================================================
3587 * \brief Return true if SMESH or GEOM objects are selected.
3588 * Is called form LightApp_Module::activateModule() which clear selection if
3589 * not isSelectionCompatible()
3591 //================================================================================
3593 bool SMESHGUI::isSelectionCompatible()
3595 bool isCompatible = true;
3596 SALOME_ListIO selected;
3597 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3598 Sel->selectedObjects( selected );
3600 SALOME_ListIteratorOfListIO It( selected );
3601 for ( ; isCompatible && It.More(); It.Next())
3603 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3604 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3606 return isCompatible;
3610 bool SMESHGUI::reusableOperation( const int id )
3612 // compute, evaluate and precompute are not reusable operations
3613 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3616 bool SMESHGUI::activateModule( SUIT_Study* study )
3618 bool res = SalomeApp_Module::activateModule( study );
3620 setMenuShown( true );
3621 setToolShown( true );
3623 // Reset actions accelerator keys
3624 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3625 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3626 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3628 action( 33)->setEnabled(true); // Delete: Key_Delete
3629 action(1101)->setEnabled(true); // Rename: Key_F2
3631 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3632 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3633 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3634 if ( _PTR(Study) aStudy = s->studyDS()) {
3635 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3636 updateObjBrowser(); // objects can be removed
3642 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3644 setMenuShown( false );
3645 setToolShown( false );
3647 EmitSignalCloseAllDialogs();
3649 // Unset actions accelerator keys
3650 action(111)->setShortcut(QKeySequence()); // Import DAT
3651 action(112)->setShortcut(QKeySequence()); // Import UNV
3652 action(113)->setShortcut(QKeySequence()); // Import MED
3654 action( 33)->setEnabled(false); // Delete: Key_Delete
3655 action(1101)->setEnabled(false); // Rename: Key_F2
3657 return SalomeApp_Module::deactivateModule( study );
3660 void SMESHGUI::studyClosed( SUIT_Study* s )
3662 SMESH::RemoveVisuData( s->id() );
3663 SalomeApp_Module::studyClosed( s );
3666 void SMESHGUI::OnGUIEvent()
3668 const QObject* obj = sender();
3669 if ( !obj || !obj->inherits( "QAction" ) )
3671 int id = actionId((QAction*)obj);
3676 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3678 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3679 if ( CORBA::is_nil( myComponentSMESH ) )
3681 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3683 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3684 return aGUI.myComponentSMESH;
3687 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3688 return myComponentSMESH;
3691 QString SMESHGUI::engineIOR() const
3693 CORBA::ORB_var anORB = getApp()->orb();
3694 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3695 return QString( anIOR.in() );
3698 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3700 SalomeApp_Module::contextMenuPopup( client, menu, title );
3702 selectionMgr()->selectedObjects( lst );
3703 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3704 Handle(SALOME_InteractiveObject) io = lst.First();
3705 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3706 _PTR(Study) study = appStudy->studyDS();
3707 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3709 QString aName = QString( obj->GetName().c_str() );
3710 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3711 aName.remove( (aName.length() - 1), 1 );
3717 LightApp_Selection* SMESHGUI::createSelection() const
3719 return new SMESHGUI_Selection();
3722 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3724 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3725 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3728 void SMESHGUI::viewManagers( QStringList& list ) const
3730 list.append( SVTK_Viewer::Type() );
3733 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3735 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3736 SMESH::UpdateSelectionProp( this );
3739 void SMESHGUI::createPreferences()
3741 // General tab ------------------------------------------------------------------------
3742 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3744 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3745 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3747 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3748 setPreferenceProperty( qaGroup, "columns", 2 );
3749 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3750 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3751 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3752 setPreferenceProperty( prec, "min", 0 );
3753 setPreferenceProperty( prec, "max", 16 );
3755 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3756 setPreferenceProperty( dispgroup, "columns", 2 );
3757 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3759 modes.append( "Wireframe" );
3760 modes.append( "Shading" );
3761 modes.append( "Nodes" );
3762 modes.append( "Shrink" );
3763 QList<QVariant> indices;
3764 indices.append( 0 );
3765 indices.append( 1 );
3766 indices.append( 2 );
3767 indices.append( 3 );
3768 setPreferenceProperty( dispmode, "strings", modes );
3769 setPreferenceProperty( dispmode, "indexes", indices );
3771 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3772 setPreferenceProperty( arcgroup, "columns", 2 );
3773 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3774 QStringList quadraticModes;
3775 quadraticModes.append("Lines");
3776 quadraticModes.append("Arcs");
3778 indices.append( 0 );
3779 indices.append( 1 );
3780 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3781 setPreferenceProperty( quadraticmode, "indexes", indices );
3783 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3784 "SMESH", "max_angle" );
3785 setPreferenceProperty( maxAngle, "min", 1 );
3786 setPreferenceProperty( maxAngle, "max", 90 );
3790 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3791 setPreferenceProperty( exportgroup, "columns", 2 );
3792 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3793 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3795 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3796 setPreferenceProperty( computeGroup, "columns", 2 );
3797 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3799 modes.append( "Never" );
3800 modes.append( "Errors only" );
3801 modes.append( "Always" );
3803 indices.append( 0 );
3804 indices.append( 1 );
3805 indices.append( 2 );
3806 setPreferenceProperty( notifyMode, "strings", modes );
3807 setPreferenceProperty( notifyMode, "indexes", indices );
3809 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3810 setPreferenceProperty( segGroup, "columns", 2 );
3811 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3812 "SMESH", "segmentation" );
3813 setPreferenceProperty( segLen, "min", 1 );
3814 setPreferenceProperty( segLen, "max", 10000000 );
3815 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3816 "SMESH", "nb_segments_per_edge" );
3817 setPreferenceProperty( nbSeg, "min", 1 );
3818 setPreferenceProperty( nbSeg, "max", 10000000 );
3820 // Mesh tab ------------------------------------------------------------------------
3821 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3822 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3823 setPreferenceProperty( nodeGroup, "columns", 3 );
3825 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3827 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
3829 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3830 QList<QVariant> aMarkerTypeIndicesList;
3831 QList<QVariant> aMarkerTypeIconsList;
3832 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
3833 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
3834 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
3835 aMarkerTypeIndicesList << i;
3836 aMarkerTypeIconsList << pixmap;
3838 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
3839 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
3841 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
3843 QList<QVariant> aMarkerScaleIndicesList;
3844 QStringList aMarkerScaleValuesList;
3845 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
3846 aMarkerScaleIndicesList << i;
3847 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
3849 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
3850 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
3852 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3853 setPreferenceProperty( elemGroup, "columns", 2 );
3855 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3856 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3857 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3858 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3860 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3861 //setPreferenceProperty( sp, "hstretch", 0 );
3862 //setPreferenceProperty( sp, "vstretch", 0 );
3864 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3865 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3866 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3867 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3868 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3869 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3870 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3872 setPreferenceProperty( size0d, "min", 1 );
3873 setPreferenceProperty( size0d, "max", 10 );
3875 setPreferenceProperty( sp, "hstretch", 0 );
3876 setPreferenceProperty( sp, "vstretch", 0 );
3878 setPreferenceProperty( elemW, "min", 1 );
3879 setPreferenceProperty( elemW, "max", 5 );
3881 setPreferenceProperty( shrink, "min", 0 );
3882 setPreferenceProperty( shrink, "max", 100 );
3884 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3885 setPreferenceProperty( orientGroup, "columns", 1 );
3887 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3888 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3890 setPreferenceProperty( orientScale, "min", 0.05 );
3891 setPreferenceProperty( orientScale, "max", 0.5 );
3892 setPreferenceProperty( orientScale, "step", 0.05 );
3894 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3896 // Selection tab ------------------------------------------------------------------------
3897 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3899 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3900 setPreferenceProperty( selGroup, "columns", 2 );
3902 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3903 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3904 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3906 setPreferenceProperty( selW, "min", 1 );
3907 setPreferenceProperty( selW, "max", 5 );
3909 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3910 setPreferenceProperty( preGroup, "columns", 2 );
3912 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3913 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3915 setPreferenceProperty( preW, "min", 1 );
3916 setPreferenceProperty( preW, "max", 5 );
3918 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3919 setPreferenceProperty( precSelGroup, "columns", 2 );
3921 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3922 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3923 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3925 // Scalar Bar tab ------------------------------------------------------------------------
3926 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3927 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3928 setPreferenceProperty( fontGr, "columns", 2 );
3930 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3931 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3933 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3934 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3936 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3937 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3939 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3940 setPreferenceProperty( numcol, "min", 2 );
3941 setPreferenceProperty( numcol, "max", 256 );
3943 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3944 setPreferenceProperty( numlab, "min", 2 );
3945 setPreferenceProperty( numlab, "max", 65 );
3947 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3948 setPreferenceProperty( orientGr, "columns", 2 );
3949 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3950 QStringList orients;
3951 orients.append( tr( "SMESH_VERTICAL" ) );
3952 orients.append( tr( "SMESH_HORIZONTAL" ) );
3953 indices.clear(); indices.append( 0 ); indices.append( 1 );
3954 setPreferenceProperty( orient, "strings", orients );
3955 setPreferenceProperty( orient, "indexes", indices );
3957 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3958 setPreferenceProperty( posVSizeGr, "columns", 2 );
3959 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3960 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3961 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3962 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3963 setPreferenceProperty( xv, "step", 0.1 );
3964 setPreferenceProperty( xv, "min", 0.0 );
3965 setPreferenceProperty( xv, "max", 1.0 );
3966 setPreferenceProperty( yv, "step", 0.1 );
3967 setPreferenceProperty( yv, "min", 0.0 );
3968 setPreferenceProperty( yv, "max", 1.0 );
3969 setPreferenceProperty( wv, "step", 0.1 );
3970 setPreferenceProperty( wv, "min", 0.0 );
3971 setPreferenceProperty( wv, "max", 1.0 );
3972 setPreferenceProperty( hv, "min", 0.0 );
3973 setPreferenceProperty( hv, "max", 1.0 );
3974 setPreferenceProperty( hv, "step", 0.1 );
3976 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3977 setPreferenceProperty( posHSizeGr, "columns", 2 );
3978 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3979 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3980 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3981 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3982 setPreferenceProperty( xv, "min", 0.0 );
3983 setPreferenceProperty( xv, "max", 1.0 );
3984 setPreferenceProperty( xv, "step", 0.1 );
3985 setPreferenceProperty( xh, "min", 0.0 );
3986 setPreferenceProperty( xh, "max", 1.0 );
3987 setPreferenceProperty( xh, "step", 0.1 );
3988 setPreferenceProperty( yh, "min", 0.0 );
3989 setPreferenceProperty( yh, "max", 1.0 );
3990 setPreferenceProperty( yh, "step", 0.1 );
3991 setPreferenceProperty( wh, "min", 0.0 );
3992 setPreferenceProperty( wh, "max", 1.0 );
3993 setPreferenceProperty( wh, "step", 0.1 );
3994 setPreferenceProperty( hh, "min", 0.0 );
3995 setPreferenceProperty( hh, "max", 1.0 );
3996 setPreferenceProperty( hh, "step", 0.1 );
3999 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4001 if( sect=="SMESH" ) {
4002 float sbX1,sbY1,sbW,sbH;
4003 float aTol = 1.00000009999999;
4004 std::string aWarning;
4005 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4006 if( name=="selection_object_color" || name=="selection_element_color" ||
4007 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4008 name=="selection_precision_node" || name=="selection_precision_element" ||
4009 name=="selection_precision_object")
4010 SMESH::UpdateSelectionProp( this );
4011 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4012 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4013 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4014 if(sbX1+sbW > aTol){
4015 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4018 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4019 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4022 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4023 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4024 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4025 if(sbY1+sbH > aTol){
4026 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4027 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4028 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4031 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4032 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4033 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4034 if(sbX1+sbW > aTol){
4035 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4038 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4039 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4042 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4043 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4044 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4045 if(sbY1+sbH > aTol){
4046 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4049 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4050 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4053 else if ( name == "segmentation" ) {
4054 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4055 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4057 else if ( name == "nb_segments_per_edge" ) {
4058 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4059 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4062 if(aWarning.size() != 0){
4063 aWarning += "The default values are applied instead.";
4064 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4065 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4066 QObject::tr(aWarning.c_str()));
4071 //================================================================================
4073 * \brief Update something in accordance with update flags
4074 * \param theFlags - update flags
4076 * Update viewer or/and object browser etc. in accordance with update flags ( see
4077 * LightApp_UpdateFlags enumeration ).
4079 //================================================================================
4080 void SMESHGUI::update( const int flags )
4082 if ( flags & UF_Viewer | flags & UF_Forced )
4083 SMESH::UpdateView();
4085 SalomeApp_Module::update( flags );
4088 //================================================================================
4090 * \brief Set default selection mode
4092 * SLOT called when operation commited. Sets default selection mode
4094 //================================================================================
4095 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4097 SVTK_ViewWindow* vtkWnd =
4098 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4100 vtkWnd->SetSelectionMode( ActorSelection );
4103 //================================================================================
4105 * \brief Set default selection mode
4107 * SLOT called when operation aborted. Sets default selection mode
4109 //================================================================================
4110 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4112 SVTK_ViewWindow* vtkWnd =
4113 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4115 vtkWnd->SetSelectionMode( ActorSelection );
4118 //================================================================================
4120 * \brief Creates operation with given identifier
4121 * \param id - identifier of operation to be started
4122 * \return Pointer on created operation or NULL if operation is not created
4124 * Virtual method redefined from the base class creates operation with given id.
4125 * It is called called automatically from startOperation method of base class.
4127 //================================================================================
4128 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4130 LightApp_Operation* op = 0;
4131 // to do : create operation here
4134 case 417: //convert to quadratic
4135 op = new SMESHGUI_ConvToQuadOp();
4137 case 418: // create 2D mesh as boundary on 3D
4138 op = new SMESHGUI_Make2DFrom3DOp();
4140 case 701: // Compute mesh
4141 op = new SMESHGUI_ComputeOp();
4143 case 702: // Create mesh
4144 op = new SMESHGUI_MeshOp( true, true );
4146 case 703: // Create sub-mesh
4147 op = new SMESHGUI_MeshOp( true, false );
4149 case 704: // Edit mesh/sub-mesh
4150 op = new SMESHGUI_MeshOp( false );
4152 case 711: // Precompute mesh
4153 op = new SMESHGUI_PrecomputeOp();
4155 case 712: // Evaluate mesh
4156 op = new SMESHGUI_EvaluateOp();
4158 case 713: // Evaluate mesh
4159 op = new SMESHGUI_MeshOrderOp();
4161 case 806: // Create group on geom
4162 op = new SMESHGUI_GroupOnShapeOp();
4164 case 904: // Find element
4165 op = new SMESHGUI_FindElemByPointOp();
4167 case 4067: // make mesh pass through point
4168 op = new SMESHGUI_MakeNodeAtPointOp();
4175 op = SalomeApp_Module::createOperation( id );
4179 //================================================================================
4181 * \brief Stops current operations and starts a given one
4182 * \param id - The id of the operation to start
4184 //================================================================================
4186 void SMESHGUI::switchToOperation(int id)
4188 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4189 activeStudy()->abortAllOperations();
4190 startOperation( id );
4193 LightApp_Displayer* SMESHGUI::displayer()
4196 myDisplayer = new SMESHGUI_Displayer( getApp() );
4200 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4203 int aTolerance = 64;
4204 int anIterations = 0;
4210 if( anIterations % aPeriod == 0 )
4213 if( aTolerance < 1 )
4216 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4218 aHue = (int)( 360.0 * rand() / RAND_MAX );
4219 //cout << "Hue = " << aHue << endl;
4221 //cout << "Auto colors : ";
4223 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4224 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4225 for( ; it != itEnd; ++it )
4227 SALOMEDS::Color anAutoColor = *it;
4228 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4231 aQColor.getHsv( &h, &s, &v );
4233 if( abs( h - aHue ) < aTolerance )
4236 //cout << "break (diff = " << abs( h - aHue ) << ")";
4246 //cout << "Hue of the returned color = " << aHue << endl;
4248 aColor.setHsv( aHue, 255, 255 );
4250 SALOMEDS::Color aSColor;
4251 aSColor.R = (double)aColor.red() / 255.0;
4252 aSColor.G = (double)aColor.green() / 255.0;
4253 aSColor.B = (double)aColor.blue() / 255.0;
4258 const char gSeparator = '_'; // character used to separate parameter names
4259 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4260 const char gPathSep = '|'; // character used to separate paths
4263 * \brief Store visual parameters
4265 * This method is called just before the study document is saved.
4266 * Store visual parameters in AttributeParameter attribue(s)
4268 void SMESHGUI::storeVisualParameters (int savePoint)
4270 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4271 if (!appStudy || !appStudy->studyDS())
4273 _PTR(Study) studyDS = appStudy->studyDS();
4275 // componentName is used for encoding of entries when storing them in IParameters
4276 std::string componentName = myComponentSMESH->ComponentDataType();
4277 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4278 //if (!aSComponent) return;
4281 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4282 componentName.c_str(),
4284 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4286 // store map of custom markers
4287 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4288 if( !aMarkerMap.empty() )
4290 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4291 for( ; anIter != aMarkerMap.end(); anIter++ )
4293 int anId = anIter->first;
4294 VTK::MarkerData aMarkerData = anIter->second;
4295 std::string aMarkerFileName = aMarkerData.first;
4296 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4297 if( aMarkerTexture.size() < 3 )
4298 continue; // should contain at least width, height and the first value
4300 QString aPropertyName( "texture" );
4301 aPropertyName += gSeparator;
4302 aPropertyName += QString::number( anId );
4304 QString aPropertyValue = aMarkerFileName.c_str();
4305 aPropertyValue += gPathSep;
4307 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4308 ushort aWidth = *aTextureIter++;
4309 ushort aHeight = *aTextureIter++;
4310 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4311 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4312 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4313 aPropertyValue += QString::number( *aTextureIter );
4315 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4319 // viewers counters are used for storing view_numbers in IParameters
4322 // main cycle to store parameters of displayed objects
4323 QList<SUIT_ViewManager*> lst;
4324 QList<SUIT_ViewManager*>::Iterator it;
4325 getApp()->viewManagers(lst);
4326 for (it = lst.begin(); it != lst.end(); it++)
4328 SUIT_ViewManager* vman = *it;
4329 QString vType = vman->getType();
4331 // saving VTK actors properties
4332 if (vType == SVTK_Viewer::Type())
4334 QVector<SUIT_ViewWindow*> views = vman->getViews();
4335 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4337 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4339 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4340 vtkActorCollection* allActors = aCopy.GetActors();
4341 allActors->InitTraversal();
4342 while (vtkActor* actor = allActors->GetNextActor())
4344 if (actor->GetVisibility()) // store only visible actors
4346 SMESH_Actor* aSmeshActor = 0;
4347 if (actor->IsA("SMESH_Actor"))
4348 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4349 if (aSmeshActor && aSmeshActor->hasIO())
4351 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4354 // entry is "encoded" = it does NOT contain component adress,
4355 // since it is a subject to change on next component loading
4356 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4358 std::string param, vtkParam = vType.toLatin1().data();
4359 vtkParam += gSeparator;
4360 vtkParam += QString::number(vtkViewers).toLatin1().data();
4361 vtkParam += gSeparator;
4364 param = vtkParam + "Visibility";
4365 ip->setParameter(entry, param, "On");
4368 param = vtkParam + "Representation";
4369 ip->setParameter(entry, param, QString::number
4370 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4373 param = vtkParam + "IsShrunk";
4374 ip->setParameter(entry, param, QString::number
4375 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4377 // Displayed entities
4378 unsigned int aMode = aSmeshActor->GetEntityMode();
4379 bool isE = aMode & SMESH_Actor::eEdges;
4380 bool isF = aMode & SMESH_Actor::eFaces;
4381 bool isV = aMode & SMESH_Actor::eVolumes;
4383 QString modeStr ("e");
4384 modeStr += gDigitsSep; modeStr += QString::number(isE);
4385 modeStr += gDigitsSep; modeStr += "f";
4386 modeStr += gDigitsSep; modeStr += QString::number(isF);
4387 modeStr += gDigitsSep; modeStr += "v";
4388 modeStr += gDigitsSep; modeStr += QString::number(isV);
4390 param = vtkParam + "Entities";
4391 ip->setParameter(entry, param, modeStr.toLatin1().data());
4393 // Colors (surface:edge:)
4394 vtkFloatingPointType r, g, b;
4396 aSmeshActor->GetSufaceColor(r, g, b);
4397 QString colorStr ("surface");
4398 colorStr += gDigitsSep; colorStr += QString::number(r);
4399 colorStr += gDigitsSep; colorStr += QString::number(g);
4400 colorStr += gDigitsSep; colorStr += QString::number(b);
4402 aSmeshActor->GetBackSufaceColor(r, g, b);
4403 colorStr += gDigitsSep; colorStr += "backsurface";
4404 colorStr += gDigitsSep; colorStr += QString::number(r);
4405 colorStr += gDigitsSep; colorStr += QString::number(g);
4406 colorStr += gDigitsSep; colorStr += QString::number(b);
4408 aSmeshActor->GetEdgeColor(r, g, b);
4409 colorStr += gDigitsSep; colorStr += "edge";
4410 colorStr += gDigitsSep; colorStr += QString::number(r);
4411 colorStr += gDigitsSep; colorStr += QString::number(g);
4412 colorStr += gDigitsSep; colorStr += QString::number(b);
4414 aSmeshActor->GetNodeColor(r, g, b);
4415 colorStr += gDigitsSep; colorStr += "node";
4416 colorStr += gDigitsSep; colorStr += QString::number(r);
4417 colorStr += gDigitsSep; colorStr += QString::number(g);
4418 colorStr += gDigitsSep; colorStr += QString::number(b);
4420 param = vtkParam + "Colors";
4421 ip->setParameter(entry, param, colorStr.toLatin1().data());
4423 // Sizes of lines and points
4424 QString sizeStr ("line");
4425 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4426 sizeStr += gDigitsSep; sizeStr += "shrink";
4427 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4429 param = vtkParam + "Sizes";
4430 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4435 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4436 if( aMarkerType == VTK::MT_USER ) {
4437 markerStr += "custom";
4438 markerStr += gDigitsSep;
4439 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4443 markerStr += gDigitsSep;
4444 markerStr += QString::number( (int)aMarkerType );
4445 markerStr += gDigitsSep;
4446 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4449 param = vtkParam + "PointMarker";
4450 ip->setParameter(entry, param, markerStr.toLatin1().data());
4453 param = vtkParam + "Opacity";
4454 ip->setParameter(entry, param,
4455 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4458 param = vtkParam + "ClippingPlane";
4459 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4461 ip->setParameter(entry, param, "Off");
4462 for (int ipl = 0; ipl < nPlanes; ipl++) {
4463 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4464 SMESH::Orientation anOrientation;
4466 vtkFloatingPointType anAngle[2];
4467 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4468 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4469 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4470 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4471 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4473 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4475 } // if (io->hasEntry())
4476 } // SMESH_Actor && hasIO
4478 } // while.. actors traversal
4482 } // if (SVTK view model)
4483 } // for (viewManagers)
4487 * \brief Restore visual parameters
4489 * This method is called after the study document is opened.
4490 * Restore visual parameters from AttributeParameter attribue(s)
4492 void SMESHGUI::restoreVisualParameters (int savePoint)
4494 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4495 if (!appStudy || !appStudy->studyDS())
4497 _PTR(Study) studyDS = appStudy->studyDS();
4499 // componentName is used for encoding of entries when storing them in IParameters
4500 std::string componentName = myComponentSMESH->ComponentDataType();
4501 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4502 //if (!aSComponent) return;
4505 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4506 componentName.c_str(),
4508 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4510 // restore map of custom markers
4511 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4513 std::vector<std::string> properties = ip->getProperties();
4514 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4516 std::string property = *propIt;
4517 QString aPropertyName( property.c_str() );
4518 QString aPropertyValue( ip->getProperty( property ).c_str() );
4520 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4521 if( aPropertyNameList.size() != 2 )
4526 if( aPropertyNameList[0] == "texture" )
4527 anId = aPropertyNameList[1].toInt( &ok );
4529 if( !ok || anId < 1 )
4532 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4533 if( aPropertyValueList.size() != 2 )
4536 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4537 QString aMarkerTextureString = aPropertyValueList[1];
4538 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4539 if( aMarkerTextureStringList.size() != 3 )
4543 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4548 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4552 VTK::MarkerTexture aMarkerTexture;
4553 aMarkerTexture.push_back( aWidth );
4554 aMarkerTexture.push_back( aHeight );
4556 QString aMarkerTextureData = aMarkerTextureStringList[2];
4557 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4559 QChar aChar = aMarkerTextureData.at( i );
4560 if( aChar.isDigit() )
4561 aMarkerTexture.push_back( aChar.digitValue() );
4564 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4567 std::vector<std::string> entries = ip->getEntries();
4569 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4571 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4572 QString entry (ip->decodeEntry(*entIt).c_str());
4574 // Check that the entry corresponds to a real object in the Study
4575 // as the object may be deleted or modified after the visual state is saved.
4576 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4577 if (!so) continue; //Skip the not existent entry
4579 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4580 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4582 std::vector<std::string>::iterator namesIt = paramNames.begin();
4583 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4585 // actors are stored in a map after displaying of them for
4586 // quicker access in the future: map < viewID to actor >
4587 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4589 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4591 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4592 // '_' is used as separator and should not be used in viewer type or parameter names.
4593 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4594 if (lst.size() != 3)
4597 QString viewerTypStr = lst[0];
4598 QString viewIndexStr = lst[1];
4599 QString paramNameStr = lst[2];
4602 int viewIndex = viewIndexStr.toUInt(&ok);
4603 if (!ok) // bad conversion of view index to integer
4607 if (viewerTypStr == SVTK_Viewer::Type())
4609 SMESH_Actor* aSmeshActor = 0;
4610 if (vtkActors.IsBound(viewIndex))
4611 aSmeshActor = vtkActors.Find(viewIndex);
4613 if (paramNameStr == "Visibility")
4615 if (!aSmeshActor && displayer())
4617 QList<SUIT_ViewManager*> lst;
4618 getApp()->viewManagers(viewerTypStr, lst);
4620 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4621 if (viewIndex >= 0 && viewIndex < lst.count()) {
4622 SUIT_ViewManager* vman = lst.at(viewIndex);
4623 SUIT_ViewModel* vmodel = vman->getViewModel();
4624 // SVTK view model can be casted to SALOME_View
4625 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4627 // store displayed actor in a temporary map for quicker
4628 // access later when restoring other parameters
4629 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4630 vtkRenderer* Renderer = vtkView->getRenderer();
4631 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4632 vtkActorCollection* theActors = aCopy.GetActors();
4633 theActors->InitTraversal();
4634 bool isFound = false;
4635 vtkActor *ac = theActors->GetNextActor();
4636 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4637 if (ac->IsA("SMESH_Actor")) {
4638 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4639 if (aGeomAc->hasIO()) {
4640 Handle(SALOME_InteractiveObject) io =
4641 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4642 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4644 vtkActors.Bind(viewIndex, aGeomAc);
4651 } // if (paramNameStr == "Visibility")
4654 // the rest properties "work" with SMESH_Actor
4657 QString val ((*valuesIt).c_str());
4660 if (paramNameStr == "Representation") {
4661 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4664 else if (paramNameStr == "IsShrunk") {
4666 if (!aSmeshActor->IsShrunk())
4667 aSmeshActor->SetShrink();
4670 if (aSmeshActor->IsShrunk())
4671 aSmeshActor->UnShrink();
4674 // Displayed entities
4675 else if (paramNameStr == "Entities") {
4676 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4677 if (mode.count() == 6) {
4678 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4679 MESSAGE("Invalid order of data in Entities, must be: "
4680 "e:0/1:f:0/1:v:0/1");
4683 unsigned int aMode = aSmeshActor->GetEntityMode();
4684 unsigned int aNewMode =
4685 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4686 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4687 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4688 if (aNewMode != aMode)
4689 aSmeshActor->SetEntityMode(aNewMode);
4694 else if (paramNameStr == "Colors") {
4695 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4696 if (colors.count() == 16) {
4697 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4698 colors[8] != "edge" || colors[12] != "node") {
4699 MESSAGE("Invalid order of data in Colors, must be: "
4700 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4703 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4704 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4705 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4706 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4710 // Sizes of lines and points
4711 else if (paramNameStr == "Sizes") {
4712 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4713 if (sizes.count() == 4) {
4714 if (sizes[0] != "line" || sizes[2] != "shrink") {
4715 MESSAGE("Invalid order of data in Sizes, must be: "
4716 "line:int:shrink:float");
4719 aSmeshActor->SetLineWidth(sizes[1].toInt());
4720 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4723 else if (sizes.count() == 6) { // just to support old format
4724 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4725 MESSAGE("Invalid order of data in Sizes, must be: "
4726 "line:int:node:int:shrink:float");
4729 aSmeshActor->SetLineWidth(sizes[1].toInt());
4730 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4731 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4736 else if (paramNameStr == "PointMarker") {
4737 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
4738 if( data.count() >= 2 ) {
4740 int aParam1 = data[1].toInt( &ok );
4742 if( data[0] == "std" && data.count() == 3 ) {
4743 int aParam2 = data[2].toInt( &ok );
4744 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
4746 else if( data[0] == "custom" ) {
4747 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
4748 if( markerIt != aMarkerMap.end() ) {
4749 VTK::MarkerData aMarkerData = markerIt->second;
4750 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
4757 else if (paramNameStr == "Opacity") {
4758 aSmeshActor->SetOpacity(val.toFloat());
4761 else if (paramNameStr.startsWith("ClippingPlane")) {
4762 cout << "$$$ ClippingPlane 1" << endl;
4763 if (paramNameStr == "ClippingPlane1" || val == "Off")
4764 aSmeshActor->RemoveAllClippingPlanes();
4766 cout << "$$$ ClippingPlane 2" << endl;
4767 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4768 if (vals.count() == 4) { // format check: 4 values
4769 cout << "$$$ ClippingPlane 3" << endl;
4770 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4771 double aDistance = vals[1].toFloat();
4772 vtkFloatingPointType anAngle[2];
4773 anAngle[0] = vals[2].toFloat();
4774 anAngle[1] = vals[3].toFloat();
4776 QList<SUIT_ViewManager*> lst;
4777 getApp()->viewManagers(viewerTypStr, lst);
4778 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4779 if (viewIndex >= 0 && viewIndex < lst.count()) {
4780 SUIT_ViewManager* vman = lst.at(viewIndex);
4781 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4782 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4783 anOrientation, aDistance, anAngle);
4788 } // if (aSmeshActor)
4789 } // other parameters than Visibility
4791 } // for names/parameters iterator
4792 } // for entries iterator
4794 // update all VTK views
4795 QList<SUIT_ViewManager*> lst;
4796 getApp()->viewManagers(lst);
4797 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4798 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4799 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4800 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4801 vtkView->getRenderer()->ResetCameraClippingRange();
4808 \brief Adds preferences for dfont of VTK viewer
4810 \param pIf group identifier
4811 \param param parameter
4812 \return identifier of preferences
4814 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4816 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4818 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4821 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4822 fam.append( tr( "SMESH_FONT_COURIER" ) );
4823 fam.append( tr( "SMESH_FONT_TIMES" ) );
4825 setPreferenceProperty( tfont, "fonts", fam );
4827 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4828 setPreferenceProperty( tfont, "features", f );
4834 \brief Actions after hypothesis edition
4835 Updates object browser after hypothesis edition
4837 void SMESHGUI::onHypothesisEdit( int result )
4839 updateObjBrowser( true );