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_TransparencyDlg.h"
73 #include "SMESHGUI_WhatIsDlg.h"
75 #include "SMESHGUI_Utils.h"
76 #include "SMESHGUI_MeshUtils.h"
77 #include "SMESHGUI_GroupUtils.h"
78 #include "SMESHGUI_FilterUtils.h"
79 #include "SMESHGUI_PatternUtils.h"
80 #include "SMESHGUI_VTKUtils.h"
81 #include "SMESHGUI_HypothesesUtils.h"
83 #include <SMESH_Client.hxx>
84 #include <SMESH_Actor.h>
85 #include <SMESH_TypeFilter.hxx>
87 // SALOME GUI includes
88 #include <SalomeApp_Tools.h>
89 #include <SalomeApp_Study.h>
90 #include <SalomeApp_Application.h>
91 #include <SalomeApp_CheckFileDlg.h>
93 #include <LightApp_DataOwner.h>
94 #include <LightApp_Preferences.h>
95 #include <LightApp_SelectionMgr.h>
96 #include <LightApp_UpdateFlags.h>
97 #include <LightApp_NameDlg.h>
99 #include <SVTK_ViewWindow.h>
100 #include <SVTK_ViewModel.h>
101 #include <SVTK_ViewManager.h>
103 #include <VTKViewer_Algorithm.h>
105 #include <SUIT_MessageBox.h>
106 #include <SUIT_ResourceMgr.h>
107 #include <SUIT_FileDlg.h>
108 #include <SUIT_Desktop.h>
109 #include <SUIT_OverrideCursor.h>
110 #include <SUIT_Session.h>
112 #include <QtxPopupMgr.h>
113 #include <QtxFontEdit.h>
115 #include <SALOME_ListIO.hxx>
116 #include <SALOME_ListIteratorOfListIO.hxx>
119 #include <SALOMEconfig.h>
120 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
121 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
124 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
128 #include <boost/shared_ptr.hpp>
131 #include <vtkScalarBarActor.h>
132 #include <vtkCamera.h>
133 #include <vtkRenderer.h>
134 #include <vtkPlane.h>
136 // SALOME KERNEL includes
137 #include <SALOMEDS_Study.hxx>
138 #include <SALOMEDSClient_StudyBuilder.hxx>
139 #include <SALOMEDSClient_SComponent.hxx>
140 #include <SALOMEDSClient_ClientFactory.hxx>
141 #include <SALOMEDSClient_IParameters.hxx>
144 #include <Standard_ErrorHandler.hxx>
145 #include <NCollection_DataMap.hxx>
149 //=============================================================
150 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
153 void ExportMeshToFile(int theCommandID);
155 void SetDisplayMode(int theCommandID);
157 void SetDisplayEntity(int theCommandID);
159 void Control( int theCommandID );
163 //=============================================================
164 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
168 std::string myExtension;
170 if ( theCommandID == 113 ) {
171 filter.append( QObject::tr( "MED files (*.med)" ) );
172 filter.append( QObject::tr( "All files (*)" ) );
174 else if ( theCommandID == 112 ) {
175 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
177 else if ( theCommandID == 111 ) {
178 filter.append( QObject::tr( "DAT files (*.dat)" ) );
181 QString anInitialPath = "";
182 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
183 anInitialPath = QDir::currentPath();
185 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
188 QObject::tr( "SMESH_IMPORT_MESH" ) );
189 if ( filenames.count() > 0 ) {
190 SUIT_OverrideCursor wc;
191 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
194 bool isEmpty = false;
195 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
196 QString filename = *it;
197 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
199 switch ( theCommandID ) {
202 // DAT format (currently unsupported)
203 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
204 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
210 aMeshes->length( 1 );
211 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
212 if ( aMeshes[0]->_is_nil() )
213 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
214 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
220 SMESH::DriverMED_ReadStatus res;
221 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
222 if ( res != SMESH::DRS_OK ) {
223 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
224 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
230 catch ( const SALOME::SALOME_Exception& S_ex ) {
231 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
232 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
235 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
236 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
238 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
239 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
240 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
241 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
242 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
250 // update Object browser
251 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
253 // show Error message box if there were errors
254 if ( errors.count() > 0 ) {
255 SUIT_MessageBox::critical( SMESHGUI::desktop(),
256 QObject::tr( "SMESH_ERROR" ),
257 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
260 // show warning message box, if some imported mesh is empty
262 SUIT_MessageBox::warning( SMESHGUI::desktop(),
263 QObject::tr( "SMESH_WRN_WARNING" ),
264 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
269 void ExportMeshToFile( int theCommandID )
271 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
272 SALOME_ListIO selected;
274 aSel->selectedObjects( selected );
276 // actually, the following condition can't be met (added for insurance)
277 if( selected.Extent() == 0 ||
278 selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 )
281 bool hasDuplicatedMeshNames = false;
282 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
283 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
284 SALOME_ListIteratorOfListIO It( selected );
285 for( ; It.More(); It.Next() ) {
286 Handle(SALOME_InteractiveObject) anIObject = It.Value();
287 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
288 if ( aMeshItem->_is_nil() ) {
289 SUIT_MessageBox::warning( SMESHGUI::desktop(),
290 QObject::tr( "SMESH_WRN_WARNING" ),
291 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
295 QString aMeshName = anIObject->getName();
297 // check for duplications
298 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
299 if( aMeshName == (*aMeshIter).second ) {
300 hasDuplicatedMeshNames = true;
305 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
308 if( hasDuplicatedMeshNames ) {
309 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
310 QObject::tr("SMESH_WRN_WARNING"),
311 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
312 QObject::tr("SMESH_BUT_YES"),
313 QObject::tr("SMESH_BUT_NO"), 0, 1);
318 aMeshIter = aMeshList.begin();
319 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
320 QString aMeshName = (*aMeshIter).second;
322 QList<SALOMEDS::Color> aReservedColors;
324 QString aFilter, aTitle = QObject::tr("Export mesh");
325 QMap<QString, SMESH::MED_VERSION> aFilterMap;
326 QMap<QString, int> aFilterMapSTL;
327 switch ( theCommandID ) {
331 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
332 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
333 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
334 int aRet = SUIT_MessageBox::warning
335 (SMESHGUI::desktop(),
336 QObject::tr("SMESH_WRN_WARNING"),
337 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
338 QObject::tr("SMESH_BUT_YES"),
339 QObject::tr("SMESH_BUT_NO"), 0, 1);
345 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
346 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
347 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
348 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
353 aFilter = QObject::tr("DAT files (*.dat)");
358 if (aMesh->NbPyramids()) {
359 int aRet = SUIT_MessageBox::warning
360 (SMESHGUI::desktop(),
361 QObject::tr("SMESH_WRN_WARNING"),
362 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
363 QObject::tr("SMESH_BUT_YES"),
364 QObject::tr("SMESH_BUT_NO"), 0, 1);
368 aFilter = QObject::tr("IDEAS files (*.unv)");
376 there must be check on others mesh elements not equal triangles
378 if (aMesh->NbTriangles() < 1) {
379 SUIT_MessageBox::warning
380 (SMESHGUI::desktop(),
381 QObject::tr("SMESH_WRN_WARNING"),
382 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
385 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
386 int aRet = SUIT_MessageBox::warning
387 (SMESHGUI::desktop(),
388 QObject::tr("SMESH_WRN_WARNING"),
389 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
390 QObject::tr("SMESH_BUT_YES"),
391 QObject::tr("SMESH_BUT_NO"), 0, 1);
396 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
397 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
405 SMESH::MED_VERSION aFormat;
406 // Init the parameter with the default value
407 bool aIsASCII_STL = true;
408 bool toCreateGroups = false;
409 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
411 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
412 bool toOverwrite = true;
414 QString anInitialPath = "";
415 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
416 anInitialPath = QDir::currentPath();
418 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
419 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
420 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
421 aFilter, aTitle, false);
423 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
425 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
426 for ( ; it != aFilterMapSTL.end(); ++it )
427 filters.push_back( it.key() );
429 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
430 fd->setWindowTitle( aTitle );
431 fd->setFilters( filters );
432 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
433 if ( !anInitialPath.isEmpty() )
434 fd->setDirectory( anInitialPath );
435 fd->selectFile(aMeshName);
439 aFilename = fd->selectedFile();
440 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
445 else { // Export to MED
447 QString aDefaultFilter;
448 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
449 for ( ; it != aFilterMap.end(); ++it ) {
450 filters.push_back( it.key() );
451 if (it.value() == SMESH::MED_V2_2)
452 aDefaultFilter = it.key();
455 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
456 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
457 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
458 fd->setWindowTitle( aTitle );
459 fd->setFilters( filters );
460 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
461 fd->selectFilter(aDefaultFilter);
462 fd->SetChecked(toCreateGroups);
463 if ( !anInitialPath.isEmpty() )
464 fd->setDirectory( anInitialPath );
465 fd->selectFile(aMeshName);
467 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
468 fd->setValidator( fv );
473 aFilename = fd->selectedFile();
475 aFilename = QString::null;
478 aFormat = aFilterMap[fd->selectedFilter()];
479 toOverwrite = fv->isOverwrite();
481 if ( !aFilename.isEmpty() ) {
482 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
483 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
484 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
485 && aFormat==SMESH::MED_V2_1) {
486 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
487 QObject::tr("SMESH_WRN_WARNING"),
488 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
489 QObject::tr("SMESH_BUT_YES"),
490 QObject::tr("SMESH_BUT_NO"), 0, 1);
498 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
499 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
500 if( !isVersionOk || aVersion != aFormat ) {
501 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
502 QObject::tr("SMESH_WRN_WARNING"),
503 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
504 QObject::tr("SMESH_BUT_YES"),
505 QObject::tr("SMESH_BUT_NO"), 0, 1);
512 QStringList aMeshNamesCollisionList;
513 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
514 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
515 QString anExistingMeshName( aMeshNames[ i ] );
516 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
517 QString anExportMeshName = (*aMeshIter).second;
518 if( anExportMeshName == anExistingMeshName ) {
519 aMeshNamesCollisionList.append( anExportMeshName );
525 if( !aMeshNamesCollisionList.isEmpty() ) {
526 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
527 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
528 QObject::tr("SMESH_WRN_WARNING"),
529 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
530 QObject::tr("SMESH_BUT_YES"),
531 QObject::tr("SMESH_BUT_NO"),
532 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
541 toCreateGroups = fd->IsChecked();
544 if ( !aFilename.isEmpty() ) {
545 // Check whether the file already exists and delete it if yes
546 QFile aFile( aFilename );
547 if ( aFile.exists() && toOverwrite )
549 SUIT_OverrideCursor wc;
552 bool Renumber = false;
553 // PAL 14172 : Check of we have to renumber or not from the preferences before export
555 Renumber= resMgr->booleanValue("SMESH","renumbering");
557 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
558 aMeshEditor->RenumberNodes();
559 aMeshEditor->RenumberElements();
560 if ( SMESHGUI::automaticUpdate() )
563 switch ( theCommandID ) {
567 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
568 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
569 if( !aMeshItem->_is_nil() )
570 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
576 aMesh->ExportDAT( aFilename.toLatin1().data() );
580 aMesh->ExportUNV( aFilename.toLatin1().data() );
584 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
590 catch (const SALOME::SALOME_Exception& S_ex){
592 SUIT_MessageBox::warning(SMESHGUI::desktop(),
593 QObject::tr("SMESH_WRN_WARNING"),
594 QObject::tr("SMESH_EXPORT_FAILED"));
600 inline void InverseEntityMode(unsigned int& theOutputMode,
601 unsigned int theMode)
603 bool anIsNotPresent = ~theOutputMode & theMode;
605 theOutputMode |= theMode;
607 theOutputMode &= ~theMode;
610 void SetDisplayEntity(int theCommandID){
611 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
612 SALOME_ListIO selected;
614 aSel->selectedObjects( selected );
616 if(selected.Extent() >= 1){
617 SALOME_ListIteratorOfListIO It( selected );
618 for( ; It.More(); It.Next()){
619 Handle(SALOME_InteractiveObject) IObject = It.Value();
620 if(IObject->hasEntry()){
621 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
622 unsigned int aMode = anActor->GetEntityMode();
623 switch(theCommandID){
625 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
628 InverseEntityMode(aMode,SMESH_Actor::eEdges);
631 InverseEntityMode(aMode,SMESH_Actor::eFaces);
634 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
637 aMode = SMESH_Actor::eAllEntity;
641 anActor->SetEntityMode(aMode);
649 SALOME_ListIO selected;
650 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
654 LightApp_SelectionMgr* aSel = app->selectionMgr();
655 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
656 if( !aSel || !appStudy )
659 aSel->selectedObjects( selected );
660 if( selected.IsEmpty() )
663 Handle(SALOME_InteractiveObject) anIObject = selected.First();
665 _PTR(Study) aStudy = appStudy->studyDS();
666 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
667 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
668 if( aMainObject->_is_nil() )
671 aMainObject->SetAutoColor( true );
673 QList<SALOMEDS::Color> aReservedColors;
675 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
676 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
678 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
679 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
681 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
682 aGroupObject->SetColor( aColor );
683 aReservedColors.append( aColor );
685 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
686 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
688 if( aGroupObject->GetType() == SMESH::NODE )
689 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
690 else if( aGroupObject->GetType() == SMESH::EDGE )
691 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
693 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
697 SMESH::RepaintCurrentView();
700 void DisableAutoColor(){
701 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
702 SALOME_ListIO selected;
704 aSel->selectedObjects( selected );
706 if(selected.Extent()){
707 Handle(SALOME_InteractiveObject) anIObject = selected.First();
708 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
709 if ( !aMesh->_is_nil() ) {
710 aMesh->SetAutoColor( false );
715 void SetDisplayMode(int theCommandID){
716 SALOME_ListIO selected;
717 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
721 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
722 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
723 if( !aSel || !appStudy )
726 _PTR(Study) aStudy = appStudy->studyDS();
728 aSel->selectedObjects( selected );
730 if(selected.Extent() >= 1){
731 switch(theCommandID){
733 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
734 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
738 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
739 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
742 SALOME_ListIteratorOfListIO It( selected );
743 for( ; It.More(); It.Next()){
744 Handle(SALOME_InteractiveObject) IObject = It.Value();
745 if(IObject->hasEntry()){
746 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
747 switch(theCommandID){
749 anActor->SetRepresentation(SMESH_Actor::eEdge);
752 anActor->SetRepresentation(SMESH_Actor::eSurface);
755 if(anActor->IsShrunk())
758 anActor->SetShrink();
761 anActor->SetRepresentation(SMESH_Actor::ePoint);
764 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
765 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
768 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
769 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
772 vtkFloatingPointType color[3];
773 anActor->GetSufaceColor(color[0], color[1], color[2]);
774 int c0 = int (color[0] * 255);
775 int c1 = int (color[1] * 255);
776 int c2 = int (color[2] * 255);
777 QColor c(c0, c1, c2);
779 vtkFloatingPointType edgecolor[3];
780 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
781 c0 = int (edgecolor[0] * 255);
782 c1 = int (edgecolor[1] * 255);
783 c2 = int (edgecolor[2] * 255);
784 QColor e(c0, c1, c2);
786 vtkFloatingPointType backfacecolor[3];
787 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
788 c0 = int (backfacecolor[0] * 255);
789 c1 = int (backfacecolor[1] * 255);
790 c2 = int (backfacecolor[2] * 255);
791 QColor b(c0, c1, c2);
793 vtkFloatingPointType nodecolor[3];
794 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
795 c0 = int (nodecolor[0] * 255);
796 c1 = int (nodecolor[1] * 255);
797 c2 = int (nodecolor[2] * 255);
798 QColor n(c0, c1, c2);
800 vtkFloatingPointType color0D[3];
801 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
802 c0 = int (color0D[0] * 255);
803 c1 = int (color0D[1] * 255);
804 c2 = int (color0D[2] * 255);
805 QColor c0D(c0, c1, c2);
807 int size0D = (int)anActor->Get0DSize();
810 int Edgewidth = (int)anActor->GetLineWidth();
813 int intValue = int(anActor->GetNodeSize());
814 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
816 vtkFloatingPointType faces_orientation_color[3];
817 anActor->GetFacesOrientationColor(faces_orientation_color);
818 c0 = int (faces_orientation_color[0] * 255);
819 c1 = int (faces_orientation_color[1] * 255);
820 c2 = int (faces_orientation_color[2] * 255);
821 QColor o(c0, c1, c2);
823 vtkFloatingPointType faces_orientation_scale = anActor->GetFacesOrientationScale();
824 bool faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
826 SMESHGUI_Preferences_ColorDlg *aDlg =
827 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
828 aDlg->SetColor(1, c);
829 aDlg->SetColor(2, e);
830 aDlg->SetColor(3, n);
831 aDlg->SetColor(4, b);
832 aDlg->SetColor(5, c0D);
833 aDlg->SetColor(6, o);
834 aDlg->SetIntValue(1, Edgewidth);
835 aDlg->SetIntValue(2, intValue);
836 aDlg->SetIntValue(3, int(Shrink*100.));
837 aDlg->SetIntValue(4, size0D);
838 aDlg->SetDoubleValue(1, faces_orientation_scale);
839 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
841 QColor color = aDlg->GetColor(1);
842 QColor edgecolor = aDlg->GetColor(2);
843 QColor nodecolor = aDlg->GetColor(3);
844 QColor backfacecolor = aDlg->GetColor(4);
845 QColor color0D = aDlg->GetColor(5);
846 QColor faces_orientation_color = aDlg->GetColor(6);
847 /* actor color and backface color */
848 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
849 vtkFloatingPointType (color.green()) / 255.,
850 vtkFloatingPointType (color.blue()) / 255.);
851 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
852 vtkFloatingPointType (backfacecolor.green()) / 255.,
853 vtkFloatingPointType (backfacecolor.blue()) / 255.);
856 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
857 vtkFloatingPointType (edgecolor.green()) / 255.,
858 vtkFloatingPointType (edgecolor.blue()) / 255.);
860 /* Shrink factor and size edges */
861 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
862 anActor->SetLineWidth(aDlg->GetIntValue(1));
864 /* Nodes color and size */
865 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
866 vtkFloatingPointType (nodecolor.green()) / 255.,
867 vtkFloatingPointType (nodecolor.blue()) / 255.);
868 anActor->SetNodeSize(aDlg->GetIntValue(2));
871 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
872 vtkFloatingPointType (color0D.green()) / 255.,
873 vtkFloatingPointType (color0D.blue()) / 255.);
874 anActor->Set0DSize(aDlg->GetIntValue(4));
876 /* Faces orientation */
877 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
878 vtkFloatingPointType(faces_orientation_color.greenF()),
879 vtkFloatingPointType(faces_orientation_color.blueF())};
880 anActor->SetFacesOrientationColor(c);
881 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
882 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
884 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
885 if( !aGroupObject->_is_nil() )
887 SMESH::ElementType anElementType = aGroupObject->GetType();
889 switch( anElementType )
891 case SMESH::NODE: aColor = nodecolor; break;
892 case SMESH::EDGE: aColor = edgecolor; break;
893 default: aColor = color; break;
896 SALOMEDS::Color aGroupColor;
897 aGroupColor.R = (float)aColor.red() / 255.0;
898 aGroupColor.G = (float)aColor.green() / 255.0;
899 aGroupColor.B = (float)aColor.blue() / 255.0;
900 aGroupObject->SetColor( aGroupColor );
910 SMESH::RepaintCurrentView();
914 void Control( int theCommandID )
916 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
917 SALOME_ListIO selected;
919 aSel->selectedObjects( selected );
921 if( !selected.IsEmpty() ){
922 Handle(SALOME_InteractiveObject) anIO = selected.First();
925 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
926 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
927 switch ( theCommandID ){
929 aTitle = QObject::tr( "LENGTH_EDGES" );
930 aControl = SMESH_Actor::eLength;
933 aTitle = QObject::tr( "LENGTH2D_EDGES" );
934 aControl = SMESH_Actor::eLength2D;
937 aTitle = QObject::tr( "FREE_EDGES" );
938 aControl = SMESH_Actor::eFreeEdges;
941 aTitle = QObject::tr( "FREE_BORDERS" );
942 aControl = SMESH_Actor::eFreeBorders;
945 aTitle = QObject::tr( "MULTI_BORDERS" );
946 aControl = SMESH_Actor::eMultiConnection;
949 aTitle = QObject::tr( "FREE_NODES" );
950 aControl = SMESH_Actor::eFreeNodes;
953 aTitle = QObject::tr( "MULTI2D_BORDERS" );
954 aControl = SMESH_Actor::eMultiConnection2D;
957 aTitle = QObject::tr( "AREA_ELEMENTS" );
958 aControl = SMESH_Actor::eArea;
961 aTitle = QObject::tr( "TAPER_ELEMENTS" );
962 aControl = SMESH_Actor::eTaper;
965 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
966 aControl = SMESH_Actor::eAspectRatio;
969 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
970 aControl = SMESH_Actor::eAspectRatio3D;
973 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
974 aControl = SMESH_Actor::eMinimumAngle;
977 aTitle = QObject::tr( "WARP_ELEMENTS" );
978 aControl = SMESH_Actor::eWarping;
981 aTitle = QObject::tr( "SKEW_ELEMENTS" );
982 aControl = SMESH_Actor::eSkew;
985 aTitle = QObject::tr( "SMESH_VOLUME" );
986 aControl = SMESH_Actor::eVolume3D;
989 aTitle = QObject::tr( "FREE_FACES" );
990 aControl = SMESH_Actor::eFreeFaces;
993 anActor->SetControlMode(aControl);
994 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
995 SMESH::RepaintCurrentView();
1002 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1003 MeshObjectType theType,
1004 const QString theInTypeName,
1005 QString & theOutTypeName)
1007 SMESH_TypeFilter aTypeFilter( theType );
1009 if( !theIO.IsNull() )
1011 entry = theIO->getEntry();
1012 LightApp_DataOwner owner( entry );
1013 if ( aTypeFilter.isOk( &owner )) {
1014 theOutTypeName = theInTypeName;
1022 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1024 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1025 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1027 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1028 CORBA::String_var anID = aSComp->GetID().c_str();
1029 if (!strcmp(anID.in(),theIO->getEntry()))
1035 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1036 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1037 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1038 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1039 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1047 QString CheckHomogeneousSelection()
1049 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1050 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1051 SALOME_ListIO selected;
1053 aSel->selectedObjects( selected );
1055 QString RefType = CheckTypeObject(selected.First());
1056 SALOME_ListIteratorOfListIO It(selected);
1057 for ( ; It.More(); It.Next())
1059 Handle(SALOME_InteractiveObject) IObject = It.Value();
1060 QString Type = CheckTypeObject(IObject);
1061 if (Type.compare(RefType) != 0)
1062 return "Heterogeneous Selection";
1069 void SMESHGUI::OnEditDelete()
1071 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1072 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1073 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1075 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1076 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1077 _PTR(GenericAttribute) anAttr;
1078 _PTR(AttributeIOR) anIOR;
1080 int objectCount = 0;
1082 QString aParentComponent = QString::null;
1083 Handle(SALOME_InteractiveObject) anIO;
1084 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1086 anIO = anIt.Value();
1087 QString cur = anIO->getComponentDataType();
1088 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1090 // check if object is reference
1091 _PTR(SObject) aRefSObj;
1092 aNameList.append("\n - ");
1093 if ( aSO->ReferencedObject( aRefSObj ) ) {
1094 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1095 aNameList.append( aRefName );
1096 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1099 aNameList.append(anIO->getName());
1103 if( aParentComponent.isNull() )
1104 aParentComponent = cur;
1105 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1106 aParentComponent = "";
1109 if ( objectCount == 0 )
1110 return; // No Valid Objects Selected
1112 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1113 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1114 QObject::tr("ERR_ERROR"),
1115 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1118 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1119 if (SUIT_MessageBox::warning
1120 (SMESHGUI::desktop(),
1121 QObject::tr("SMESH_WRN_WARNING"),
1122 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1123 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1124 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1127 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1128 SUIT_ViewManager* vm = anApp->activeViewManager();
1129 int nbSf = vm->getViewsCount();
1131 SALOME_ListIteratorOfListIO It(selected);
1133 aStudyBuilder->NewCommand(); // There is a transaction
1134 for( ; It.More(); It.Next()){ // loop on selected IO's
1135 Handle(SALOME_InteractiveObject) IObject = It.Value();
1136 if(IObject->hasEntry()) {
1137 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1139 // disable removal of "SMESH" component object
1140 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1142 if ( engineIOR() == anIOR->Value().c_str() )
1145 //Check the referenced object
1146 _PTR(SObject) aRefSObject;
1147 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1148 aSO = aRefSObject; // Delete main Object instead of reference
1150 // put the whole hierarchy of sub-objects of the selected SO into a list and
1151 // then treat them all starting from the deepest objects (at list back)
1153 std::list< _PTR(SObject) > listSO;
1154 listSO.push_back( aSO );
1155 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1156 for ( ; itSO != listSO.end(); ++itSO ) {
1157 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1158 for (it->InitEx(false); it->More(); it->Next())
1159 listSO.push_back( it->Value() );
1162 // treat SO's in the list starting from the back
1164 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1165 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1166 _PTR(SObject) SO = *ritSO;
1167 if ( !SO ) continue;
1168 std::string anEntry = SO->GetID();
1170 /** Erase graphical object **/
1171 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1172 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1173 for(int i = 0; i < nbSf; i++){
1174 SUIT_ViewWindow *sf = aViews[i];
1175 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1176 SMESH::RemoveActor(sf,anActor);
1181 /** Remove an object from data structures **/
1182 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1183 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1184 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1185 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1186 aMesh->RemoveGroup( aGroup );
1188 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1189 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1190 aMesh->RemoveSubMesh( aSubMesh );
1192 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1194 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1197 IObject = new SALOME_InteractiveObject
1198 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1199 QString objType = CheckTypeObject(IObject);
1200 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1201 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1202 aStudyBuilder->RemoveObjectWithChildren( SO );
1204 else {// default action: remove SObject from the study
1205 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1206 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1208 aStudyBuilder->RemoveObjectWithChildren( SO );
1212 } /* listSO back loop */
1213 } /* IObject->hasEntry() */
1215 aStudyBuilder->CommitCommand();
1217 /* Clear any previous selection */
1219 aSel->setSelectedObjects( l1 );
1221 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1226 SMESHGUI_EXPORT CAM_Module* createModule()
1228 return new SMESHGUI();
1232 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1234 //=============================================================================
1238 //=============================================================================
1239 SMESHGUI::SMESHGUI() :
1240 SalomeApp_Module( "SMESH" ),
1241 LightApp_Module( "SMESH" )
1243 if ( CORBA::is_nil( myComponentSMESH ) )
1245 CORBA::Boolean anIsEmbeddedMode;
1246 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1248 // 0019923: EDF 765 SMESH : default values of hypothesis
1249 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1250 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1251 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1252 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1253 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1256 myActiveDialogBox = 0;
1257 myFilterLibraryDlg = 0;
1261 SMESH::GetFilterManager();
1262 SMESH::GetPattern();
1264 /* load resources for all available meshers */
1265 SMESH::InitAvailableHypotheses();
1268 //=============================================================================
1272 //=============================================================================
1273 SMESHGUI::~SMESHGUI()
1275 SMESH::GetFilterManager()->Destroy();
1276 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1279 //=============================================================================
1283 //=============================================================================
1284 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1286 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1288 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1293 bool SMESHGUI::automaticUpdate()
1295 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1299 return resMgr->booleanValue( "SMESH", "auto_update", false );
1302 //=============================================================================
1306 //=============================================================================
1307 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1309 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1312 //=============================================================================
1316 //=============================================================================
1317 SMESHGUI* SMESHGUI::GetSMESHGUI()
1319 SMESHGUI* smeshMod = 0;
1320 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1323 CAM_Module* module = app->module( "Mesh" );
1324 smeshMod = dynamic_cast<SMESHGUI*>( module );
1327 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1329 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1332 _PTR(Study) aStudy = study->studyDS();
1334 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1343 Standard_EXPORT SMESHGUI* GetComponentGUI()
1345 return SMESHGUI::GetSMESHGUI();
1349 //=============================================================================
1353 //=============================================================================
1354 void SMESHGUI::SetState(int aState)
1359 //=============================================================================
1363 //=============================================================================
1364 void SMESHGUI::ResetState()
1369 //=============================================================================
1373 //=============================================================================
1374 void SMESHGUI::EmitSignalDeactivateDialog()
1376 emit SignalDeactivateActiveDialog();
1379 //=============================================================================
1383 //=============================================================================
1384 void SMESHGUI::EmitSignalStudyFrameChanged()
1386 emit SignalStudyFrameChanged();
1389 //=============================================================================
1393 //=============================================================================
1394 void SMESHGUI::EmitSignalCloseAllDialogs()
1396 emit SignalCloseAllDialogs();
1399 //=============================================================================
1403 //=============================================================================
1404 void SMESHGUI::EmitSignalVisibilityChanged()
1406 emit SignalVisibilityChanged();
1409 //=============================================================================
1413 //=============================================================================
1414 QDialog *SMESHGUI::GetActiveDialogBox()
1416 return myActiveDialogBox;
1419 //=============================================================================
1423 //=============================================================================
1424 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1426 myActiveDialogBox = (QDialog *) aDlg;
1430 //=============================================================================
1434 //=============================================================================
1435 SUIT_Desktop* SMESHGUI::desktop()
1437 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1439 return app->desktop();
1444 //=============================================================================
1448 //=============================================================================
1449 SalomeApp_Study* SMESHGUI::activeStudy()
1451 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1453 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1458 //=============================================================================
1462 //=============================================================================
1463 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1465 /* Here the position is on the bottom right corner - 10 */
1466 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1468 SUIT_Desktop *PP = desktop();
1469 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1470 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1474 //=============================================================================
1478 //=============================================================================
1479 static int isStudyLocked(_PTR(Study) theStudy){
1480 return theStudy->GetProperties()->IsLocked();
1483 static bool checkLock(_PTR(Study) theStudy) {
1484 if (isStudyLocked(theStudy)) {
1485 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1486 QObject::tr("WRN_WARNING"),
1487 QObject::tr("WRN_STUDY_LOCKED") );
1493 //=======================================================================
1494 //function : CheckActiveStudyLocked
1496 //=======================================================================
1498 bool SMESHGUI::isActiveStudyLocked()
1500 _PTR(Study) aStudy = activeStudy()->studyDS();
1501 return checkLock( aStudy );
1504 //=============================================================================
1508 //=============================================================================
1509 bool SMESHGUI::OnGUIEvent( int theCommandID )
1511 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1515 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1516 SUIT_ResourceMgr* mgr = resourceMgr();
1520 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1521 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1524 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1525 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1527 //QAction* act = action( theCommandID );
1529 switch (theCommandID) {
1531 if(checkLock(aStudy)) break;
1539 if(checkLock(aStudy)) break;
1540 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1544 case 150: //MED FILE INFORMATION
1546 SALOME_ListIO selected;
1547 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1549 aSel->selectedObjects( selected );
1550 if( selected.Extent() )
1552 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1553 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1554 if ( !aMesh->_is_nil() )
1556 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1563 case 122: // EXPORT MED
1572 ::ExportMeshToFile(theCommandID);
1576 case 200: // SCALAR BAR
1578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1579 SALOME_ListIO selected;
1581 aSel->selectedObjects( selected );
1583 if( selected.Extent() ) {
1584 Handle(SALOME_InteractiveObject) anIO = selected.First();
1585 if( anIO->hasEntry() ) {
1586 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1587 anActor->SetControlMode( SMESH_Actor::eNone );
1595 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1605 ::DisableAutoColor();
1608 case 1134: // Clipping
1609 case 1133: // Tranparency
1610 case 1132: // Colors / Size
1617 ::SetDisplayMode(theCommandID);
1620 //2D quadratic representation
1623 ::SetDisplayMode(theCommandID);
1627 case 216: // 0D elements
1630 case 219: // Volumes
1631 case 220: // All Entity
1632 ::SetDisplayEntity(theCommandID);
1635 case 221: // Orientation of faces
1637 LightApp_SelectionMgr* mgr = selectionMgr();
1638 SALOME_ListIO selected; mgr->selectedObjects( selected );
1640 SALOME_ListIteratorOfListIO it(selected);
1641 for( ; it.More(); it.Next()) {
1642 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1643 if(anIObject->hasEntry()) {
1644 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1645 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1654 if(checkLock(aStudy)) break;
1656 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1659 SMESH::UpdateView();
1661 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1662 SMESH::OnVisuException();
1664 catch (...) { // PAL16774 (Crash after display of many groups)
1665 SMESH::OnVisuException();
1669 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1670 aSel->selectedObjects( l );
1671 aSel->setSelectedObjects( l );
1676 case 301: // DISPLAY
1677 case 302: // DISPLAY ONLY
1679 SMESH::EDisplaing anAction;
1680 switch (theCommandID) {
1681 case 300: anAction = SMESH::eErase; break;
1682 case 301: anAction = SMESH::eDisplay; break;
1683 case 302: anAction = SMESH::eDisplayOnly; break;
1686 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1687 SALOME_ListIO sel_objects, to_process;
1689 aSel->selectedObjects( sel_objects );
1691 if( theCommandID==302 )
1692 startOperation( myEraseAll );
1694 extractContainers( sel_objects, to_process );
1697 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1701 SALOME_ListIteratorOfListIO It( to_process );
1702 for ( ; It.More(); It.Next()) {
1703 Handle(SALOME_InteractiveObject) IOS = It.Value();
1704 if (IOS->hasEntry()) {
1705 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1706 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1707 break; // PAL16774 (Crash after display of many groups)
1709 if (anAction == SMESH::eDisplayOnly)
1710 anAction = SMESH::eDisplay;
1715 // PAL13338 + PAL15161 -->
1716 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1717 SMESH::UpdateView();
1718 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1720 // PAL13338 + PAL15161 <--
1722 catch (...) { // PAL16774 (Crash after display of many groups)
1723 SMESH::OnVisuException();
1726 if (anAction == SMESH::eErase) {
1728 aSel->setSelectedObjects( l1 );
1731 aSel->setSelectedObjects( to_process );
1738 if(checkLock(aStudy)) break;
1741 EmitSignalDeactivateDialog();
1743 ( new SMESHGUI_NodesDlg( this ) )->show();
1746 SUIT_MessageBox::warning(desktop(),
1747 tr("SMESH_WRN_WARNING"),
1748 tr("SMESH_WRN_VIEWER_VTK"));
1753 case 2151: // FILTER
1757 EmitSignalDeactivateDialog();
1758 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1763 case 406: // MOVE NODE
1767 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1768 tr( "NOT_A_VTK_VIEWER" ) );
1772 if(checkLock(aStudy)) break;
1773 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1777 case 701: // COMPUTE MESH
1778 case 711: // PRECOMPUTE MESH
1779 case 712: // EVALUATE MESH
1780 case 713: // MESH ORDER
1782 if (checkLock(aStudy)) break;
1783 startOperation( theCommandID );
1787 case 702: // Create mesh
1788 case 703: // Create sub-mesh
1789 case 704: // Edit mesh/sub-mesh
1790 startOperation( theCommandID );
1792 case 710: // Build compound mesh
1794 if (checkLock(aStudy)) break;
1795 EmitSignalDeactivateDialog();
1796 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1800 case 407: // DIAGONAL INVERSION
1801 case 408: // Delete diagonal
1805 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1806 tr( "NOT_A_VTK_VIEWER" ) );
1810 if ( checkLock( aStudy ) )
1813 /*Standard_Boolean aRes;
1814 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1815 if ( aMesh->_is_nil() )
1817 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1818 tr( "SMESH_BAD_SELECTION" ) );
1822 EmitSignalDeactivateDialog();
1823 if ( theCommandID == 407 )
1824 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1826 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1829 case 409: // Change orientation
1830 case 410: // Union of triangles
1831 case 411: // Cutting of quadrangles
1835 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1836 tr( "NOT_A_VTK_VIEWER" ) );
1840 if ( checkLock( aStudy ) )
1843 EmitSignalDeactivateDialog();
1844 SMESHGUI_MultiEditDlg* aDlg = NULL;
1845 if ( theCommandID == 409 )
1846 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1847 else if ( theCommandID == 410 )
1848 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1850 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1855 case 412: // Smoothing
1857 if(checkLock(aStudy)) break;
1859 EmitSignalDeactivateDialog();
1860 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1863 SUIT_MessageBox::warning(desktop(),
1864 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1868 case 413: // Extrusion
1870 if (checkLock(aStudy)) break;
1872 EmitSignalDeactivateDialog();
1873 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1875 SUIT_MessageBox::warning(desktop(),
1876 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1880 case 414: // Revolution
1882 if(checkLock(aStudy)) break;
1884 EmitSignalDeactivateDialog();
1885 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1888 SUIT_MessageBox::warning(desktop(),
1889 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1893 case 415: // Pattern mapping
1895 if ( checkLock( aStudy ) )
1899 EmitSignalDeactivateDialog();
1900 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1903 SUIT_MessageBox::warning(desktop(),
1904 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1908 case 416: // Extrusion along a path
1910 if (checkLock(aStudy)) break;
1912 EmitSignalDeactivateDialog();
1913 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1915 SUIT_MessageBox::warning(desktop(),
1916 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1920 case 417: // Convert mesh to quadratic
1922 startOperation( 417 );
1923 /* if (checkLock(aStudy)) break;
1925 EmitSignalDeactivateDialog();
1926 new SMESHGUI_ConvToQuadDlg();
1928 SUIT_MessageBox::warning(desktop(),
1929 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1933 case 418: // create 2D mesh from 3D
1935 startOperation( 418 );
1938 case 806: // CREATE GEO GROUP
1940 startOperation( 806 );
1943 case 801: // CREATE GROUP
1947 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1948 tr( "NOT_A_VTK_VIEWER" ) );
1952 if(checkLock(aStudy)) break;
1953 EmitSignalDeactivateDialog();
1954 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1956 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1957 SALOME_ListIO selected;
1959 aSel->selectedObjects( selected );
1961 int nbSel = selected.Extent();
1963 // check if mesh is selected
1964 aMesh = SMESH::GetMeshByIO( selected.First() );
1966 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1971 case 802: // CONSTRUCT GROUP
1975 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1976 tr( "NOT_A_VTK_VIEWER" ) );
1980 if(checkLock(aStudy)) break;
1981 EmitSignalDeactivateDialog();
1983 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1984 SALOME_ListIO selected;
1986 aSel->selectedObjects( selected );
1988 int nbSel = selected.Extent();
1990 // check if submesh is selected
1991 Handle(SALOME_InteractiveObject) IObject = selected.First();
1992 if (IObject->hasEntry()) {
1993 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1995 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1996 if (!aSubMesh->_is_nil()) {
1998 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1999 // get submesh elements list by types
2000 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2001 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2002 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2003 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2004 // create group for each type o elements
2005 QString aName = IObject->getName();
2006 if (aNodes->length() > 0) {
2007 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2008 aGroup->Add(aNodes.inout());
2010 if (aEdges->length() > 0) {
2011 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2012 aGroup->Add(aEdges.inout());
2014 if (aFaces->length() > 0) {
2015 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2016 aGroup->Add(aFaces.inout());
2018 if (aVolumes->length() > 0) {
2019 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2020 aGroup->Add(aVolumes.inout());
2025 catch(const SALOME::SALOME_Exception & S_ex){
2026 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2033 SUIT_MessageBox::warning(desktop(),
2034 tr("SMESH_WRN_WARNING"),
2035 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2040 case 803: // EDIT GROUP
2044 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2045 tr( "NOT_A_VTK_VIEWER" ) );
2049 if(checkLock(aStudy)) break;
2050 EmitSignalDeactivateDialog();
2052 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2053 SALOME_ListIO selected;
2055 aSel->selectedObjects( selected );
2057 SALOME_ListIteratorOfListIO It (selected);
2058 int nbSelectedGroups = 0;
2059 for ( ; It.More(); It.Next() )
2061 SMESH::SMESH_GroupBase_var aGroup =
2062 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2063 if (!aGroup->_is_nil()) {
2065 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2069 if (nbSelectedGroups == 0)
2071 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2077 case 804: // Add elements to group
2079 if(checkLock(aStudy)) break;
2080 if (myState == 800) {
2081 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2082 if (aDlg) aDlg->onAdd();
2087 case 805: // Remove elements from group
2089 if(checkLock(aStudy)) break;
2090 if (myState == 800) {
2091 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2092 if (aDlg) aDlg->onRemove();
2097 case 815: // Edit GEOM GROUP as standalone
2101 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2102 tr( "NOT_A_VTK_VIEWER" ) );
2106 if(checkLock(aStudy)) break;
2107 EmitSignalDeactivateDialog();
2109 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2110 SALOME_ListIO selected;
2112 aSel->selectedObjects( selected );
2114 SALOME_ListIteratorOfListIO It (selected);
2115 for ( ; It.More(); It.Next() )
2117 SMESH::SMESH_GroupOnGeom_var aGroup =
2118 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2119 if (!aGroup->_is_nil()) {
2120 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2127 case 810: // Union Groups
2128 case 811: // Intersect groups
2129 case 812: // Cut groups
2133 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2134 tr( "NOT_A_VTK_VIEWER" ) );
2138 if ( checkLock( aStudy ) )
2141 EmitSignalDeactivateDialog();
2143 SMESHGUI_GroupOpDlg* aDlg = 0;
2144 if ( theCommandID == 810 )
2145 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2146 else if ( theCommandID == 811 )
2147 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2149 aDlg = new SMESHGUI_CutGroupsDlg( this );
2156 case 814: // Create groups of entities from existing groups of superior dimensions
2158 if ( checkLock( aStudy ) )
2161 EmitSignalDeactivateDialog();
2162 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2168 case 813: // Delete groups with their contents
2172 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2173 tr( "NOT_A_VTK_VIEWER" ) );
2177 if ( checkLock( aStudy ) )
2180 EmitSignalDeactivateDialog();
2182 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2186 case 900: // MESH INFOS
2188 EmitSignalDeactivateDialog();
2189 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2190 SALOME_ListIO selected;
2192 aSel->selectedObjects( selected );
2194 if ( selected.Extent() > 1 ) { // a dlg for each IO
2196 SALOME_ListIteratorOfListIO It (selected);
2197 for ( ; It.More(); It.Next() ) {
2198 IOs.Clear(); IOs.Append( It.Value() );
2199 aSel->setSelectedObjects( IOs );
2200 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2202 // restore selection
2203 aSel->setSelectedObjects( selected );
2206 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2210 case 902: // STANDARD MESH INFOS
2212 EmitSignalDeactivateDialog();
2213 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2214 SALOME_ListIO selected;
2216 aSel->selectedObjects( selected );
2218 if ( selected.Extent() > 1 ) { // a dlg for each IO
2220 SALOME_ListIteratorOfListIO It (selected);
2221 for ( ; It.More(); It.Next() ) {
2223 IOs.Append( It.Value() );
2224 aSel->setSelectedObjects( IOs );
2225 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2227 // restore selection
2228 aSel->setSelectedObjects( selected );
2231 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2235 case 903: // WHAT IS
2237 EmitSignalDeactivateDialog();
2238 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2242 case 904: // FIND ELEM
2244 startOperation( theCommandID );
2248 case 1100: // EDIT HYPOTHESIS
2250 if(checkLock(aStudy)) break;
2252 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2253 SALOME_ListIO selected;
2255 aSel->selectedObjects( selected );
2257 int nbSel = selected.Extent();
2260 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2261 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2263 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2264 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2265 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2266 if ( !aHypothesis->_is_nil() )
2269 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2270 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2272 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2283 case 1101: // RENAME
2285 if ( checkLock( aStudy ) )
2288 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2289 SALOME_ListIO selected;
2291 aSel->selectedObjects( selected );
2293 bool isAny = false; // is there any appropriate object selected
2295 SALOME_ListIteratorOfListIO It( selected );
2296 for ( ; It.More(); It.Next() )
2298 Handle(SALOME_InteractiveObject) IObject = It.Value();
2299 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2300 _PTR(GenericAttribute) anAttr;
2301 _PTR(AttributeName) aName;
2304 if ( obj->FindAttribute(anAttr, "AttributeName") )
2307 QString newName = QString(aName->Value().c_str());
2309 // check type to prevent renaming of inappropriate objects
2310 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2311 if (aType == MESH || aType == GROUP ||
2312 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2313 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2314 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2315 aType == HYPOTHESIS || aType == ALGORITHM)
2318 newName = LightApp_NameDlg::getName(desktop(), newName);
2319 if ( !newName.isEmpty() )
2321 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2323 // update name of group object and its actor
2324 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2325 if( !aGroupObject->_is_nil() )
2327 aGroupObject->SetName( newName.toLatin1().data() );
2328 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2329 anActor->setName( newName.toLatin1().data() );
2340 SUIT_MessageBox::warning(desktop(),
2341 QObject::tr("SMESH_WRN_WARNING"),
2342 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2347 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2349 if(checkLock(aStudy)) break;
2350 SUIT_OverrideCursor wc;
2352 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2353 SALOME_ListIO selected;
2355 aSel->selectedObjects( selected, QString::null, false );
2357 SALOME_ListIteratorOfListIO It(selected);
2358 for (int i = 0; It.More(); It.Next(), i++) {
2359 Handle(SALOME_InteractiveObject) IObject = It.Value();
2360 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2363 aSel->setSelectedObjects( l1 );
2368 case 4009: // ELEM0D
2369 case 4010: // GEOM::EDGE
2370 case 4021: // TRIANGLE
2372 case 4023: // POLYGON
2376 if(checkLock(aStudy)) break;
2378 EmitSignalDeactivateDialog();
2379 SMDSAbs_ElementType type = SMDSAbs_Edge;
2381 switch (theCommandID) {
2382 case 4009: // ELEM0D
2383 type = SMDSAbs_0DElement; nbNodes = 1; break;
2384 case 4021: // TRIANGLE
2385 type = SMDSAbs_Face; nbNodes = 3; break;
2387 type = SMDSAbs_Face; nbNodes = 4; break;
2389 type = SMDSAbs_Volume; nbNodes = 4; break;
2390 case 4023: // POLYGON
2391 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2393 type = SMDSAbs_Volume; nbNodes = 8; break;
2394 case 4033: // POLYHEDRE
2395 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2398 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2401 SUIT_MessageBox::warning(desktop(),
2402 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2406 case 4033: // POLYHEDRON
2408 if(checkLock(aStudy)) break;
2410 EmitSignalDeactivateDialog();
2411 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2414 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2415 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2419 case 4034: // QUADRATIC EDGE
2420 case 4035: // QUADRATIC TRIANGLE
2421 case 4036: // QUADRATIC QUADRANGLE
2422 case 4037: // QUADRATIC TETRAHEDRON
2423 case 4038: // QUADRATIC PYRAMID
2424 case 4039: // QUADRATIC PENTAHEDRON
2425 case 4040: // QUADRATIC HEXAHEDRON
2427 if(checkLock(aStudy)) break;
2429 EmitSignalDeactivateDialog();
2432 switch (theCommandID) {
2434 type = QUAD_EDGE; break;
2436 type = QUAD_TRIANGLE; break;
2438 type = QUAD_QUADRANGLE; break;
2440 type = QUAD_TETRAHEDRON; break;
2442 type = QUAD_PYRAMID; break;
2444 type = QUAD_PENTAHEDRON; break;
2446 type = QUAD_HEXAHEDRON;
2450 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2453 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2454 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2458 case 4041: // REMOVES NODES
2460 if(checkLock(aStudy)) break;
2462 EmitSignalDeactivateDialog();
2463 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2466 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2467 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2471 case 4042: // REMOVES ELEMENTS
2473 if(checkLock(aStudy)) break;
2475 EmitSignalDeactivateDialog();
2476 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2480 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2485 case 4043: { // CLEAR_MESH
2487 if(checkLock(aStudy)) break;
2489 SALOME_ListIO selected;
2490 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2491 aSel->selectedObjects( selected );
2493 SUIT_OverrideCursor wc;
2494 SALOME_ListIteratorOfListIO It (selected);
2495 for ( ; It.More(); It.Next() )
2497 Handle(SALOME_InteractiveObject) IOS = It.Value();
2498 SMESH::SMESH_Mesh_var aMesh =
2499 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2500 if ( aMesh->_is_nil()) continue;
2502 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2504 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2505 SMESH::ModifiedMesh( aMeshSObj, false, true);
2506 // hide groups and submeshes
2507 _PTR(ChildIterator) anIter =
2508 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2509 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2511 _PTR(SObject) so = anIter->Value();
2512 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2515 catch (const SALOME::SALOME_Exception& S_ex){
2517 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2521 SMESH::UpdateView();
2525 case 4051: // RENUMBERING NODES
2527 if(checkLock(aStudy)) break;
2529 EmitSignalDeactivateDialog();
2530 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2534 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2535 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2539 case 4052: // RENUMBERING ELEMENTS
2541 if(checkLock(aStudy)) break;
2543 EmitSignalDeactivateDialog();
2544 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2548 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2549 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2553 case 4061: // TRANSLATION
2555 if(checkLock(aStudy)) break;
2557 EmitSignalDeactivateDialog();
2558 ( new SMESHGUI_TranslationDlg( this ) )->show();
2561 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2562 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2566 case 4062: // ROTATION
2568 if(checkLock(aStudy)) break;
2570 EmitSignalDeactivateDialog();
2571 ( new SMESHGUI_RotationDlg( this ) )->show();
2574 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2575 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2579 case 4063: // SYMMETRY
2581 if(checkLock(aStudy)) break;
2583 EmitSignalDeactivateDialog();
2584 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2587 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2588 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2592 case 4064: // SEWING
2594 if(checkLock(aStudy)) break;
2596 EmitSignalDeactivateDialog();
2597 ( new SMESHGUI_SewingDlg( this ) )->show();
2600 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2601 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2605 case 4065: // MERGE NODES
2607 if(checkLock(aStudy)) break;
2609 EmitSignalDeactivateDialog();
2610 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2613 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2614 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2618 case 4066: // MERGE EQUAL ELEMENTS
2620 if (checkLock(aStudy)) break;
2622 EmitSignalDeactivateDialog();
2623 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2625 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2626 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2631 case 4067: // MAKE MESH PASS THROUGH POINT
2632 startOperation( 4067 );
2635 case 5105: // Library of selection filters
2637 static QList<int> aTypes;
2638 if ( aTypes.isEmpty() )
2640 aTypes.append( SMESH::NODE );
2641 aTypes.append( SMESH::EDGE );
2642 aTypes.append( SMESH::FACE );
2643 aTypes.append( SMESH::VOLUME );
2645 if (!myFilterLibraryDlg)
2646 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2647 else if (myFilterLibraryDlg->isHidden())
2648 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2649 myFilterLibraryDlg->raise();
2653 case 6017: // CONTROLS
2671 LightApp_SelectionMgr* mgr = selectionMgr();
2672 SALOME_ListIO selected; mgr->selectedObjects( selected );
2674 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2675 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2677 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2678 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2679 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2680 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2681 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2682 ::Control( theCommandID );
2687 SUIT_MessageBox::warning(desktop(),
2688 tr( "SMESH_WRN_WARNING" ),
2689 tr( "SMESH_BAD_SELECTION" ) );
2693 SUIT_MessageBox::warning(desktop(),
2694 tr( "SMESH_WRN_WARNING" ),
2695 tr( "NOT_A_VTK_VIEWER" ) );
2700 LightApp_SelectionMgr* mgr = selectionMgr();
2701 SALOME_ListIO selected; mgr->selectedObjects( selected );
2703 SALOME_ListIteratorOfListIO it(selected);
2704 for( ; it.More(); it.Next()) {
2705 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2706 if(anIObject->hasEntry()) {
2707 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2708 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2716 LightApp_SelectionMgr* mgr = selectionMgr();
2717 SALOME_ListIO selected; mgr->selectedObjects( selected );
2719 if (selected.Extent() == 1) {
2720 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2721 if(anIObject->hasEntry())
2722 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2723 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2730 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2731 //updateObjBrowser();
2735 //=============================================================================
2739 //=============================================================================
2740 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2745 //=============================================================================
2749 //=============================================================================
2750 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2755 //=============================================================================
2759 //=============================================================================
2760 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2765 //=============================================================================
2766 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2767 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2769 //=============================================================================
2770 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2771 SUIT_ViewWindow* wnd )
2773 if(theIO->hasEntry()){
2774 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2775 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2779 //=======================================================================
2780 // function : createSMESHAction
2782 //=======================================================================
2783 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2786 QWidget* parent = application()->desktop();
2787 SUIT_ResourceMgr* resMgr = resourceMgr();
2789 if ( !icon_id.isEmpty() )
2790 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2792 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2793 if ( !pix.isNull() )
2794 icon = QIcon( pix );
2796 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2797 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2798 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2800 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2803 //=======================================================================
2804 // function : createPopupItem
2806 //=======================================================================
2807 void SMESHGUI::createPopupItem( const int id,
2808 const QString& clients,
2809 const QString& types,
2810 const QString& theRule,
2815 parentId = popupMgr()->actionId( action( pId ) );
2817 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2818 popupMgr()->insert( action( id ), parentId, 0 );
2820 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2821 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2822 QString rule = "(%1) and (%2) and (%3)";
2823 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2824 if( clients.isEmpty() )
2825 rule = rule.arg( QString( "true" ) );
2827 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2828 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2831 bool cont = myRules.contains( id );
2833 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2835 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2836 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2839 //=======================================================================
2840 // function : initialize
2842 //=======================================================================
2843 void SMESHGUI::initialize( CAM_Application* app )
2845 SalomeApp_Module::initialize( app );
2847 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2849 /* Automatic Update flag */
2850 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2852 // ----- create actions --------------
2854 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2855 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2856 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2857 createSMESHAction( 114, "NUM" );
2858 createSMESHAction( 121, "DAT" );
2859 createSMESHAction( 122, "MED" );
2860 createSMESHAction( 123, "UNV" );
2861 createSMESHAction( 140, "STL" );
2862 createSMESHAction( 124, "EXPORT_DAT" );
2863 createSMESHAction( 125, "EXPORT_MED" );
2864 createSMESHAction( 126, "EXPORT_UNV" );
2865 createSMESHAction( 141, "EXPORT_STL" );
2866 createSMESHAction( 150, "FILE_INFO" );
2867 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2868 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2869 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2870 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2871 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2872 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2873 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2874 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2875 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2876 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2877 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2878 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2879 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2880 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2881 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2882 createSMESHAction( 804, "ADD" );
2883 createSMESHAction( 805, "REMOVE" );
2884 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2885 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2886 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2887 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2888 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2889 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2890 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2891 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2892 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2893 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2894 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2895 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2896 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2897 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2898 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2899 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2900 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2901 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2902 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2903 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2904 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2905 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2906 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2907 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2908 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2909 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2910 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2911 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2912 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2913 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2914 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2915 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2916 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2917 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2918 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2919 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2920 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2921 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2922 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2923 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2924 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2925 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2926 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2927 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2928 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2929 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2930 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2931 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2932 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2933 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2934 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2935 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2936 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2937 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2938 createSMESHAction( 415, "MAP", "ICON_MAP" );
2939 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2940 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2941 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2942 createSMESHAction( 200, "RESET" );
2943 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2944 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2945 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2946 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2947 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2948 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2949 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2950 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2951 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2952 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2953 createSMESHAction( 220, "ALL" );
2954 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2956 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2957 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2959 createSMESHAction( 1100, "EDIT_HYPO" );
2960 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2961 createSMESHAction( 1102, "UNASSIGN" );
2962 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2963 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2964 createSMESHAction( 1131, "DISPMODE" );
2965 createSMESHAction( 1132, "COLORS" );
2966 createSMESHAction( 1133, "TRANSP" );
2967 createSMESHAction( 1134, "CLIP" );
2968 createSMESHAction( 1135, "DISP_ENT" );
2969 createSMESHAction( 1136, "AUTO_COLOR" );
2970 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2971 createSMESHAction( 2000, "CTRL" );
2973 createSMESHAction( 300, "ERASE" );
2974 createSMESHAction( 301, "DISPLAY" );
2975 createSMESHAction( 302, "DISPLAY_ONLY" );
2976 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2977 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2978 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2979 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2980 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2981 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2982 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2983 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2985 // ----- create menu --------------
2986 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2987 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2988 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2989 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2990 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2991 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2992 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2994 createMenu( separator(), fileId );
2996 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2997 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2998 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2999 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3000 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3001 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3003 createMenu( 111, importId, -1 );
3004 createMenu( 112, importId, -1 );
3005 createMenu( 113, importId, -1 );
3007 createMenu( 121, exportId, -1 );
3008 createMenu( 122, exportId, -1 );
3009 createMenu( 123, exportId, -1 );
3010 createMenu( 140, exportId, -1 ); // export to stl STL
3012 createMenu( separator(), fileId, 10 );
3014 createMenu( 33, editId, -1 );
3016 createMenu( 5105, toolsId, -1 );
3018 createMenu( 702, meshId, -1 ); // "Mesh" menu
3019 createMenu( 703, meshId, -1 );
3020 createMenu( 704, meshId, -1 );
3021 createMenu( 710, meshId, -1 );
3022 createMenu( separator(), meshId, -1 );
3023 createMenu( 701, meshId, -1 );
3024 createMenu( 711, meshId, -1 );
3025 createMenu( 712, meshId, -1 );
3026 createMenu( 713, meshId, -1 );
3027 createMenu( separator(), meshId, -1 );
3028 createMenu( 801, meshId, -1 );
3029 createMenu( 806, meshId, -1 );
3030 createMenu( 802, meshId, -1 );
3031 createMenu( 803, meshId, -1 );
3032 createMenu( 815, meshId, -1 );
3033 createMenu( separator(), meshId, -1 );
3034 createMenu( 810, meshId, -1 );
3035 createMenu( 811, meshId, -1 );
3036 createMenu( 812, meshId, -1 );
3037 createMenu( separator(), meshId, -1 );
3038 createMenu( 814, meshId, -1 );
3039 createMenu( separator(), meshId, -1 );
3040 createMenu( 813, meshId, -1 );
3041 createMenu( separator(), meshId, -1 );
3042 createMenu( 900, meshId, -1 );
3043 createMenu( 902, meshId, -1 );
3044 createMenu( 903, meshId, -1 );
3045 createMenu( 904, meshId, -1 );
3046 createMenu( separator(), meshId, -1 );
3048 createMenu( 6003, ctrlId, -1 );
3049 createMenu( 6001, ctrlId, -1 );
3050 createMenu( 6004, ctrlId, -1 );
3051 createMenu( separator(), ctrlId, -1 );
3052 createMenu( 6005, ctrlId, -1 );
3053 createMenu( 6002, ctrlId, -1 );
3054 createMenu( 6018, ctrlId, -1 );
3055 createMenu( 6019, ctrlId, -1 );
3056 createMenu( 6011, ctrlId, -1 );
3057 createMenu( 6012, ctrlId, -1 );
3058 createMenu( 6013, ctrlId, -1 );
3059 createMenu( 6014, ctrlId, -1 );
3060 createMenu( 6015, ctrlId, -1 );
3061 createMenu( 6016, ctrlId, -1 );
3062 createMenu( separator(), ctrlId, -1 );
3063 createMenu( 6017, ctrlId, -1 );
3064 createMenu( 6009, ctrlId, -1 );
3065 createMenu( 6021, ctrlId, -1 );
3066 createMenu( separator(), ctrlId, -1 );
3068 createMenu( 4000, addId, -1 );
3069 createMenu( 4009, addId, -1 );
3070 createMenu( 4010, addId, -1 );
3071 createMenu( 4021, addId, -1 );
3072 createMenu( 4022, addId, -1 );
3073 createMenu( 4023, addId, -1 );
3074 createMenu( 4031, addId, -1 );
3075 createMenu( 4032, addId, -1 );
3076 createMenu( 4033, addId, -1 );
3077 createMenu( separator(), addId, -1 );
3078 createMenu( 4034, addId, -1 );
3079 createMenu( 4035, addId, -1 );
3080 createMenu( 4036, addId, -1 );
3081 createMenu( 4037, addId, -1 );
3082 createMenu( 4038, addId, -1 );
3083 createMenu( 4039, addId, -1 );
3084 createMenu( 4040, addId, -1 );
3086 createMenu( 4041, removeId, -1 );
3087 createMenu( 4042, removeId, -1 );
3088 createMenu( 4043, removeId, -1 );
3090 createMenu( 4051, renumId, -1 );
3091 createMenu( 4052, renumId, -1 );
3093 createMenu( 4061, transfId, -1 );
3094 createMenu( 4062, transfId, -1 );
3095 createMenu( 4063, transfId, -1 );
3096 createMenu( 4064, transfId, -1 );
3097 createMenu( 4065, transfId, -1 );
3098 createMenu( 4066, transfId, -1 );
3100 createMenu( 406, modifyId, -1 );
3101 createMenu( 4067,modifyId, -1 );
3102 createMenu( 407, modifyId, -1 );
3103 createMenu( 408, modifyId, -1 );
3104 createMenu( 409, modifyId, -1 );
3105 createMenu( 410, modifyId, -1 );
3106 createMenu( 411, modifyId, -1 );
3107 createMenu( 412, modifyId, -1 );
3108 createMenu( 413, modifyId, -1 );
3109 createMenu( 416, modifyId, -1 );
3110 createMenu( 414, modifyId, -1 );
3111 createMenu( 415, modifyId, -1 );
3112 createMenu( 417, modifyId, -1 );
3113 createMenu( 418, modifyId, -1 );
3115 createMenu( 214, viewId, -1 );
3117 // ----- create toolbars --------------
3118 int meshTb = createTool( tr( "TB_MESH" ) ),
3119 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3120 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3121 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3122 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3124 createTool( 702, meshTb );
3125 createTool( 703, meshTb );
3126 createTool( 704, meshTb );
3127 createTool( 710, meshTb );
3128 createTool( separator(), meshTb );
3129 createTool( 701, meshTb );
3130 createTool( 711, meshTb );
3131 createTool( 712, meshTb );
3132 createTool( 713, meshTb );
3133 createTool( separator(), meshTb );
3134 createTool( 801, meshTb );
3135 createTool( 806, meshTb );
3136 createTool( 802, meshTb );
3137 createTool( 803, meshTb );
3138 //createTool( 815, meshTb );
3139 createTool( separator(), meshTb );
3140 createTool( 900, meshTb );
3141 createTool( 902, meshTb );
3142 createTool( 903, meshTb );
3143 createTool( 904, meshTb );
3144 createTool( separator(), meshTb );
3146 createTool( 6001, ctrlTb );
3147 createTool( 6003, ctrlTb );
3148 createTool( 6004, ctrlTb );
3149 createTool( separator(), ctrlTb );
3150 createTool( 6005, ctrlTb );
3151 createTool( 6002, ctrlTb );
3152 createTool( 6018, ctrlTb );
3153 createTool( 6019, ctrlTb );
3154 createTool( 6011, ctrlTb );
3155 createTool( 6012, ctrlTb );
3156 createTool( 6013, ctrlTb );
3157 createTool( 6014, ctrlTb );
3158 createTool( 6015, ctrlTb );
3159 createTool( 6016, ctrlTb );
3160 createTool( separator(), ctrlTb );
3161 createTool( 6017, ctrlTb );
3162 createTool( 6009, ctrlTb );
3163 createTool( 6021, ctrlTb );
3164 createTool( separator(), ctrlTb );
3166 createTool( 4000, addRemTb );
3167 createTool( 4009, addRemTb );
3168 createTool( 4010, addRemTb );
3169 createTool( 4021, addRemTb );
3170 createTool( 4022, addRemTb );
3171 createTool( 4023, addRemTb );
3172 createTool( 4031, addRemTb );
3173 createTool( 4032, addRemTb );
3174 createTool( 4033, addRemTb );
3175 createTool( separator(), addRemTb );
3176 createTool( 4034, addRemTb );
3177 createTool( 4035, addRemTb );
3178 createTool( 4036, addRemTb );
3179 createTool( 4037, addRemTb );
3180 createTool( 4038, addRemTb );
3181 createTool( 4039, addRemTb );
3182 createTool( 4040, addRemTb );
3183 createTool( separator(), addRemTb );
3184 createTool( 4041, addRemTb );
3185 createTool( 4042, addRemTb );
3186 createTool( 4043, addRemTb );
3187 createTool( separator(), addRemTb );
3188 createTool( 4051, addRemTb );
3189 createTool( 4052, addRemTb );
3190 createTool( separator(), addRemTb );
3191 createTool( 4061, addRemTb );
3192 createTool( 4062, addRemTb );
3193 createTool( 4063, addRemTb );
3194 createTool( 4064, addRemTb );
3195 createTool( 4065, addRemTb );
3196 createTool( 4066, addRemTb );
3197 createTool( separator(), addRemTb );
3199 createTool( 406, modifyTb );
3200 createTool( 4067,modifyTb );
3201 createTool( 407, modifyTb );
3202 createTool( 408, modifyTb );
3203 createTool( 409, modifyTb );
3204 createTool( 410, modifyTb );
3205 createTool( 411, modifyTb );
3206 createTool( 412, modifyTb );
3207 createTool( 413, modifyTb );
3208 createTool( 416, modifyTb );
3209 createTool( 414, modifyTb );
3210 createTool( 415, modifyTb );
3211 createTool( 417, modifyTb );
3212 createTool( 418, modifyTb );
3214 createTool( 214, dispModeTb );
3216 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3217 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3220 QString OB = "'ObjectBrowser'",
3221 View = "'" + SVTK_Viewer::Type() + "'",
3223 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3224 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3225 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3226 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3227 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3228 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3229 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3230 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3231 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3232 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3233 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3235 mesh_group = mesh + " " + subMesh + " " + group,
3236 hyp_alg = hypo + " " + algo;
3238 // popup for object browser
3240 isInvisible("not( isVisible )"),
3241 isEmpty("numberOfNodes = 0"),
3242 isNotEmpty("numberOfNodes <> 0"),
3244 // has nodes, edges, etc in VISIBLE! actor
3245 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3246 hasElems("(count( elemTypes ) > 0)"),
3247 hasDifferentElems("(count( elemTypes ) > 1)"),
3248 hasElems0d("({'Elem0d'} in elemTypes)"),
3249 hasEdges("({'Edge'} in elemTypes)"),
3250 hasFaces("({'Face'} in elemTypes)"),
3251 hasVolumes("({'Volume'} in elemTypes)");
3253 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3254 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3255 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3256 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3257 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3258 createPopupItem( 803, OB, group ); // EDIT_GROUP
3259 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3261 popupMgr()->insert( separator(), -1, 0 );
3262 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3263 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3264 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3265 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3266 createPopupItem( 214, OB, mesh_group ); // UPDATE
3267 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3268 createPopupItem( 902, OB, mesh ); // STD_INFO
3269 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3270 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3271 popupMgr()->insert( separator(), -1, 0 );
3272 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3273 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3274 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3275 popupMgr()->insert( separator(), -1, 0 );
3276 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3277 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3278 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3279 popupMgr()->insert( separator(), -1, 0 );
3280 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3281 popupMgr()->insert( separator(), -1, 0 );
3282 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3283 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3284 popupMgr()->insert( separator(), -1, 0 );
3286 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3287 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3289 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3290 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3291 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3292 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3293 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3294 popupMgr()->insert( separator(), -1, 0 );
3297 createPopupItem( 803, View, group ); // EDIT_GROUP
3298 createPopupItem( 804, View, elems ); // ADD
3299 createPopupItem( 805, View, elems ); // REMOVE
3301 popupMgr()->insert( separator(), -1, 0 );
3302 createPopupItem( 214, View, mesh_group ); // UPDATE
3303 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3304 createPopupItem( 902, View, mesh ); // STD_INFO
3305 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3306 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3307 popupMgr()->insert( separator(), -1, 0 );
3309 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3310 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3311 popupMgr()->insert( separator(), -1, 0 );
3314 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3315 QString aType = QString( "%1type in {%2}" ).arg( lc );
3316 aType = aType.arg( mesh_group );
3317 QString aMeshInVTK = aClient + "&&" + aType;
3319 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3320 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3321 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3323 //-------------------------------------------------
3325 //-------------------------------------------------
3326 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3328 popupMgr()->insert( action( 9010 ), anId, -1 );
3329 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3330 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3332 popupMgr()->insert( action( 9011 ), anId, -1 );
3333 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3334 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3336 popupMgr()->insert( separator(), -1, -1 );
3338 //-------------------------------------------------
3340 //-------------------------------------------------
3341 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3343 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3344 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3345 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3347 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3348 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3349 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3351 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3352 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3353 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3355 popupMgr()->insert( separator(), anId, -1 );
3357 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3358 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3359 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3361 //-------------------------------------------------
3363 //-------------------------------------------------
3364 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3366 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3368 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3369 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3370 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3372 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3373 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3374 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3376 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3377 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3378 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3380 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3381 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3382 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3384 popupMgr()->insert( separator(), anId, -1 );
3386 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3387 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3390 //-------------------------------------------------
3391 // Representation of the 2D Quadratic elements
3392 //-------------------------------------------------
3393 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3394 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3395 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3396 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3398 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3399 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3400 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3402 //-------------------------------------------------
3403 // Orientation of faces
3404 //-------------------------------------------------
3405 popupMgr()->insert( action( 221 ), -1, -1 );
3406 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3407 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3409 //-------------------------------------------------
3411 //-------------------------------------------------
3412 popupMgr()->insert( action( 1132 ), -1, -1 );
3413 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3415 //-------------------------------------------------
3417 //-------------------------------------------------
3418 popupMgr()->insert( action( 1133 ), -1, -1 );
3419 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3421 //-------------------------------------------------
3423 //-------------------------------------------------
3424 popupMgr()->insert( action( 1134 ), -1, -1 );
3425 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3427 popupMgr()->insert( separator(), -1, -1 );
3429 //-------------------------------------------------
3431 //-------------------------------------------------
3433 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3434 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3435 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3436 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3438 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3440 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3441 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3443 popupMgr()->insert( separator(), anId, -1 );
3445 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3446 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3447 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3449 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3450 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3451 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3453 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3454 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3455 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3457 popupMgr()->insert( separator(), anId, -1 );
3459 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3460 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3461 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3463 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3464 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3465 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3467 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3468 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3469 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3471 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3472 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3473 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3475 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3476 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3477 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3479 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3480 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3481 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3483 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3484 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3485 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3487 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3488 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3489 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3491 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3492 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3493 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3495 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3496 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3497 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3499 popupMgr()->insert( separator(), anId, -1 );
3501 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3502 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3503 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3505 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3506 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3507 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3509 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3510 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3511 QtxPopupMgr::VisibleRule );
3512 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3514 popupMgr()->insert( separator(), anId, -1 );
3516 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3517 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3519 popupMgr()->insert( separator(), -1, -1 );
3521 //-------------------------------------------------
3523 //-------------------------------------------------
3524 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3525 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3526 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3527 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3529 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3530 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3532 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3533 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3535 popupMgr()->insert( separator(), -1, -1 );
3537 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3538 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3541 //================================================================================
3543 * \brief Return true if SMESH or GEOM objects are selected.
3544 * Is called form LightApp_Module::activateModule() which clear selection if
3545 * not isSelectionCompatible()
3547 //================================================================================
3549 bool SMESHGUI::isSelectionCompatible()
3551 bool isCompatible = true;
3552 SALOME_ListIO selected;
3553 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3554 Sel->selectedObjects( selected );
3556 SALOME_ListIteratorOfListIO It( selected );
3557 for ( ; isCompatible && It.More(); It.Next())
3559 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3560 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3562 return isCompatible;
3566 bool SMESHGUI::reusableOperation( const int id )
3568 // compute, evaluate and precompute are not reusable operations
3569 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3572 bool SMESHGUI::activateModule( SUIT_Study* study )
3574 bool res = SalomeApp_Module::activateModule( study );
3576 setMenuShown( true );
3577 setToolShown( true );
3579 // Reset actions accelerator keys
3580 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3581 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3582 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3584 action( 33)->setEnabled(true); // Delete: Key_Delete
3585 action(1101)->setEnabled(true); // Rename: Key_F2
3587 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3588 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3589 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3590 if ( _PTR(Study) aStudy = s->studyDS()) {
3591 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3592 updateObjBrowser(); // objects can be removed
3598 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3600 setMenuShown( false );
3601 setToolShown( false );
3603 EmitSignalCloseAllDialogs();
3605 // Unset actions accelerator keys
3606 action(111)->setShortcut(QKeySequence()); // Import DAT
3607 action(112)->setShortcut(QKeySequence()); // Import UNV
3608 action(113)->setShortcut(QKeySequence()); // Import MED
3610 action( 33)->setEnabled(false); // Delete: Key_Delete
3611 action(1101)->setEnabled(false); // Rename: Key_F2
3613 return SalomeApp_Module::deactivateModule( study );
3616 void SMESHGUI::studyClosed( SUIT_Study* s )
3618 SMESH::RemoveVisuData( s->id() );
3619 SalomeApp_Module::studyClosed( s );
3622 void SMESHGUI::OnGUIEvent()
3624 const QObject* obj = sender();
3625 if ( !obj || !obj->inherits( "QAction" ) )
3627 int id = actionId((QAction*)obj);
3632 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3634 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3635 if ( CORBA::is_nil( myComponentSMESH ) )
3637 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3639 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3640 return aGUI.myComponentSMESH;
3643 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3644 return myComponentSMESH;
3647 QString SMESHGUI::engineIOR() const
3649 CORBA::ORB_var anORB = getApp()->orb();
3650 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3651 return QString( anIOR.in() );
3654 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3656 SalomeApp_Module::contextMenuPopup( client, menu, title );
3658 selectionMgr()->selectedObjects( lst );
3659 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3660 Handle(SALOME_InteractiveObject) io = lst.First();
3661 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3662 _PTR(Study) study = appStudy->studyDS();
3663 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3665 QString aName = QString( obj->GetName().c_str() );
3666 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3667 aName.remove( (aName.length() - 1), 1 );
3673 LightApp_Selection* SMESHGUI::createSelection() const
3675 return new SMESHGUI_Selection();
3678 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3680 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3681 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3684 void SMESHGUI::viewManagers( QStringList& list ) const
3686 list.append( SVTK_Viewer::Type() );
3689 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3691 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3692 SMESH::UpdateSelectionProp( this );
3695 void SMESHGUI::createPreferences()
3697 // General tab ------------------------------------------------------------------------
3698 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3700 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3701 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3703 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3704 setPreferenceProperty( qaGroup, "columns", 2 );
3705 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3706 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3707 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3708 setPreferenceProperty( prec, "min", 0 );
3709 setPreferenceProperty( prec, "max", 16 );
3711 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3712 setPreferenceProperty( dispgroup, "columns", 2 );
3713 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3715 modes.append( "Wireframe" );
3716 modes.append( "Shading" );
3717 modes.append( "Nodes" );
3718 modes.append( "Shrink" );
3719 QList<QVariant> indices;
3720 indices.append( 0 );
3721 indices.append( 1 );
3722 indices.append( 2 );
3723 indices.append( 3 );
3724 setPreferenceProperty( dispmode, "strings", modes );
3725 setPreferenceProperty( dispmode, "indexes", indices );
3727 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3728 setPreferenceProperty( arcgroup, "columns", 2 );
3729 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3730 QStringList quadraticModes;
3731 quadraticModes.append("Lines");
3732 quadraticModes.append("Arcs");
3734 indices.append( 0 );
3735 indices.append( 1 );
3736 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3737 setPreferenceProperty( quadraticmode, "indexes", indices );
3739 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3740 "SMESH", "max_angle" );
3741 setPreferenceProperty( maxAngle, "min", 1 );
3742 setPreferenceProperty( maxAngle, "max", 90 );
3746 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3747 setPreferenceProperty( exportgroup, "columns", 2 );
3748 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3749 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3751 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3752 setPreferenceProperty( computeGroup, "columns", 2 );
3753 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3755 modes.append( "Never" );
3756 modes.append( "Errors only" );
3757 modes.append( "Always" );
3759 indices.append( 0 );
3760 indices.append( 1 );
3761 indices.append( 2 );
3762 setPreferenceProperty( notifyMode, "strings", modes );
3763 setPreferenceProperty( notifyMode, "indexes", indices );
3765 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3766 setPreferenceProperty( segGroup, "columns", 2 );
3767 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3768 "SMESH", "segmentation" );
3769 setPreferenceProperty( segLen, "min", 1 );
3770 setPreferenceProperty( segLen, "max", 10000000 );
3771 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3772 "SMESH", "nb_segments_per_edge" );
3773 setPreferenceProperty( nbSeg, "min", 1 );
3774 setPreferenceProperty( nbSeg, "max", 10000000 );
3776 // Mesh tab ------------------------------------------------------------------------
3777 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3778 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3779 setPreferenceProperty( nodeGroup, "columns", 2 );
3781 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3782 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3784 setPreferenceProperty( nodeSz, "min", 1 );
3785 setPreferenceProperty( nodeSz, "max", 5 );
3787 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3788 setPreferenceProperty( elemGroup, "columns", 2 );
3790 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3791 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3792 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3793 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3795 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3796 //setPreferenceProperty( sp, "hstretch", 0 );
3797 //setPreferenceProperty( sp, "vstretch", 0 );
3799 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3800 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3801 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3802 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3803 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3804 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3805 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3807 setPreferenceProperty( size0d, "min", 1 );
3808 setPreferenceProperty( size0d, "max", 10 );
3810 setPreferenceProperty( sp, "hstretch", 0 );
3811 setPreferenceProperty( sp, "vstretch", 0 );
3813 setPreferenceProperty( elemW, "min", 1 );
3814 setPreferenceProperty( elemW, "max", 5 );
3816 setPreferenceProperty( shrink, "min", 0 );
3817 setPreferenceProperty( shrink, "max", 100 );
3819 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3820 setPreferenceProperty( orientGroup, "columns", 1 );
3822 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3823 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3825 setPreferenceProperty( orientScale, "min", 0.05 );
3826 setPreferenceProperty( orientScale, "max", 0.5 );
3827 setPreferenceProperty( orientScale, "step", 0.05 );
3829 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3831 // Selection tab ------------------------------------------------------------------------
3832 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3834 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3835 setPreferenceProperty( selGroup, "columns", 2 );
3837 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3838 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3839 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3841 setPreferenceProperty( selW, "min", 1 );
3842 setPreferenceProperty( selW, "max", 5 );
3844 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3845 setPreferenceProperty( preGroup, "columns", 2 );
3847 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3848 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3850 setPreferenceProperty( preW, "min", 1 );
3851 setPreferenceProperty( preW, "max", 5 );
3853 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3854 setPreferenceProperty( precSelGroup, "columns", 2 );
3856 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3857 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3858 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3860 // Scalar Bar tab ------------------------------------------------------------------------
3861 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3862 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3863 setPreferenceProperty( fontGr, "columns", 2 );
3865 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3866 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3868 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3869 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3871 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3872 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3874 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3875 setPreferenceProperty( numcol, "min", 2 );
3876 setPreferenceProperty( numcol, "max", 256 );
3878 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3879 setPreferenceProperty( numlab, "min", 2 );
3880 setPreferenceProperty( numlab, "max", 65 );
3882 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3883 setPreferenceProperty( orientGr, "columns", 2 );
3884 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3885 QStringList orients;
3886 orients.append( tr( "SMESH_VERTICAL" ) );
3887 orients.append( tr( "SMESH_HORIZONTAL" ) );
3888 indices.clear(); indices.append( 0 ); indices.append( 1 );
3889 setPreferenceProperty( orient, "strings", orients );
3890 setPreferenceProperty( orient, "indexes", indices );
3892 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3893 setPreferenceProperty( posVSizeGr, "columns", 2 );
3894 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3895 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3896 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3897 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3898 setPreferenceProperty( xv, "step", 0.1 );
3899 setPreferenceProperty( xv, "min", 0.0 );
3900 setPreferenceProperty( xv, "max", 1.0 );
3901 setPreferenceProperty( yv, "step", 0.1 );
3902 setPreferenceProperty( yv, "min", 0.0 );
3903 setPreferenceProperty( yv, "max", 1.0 );
3904 setPreferenceProperty( wv, "step", 0.1 );
3905 setPreferenceProperty( wv, "min", 0.0 );
3906 setPreferenceProperty( wv, "max", 1.0 );
3907 setPreferenceProperty( hv, "min", 0.0 );
3908 setPreferenceProperty( hv, "max", 1.0 );
3909 setPreferenceProperty( hv, "step", 0.1 );
3911 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3912 setPreferenceProperty( posHSizeGr, "columns", 2 );
3913 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3914 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3915 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3916 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3917 setPreferenceProperty( xv, "min", 0.0 );
3918 setPreferenceProperty( xv, "max", 1.0 );
3919 setPreferenceProperty( xv, "step", 0.1 );
3920 setPreferenceProperty( xh, "min", 0.0 );
3921 setPreferenceProperty( xh, "max", 1.0 );
3922 setPreferenceProperty( xh, "step", 0.1 );
3923 setPreferenceProperty( yh, "min", 0.0 );
3924 setPreferenceProperty( yh, "max", 1.0 );
3925 setPreferenceProperty( yh, "step", 0.1 );
3926 setPreferenceProperty( wh, "min", 0.0 );
3927 setPreferenceProperty( wh, "max", 1.0 );
3928 setPreferenceProperty( wh, "step", 0.1 );
3929 setPreferenceProperty( hh, "min", 0.0 );
3930 setPreferenceProperty( hh, "max", 1.0 );
3931 setPreferenceProperty( hh, "step", 0.1 );
3934 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3936 if( sect=="SMESH" ) {
3937 float sbX1,sbY1,sbW,sbH;
3938 float aTol = 1.00000009999999;
3939 std::string aWarning;
3940 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3941 if( name=="selection_object_color" || name=="selection_element_color" ||
3942 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3943 name=="selection_precision_node" || name=="selection_precision_element" ||
3944 name=="selection_precision_object")
3945 SMESH::UpdateSelectionProp( this );
3946 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3947 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3948 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3949 if(sbX1+sbW > aTol){
3950 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3953 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3954 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3957 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3958 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3959 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3960 if(sbY1+sbH > aTol){
3961 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3962 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3963 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3966 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3967 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3968 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3969 if(sbX1+sbW > aTol){
3970 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3973 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3974 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3977 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3978 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3979 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3980 if(sbY1+sbH > aTol){
3981 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3984 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3985 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3988 else if ( name == "segmentation" ) {
3989 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3990 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3992 else if ( name == "nb_segments_per_edge" ) {
3993 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3994 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3997 if(aWarning.size() != 0){
3998 aWarning += "The default values are applied instead.";
3999 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4000 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4001 QObject::tr(aWarning.c_str()));
4006 //================================================================================
4008 * \brief Update something in accordance with update flags
4009 * \param theFlags - update flags
4011 * Update viewer or/and object browser etc. in accordance with update flags ( see
4012 * LightApp_UpdateFlags enumeration ).
4014 //================================================================================
4015 void SMESHGUI::update( const int flags )
4017 if ( flags & UF_Viewer | flags & UF_Forced )
4018 SMESH::UpdateView();
4020 SalomeApp_Module::update( flags );
4023 //================================================================================
4025 * \brief Set default selection mode
4027 * SLOT called when operation commited. Sets default selection mode
4029 //================================================================================
4030 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4032 SVTK_ViewWindow* vtkWnd =
4033 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4035 vtkWnd->SetSelectionMode( ActorSelection );
4038 //================================================================================
4040 * \brief Set default selection mode
4042 * SLOT called when operation aborted. Sets default selection mode
4044 //================================================================================
4045 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4047 SVTK_ViewWindow* vtkWnd =
4048 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4050 vtkWnd->SetSelectionMode( ActorSelection );
4053 //================================================================================
4055 * \brief Creates operation with given identifier
4056 * \param id - identifier of operation to be started
4057 * \return Pointer on created operation or NULL if operation is not created
4059 * Virtual method redefined from the base class creates operation with given id.
4060 * It is called called automatically from startOperation method of base class.
4062 //================================================================================
4063 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4065 LightApp_Operation* op = 0;
4066 // to do : create operation here
4069 case 417: //convert to quadratic
4070 op = new SMESHGUI_ConvToQuadOp();
4072 case 418: // create 2D mesh as boundary on 3D
4073 op = new SMESHGUI_Make2DFrom3DOp();
4075 case 701: // Compute mesh
4076 op = new SMESHGUI_ComputeOp();
4078 case 702: // Create mesh
4079 op = new SMESHGUI_MeshOp( true, true );
4081 case 703: // Create sub-mesh
4082 op = new SMESHGUI_MeshOp( true, false );
4084 case 704: // Edit mesh/sub-mesh
4085 op = new SMESHGUI_MeshOp( false );
4087 case 711: // Precompute mesh
4088 op = new SMESHGUI_PrecomputeOp();
4090 case 712: // Evaluate mesh
4091 op = new SMESHGUI_EvaluateOp();
4093 case 713: // Evaluate mesh
4094 op = new SMESHGUI_MeshOrderOp();
4096 case 806: // Create group on geom
4097 op = new SMESHGUI_GroupOnShapeOp();
4099 case 904: // Find element
4100 op = new SMESHGUI_FindElemByPointOp();
4102 case 4067: // make mesh pass through point
4103 op = new SMESHGUI_MakeNodeAtPointOp();
4110 op = SalomeApp_Module::createOperation( id );
4114 //================================================================================
4116 * \brief Stops current operations and starts a given one
4117 * \param id - The id of the operation to start
4119 //================================================================================
4121 void SMESHGUI::switchToOperation(int id)
4123 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4124 activeStudy()->abortAllOperations();
4125 startOperation( id );
4128 LightApp_Displayer* SMESHGUI::displayer()
4131 myDisplayer = new SMESHGUI_Displayer( getApp() );
4135 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4138 int aTolerance = 64;
4139 int anIterations = 0;
4145 if( anIterations % aPeriod == 0 )
4148 if( aTolerance < 1 )
4151 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4153 aHue = (int)( 360.0 * rand() / RAND_MAX );
4154 //cout << "Hue = " << aHue << endl;
4156 //cout << "Auto colors : ";
4158 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4159 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4160 for( ; it != itEnd; ++it )
4162 SALOMEDS::Color anAutoColor = *it;
4163 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4166 aQColor.getHsv( &h, &s, &v );
4168 if( abs( h - aHue ) < aTolerance )
4171 //cout << "break (diff = " << abs( h - aHue ) << ")";
4181 //cout << "Hue of the returned color = " << aHue << endl;
4183 aColor.setHsv( aHue, 255, 255 );
4185 SALOMEDS::Color aSColor;
4186 aSColor.R = (double)aColor.red() / 255.0;
4187 aSColor.G = (double)aColor.green() / 255.0;
4188 aSColor.B = (double)aColor.blue() / 255.0;
4193 const char gSeparator = '_'; // character used to separate parameter names
4194 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4197 * \brief Store visual parameters
4199 * This method is called just before the study document is saved.
4200 * Store visual parameters in AttributeParameter attribue(s)
4202 void SMESHGUI::storeVisualParameters (int savePoint)
4204 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4205 if (!appStudy || !appStudy->studyDS())
4207 _PTR(Study) studyDS = appStudy->studyDS();
4209 // componentName is used for encoding of entries when storing them in IParameters
4210 std::string componentName = myComponentSMESH->ComponentDataType();
4211 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4212 //if (!aSComponent) return;
4215 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4216 componentName.c_str(),
4218 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4220 // viewers counters are used for storing view_numbers in IParameters
4223 // main cycle to store parameters of displayed objects
4224 QList<SUIT_ViewManager*> lst;
4225 QList<SUIT_ViewManager*>::Iterator it;
4226 getApp()->viewManagers(lst);
4227 for (it = lst.begin(); it != lst.end(); it++)
4229 SUIT_ViewManager* vman = *it;
4230 QString vType = vman->getType();
4232 // saving VTK actors properties
4233 if (vType == SVTK_Viewer::Type())
4235 QVector<SUIT_ViewWindow*> views = vman->getViews();
4236 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4238 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4240 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4241 vtkActorCollection* allActors = aCopy.GetActors();
4242 allActors->InitTraversal();
4243 while (vtkActor* actor = allActors->GetNextActor())
4245 if (actor->GetVisibility()) // store only visible actors
4247 SMESH_Actor* aSmeshActor = 0;
4248 if (actor->IsA("SMESH_Actor"))
4249 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4250 if (aSmeshActor && aSmeshActor->hasIO())
4252 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4255 // entry is "encoded" = it does NOT contain component adress,
4256 // since it is a subject to change on next component loading
4257 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4259 std::string param, vtkParam = vType.toLatin1().data();
4260 vtkParam += gSeparator;
4261 vtkParam += QString::number(vtkViewers).toLatin1().data();
4262 vtkParam += gSeparator;
4265 param = vtkParam + "Visibility";
4266 ip->setParameter(entry, param, "On");
4269 param = vtkParam + "Representation";
4270 ip->setParameter(entry, param, QString::number
4271 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4274 param = vtkParam + "IsShrunk";
4275 ip->setParameter(entry, param, QString::number
4276 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4278 // Displayed entities
4279 unsigned int aMode = aSmeshActor->GetEntityMode();
4280 bool isE = aMode & SMESH_Actor::eEdges;
4281 bool isF = aMode & SMESH_Actor::eFaces;
4282 bool isV = aMode & SMESH_Actor::eVolumes;
4284 QString modeStr ("e");
4285 modeStr += gDigitsSep; modeStr += QString::number(isE);
4286 modeStr += gDigitsSep; modeStr += "f";
4287 modeStr += gDigitsSep; modeStr += QString::number(isF);
4288 modeStr += gDigitsSep; modeStr += "v";
4289 modeStr += gDigitsSep; modeStr += QString::number(isV);
4291 param = vtkParam + "Entities";
4292 ip->setParameter(entry, param, modeStr.toLatin1().data());
4294 // Colors (surface:edge:)
4295 vtkFloatingPointType r, g, b;
4297 aSmeshActor->GetSufaceColor(r, g, b);
4298 QString colorStr ("surface");
4299 colorStr += gDigitsSep; colorStr += QString::number(r);
4300 colorStr += gDigitsSep; colorStr += QString::number(g);
4301 colorStr += gDigitsSep; colorStr += QString::number(b);
4303 aSmeshActor->GetBackSufaceColor(r, g, b);
4304 colorStr += gDigitsSep; colorStr += "backsurface";
4305 colorStr += gDigitsSep; colorStr += QString::number(r);
4306 colorStr += gDigitsSep; colorStr += QString::number(g);
4307 colorStr += gDigitsSep; colorStr += QString::number(b);
4309 aSmeshActor->GetEdgeColor(r, g, b);
4310 colorStr += gDigitsSep; colorStr += "edge";
4311 colorStr += gDigitsSep; colorStr += QString::number(r);
4312 colorStr += gDigitsSep; colorStr += QString::number(g);
4313 colorStr += gDigitsSep; colorStr += QString::number(b);
4315 aSmeshActor->GetNodeColor(r, g, b);
4316 colorStr += gDigitsSep; colorStr += "node";
4317 colorStr += gDigitsSep; colorStr += QString::number(r);
4318 colorStr += gDigitsSep; colorStr += QString::number(g);
4319 colorStr += gDigitsSep; colorStr += QString::number(b);
4321 param = vtkParam + "Colors";
4322 ip->setParameter(entry, param, colorStr.toLatin1().data());
4324 // Sizes of lines and points
4325 QString sizeStr ("line");
4326 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4327 sizeStr += gDigitsSep; sizeStr += "node";
4328 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4329 sizeStr += gDigitsSep; sizeStr += "shrink";
4330 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4332 param = vtkParam + "Sizes";
4333 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4336 param = vtkParam + "Opacity";
4337 ip->setParameter(entry, param,
4338 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4341 param = vtkParam + "ClippingPlane";
4342 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4344 ip->setParameter(entry, param, "Off");
4345 for (int ipl = 0; ipl < nPlanes; ipl++) {
4346 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4347 SMESH::Orientation anOrientation;
4349 vtkFloatingPointType anAngle[2];
4350 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4351 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4352 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4353 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4354 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4356 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4358 } // if (io->hasEntry())
4359 } // SMESH_Actor && hasIO
4361 } // while.. actors traversal
4365 } // if (SVTK view model)
4366 } // for (viewManagers)
4370 * \brief Restore visual parameters
4372 * This method is called after the study document is opened.
4373 * Restore visual parameters from AttributeParameter attribue(s)
4375 void SMESHGUI::restoreVisualParameters (int savePoint)
4377 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4378 if (!appStudy || !appStudy->studyDS())
4380 _PTR(Study) studyDS = appStudy->studyDS();
4382 // componentName is used for encoding of entries when storing them in IParameters
4383 std::string componentName = myComponentSMESH->ComponentDataType();
4384 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4385 //if (!aSComponent) return;
4388 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4389 componentName.c_str(),
4391 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4393 std::vector<std::string> entries = ip->getEntries();
4395 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4397 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4398 QString entry (ip->decodeEntry(*entIt).c_str());
4400 // Check that the entry corresponds to a real object in the Study
4401 // as the object may be deleted or modified after the visual state is saved.
4402 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4403 if (!so) continue; //Skip the not existent entry
4405 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4406 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4408 std::vector<std::string>::iterator namesIt = paramNames.begin();
4409 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4411 // actors are stored in a map after displaying of them for
4412 // quicker access in the future: map < viewID to actor >
4413 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4415 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4417 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4418 // '_' is used as separator and should not be used in viewer type or parameter names.
4419 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4420 if (lst.size() != 3)
4423 QString viewerTypStr = lst[0];
4424 QString viewIndexStr = lst[1];
4425 QString paramNameStr = lst[2];
4428 int viewIndex = viewIndexStr.toUInt(&ok);
4429 if (!ok) // bad conversion of view index to integer
4433 if (viewerTypStr == SVTK_Viewer::Type())
4435 SMESH_Actor* aSmeshActor = 0;
4436 if (vtkActors.IsBound(viewIndex))
4437 aSmeshActor = vtkActors.Find(viewIndex);
4439 if (paramNameStr == "Visibility")
4441 if (!aSmeshActor && displayer())
4443 QList<SUIT_ViewManager*> lst;
4444 getApp()->viewManagers(viewerTypStr, lst);
4446 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4447 if (viewIndex >= 0 && viewIndex < lst.count()) {
4448 SUIT_ViewManager* vman = lst.at(viewIndex);
4449 SUIT_ViewModel* vmodel = vman->getViewModel();
4450 // SVTK view model can be casted to SALOME_View
4451 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4453 // store displayed actor in a temporary map for quicker
4454 // access later when restoring other parameters
4455 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4456 vtkRenderer* Renderer = vtkView->getRenderer();
4457 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4458 vtkActorCollection* theActors = aCopy.GetActors();
4459 theActors->InitTraversal();
4460 bool isFound = false;
4461 vtkActor *ac = theActors->GetNextActor();
4462 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4463 if (ac->IsA("SMESH_Actor")) {
4464 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4465 if (aGeomAc->hasIO()) {
4466 Handle(SALOME_InteractiveObject) io =
4467 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4468 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4470 vtkActors.Bind(viewIndex, aGeomAc);
4477 } // if (paramNameStr == "Visibility")
4480 // the rest properties "work" with SMESH_Actor
4483 QString val ((*valuesIt).c_str());
4486 if (paramNameStr == "Representation") {
4487 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4490 else if (paramNameStr == "IsShrunk") {
4492 if (!aSmeshActor->IsShrunk())
4493 aSmeshActor->SetShrink();
4496 if (aSmeshActor->IsShrunk())
4497 aSmeshActor->UnShrink();
4500 // Displayed entities
4501 else if (paramNameStr == "Entities") {
4502 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4503 if (mode.count() == 6) {
4504 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4505 MESSAGE("Invalid order of data in Entities, must be: "
4506 "e:0/1:f:0/1:v:0/1");
4509 unsigned int aMode = aSmeshActor->GetEntityMode();
4510 unsigned int aNewMode =
4511 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4512 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4513 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4514 if (aNewMode != aMode)
4515 aSmeshActor->SetEntityMode(aNewMode);
4520 else if (paramNameStr == "Colors") {
4521 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4522 if (colors.count() == 16) {
4523 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4524 colors[8] != "edge" || colors[12] != "node") {
4525 MESSAGE("Invalid order of data in Colors, must be: "
4526 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4529 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4530 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4531 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4532 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4536 // Sizes of lines and points
4537 else if (paramNameStr == "Sizes") {
4538 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4539 if (sizes.count() == 6) {
4540 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4541 MESSAGE("Invalid order of data in Sizes, must be: "
4542 "line:int:node:int:shrink:float");
4545 aSmeshActor->SetLineWidth(sizes[1].toInt());
4546 aSmeshActor->SetNodeSize(sizes[3].toInt());
4547 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4552 else if (paramNameStr == "Opacity") {
4553 aSmeshActor->SetOpacity(val.toFloat());
4556 else if (paramNameStr.startsWith("ClippingPlane")) {
4557 cout << "$$$ ClippingPlane 1" << endl;
4558 if (paramNameStr == "ClippingPlane1" || val == "Off")
4559 aSmeshActor->RemoveAllClippingPlanes();
4561 cout << "$$$ ClippingPlane 2" << endl;
4562 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4563 if (vals.count() == 4) { // format check: 4 values
4564 cout << "$$$ ClippingPlane 3" << endl;
4565 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4566 double aDistance = vals[1].toFloat();
4567 vtkFloatingPointType anAngle[2];
4568 anAngle[0] = vals[2].toFloat();
4569 anAngle[1] = vals[3].toFloat();
4571 QList<SUIT_ViewManager*> lst;
4572 getApp()->viewManagers(viewerTypStr, lst);
4573 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4574 if (viewIndex >= 0 && viewIndex < lst.count()) {
4575 SUIT_ViewManager* vman = lst.at(viewIndex);
4576 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4577 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4578 anOrientation, aDistance, anAngle);
4583 } // if (aSmeshActor)
4584 } // other parameters than Visibility
4586 } // for names/parameters iterator
4587 } // for entries iterator
4589 // update all VTK views
4590 QList<SUIT_ViewManager*> lst;
4591 getApp()->viewManagers(lst);
4592 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4593 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4594 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4595 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4596 vtkView->getRenderer()->ResetCameraClippingRange();
4603 \brief Adds preferences for dfont of VTK viewer
4605 \param pIf group identifier
4606 \param param parameter
4607 \return identifier of preferences
4609 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4611 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4613 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4616 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4617 fam.append( tr( "SMESH_FONT_COURIER" ) );
4618 fam.append( tr( "SMESH_FONT_TIMES" ) );
4620 setPreferenceProperty( tfont, "fonts", fam );
4622 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4623 setPreferenceProperty( tfont, "features", f );
4629 \brief Actions after hypothesis edition
4630 Updates object browser after hypothesis edition
4632 void SMESHGUI::onHypothesisEdit( int result )
4634 updateObjBrowser( true );