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_NodesDlg.h"
29 #include "SMESHGUI_TransparencyDlg.h"
30 #include "SMESHGUI_ClippingDlg.h"
31 #include "SMESHGUI_GroupDlg.h"
32 #include "SMESHGUI_RemoveNodesDlg.h"
33 #include "SMESHGUI_RemoveElementsDlg.h"
34 #include "SMESHGUI_MeshInfosDlg.h"
35 #include "SMESHGUI_StandardMeshInfosDlg.h"
36 #include "SMESHGUI_WhatIsDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_MoveNodesDlg.h"
41 #include "SMESHGUI_AddMeshElementDlg.h"
42 #include "SMESHGUI_AddQuadraticElementDlg.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_SingleEditDlg.h"
46 #include "SMESHGUI_MultiEditDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_GroupOnShapeDlg.h"
49 #include "SMESHGUI_DeleteGroupDlg.h"
50 #include "SMESHGUI_SmoothingDlg.h"
51 #include "SMESHGUI_RenumberingDlg.h"
52 #include "SMESHGUI_ExtrusionDlg.h"
53 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
54 #include "SMESHGUI_RevolutionDlg.h"
55 #include "SMESHGUI_TranslationDlg.h"
56 #include "SMESHGUI_RotationDlg.h"
57 #include "SMESHGUI_SymmetryDlg.h"
58 #include "SMESHGUI_SewingDlg.h"
59 #include "SMESHGUI_EditMeshDlg.h"
60 #include "SMESHGUI_MeshPatternDlg.h"
61 #include "SMESHGUI_Selection.h"
62 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
63 #include "SMESHGUI_ConvToQuadOp.h"
64 #include "SMESHGUI_MeshOp.h"
65 #include "SMESHGUI_Displayer.h"
66 #include "SMESHGUI_MakeNodeAtPointDlg.h"
67 #include "SMESHGUI_BuildCompoundDlg.h"
68 #include "SMESHGUI_ComputeDlg.h"
69 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Make2DFrom3DOp.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include <SMESH_Client.hxx>
81 #include <SMESH_Actor.h>
82 #include <SMESH_TypeFilter.hxx>
84 // SALOME GUI includes
85 #include <SalomeApp_Tools.h>
86 #include <SalomeApp_Study.h>
87 #include <SalomeApp_Application.h>
88 #include <SalomeApp_CheckFileDlg.h>
90 #include <LightApp_DataOwner.h>
91 #include <LightApp_Preferences.h>
92 #include <LightApp_SelectionMgr.h>
93 #include <LightApp_UpdateFlags.h>
94 #include <LightApp_NameDlg.h>
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_ViewManager.h>
100 #include <VTKViewer_Algorithm.h>
102 #include <SUIT_MessageBox.h>
103 #include <SUIT_ResourceMgr.h>
104 #include <SUIT_FileDlg.h>
105 #include <SUIT_Desktop.h>
106 #include <SUIT_OverrideCursor.h>
107 #include <SUIT_Session.h>
109 #include <QtxPopupMgr.h>
110 #include <QtxFontEdit.h>
112 #include <SALOME_ListIO.hxx>
113 #include <SALOME_ListIteratorOfListIO.hxx>
116 #include <SALOMEconfig.h>
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
118 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
121 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
125 #include <boost/shared_ptr.hpp>
128 #include <vtkScalarBarActor.h>
129 #include <vtkCamera.h>
130 #include <vtkRenderer.h>
131 #include <vtkPlane.h>
133 // SALOME KERNEL includes
134 #include <SALOMEDS_Study.hxx>
135 #include <SALOMEDSClient_StudyBuilder.hxx>
136 #include <SALOMEDSClient_SComponent.hxx>
137 #include <SALOMEDSClient_ClientFactory.hxx>
138 #include <SALOMEDSClient_IParameters.hxx>
141 #include <Standard_ErrorHandler.hxx>
142 #include <NCollection_DataMap.hxx>
146 //=============================================================
147 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
150 void ExportMeshToFile(int theCommandID);
152 void SetDisplayMode(int theCommandID);
154 void SetDisplayEntity(int theCommandID);
156 void Control( int theCommandID );
160 //=============================================================
161 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
165 std::string myExtension;
167 if ( theCommandID == 113 ) {
168 filter.append( QObject::tr( "MED files (*.med)" ) );
169 filter.append( QObject::tr( "All files (*)" ) );
171 else if ( theCommandID == 112 ) {
172 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
174 else if ( theCommandID == 111 ) {
175 filter.append( QObject::tr( "DAT files (*.dat)" ) );
177 else if ( theCommandID == 115 ) {
178 filter.append( QObject::tr( "SAUV files (*.sauv *.sauve)" ) );
179 filter.append( QObject::tr( "All files (*)" ) );
182 QString anInitialPath = "";
183 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
184 anInitialPath = QDir::currentPath();
186 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
189 QObject::tr( "SMESH_IMPORT_MESH" ) );
190 if ( filenames.count() > 0 ) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 bool isEmpty = false;
196 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
197 QString filename = *it;
198 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
200 switch ( theCommandID ) {
203 // DAT format (currently unsupported)
204 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
205 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
211 aMeshes->length( 1 );
212 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
213 if ( aMeshes[0]->_is_nil() )
214 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
215 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
221 SMESH::DriverMED_ReadStatus res;
222 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
223 if ( res != SMESH::DRS_OK ) {
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
231 std::string file_in = filename.toLatin1().constData();
232 std::string file_tmp = file_in + ".med";
235 cmd = "%PYTHONBIN% ";
240 cmd += "from medutilities import convert ; convert(r'" + file_in + "', 'GIBI', 'MED', 1, r'" + file_tmp + "')";
244 SMESH::DriverMED_ReadStatus res;
245 aMeshes = theComponentMesh->CreateMeshesFromMED( file_tmp.c_str(), res );
246 if ( res != SMESH::DRS_OK ) {
247 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
248 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
251 cmd = "%PYTHONBIN% ";
256 cmd += "from medutilities import my_remove ; my_remove(r'" + file_tmp + "')";
263 catch ( const SALOME::SALOME_Exception& S_ex ) {
264 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
265 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
268 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
269 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
271 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
272 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
273 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
274 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
275 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
283 // update Object browser
284 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
286 // show Error message box if there were errors
287 if ( errors.count() > 0 ) {
288 SUIT_MessageBox::critical( SMESHGUI::desktop(),
289 QObject::tr( "SMESH_ERROR" ),
290 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
293 // show warning message box, if some imported mesh is empty
295 SUIT_MessageBox::warning( SMESHGUI::desktop(),
296 QObject::tr( "SMESH_WRN_WARNING" ),
297 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
302 void ExportMeshToFile( int theCommandID )
304 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
305 SALOME_ListIO selected;
307 aSel->selectedObjects( selected );
309 SMESH::SMESH_Mesh_var aMesh;
310 if(selected.Extent() == 1)
311 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
312 if ( aMesh->_is_nil() ) {
313 SUIT_MessageBox::warning( SMESHGUI::desktop(),
314 QObject::tr( "SMESH_WRN_WARNING" ),
315 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
319 Handle(SALOME_InteractiveObject) anIObject = selected.First();
320 QString aFilter, aTitle = QObject::tr("Export mesh");
321 QMap<QString, SMESH::MED_VERSION> aFilterMap;
322 QMap<QString, int> aFilterMapSTL;
323 switch ( theCommandID ) {
329 if (aMesh->HasDuplicatedGroupNamesMED()) {
330 int aRet = SUIT_MessageBox::warning
331 (SMESHGUI::desktop(),
332 QObject::tr("SMESH_WRN_WARNING"),
333 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
334 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
335 if (aRet != SUIT_MessageBox::Yes)
338 switch ( theCommandID ) {
343 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
344 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
345 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
346 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
352 aFilterMap.insert("SAUV files (*.sauv *.sauve)", SMESH::MED_V2_2 );
353 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
361 aFilter = QObject::tr("DAT files (*.dat)");
366 if (aMesh->NbPyramids()) {
367 int aRet = SUIT_MessageBox::warning
368 (SMESHGUI::desktop(),
369 QObject::tr("SMESH_WRN_WARNING"),
370 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
371 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
372 if (aRet != SUIT_MessageBox::Yes)
375 aFilter = QObject::tr("IDEAS files (*.unv)");
383 there must be check on others mesh elements not equal triangles
385 if (aMesh->NbTriangles() < 1) {
386 SUIT_MessageBox::warning
387 (SMESHGUI::desktop(),
388 QObject::tr("SMESH_WRN_WARNING"),
389 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
392 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
393 int aRet = SUIT_MessageBox::warning
394 (SMESHGUI::desktop(),
395 QObject::tr("SMESH_WRN_WARNING"),
396 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
397 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
398 if (aRet != SUIT_MessageBox::Yes)
402 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
403 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
411 SMESH::MED_VERSION aFormat;
412 // Init the parameter with the default value
413 bool aIsASCII_STL = true;
414 bool toCreateGroups = false;
415 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
417 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
419 QString anInitialPath = "";
420 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
421 anInitialPath = QDir::currentPath();
423 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141 && theCommandID != 142 && theCommandID != 143) {
424 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
425 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
426 aFilter, aTitle, false);
428 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
430 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
431 for ( ; it != aFilterMapSTL.end(); ++it )
432 filters.push_back( it.key() );
434 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
435 fd->setWindowTitle( aTitle );
436 fd->setFilters( filters );
437 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
438 if ( !anInitialPath.isEmpty() )
439 fd->setDirectory( anInitialPath );
440 fd->selectFile(anIObject->getName());
444 aFilename = fd->selectedFile();
445 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
450 else { // Export to MED
452 QString aDefaultFilter;
453 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
454 for ( ; it != aFilterMap.end(); ++it ) {
455 filters.push_back( it.key() );
456 if (it.value() == SMESH::MED_V2_2)
457 aDefaultFilter = it.key();
460 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
461 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
462 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
463 fd->setWindowTitle( aTitle );
464 fd->setFilters( filters );
465 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
466 fd->selectFilter(aDefaultFilter);
467 fd->SetChecked(toCreateGroups);
468 if ( !anInitialPath.isEmpty() )
469 fd->setDirectory( anInitialPath );
470 fd->selectFile(anIObject->getName());
474 aFilename = fd->selectedFile();
475 aFormat = aFilterMap[fd->selectedFilter()];
477 if ( !aFilename.isEmpty()
478 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
479 && aFormat==SMESH::MED_V2_1) {
480 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
481 QObject::tr("SMESH_WRN_WARNING"),
482 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
483 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
484 if (aRet != SUIT_MessageBox::Yes) {
489 toCreateGroups = fd->IsChecked();
492 if ( !aFilename.isEmpty() ) {
493 // Check whether the file already exists and delete it if yes
494 QFile aFile( aFilename );
495 if ( aFile.exists() )
497 SUIT_OverrideCursor wc;
500 bool Renumber = false;
501 // PAL 14172 : Check of we have to renumber or not from the preferences before export
503 Renumber= resMgr->booleanValue("SMESH","renumbering");
505 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
506 aMeshEditor->RenumberNodes();
507 aMeshEditor->RenumberElements();
508 if ( SMESHGUI::automaticUpdate() )
511 switch ( theCommandID ) {
514 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
519 std::string file_out = aFilename.toLatin1().data();
520 std::string file_tmp = file_out + "_tmp.med";
522 aMesh->ExportToMED( file_tmp.c_str(), toCreateGroups, aFormat );
524 cmd = "%PYTHONBIN% ";
529 cmd += "from medutilities import convert ; convert(r'" + file_tmp + "', 'MED', 'GIBI', 1, r'" + file_out + "')";
531 cmd += "from medutilities import my_remove ; my_remove(r'" + file_tmp + "')";
538 aMesh->ExportDAT( aFilename.toLatin1().data() );
542 aMesh->ExportUNV( aFilename.toLatin1().data() );
546 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
552 catch (const SALOME::SALOME_Exception& S_ex){
554 SUIT_MessageBox::warning(SMESHGUI::desktop(),
555 QObject::tr("SMESH_WRN_WARNING"),
556 QObject::tr("SMESH_EXPORT_FAILED"));
562 inline void InverseEntityMode(unsigned int& theOutputMode,
563 unsigned int theMode)
565 bool anIsNotPresent = ~theOutputMode & theMode;
567 theOutputMode |= theMode;
569 theOutputMode &= ~theMode;
572 void SetDisplayEntity(int theCommandID){
573 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
574 SALOME_ListIO selected;
576 aSel->selectedObjects( selected );
578 if(selected.Extent() >= 1){
579 SALOME_ListIteratorOfListIO It( selected );
580 for( ; It.More(); It.Next()){
581 Handle(SALOME_InteractiveObject) IObject = It.Value();
582 if(IObject->hasEntry()){
583 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
584 unsigned int aMode = anActor->GetEntityMode();
585 switch(theCommandID){
587 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
590 InverseEntityMode(aMode,SMESH_Actor::eEdges);
593 InverseEntityMode(aMode,SMESH_Actor::eFaces);
596 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
599 aMode = SMESH_Actor::eAllEntity;
603 anActor->SetEntityMode(aMode);
611 SALOME_ListIO selected;
612 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
616 LightApp_SelectionMgr* aSel = app->selectionMgr();
617 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
618 if( !aSel || !appStudy )
621 aSel->selectedObjects( selected );
622 if( selected.IsEmpty() )
625 Handle(SALOME_InteractiveObject) anIObject = selected.First();
627 _PTR(Study) aStudy = appStudy->studyDS();
628 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
629 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
630 if( aMainObject->_is_nil() )
633 aMainObject->SetAutoColor( true );
635 QList<SALOMEDS::Color> aReservedColors;
637 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
638 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
640 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
641 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
643 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
644 aGroupObject->SetColor( aColor );
645 aReservedColors.append( aColor );
647 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
648 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
650 if( aGroupObject->GetType() == SMESH::NODE )
651 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
652 else if( aGroupObject->GetType() == SMESH::EDGE )
653 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
655 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
659 SMESH::RepaintCurrentView();
662 void DisableAutoColor(){
663 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
664 SALOME_ListIO selected;
666 aSel->selectedObjects( selected );
668 if(selected.Extent()){
669 Handle(SALOME_InteractiveObject) anIObject = selected.First();
670 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
671 if ( !aMesh->_is_nil() ) {
672 aMesh->SetAutoColor( false );
677 void SetDisplayMode(int theCommandID){
678 SALOME_ListIO selected;
679 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
683 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
684 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
685 if( !aSel || !appStudy )
688 _PTR(Study) aStudy = appStudy->studyDS();
690 aSel->selectedObjects( selected );
692 if(selected.Extent() >= 1){
693 switch(theCommandID){
695 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
696 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
700 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
701 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
704 SALOME_ListIteratorOfListIO It( selected );
705 for( ; It.More(); It.Next()){
706 Handle(SALOME_InteractiveObject) IObject = It.Value();
707 if(IObject->hasEntry()){
708 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
709 switch(theCommandID){
711 anActor->SetRepresentation(SMESH_Actor::eEdge);
714 anActor->SetRepresentation(SMESH_Actor::eSurface);
717 if(anActor->IsShrunk())
720 anActor->SetShrink();
723 anActor->SetRepresentation(SMESH_Actor::ePoint);
726 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
727 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
730 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
731 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
734 vtkFloatingPointType color[3];
735 anActor->GetSufaceColor(color[0], color[1], color[2]);
736 int c0 = int (color[0] * 255);
737 int c1 = int (color[1] * 255);
738 int c2 = int (color[2] * 255);
739 QColor c(c0, c1, c2);
741 vtkFloatingPointType edgecolor[3];
742 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
743 c0 = int (edgecolor[0] * 255);
744 c1 = int (edgecolor[1] * 255);
745 c2 = int (edgecolor[2] * 255);
746 QColor e(c0, c1, c2);
748 vtkFloatingPointType backfacecolor[3];
749 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
750 c0 = int (backfacecolor[0] * 255);
751 c1 = int (backfacecolor[1] * 255);
752 c2 = int (backfacecolor[2] * 255);
753 QColor b(c0, c1, c2);
755 vtkFloatingPointType nodecolor[3];
756 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
757 c0 = int (nodecolor[0] * 255);
758 c1 = int (nodecolor[1] * 255);
759 c2 = int (nodecolor[2] * 255);
760 QColor n(c0, c1, c2);
762 int Edgewidth = (int)anActor->GetLineWidth();
765 int intValue = int(anActor->GetNodeSize());
766 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
768 SMESHGUI_Preferences_ColorDlg *aDlg =
769 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
770 aDlg->SetColor(1, c);
771 aDlg->SetColor(2, e);
772 aDlg->SetColor(3, n);
773 aDlg->SetColor(4, b);
774 aDlg->SetIntValue(1, Edgewidth);
775 aDlg->SetIntValue(2, intValue);
776 aDlg->SetIntValue(3, int(Shrink*100.));
778 QColor color = aDlg->GetColor(1);
779 QColor edgecolor = aDlg->GetColor(2);
780 QColor nodecolor = aDlg->GetColor(3);
781 QColor backfacecolor = aDlg->GetColor(4);
782 /* actor color and backface color */
783 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
784 vtkFloatingPointType (color.green()) / 255.,
785 vtkFloatingPointType (color.blue()) / 255.);
786 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
787 vtkFloatingPointType (backfacecolor.green()) / 255.,
788 vtkFloatingPointType (backfacecolor.blue()) / 255.);
791 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
792 vtkFloatingPointType (edgecolor.green()) / 255.,
793 vtkFloatingPointType (edgecolor.blue()) / 255.);
795 /* Shrink factor and size edges */
796 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
797 anActor->SetLineWidth(aDlg->GetIntValue(1));
799 /* Nodes color and size */
800 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
801 vtkFloatingPointType (nodecolor.green()) / 255.,
802 vtkFloatingPointType (nodecolor.blue()) / 255.);
803 anActor->SetNodeSize(aDlg->GetIntValue(2));
805 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
806 if( !aGroupObject->_is_nil() )
808 SMESH::ElementType anElementType = aGroupObject->GetType();
810 switch( anElementType )
812 case SMESH::NODE: aColor = nodecolor; break;
813 case SMESH::EDGE: aColor = edgecolor; break;
814 default: aColor = color; break;
817 SALOMEDS::Color aGroupColor;
818 aGroupColor.R = (float)aColor.red() / 255.0;
819 aGroupColor.G = (float)aColor.green() / 255.0;
820 aGroupColor.B = (float)aColor.blue() / 255.0;
821 aGroupObject->SetColor( aGroupColor );
831 SMESH::RepaintCurrentView();
835 void Control( int theCommandID )
837 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
838 SALOME_ListIO selected;
840 aSel->selectedObjects( selected );
842 if( !selected.IsEmpty() ){
843 Handle(SALOME_InteractiveObject) anIO = selected.First();
846 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
847 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
848 switch ( theCommandID ){
850 aTitle = QObject::tr( "LENGTH_EDGES" );
851 aControl = SMESH_Actor::eLength;
854 aTitle = QObject::tr( "LENGTH2D_EDGES" );
855 aControl = SMESH_Actor::eLength2D;
858 aTitle = QObject::tr( "FREE_EDGES" );
859 aControl = SMESH_Actor::eFreeEdges;
862 aTitle = QObject::tr( "FREE_BORDERS" );
863 aControl = SMESH_Actor::eFreeBorders;
866 aTitle = QObject::tr( "MULTI_BORDERS" );
867 aControl = SMESH_Actor::eMultiConnection;
870 aTitle = QObject::tr( "FREE_NODES" );
871 aControl = SMESH_Actor::eFreeNodes;
874 aTitle = QObject::tr( "MULTI2D_BORDERS" );
875 aControl = SMESH_Actor::eMultiConnection2D;
878 aTitle = QObject::tr( "AREA_ELEMENTS" );
879 aControl = SMESH_Actor::eArea;
882 aTitle = QObject::tr( "TAPER_ELEMENTS" );
883 aControl = SMESH_Actor::eTaper;
886 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
887 aControl = SMESH_Actor::eAspectRatio;
890 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
891 aControl = SMESH_Actor::eAspectRatio3D;
894 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
895 aControl = SMESH_Actor::eMinimumAngle;
898 aTitle = QObject::tr( "WARP_ELEMENTS" );
899 aControl = SMESH_Actor::eWarping;
902 aTitle = QObject::tr( "SKEW_ELEMENTS" );
903 aControl = SMESH_Actor::eSkew;
906 aTitle = QObject::tr( "SMESH_VOLUME" );
907 aControl = SMESH_Actor::eVolume3D;
910 aTitle = QObject::tr( "FREE_FACES" );
911 aControl = SMESH_Actor::eFreeFaces;
914 anActor->SetControlMode(aControl);
915 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
916 SMESH::RepaintCurrentView();
923 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
924 MeshObjectType theType,
925 const QString theInTypeName,
926 QString & theOutTypeName)
928 SMESH_TypeFilter aTypeFilter( theType );
930 if( !theIO.IsNull() )
932 entry = theIO->getEntry();
933 LightApp_DataOwner owner( entry );
934 if ( aTypeFilter.isOk( &owner )) {
935 theOutTypeName = theInTypeName;
943 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
945 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
946 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
948 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
949 CORBA::String_var anID = aSComp->GetID().c_str();
950 if (!strcmp(anID.in(),theIO->getEntry()))
956 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
957 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
958 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
959 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
960 CheckOIType ( theIO, GROUP, "Group", aTypeName )
968 QString CheckHomogeneousSelection()
970 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
971 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
972 SALOME_ListIO selected;
974 aSel->selectedObjects( selected );
976 QString RefType = CheckTypeObject(selected.First());
977 SALOME_ListIteratorOfListIO It(selected);
978 for ( ; It.More(); It.Next())
980 Handle(SALOME_InteractiveObject) IObject = It.Value();
981 QString Type = CheckTypeObject(IObject);
982 if (Type.compare(RefType) != 0)
983 return "Heterogeneous Selection";
990 void SMESHGUI::OnEditDelete()
992 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
993 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
994 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
996 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
997 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
998 _PTR(GenericAttribute) anAttr;
999 _PTR(AttributeIOR) anIOR;
1001 int objectCount = 0;
1003 QString aParentComponent = QString::null;
1004 Handle(SALOME_InteractiveObject) anIO;
1005 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1007 anIO = anIt.Value();
1008 QString cur = anIO->getComponentDataType();
1009 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1011 // check if object is reference
1012 _PTR(SObject) aRefSObj;
1013 aNameList.append("\n - ");
1014 if ( aSO->ReferencedObject( aRefSObj ) ) {
1015 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1016 aNameList.append( aRefName );
1017 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1020 aNameList.append(anIO->getName());
1024 if( aParentComponent.isNull() )
1025 aParentComponent = cur;
1026 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1027 aParentComponent = "";
1030 if ( objectCount == 0 )
1031 return; // No Valid Objects Selected
1033 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1034 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1035 QObject::tr("ERR_ERROR"),
1036 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1039 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1040 if (SUIT_MessageBox::warning
1041 (SMESHGUI::desktop(),
1042 QObject::tr("SMESH_WRN_WARNING"),
1043 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1044 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1045 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1048 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1049 SUIT_ViewManager* vm = anApp->activeViewManager();
1050 int nbSf = vm->getViewsCount();
1052 SALOME_ListIteratorOfListIO It(selected);
1054 aStudyBuilder->NewCommand(); // There is a transaction
1055 for( ; It.More(); It.Next()){ // loop on selected IO's
1056 Handle(SALOME_InteractiveObject) IObject = It.Value();
1057 if(IObject->hasEntry()) {
1058 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1060 // disable removal of "SMESH" component object
1061 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1063 if ( engineIOR() == anIOR->Value().c_str() )
1066 //Check the referenced object
1067 _PTR(SObject) aRefSObject;
1068 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1069 aSO = aRefSObject; // Delete main Object instead of reference
1071 // put the whole hierarchy of sub-objects of the selected SO into a list and
1072 // then treat them all starting from the deepest objects (at list back)
1074 std::list< _PTR(SObject) > listSO;
1075 listSO.push_back( aSO );
1076 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1077 for ( ; itSO != listSO.end(); ++itSO ) {
1078 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1079 for (it->InitEx(false); it->More(); it->Next())
1080 listSO.push_back( it->Value() );
1083 // treat SO's in the list starting from the back
1085 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1086 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1087 _PTR(SObject) SO = *ritSO;
1088 if ( !SO ) continue;
1089 std::string anEntry = SO->GetID();
1091 /** Erase graphical object **/
1092 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1093 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1094 for(int i = 0; i < nbSf; i++){
1095 SUIT_ViewWindow *sf = aViews[i];
1096 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1097 SMESH::RemoveActor(sf,anActor);
1102 /** Remove an object from data structures **/
1103 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1104 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1105 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1106 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1107 aMesh->RemoveGroup( aGroup );
1109 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1110 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1111 aMesh->RemoveSubMesh( aSubMesh );
1113 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1115 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1118 IObject = new SALOME_InteractiveObject
1119 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1120 QString objType = CheckTypeObject(IObject);
1121 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1122 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1123 aStudyBuilder->RemoveObjectWithChildren( SO );
1125 else {// default action: remove SObject from the study
1126 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1127 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1129 aStudyBuilder->RemoveObjectWithChildren( SO );
1133 } /* listSO back loop */
1134 } /* IObject->hasEntry() */
1136 aStudyBuilder->CommitCommand();
1138 /* Clear any previous selection */
1140 aSel->setSelectedObjects( l1 );
1142 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1147 SMESHGUI_EXPORT CAM_Module* createModule()
1149 return new SMESHGUI();
1153 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1155 //=============================================================================
1159 //=============================================================================
1160 SMESHGUI::SMESHGUI() :
1161 SalomeApp_Module( "SMESH" ),
1162 LightApp_Module( "SMESH" )
1164 if ( CORBA::is_nil( myComponentSMESH ) )
1166 CORBA::Boolean anIsEmbeddedMode;
1167 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1169 // 0019923: EDF 765 SMESH : default values of hypothesis
1170 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1171 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1172 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1173 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1174 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1177 myActiveDialogBox = 0;
1178 myFilterLibraryDlg = 0;
1182 SMESH::GetFilterManager();
1183 SMESH::GetPattern();
1185 /* load resources for all available meshers */
1186 SMESH::InitAvailableHypotheses();
1189 //=============================================================================
1193 //=============================================================================
1194 SMESHGUI::~SMESHGUI()
1196 SMESH::GetFilterManager()->Destroy();
1197 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1200 //=============================================================================
1204 //=============================================================================
1205 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1207 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1209 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1214 bool SMESHGUI::automaticUpdate()
1216 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1220 return resMgr->booleanValue( "SMESH", "auto_update", false );
1223 //=============================================================================
1227 //=============================================================================
1228 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1230 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1233 //=============================================================================
1237 //=============================================================================
1238 SMESHGUI* SMESHGUI::GetSMESHGUI()
1240 SMESHGUI* smeshMod = 0;
1241 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1244 CAM_Module* module = app->module( "Mesh" );
1245 smeshMod = dynamic_cast<SMESHGUI*>( module );
1248 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1250 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1253 _PTR(Study) aStudy = study->studyDS();
1255 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1264 Standard_EXPORT SMESHGUI* GetComponentGUI()
1266 return SMESHGUI::GetSMESHGUI();
1270 //=============================================================================
1274 //=============================================================================
1275 void SMESHGUI::SetState(int aState)
1280 //=============================================================================
1284 //=============================================================================
1285 void SMESHGUI::ResetState()
1290 //=============================================================================
1294 //=============================================================================
1295 void SMESHGUI::EmitSignalDeactivateDialog()
1297 emit SignalDeactivateActiveDialog();
1300 //=============================================================================
1304 //=============================================================================
1305 void SMESHGUI::EmitSignalStudyFrameChanged()
1307 emit SignalStudyFrameChanged();
1310 //=============================================================================
1314 //=============================================================================
1315 void SMESHGUI::EmitSignalCloseAllDialogs()
1317 emit SignalCloseAllDialogs();
1320 //=============================================================================
1324 //=============================================================================
1325 void SMESHGUI::EmitSignalVisibilityChanged()
1327 emit SignalVisibilityChanged();
1330 //=============================================================================
1334 //=============================================================================
1335 QDialog *SMESHGUI::GetActiveDialogBox()
1337 return myActiveDialogBox;
1340 //=============================================================================
1344 //=============================================================================
1345 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1347 myActiveDialogBox = (QDialog *) aDlg;
1351 //=============================================================================
1355 //=============================================================================
1356 SUIT_Desktop* SMESHGUI::desktop()
1358 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1360 return app->desktop();
1365 //=============================================================================
1369 //=============================================================================
1370 SalomeApp_Study* SMESHGUI::activeStudy()
1372 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1374 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1379 //=============================================================================
1383 //=============================================================================
1384 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1386 /* Here the position is on the bottom right corner - 10 */
1387 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1389 SUIT_Desktop *PP = desktop();
1390 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1391 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1395 //=============================================================================
1399 //=============================================================================
1400 static int isStudyLocked(_PTR(Study) theStudy){
1401 return theStudy->GetProperties()->IsLocked();
1404 static bool checkLock(_PTR(Study) theStudy) {
1405 if (isStudyLocked(theStudy)) {
1406 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1407 QObject::tr("WRN_WARNING"),
1408 QObject::tr("WRN_STUDY_LOCKED") );
1414 //=======================================================================
1415 //function : CheckActiveStudyLocked
1417 //=======================================================================
1419 bool SMESHGUI::isActiveStudyLocked()
1421 _PTR(Study) aStudy = activeStudy()->studyDS();
1422 return checkLock( aStudy );
1425 //=============================================================================
1429 //=============================================================================
1430 bool SMESHGUI::OnGUIEvent( int theCommandID )
1432 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1436 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1437 SUIT_ResourceMgr* mgr = resourceMgr();
1441 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1442 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1445 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1446 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1448 //QAction* act = action( theCommandID );
1450 switch (theCommandID) {
1452 if(checkLock(aStudy)) break;
1461 if(checkLock(aStudy)) break;
1462 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1466 case 150: //MED FILE INFORMATION
1468 SALOME_ListIO selected;
1469 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1471 aSel->selectedObjects( selected );
1472 if( selected.Extent() )
1474 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1475 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1476 if ( !aMesh->_is_nil() )
1478 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1485 case 122: // EXPORT MED
1496 ::ExportMeshToFile(theCommandID);
1500 case 200: // SCALAR BAR
1502 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1503 SALOME_ListIO selected;
1505 aSel->selectedObjects( selected );
1507 if( selected.Extent() ) {
1508 Handle(SALOME_InteractiveObject) anIO = selected.First();
1509 if( anIO->hasEntry() ) {
1510 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1511 anActor->SetControlMode( SMESH_Actor::eNone );
1519 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1529 ::DisableAutoColor();
1532 case 1134: // Clipping
1533 case 1133: // Tranparency
1534 case 1132: // Colors / Size
1541 ::SetDisplayMode(theCommandID);
1544 //2D quadratic representation
1547 ::SetDisplayMode(theCommandID);
1551 case 216: // 0D elements
1554 case 219: // Volumes
1555 case 220: // All Entity
1556 ::SetDisplayEntity(theCommandID);
1559 case 221: // Orientation of faces
1561 LightApp_SelectionMgr* mgr = selectionMgr();
1562 SALOME_ListIO selected; mgr->selectedObjects( selected );
1564 SALOME_ListIteratorOfListIO it(selected);
1565 for( ; it.More(); it.Next()) {
1566 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1567 if(anIObject->hasEntry()) {
1568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1569 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1578 if(checkLock(aStudy)) break;
1580 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1583 SMESH::UpdateView();
1585 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1586 SMESH::OnVisuException();
1588 catch (...) { // PAL16774 (Crash after display of many groups)
1589 SMESH::OnVisuException();
1593 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1594 aSel->selectedObjects( l );
1595 aSel->setSelectedObjects( l );
1600 case 301: // DISPLAY
1601 case 302: // DISPLAY ONLY
1603 SMESH::EDisplaing anAction;
1604 switch (theCommandID) {
1605 case 300: anAction = SMESH::eErase; break;
1606 case 301: anAction = SMESH::eDisplay; break;
1607 case 302: anAction = SMESH::eDisplayOnly; break;
1610 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1611 SALOME_ListIO sel_objects, to_process;
1613 aSel->selectedObjects( sel_objects );
1615 if( theCommandID==302 )
1616 startOperation( myEraseAll );
1618 extractContainers( sel_objects, to_process );
1621 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1625 SALOME_ListIteratorOfListIO It( to_process );
1626 for ( ; It.More(); It.Next()) {
1627 Handle(SALOME_InteractiveObject) IOS = It.Value();
1628 if (IOS->hasEntry()) {
1629 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1630 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1631 break; // PAL16774 (Crash after display of many groups)
1633 if (anAction == SMESH::eDisplayOnly)
1634 anAction = SMESH::eDisplay;
1639 // PAL13338 + PAL15161 -->
1640 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1641 SMESH::UpdateView();
1642 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1644 // PAL13338 + PAL15161 <--
1646 catch (...) { // PAL16774 (Crash after display of many groups)
1647 SMESH::OnVisuException();
1650 if (anAction == SMESH::eErase) {
1652 aSel->setSelectedObjects( l1 );
1655 aSel->setSelectedObjects( to_process );
1662 if(checkLock(aStudy)) break;
1665 EmitSignalDeactivateDialog();
1667 ( new SMESHGUI_NodesDlg( this ) )->show();
1670 SUIT_MessageBox::warning(desktop(),
1671 tr("SMESH_WRN_WARNING"),
1672 tr("SMESH_WRN_VIEWER_VTK"));
1677 case 2151: // FILTER
1681 EmitSignalDeactivateDialog();
1682 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1687 case 406: // MOVE NODE
1691 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1692 tr( "NOT_A_VTK_VIEWER" ) );
1696 if(checkLock(aStudy)) break;
1697 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1701 case 701: // COMPUTE MESH
1702 case 711: // PRECOMPUTE MESH
1703 case 712: // EVALUATE MESH
1705 if (checkLock(aStudy)) break;
1706 startOperation( theCommandID );
1710 case 702: // Create mesh
1711 case 703: // Create sub-mesh
1712 case 704: // Edit mesh/sub-mesh
1713 startOperation( theCommandID );
1715 case 710: // Build compound mesh
1717 if (checkLock(aStudy)) break;
1718 EmitSignalDeactivateDialog();
1719 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1723 case 407: // DIAGONAL INVERSION
1724 case 408: // Delete diagonal
1728 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1729 tr( "NOT_A_VTK_VIEWER" ) );
1733 if ( checkLock( aStudy ) )
1736 /*Standard_Boolean aRes;
1737 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1738 if ( aMesh->_is_nil() )
1740 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1741 tr( "SMESH_BAD_SELECTION" ) );
1745 EmitSignalDeactivateDialog();
1746 if ( theCommandID == 407 )
1747 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1749 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1752 case 409: // Change orientation
1753 case 410: // Union of triangles
1754 case 411: // Cutting of quadrangles
1758 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1759 tr( "NOT_A_VTK_VIEWER" ) );
1763 if ( checkLock( aStudy ) )
1766 EmitSignalDeactivateDialog();
1767 SMESHGUI_MultiEditDlg* aDlg = NULL;
1768 if ( theCommandID == 409 )
1769 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1770 else if ( theCommandID == 410 )
1771 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1773 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1778 case 412: // Smoothing
1780 if(checkLock(aStudy)) break;
1782 EmitSignalDeactivateDialog();
1783 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1786 SUIT_MessageBox::warning(desktop(),
1787 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1791 case 413: // Extrusion
1793 if (checkLock(aStudy)) break;
1795 EmitSignalDeactivateDialog();
1796 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1798 SUIT_MessageBox::warning(desktop(),
1799 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1803 case 414: // Revolution
1805 if(checkLock(aStudy)) break;
1807 EmitSignalDeactivateDialog();
1808 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1811 SUIT_MessageBox::warning(desktop(),
1812 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1816 case 415: // Pattern mapping
1818 if ( checkLock( aStudy ) )
1822 EmitSignalDeactivateDialog();
1823 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1826 SUIT_MessageBox::warning(desktop(),
1827 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1831 case 416: // Extrusion along a path
1833 if (checkLock(aStudy)) break;
1835 EmitSignalDeactivateDialog();
1836 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1838 SUIT_MessageBox::warning(desktop(),
1839 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1843 case 417: // Convert mesh to quadratic
1845 startOperation( 417 );
1846 /* if (checkLock(aStudy)) break;
1848 EmitSignalDeactivateDialog();
1849 new SMESHGUI_ConvToQuadDlg();
1851 SUIT_MessageBox::warning(desktop(),
1852 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1856 case 418: // create 2D mesh from 3D
1858 startOperation( 418 );
1861 case 806: // CREATE GEO GROUP
1863 startOperation( 806 );
1866 case 801: // CREATE GROUP
1870 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1871 tr( "NOT_A_VTK_VIEWER" ) );
1875 if(checkLock(aStudy)) break;
1876 EmitSignalDeactivateDialog();
1877 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1879 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1880 SALOME_ListIO selected;
1882 aSel->selectedObjects( selected );
1884 int nbSel = selected.Extent();
1886 // check if mesh is selected
1887 aMesh = SMESH::GetMeshByIO( selected.First() );
1889 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1894 case 802: // CONSTRUCT GROUP
1898 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1899 tr( "NOT_A_VTK_VIEWER" ) );
1903 if(checkLock(aStudy)) break;
1904 EmitSignalDeactivateDialog();
1906 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1907 SALOME_ListIO selected;
1909 aSel->selectedObjects( selected );
1911 int nbSel = selected.Extent();
1913 // check if submesh is selected
1914 Handle(SALOME_InteractiveObject) IObject = selected.First();
1915 if (IObject->hasEntry()) {
1916 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1918 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1919 if (!aSubMesh->_is_nil()) {
1921 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1922 // get submesh elements list by types
1923 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1924 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1925 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1926 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1927 // create group for each type o elements
1928 QString aName = IObject->getName();
1929 if (aNodes->length() > 0) {
1930 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1931 aGroup->Add(aNodes.inout());
1933 if (aEdges->length() > 0) {
1934 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1935 aGroup->Add(aEdges.inout());
1937 if (aFaces->length() > 0) {
1938 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1939 aGroup->Add(aFaces.inout());
1941 if (aVolumes->length() > 0) {
1942 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1943 aGroup->Add(aVolumes.inout());
1948 catch(const SALOME::SALOME_Exception & S_ex){
1949 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1956 SUIT_MessageBox::warning(desktop(),
1957 tr("SMESH_WRN_WARNING"),
1958 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1963 case 803: // EDIT GROUP
1967 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1968 tr( "NOT_A_VTK_VIEWER" ) );
1972 if(checkLock(aStudy)) break;
1973 EmitSignalDeactivateDialog();
1975 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1976 SALOME_ListIO selected;
1978 aSel->selectedObjects( selected );
1980 SALOME_ListIteratorOfListIO It (selected);
1981 int nbSelectedGroups = 0;
1982 for ( ; It.More(); It.Next() )
1984 SMESH::SMESH_GroupBase_var aGroup =
1985 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1986 if (!aGroup->_is_nil()) {
1988 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1992 if (nbSelectedGroups == 0)
1994 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2000 case 804: // Add elements to group
2002 if(checkLock(aStudy)) break;
2003 if (myState == 800) {
2004 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2005 if (aDlg) aDlg->onAdd();
2010 case 805: // Remove elements from group
2012 if(checkLock(aStudy)) break;
2013 if (myState == 800) {
2014 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2015 if (aDlg) aDlg->onRemove();
2020 case 815: // Edit GEOM GROUP as standalone
2024 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2025 tr( "NOT_A_VTK_VIEWER" ) );
2029 if(checkLock(aStudy)) break;
2030 EmitSignalDeactivateDialog();
2032 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2033 SALOME_ListIO selected;
2035 aSel->selectedObjects( selected );
2037 SALOME_ListIteratorOfListIO It (selected);
2038 for ( ; It.More(); It.Next() )
2040 SMESH::SMESH_GroupOnGeom_var aGroup =
2041 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2042 if (!aGroup->_is_nil()) {
2043 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2050 case 810: // Union Groups
2051 case 811: // Intersect groups
2052 case 812: // Cut groups
2056 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2057 tr( "NOT_A_VTK_VIEWER" ) );
2061 if ( checkLock( aStudy ) )
2064 EmitSignalDeactivateDialog();
2066 SMESHGUI_GroupOpDlg* aDlg = 0;
2067 if ( theCommandID == 810 )
2068 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2069 else if ( theCommandID == 811 )
2070 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2072 aDlg = new SMESHGUI_CutGroupsDlg( this );
2079 case 814: // Create groups of entities from existing groups of superior dimensions
2081 if ( checkLock( aStudy ) )
2084 EmitSignalDeactivateDialog();
2085 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2091 case 813: // Delete groups with their contents
2095 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2096 tr( "NOT_A_VTK_VIEWER" ) );
2100 if ( checkLock( aStudy ) )
2103 EmitSignalDeactivateDialog();
2105 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2109 case 900: // MESH INFOS
2111 EmitSignalDeactivateDialog();
2112 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2113 SALOME_ListIO selected;
2115 aSel->selectedObjects( selected );
2117 if ( selected.Extent() > 1 ) { // a dlg for each IO
2119 SALOME_ListIteratorOfListIO It (selected);
2120 for ( ; It.More(); It.Next() ) {
2121 IOs.Clear(); IOs.Append( It.Value() );
2122 aSel->setSelectedObjects( IOs );
2123 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2125 // restore selection
2126 aSel->setSelectedObjects( selected );
2129 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2133 case 902: // STANDARD MESH INFOS
2135 EmitSignalDeactivateDialog();
2136 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2137 SALOME_ListIO selected;
2139 aSel->selectedObjects( selected );
2141 if ( selected.Extent() > 1 ) { // a dlg for each IO
2143 SALOME_ListIteratorOfListIO It (selected);
2144 for ( ; It.More(); It.Next() ) {
2146 IOs.Append( It.Value() );
2147 aSel->setSelectedObjects( IOs );
2148 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2150 // restore selection
2151 aSel->setSelectedObjects( selected );
2154 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2158 case 903: // WHAT IS
2160 EmitSignalDeactivateDialog();
2161 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2165 case 1100: // EDIT HYPOTHESIS
2167 if(checkLock(aStudy)) break;
2169 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2170 SALOME_ListIO selected;
2172 aSel->selectedObjects( selected );
2174 int nbSel = selected.Extent();
2177 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2178 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2180 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2181 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2182 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2183 if ( !aHypothesis->_is_nil() )
2186 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2187 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2189 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2200 case 1101: // RENAME
2202 if ( checkLock( aStudy ) )
2205 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2206 SALOME_ListIO selected;
2208 aSel->selectedObjects( selected );
2210 bool isAny = false; // is there any appropriate object selected
2212 SALOME_ListIteratorOfListIO It( selected );
2213 for ( ; It.More(); It.Next() )
2215 Handle(SALOME_InteractiveObject) IObject = It.Value();
2216 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2217 _PTR(GenericAttribute) anAttr;
2218 _PTR(AttributeName) aName;
2221 if ( obj->FindAttribute(anAttr, "AttributeName") )
2224 QString newName = QString(aName->Value().c_str());
2226 // check type to prevent renaming of inappropriate objects
2227 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2228 if (aType == MESH || aType == GROUP ||
2229 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2230 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2231 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2232 aType == HYPOTHESIS || aType == ALGORITHM)
2235 newName = LightApp_NameDlg::getName(desktop(), newName);
2236 if ( !newName.isEmpty() )
2238 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2240 // update name of group object and its actor
2241 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2242 if( !aGroupObject->_is_nil() )
2244 aGroupObject->SetName( newName.toLatin1().data() );
2245 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2246 anActor->setName( newName.toLatin1().data() );
2257 SUIT_MessageBox::warning(desktop(),
2258 QObject::tr("SMESH_WRN_WARNING"),
2259 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2264 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2266 if(checkLock(aStudy)) break;
2267 SUIT_OverrideCursor wc;
2269 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2270 SALOME_ListIO selected;
2272 aSel->selectedObjects( selected, QString::null, false );
2274 SALOME_ListIteratorOfListIO It(selected);
2275 for (int i = 0; It.More(); It.Next(), i++) {
2276 Handle(SALOME_InteractiveObject) IObject = It.Value();
2277 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2280 aSel->setSelectedObjects( l1 );
2285 case 4009: // ELEM0D
2286 case 4010: // GEOM::EDGE
2287 case 4021: // TRIANGLE
2289 case 4023: // POLYGON
2293 if(checkLock(aStudy)) break;
2295 EmitSignalDeactivateDialog();
2296 SMDSAbs_ElementType type = SMDSAbs_Edge;
2298 switch (theCommandID) {
2299 case 4009: // ELEM0D
2300 type = SMDSAbs_0DElement; nbNodes = 1; break;
2301 case 4021: // TRIANGLE
2302 type = SMDSAbs_Face; nbNodes = 3; break;
2304 type = SMDSAbs_Face; nbNodes = 4; break;
2306 type = SMDSAbs_Volume; nbNodes = 4; break;
2307 case 4023: // POLYGON
2308 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2310 type = SMDSAbs_Volume; nbNodes = 8; break;
2311 case 4033: // POLYHEDRE
2312 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2315 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2318 SUIT_MessageBox::warning(desktop(),
2319 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2323 case 4033: // POLYHEDRON
2325 if(checkLock(aStudy)) break;
2327 EmitSignalDeactivateDialog();
2328 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2331 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2332 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2336 case 4034: // QUADRATIC EDGE
2337 case 4035: // QUADRATIC TRIANGLE
2338 case 4036: // QUADRATIC QUADRANGLE
2339 case 4037: // QUADRATIC TETRAHEDRON
2340 case 4038: // QUADRATIC PYRAMID
2341 case 4039: // QUADRATIC PENTAHEDRON
2342 case 4040: // QUADRATIC HEXAHEDRON
2344 if(checkLock(aStudy)) break;
2346 EmitSignalDeactivateDialog();
2349 switch (theCommandID) {
2351 type = QUAD_EDGE; break;
2353 type = QUAD_TRIANGLE; break;
2355 type = QUAD_QUADRANGLE; break;
2357 type = QUAD_TETRAHEDRON; break;
2359 type = QUAD_PYRAMID; break;
2361 type = QUAD_PENTAHEDRON; break;
2363 type = QUAD_HEXAHEDRON;
2367 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2370 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2371 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2375 case 4041: // REMOVES NODES
2377 if(checkLock(aStudy)) break;
2379 EmitSignalDeactivateDialog();
2380 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2383 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2384 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2388 case 4042: // REMOVES ELEMENTS
2390 if(checkLock(aStudy)) break;
2392 EmitSignalDeactivateDialog();
2393 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2397 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2398 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2402 case 4043: { // CLEAR_MESH
2404 if(checkLock(aStudy)) break;
2406 SALOME_ListIO selected;
2407 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2408 aSel->selectedObjects( selected );
2410 SUIT_OverrideCursor wc;
2411 SALOME_ListIteratorOfListIO It (selected);
2412 for ( ; It.More(); It.Next() )
2414 Handle(SALOME_InteractiveObject) IOS = It.Value();
2415 SMESH::SMESH_Mesh_var aMesh =
2416 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2417 if ( aMesh->_is_nil()) continue;
2419 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2421 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2422 SMESH::ModifiedMesh( aMeshSObj, false, true);
2423 // hide groups and submeshes
2424 _PTR(ChildIterator) anIter =
2425 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2426 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2428 _PTR(SObject) so = anIter->Value();
2429 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2432 catch (const SALOME::SALOME_Exception& S_ex){
2434 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2438 SMESH::UpdateView();
2442 case 4051: // RENUMBERING NODES
2444 if(checkLock(aStudy)) break;
2446 EmitSignalDeactivateDialog();
2447 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2451 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2452 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2456 case 4052: // RENUMBERING ELEMENTS
2458 if(checkLock(aStudy)) break;
2460 EmitSignalDeactivateDialog();
2461 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2465 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2466 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2470 case 4061: // TRANSLATION
2472 if(checkLock(aStudy)) break;
2474 EmitSignalDeactivateDialog();
2475 ( new SMESHGUI_TranslationDlg( this ) )->show();
2478 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2479 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2483 case 4062: // ROTATION
2485 if(checkLock(aStudy)) break;
2487 EmitSignalDeactivateDialog();
2488 ( new SMESHGUI_RotationDlg( this ) )->show();
2491 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2492 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2496 case 4063: // SYMMETRY
2498 if(checkLock(aStudy)) break;
2500 EmitSignalDeactivateDialog();
2501 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2504 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2505 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2509 case 4064: // SEWING
2511 if(checkLock(aStudy)) break;
2513 EmitSignalDeactivateDialog();
2514 ( new SMESHGUI_SewingDlg( this ) )->show();
2517 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2518 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2522 case 4065: // MERGE NODES
2524 if(checkLock(aStudy)) break;
2526 EmitSignalDeactivateDialog();
2527 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2530 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2531 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2535 case 4066: // MERGE EQUAL ELEMENTS
2537 if (checkLock(aStudy)) break;
2539 EmitSignalDeactivateDialog();
2540 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2542 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2543 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2548 case 4067: // MAKE MESH PASS THROUGH POINT
2549 startOperation( 4067 );
2552 case 5105: // Library of selection filters
2554 static QList<int> aTypes;
2555 if ( aTypes.isEmpty() )
2557 aTypes.append( SMESH::NODE );
2558 aTypes.append( SMESH::EDGE );
2559 aTypes.append( SMESH::FACE );
2560 aTypes.append( SMESH::VOLUME );
2562 if (!myFilterLibraryDlg)
2563 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2564 else if (myFilterLibraryDlg->isHidden())
2565 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2566 myFilterLibraryDlg->raise();
2570 case 6017: // CONTROLS
2588 LightApp_SelectionMgr* mgr = selectionMgr();
2589 SALOME_ListIO selected; mgr->selectedObjects( selected );
2591 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2592 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2594 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2595 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2596 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2597 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2598 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2599 ::Control( theCommandID );
2604 SUIT_MessageBox::warning(desktop(),
2605 tr( "SMESH_WRN_WARNING" ),
2606 tr( "SMESH_BAD_SELECTION" ) );
2610 SUIT_MessageBox::warning(desktop(),
2611 tr( "SMESH_WRN_WARNING" ),
2612 tr( "NOT_A_VTK_VIEWER" ) );
2617 LightApp_SelectionMgr* mgr = selectionMgr();
2618 SALOME_ListIO selected; mgr->selectedObjects( selected );
2620 SALOME_ListIteratorOfListIO it(selected);
2621 for( ; it.More(); it.Next()) {
2622 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2623 if(anIObject->hasEntry()) {
2624 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2625 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2633 LightApp_SelectionMgr* mgr = selectionMgr();
2634 SALOME_ListIO selected; mgr->selectedObjects( selected );
2636 if (selected.Extent() == 1) {
2637 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2638 if(anIObject->hasEntry())
2639 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2640 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2647 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2648 //updateObjBrowser();
2652 //=============================================================================
2656 //=============================================================================
2657 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2662 //=============================================================================
2666 //=============================================================================
2667 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2672 //=============================================================================
2676 //=============================================================================
2677 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2682 //=============================================================================
2683 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2684 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2686 //=============================================================================
2687 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2688 SUIT_ViewWindow* wnd )
2690 if(theIO->hasEntry()){
2691 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2692 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2696 //=======================================================================
2697 // function : createSMESHAction
2699 //=======================================================================
2700 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2703 QWidget* parent = application()->desktop();
2704 SUIT_ResourceMgr* resMgr = resourceMgr();
2706 if ( !icon_id.isEmpty() )
2707 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2709 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2710 if ( !pix.isNull() )
2711 icon = QIcon( pix );
2713 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2714 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2715 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2717 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2720 //=======================================================================
2721 // function : createPopupItem
2723 //=======================================================================
2724 void SMESHGUI::createPopupItem( const int id,
2725 const QString& clients,
2726 const QString& types,
2727 const QString& theRule,
2732 parentId = popupMgr()->actionId( action( pId ) );
2734 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2735 popupMgr()->insert( action( id ), parentId, 0 );
2737 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2738 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2739 QString rule = "(%1) and (%2) and (%3)";
2740 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2741 if( clients.isEmpty() )
2742 rule = rule.arg( QString( "true" ) );
2744 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2745 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2748 bool cont = myRules.contains( id );
2750 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2752 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2753 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2756 //=======================================================================
2757 // function : initialize
2759 //=======================================================================
2760 void SMESHGUI::initialize( CAM_Application* app )
2762 SalomeApp_Module::initialize( app );
2764 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2766 /* Automatic Update flag */
2767 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2769 // ----- create actions --------------
2771 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2772 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2773 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2774 createSMESHAction( 115, "SAUV" );
2775 createSMESHAction( 114, "NUM" );
2776 createSMESHAction( 121, "DAT" );
2777 createSMESHAction( 122, "MED" );
2778 createSMESHAction( 123, "UNV" );
2779 createSMESHAction( 140, "STL" );
2780 createSMESHAction( 142, "SAUV" );
2781 createSMESHAction( 124, "EXPORT_DAT" );
2782 createSMESHAction( 125, "EXPORT_MED" );
2783 createSMESHAction( 126, "EXPORT_UNV" );
2784 createSMESHAction( 141, "EXPORT_STL" );
2785 createSMESHAction( 143, "EXPORT_SAUV" );
2786 createSMESHAction( 150, "FILE_INFO" );
2787 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2788 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2789 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2790 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2791 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2792 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2793 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2794 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2795 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2796 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2797 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2798 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2799 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2800 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2801 createSMESHAction( 804, "ADD" );
2802 createSMESHAction( 805, "REMOVE" );
2803 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2804 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2805 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2806 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2807 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2808 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2809 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2810 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2811 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2812 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2813 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2814 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2815 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2816 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2817 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2818 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2819 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2820 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2821 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2822 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2823 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2824 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2825 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2826 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2827 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2828 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2829 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2830 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2831 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2832 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2833 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2834 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2835 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2836 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2837 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2838 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2839 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2840 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2841 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2842 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2843 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2844 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2845 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2846 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2847 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2848 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2849 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2850 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2851 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2852 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2853 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2854 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2855 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2856 createSMESHAction( 415, "MAP", "ICON_MAP" );
2857 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2858 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2859 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2860 createSMESHAction( 200, "RESET" );
2861 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2862 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2863 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2864 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2865 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2866 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2867 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2868 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2869 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2870 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2871 createSMESHAction( 220, "ALL" );
2872 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2874 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2875 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2877 createSMESHAction( 1100, "EDIT_HYPO" );
2878 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2879 createSMESHAction( 1102, "UNASSIGN" );
2880 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2881 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2882 createSMESHAction( 1131, "DISPMODE" );
2883 createSMESHAction( 1132, "COLORS" );
2884 createSMESHAction( 1133, "TRANSP" );
2885 createSMESHAction( 1134, "CLIP" );
2886 createSMESHAction( 1135, "DISP_ENT" );
2887 createSMESHAction( 1136, "AUTO_COLOR" );
2888 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2889 createSMESHAction( 2000, "CTRL" );
2891 createSMESHAction( 300, "ERASE" );
2892 createSMESHAction( 301, "DISPLAY" );
2893 createSMESHAction( 302, "DISPLAY_ONLY" );
2894 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2895 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2896 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2897 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2898 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2899 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2900 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2901 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2903 // ----- create menu --------------
2904 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2905 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2906 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2907 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2908 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2909 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2910 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2912 createMenu( separator(), fileId );
2914 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2915 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2916 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2917 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2918 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2919 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2921 createMenu( 111, importId, -1 );
2922 createMenu( 112, importId, -1 );
2923 createMenu( 113, importId, -1 );
2924 createMenu( 115, importId, -1 );
2926 createMenu( 121, exportId, -1 );
2927 createMenu( 122, exportId, -1 );
2928 createMenu( 123, exportId, -1 );
2929 createMenu( 140, exportId, -1 ); // export to stl STL
2930 createMenu( 142, exportId, -1 );
2932 createMenu( separator(), fileId, 10 );
2934 createMenu( 33, editId, -1 );
2936 createMenu( 5105, toolsId, -1 );
2938 createMenu( 702, meshId, -1 ); // "Mesh" menu
2939 createMenu( 703, meshId, -1 );
2940 createMenu( 704, meshId, -1 );
2941 createMenu( 710, meshId, -1 );
2942 createMenu( separator(), meshId, -1 );
2943 createMenu( 701, meshId, -1 );
2944 createMenu( 711, meshId, -1 );
2945 createMenu( 712, meshId, -1 );
2946 createMenu( separator(), meshId, -1 );
2947 createMenu( 801, meshId, -1 );
2948 createMenu( 806, meshId, -1 );
2949 createMenu( 802, meshId, -1 );
2950 createMenu( 803, meshId, -1 );
2951 createMenu( 815, meshId, -1 );
2952 createMenu( separator(), meshId, -1 );
2953 createMenu( 810, meshId, -1 );
2954 createMenu( 811, meshId, -1 );
2955 createMenu( 812, meshId, -1 );
2956 createMenu( separator(), meshId, -1 );
2957 createMenu( 814, meshId, -1 );
2958 createMenu( separator(), meshId, -1 );
2959 createMenu( 813, meshId, -1 );
2960 createMenu( separator(), meshId, -1 );
2961 createMenu( 900, meshId, -1 );
2962 createMenu( 902, meshId, -1 );
2963 createMenu( 903, meshId, -1 );
2964 createMenu( separator(), meshId, -1 );
2966 createMenu( 6003, ctrlId, -1 );
2967 createMenu( 6001, ctrlId, -1 );
2968 createMenu( 6004, ctrlId, -1 );
2969 createMenu( separator(), ctrlId, -1 );
2970 createMenu( 6005, ctrlId, -1 );
2971 createMenu( 6002, ctrlId, -1 );
2972 createMenu( 6018, ctrlId, -1 );
2973 createMenu( 6019, ctrlId, -1 );
2974 createMenu( 6011, ctrlId, -1 );
2975 createMenu( 6012, ctrlId, -1 );
2976 createMenu( 6013, ctrlId, -1 );
2977 createMenu( 6014, ctrlId, -1 );
2978 createMenu( 6015, ctrlId, -1 );
2979 createMenu( 6016, ctrlId, -1 );
2980 createMenu( separator(), ctrlId, -1 );
2981 createMenu( 6017, ctrlId, -1 );
2982 createMenu( 6009, ctrlId, -1 );
2983 createMenu( 6021, ctrlId, -1 );
2984 createMenu( separator(), ctrlId, -1 );
2986 createMenu( 4000, addId, -1 );
2987 createMenu( 4009, addId, -1 );
2988 createMenu( 4010, addId, -1 );
2989 createMenu( 4021, addId, -1 );
2990 createMenu( 4022, addId, -1 );
2991 createMenu( 4023, addId, -1 );
2992 createMenu( 4031, addId, -1 );
2993 createMenu( 4032, addId, -1 );
2994 createMenu( 4033, addId, -1 );
2995 createMenu( separator(), addId, -1 );
2996 createMenu( 4034, addId, -1 );
2997 createMenu( 4035, addId, -1 );
2998 createMenu( 4036, addId, -1 );
2999 createMenu( 4037, addId, -1 );
3000 createMenu( 4038, addId, -1 );
3001 createMenu( 4039, addId, -1 );
3002 createMenu( 4040, addId, -1 );
3004 createMenu( 4041, removeId, -1 );
3005 createMenu( 4042, removeId, -1 );
3006 createMenu( 4043, removeId, -1 );
3008 createMenu( 4051, renumId, -1 );
3009 createMenu( 4052, renumId, -1 );
3011 createMenu( 4061, transfId, -1 );
3012 createMenu( 4062, transfId, -1 );
3013 createMenu( 4063, transfId, -1 );
3014 createMenu( 4064, transfId, -1 );
3015 createMenu( 4065, transfId, -1 );
3016 createMenu( 4066, transfId, -1 );
3018 createMenu( 406, modifyId, -1 );
3019 createMenu( 4067,modifyId, -1 );
3020 createMenu( 407, modifyId, -1 );
3021 createMenu( 408, modifyId, -1 );
3022 createMenu( 409, modifyId, -1 );
3023 createMenu( 410, modifyId, -1 );
3024 createMenu( 411, modifyId, -1 );
3025 createMenu( 412, modifyId, -1 );
3026 createMenu( 413, modifyId, -1 );
3027 createMenu( 416, modifyId, -1 );
3028 createMenu( 414, modifyId, -1 );
3029 createMenu( 415, modifyId, -1 );
3030 createMenu( 417, modifyId, -1 );
3031 createMenu( 418, modifyId, -1 );
3033 createMenu( 214, viewId, -1 );
3035 // ----- create toolbars --------------
3036 int meshTb = createTool( tr( "TB_MESH" ) ),
3037 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3038 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3039 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3040 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3042 createTool( 702, meshTb );
3043 createTool( 703, meshTb );
3044 createTool( 704, meshTb );
3045 createTool( 710, meshTb );
3046 createTool( separator(), meshTb );
3047 createTool( 701, meshTb );
3048 createTool( 711, meshTb );
3049 createTool( 712, meshTb );
3050 createTool( separator(), meshTb );
3051 createTool( 801, meshTb );
3052 createTool( 806, meshTb );
3053 createTool( 802, meshTb );
3054 createTool( 803, meshTb );
3055 //createTool( 815, meshTb );
3056 createTool( separator(), meshTb );
3057 createTool( 900, meshTb );
3058 createTool( 902, meshTb );
3059 createTool( 903, meshTb );
3060 createTool( separator(), meshTb );
3062 createTool( 6001, ctrlTb );
3063 createTool( 6003, ctrlTb );
3064 createTool( 6004, ctrlTb );
3065 createTool( separator(), ctrlTb );
3066 createTool( 6005, ctrlTb );
3067 createTool( 6002, ctrlTb );
3068 createTool( 6018, ctrlTb );
3069 createTool( 6019, ctrlTb );
3070 createTool( 6011, ctrlTb );
3071 createTool( 6012, ctrlTb );
3072 createTool( 6013, ctrlTb );
3073 createTool( 6014, ctrlTb );
3074 createTool( 6015, ctrlTb );
3075 createTool( 6016, ctrlTb );
3076 createTool( separator(), ctrlTb );
3077 createTool( 6017, ctrlTb );
3078 createTool( 6009, ctrlTb );
3079 createTool( 6021, ctrlTb );
3080 createTool( separator(), ctrlTb );
3082 createTool( 4000, addRemTb );
3083 createTool( 4009, addRemTb );
3084 createTool( 4010, addRemTb );
3085 createTool( 4021, addRemTb );
3086 createTool( 4022, addRemTb );
3087 createTool( 4023, addRemTb );
3088 createTool( 4031, addRemTb );
3089 createTool( 4032, addRemTb );
3090 createTool( 4033, addRemTb );
3091 createTool( separator(), addRemTb );
3092 createTool( 4034, addRemTb );
3093 createTool( 4035, addRemTb );
3094 createTool( 4036, addRemTb );
3095 createTool( 4037, addRemTb );
3096 createTool( 4038, addRemTb );
3097 createTool( 4039, addRemTb );
3098 createTool( 4040, addRemTb );
3099 createTool( separator(), addRemTb );
3100 createTool( 4041, addRemTb );
3101 createTool( 4042, addRemTb );
3102 createTool( 4043, addRemTb );
3103 createTool( separator(), addRemTb );
3104 createTool( 4051, addRemTb );
3105 createTool( 4052, addRemTb );
3106 createTool( separator(), addRemTb );
3107 createTool( 4061, addRemTb );
3108 createTool( 4062, addRemTb );
3109 createTool( 4063, addRemTb );
3110 createTool( 4064, addRemTb );
3111 createTool( 4065, addRemTb );
3112 createTool( 4066, addRemTb );
3113 createTool( separator(), addRemTb );
3115 createTool( 406, modifyTb );
3116 createTool( 4067,modifyTb );
3117 createTool( 407, modifyTb );
3118 createTool( 408, modifyTb );
3119 createTool( 409, modifyTb );
3120 createTool( 410, modifyTb );
3121 createTool( 411, modifyTb );
3122 createTool( 412, modifyTb );
3123 createTool( 413, modifyTb );
3124 createTool( 416, modifyTb );
3125 createTool( 414, modifyTb );
3126 createTool( 415, modifyTb );
3127 createTool( 417, modifyTb );
3128 createTool( 418, modifyTb );
3130 createTool( 214, dispModeTb );
3132 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3133 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3136 QString OB = "'ObjectBrowser'",
3137 View = "'" + SVTK_Viewer::Type() + "'",
3139 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3140 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3141 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3142 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3143 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3144 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3145 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3146 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3147 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3148 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3149 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3151 mesh_group = mesh + " " + subMesh + " " + group,
3152 hyp_alg = hypo + " " + algo;
3154 // popup for object browser
3156 isInvisible("not( isVisible )"),
3157 isEmpty("numberOfNodes = 0"),
3158 isNotEmpty("numberOfNodes <> 0"),
3160 // has nodes, edges, etc in VISIBLE! actor
3161 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3162 hasElems("(count( elemTypes ) > 0)"),
3163 hasDifferentElems("(count( elemTypes ) > 1)"),
3164 hasElems0d("({'Elem0d'} in elemTypes)"),
3165 hasEdges("({'Edge'} in elemTypes)"),
3166 hasFaces("({'Face'} in elemTypes)"),
3167 hasVolumes("({'Volume'} in elemTypes)");
3169 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3170 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3171 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3172 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3173 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3174 createPopupItem( 803, OB, group ); // EDIT_GROUP
3175 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3177 popupMgr()->insert( separator(), -1, 0 );
3178 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3179 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3180 createPopupItem( 712, OB, mesh, "&& isComputable" ); // COMPUTE
3181 createPopupItem( 214, OB, mesh_group ); // UPDATE
3182 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3183 createPopupItem( 902, OB, mesh ); // STD_INFO
3184 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3185 popupMgr()->insert( separator(), -1, 0 );
3186 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3187 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3188 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3189 popupMgr()->insert( separator(), -1, 0 );
3190 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3191 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3192 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3193 popupMgr()->insert( separator(), -1, 0 );
3194 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3195 popupMgr()->insert( separator(), -1, 0 );
3196 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3197 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3198 popupMgr()->insert( separator(), -1, 0 );
3200 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3202 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3203 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3204 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3205 createPopupItem( 143, OB, mesh, only_one_non_empty ); // EXPORT_SAUV
3206 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3207 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3208 popupMgr()->insert( separator(), -1, 0 );
3211 createPopupItem( 803, View, group ); // EDIT_GROUP
3212 createPopupItem( 804, View, elems ); // ADD
3213 createPopupItem( 805, View, elems ); // REMOVE
3215 popupMgr()->insert( separator(), -1, 0 );
3216 createPopupItem( 214, View, mesh_group ); // UPDATE
3217 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3218 createPopupItem( 902, View, mesh ); // STD_INFO
3219 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3220 popupMgr()->insert( separator(), -1, 0 );
3222 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3223 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3224 popupMgr()->insert( separator(), -1, 0 );
3227 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3228 QString aType = QString( "%1type in {%2}" ).arg( lc );
3229 aType = aType.arg( mesh_group );
3230 QString aMeshInVTK = aClient + "&&" + aType;
3232 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3233 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3234 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3236 //-------------------------------------------------
3238 //-------------------------------------------------
3239 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3241 popupMgr()->insert( action( 9010 ), anId, -1 );
3242 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3243 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3245 popupMgr()->insert( action( 9011 ), anId, -1 );
3246 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3247 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3249 popupMgr()->insert( separator(), -1, -1 );
3251 //-------------------------------------------------
3253 //-------------------------------------------------
3254 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3256 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3257 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3258 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3260 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3261 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3262 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3264 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3265 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3266 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3268 popupMgr()->insert( separator(), anId, -1 );
3270 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3271 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3272 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3274 //-------------------------------------------------
3276 //-------------------------------------------------
3277 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3279 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3281 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3282 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3283 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3285 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3286 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3287 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3289 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3290 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3291 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3293 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3294 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3295 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3297 popupMgr()->insert( separator(), anId, -1 );
3299 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3300 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3303 //-------------------------------------------------
3304 // Representation of the 2D Quadratic elements
3305 //-------------------------------------------------
3306 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3307 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3308 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3309 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3311 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3312 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3313 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3315 //-------------------------------------------------
3316 // Orientation of faces
3317 //-------------------------------------------------
3318 popupMgr()->insert( action( 221 ), -1, -1 );
3319 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3320 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3322 //-------------------------------------------------
3324 //-------------------------------------------------
3325 popupMgr()->insert( action( 1132 ), -1, -1 );
3326 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3328 //-------------------------------------------------
3330 //-------------------------------------------------
3331 popupMgr()->insert( action( 1133 ), -1, -1 );
3332 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3334 //-------------------------------------------------
3336 //-------------------------------------------------
3337 popupMgr()->insert( action( 1134 ), -1, -1 );
3338 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3340 popupMgr()->insert( separator(), -1, -1 );
3342 //-------------------------------------------------
3344 //-------------------------------------------------
3346 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3347 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3348 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3349 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3351 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3353 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3354 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3356 popupMgr()->insert( separator(), anId, -1 );
3358 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3359 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3360 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3362 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3363 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3364 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3366 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3367 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3368 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3370 popupMgr()->insert( separator(), anId, -1 );
3372 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3373 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3374 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3376 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3377 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3378 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3380 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3381 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3382 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3384 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3385 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3386 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3388 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3389 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3390 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3392 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3393 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3394 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3396 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3397 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3398 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3400 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3401 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3402 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3404 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3405 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3406 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3408 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3409 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3410 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3412 popupMgr()->insert( separator(), anId, -1 );
3414 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3415 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3416 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3418 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3419 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3420 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3422 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3423 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3424 QtxPopupMgr::VisibleRule );
3425 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3427 popupMgr()->insert( separator(), anId, -1 );
3429 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3430 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3432 popupMgr()->insert( separator(), -1, -1 );
3434 //-------------------------------------------------
3436 //-------------------------------------------------
3437 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3438 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3439 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3440 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3442 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3443 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3445 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3446 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3448 popupMgr()->insert( separator(), -1, -1 );
3450 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3451 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3454 //================================================================================
3456 * \brief Return true if SMESH or GEOM objects are selected.
3457 * Is called form LightApp_Module::activateModule() which clear selection if
3458 * not isSelectionCompatible()
3460 //================================================================================
3462 bool SMESHGUI::isSelectionCompatible()
3464 bool isCompatible = true;
3465 SALOME_ListIO selected;
3466 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3467 Sel->selectedObjects( selected );
3469 SALOME_ListIteratorOfListIO It( selected );
3470 for ( ; isCompatible && It.More(); It.Next())
3472 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3473 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3475 return isCompatible;
3478 bool SMESHGUI::activateModule( SUIT_Study* study )
3480 bool res = SalomeApp_Module::activateModule( study );
3482 setMenuShown( true );
3483 setToolShown( true );
3485 // Reset actions accelerator keys
3486 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3487 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3488 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3490 action( 33)->setEnabled(true); // Delete: Key_Delete
3491 action(1101)->setEnabled(true); // Rename: Key_F2
3493 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3494 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3495 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3496 if ( _PTR(Study) aStudy = s->studyDS()) {
3497 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3498 updateObjBrowser(); // objects can be removed
3504 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3506 setMenuShown( false );
3507 setToolShown( false );
3509 EmitSignalCloseAllDialogs();
3511 // Unset actions accelerator keys
3512 action(111)->setShortcut(QKeySequence()); // Import DAT
3513 action(112)->setShortcut(QKeySequence()); // Import UNV
3514 action(113)->setShortcut(QKeySequence()); // Import MED
3516 action( 33)->setEnabled(false); // Delete: Key_Delete
3517 action(1101)->setEnabled(false); // Rename: Key_F2
3519 return SalomeApp_Module::deactivateModule( study );
3522 void SMESHGUI::studyClosed( SUIT_Study* s )
3524 SMESH::RemoveVisuData( s->id() );
3525 SalomeApp_Module::studyClosed( s );
3528 void SMESHGUI::OnGUIEvent()
3530 const QObject* obj = sender();
3531 if ( !obj || !obj->inherits( "QAction" ) )
3533 int id = actionId((QAction*)obj);
3538 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3540 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3541 if ( CORBA::is_nil( myComponentSMESH ) )
3543 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3545 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3546 return aGUI.myComponentSMESH;
3549 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3550 return myComponentSMESH;
3553 QString SMESHGUI::engineIOR() const
3555 CORBA::ORB_var anORB = getApp()->orb();
3556 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3557 return QString( anIOR.in() );
3560 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3562 SalomeApp_Module::contextMenuPopup( client, menu, title );
3564 selectionMgr()->selectedObjects( lst );
3565 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3566 Handle(SALOME_InteractiveObject) io = lst.First();
3567 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3568 _PTR(Study) study = appStudy->studyDS();
3569 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3571 QString aName = QString( obj->GetName().c_str() );
3572 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3573 aName.remove( (aName.length() - 1), 1 );
3579 LightApp_Selection* SMESHGUI::createSelection() const
3581 return new SMESHGUI_Selection();
3584 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3586 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3587 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3590 void SMESHGUI::viewManagers( QStringList& list ) const
3592 list.append( SVTK_Viewer::Type() );
3595 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3597 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3598 SMESH::UpdateSelectionProp( this );
3601 void SMESHGUI::createPreferences()
3603 // General tab ------------------------------------------------------------------------
3604 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3606 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3607 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3609 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3610 setPreferenceProperty( qaGroup, "columns", 2 );
3611 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3612 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3613 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3614 setPreferenceProperty( prec, "min", 0 );
3615 setPreferenceProperty( prec, "max", 16 );
3617 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3618 setPreferenceProperty( dispgroup, "columns", 2 );
3619 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3621 modes.append( "Wireframe" );
3622 modes.append( "Shading" );
3623 modes.append( "Nodes" );
3624 modes.append( "Shrink" );
3625 QList<QVariant> indices;
3626 indices.append( 0 );
3627 indices.append( 1 );
3628 indices.append( 2 );
3629 indices.append( 3 );
3630 setPreferenceProperty( dispmode, "strings", modes );
3631 setPreferenceProperty( dispmode, "indexes", indices );
3633 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3634 setPreferenceProperty( arcgroup, "columns", 2 );
3635 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3636 QStringList quadraticModes;
3637 quadraticModes.append("Lines");
3638 quadraticModes.append("Arcs");
3640 indices.append( 0 );
3641 indices.append( 1 );
3642 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3643 setPreferenceProperty( quadraticmode, "indexes", indices );
3645 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3646 "SMESH", "max_angle" );
3647 setPreferenceProperty( maxAngle, "min", 1 );
3648 setPreferenceProperty( maxAngle, "max", 90 );
3652 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3653 setPreferenceProperty( exportgroup, "columns", 2 );
3654 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3655 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3657 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3658 setPreferenceProperty( computeGroup, "columns", 2 );
3659 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3661 modes.append( "Never" );
3662 modes.append( "Errors only" );
3663 modes.append( "Always" );
3665 indices.append( 0 );
3666 indices.append( 1 );
3667 indices.append( 2 );
3668 setPreferenceProperty( notifyMode, "strings", modes );
3669 setPreferenceProperty( notifyMode, "indexes", indices );
3671 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3672 setPreferenceProperty( segGroup, "columns", 2 );
3673 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3674 "SMESH", "segmentation" );
3675 setPreferenceProperty( segLen, "min", 1 );
3676 setPreferenceProperty( segLen, "max", 10000000 );
3677 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3678 "SMESH", "nb_segments_per_edge" );
3679 setPreferenceProperty( nbSeg, "min", 1 );
3680 setPreferenceProperty( nbSeg, "max", 10000000 );
3682 // Mesh tab ------------------------------------------------------------------------
3683 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3684 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3685 setPreferenceProperty( nodeGroup, "columns", 2 );
3687 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3688 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3690 setPreferenceProperty( nodeSz, "min", 1 );
3691 setPreferenceProperty( nodeSz, "max", 5 );
3693 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3694 setPreferenceProperty( elemGroup, "columns", 2 );
3696 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3697 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3698 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3699 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3701 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3702 //setPreferenceProperty( sp, "hstretch", 0 );
3703 //setPreferenceProperty( sp, "vstretch", 0 );
3705 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3706 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3707 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3708 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3709 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3710 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3711 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3713 setPreferenceProperty( size0d, "min", 1 );
3714 setPreferenceProperty( size0d, "max", 10 );
3716 setPreferenceProperty( sp, "hstretch", 0 );
3717 setPreferenceProperty( sp, "vstretch", 0 );
3719 setPreferenceProperty( elemW, "min", 1 );
3720 setPreferenceProperty( elemW, "max", 5 );
3722 setPreferenceProperty( shrink, "min", 0 );
3723 setPreferenceProperty( shrink, "max", 100 );
3725 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3726 setPreferenceProperty( orientGroup, "columns", 1 );
3728 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3729 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3731 setPreferenceProperty( orientScale, "min", 0.05 );
3732 setPreferenceProperty( orientScale, "max", 0.5 );
3733 setPreferenceProperty( orientScale, "step", 0.05 );
3735 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3737 // Selection tab ------------------------------------------------------------------------
3738 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3740 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3741 setPreferenceProperty( selGroup, "columns", 2 );
3743 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3744 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3745 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3747 setPreferenceProperty( selW, "min", 1 );
3748 setPreferenceProperty( selW, "max", 5 );
3750 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3751 setPreferenceProperty( preGroup, "columns", 2 );
3753 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3754 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3756 setPreferenceProperty( preW, "min", 1 );
3757 setPreferenceProperty( preW, "max", 5 );
3759 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3760 setPreferenceProperty( precSelGroup, "columns", 2 );
3762 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3763 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3764 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3766 // Scalar Bar tab ------------------------------------------------------------------------
3767 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3768 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3769 setPreferenceProperty( fontGr, "columns", 2 );
3771 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3772 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3774 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3775 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3777 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3778 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3780 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3781 setPreferenceProperty( numcol, "min", 2 );
3782 setPreferenceProperty( numcol, "max", 256 );
3784 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3785 setPreferenceProperty( numlab, "min", 2 );
3786 setPreferenceProperty( numlab, "max", 65 );
3788 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3789 setPreferenceProperty( orientGr, "columns", 2 );
3790 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3791 QStringList orients;
3792 orients.append( tr( "SMESH_VERTICAL" ) );
3793 orients.append( tr( "SMESH_HORIZONTAL" ) );
3794 indices.clear(); indices.append( 0 ); indices.append( 1 );
3795 setPreferenceProperty( orient, "strings", orients );
3796 setPreferenceProperty( orient, "indexes", indices );
3798 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3799 setPreferenceProperty( posVSizeGr, "columns", 2 );
3800 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3801 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3802 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3803 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3804 setPreferenceProperty( xv, "step", 0.1 );
3805 setPreferenceProperty( xv, "min", 0.0 );
3806 setPreferenceProperty( xv, "max", 1.0 );
3807 setPreferenceProperty( yv, "step", 0.1 );
3808 setPreferenceProperty( yv, "min", 0.0 );
3809 setPreferenceProperty( yv, "max", 1.0 );
3810 setPreferenceProperty( wv, "step", 0.1 );
3811 setPreferenceProperty( wv, "min", 0.0 );
3812 setPreferenceProperty( wv, "max", 1.0 );
3813 setPreferenceProperty( hv, "min", 0.0 );
3814 setPreferenceProperty( hv, "max", 1.0 );
3815 setPreferenceProperty( hv, "step", 0.1 );
3817 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3818 setPreferenceProperty( posHSizeGr, "columns", 2 );
3819 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3820 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3821 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3822 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3823 setPreferenceProperty( xv, "min", 0.0 );
3824 setPreferenceProperty( xv, "max", 1.0 );
3825 setPreferenceProperty( xv, "step", 0.1 );
3826 setPreferenceProperty( xh, "min", 0.0 );
3827 setPreferenceProperty( xh, "max", 1.0 );
3828 setPreferenceProperty( xh, "step", 0.1 );
3829 setPreferenceProperty( yh, "min", 0.0 );
3830 setPreferenceProperty( yh, "max", 1.0 );
3831 setPreferenceProperty( yh, "step", 0.1 );
3832 setPreferenceProperty( wh, "min", 0.0 );
3833 setPreferenceProperty( wh, "max", 1.0 );
3834 setPreferenceProperty( wh, "step", 0.1 );
3835 setPreferenceProperty( hh, "min", 0.0 );
3836 setPreferenceProperty( hh, "max", 1.0 );
3837 setPreferenceProperty( hh, "step", 0.1 );
3840 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3842 if( sect=="SMESH" ) {
3843 float sbX1,sbY1,sbW,sbH;
3844 float aTol = 1.00000009999999;
3845 std::string aWarning;
3846 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3847 if( name=="selection_object_color" || name=="selection_element_color" ||
3848 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3849 name=="selection_precision_node" || name=="selection_precision_element" ||
3850 name=="selection_precision_object")
3851 SMESH::UpdateSelectionProp( this );
3852 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3853 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3854 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3855 if(sbX1+sbW > aTol){
3856 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3859 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3860 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3863 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3864 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3865 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3866 if(sbY1+sbH > aTol){
3867 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3868 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3869 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3872 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3873 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3874 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3875 if(sbX1+sbW > aTol){
3876 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3879 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3880 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3883 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3884 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3885 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3886 if(sbY1+sbH > aTol){
3887 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3890 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3891 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3894 else if ( name == "segmentation" ) {
3895 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3896 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3898 else if ( name == "nb_segments_per_edge" ) {
3899 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3900 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3903 if(aWarning.size() != 0){
3904 aWarning += "The default values are applied instead.";
3905 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3906 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3907 QObject::tr(aWarning.c_str()));
3912 //================================================================================
3914 * \brief Update something in accordance with update flags
3915 * \param theFlags - update flags
3917 * Update viewer or/and object browser etc. in accordance with update flags ( see
3918 * LightApp_UpdateFlags enumeration ).
3920 //================================================================================
3921 void SMESHGUI::update( const int flags )
3923 if ( flags & UF_Viewer | flags & UF_Forced )
3924 SMESH::UpdateView();
3926 SalomeApp_Module::update( flags );
3929 //================================================================================
3931 * \brief Set default selection mode
3933 * SLOT called when operation commited. Sets default selection mode
3935 //================================================================================
3936 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3938 SVTK_ViewWindow* vtkWnd =
3939 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3941 vtkWnd->SetSelectionMode( ActorSelection );
3944 //================================================================================
3946 * \brief Set default selection mode
3948 * SLOT called when operation aborted. Sets default selection mode
3950 //================================================================================
3951 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3953 SVTK_ViewWindow* vtkWnd =
3954 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3956 vtkWnd->SetSelectionMode( ActorSelection );
3959 //================================================================================
3961 * \brief Creates operation with given identifier
3962 * \param id - identifier of operation to be started
3963 * \return Pointer on created operation or NULL if operation is not created
3965 * Virtual method redefined from the base class creates operation with given id.
3966 * It is called called automatically from startOperation method of base class.
3968 //================================================================================
3969 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3971 LightApp_Operation* op = 0;
3972 // to do : create operation here
3975 case 701: // Compute mesh
3976 op = new SMESHGUI_ComputeOp();
3978 case 702: // Create mesh
3979 op = new SMESHGUI_MeshOp( true, true );
3981 case 703: // Create sub-mesh
3982 op = new SMESHGUI_MeshOp( true, false );
3984 case 704: // Edit mesh/sub-mesh
3985 op = new SMESHGUI_MeshOp( false );
3987 case 711: // Precompute mesh
3988 op = new SMESHGUI_PrecomputeOp();
3990 case 712: // Evaluate mesh
3991 op = new SMESHGUI_EvaluateOp();
3993 case 806: // Create group on geom
3994 op = new SMESHGUI_GroupOnShapeOp();
3996 case 417: //convert to quadratic
3997 op = new SMESHGUI_ConvToQuadOp();
3999 case 418: // create 2D mesh as boundary on 3D
4000 op = new SMESHGUI_Make2DFrom3DOp();
4002 case 4067: // make mesh pass through point
4003 op = new SMESHGUI_MakeNodeAtPointOp();
4010 op = SalomeApp_Module::createOperation( id );
4014 //================================================================================
4016 * \brief Stops current operations and starts a given one
4017 * \param id - The id of the operation to start
4019 //================================================================================
4021 void SMESHGUI::switchToOperation(int id)
4023 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4024 activeStudy()->abortAllOperations();
4025 startOperation( id );
4028 LightApp_Displayer* SMESHGUI::displayer()
4031 myDisplayer = new SMESHGUI_Displayer( getApp() );
4035 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4038 int aTolerance = 64;
4039 int anIterations = 0;
4045 if( anIterations % aPeriod == 0 )
4048 if( aTolerance < 1 )
4051 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4053 aHue = (int)( 360.0 * rand() / RAND_MAX );
4054 //cout << "Hue = " << aHue << endl;
4056 //cout << "Auto colors : ";
4058 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4059 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4060 for( ; it != itEnd; ++it )
4062 SALOMEDS::Color anAutoColor = *it;
4063 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4066 aQColor.getHsv( &h, &s, &v );
4068 if( abs( h - aHue ) < aTolerance )
4071 //cout << "break (diff = " << abs( h - aHue ) << ")";
4081 //cout << "Hue of the returned color = " << aHue << endl;
4083 aColor.setHsv( aHue, 255, 255 );
4085 SALOMEDS::Color aSColor;
4086 aSColor.R = (double)aColor.red() / 255.0;
4087 aSColor.G = (double)aColor.green() / 255.0;
4088 aSColor.B = (double)aColor.blue() / 255.0;
4093 const char gSeparator = '_'; // character used to separate parameter names
4094 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4097 * \brief Store visual parameters
4099 * This method is called just before the study document is saved.
4100 * Store visual parameters in AttributeParameter attribue(s)
4102 void SMESHGUI::storeVisualParameters (int savePoint)
4104 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4105 if (!appStudy || !appStudy->studyDS())
4107 _PTR(Study) studyDS = appStudy->studyDS();
4109 // componentName is used for encoding of entries when storing them in IParameters
4110 std::string componentName = myComponentSMESH->ComponentDataType();
4111 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4112 //if (!aSComponent) return;
4115 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4116 componentName.c_str(),
4118 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4120 // viewers counters are used for storing view_numbers in IParameters
4123 // main cycle to store parameters of displayed objects
4124 QList<SUIT_ViewManager*> lst;
4125 QList<SUIT_ViewManager*>::Iterator it;
4126 getApp()->viewManagers(lst);
4127 for (it = lst.begin(); it != lst.end(); it++)
4129 SUIT_ViewManager* vman = *it;
4130 QString vType = vman->getType();
4132 // saving VTK actors properties
4133 if (vType == SVTK_Viewer::Type())
4135 QVector<SUIT_ViewWindow*> views = vman->getViews();
4136 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4138 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4140 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4141 vtkActorCollection* allActors = aCopy.GetActors();
4142 allActors->InitTraversal();
4143 while (vtkActor* actor = allActors->GetNextActor())
4145 if (actor->GetVisibility()) // store only visible actors
4147 SMESH_Actor* aSmeshActor = 0;
4148 if (actor->IsA("SMESH_Actor"))
4149 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4150 if (aSmeshActor && aSmeshActor->hasIO())
4152 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4155 // entry is "encoded" = it does NOT contain component adress,
4156 // since it is a subject to change on next component loading
4157 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4159 std::string param, vtkParam = vType.toLatin1().data();
4160 vtkParam += gSeparator;
4161 vtkParam += QString::number(vtkViewers).toLatin1().data();
4162 vtkParam += gSeparator;
4165 param = vtkParam + "Visibility";
4166 ip->setParameter(entry, param, "On");
4169 param = vtkParam + "Representation";
4170 ip->setParameter(entry, param, QString::number
4171 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4174 param = vtkParam + "IsShrunk";
4175 ip->setParameter(entry, param, QString::number
4176 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4178 // Displayed entities
4179 unsigned int aMode = aSmeshActor->GetEntityMode();
4180 bool isE = aMode & SMESH_Actor::eEdges;
4181 bool isF = aMode & SMESH_Actor::eFaces;
4182 bool isV = aMode & SMESH_Actor::eVolumes;
4184 QString modeStr ("e");
4185 modeStr += gDigitsSep; modeStr += QString::number(isE);
4186 modeStr += gDigitsSep; modeStr += "f";
4187 modeStr += gDigitsSep; modeStr += QString::number(isF);
4188 modeStr += gDigitsSep; modeStr += "v";
4189 modeStr += gDigitsSep; modeStr += QString::number(isV);
4191 param = vtkParam + "Entities";
4192 ip->setParameter(entry, param, modeStr.toLatin1().data());
4194 // Colors (surface:edge:)
4195 vtkFloatingPointType r, g, b;
4197 aSmeshActor->GetSufaceColor(r, g, b);
4198 QString colorStr ("surface");
4199 colorStr += gDigitsSep; colorStr += QString::number(r);
4200 colorStr += gDigitsSep; colorStr += QString::number(g);
4201 colorStr += gDigitsSep; colorStr += QString::number(b);
4203 aSmeshActor->GetBackSufaceColor(r, g, b);
4204 colorStr += gDigitsSep; colorStr += "backsurface";
4205 colorStr += gDigitsSep; colorStr += QString::number(r);
4206 colorStr += gDigitsSep; colorStr += QString::number(g);
4207 colorStr += gDigitsSep; colorStr += QString::number(b);
4209 aSmeshActor->GetEdgeColor(r, g, b);
4210 colorStr += gDigitsSep; colorStr += "edge";
4211 colorStr += gDigitsSep; colorStr += QString::number(r);
4212 colorStr += gDigitsSep; colorStr += QString::number(g);
4213 colorStr += gDigitsSep; colorStr += QString::number(b);
4215 aSmeshActor->GetNodeColor(r, g, b);
4216 colorStr += gDigitsSep; colorStr += "node";
4217 colorStr += gDigitsSep; colorStr += QString::number(r);
4218 colorStr += gDigitsSep; colorStr += QString::number(g);
4219 colorStr += gDigitsSep; colorStr += QString::number(b);
4221 param = vtkParam + "Colors";
4222 ip->setParameter(entry, param, colorStr.toLatin1().data());
4224 // Sizes of lines and points
4225 QString sizeStr ("line");
4226 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4227 sizeStr += gDigitsSep; sizeStr += "node";
4228 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4229 sizeStr += gDigitsSep; sizeStr += "shrink";
4230 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4232 param = vtkParam + "Sizes";
4233 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4236 param = vtkParam + "Opacity";
4237 ip->setParameter(entry, param,
4238 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4241 param = vtkParam + "ClippingPlane";
4242 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4244 ip->setParameter(entry, param, "Off");
4245 for (int ipl = 0; ipl < nPlanes; ipl++) {
4246 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4247 SMESH::Orientation anOrientation;
4249 vtkFloatingPointType anAngle[2];
4250 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4251 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4252 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4253 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4254 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4256 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4258 } // if (io->hasEntry())
4259 } // SMESH_Actor && hasIO
4261 } // while.. actors traversal
4265 } // if (SVTK view model)
4266 } // for (viewManagers)
4270 * \brief Restore visual parameters
4272 * This method is called after the study document is opened.
4273 * Restore visual parameters from AttributeParameter attribue(s)
4275 void SMESHGUI::restoreVisualParameters (int savePoint)
4277 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4278 if (!appStudy || !appStudy->studyDS())
4280 _PTR(Study) studyDS = appStudy->studyDS();
4282 // componentName is used for encoding of entries when storing them in IParameters
4283 std::string componentName = myComponentSMESH->ComponentDataType();
4284 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4285 //if (!aSComponent) return;
4288 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4289 componentName.c_str(),
4291 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4293 std::vector<std::string> entries = ip->getEntries();
4295 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4297 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4298 QString entry (ip->decodeEntry(*entIt).c_str());
4300 // Check that the entry corresponds to a real object in the Study
4301 // as the object may be deleted or modified after the visual state is saved.
4302 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4303 if (!so) continue; //Skip the not existent entry
4305 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4306 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4308 std::vector<std::string>::iterator namesIt = paramNames.begin();
4309 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4311 // actors are stored in a map after displaying of them for
4312 // quicker access in the future: map < viewID to actor >
4313 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4315 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4317 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4318 // '_' is used as separator and should not be used in viewer type or parameter names.
4319 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4320 if (lst.size() != 3)
4323 QString viewerTypStr = lst[0];
4324 QString viewIndexStr = lst[1];
4325 QString paramNameStr = lst[2];
4328 int viewIndex = viewIndexStr.toUInt(&ok);
4329 if (!ok) // bad conversion of view index to integer
4333 if (viewerTypStr == SVTK_Viewer::Type())
4335 SMESH_Actor* aSmeshActor = 0;
4336 if (vtkActors.IsBound(viewIndex))
4337 aSmeshActor = vtkActors.Find(viewIndex);
4339 if (paramNameStr == "Visibility")
4341 if (!aSmeshActor && displayer())
4343 QList<SUIT_ViewManager*> lst;
4344 getApp()->viewManagers(viewerTypStr, lst);
4346 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4347 if (viewIndex >= 0 && viewIndex < lst.count()) {
4348 SUIT_ViewManager* vman = lst.at(viewIndex);
4349 SUIT_ViewModel* vmodel = vman->getViewModel();
4350 // SVTK view model can be casted to SALOME_View
4351 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4353 // store displayed actor in a temporary map for quicker
4354 // access later when restoring other parameters
4355 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4356 vtkRenderer* Renderer = vtkView->getRenderer();
4357 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4358 vtkActorCollection* theActors = aCopy.GetActors();
4359 theActors->InitTraversal();
4360 bool isFound = false;
4361 vtkActor *ac = theActors->GetNextActor();
4362 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4363 if (ac->IsA("SMESH_Actor")) {
4364 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4365 if (aGeomAc->hasIO()) {
4366 Handle(SALOME_InteractiveObject) io =
4367 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4368 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4370 vtkActors.Bind(viewIndex, aGeomAc);
4377 } // if (paramNameStr == "Visibility")
4380 // the rest properties "work" with SMESH_Actor
4383 QString val ((*valuesIt).c_str());
4386 if (paramNameStr == "Representation") {
4387 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4390 else if (paramNameStr == "IsShrunk") {
4392 if (!aSmeshActor->IsShrunk())
4393 aSmeshActor->SetShrink();
4396 if (aSmeshActor->IsShrunk())
4397 aSmeshActor->UnShrink();
4400 // Displayed entities
4401 else if (paramNameStr == "Entities") {
4402 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4403 if (mode.count() == 6) {
4404 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4405 MESSAGE("Invalid order of data in Entities, must be: "
4406 "e:0/1:f:0/1:v:0/1");
4409 unsigned int aMode = aSmeshActor->GetEntityMode();
4410 unsigned int aNewMode =
4411 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4412 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4413 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4414 if (aNewMode != aMode)
4415 aSmeshActor->SetEntityMode(aNewMode);
4420 else if (paramNameStr == "Colors") {
4421 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4422 if (colors.count() == 16) {
4423 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4424 colors[8] != "edge" || colors[12] != "node") {
4425 MESSAGE("Invalid order of data in Colors, must be: "
4426 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4429 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4430 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4431 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4432 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4436 // Sizes of lines and points
4437 else if (paramNameStr == "Sizes") {
4438 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4439 if (sizes.count() == 6) {
4440 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4441 MESSAGE("Invalid order of data in Sizes, must be: "
4442 "line:int:node:int:shrink:float");
4445 aSmeshActor->SetLineWidth(sizes[1].toInt());
4446 aSmeshActor->SetNodeSize(sizes[3].toInt());
4447 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4452 else if (paramNameStr == "Opacity") {
4453 aSmeshActor->SetOpacity(val.toFloat());
4456 else if (paramNameStr.startsWith("ClippingPlane")) {
4457 cout << "$$$ ClippingPlane 1" << endl;
4458 if (paramNameStr == "ClippingPlane1" || val == "Off")
4459 aSmeshActor->RemoveAllClippingPlanes();
4461 cout << "$$$ ClippingPlane 2" << endl;
4462 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4463 if (vals.count() == 4) { // format check: 4 values
4464 cout << "$$$ ClippingPlane 3" << endl;
4465 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4466 double aDistance = vals[1].toFloat();
4467 vtkFloatingPointType anAngle[2];
4468 anAngle[0] = vals[2].toFloat();
4469 anAngle[1] = vals[3].toFloat();
4471 QList<SUIT_ViewManager*> lst;
4472 getApp()->viewManagers(viewerTypStr, lst);
4473 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4474 if (viewIndex >= 0 && viewIndex < lst.count()) {
4475 SUIT_ViewManager* vman = lst.at(viewIndex);
4476 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4477 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4478 anOrientation, aDistance, anAngle);
4483 } // if (aSmeshActor)
4484 } // other parameters than Visibility
4486 } // for names/parameters iterator
4487 } // for entries iterator
4489 // update all VTK views
4490 QList<SUIT_ViewManager*> lst;
4491 getApp()->viewManagers(lst);
4492 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4493 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4494 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4495 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4496 vtkView->getRenderer()->ResetCameraClippingRange();
4503 \brief Adds preferences for dfont of VTK viewer
4505 \param pIf group identifier
4506 \param param parameter
4507 \return identifier of preferences
4509 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4511 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4513 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4516 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4517 fam.append( tr( "SMESH_FONT_COURIER" ) );
4518 fam.append( tr( "SMESH_FONT_TIMES" ) );
4520 setPreferenceProperty( tfont, "fonts", fam );
4522 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4523 setPreferenceProperty( tfont, "features", f );
4529 \brief Actions after hypothesis edition
4530 Updates object browser after hypothesis edition
4532 void SMESHGUI::onHypothesisEdit( int result )
4534 updateObjBrowser( true );