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 int Edgewidth = (int)anActor->GetLineWidth();
803 int intValue = int(anActor->GetNodeSize());
804 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
806 SMESHGUI_Preferences_ColorDlg *aDlg =
807 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
808 aDlg->SetColor(1, c);
809 aDlg->SetColor(2, e);
810 aDlg->SetColor(3, n);
811 aDlg->SetColor(4, b);
812 aDlg->SetIntValue(1, Edgewidth);
813 aDlg->SetIntValue(2, intValue);
814 aDlg->SetIntValue(3, int(Shrink*100.));
816 QColor color = aDlg->GetColor(1);
817 QColor edgecolor = aDlg->GetColor(2);
818 QColor nodecolor = aDlg->GetColor(3);
819 QColor backfacecolor = aDlg->GetColor(4);
820 /* actor color and backface color */
821 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
822 vtkFloatingPointType (color.green()) / 255.,
823 vtkFloatingPointType (color.blue()) / 255.);
824 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
825 vtkFloatingPointType (backfacecolor.green()) / 255.,
826 vtkFloatingPointType (backfacecolor.blue()) / 255.);
829 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
830 vtkFloatingPointType (edgecolor.green()) / 255.,
831 vtkFloatingPointType (edgecolor.blue()) / 255.);
833 /* Shrink factor and size edges */
834 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
835 anActor->SetLineWidth(aDlg->GetIntValue(1));
837 /* Nodes color and size */
838 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
839 vtkFloatingPointType (nodecolor.green()) / 255.,
840 vtkFloatingPointType (nodecolor.blue()) / 255.);
841 anActor->SetNodeSize(aDlg->GetIntValue(2));
843 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
844 if( !aGroupObject->_is_nil() )
846 SMESH::ElementType anElementType = aGroupObject->GetType();
848 switch( anElementType )
850 case SMESH::NODE: aColor = nodecolor; break;
851 case SMESH::EDGE: aColor = edgecolor; break;
852 default: aColor = color; break;
855 SALOMEDS::Color aGroupColor;
856 aGroupColor.R = (float)aColor.red() / 255.0;
857 aGroupColor.G = (float)aColor.green() / 255.0;
858 aGroupColor.B = (float)aColor.blue() / 255.0;
859 aGroupObject->SetColor( aGroupColor );
869 SMESH::RepaintCurrentView();
873 void Control( int theCommandID )
875 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
876 SALOME_ListIO selected;
878 aSel->selectedObjects( selected );
880 if( !selected.IsEmpty() ){
881 Handle(SALOME_InteractiveObject) anIO = selected.First();
884 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
885 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
886 switch ( theCommandID ){
888 aTitle = QObject::tr( "LENGTH_EDGES" );
889 aControl = SMESH_Actor::eLength;
892 aTitle = QObject::tr( "LENGTH2D_EDGES" );
893 aControl = SMESH_Actor::eLength2D;
896 aTitle = QObject::tr( "FREE_EDGES" );
897 aControl = SMESH_Actor::eFreeEdges;
900 aTitle = QObject::tr( "FREE_BORDERS" );
901 aControl = SMESH_Actor::eFreeBorders;
904 aTitle = QObject::tr( "MULTI_BORDERS" );
905 aControl = SMESH_Actor::eMultiConnection;
908 aTitle = QObject::tr( "FREE_NODES" );
909 aControl = SMESH_Actor::eFreeNodes;
912 aTitle = QObject::tr( "MULTI2D_BORDERS" );
913 aControl = SMESH_Actor::eMultiConnection2D;
916 aTitle = QObject::tr( "AREA_ELEMENTS" );
917 aControl = SMESH_Actor::eArea;
920 aTitle = QObject::tr( "TAPER_ELEMENTS" );
921 aControl = SMESH_Actor::eTaper;
924 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
925 aControl = SMESH_Actor::eAspectRatio;
928 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
929 aControl = SMESH_Actor::eAspectRatio3D;
932 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
933 aControl = SMESH_Actor::eMinimumAngle;
936 aTitle = QObject::tr( "WARP_ELEMENTS" );
937 aControl = SMESH_Actor::eWarping;
940 aTitle = QObject::tr( "SKEW_ELEMENTS" );
941 aControl = SMESH_Actor::eSkew;
944 aTitle = QObject::tr( "SMESH_VOLUME" );
945 aControl = SMESH_Actor::eVolume3D;
948 aTitle = QObject::tr( "FREE_FACES" );
949 aControl = SMESH_Actor::eFreeFaces;
952 anActor->SetControlMode(aControl);
953 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
954 SMESH::RepaintCurrentView();
961 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
962 MeshObjectType theType,
963 const QString theInTypeName,
964 QString & theOutTypeName)
966 SMESH_TypeFilter aTypeFilter( theType );
968 if( !theIO.IsNull() )
970 entry = theIO->getEntry();
971 LightApp_DataOwner owner( entry );
972 if ( aTypeFilter.isOk( &owner )) {
973 theOutTypeName = theInTypeName;
981 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
983 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
984 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
986 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
987 CORBA::String_var anID = aSComp->GetID().c_str();
988 if (!strcmp(anID.in(),theIO->getEntry()))
994 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
995 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
996 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
997 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
998 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1006 QString CheckHomogeneousSelection()
1008 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1009 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1010 SALOME_ListIO selected;
1012 aSel->selectedObjects( selected );
1014 QString RefType = CheckTypeObject(selected.First());
1015 SALOME_ListIteratorOfListIO It(selected);
1016 for ( ; It.More(); It.Next())
1018 Handle(SALOME_InteractiveObject) IObject = It.Value();
1019 QString Type = CheckTypeObject(IObject);
1020 if (Type.compare(RefType) != 0)
1021 return "Heterogeneous Selection";
1028 void SMESHGUI::OnEditDelete()
1030 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1031 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1032 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1034 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1035 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1036 _PTR(GenericAttribute) anAttr;
1037 _PTR(AttributeIOR) anIOR;
1039 int objectCount = 0;
1041 QString aParentComponent = QString::null;
1042 Handle(SALOME_InteractiveObject) anIO;
1043 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1045 anIO = anIt.Value();
1046 QString cur = anIO->getComponentDataType();
1047 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1049 // check if object is reference
1050 _PTR(SObject) aRefSObj;
1051 aNameList.append("\n - ");
1052 if ( aSO->ReferencedObject( aRefSObj ) ) {
1053 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1054 aNameList.append( aRefName );
1055 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1058 aNameList.append(anIO->getName());
1062 if( aParentComponent.isNull() )
1063 aParentComponent = cur;
1064 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1065 aParentComponent = "";
1068 if ( objectCount == 0 )
1069 return; // No Valid Objects Selected
1071 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1072 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1073 QObject::tr("ERR_ERROR"),
1074 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1077 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1078 if (SUIT_MessageBox::warning
1079 (SMESHGUI::desktop(),
1080 QObject::tr("SMESH_WRN_WARNING"),
1081 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1082 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1083 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1086 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1087 SUIT_ViewManager* vm = anApp->activeViewManager();
1088 int nbSf = vm->getViewsCount();
1090 SALOME_ListIteratorOfListIO It(selected);
1092 aStudyBuilder->NewCommand(); // There is a transaction
1093 for( ; It.More(); It.Next()){ // loop on selected IO's
1094 Handle(SALOME_InteractiveObject) IObject = It.Value();
1095 if(IObject->hasEntry()) {
1096 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1098 // disable removal of "SMESH" component object
1099 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1101 if ( engineIOR() == anIOR->Value().c_str() )
1104 //Check the referenced object
1105 _PTR(SObject) aRefSObject;
1106 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1107 aSO = aRefSObject; // Delete main Object instead of reference
1109 // put the whole hierarchy of sub-objects of the selected SO into a list and
1110 // then treat them all starting from the deepest objects (at list back)
1112 std::list< _PTR(SObject) > listSO;
1113 listSO.push_back( aSO );
1114 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1115 for ( ; itSO != listSO.end(); ++itSO ) {
1116 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1117 for (it->InitEx(false); it->More(); it->Next())
1118 listSO.push_back( it->Value() );
1121 // treat SO's in the list starting from the back
1123 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1124 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1125 _PTR(SObject) SO = *ritSO;
1126 if ( !SO ) continue;
1127 std::string anEntry = SO->GetID();
1129 /** Erase graphical object **/
1130 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1131 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1132 for(int i = 0; i < nbSf; i++){
1133 SUIT_ViewWindow *sf = aViews[i];
1134 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1135 SMESH::RemoveActor(sf,anActor);
1140 /** Remove an object from data structures **/
1141 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1142 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1143 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1144 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1145 aMesh->RemoveGroup( aGroup );
1147 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1148 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1149 aMesh->RemoveSubMesh( aSubMesh );
1151 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1153 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1156 IObject = new SALOME_InteractiveObject
1157 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1158 QString objType = CheckTypeObject(IObject);
1159 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1160 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1161 aStudyBuilder->RemoveObjectWithChildren( SO );
1163 else {// default action: remove SObject from the study
1164 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1165 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1167 aStudyBuilder->RemoveObjectWithChildren( SO );
1171 } /* listSO back loop */
1172 } /* IObject->hasEntry() */
1174 aStudyBuilder->CommitCommand();
1176 /* Clear any previous selection */
1178 aSel->setSelectedObjects( l1 );
1180 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1185 SMESHGUI_EXPORT CAM_Module* createModule()
1187 return new SMESHGUI();
1191 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1193 //=============================================================================
1197 //=============================================================================
1198 SMESHGUI::SMESHGUI() :
1199 SalomeApp_Module( "SMESH" ),
1200 LightApp_Module( "SMESH" )
1202 if ( CORBA::is_nil( myComponentSMESH ) )
1204 CORBA::Boolean anIsEmbeddedMode;
1205 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1207 // 0019923: EDF 765 SMESH : default values of hypothesis
1208 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1209 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1210 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1211 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1212 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1215 myActiveDialogBox = 0;
1216 myFilterLibraryDlg = 0;
1220 SMESH::GetFilterManager();
1221 SMESH::GetPattern();
1223 /* load resources for all available meshers */
1224 SMESH::InitAvailableHypotheses();
1227 //=============================================================================
1231 //=============================================================================
1232 SMESHGUI::~SMESHGUI()
1234 SMESH::GetFilterManager()->Destroy();
1235 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1238 //=============================================================================
1242 //=============================================================================
1243 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1245 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1247 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1252 bool SMESHGUI::automaticUpdate()
1254 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1258 return resMgr->booleanValue( "SMESH", "auto_update", false );
1261 //=============================================================================
1265 //=============================================================================
1266 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1268 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1271 //=============================================================================
1275 //=============================================================================
1276 SMESHGUI* SMESHGUI::GetSMESHGUI()
1278 SMESHGUI* smeshMod = 0;
1279 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1282 CAM_Module* module = app->module( "Mesh" );
1283 smeshMod = dynamic_cast<SMESHGUI*>( module );
1286 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1288 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1291 _PTR(Study) aStudy = study->studyDS();
1293 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1302 Standard_EXPORT SMESHGUI* GetComponentGUI()
1304 return SMESHGUI::GetSMESHGUI();
1308 //=============================================================================
1312 //=============================================================================
1313 void SMESHGUI::SetState(int aState)
1318 //=============================================================================
1322 //=============================================================================
1323 void SMESHGUI::ResetState()
1328 //=============================================================================
1332 //=============================================================================
1333 void SMESHGUI::EmitSignalDeactivateDialog()
1335 emit SignalDeactivateActiveDialog();
1338 //=============================================================================
1342 //=============================================================================
1343 void SMESHGUI::EmitSignalStudyFrameChanged()
1345 emit SignalStudyFrameChanged();
1348 //=============================================================================
1352 //=============================================================================
1353 void SMESHGUI::EmitSignalCloseAllDialogs()
1355 emit SignalCloseAllDialogs();
1358 //=============================================================================
1362 //=============================================================================
1363 void SMESHGUI::EmitSignalVisibilityChanged()
1365 emit SignalVisibilityChanged();
1368 //=============================================================================
1372 //=============================================================================
1373 QDialog *SMESHGUI::GetActiveDialogBox()
1375 return myActiveDialogBox;
1378 //=============================================================================
1382 //=============================================================================
1383 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1385 myActiveDialogBox = (QDialog *) aDlg;
1389 //=============================================================================
1393 //=============================================================================
1394 SUIT_Desktop* SMESHGUI::desktop()
1396 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1398 return app->desktop();
1403 //=============================================================================
1407 //=============================================================================
1408 SalomeApp_Study* SMESHGUI::activeStudy()
1410 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1412 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1417 //=============================================================================
1421 //=============================================================================
1422 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1424 /* Here the position is on the bottom right corner - 10 */
1425 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1427 SUIT_Desktop *PP = desktop();
1428 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1429 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1433 //=============================================================================
1437 //=============================================================================
1438 static int isStudyLocked(_PTR(Study) theStudy){
1439 return theStudy->GetProperties()->IsLocked();
1442 static bool checkLock(_PTR(Study) theStudy) {
1443 if (isStudyLocked(theStudy)) {
1444 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1445 QObject::tr("WRN_WARNING"),
1446 QObject::tr("WRN_STUDY_LOCKED") );
1452 //=======================================================================
1453 //function : CheckActiveStudyLocked
1455 //=======================================================================
1457 bool SMESHGUI::isActiveStudyLocked()
1459 _PTR(Study) aStudy = activeStudy()->studyDS();
1460 return checkLock( aStudy );
1463 //=============================================================================
1467 //=============================================================================
1468 bool SMESHGUI::OnGUIEvent( int theCommandID )
1470 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1474 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1475 SUIT_ResourceMgr* mgr = resourceMgr();
1479 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1480 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1483 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1484 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1486 //QAction* act = action( theCommandID );
1488 switch (theCommandID) {
1490 if(checkLock(aStudy)) break;
1498 if(checkLock(aStudy)) break;
1499 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1503 case 150: //MED FILE INFORMATION
1505 SALOME_ListIO selected;
1506 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1508 aSel->selectedObjects( selected );
1509 if( selected.Extent() )
1511 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1512 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1513 if ( !aMesh->_is_nil() )
1515 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1522 case 122: // EXPORT MED
1531 ::ExportMeshToFile(theCommandID);
1535 case 200: // SCALAR BAR
1537 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1538 SALOME_ListIO selected;
1540 aSel->selectedObjects( selected );
1542 if( selected.Extent() ) {
1543 Handle(SALOME_InteractiveObject) anIO = selected.First();
1544 if( anIO->hasEntry() ) {
1545 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1546 anActor->SetControlMode( SMESH_Actor::eNone );
1554 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1564 ::DisableAutoColor();
1567 case 1134: // Clipping
1568 case 1133: // Tranparency
1569 case 1132: // Colors / Size
1576 ::SetDisplayMode(theCommandID);
1579 //2D quadratic representation
1582 ::SetDisplayMode(theCommandID);
1586 case 216: // 0D elements
1589 case 219: // Volumes
1590 case 220: // All Entity
1591 ::SetDisplayEntity(theCommandID);
1594 case 221: // Orientation of faces
1596 LightApp_SelectionMgr* mgr = selectionMgr();
1597 SALOME_ListIO selected; mgr->selectedObjects( selected );
1599 SALOME_ListIteratorOfListIO it(selected);
1600 for( ; it.More(); it.Next()) {
1601 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1602 if(anIObject->hasEntry()) {
1603 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1604 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1613 if(checkLock(aStudy)) break;
1615 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1618 SMESH::UpdateView();
1620 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1621 SMESH::OnVisuException();
1623 catch (...) { // PAL16774 (Crash after display of many groups)
1624 SMESH::OnVisuException();
1628 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1629 aSel->selectedObjects( l );
1630 aSel->setSelectedObjects( l );
1635 case 301: // DISPLAY
1636 case 302: // DISPLAY ONLY
1638 SMESH::EDisplaing anAction;
1639 switch (theCommandID) {
1640 case 300: anAction = SMESH::eErase; break;
1641 case 301: anAction = SMESH::eDisplay; break;
1642 case 302: anAction = SMESH::eDisplayOnly; break;
1645 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1646 SALOME_ListIO sel_objects, to_process;
1648 aSel->selectedObjects( sel_objects );
1650 if( theCommandID==302 )
1651 startOperation( myEraseAll );
1653 extractContainers( sel_objects, to_process );
1656 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1660 SALOME_ListIteratorOfListIO It( to_process );
1661 for ( ; It.More(); It.Next()) {
1662 Handle(SALOME_InteractiveObject) IOS = It.Value();
1663 if (IOS->hasEntry()) {
1664 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1665 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1666 break; // PAL16774 (Crash after display of many groups)
1668 if (anAction == SMESH::eDisplayOnly)
1669 anAction = SMESH::eDisplay;
1674 // PAL13338 + PAL15161 -->
1675 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1676 SMESH::UpdateView();
1677 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1679 // PAL13338 + PAL15161 <--
1681 catch (...) { // PAL16774 (Crash after display of many groups)
1682 SMESH::OnVisuException();
1685 if (anAction == SMESH::eErase) {
1687 aSel->setSelectedObjects( l1 );
1690 aSel->setSelectedObjects( to_process );
1697 if(checkLock(aStudy)) break;
1700 EmitSignalDeactivateDialog();
1702 ( new SMESHGUI_NodesDlg( this ) )->show();
1705 SUIT_MessageBox::warning(desktop(),
1706 tr("SMESH_WRN_WARNING"),
1707 tr("SMESH_WRN_VIEWER_VTK"));
1712 case 2151: // FILTER
1716 EmitSignalDeactivateDialog();
1717 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1722 case 406: // MOVE NODE
1726 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1727 tr( "NOT_A_VTK_VIEWER" ) );
1731 if(checkLock(aStudy)) break;
1732 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1736 case 701: // COMPUTE MESH
1737 case 711: // PRECOMPUTE MESH
1738 case 712: // EVALUATE MESH
1739 case 713: // MESH ORDER
1741 if (checkLock(aStudy)) break;
1742 startOperation( theCommandID );
1746 case 702: // Create mesh
1747 case 703: // Create sub-mesh
1748 case 704: // Edit mesh/sub-mesh
1749 startOperation( theCommandID );
1751 case 710: // Build compound mesh
1753 if (checkLock(aStudy)) break;
1754 EmitSignalDeactivateDialog();
1755 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1759 case 407: // DIAGONAL INVERSION
1760 case 408: // Delete diagonal
1764 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1765 tr( "NOT_A_VTK_VIEWER" ) );
1769 if ( checkLock( aStudy ) )
1772 /*Standard_Boolean aRes;
1773 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1774 if ( aMesh->_is_nil() )
1776 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1777 tr( "SMESH_BAD_SELECTION" ) );
1781 EmitSignalDeactivateDialog();
1782 if ( theCommandID == 407 )
1783 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1785 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1788 case 409: // Change orientation
1789 case 410: // Union of triangles
1790 case 411: // Cutting of quadrangles
1794 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1795 tr( "NOT_A_VTK_VIEWER" ) );
1799 if ( checkLock( aStudy ) )
1802 EmitSignalDeactivateDialog();
1803 SMESHGUI_MultiEditDlg* aDlg = NULL;
1804 if ( theCommandID == 409 )
1805 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1806 else if ( theCommandID == 410 )
1807 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1809 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1814 case 412: // Smoothing
1816 if(checkLock(aStudy)) break;
1818 EmitSignalDeactivateDialog();
1819 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1822 SUIT_MessageBox::warning(desktop(),
1823 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1827 case 413: // Extrusion
1829 if (checkLock(aStudy)) break;
1831 EmitSignalDeactivateDialog();
1832 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1834 SUIT_MessageBox::warning(desktop(),
1835 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1839 case 414: // Revolution
1841 if(checkLock(aStudy)) break;
1843 EmitSignalDeactivateDialog();
1844 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1847 SUIT_MessageBox::warning(desktop(),
1848 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1852 case 415: // Pattern mapping
1854 if ( checkLock( aStudy ) )
1858 EmitSignalDeactivateDialog();
1859 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1862 SUIT_MessageBox::warning(desktop(),
1863 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1867 case 416: // Extrusion along a path
1869 if (checkLock(aStudy)) break;
1871 EmitSignalDeactivateDialog();
1872 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1874 SUIT_MessageBox::warning(desktop(),
1875 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1879 case 417: // Convert mesh to quadratic
1881 startOperation( 417 );
1882 /* if (checkLock(aStudy)) break;
1884 EmitSignalDeactivateDialog();
1885 new SMESHGUI_ConvToQuadDlg();
1887 SUIT_MessageBox::warning(desktop(),
1888 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1892 case 418: // create 2D mesh from 3D
1894 startOperation( 418 );
1897 case 806: // CREATE GEO GROUP
1899 startOperation( 806 );
1902 case 801: // CREATE GROUP
1906 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1907 tr( "NOT_A_VTK_VIEWER" ) );
1911 if(checkLock(aStudy)) break;
1912 EmitSignalDeactivateDialog();
1913 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1915 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1916 SALOME_ListIO selected;
1918 aSel->selectedObjects( selected );
1920 int nbSel = selected.Extent();
1922 // check if mesh is selected
1923 aMesh = SMESH::GetMeshByIO( selected.First() );
1925 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1930 case 802: // CONSTRUCT GROUP
1934 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1935 tr( "NOT_A_VTK_VIEWER" ) );
1939 if(checkLock(aStudy)) break;
1940 EmitSignalDeactivateDialog();
1942 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1943 SALOME_ListIO selected;
1945 aSel->selectedObjects( selected );
1947 int nbSel = selected.Extent();
1949 // check if submesh is selected
1950 Handle(SALOME_InteractiveObject) IObject = selected.First();
1951 if (IObject->hasEntry()) {
1952 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1954 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1955 if (!aSubMesh->_is_nil()) {
1957 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1958 // get submesh elements list by types
1959 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1960 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1961 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1962 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1963 // create group for each type o elements
1964 QString aName = IObject->getName();
1965 if (aNodes->length() > 0) {
1966 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1967 aGroup->Add(aNodes.inout());
1969 if (aEdges->length() > 0) {
1970 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1971 aGroup->Add(aEdges.inout());
1973 if (aFaces->length() > 0) {
1974 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1975 aGroup->Add(aFaces.inout());
1977 if (aVolumes->length() > 0) {
1978 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1979 aGroup->Add(aVolumes.inout());
1984 catch(const SALOME::SALOME_Exception & S_ex){
1985 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1992 SUIT_MessageBox::warning(desktop(),
1993 tr("SMESH_WRN_WARNING"),
1994 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1999 case 803: // EDIT GROUP
2003 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2004 tr( "NOT_A_VTK_VIEWER" ) );
2008 if(checkLock(aStudy)) break;
2009 EmitSignalDeactivateDialog();
2011 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2012 SALOME_ListIO selected;
2014 aSel->selectedObjects( selected );
2016 SALOME_ListIteratorOfListIO It (selected);
2017 int nbSelectedGroups = 0;
2018 for ( ; It.More(); It.Next() )
2020 SMESH::SMESH_GroupBase_var aGroup =
2021 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2022 if (!aGroup->_is_nil()) {
2024 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2028 if (nbSelectedGroups == 0)
2030 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2036 case 804: // Add elements to group
2038 if(checkLock(aStudy)) break;
2039 if (myState == 800) {
2040 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2041 if (aDlg) aDlg->onAdd();
2046 case 805: // Remove elements from group
2048 if(checkLock(aStudy)) break;
2049 if (myState == 800) {
2050 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2051 if (aDlg) aDlg->onRemove();
2056 case 815: // Edit GEOM GROUP as standalone
2060 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2061 tr( "NOT_A_VTK_VIEWER" ) );
2065 if(checkLock(aStudy)) break;
2066 EmitSignalDeactivateDialog();
2068 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2069 SALOME_ListIO selected;
2071 aSel->selectedObjects( selected );
2073 SALOME_ListIteratorOfListIO It (selected);
2074 for ( ; It.More(); It.Next() )
2076 SMESH::SMESH_GroupOnGeom_var aGroup =
2077 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2078 if (!aGroup->_is_nil()) {
2079 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2086 case 810: // Union Groups
2087 case 811: // Intersect groups
2088 case 812: // Cut groups
2092 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2093 tr( "NOT_A_VTK_VIEWER" ) );
2097 if ( checkLock( aStudy ) )
2100 EmitSignalDeactivateDialog();
2102 SMESHGUI_GroupOpDlg* aDlg = 0;
2103 if ( theCommandID == 810 )
2104 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2105 else if ( theCommandID == 811 )
2106 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2108 aDlg = new SMESHGUI_CutGroupsDlg( this );
2115 case 814: // Create groups of entities from existing groups of superior dimensions
2117 if ( checkLock( aStudy ) )
2120 EmitSignalDeactivateDialog();
2121 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2127 case 813: // Delete groups with their contents
2131 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2132 tr( "NOT_A_VTK_VIEWER" ) );
2136 if ( checkLock( aStudy ) )
2139 EmitSignalDeactivateDialog();
2141 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2145 case 900: // MESH INFOS
2147 EmitSignalDeactivateDialog();
2148 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2149 SALOME_ListIO selected;
2151 aSel->selectedObjects( selected );
2153 if ( selected.Extent() > 1 ) { // a dlg for each IO
2155 SALOME_ListIteratorOfListIO It (selected);
2156 for ( ; It.More(); It.Next() ) {
2157 IOs.Clear(); IOs.Append( It.Value() );
2158 aSel->setSelectedObjects( IOs );
2159 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2161 // restore selection
2162 aSel->setSelectedObjects( selected );
2165 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2169 case 902: // STANDARD MESH INFOS
2171 EmitSignalDeactivateDialog();
2172 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2173 SALOME_ListIO selected;
2175 aSel->selectedObjects( selected );
2177 if ( selected.Extent() > 1 ) { // a dlg for each IO
2179 SALOME_ListIteratorOfListIO It (selected);
2180 for ( ; It.More(); It.Next() ) {
2182 IOs.Append( It.Value() );
2183 aSel->setSelectedObjects( IOs );
2184 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2186 // restore selection
2187 aSel->setSelectedObjects( selected );
2190 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2194 case 903: // WHAT IS
2196 EmitSignalDeactivateDialog();
2197 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2201 case 904: // FIND ELEM
2203 startOperation( theCommandID );
2207 case 1100: // EDIT HYPOTHESIS
2209 if(checkLock(aStudy)) break;
2211 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2212 SALOME_ListIO selected;
2214 aSel->selectedObjects( selected );
2216 int nbSel = selected.Extent();
2219 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2220 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2222 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2223 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2224 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2225 if ( !aHypothesis->_is_nil() )
2228 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2229 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2231 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2242 case 1101: // RENAME
2244 if ( checkLock( aStudy ) )
2247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2248 SALOME_ListIO selected;
2250 aSel->selectedObjects( selected );
2252 bool isAny = false; // is there any appropriate object selected
2254 SALOME_ListIteratorOfListIO It( selected );
2255 for ( ; It.More(); It.Next() )
2257 Handle(SALOME_InteractiveObject) IObject = It.Value();
2258 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2259 _PTR(GenericAttribute) anAttr;
2260 _PTR(AttributeName) aName;
2263 if ( obj->FindAttribute(anAttr, "AttributeName") )
2266 QString newName = QString(aName->Value().c_str());
2268 // check type to prevent renaming of inappropriate objects
2269 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2270 if (aType == MESH || aType == GROUP ||
2271 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2272 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2273 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2274 aType == HYPOTHESIS || aType == ALGORITHM)
2277 newName = LightApp_NameDlg::getName(desktop(), newName);
2278 if ( !newName.isEmpty() )
2280 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2282 // update name of group object and its actor
2283 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2284 if( !aGroupObject->_is_nil() )
2286 aGroupObject->SetName( newName.toLatin1().data() );
2287 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2288 anActor->setName( newName.toLatin1().data() );
2299 SUIT_MessageBox::warning(desktop(),
2300 QObject::tr("SMESH_WRN_WARNING"),
2301 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2306 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2308 if(checkLock(aStudy)) break;
2309 SUIT_OverrideCursor wc;
2311 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2312 SALOME_ListIO selected;
2314 aSel->selectedObjects( selected, QString::null, false );
2316 SALOME_ListIteratorOfListIO It(selected);
2317 for (int i = 0; It.More(); It.Next(), i++) {
2318 Handle(SALOME_InteractiveObject) IObject = It.Value();
2319 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2322 aSel->setSelectedObjects( l1 );
2327 case 4009: // ELEM0D
2328 case 4010: // GEOM::EDGE
2329 case 4021: // TRIANGLE
2331 case 4023: // POLYGON
2335 if(checkLock(aStudy)) break;
2337 EmitSignalDeactivateDialog();
2338 SMDSAbs_ElementType type = SMDSAbs_Edge;
2340 switch (theCommandID) {
2341 case 4009: // ELEM0D
2342 type = SMDSAbs_0DElement; nbNodes = 1; break;
2343 case 4021: // TRIANGLE
2344 type = SMDSAbs_Face; nbNodes = 3; break;
2346 type = SMDSAbs_Face; nbNodes = 4; break;
2348 type = SMDSAbs_Volume; nbNodes = 4; break;
2349 case 4023: // POLYGON
2350 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2352 type = SMDSAbs_Volume; nbNodes = 8; break;
2353 case 4033: // POLYHEDRE
2354 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2357 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2360 SUIT_MessageBox::warning(desktop(),
2361 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2365 case 4033: // POLYHEDRON
2367 if(checkLock(aStudy)) break;
2369 EmitSignalDeactivateDialog();
2370 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2373 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2374 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2378 case 4034: // QUADRATIC EDGE
2379 case 4035: // QUADRATIC TRIANGLE
2380 case 4036: // QUADRATIC QUADRANGLE
2381 case 4037: // QUADRATIC TETRAHEDRON
2382 case 4038: // QUADRATIC PYRAMID
2383 case 4039: // QUADRATIC PENTAHEDRON
2384 case 4040: // QUADRATIC HEXAHEDRON
2386 if(checkLock(aStudy)) break;
2388 EmitSignalDeactivateDialog();
2391 switch (theCommandID) {
2393 type = QUAD_EDGE; break;
2395 type = QUAD_TRIANGLE; break;
2397 type = QUAD_QUADRANGLE; break;
2399 type = QUAD_TETRAHEDRON; break;
2401 type = QUAD_PYRAMID; break;
2403 type = QUAD_PENTAHEDRON; break;
2405 type = QUAD_HEXAHEDRON;
2409 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2412 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2413 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2417 case 4041: // REMOVES NODES
2419 if(checkLock(aStudy)) break;
2421 EmitSignalDeactivateDialog();
2422 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2425 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2426 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2430 case 4042: // REMOVES ELEMENTS
2432 if(checkLock(aStudy)) break;
2434 EmitSignalDeactivateDialog();
2435 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2439 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2440 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2444 case 4043: { // CLEAR_MESH
2446 if(checkLock(aStudy)) break;
2448 SALOME_ListIO selected;
2449 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2450 aSel->selectedObjects( selected );
2452 SUIT_OverrideCursor wc;
2453 SALOME_ListIteratorOfListIO It (selected);
2454 for ( ; It.More(); It.Next() )
2456 Handle(SALOME_InteractiveObject) IOS = It.Value();
2457 SMESH::SMESH_Mesh_var aMesh =
2458 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2459 if ( aMesh->_is_nil()) continue;
2461 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2463 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2464 SMESH::ModifiedMesh( aMeshSObj, false, true);
2465 // hide groups and submeshes
2466 _PTR(ChildIterator) anIter =
2467 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2468 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2470 _PTR(SObject) so = anIter->Value();
2471 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2474 catch (const SALOME::SALOME_Exception& S_ex){
2476 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2480 SMESH::UpdateView();
2484 case 4051: // RENUMBERING NODES
2486 if(checkLock(aStudy)) break;
2488 EmitSignalDeactivateDialog();
2489 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2493 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2498 case 4052: // RENUMBERING ELEMENTS
2500 if(checkLock(aStudy)) break;
2502 EmitSignalDeactivateDialog();
2503 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2507 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2508 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2512 case 4061: // TRANSLATION
2514 if(checkLock(aStudy)) break;
2516 EmitSignalDeactivateDialog();
2517 ( new SMESHGUI_TranslationDlg( this ) )->show();
2520 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2521 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2525 case 4062: // ROTATION
2527 if(checkLock(aStudy)) break;
2529 EmitSignalDeactivateDialog();
2530 ( new SMESHGUI_RotationDlg( this ) )->show();
2533 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2534 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2538 case 4063: // SYMMETRY
2540 if(checkLock(aStudy)) break;
2542 EmitSignalDeactivateDialog();
2543 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2546 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2547 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2551 case 4064: // SEWING
2553 if(checkLock(aStudy)) break;
2555 EmitSignalDeactivateDialog();
2556 ( new SMESHGUI_SewingDlg( this ) )->show();
2559 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2560 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2564 case 4065: // MERGE NODES
2566 if(checkLock(aStudy)) break;
2568 EmitSignalDeactivateDialog();
2569 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2572 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2573 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2577 case 4066: // MERGE EQUAL ELEMENTS
2579 if (checkLock(aStudy)) break;
2581 EmitSignalDeactivateDialog();
2582 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2584 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2585 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2590 case 4067: // MAKE MESH PASS THROUGH POINT
2591 startOperation( 4067 );
2594 case 5105: // Library of selection filters
2596 static QList<int> aTypes;
2597 if ( aTypes.isEmpty() )
2599 aTypes.append( SMESH::NODE );
2600 aTypes.append( SMESH::EDGE );
2601 aTypes.append( SMESH::FACE );
2602 aTypes.append( SMESH::VOLUME );
2604 if (!myFilterLibraryDlg)
2605 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2606 else if (myFilterLibraryDlg->isHidden())
2607 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2608 myFilterLibraryDlg->raise();
2612 case 6017: // CONTROLS
2630 LightApp_SelectionMgr* mgr = selectionMgr();
2631 SALOME_ListIO selected; mgr->selectedObjects( selected );
2633 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2634 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2636 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2637 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2638 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2639 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2640 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2641 ::Control( theCommandID );
2646 SUIT_MessageBox::warning(desktop(),
2647 tr( "SMESH_WRN_WARNING" ),
2648 tr( "SMESH_BAD_SELECTION" ) );
2652 SUIT_MessageBox::warning(desktop(),
2653 tr( "SMESH_WRN_WARNING" ),
2654 tr( "NOT_A_VTK_VIEWER" ) );
2659 LightApp_SelectionMgr* mgr = selectionMgr();
2660 SALOME_ListIO selected; mgr->selectedObjects( selected );
2662 SALOME_ListIteratorOfListIO it(selected);
2663 for( ; it.More(); it.Next()) {
2664 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2665 if(anIObject->hasEntry()) {
2666 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2667 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2675 LightApp_SelectionMgr* mgr = selectionMgr();
2676 SALOME_ListIO selected; mgr->selectedObjects( selected );
2678 if (selected.Extent() == 1) {
2679 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2680 if(anIObject->hasEntry())
2681 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2682 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2689 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2690 //updateObjBrowser();
2694 //=============================================================================
2698 //=============================================================================
2699 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2704 //=============================================================================
2708 //=============================================================================
2709 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2714 //=============================================================================
2718 //=============================================================================
2719 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2724 //=============================================================================
2725 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2726 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2728 //=============================================================================
2729 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2730 SUIT_ViewWindow* wnd )
2732 if(theIO->hasEntry()){
2733 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2734 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2738 //=======================================================================
2739 // function : createSMESHAction
2741 //=======================================================================
2742 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2745 QWidget* parent = application()->desktop();
2746 SUIT_ResourceMgr* resMgr = resourceMgr();
2748 if ( !icon_id.isEmpty() )
2749 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2751 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2752 if ( !pix.isNull() )
2753 icon = QIcon( pix );
2755 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2756 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2757 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2759 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2762 //=======================================================================
2763 // function : createPopupItem
2765 //=======================================================================
2766 void SMESHGUI::createPopupItem( const int id,
2767 const QString& clients,
2768 const QString& types,
2769 const QString& theRule,
2774 parentId = popupMgr()->actionId( action( pId ) );
2776 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2777 popupMgr()->insert( action( id ), parentId, 0 );
2779 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2780 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2781 QString rule = "(%1) and (%2) and (%3)";
2782 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2783 if( clients.isEmpty() )
2784 rule = rule.arg( QString( "true" ) );
2786 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2787 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2790 bool cont = myRules.contains( id );
2792 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2794 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2795 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2798 //=======================================================================
2799 // function : initialize
2801 //=======================================================================
2802 void SMESHGUI::initialize( CAM_Application* app )
2804 SalomeApp_Module::initialize( app );
2806 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2808 /* Automatic Update flag */
2809 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2811 // ----- create actions --------------
2813 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2814 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2815 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2816 createSMESHAction( 114, "NUM" );
2817 createSMESHAction( 121, "DAT" );
2818 createSMESHAction( 122, "MED" );
2819 createSMESHAction( 123, "UNV" );
2820 createSMESHAction( 140, "STL" );
2821 createSMESHAction( 124, "EXPORT_DAT" );
2822 createSMESHAction( 125, "EXPORT_MED" );
2823 createSMESHAction( 126, "EXPORT_UNV" );
2824 createSMESHAction( 141, "EXPORT_STL" );
2825 createSMESHAction( 150, "FILE_INFO" );
2826 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2827 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2828 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2829 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2830 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2831 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2832 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2833 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2834 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2835 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2836 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2837 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2838 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2839 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2840 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2841 createSMESHAction( 804, "ADD" );
2842 createSMESHAction( 805, "REMOVE" );
2843 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2844 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2845 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2846 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2847 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2848 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2849 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2850 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2851 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2852 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2853 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2854 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2855 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2856 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2857 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2858 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2859 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2860 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2861 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2862 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2863 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2864 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2865 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2866 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2867 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2868 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2869 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2870 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2871 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2872 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2873 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2874 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2875 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2876 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2877 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2878 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2879 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2880 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2881 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2882 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2883 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2884 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2885 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2886 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2887 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2888 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2889 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2890 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2891 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2892 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2893 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2894 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2895 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2896 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2897 createSMESHAction( 415, "MAP", "ICON_MAP" );
2898 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2899 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2900 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2901 createSMESHAction( 200, "RESET" );
2902 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2903 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2904 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2905 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2906 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2907 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2908 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2909 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2910 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2911 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2912 createSMESHAction( 220, "ALL" );
2913 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2915 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2916 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2918 createSMESHAction( 1100, "EDIT_HYPO" );
2919 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2920 createSMESHAction( 1102, "UNASSIGN" );
2921 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2922 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2923 createSMESHAction( 1131, "DISPMODE" );
2924 createSMESHAction( 1132, "COLORS" );
2925 createSMESHAction( 1133, "TRANSP" );
2926 createSMESHAction( 1134, "CLIP" );
2927 createSMESHAction( 1135, "DISP_ENT" );
2928 createSMESHAction( 1136, "AUTO_COLOR" );
2929 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2930 createSMESHAction( 2000, "CTRL" );
2932 createSMESHAction( 300, "ERASE" );
2933 createSMESHAction( 301, "DISPLAY" );
2934 createSMESHAction( 302, "DISPLAY_ONLY" );
2935 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2936 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2937 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2938 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2939 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2940 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2941 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2942 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2944 // ----- create menu --------------
2945 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2946 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2947 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2948 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2949 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2950 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2951 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2953 createMenu( separator(), fileId );
2955 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2956 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2957 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2958 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2959 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2960 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2962 createMenu( 111, importId, -1 );
2963 createMenu( 112, importId, -1 );
2964 createMenu( 113, importId, -1 );
2966 createMenu( 121, exportId, -1 );
2967 createMenu( 122, exportId, -1 );
2968 createMenu( 123, exportId, -1 );
2969 createMenu( 140, exportId, -1 ); // export to stl STL
2971 createMenu( separator(), fileId, 10 );
2973 createMenu( 33, editId, -1 );
2975 createMenu( 5105, toolsId, -1 );
2977 createMenu( 702, meshId, -1 ); // "Mesh" menu
2978 createMenu( 703, meshId, -1 );
2979 createMenu( 704, meshId, -1 );
2980 createMenu( 710, meshId, -1 );
2981 createMenu( separator(), meshId, -1 );
2982 createMenu( 701, meshId, -1 );
2983 createMenu( 711, meshId, -1 );
2984 createMenu( 712, meshId, -1 );
2985 createMenu( 713, meshId, -1 );
2986 createMenu( separator(), meshId, -1 );
2987 createMenu( 801, meshId, -1 );
2988 createMenu( 806, meshId, -1 );
2989 createMenu( 802, meshId, -1 );
2990 createMenu( 803, meshId, -1 );
2991 createMenu( 815, meshId, -1 );
2992 createMenu( separator(), meshId, -1 );
2993 createMenu( 810, meshId, -1 );
2994 createMenu( 811, meshId, -1 );
2995 createMenu( 812, meshId, -1 );
2996 createMenu( separator(), meshId, -1 );
2997 createMenu( 814, meshId, -1 );
2998 createMenu( separator(), meshId, -1 );
2999 createMenu( 813, meshId, -1 );
3000 createMenu( separator(), meshId, -1 );
3001 createMenu( 900, meshId, -1 );
3002 createMenu( 902, meshId, -1 );
3003 createMenu( 903, meshId, -1 );
3004 createMenu( 904, meshId, -1 );
3005 createMenu( separator(), meshId, -1 );
3007 createMenu( 6003, ctrlId, -1 );
3008 createMenu( 6001, ctrlId, -1 );
3009 createMenu( 6004, ctrlId, -1 );
3010 createMenu( separator(), ctrlId, -1 );
3011 createMenu( 6005, ctrlId, -1 );
3012 createMenu( 6002, ctrlId, -1 );
3013 createMenu( 6018, ctrlId, -1 );
3014 createMenu( 6019, ctrlId, -1 );
3015 createMenu( 6011, ctrlId, -1 );
3016 createMenu( 6012, ctrlId, -1 );
3017 createMenu( 6013, ctrlId, -1 );
3018 createMenu( 6014, ctrlId, -1 );
3019 createMenu( 6015, ctrlId, -1 );
3020 createMenu( 6016, ctrlId, -1 );
3021 createMenu( separator(), ctrlId, -1 );
3022 createMenu( 6017, ctrlId, -1 );
3023 createMenu( 6009, ctrlId, -1 );
3024 createMenu( 6021, ctrlId, -1 );
3025 createMenu( separator(), ctrlId, -1 );
3027 createMenu( 4000, addId, -1 );
3028 createMenu( 4009, addId, -1 );
3029 createMenu( 4010, addId, -1 );
3030 createMenu( 4021, addId, -1 );
3031 createMenu( 4022, addId, -1 );
3032 createMenu( 4023, addId, -1 );
3033 createMenu( 4031, addId, -1 );
3034 createMenu( 4032, addId, -1 );
3035 createMenu( 4033, addId, -1 );
3036 createMenu( separator(), addId, -1 );
3037 createMenu( 4034, addId, -1 );
3038 createMenu( 4035, addId, -1 );
3039 createMenu( 4036, addId, -1 );
3040 createMenu( 4037, addId, -1 );
3041 createMenu( 4038, addId, -1 );
3042 createMenu( 4039, addId, -1 );
3043 createMenu( 4040, addId, -1 );
3045 createMenu( 4041, removeId, -1 );
3046 createMenu( 4042, removeId, -1 );
3047 createMenu( 4043, removeId, -1 );
3049 createMenu( 4051, renumId, -1 );
3050 createMenu( 4052, renumId, -1 );
3052 createMenu( 4061, transfId, -1 );
3053 createMenu( 4062, transfId, -1 );
3054 createMenu( 4063, transfId, -1 );
3055 createMenu( 4064, transfId, -1 );
3056 createMenu( 4065, transfId, -1 );
3057 createMenu( 4066, transfId, -1 );
3059 createMenu( 406, modifyId, -1 );
3060 createMenu( 4067,modifyId, -1 );
3061 createMenu( 407, modifyId, -1 );
3062 createMenu( 408, modifyId, -1 );
3063 createMenu( 409, modifyId, -1 );
3064 createMenu( 410, modifyId, -1 );
3065 createMenu( 411, modifyId, -1 );
3066 createMenu( 412, modifyId, -1 );
3067 createMenu( 413, modifyId, -1 );
3068 createMenu( 416, modifyId, -1 );
3069 createMenu( 414, modifyId, -1 );
3070 createMenu( 415, modifyId, -1 );
3071 createMenu( 417, modifyId, -1 );
3072 createMenu( 418, modifyId, -1 );
3074 createMenu( 214, viewId, -1 );
3076 // ----- create toolbars --------------
3077 int meshTb = createTool( tr( "TB_MESH" ) ),
3078 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3079 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3080 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3081 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3083 createTool( 702, meshTb );
3084 createTool( 703, meshTb );
3085 createTool( 704, meshTb );
3086 createTool( 710, meshTb );
3087 createTool( separator(), meshTb );
3088 createTool( 701, meshTb );
3089 createTool( 711, meshTb );
3090 createTool( 712, meshTb );
3091 createTool( 713, meshTb );
3092 createTool( separator(), meshTb );
3093 createTool( 801, meshTb );
3094 createTool( 806, meshTb );
3095 createTool( 802, meshTb );
3096 createTool( 803, meshTb );
3097 //createTool( 815, meshTb );
3098 createTool( separator(), meshTb );
3099 createTool( 900, meshTb );
3100 createTool( 902, meshTb );
3101 createTool( 903, meshTb );
3102 createTool( 904, meshTb );
3103 createTool( separator(), meshTb );
3105 createTool( 6001, ctrlTb );
3106 createTool( 6003, ctrlTb );
3107 createTool( 6004, ctrlTb );
3108 createTool( separator(), ctrlTb );
3109 createTool( 6005, ctrlTb );
3110 createTool( 6002, ctrlTb );
3111 createTool( 6018, ctrlTb );
3112 createTool( 6019, ctrlTb );
3113 createTool( 6011, ctrlTb );
3114 createTool( 6012, ctrlTb );
3115 createTool( 6013, ctrlTb );
3116 createTool( 6014, ctrlTb );
3117 createTool( 6015, ctrlTb );
3118 createTool( 6016, ctrlTb );
3119 createTool( separator(), ctrlTb );
3120 createTool( 6017, ctrlTb );
3121 createTool( 6009, ctrlTb );
3122 createTool( 6021, ctrlTb );
3123 createTool( separator(), ctrlTb );
3125 createTool( 4000, addRemTb );
3126 createTool( 4009, addRemTb );
3127 createTool( 4010, addRemTb );
3128 createTool( 4021, addRemTb );
3129 createTool( 4022, addRemTb );
3130 createTool( 4023, addRemTb );
3131 createTool( 4031, addRemTb );
3132 createTool( 4032, addRemTb );
3133 createTool( 4033, addRemTb );
3134 createTool( separator(), addRemTb );
3135 createTool( 4034, addRemTb );
3136 createTool( 4035, addRemTb );
3137 createTool( 4036, addRemTb );
3138 createTool( 4037, addRemTb );
3139 createTool( 4038, addRemTb );
3140 createTool( 4039, addRemTb );
3141 createTool( 4040, addRemTb );
3142 createTool( separator(), addRemTb );
3143 createTool( 4041, addRemTb );
3144 createTool( 4042, addRemTb );
3145 createTool( 4043, addRemTb );
3146 createTool( separator(), addRemTb );
3147 createTool( 4051, addRemTb );
3148 createTool( 4052, addRemTb );
3149 createTool( separator(), addRemTb );
3150 createTool( 4061, addRemTb );
3151 createTool( 4062, addRemTb );
3152 createTool( 4063, addRemTb );
3153 createTool( 4064, addRemTb );
3154 createTool( 4065, addRemTb );
3155 createTool( 4066, addRemTb );
3156 createTool( separator(), addRemTb );
3158 createTool( 406, modifyTb );
3159 createTool( 4067,modifyTb );
3160 createTool( 407, modifyTb );
3161 createTool( 408, modifyTb );
3162 createTool( 409, modifyTb );
3163 createTool( 410, modifyTb );
3164 createTool( 411, modifyTb );
3165 createTool( 412, modifyTb );
3166 createTool( 413, modifyTb );
3167 createTool( 416, modifyTb );
3168 createTool( 414, modifyTb );
3169 createTool( 415, modifyTb );
3170 createTool( 417, modifyTb );
3171 createTool( 418, modifyTb );
3173 createTool( 214, dispModeTb );
3175 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3176 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3179 QString OB = "'ObjectBrowser'",
3180 View = "'" + SVTK_Viewer::Type() + "'",
3182 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3183 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3184 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3185 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3186 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3187 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3188 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3189 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3190 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3191 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3192 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3194 mesh_group = mesh + " " + subMesh + " " + group,
3195 hyp_alg = hypo + " " + algo;
3197 // popup for object browser
3199 isInvisible("not( isVisible )"),
3200 isEmpty("numberOfNodes = 0"),
3201 isNotEmpty("numberOfNodes <> 0"),
3203 // has nodes, edges, etc in VISIBLE! actor
3204 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3205 hasElems("(count( elemTypes ) > 0)"),
3206 hasDifferentElems("(count( elemTypes ) > 1)"),
3207 hasElems0d("({'Elem0d'} in elemTypes)"),
3208 hasEdges("({'Edge'} in elemTypes)"),
3209 hasFaces("({'Face'} in elemTypes)"),
3210 hasVolumes("({'Volume'} in elemTypes)");
3212 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3213 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3214 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3215 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3216 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3217 createPopupItem( 803, OB, group ); // EDIT_GROUP
3218 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3220 popupMgr()->insert( separator(), -1, 0 );
3221 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3222 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3223 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3224 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3225 createPopupItem( 214, OB, mesh_group ); // UPDATE
3226 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3227 createPopupItem( 902, OB, mesh ); // STD_INFO
3228 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3229 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3230 popupMgr()->insert( separator(), -1, 0 );
3231 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3232 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3233 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3234 popupMgr()->insert( separator(), -1, 0 );
3235 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3236 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3237 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3238 popupMgr()->insert( separator(), -1, 0 );
3239 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3240 popupMgr()->insert( separator(), -1, 0 );
3241 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3242 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3243 popupMgr()->insert( separator(), -1, 0 );
3245 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3246 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3248 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3249 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3250 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3251 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3252 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3253 popupMgr()->insert( separator(), -1, 0 );
3256 createPopupItem( 803, View, group ); // EDIT_GROUP
3257 createPopupItem( 804, View, elems ); // ADD
3258 createPopupItem( 805, View, elems ); // REMOVE
3260 popupMgr()->insert( separator(), -1, 0 );
3261 createPopupItem( 214, View, mesh_group ); // UPDATE
3262 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3263 createPopupItem( 902, View, mesh ); // STD_INFO
3264 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3265 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3266 popupMgr()->insert( separator(), -1, 0 );
3268 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3269 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3270 popupMgr()->insert( separator(), -1, 0 );
3273 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3274 QString aType = QString( "%1type in {%2}" ).arg( lc );
3275 aType = aType.arg( mesh_group );
3276 QString aMeshInVTK = aClient + "&&" + aType;
3278 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3279 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3280 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3282 //-------------------------------------------------
3284 //-------------------------------------------------
3285 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3287 popupMgr()->insert( action( 9010 ), anId, -1 );
3288 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3289 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3291 popupMgr()->insert( action( 9011 ), anId, -1 );
3292 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3293 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3295 popupMgr()->insert( separator(), -1, -1 );
3297 //-------------------------------------------------
3299 //-------------------------------------------------
3300 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3302 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3303 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3304 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3306 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3307 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3308 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3310 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3311 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3312 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3314 popupMgr()->insert( separator(), anId, -1 );
3316 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3317 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3318 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3320 //-------------------------------------------------
3322 //-------------------------------------------------
3323 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3325 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3327 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3328 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3329 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3331 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3332 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3333 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3335 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3336 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3337 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3339 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3340 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3341 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3343 popupMgr()->insert( separator(), anId, -1 );
3345 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3346 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3349 //-------------------------------------------------
3350 // Representation of the 2D Quadratic elements
3351 //-------------------------------------------------
3352 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3353 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3354 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3355 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3357 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3358 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3359 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3361 //-------------------------------------------------
3362 // Orientation of faces
3363 //-------------------------------------------------
3364 popupMgr()->insert( action( 221 ), -1, -1 );
3365 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3366 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3368 //-------------------------------------------------
3370 //-------------------------------------------------
3371 popupMgr()->insert( action( 1132 ), -1, -1 );
3372 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3374 //-------------------------------------------------
3376 //-------------------------------------------------
3377 popupMgr()->insert( action( 1133 ), -1, -1 );
3378 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3380 //-------------------------------------------------
3382 //-------------------------------------------------
3383 popupMgr()->insert( action( 1134 ), -1, -1 );
3384 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3386 popupMgr()->insert( separator(), -1, -1 );
3388 //-------------------------------------------------
3390 //-------------------------------------------------
3392 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3393 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3394 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3395 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3397 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3399 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3400 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3402 popupMgr()->insert( separator(), anId, -1 );
3404 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3405 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3406 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3408 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3409 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3410 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3412 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3413 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3414 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3416 popupMgr()->insert( separator(), anId, -1 );
3418 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3419 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3420 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3422 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3423 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3424 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3426 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3427 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3428 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3430 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3431 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3432 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3434 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3435 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3436 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3438 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3439 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3440 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3442 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3443 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3444 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3446 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3447 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3448 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3450 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3451 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3452 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3454 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3455 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3456 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3458 popupMgr()->insert( separator(), anId, -1 );
3460 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3461 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3462 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3464 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3465 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3466 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3468 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3469 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3470 QtxPopupMgr::VisibleRule );
3471 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3473 popupMgr()->insert( separator(), anId, -1 );
3475 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3476 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3478 popupMgr()->insert( separator(), -1, -1 );
3480 //-------------------------------------------------
3482 //-------------------------------------------------
3483 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3484 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3485 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3486 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3488 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3489 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3491 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3492 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3494 popupMgr()->insert( separator(), -1, -1 );
3496 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3497 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3500 //================================================================================
3502 * \brief Return true if SMESH or GEOM objects are selected.
3503 * Is called form LightApp_Module::activateModule() which clear selection if
3504 * not isSelectionCompatible()
3506 //================================================================================
3508 bool SMESHGUI::isSelectionCompatible()
3510 bool isCompatible = true;
3511 SALOME_ListIO selected;
3512 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3513 Sel->selectedObjects( selected );
3515 SALOME_ListIteratorOfListIO It( selected );
3516 for ( ; isCompatible && It.More(); It.Next())
3518 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3519 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3521 return isCompatible;
3525 bool SMESHGUI::reusableOperation( const int id )
3527 // compute, evaluate and precompute are not reusable operations
3528 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3531 bool SMESHGUI::activateModule( SUIT_Study* study )
3533 bool res = SalomeApp_Module::activateModule( study );
3535 setMenuShown( true );
3536 setToolShown( true );
3538 // Reset actions accelerator keys
3539 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3540 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3541 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3543 action( 33)->setEnabled(true); // Delete: Key_Delete
3544 action(1101)->setEnabled(true); // Rename: Key_F2
3546 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3547 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3548 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3549 if ( _PTR(Study) aStudy = s->studyDS()) {
3550 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3551 updateObjBrowser(); // objects can be removed
3557 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3559 setMenuShown( false );
3560 setToolShown( false );
3562 EmitSignalCloseAllDialogs();
3564 // Unset actions accelerator keys
3565 action(111)->setShortcut(QKeySequence()); // Import DAT
3566 action(112)->setShortcut(QKeySequence()); // Import UNV
3567 action(113)->setShortcut(QKeySequence()); // Import MED
3569 action( 33)->setEnabled(false); // Delete: Key_Delete
3570 action(1101)->setEnabled(false); // Rename: Key_F2
3572 return SalomeApp_Module::deactivateModule( study );
3575 void SMESHGUI::studyClosed( SUIT_Study* s )
3577 SMESH::RemoveVisuData( s->id() );
3578 SalomeApp_Module::studyClosed( s );
3581 void SMESHGUI::OnGUIEvent()
3583 const QObject* obj = sender();
3584 if ( !obj || !obj->inherits( "QAction" ) )
3586 int id = actionId((QAction*)obj);
3591 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3593 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3594 if ( CORBA::is_nil( myComponentSMESH ) )
3596 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3598 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3599 return aGUI.myComponentSMESH;
3602 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3603 return myComponentSMESH;
3606 QString SMESHGUI::engineIOR() const
3608 CORBA::ORB_var anORB = getApp()->orb();
3609 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3610 return QString( anIOR.in() );
3613 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3615 SalomeApp_Module::contextMenuPopup( client, menu, title );
3617 selectionMgr()->selectedObjects( lst );
3618 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3619 Handle(SALOME_InteractiveObject) io = lst.First();
3620 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3621 _PTR(Study) study = appStudy->studyDS();
3622 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3624 QString aName = QString( obj->GetName().c_str() );
3625 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3626 aName.remove( (aName.length() - 1), 1 );
3632 LightApp_Selection* SMESHGUI::createSelection() const
3634 return new SMESHGUI_Selection();
3637 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3639 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3640 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3643 void SMESHGUI::viewManagers( QStringList& list ) const
3645 list.append( SVTK_Viewer::Type() );
3648 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3650 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3651 SMESH::UpdateSelectionProp( this );
3654 void SMESHGUI::createPreferences()
3656 // General tab ------------------------------------------------------------------------
3657 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3659 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3660 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3662 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3663 setPreferenceProperty( qaGroup, "columns", 2 );
3664 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3665 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3666 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3667 setPreferenceProperty( prec, "min", 0 );
3668 setPreferenceProperty( prec, "max", 16 );
3670 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3671 setPreferenceProperty( dispgroup, "columns", 2 );
3672 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3674 modes.append( "Wireframe" );
3675 modes.append( "Shading" );
3676 modes.append( "Nodes" );
3677 modes.append( "Shrink" );
3678 QList<QVariant> indices;
3679 indices.append( 0 );
3680 indices.append( 1 );
3681 indices.append( 2 );
3682 indices.append( 3 );
3683 setPreferenceProperty( dispmode, "strings", modes );
3684 setPreferenceProperty( dispmode, "indexes", indices );
3686 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3687 setPreferenceProperty( arcgroup, "columns", 2 );
3688 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3689 QStringList quadraticModes;
3690 quadraticModes.append("Lines");
3691 quadraticModes.append("Arcs");
3693 indices.append( 0 );
3694 indices.append( 1 );
3695 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3696 setPreferenceProperty( quadraticmode, "indexes", indices );
3698 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3699 "SMESH", "max_angle" );
3700 setPreferenceProperty( maxAngle, "min", 1 );
3701 setPreferenceProperty( maxAngle, "max", 90 );
3705 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3706 setPreferenceProperty( exportgroup, "columns", 2 );
3707 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3708 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3710 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3711 setPreferenceProperty( computeGroup, "columns", 2 );
3712 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3714 modes.append( "Never" );
3715 modes.append( "Errors only" );
3716 modes.append( "Always" );
3718 indices.append( 0 );
3719 indices.append( 1 );
3720 indices.append( 2 );
3721 setPreferenceProperty( notifyMode, "strings", modes );
3722 setPreferenceProperty( notifyMode, "indexes", indices );
3724 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3725 setPreferenceProperty( segGroup, "columns", 2 );
3726 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3727 "SMESH", "segmentation" );
3728 setPreferenceProperty( segLen, "min", 1 );
3729 setPreferenceProperty( segLen, "max", 10000000 );
3730 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3731 "SMESH", "nb_segments_per_edge" );
3732 setPreferenceProperty( nbSeg, "min", 1 );
3733 setPreferenceProperty( nbSeg, "max", 10000000 );
3735 // Mesh tab ------------------------------------------------------------------------
3736 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3737 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3738 setPreferenceProperty( nodeGroup, "columns", 2 );
3740 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3741 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3743 setPreferenceProperty( nodeSz, "min", 1 );
3744 setPreferenceProperty( nodeSz, "max", 5 );
3746 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3747 setPreferenceProperty( elemGroup, "columns", 2 );
3749 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3750 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3751 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3752 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3754 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3755 //setPreferenceProperty( sp, "hstretch", 0 );
3756 //setPreferenceProperty( sp, "vstretch", 0 );
3758 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3759 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3760 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3761 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3762 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3763 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3764 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3766 setPreferenceProperty( size0d, "min", 1 );
3767 setPreferenceProperty( size0d, "max", 10 );
3769 setPreferenceProperty( sp, "hstretch", 0 );
3770 setPreferenceProperty( sp, "vstretch", 0 );
3772 setPreferenceProperty( elemW, "min", 1 );
3773 setPreferenceProperty( elemW, "max", 5 );
3775 setPreferenceProperty( shrink, "min", 0 );
3776 setPreferenceProperty( shrink, "max", 100 );
3778 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3779 setPreferenceProperty( orientGroup, "columns", 1 );
3781 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3782 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3784 setPreferenceProperty( orientScale, "min", 0.05 );
3785 setPreferenceProperty( orientScale, "max", 0.5 );
3786 setPreferenceProperty( orientScale, "step", 0.05 );
3788 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3790 // Selection tab ------------------------------------------------------------------------
3791 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3793 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3794 setPreferenceProperty( selGroup, "columns", 2 );
3796 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3797 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3798 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3800 setPreferenceProperty( selW, "min", 1 );
3801 setPreferenceProperty( selW, "max", 5 );
3803 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3804 setPreferenceProperty( preGroup, "columns", 2 );
3806 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3807 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3809 setPreferenceProperty( preW, "min", 1 );
3810 setPreferenceProperty( preW, "max", 5 );
3812 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3813 setPreferenceProperty( precSelGroup, "columns", 2 );
3815 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3816 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3817 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3819 // Scalar Bar tab ------------------------------------------------------------------------
3820 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3821 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3822 setPreferenceProperty( fontGr, "columns", 2 );
3824 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3825 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3827 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3828 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3830 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3831 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3833 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3834 setPreferenceProperty( numcol, "min", 2 );
3835 setPreferenceProperty( numcol, "max", 256 );
3837 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3838 setPreferenceProperty( numlab, "min", 2 );
3839 setPreferenceProperty( numlab, "max", 65 );
3841 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3842 setPreferenceProperty( orientGr, "columns", 2 );
3843 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3844 QStringList orients;
3845 orients.append( tr( "SMESH_VERTICAL" ) );
3846 orients.append( tr( "SMESH_HORIZONTAL" ) );
3847 indices.clear(); indices.append( 0 ); indices.append( 1 );
3848 setPreferenceProperty( orient, "strings", orients );
3849 setPreferenceProperty( orient, "indexes", indices );
3851 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3852 setPreferenceProperty( posVSizeGr, "columns", 2 );
3853 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3854 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3855 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3856 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3857 setPreferenceProperty( xv, "step", 0.1 );
3858 setPreferenceProperty( xv, "min", 0.0 );
3859 setPreferenceProperty( xv, "max", 1.0 );
3860 setPreferenceProperty( yv, "step", 0.1 );
3861 setPreferenceProperty( yv, "min", 0.0 );
3862 setPreferenceProperty( yv, "max", 1.0 );
3863 setPreferenceProperty( wv, "step", 0.1 );
3864 setPreferenceProperty( wv, "min", 0.0 );
3865 setPreferenceProperty( wv, "max", 1.0 );
3866 setPreferenceProperty( hv, "min", 0.0 );
3867 setPreferenceProperty( hv, "max", 1.0 );
3868 setPreferenceProperty( hv, "step", 0.1 );
3870 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3871 setPreferenceProperty( posHSizeGr, "columns", 2 );
3872 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3873 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3874 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3875 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3876 setPreferenceProperty( xv, "min", 0.0 );
3877 setPreferenceProperty( xv, "max", 1.0 );
3878 setPreferenceProperty( xv, "step", 0.1 );
3879 setPreferenceProperty( xh, "min", 0.0 );
3880 setPreferenceProperty( xh, "max", 1.0 );
3881 setPreferenceProperty( xh, "step", 0.1 );
3882 setPreferenceProperty( yh, "min", 0.0 );
3883 setPreferenceProperty( yh, "max", 1.0 );
3884 setPreferenceProperty( yh, "step", 0.1 );
3885 setPreferenceProperty( wh, "min", 0.0 );
3886 setPreferenceProperty( wh, "max", 1.0 );
3887 setPreferenceProperty( wh, "step", 0.1 );
3888 setPreferenceProperty( hh, "min", 0.0 );
3889 setPreferenceProperty( hh, "max", 1.0 );
3890 setPreferenceProperty( hh, "step", 0.1 );
3893 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3895 if( sect=="SMESH" ) {
3896 float sbX1,sbY1,sbW,sbH;
3897 float aTol = 1.00000009999999;
3898 std::string aWarning;
3899 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3900 if( name=="selection_object_color" || name=="selection_element_color" ||
3901 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3902 name=="selection_precision_node" || name=="selection_precision_element" ||
3903 name=="selection_precision_object")
3904 SMESH::UpdateSelectionProp( this );
3905 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3906 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3907 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3908 if(sbX1+sbW > aTol){
3909 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3912 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3913 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3916 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3917 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3918 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3919 if(sbY1+sbH > aTol){
3920 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3921 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3922 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3925 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3926 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3927 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3928 if(sbX1+sbW > aTol){
3929 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3932 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3933 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3936 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3937 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3938 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3939 if(sbY1+sbH > aTol){
3940 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3943 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3944 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3947 else if ( name == "segmentation" ) {
3948 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3949 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3951 else if ( name == "nb_segments_per_edge" ) {
3952 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3953 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3956 if(aWarning.size() != 0){
3957 aWarning += "The default values are applied instead.";
3958 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3959 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3960 QObject::tr(aWarning.c_str()));
3965 //================================================================================
3967 * \brief Update something in accordance with update flags
3968 * \param theFlags - update flags
3970 * Update viewer or/and object browser etc. in accordance with update flags ( see
3971 * LightApp_UpdateFlags enumeration ).
3973 //================================================================================
3974 void SMESHGUI::update( const int flags )
3976 if ( flags & UF_Viewer | flags & UF_Forced )
3977 SMESH::UpdateView();
3979 SalomeApp_Module::update( flags );
3982 //================================================================================
3984 * \brief Set default selection mode
3986 * SLOT called when operation commited. Sets default selection mode
3988 //================================================================================
3989 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3991 SVTK_ViewWindow* vtkWnd =
3992 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3994 vtkWnd->SetSelectionMode( ActorSelection );
3997 //================================================================================
3999 * \brief Set default selection mode
4001 * SLOT called when operation aborted. Sets default selection mode
4003 //================================================================================
4004 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4006 SVTK_ViewWindow* vtkWnd =
4007 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4009 vtkWnd->SetSelectionMode( ActorSelection );
4012 //================================================================================
4014 * \brief Creates operation with given identifier
4015 * \param id - identifier of operation to be started
4016 * \return Pointer on created operation or NULL if operation is not created
4018 * Virtual method redefined from the base class creates operation with given id.
4019 * It is called called automatically from startOperation method of base class.
4021 //================================================================================
4022 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4024 LightApp_Operation* op = 0;
4025 // to do : create operation here
4028 case 417: //convert to quadratic
4029 op = new SMESHGUI_ConvToQuadOp();
4031 case 418: // create 2D mesh as boundary on 3D
4032 op = new SMESHGUI_Make2DFrom3DOp();
4034 case 701: // Compute mesh
4035 op = new SMESHGUI_ComputeOp();
4037 case 702: // Create mesh
4038 op = new SMESHGUI_MeshOp( true, true );
4040 case 703: // Create sub-mesh
4041 op = new SMESHGUI_MeshOp( true, false );
4043 case 704: // Edit mesh/sub-mesh
4044 op = new SMESHGUI_MeshOp( false );
4046 case 711: // Precompute mesh
4047 op = new SMESHGUI_PrecomputeOp();
4049 case 712: // Evaluate mesh
4050 op = new SMESHGUI_EvaluateOp();
4052 case 713: // Evaluate mesh
4053 op = new SMESHGUI_MeshOrderOp();
4055 case 806: // Create group on geom
4056 op = new SMESHGUI_GroupOnShapeOp();
4058 case 904: // Find element
4059 op = new SMESHGUI_FindElemByPointOp();
4061 case 4067: // make mesh pass through point
4062 op = new SMESHGUI_MakeNodeAtPointOp();
4069 op = SalomeApp_Module::createOperation( id );
4073 //================================================================================
4075 * \brief Stops current operations and starts a given one
4076 * \param id - The id of the operation to start
4078 //================================================================================
4080 void SMESHGUI::switchToOperation(int id)
4082 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4083 activeStudy()->abortAllOperations();
4084 startOperation( id );
4087 LightApp_Displayer* SMESHGUI::displayer()
4090 myDisplayer = new SMESHGUI_Displayer( getApp() );
4094 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4097 int aTolerance = 64;
4098 int anIterations = 0;
4104 if( anIterations % aPeriod == 0 )
4107 if( aTolerance < 1 )
4110 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4112 aHue = (int)( 360.0 * rand() / RAND_MAX );
4113 //cout << "Hue = " << aHue << endl;
4115 //cout << "Auto colors : ";
4117 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4118 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4119 for( ; it != itEnd; ++it )
4121 SALOMEDS::Color anAutoColor = *it;
4122 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4125 aQColor.getHsv( &h, &s, &v );
4127 if( abs( h - aHue ) < aTolerance )
4130 //cout << "break (diff = " << abs( h - aHue ) << ")";
4140 //cout << "Hue of the returned color = " << aHue << endl;
4142 aColor.setHsv( aHue, 255, 255 );
4144 SALOMEDS::Color aSColor;
4145 aSColor.R = (double)aColor.red() / 255.0;
4146 aSColor.G = (double)aColor.green() / 255.0;
4147 aSColor.B = (double)aColor.blue() / 255.0;
4152 const char gSeparator = '_'; // character used to separate parameter names
4153 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4156 * \brief Store visual parameters
4158 * This method is called just before the study document is saved.
4159 * Store visual parameters in AttributeParameter attribue(s)
4161 void SMESHGUI::storeVisualParameters (int savePoint)
4163 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4164 if (!appStudy || !appStudy->studyDS())
4166 _PTR(Study) studyDS = appStudy->studyDS();
4168 // componentName is used for encoding of entries when storing them in IParameters
4169 std::string componentName = myComponentSMESH->ComponentDataType();
4170 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4171 //if (!aSComponent) return;
4174 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4175 componentName.c_str(),
4177 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4179 // viewers counters are used for storing view_numbers in IParameters
4182 // main cycle to store parameters of displayed objects
4183 QList<SUIT_ViewManager*> lst;
4184 QList<SUIT_ViewManager*>::Iterator it;
4185 getApp()->viewManagers(lst);
4186 for (it = lst.begin(); it != lst.end(); it++)
4188 SUIT_ViewManager* vman = *it;
4189 QString vType = vman->getType();
4191 // saving VTK actors properties
4192 if (vType == SVTK_Viewer::Type())
4194 QVector<SUIT_ViewWindow*> views = vman->getViews();
4195 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4197 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4199 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4200 vtkActorCollection* allActors = aCopy.GetActors();
4201 allActors->InitTraversal();
4202 while (vtkActor* actor = allActors->GetNextActor())
4204 if (actor->GetVisibility()) // store only visible actors
4206 SMESH_Actor* aSmeshActor = 0;
4207 if (actor->IsA("SMESH_Actor"))
4208 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4209 if (aSmeshActor && aSmeshActor->hasIO())
4211 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4214 // entry is "encoded" = it does NOT contain component adress,
4215 // since it is a subject to change on next component loading
4216 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4218 std::string param, vtkParam = vType.toLatin1().data();
4219 vtkParam += gSeparator;
4220 vtkParam += QString::number(vtkViewers).toLatin1().data();
4221 vtkParam += gSeparator;
4224 param = vtkParam + "Visibility";
4225 ip->setParameter(entry, param, "On");
4228 param = vtkParam + "Representation";
4229 ip->setParameter(entry, param, QString::number
4230 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4233 param = vtkParam + "IsShrunk";
4234 ip->setParameter(entry, param, QString::number
4235 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4237 // Displayed entities
4238 unsigned int aMode = aSmeshActor->GetEntityMode();
4239 bool isE = aMode & SMESH_Actor::eEdges;
4240 bool isF = aMode & SMESH_Actor::eFaces;
4241 bool isV = aMode & SMESH_Actor::eVolumes;
4243 QString modeStr ("e");
4244 modeStr += gDigitsSep; modeStr += QString::number(isE);
4245 modeStr += gDigitsSep; modeStr += "f";
4246 modeStr += gDigitsSep; modeStr += QString::number(isF);
4247 modeStr += gDigitsSep; modeStr += "v";
4248 modeStr += gDigitsSep; modeStr += QString::number(isV);
4250 param = vtkParam + "Entities";
4251 ip->setParameter(entry, param, modeStr.toLatin1().data());
4253 // Colors (surface:edge:)
4254 vtkFloatingPointType r, g, b;
4256 aSmeshActor->GetSufaceColor(r, g, b);
4257 QString colorStr ("surface");
4258 colorStr += gDigitsSep; colorStr += QString::number(r);
4259 colorStr += gDigitsSep; colorStr += QString::number(g);
4260 colorStr += gDigitsSep; colorStr += QString::number(b);
4262 aSmeshActor->GetBackSufaceColor(r, g, b);
4263 colorStr += gDigitsSep; colorStr += "backsurface";
4264 colorStr += gDigitsSep; colorStr += QString::number(r);
4265 colorStr += gDigitsSep; colorStr += QString::number(g);
4266 colorStr += gDigitsSep; colorStr += QString::number(b);
4268 aSmeshActor->GetEdgeColor(r, g, b);
4269 colorStr += gDigitsSep; colorStr += "edge";
4270 colorStr += gDigitsSep; colorStr += QString::number(r);
4271 colorStr += gDigitsSep; colorStr += QString::number(g);
4272 colorStr += gDigitsSep; colorStr += QString::number(b);
4274 aSmeshActor->GetNodeColor(r, g, b);
4275 colorStr += gDigitsSep; colorStr += "node";
4276 colorStr += gDigitsSep; colorStr += QString::number(r);
4277 colorStr += gDigitsSep; colorStr += QString::number(g);
4278 colorStr += gDigitsSep; colorStr += QString::number(b);
4280 param = vtkParam + "Colors";
4281 ip->setParameter(entry, param, colorStr.toLatin1().data());
4283 // Sizes of lines and points
4284 QString sizeStr ("line");
4285 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4286 sizeStr += gDigitsSep; sizeStr += "node";
4287 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4288 sizeStr += gDigitsSep; sizeStr += "shrink";
4289 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4291 param = vtkParam + "Sizes";
4292 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4295 param = vtkParam + "Opacity";
4296 ip->setParameter(entry, param,
4297 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4300 param = vtkParam + "ClippingPlane";
4301 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4303 ip->setParameter(entry, param, "Off");
4304 for (int ipl = 0; ipl < nPlanes; ipl++) {
4305 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4306 SMESH::Orientation anOrientation;
4308 vtkFloatingPointType anAngle[2];
4309 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4310 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4311 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4312 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4313 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4315 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4317 } // if (io->hasEntry())
4318 } // SMESH_Actor && hasIO
4320 } // while.. actors traversal
4324 } // if (SVTK view model)
4325 } // for (viewManagers)
4329 * \brief Restore visual parameters
4331 * This method is called after the study document is opened.
4332 * Restore visual parameters from AttributeParameter attribue(s)
4334 void SMESHGUI::restoreVisualParameters (int savePoint)
4336 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4337 if (!appStudy || !appStudy->studyDS())
4339 _PTR(Study) studyDS = appStudy->studyDS();
4341 // componentName is used for encoding of entries when storing them in IParameters
4342 std::string componentName = myComponentSMESH->ComponentDataType();
4343 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4344 //if (!aSComponent) return;
4347 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4348 componentName.c_str(),
4350 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4352 std::vector<std::string> entries = ip->getEntries();
4354 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4356 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4357 QString entry (ip->decodeEntry(*entIt).c_str());
4359 // Check that the entry corresponds to a real object in the Study
4360 // as the object may be deleted or modified after the visual state is saved.
4361 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4362 if (!so) continue; //Skip the not existent entry
4364 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4365 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4367 std::vector<std::string>::iterator namesIt = paramNames.begin();
4368 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4370 // actors are stored in a map after displaying of them for
4371 // quicker access in the future: map < viewID to actor >
4372 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4374 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4376 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4377 // '_' is used as separator and should not be used in viewer type or parameter names.
4378 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4379 if (lst.size() != 3)
4382 QString viewerTypStr = lst[0];
4383 QString viewIndexStr = lst[1];
4384 QString paramNameStr = lst[2];
4387 int viewIndex = viewIndexStr.toUInt(&ok);
4388 if (!ok) // bad conversion of view index to integer
4392 if (viewerTypStr == SVTK_Viewer::Type())
4394 SMESH_Actor* aSmeshActor = 0;
4395 if (vtkActors.IsBound(viewIndex))
4396 aSmeshActor = vtkActors.Find(viewIndex);
4398 if (paramNameStr == "Visibility")
4400 if (!aSmeshActor && displayer())
4402 QList<SUIT_ViewManager*> lst;
4403 getApp()->viewManagers(viewerTypStr, lst);
4405 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4406 if (viewIndex >= 0 && viewIndex < lst.count()) {
4407 SUIT_ViewManager* vman = lst.at(viewIndex);
4408 SUIT_ViewModel* vmodel = vman->getViewModel();
4409 // SVTK view model can be casted to SALOME_View
4410 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4412 // store displayed actor in a temporary map for quicker
4413 // access later when restoring other parameters
4414 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4415 vtkRenderer* Renderer = vtkView->getRenderer();
4416 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4417 vtkActorCollection* theActors = aCopy.GetActors();
4418 theActors->InitTraversal();
4419 bool isFound = false;
4420 vtkActor *ac = theActors->GetNextActor();
4421 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4422 if (ac->IsA("SMESH_Actor")) {
4423 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4424 if (aGeomAc->hasIO()) {
4425 Handle(SALOME_InteractiveObject) io =
4426 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4427 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4429 vtkActors.Bind(viewIndex, aGeomAc);
4436 } // if (paramNameStr == "Visibility")
4439 // the rest properties "work" with SMESH_Actor
4442 QString val ((*valuesIt).c_str());
4445 if (paramNameStr == "Representation") {
4446 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4449 else if (paramNameStr == "IsShrunk") {
4451 if (!aSmeshActor->IsShrunk())
4452 aSmeshActor->SetShrink();
4455 if (aSmeshActor->IsShrunk())
4456 aSmeshActor->UnShrink();
4459 // Displayed entities
4460 else if (paramNameStr == "Entities") {
4461 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4462 if (mode.count() == 6) {
4463 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4464 MESSAGE("Invalid order of data in Entities, must be: "
4465 "e:0/1:f:0/1:v:0/1");
4468 unsigned int aMode = aSmeshActor->GetEntityMode();
4469 unsigned int aNewMode =
4470 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4471 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4472 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4473 if (aNewMode != aMode)
4474 aSmeshActor->SetEntityMode(aNewMode);
4479 else if (paramNameStr == "Colors") {
4480 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4481 if (colors.count() == 16) {
4482 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4483 colors[8] != "edge" || colors[12] != "node") {
4484 MESSAGE("Invalid order of data in Colors, must be: "
4485 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4488 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4489 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4490 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4491 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4495 // Sizes of lines and points
4496 else if (paramNameStr == "Sizes") {
4497 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4498 if (sizes.count() == 6) {
4499 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4500 MESSAGE("Invalid order of data in Sizes, must be: "
4501 "line:int:node:int:shrink:float");
4504 aSmeshActor->SetLineWidth(sizes[1].toInt());
4505 aSmeshActor->SetNodeSize(sizes[3].toInt());
4506 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4511 else if (paramNameStr == "Opacity") {
4512 aSmeshActor->SetOpacity(val.toFloat());
4515 else if (paramNameStr.startsWith("ClippingPlane")) {
4516 cout << "$$$ ClippingPlane 1" << endl;
4517 if (paramNameStr == "ClippingPlane1" || val == "Off")
4518 aSmeshActor->RemoveAllClippingPlanes();
4520 cout << "$$$ ClippingPlane 2" << endl;
4521 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4522 if (vals.count() == 4) { // format check: 4 values
4523 cout << "$$$ ClippingPlane 3" << endl;
4524 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4525 double aDistance = vals[1].toFloat();
4526 vtkFloatingPointType anAngle[2];
4527 anAngle[0] = vals[2].toFloat();
4528 anAngle[1] = vals[3].toFloat();
4530 QList<SUIT_ViewManager*> lst;
4531 getApp()->viewManagers(viewerTypStr, lst);
4532 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4533 if (viewIndex >= 0 && viewIndex < lst.count()) {
4534 SUIT_ViewManager* vman = lst.at(viewIndex);
4535 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4536 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4537 anOrientation, aDistance, anAngle);
4542 } // if (aSmeshActor)
4543 } // other parameters than Visibility
4545 } // for names/parameters iterator
4546 } // for entries iterator
4548 // update all VTK views
4549 QList<SUIT_ViewManager*> lst;
4550 getApp()->viewManagers(lst);
4551 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4552 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4553 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4554 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4555 vtkView->getRenderer()->ResetCameraClippingRange();
4562 \brief Adds preferences for dfont of VTK viewer
4564 \param pIf group identifier
4565 \param param parameter
4566 \return identifier of preferences
4568 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4570 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4572 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4575 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4576 fam.append( tr( "SMESH_FONT_COURIER" ) );
4577 fam.append( tr( "SMESH_FONT_TIMES" ) );
4579 setPreferenceProperty( tfont, "fonts", fam );
4581 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4582 setPreferenceProperty( tfont, "features", f );
4588 \brief Actions after hypothesis edition
4589 Updates object browser after hypothesis edition
4591 void SMESHGUI::onHypothesisEdit( int result )
4593 updateObjBrowser( true );