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
30 #include "SMESH_Client.hxx"
31 #include "SMESHGUI_NodesDlg.h"
32 #include "SMESHGUI_TransparencyDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_GroupDlg.h"
35 #include "SMESHGUI_RemoveNodesDlg.h"
36 #include "SMESHGUI_RemoveElementsDlg.h"
37 #include "SMESHGUI_MeshInfosDlg.h"
38 #include "SMESHGUI_StandardMeshInfosDlg.h"
39 #include "SMESHGUI_WhatIsDlg.h"
40 #include "SMESHGUI_Preferences_ColorDlg.h"
41 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
42 #include "SMESHGUI_Preferences_SelectionDlg.h"
43 #include "SMESHGUI_Hypotheses.h"
44 #include "SMESHGUI_MoveNodesDlg.h"
45 #include "SMESHGUI_AddMeshElementDlg.h"
46 #include "SMESHGUI_AddQuadraticElementDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_EditMeshDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
66 #include "SMESHGUI_ConvToQuadOp.h"
67 #include "SMESHGUI_MeshOp.h"
68 #include "SMESHGUI_Displayer.h"
69 #include "SMESHGUI_MakeNodeAtPointDlg.h"
70 #include "SMESHGUI_BuildCompoundDlg.h"
71 #include "SMESHGUI_ComputeDlg.h"
72 #include "SMESHGUI_FileInfoDlg.h"
73 #include "SMESHGUI_GroupOnShapeDlg.h"
75 #include "SMESHGUI_Utils.h"
76 #include "SMESHGUI_GEOMGenUtils.h"
77 #include "SMESHGUI_MeshUtils.h"
78 #include "SMESHGUI_GroupUtils.h"
79 #include "SMESHGUI_FilterUtils.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_VTKUtils.h"
82 #include "SMESHGUI_HypothesesUtils.h"
84 #include "SMESH_Actor.h"
85 #include "SMESH_Object.h"
86 #include "SMESH_TypeFilter.hxx"
88 #include "SalomeApp_Tools.h"
89 #include "SalomeApp_Study.h"
90 #include "SalomeApp_Application.h"
91 #include "SalomeApp_CheckFileDlg.h"
92 #include "SalomeApp_ImportOperation.h"
94 #include "LightApp_DataOwner.h"
95 #include "LightApp_Preferences.h"
96 #include "LightApp_VTKSelector.h"
97 #include "LightApp_Operation.h"
98 #include "LightApp_UpdateFlags.h"
99 #include "LightApp_NameDlg.h"
101 #include <SVTK_ViewWindow.h>
102 #include <SVTK_ViewModel.h>
103 #include <SVTK_InteractorStyle.h>
104 #include <SVTK_RenderWindowInteractor.h>
105 #include <SVTK_ViewManager.h>
107 #include "OB_Browser.h"
109 #include "SUIT_Tools.h"
110 #include "SUIT_MessageBox.h"
111 #include "SUIT_ResourceMgr.h"
112 #include "SUIT_FileDlg.h"
113 #include "SUIT_Desktop.h"
114 #include "SUIT_OverrideCursor.h"
115 #include "SUIT_Study.h"
116 #include "SUIT_Session.h"
118 #include "QtxPopupMgr.h"
120 #include "SALOME_ListIO.hxx"
121 #include "SALOME_ListIteratorOfListIO.hxx"
122 #include "SALOME_InteractiveObject.hxx"
123 #include "SALOME_NamingService.hxx"
124 #include "SALOME_LifeCycleCORBA.hxx"
126 #include "SALOMEconfig.h"
127 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
128 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
131 #define INCLUDE_MENUITEM_DEF
132 #include <qpopupmenu.h>
138 #include <boost/shared_ptr.hpp>
141 #include <vtkRenderer.h>
142 #include <vtkRenderWindow.h>
143 #include <vtkActorCollection.h>
144 #include <vtkScalarBarActor.h>
145 #include <vtkUnstructuredGrid.h>
147 #include "utilities.h"
149 #include "SALOMEDS_Study.hxx"
150 #include "SALOMEDSClient_StudyBuilder.hxx"
151 #include "SALOMEDSClient_SComponent.hxx"
153 #include <Standard_ErrorHandler.hxx>
159 //=============================================================
160 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
163 void ExportMeshToFile(int theCommandID);
165 void SetDisplayMode(int theCommandID);
167 void SetDisplayEntity(int theCommandID);
169 void Control( int theCommandID );
173 //=============================================================
174 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
180 if ( theCommandID == 113 ) {
181 filter.append( QObject::tr( "MED files (*.med)" ) );
182 filter.append( QObject::tr( "All files (*)" ) );
184 else if ( theCommandID == 112 ) {
185 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
187 else if ( theCommandID == 111 ) {
188 filter.append( QObject::tr( "DAT files (*.dat)" ) );
191 QString anInitialPath = "";
192 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
193 anInitialPath = QDir::currentDirPath();
195 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
198 QObject::tr( "SMESH_IMPORT_MESH" ) );
199 if ( filenames.count() > 0 ) {
200 SUIT_OverrideCursor wc;
201 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
204 bool isEmpty = false;
205 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
206 QString filename = *it;
207 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
209 switch ( theCommandID ) {
212 // DAT format (currently unsupported)
213 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
214 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
220 aMeshes->length( 1 );
221 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.latin1() );
222 if ( aMeshes[0]->_is_nil() )
223 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
224 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
230 SMESH::DriverMED_ReadStatus res;
231 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.latin1(), res );
232 if ( res != SMESH::DRS_OK ) {
233 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
234 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
240 catch ( const SALOME::SALOME_Exception& S_ex ) {
241 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
242 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
245 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
246 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
248 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
249 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
250 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
251 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
252 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
260 // update Object browser
261 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
263 // show Error message box if there were errors
264 if ( errors.count() > 0 ) {
265 SUIT_MessageBox::error1( SMESHGUI::desktop(),
266 QObject::tr( "SMESH_ERROR" ),
267 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
268 QObject::tr( "SMESH_BUT_OK" ) );
271 // show warning message box, if some imported mesh is empty
273 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
274 QObject::tr( "SMESH_WRN_WARNING" ),
275 QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
276 QObject::tr( "SMESH_BUT_OK" ) );
281 void ExportMeshToFile( int theCommandID )
283 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
284 SALOME_ListIO selected;
286 aSel->selectedObjects( selected );
288 SMESH::SMESH_Mesh_var aMesh;
289 if(selected.Extent() == 1)
290 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
291 if ( aMesh->_is_nil() ) {
292 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
293 QObject::tr( "SMESH_WRN_WARNING" ),
294 QObject::tr( "SMESH_BAD_MESH_SELECTION" ),
295 QObject::tr( "SMESH_BUT_OK" ) );
299 Handle(SALOME_InteractiveObject) anIObject = selected.First();
300 QString aFilter, aTitle = QObject::tr("Export mesh");
301 QMap<QString, SMESH::MED_VERSION> aFilterMap;
302 QMap<QString, int> aFilterMapSTL;
303 switch ( theCommandID ) {
307 if (aMesh->HasDuplicatedGroupNamesMED()) {
308 int aRet = SUIT_MessageBox::warn2
309 (SMESHGUI::desktop(),
310 QObject::tr("SMESH_WRN_WARNING"),
311 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
312 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
318 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
319 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
320 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
321 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
326 aFilter = QObject::tr("DAT files (*.dat)");
331 if (aMesh->NbPyramids()) {
332 int aRet = SUIT_MessageBox::warn2
333 (SMESHGUI::desktop(),
334 QObject::tr("SMESH_WRN_WARNING"),
335 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
336 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
341 aFilter = QObject::tr("IDEAS files (*.unv)");
349 there must be check on others mesh elements not equal triangles
351 if (aMesh->NbTriangles() < 1) {
352 SUIT_MessageBox::warn1
353 (SMESHGUI::desktop(),
354 QObject::tr("SMESH_WRN_WARNING"),
355 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
356 QObject::tr("SMESH_BUT_OK"));
359 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
360 int aRet = SUIT_MessageBox::warn2
361 (SMESHGUI::desktop(),
362 QObject::tr("SMESH_WRN_WARNING"),
363 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
364 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
370 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
371 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
379 SMESH::MED_VERSION aFormat;
380 // Init the parameter with the default value
381 bool aIsASCII_STL = true;
382 bool toCreateGroups = false;
383 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
385 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
387 QString anInitialPath = "";
388 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
389 anInitialPath = QDir::currentDirPath();
391 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
392 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
393 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
394 aFilter, aTitle, false);
396 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
398 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
399 for ( ; it != aFilterMapSTL.end(); ++it )
400 filters.push_back( it.key() );
402 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
403 fd->setCaption( aTitle );
404 fd->setFilters( filters );
405 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
406 if ( !anInitialPath.isEmpty() )
407 fd->setDir( anInitialPath );
408 fd->setSelection(anIObject->getName());
412 aFilename = fd->selectedFile();
413 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
418 else { // Export to MED
420 QString aDefaultFilter;
421 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
422 for ( ; it != aFilterMap.end(); ++it ) {
423 filters.push_back( it.key() );
424 if (it.data() == SMESH::MED_V2_2)
425 aDefaultFilter = it.key();
428 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
429 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
430 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
431 fd->setCaption( aTitle );
432 fd->setFilters( filters );
433 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
434 fd->setSelectedFilter(aDefaultFilter);
435 fd->SetChecked(toCreateGroups);
436 if ( !anInitialPath.isEmpty() )
437 fd->setDir( anInitialPath );
438 fd->setSelection(anIObject->getName());
442 aFilename = fd->selectedFile();
443 aFormat = aFilterMap[fd->selectedFilter()];
445 if ( !aFilename.isEmpty()
446 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
447 && aFormat==SMESH::MED_V2_1) {
448 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
449 QObject::tr("SMESH_WRN_WARNING"),
450 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
451 QObject::tr("SMESH_BUT_YES"),
452 QObject::tr("SMESH_BUT_NO"),
459 toCreateGroups = fd->IsChecked();
462 if ( !aFilename.isEmpty() ) {
463 // Check whether the file already exists and delete it if yes
464 QFile aFile( aFilename );
465 if ( aFile.exists() )
467 SUIT_OverrideCursor wc;
470 bool Renumber = false ;
471 // PAL 14172 : Check of we have to renumber or not from the preferences before export
473 Renumber= resMgr->booleanValue("SMESH","renumbering");
475 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
476 aMeshEditor->RenumberNodes();
477 aMeshEditor->RenumberElements();
478 if ( SMESHGUI::automaticUpdate() )
481 switch ( theCommandID ) {
484 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
488 aMesh->ExportDAT( aFilename.latin1() );
492 aMesh->ExportUNV( aFilename.latin1() );
496 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
502 catch (const SALOME::SALOME_Exception& S_ex){
504 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
505 QObject::tr("SMESH_WRN_WARNING"),
506 QObject::tr("SMESH_EXPORT_FAILED"),
507 QObject::tr("SMESH_BUT_OK"));
513 inline void InverseEntityMode(unsigned int& theOutputMode,
514 unsigned int theMode)
516 bool anIsNotPresent = ~theOutputMode & theMode;
518 theOutputMode |= theMode;
520 theOutputMode &= ~theMode;
523 void SetDisplayEntity(int theCommandID){
524 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
525 SALOME_ListIO selected;
527 aSel->selectedObjects( selected );
529 if(selected.Extent() >= 1){
530 SALOME_ListIteratorOfListIO It( selected );
531 for(; It.More(); It.Next()){
532 Handle(SALOME_InteractiveObject) IObject = It.Value();
533 if(IObject->hasEntry()){
534 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
535 unsigned int aMode = anActor->GetEntityMode();
536 switch(theCommandID){
538 InverseEntityMode(aMode,SMESH_Actor::eEdges);
541 InverseEntityMode(aMode,SMESH_Actor::eFaces);
544 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
547 aMode = SMESH_Actor::eAllEntity;
551 anActor->SetEntityMode(aMode);
559 SALOME_ListIO selected;
560 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
564 LightApp_SelectionMgr* aSel = app->selectionMgr();
565 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
566 if( !aSel || !appStudy )
569 aSel->selectedObjects( selected );
570 if( selected.IsEmpty() )
573 Handle(SALOME_InteractiveObject) anIObject = selected.First();
575 _PTR(Study) aStudy = appStudy->studyDS();
576 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
577 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
578 if( aMainObject->_is_nil() )
581 aMainObject->SetAutoColor( true );
583 QValueList<SALOMEDS::Color> aReservedColors;
585 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
586 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
588 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
589 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
591 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
592 aGroupObject->SetColor( aColor );
593 aReservedColors.append( aColor );
595 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
596 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
598 if( aGroupObject->GetType() == SMESH::NODE )
599 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
600 else if( aGroupObject->GetType() == SMESH::EDGE )
601 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
603 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
607 SMESH::RepaintCurrentView();
610 void DisableAutoColor(){
611 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
612 SALOME_ListIO selected;
614 aSel->selectedObjects( selected );
616 if(selected.Extent()){
617 Handle(SALOME_InteractiveObject) anIObject = selected.First();
618 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
619 if ( !aMesh->_is_nil() ) {
620 aMesh->SetAutoColor( false );
625 void SetDisplayMode(int theCommandID){
626 SALOME_ListIO selected;
627 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
631 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
632 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
633 if( !aSel || !appStudy )
636 _PTR(Study) aStudy = appStudy->studyDS();
638 aSel->selectedObjects( selected );
640 if(selected.Extent() >= 1){
641 switch(theCommandID){
643 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
644 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
648 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
649 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
652 SALOME_ListIteratorOfListIO It( selected );
653 for(; It.More(); It.Next()){
654 Handle(SALOME_InteractiveObject) IObject = It.Value();
655 if(IObject->hasEntry()){
656 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
657 switch(theCommandID){
659 anActor->SetRepresentation(SMESH_Actor::eEdge);
662 anActor->SetRepresentation(SMESH_Actor::eSurface);
665 if(anActor->IsShrunk())
668 anActor->SetShrink();
671 anActor->SetRepresentation(SMESH_Actor::ePoint);
674 vtkFloatingPointType color[3];
675 anActor->GetSufaceColor(color[0], color[1], color[2]);
676 int c0 = int (color[0] * 255);
677 int c1 = int (color[1] * 255);
678 int c2 = int (color[2] * 255);
679 QColor c(c0, c1, c2);
681 vtkFloatingPointType edgecolor[3];
682 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
683 c0 = int (edgecolor[0] * 255);
684 c1 = int (edgecolor[1] * 255);
685 c2 = int (edgecolor[2] * 255);
686 QColor e(c0, c1, c2);
688 vtkFloatingPointType backfacecolor[3];
689 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
690 c0 = int (backfacecolor[0] * 255);
691 c1 = int (backfacecolor[1] * 255);
692 c2 = int (backfacecolor[2] * 255);
693 QColor b(c0, c1, c2);
695 vtkFloatingPointType nodecolor[3];
696 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
697 c0 = int (nodecolor[0] * 255);
698 c1 = int (nodecolor[1] * 255);
699 c2 = int (nodecolor[2] * 255);
700 QColor n(c0, c1, c2);
702 int Edgewidth = (int)anActor->GetLineWidth();
705 int intValue = int(anActor->GetNodeSize());
706 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
708 SMESHGUI_Preferences_ColorDlg *aDlg =
709 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
710 aDlg->SetColor(1, c);
711 aDlg->SetColor(2, e);
712 aDlg->SetColor(3, n);
713 aDlg->SetColor(4, b);
714 aDlg->SetIntValue(1, Edgewidth);
715 aDlg->SetIntValue(2, intValue);
716 aDlg->SetIntValue(3, int(Shrink*100.));
718 QColor color = aDlg->GetColor(1);
719 QColor edgecolor = aDlg->GetColor(2);
720 QColor nodecolor = aDlg->GetColor(3);
721 QColor backfacecolor = aDlg->GetColor(4);
722 /* actor color and backface color */
723 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
724 vtkFloatingPointType (color.green()) / 255.,
725 vtkFloatingPointType (color.blue()) / 255.);
726 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
727 vtkFloatingPointType (backfacecolor.green()) / 255.,
728 vtkFloatingPointType (backfacecolor.blue()) / 255.);
731 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
732 vtkFloatingPointType (edgecolor.green()) / 255.,
733 vtkFloatingPointType (edgecolor.blue()) / 255.);
735 /* Shrink factor and size edges */
736 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
737 anActor->SetLineWidth(aDlg->GetIntValue(1));
739 /* Nodes color and size */
740 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
741 vtkFloatingPointType (nodecolor.green()) / 255.,
742 vtkFloatingPointType (nodecolor.blue()) / 255.);
743 anActor->SetNodeSize(aDlg->GetIntValue(2));
745 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
746 if( !aGroupObject->_is_nil() )
748 SALOMEDS::Color aColor;
749 aColor.R = (float)color.red() / 255.0;
750 aColor.G = (float)color.green() / 255.0;
751 aColor.B = (float)color.blue() / 255.0;
752 aGroupObject->SetColor( aColor );
762 SMESH::RepaintCurrentView();
766 void Control( int theCommandID )
768 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
769 SALOME_ListIO selected;
771 aSel->selectedObjects( selected );
773 if( !selected.IsEmpty() ){
774 Handle(SALOME_InteractiveObject) anIO = selected.First();
777 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
778 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
779 switch ( theCommandID ){
781 aTitle = QObject::tr( "LENGTH_EDGES" );
782 aControl = SMESH_Actor::eLength;
785 aTitle = QObject::tr( "LENGTH2D_EDGES" );
786 aControl = SMESH_Actor::eLength2D;
789 aTitle = QObject::tr( "FREE_EDGES" );
790 aControl = SMESH_Actor::eFreeEdges;
793 aTitle = QObject::tr( "FREE_BORDERS" );
794 aControl = SMESH_Actor::eFreeBorders;
797 aTitle = QObject::tr( "MULTI_BORDERS" );
798 aControl = SMESH_Actor::eMultiConnection;
801 aTitle = QObject::tr( "MULTI2D_BORDERS" );
802 aControl = SMESH_Actor::eMultiConnection2D;
805 aTitle = QObject::tr( "AREA_ELEMENTS" );
806 aControl = SMESH_Actor::eArea;
809 aTitle = QObject::tr( "TAPER_ELEMENTS" );
810 aControl = SMESH_Actor::eTaper;
813 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
814 aControl = SMESH_Actor::eAspectRatio;
817 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
818 aControl = SMESH_Actor::eAspectRatio3D;
821 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
822 aControl = SMESH_Actor::eMinimumAngle;
825 aTitle = QObject::tr( "WARP_ELEMENTS" );
826 aControl = SMESH_Actor::eWarping;
829 aTitle = QObject::tr( "SKEW_ELEMENTS" );
830 aControl = SMESH_Actor::eSkew;
833 aTitle = QObject::tr( "SMESH_VOLUME" );
834 aControl = SMESH_Actor::eVolume3D;
837 anActor->SetControlMode(aControl);
838 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
839 SMESH::RepaintCurrentView();
846 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
847 MeshObjectType theType,
848 const QString theInTypeName,
849 QString & theOutTypeName)
851 SMESH_TypeFilter aTypeFilter( theType );
853 if( !theIO.IsNull() )
855 entry = theIO->getEntry();
856 LightApp_DataOwner owner( entry );
857 if ( aTypeFilter.isOk( &owner )) {
858 theOutTypeName = theInTypeName;
866 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
868 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
869 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
871 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
872 CORBA::String_var anID = aSComp->GetID().c_str();
873 if (!strcmp(anID.in(),theIO->getEntry()))
879 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
880 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
881 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
882 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
883 CheckOIType ( theIO, GROUP, "Group", aTypeName )
891 QString CheckHomogeneousSelection()
893 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
894 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
895 SALOME_ListIO selected;
897 aSel->selectedObjects( selected );
899 QString RefType = CheckTypeObject(selected.First());
900 SALOME_ListIteratorOfListIO It(selected);
901 for (; It.More(); It.Next())
903 Handle(SALOME_InteractiveObject) IObject = It.Value();
904 QString Type = CheckTypeObject(IObject);
905 if (Type.compare(RefType) != 0)
906 return "Heterogeneous Selection";
913 void SMESHGUI::OnEditDelete()
915 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
916 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
917 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
919 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
920 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
921 _PTR(GenericAttribute) anAttr;
922 _PTR(AttributeIOR) anIOR;
926 QString aParentComponent = QString::null;
927 Handle(SALOME_InteractiveObject) anIO;
928 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
931 QString cur = anIt.Value()->getComponentDataType();
932 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
934 // check if object is reference
935 _PTR(SObject) aRefSObj;
936 aNameList.append("\n - ");
937 if ( aSO->ReferencedObject( aRefSObj ) ) {
938 QString aRefName = aRefSObj->GetName();
939 aNameList.append( aRefName );
940 cur = aRefSObj->GetFatherComponent()->ComponentDataType();
943 aNameList.append(anIO->getName());
947 if( aParentComponent.isNull() )
948 aParentComponent = cur;
949 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
950 aParentComponent = "";
953 if ( objectCount == 0 )
954 return; // No Valid Objects Selected
956 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
957 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
958 QObject::tr("ERR_ERROR"),
959 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
960 QObject::tr("BUT_OK") );
963 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
964 if (SUIT_MessageBox::warn2
965 (SMESHGUI::desktop(),
966 QObject::tr("SMESH_WRN_WARNING"),
967 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
968 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
971 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
972 SUIT_ViewManager* vm = anApp->activeViewManager();
973 int nbSf = vm->getViewsCount();
975 SALOME_ListIteratorOfListIO It(selected);
977 aStudyBuilder->NewCommand(); // There is a transaction
978 for(; It.More(); It.Next()){ // loop on selected IO's
979 Handle(SALOME_InteractiveObject) IObject = It.Value();
980 if(IObject->hasEntry()) {
981 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
983 // disable removal of "SMESH" component object
984 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
986 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
989 //Check the referenced object
990 _PTR(SObject) refobj;
991 if ( aSO && aSO->ReferencedObject( refobj ) )
992 aSO = refobj; // Delete main Object instead of reference
994 // put the whole hierarchy of sub-objects of the selected SO into a list and
995 // then treat them all starting from the deepest objects (at list back)
997 list< _PTR(SObject) > listSO;
998 listSO.push_back( aSO );
999 list< _PTR(SObject) >::iterator itSO = listSO.begin();
1000 for ( ; itSO != listSO.end(); ++itSO ) {
1001 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1002 for (it->InitEx(false); it->More(); it->Next())
1003 listSO.push_back( it->Value() );
1006 // treat SO's in the list starting from the back
1008 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1009 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1010 _PTR(SObject) SO = *ritSO;
1011 if ( !SO ) continue;
1012 string anEntry = SO->GetID();
1014 /** Erase graphical object **/
1015 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1016 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
1017 for(int i = 0; i < nbSf; i++){
1018 SUIT_ViewWindow *sf = aViews[i];
1019 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1020 SMESH::RemoveActor(sf,anActor);
1025 /** Remove an object from data structures **/
1026 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1027 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1028 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1029 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1030 aMesh->RemoveGroup( aGroup );
1032 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1033 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1034 aMesh->RemoveSubMesh( aSubMesh );
1036 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1038 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1041 IObject = new SALOME_InteractiveObject
1042 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1043 QString objType = CheckTypeObject(IObject);
1044 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1045 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1046 aStudyBuilder->RemoveObjectWithChildren( SO );
1048 else {// default action: remove SObject from the study
1049 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1050 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1052 aStudyBuilder->RemoveObjectWithChildren( SO );
1056 } /* listSO back loop */
1057 } /* IObject->hasEntry() */
1059 aStudyBuilder->CommitCommand();
1061 /* Clear any previous selection */
1063 aSel->setSelectedObjects( l1 );
1065 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1070 SMESHGUI_EXPORT CAM_Module* createModule()
1072 return new SMESHGUI();
1076 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1078 //=============================================================================
1082 //=============================================================================
1083 SMESHGUI::SMESHGUI() :
1084 SalomeApp_Module( "SMESH" )
1086 if ( CORBA::is_nil( myComponentSMESH ) )
1088 CORBA::Boolean anIsEmbeddedMode;
1089 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1092 myActiveDialogBox = 0;
1093 myFilterLibraryDlg = 0;
1097 SMESH::GetFilterManager();
1098 SMESH::GetPattern();
1100 /* load resources for all available meshers */
1101 SMESH::InitAvailableHypotheses();
1104 //=============================================================================
1108 //=============================================================================
1109 SMESHGUI::~SMESHGUI()
1111 SMESH::GetFilterManager()->Destroy();
1112 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1115 //=============================================================================
1119 //=============================================================================
1120 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1122 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1124 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1129 bool SMESHGUI::automaticUpdate()
1131 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1135 return resMgr->booleanValue( "SMESH", "auto_update", false );
1138 //=============================================================================
1142 //=============================================================================
1143 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1145 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1148 //=============================================================================
1152 //=============================================================================
1153 SMESHGUI* SMESHGUI::GetSMESHGUI()
1155 SMESHGUI* smeshMod = 0;
1156 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1159 CAM_Module* module = app->module( "Mesh" );
1160 smeshMod = dynamic_cast<SMESHGUI*>( module );
1163 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1165 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1168 _PTR(Study) aStudy = study->studyDS();
1170 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1179 Standard_EXPORT SMESHGUI* GetComponentGUI()
1181 return SMESHGUI::GetSMESHGUI();
1185 //=============================================================================
1189 //=============================================================================
1190 void SMESHGUI::SetState(int aState)
1195 //=============================================================================
1199 //=============================================================================
1200 void SMESHGUI::ResetState()
1205 //=============================================================================
1209 //=============================================================================
1210 void SMESHGUI::EmitSignalDeactivateDialog()
1212 emit SignalDeactivateActiveDialog();
1215 //=============================================================================
1219 //=============================================================================
1220 void SMESHGUI::EmitSignalStudyFrameChanged()
1222 emit SignalStudyFrameChanged();
1225 //=============================================================================
1229 //=============================================================================
1230 void SMESHGUI::EmitSignalCloseAllDialogs()
1232 emit SignalCloseAllDialogs();
1235 //=============================================================================
1239 //=============================================================================
1240 QDialog *SMESHGUI::GetActiveDialogBox()
1242 return myActiveDialogBox;
1245 //=============================================================================
1249 //=============================================================================
1250 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1252 myActiveDialogBox = (QDialog *) aDlg;
1256 //=============================================================================
1260 //=============================================================================
1261 SUIT_Desktop* SMESHGUI::desktop()
1263 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1265 return app->desktop();
1270 //=============================================================================
1274 //=============================================================================
1275 SalomeApp_Study* SMESHGUI::activeStudy()
1277 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1279 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1284 //=============================================================================
1288 //=============================================================================
1289 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1291 /* Here the position is on the bottom right corner - 10 */
1292 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1294 SUIT_Desktop *PP = desktop();
1295 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1296 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1300 //=============================================================================
1304 //=============================================================================
1305 static int isStudyLocked(_PTR(Study) theStudy){
1306 return theStudy->GetProperties()->IsLocked();
1309 static bool checkLock(_PTR(Study) theStudy) {
1310 if (isStudyLocked(theStudy)) {
1311 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1312 QObject::tr("WRN_WARNING"),
1313 QObject::tr("WRN_STUDY_LOCKED"),
1314 QObject::tr("BUT_OK") );
1320 //=======================================================================
1321 //function : CheckActiveStudyLocked
1323 //=======================================================================
1325 bool SMESHGUI::isActiveStudyLocked()
1327 _PTR(Study) aStudy = activeStudy()->studyDS();
1328 return checkLock( aStudy );
1331 //=============================================================================
1335 //=============================================================================
1336 bool SMESHGUI::OnGUIEvent( int theCommandID )
1338 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1342 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1343 SUIT_ResourceMgr* mgr = resourceMgr();
1347 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1348 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1351 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1352 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1354 //QAction* act = action( theCommandID );
1356 switch (theCommandID) {
1358 if(checkLock(aStudy)) break;
1366 if(checkLock(aStudy)) break;
1367 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1371 case 150: //MED FILE INFORMATION
1373 SALOME_ListIO selected;
1374 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1376 aSel->selectedObjects( selected );
1377 if( selected.Extent() )
1379 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1380 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1381 if ( !aMesh->_is_nil() )
1383 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1389 case 122: // EXPORT MED
1398 ::ExportMeshToFile(theCommandID);
1402 case 200: // SCALAR BAR
1404 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1405 SALOME_ListIO selected;
1407 aSel->selectedObjects( selected );
1409 if( selected.Extent() ) {
1410 Handle(SALOME_InteractiveObject) anIO = selected.First();
1411 if( anIO->hasEntry() ) {
1412 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1413 anActor->SetControlMode( SMESH_Actor::eNone );
1421 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1431 ::DisableAutoColor();
1434 case 1134: // Clipping
1435 case 1133: // Tranparency
1436 case 1132: // Colors / Size
1443 ::SetDisplayMode(theCommandID);
1449 case 219: // Volumes
1450 case 220: // All Entity
1451 ::SetDisplayEntity(theCommandID);
1456 if(checkLock(aStudy)) break;
1458 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1461 SMESH::UpdateView();
1463 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1464 SMESH::OnVisuException();
1466 catch (...) { // PAL16774 (Crash after display of many groups)
1467 SMESH::OnVisuException();
1471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1472 aSel->selectedObjects( l );
1473 aSel->setSelectedObjects( l );
1478 case 301: // DISPLAY
1479 case 302: // DISPLAY ONLY
1481 SMESH::EDisplaing anAction;
1482 switch (theCommandID) {
1483 case 300: anAction = SMESH::eErase; break;
1484 case 301: anAction = SMESH::eDisplay; break;
1485 case 302: anAction = SMESH::eDisplayOnly; break;
1488 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1489 SALOME_ListIO sel_objects, to_process;
1491 aSel->selectedObjects( sel_objects );
1493 if( theCommandID==302 )
1494 startOperation( myEraseAll );
1496 extractContainers( sel_objects, to_process );
1499 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1503 SALOME_ListIteratorOfListIO It( to_process );
1504 for (; It.More(); It.Next()) {
1505 Handle(SALOME_InteractiveObject) IOS = It.Value();
1506 if (IOS->hasEntry()) {
1507 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1508 break; // PAL16774 (Crash after display of many groups)
1509 if (anAction == SMESH::eDisplayOnly)
1510 anAction = SMESH::eDisplay;
1515 // PAL13338 + PAL15161 -->
1516 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1517 SMESH::UpdateView();
1518 // PAL13338 + PAL15161 <--
1520 catch (...) { // PAL16774 (Crash after display of many groups)
1521 SMESH::OnVisuException();
1524 if (anAction == SMESH::eErase) {
1526 aSel->setSelectedObjects( l1 );
1529 aSel->setSelectedObjects( to_process );
1536 if(checkLock(aStudy)) break;
1539 EmitSignalDeactivateDialog();
1541 new SMESHGUI_NodesDlg(this);
1544 SUIT_MessageBox::warn1(desktop(),
1545 tr("SMESH_WRN_WARNING"),
1546 tr("SMESH_WRN_VIEWER_VTK"),
1547 tr("SMESH_BUT_OK"));
1552 case 2151: // FILTER
1556 EmitSignalDeactivateDialog();
1557 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1562 case 406: // MOVE NODE
1566 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1567 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1571 if(checkLock(aStudy)) break;
1572 new SMESHGUI_MoveNodesDlg(this);
1576 case 701: // COMPUTE MESH
1578 if (checkLock(aStudy)) break;
1580 startOperation( 701 );
1584 case 702: // Create mesh
1585 startOperation( 702 );
1587 case 703: // Create sub-mesh
1588 startOperation( 703 );
1590 case 704: // Edit mesh/sub-mesh
1591 startOperation( 704 );
1593 case 710: // Build compound mesh
1595 if (checkLock(aStudy)) break;
1596 EmitSignalDeactivateDialog();
1597 new SMESHGUI_BuildCompoundDlg( this );
1601 case 407: // DIAGONAL INVERSION
1602 case 408: // Delete diagonal
1606 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1607 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1611 if ( checkLock( aStudy ) )
1614 /*Standard_Boolean aRes;
1615 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1616 if ( aMesh->_is_nil() )
1618 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1619 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1623 EmitSignalDeactivateDialog();
1624 if ( theCommandID == 407 )
1625 new SMESHGUI_TrianglesInversionDlg(this);
1627 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1630 case 409: // Change orientation
1631 case 410: // Union of triangles
1632 case 411: // Cutting of quadrangles
1636 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1637 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1641 if ( checkLock( aStudy ) )
1644 EmitSignalDeactivateDialog();
1645 SMESHGUI_MultiEditDlg* aDlg = NULL;
1646 if ( theCommandID == 409 )
1647 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1648 else if ( theCommandID == 410 )
1649 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1651 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1656 case 412: // Smoothing
1658 if(checkLock(aStudy)) break;
1660 EmitSignalDeactivateDialog();
1661 new SMESHGUI_SmoothingDlg( this );
1664 SUIT_MessageBox::warn1(desktop(),
1665 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1666 tr("SMESH_BUT_OK"));
1670 case 413: // Extrusion
1672 if (checkLock(aStudy)) break;
1674 EmitSignalDeactivateDialog();
1675 new SMESHGUI_ExtrusionDlg ( this );
1677 SUIT_MessageBox::warn1(desktop(),
1678 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1679 tr("SMESH_BUT_OK"));
1683 case 414: // Revolution
1685 if(checkLock(aStudy)) break;
1687 EmitSignalDeactivateDialog();
1688 new SMESHGUI_RevolutionDlg( this );
1691 SUIT_MessageBox::warn1(desktop(),
1692 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1693 tr("SMESH_BUT_OK"));
1697 case 415: // Pattern mapping
1699 if ( checkLock( aStudy ) )
1703 EmitSignalDeactivateDialog();
1704 new SMESHGUI_MeshPatternDlg( this );
1707 SUIT_MessageBox::warn1(desktop(),
1708 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1709 tr("SMESH_BUT_OK"));
1713 case 416: // Extrusion along a path
1715 if (checkLock(aStudy)) break;
1717 EmitSignalDeactivateDialog();
1718 new SMESHGUI_ExtrusionAlongPathDlg( this );
1720 SUIT_MessageBox::warn1(desktop(),
1721 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1722 tr("SMESH_BUT_OK"));
1726 case 417: // Convert mesh to quadratic
1728 startOperation( 417 );
1729 /* if (checkLock(aStudy)) break;
1731 EmitSignalDeactivateDialog();
1732 new SMESHGUI_ConvToQuadDlg();
1734 SUIT_MessageBox::warn1(desktop(),
1735 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1736 tr("SMESH_BUT_OK"));
1740 case 806: // CREATE GEO GROUP
1742 startOperation( 806 );
1745 case 801: // CREATE GROUP
1749 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1750 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1754 if(checkLock(aStudy)) break;
1755 EmitSignalDeactivateDialog();
1756 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1758 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1759 SALOME_ListIO selected;
1761 aSel->selectedObjects( selected );
1763 int nbSel = selected.Extent();
1765 // check if mesh is selected
1766 aMesh = SMESH::GetMeshByIO( selected.First() );
1768 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1773 case 802: // CONSTRUCT GROUP
1777 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1778 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1782 if(checkLock(aStudy)) break;
1783 EmitSignalDeactivateDialog();
1785 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1786 SALOME_ListIO selected;
1788 aSel->selectedObjects( selected );
1790 int nbSel = selected.Extent();
1792 // check if submesh is selected
1793 Handle(SALOME_InteractiveObject) IObject = selected.First();
1794 if (IObject->hasEntry()) {
1795 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1797 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1798 if (!aSubMesh->_is_nil()) {
1800 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1801 // get submesh elements list by types
1802 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1803 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1804 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1805 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1806 // create group for each type o elements
1807 QString aName = IObject->getName();
1808 if (aNodes->length() > 0) {
1809 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1810 aGroup->Add(aNodes.inout());
1812 if (aEdges->length() > 0) {
1813 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1814 aGroup->Add(aEdges.inout());
1816 if (aFaces->length() > 0) {
1817 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1818 aGroup->Add(aFaces.inout());
1820 if (aVolumes->length() > 0) {
1821 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1822 aGroup->Add(aVolumes.inout());
1827 catch(const SALOME::SALOME_Exception & S_ex){
1828 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1835 SUIT_MessageBox::warn1(desktop(),
1836 tr("SMESH_WRN_WARNING"),
1837 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1838 tr("SMESH_BUT_OK"));
1843 case 803: // EDIT GROUP
1847 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1848 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1852 if(checkLock(aStudy)) break;
1853 EmitSignalDeactivateDialog();
1855 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1856 SALOME_ListIO selected;
1858 aSel->selectedObjects( selected );
1860 SALOME_ListIteratorOfListIO It (selected);
1861 int nbSelectedGroups = 0;
1862 for ( ; It.More(); It.Next() )
1864 SMESH::SMESH_GroupBase_var aGroup =
1865 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1866 if (!aGroup->_is_nil()) {
1868 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1872 if (nbSelectedGroups == 0)
1874 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1880 case 804: // Add elements to group
1882 if(checkLock(aStudy)) break;
1883 if (myState == 800) {
1884 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1885 if (aDlg) aDlg->onAdd();
1890 case 805: // Remove elements from group
1892 if(checkLock(aStudy)) break;
1893 if (myState == 800) {
1894 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1895 if (aDlg) aDlg->onRemove();
1900 case 810: // Union Groups
1901 case 811: // Intersect groups
1902 case 812: // Cut groups
1906 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1907 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1911 if ( checkLock( aStudy ) )
1914 EmitSignalDeactivateDialog();
1917 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1918 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1919 else aMode = SMESHGUI_GroupOpDlg::CUT;
1921 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1925 case 813: // Delete groups with their contents
1929 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1930 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1934 if ( checkLock( aStudy ) )
1937 EmitSignalDeactivateDialog();
1939 new SMESHGUI_DeleteGroupDlg( this );
1943 case 900: // MESH INFOS
1945 EmitSignalDeactivateDialog();
1946 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1947 SALOME_ListIO selected;
1949 aSel->selectedObjects( selected );
1951 if ( selected.Extent() > 1 ) { // a dlg for each IO
1953 SALOME_ListIteratorOfListIO It (selected);
1954 for ( ; It.More(); It.Next() ) {
1955 IOs.Clear(); IOs.Append( It.Value() );
1956 aSel->setSelectedObjects( IOs );
1957 new SMESHGUI_MeshInfosDlg(this, "", false);
1959 // restore selection
1960 aSel->setSelectedObjects( selected );
1963 new SMESHGUI_MeshInfosDlg(this, "", false);
1967 case 902: // STANDARD MESH INFOS
1969 EmitSignalDeactivateDialog();
1970 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1971 SALOME_ListIO selected;
1973 aSel->selectedObjects( selected );
1975 if ( selected.Extent() > 1 ) { // a dlg for each IO
1977 SALOME_ListIteratorOfListIO It (selected);
1978 for ( ; It.More(); It.Next() ) {
1980 IOs.Append( It.Value() );
1981 aSel->setSelectedObjects( IOs );
1982 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1984 // restore selection
1985 aSel->setSelectedObjects( selected );
1988 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1992 case 903: // WHAT IS
1994 EmitSignalDeactivateDialog();
1995 new SMESHGUI_WhatIsDlg( this, "", false);
1999 case 1100: // EDIT HYPOTHESIS
2001 if(checkLock(aStudy)) break;
2003 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2004 SALOME_ListIO selected;
2006 aSel->selectedObjects( selected );
2008 int nbSel = selected.Extent();
2011 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2012 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2014 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2015 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2016 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2017 if ( !aHypothesis->_is_nil() )
2019 CORBA::String_var aHypType = aHypothesis->GetName();
2020 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
2022 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2029 updateObjBrowser( true );
2033 case 1101: // RENAME
2035 if ( checkLock( aStudy ) )
2038 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2039 SALOME_ListIO selected;
2041 aSel->selectedObjects( selected );
2043 bool isAny = false; // iss there any appropriate object selected
2045 SALOME_ListIteratorOfListIO It( selected );
2046 for ( ; It.More(); It.Next() )
2048 Handle(SALOME_InteractiveObject) IObject = It.Value();
2049 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2050 _PTR(GenericAttribute) anAttr;
2051 _PTR(AttributeName) aName;
2054 if ( obj->FindAttribute(anAttr, "AttributeName") )
2057 QString newName = QString(aName->Value().c_str());
2059 // check type to prevent renaming of inappropriate objects
2060 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2061 if (aType == MESH || aType == GROUP ||
2062 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2063 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2064 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2065 aType == HYPOTHESIS || aType == ALGORITHM)
2068 newName = LightApp_NameDlg::getName(desktop(), newName);
2069 if ( !newName.isEmpty() )
2071 //old source: aStudy->renameIObject( IObject, newName );
2072 aName->SetValue( newName.latin1() );
2074 // if current object is group update group's name
2075 SMESH::SMESH_GroupBase_var aGroup =
2076 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2077 if (!aGroup->_is_nil() )
2078 aGroup->SetName( newName.latin1() );
2088 SUIT_MessageBox::warn1(desktop(),
2089 QObject::tr("SMESH_WRN_WARNING"),
2090 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2091 QObject::tr("SMESH_BUT_OK"));
2096 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2098 if(checkLock(aStudy)) break;
2099 SUIT_OverrideCursor wc;
2101 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2102 SALOME_ListIO selected;
2104 aSel->selectedObjects( selected, QString::null, false );
2106 SALOME_ListIteratorOfListIO It(selected);
2107 for (int i = 0; It.More(); It.Next(), i++) {
2108 Handle(SALOME_InteractiveObject) IObject = It.Value();
2109 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2112 aSel->setSelectedObjects( l1 );
2117 case 401: // GEOM::EDGE
2118 case 4021: // TRIANGLE
2120 case 4023: // POLYGON
2124 if(checkLock(aStudy)) break;
2126 EmitSignalDeactivateDialog();
2127 SMDSAbs_ElementType type = SMDSAbs_Edge;
2129 switch (theCommandID) {
2130 case 4021: // TRIANGLE
2131 type = SMDSAbs_Face; nbNodes = 3; break;
2133 type = SMDSAbs_Face; nbNodes = 4; break;
2135 type = SMDSAbs_Volume; nbNodes = 4; break;
2136 case 4023: // POLYGON
2137 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2139 type = SMDSAbs_Volume; nbNodes = 8; break;
2140 case 4033: // POLYHEDRE
2141 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2144 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2147 SUIT_MessageBox::warn1(desktop(),
2148 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2149 tr("SMESH_BUT_OK"));
2153 case 4033: // POLYHEDRON
2155 if(checkLock(aStudy)) break;
2157 EmitSignalDeactivateDialog();
2158 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2161 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2162 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2163 tr("SMESH_BUT_OK"));
2167 case 4034: // QUADRATIC EDGE
2168 case 4035: // QUADRATIC TRIANGLE
2169 case 4036: // QUADRATIC QUADRANGLE
2170 case 4037: // QUADRATIC TETRAHEDRON
2171 case 4038: // QUADRATIC PYRAMID
2172 case 4039: // QUADRATIC PENTAHEDRON
2173 case 4040: // QUADRATIC HEXAHEDRON
2175 if(checkLock(aStudy)) break;
2177 EmitSignalDeactivateDialog();
2180 switch (theCommandID) {
2182 type = QUAD_EDGE; break;
2184 type = QUAD_TRIANGLE; break;
2186 type = QUAD_QUADRANGLE; break;
2188 type = QUAD_TETRAHEDRON; break;
2190 type = QUAD_PYRAMID; break;
2192 type = QUAD_PENTAHEDRON; break;
2194 type = QUAD_HEXAHEDRON;
2198 new SMESHGUI_AddQuadraticElementDlg( this, type );
2201 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2202 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2203 tr("SMESH_BUT_OK"));
2207 case 4041: // REMOVES NODES
2209 if(checkLock(aStudy)) break;
2211 EmitSignalDeactivateDialog();
2212 new SMESHGUI_RemoveNodesDlg(this);
2215 SUIT_MessageBox::warn1(desktop(),
2216 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2217 tr("SMESH_BUT_OK"));
2221 case 4042: // REMOVES ELEMENTS
2223 if(checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 new SMESHGUI_RemoveElementsDlg(this);
2230 SUIT_MessageBox::warn1(desktop(),
2231 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2232 tr("SMESH_BUT_OK"));
2236 case 4043: { // CLEAR_MESH
2238 if(checkLock(aStudy)) break;
2240 SALOME_ListIO selected;
2241 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2242 aSel->selectedObjects( selected );
2244 SUIT_OverrideCursor wc;
2245 SALOME_ListIteratorOfListIO It (selected);
2246 for ( ; It.More(); It.Next() )
2248 Handle(SALOME_InteractiveObject) IOS = It.Value();
2249 SMESH::SMESH_Mesh_var aMesh =
2250 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2251 if ( aMesh->_is_nil()) continue;
2253 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2255 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2256 SMESH::ModifiedMesh( aMeshSObj, false, true);
2257 // hide groups and submeshes
2258 _PTR(ChildIterator) anIter =
2259 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2260 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2262 _PTR(SObject) so = anIter->Value();
2263 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2266 catch (const SALOME::SALOME_Exception& S_ex){
2268 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2272 SMESH::UpdateView();
2276 case 4051: // RENUMBERING NODES
2278 if(checkLock(aStudy)) break;
2280 EmitSignalDeactivateDialog();
2281 new SMESHGUI_RenumberingDlg( this, "", 0);
2285 SUIT_MessageBox::warn1(desktop(),
2286 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2287 tr("SMESH_BUT_OK"));
2291 case 4052: // RENUMBERING ELEMENTS
2293 if(checkLock(aStudy)) break;
2295 EmitSignalDeactivateDialog();
2296 new SMESHGUI_RenumberingDlg( this, "", 1);
2300 SUIT_MessageBox::warn1(desktop(),
2301 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2302 tr("SMESH_BUT_OK"));
2306 case 4061: // TRANSLATION
2308 if(checkLock(aStudy)) break;
2310 EmitSignalDeactivateDialog();
2311 new SMESHGUI_TranslationDlg( this );
2314 SUIT_MessageBox::warn1(desktop(),
2315 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2316 tr("SMESH_BUT_OK"));
2320 case 4062: // ROTATION
2322 if(checkLock(aStudy)) break;
2324 EmitSignalDeactivateDialog();
2325 new SMESHGUI_RotationDlg( this );
2328 SUIT_MessageBox::warn1(desktop(),
2329 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2330 tr("SMESH_BUT_OK"));
2334 case 4063: // SYMMETRY
2336 if(checkLock(aStudy)) break;
2338 EmitSignalDeactivateDialog();
2339 new SMESHGUI_SymmetryDlg( this );
2342 SUIT_MessageBox::warn1(desktop(),
2343 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2344 tr("SMESH_BUT_OK"));
2348 case 4064: // SEWING
2350 if(checkLock(aStudy)) break;
2352 EmitSignalDeactivateDialog();
2353 new SMESHGUI_SewingDlg( this );
2356 SUIT_MessageBox::warn1(desktop(),
2357 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2358 tr("SMESH_BUT_OK"));
2362 case 4065: // MERGE NODES
2364 if(checkLock(aStudy)) break;
2366 EmitSignalDeactivateDialog();
2367 new SMESHGUI_EditMeshDlg( this, 0 );
2370 SUIT_MessageBox::warn1(desktop(),
2371 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2372 tr("SMESH_BUT_OK"));
2376 case 4066: // MERGE EQUAL ELEMENTS
2378 if (checkLock(aStudy)) break;
2380 EmitSignalDeactivateDialog();
2381 new SMESHGUI_EditMeshDlg( this, 1 );
2383 SUIT_MessageBox::warn1(desktop(),
2384 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2385 tr("SMESH_BUT_OK"));
2390 case 4067: // MAKE MESH PASS THROUGH POINT
2391 startOperation( 4067 );
2394 case 5105: // Library of selection filters
2396 static QValueList<int> aTypes;
2397 if ( aTypes.isEmpty() )
2399 aTypes.append( SMESH::NODE );
2400 aTypes.append( SMESH::EDGE );
2401 aTypes.append( SMESH::FACE );
2402 aTypes.append( SMESH::VOLUME );
2404 if (!myFilterLibraryDlg)
2405 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2406 else if (myFilterLibraryDlg->isHidden())
2407 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2408 myFilterLibraryDlg->raise();
2412 case 6017: // CONTROLS
2428 LightApp_SelectionMgr* mgr = selectionMgr();
2429 SALOME_ListIO selected; mgr->selectedObjects( selected );
2431 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2432 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2434 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2435 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2436 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2437 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2438 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2439 ::Control( theCommandID );
2444 SUIT_MessageBox::warn1(desktop(),
2445 tr( "SMESH_WRN_WARNING" ),
2446 tr( "SMESH_BAD_SELECTION" ),
2447 tr( "SMESH_BUT_OK" ) );
2451 SUIT_MessageBox::warn1(desktop(),
2452 tr( "SMESH_WRN_WARNING" ),
2453 tr( "NOT_A_VTK_VIEWER" ),
2454 tr( "SMESH_BUT_OK" ) );
2459 LightApp_SelectionMgr* mgr = selectionMgr();
2460 SALOME_ListIO selected; mgr->selectedObjects( selected );
2462 SALOME_ListIteratorOfListIO it(selected);
2463 for(; it.More(); it.Next()) {
2464 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2465 if(anIObject->hasEntry()) {
2466 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2467 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2475 LightApp_SelectionMgr* mgr = selectionMgr();
2476 SALOME_ListIO selected; mgr->selectedObjects( selected );
2478 if (selected.Extent() == 1) {
2479 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2480 if(anIObject->hasEntry())
2481 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2482 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2489 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2490 //updateObjBrowser();
2494 //=============================================================================
2498 //=============================================================================
2499 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2504 //=============================================================================
2508 //=============================================================================
2509 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2514 //=============================================================================
2518 //=============================================================================
2519 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2524 //=============================================================================
2525 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2526 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2528 //=============================================================================
2529 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2530 SUIT_ViewWindow* wnd )
2532 if(theIO->hasEntry()){
2533 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2534 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2538 //=======================================================================
2539 // function : createSMESHAction
2541 //=======================================================================
2542 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2545 QWidget* parent = application()->desktop();
2546 SUIT_ResourceMgr* resMgr = resourceMgr();
2548 if ( icon_id.length() )
2549 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2551 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2552 if ( !pix.isNull() )
2553 icon = QIconSet( pix );
2555 QString tooltip = tr( QString( "TOP_" )+po_id ),
2556 menu = tr( QString( "MEN_" )+po_id ),
2557 status_bar = tr( QString( "STB_" )+po_id );
2559 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2562 //=======================================================================
2563 // function : createPopupItem
2565 //=======================================================================
2566 void SMESHGUI::createPopupItem( const int id,
2567 const QString& clients,
2568 const QString& types,
2569 const QString& theRule,
2574 parentId = popupMgr()->actionId( action( pId ) );
2576 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2577 popupMgr()->insert( action( id ), parentId, 0 );
2579 QChar lc = QtxPopupMgr::Selection::defEquality();
2580 QString rule = "(%1) and (%2) and (%3)";
2581 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2582 if( clients.isEmpty() )
2583 rule = rule.arg( QString( "true" ) );
2585 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2586 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2589 bool cont = myRules.contains( id );
2591 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2593 popupMgr()->setRule( action( id ), rule, true );
2594 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2597 //=======================================================================
2598 // function : initialize
2600 //=======================================================================
2601 void SMESHGUI::initialize( CAM_Application* app )
2603 SalomeApp_Module::initialize( app );
2605 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2607 /* Automatic Update flag */
2608 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2610 // ----- create actions --------------
2612 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2613 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2614 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2615 createSMESHAction( 114, "NUM" );
2616 createSMESHAction( 121, "DAT" );
2617 createSMESHAction( 122, "MED" );
2618 createSMESHAction( 123, "UNV" );
2619 createSMESHAction( 140, "STL" );
2620 createSMESHAction( 124, "EXPORT_DAT" );
2621 createSMESHAction( 125, "EXPORT_MED" );
2622 createSMESHAction( 126, "EXPORT_UNV" );
2623 createSMESHAction( 141, "EXPORT_STL" );
2624 createSMESHAction( 150, "FILE_INFO" );
2625 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2626 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2627 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2628 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2629 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2630 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2631 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2632 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" );
2633 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2634 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2635 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2636 createSMESHAction( 804, "ADD" );
2637 createSMESHAction( 805, "REMOVE" );
2638 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2639 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2640 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2641 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2642 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2643 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2644 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2645 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2646 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2647 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2648 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2649 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2650 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2651 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2652 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2653 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2654 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2655 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2656 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2657 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2658 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2659 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2660 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2661 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2662 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2663 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2664 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2665 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2666 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2667 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2668 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2669 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2670 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2671 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2672 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2673 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2674 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2675 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2676 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2677 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2678 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2679 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2680 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2681 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2682 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2683 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2684 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2685 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2686 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2687 createSMESHAction( 415, "MAP", "ICON_MAP" );
2688 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2689 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2690 createSMESHAction( 200, "RESET" );
2691 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2692 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2693 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2694 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2695 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2696 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2697 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2698 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2699 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2700 createSMESHAction( 220, "ALL" );
2701 createSMESHAction( 1100, "EDIT_HYPO" );
2702 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2703 createSMESHAction( 1102, "UNASSIGN" );
2704 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2705 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2706 createSMESHAction( 1131, "DISPMODE" );
2707 createSMESHAction( 1132, "COLORS" );
2708 createSMESHAction( 1133, "TRANSP" );
2709 createSMESHAction( 1134, "CLIP" );
2710 createSMESHAction( 1135, "DISP_ENT" );
2711 createSMESHAction( 1136, "AUTO_COLOR" );
2712 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2713 createSMESHAction( 2000, "CTRL" );
2715 createSMESHAction( 300, "ERASE" );
2716 createSMESHAction( 301, "DISPLAY" );
2717 createSMESHAction( 302, "DISPLAY_ONLY" );
2718 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2719 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2720 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2721 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2722 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2723 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2724 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2725 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2727 // ----- create menu --------------
2728 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2729 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2730 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2731 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2732 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2733 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2734 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2736 createMenu( separator(), fileId );
2738 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2739 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2740 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2741 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2742 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2743 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2745 createMenu( 111, importId, -1 );
2746 createMenu( 112, importId, -1 );
2747 createMenu( 113, importId, -1 );
2749 createMenu( 121, exportId, -1 );
2750 createMenu( 122, exportId, -1 );
2751 createMenu( 123, exportId, -1 );
2752 createMenu( 140, exportId, -1 ); // export to stl STL
2754 createMenu( separator(), fileId, 10 );
2756 createMenu( 33, editId, -1 );
2758 createMenu( 5105, toolsId, -1 );
2760 createMenu( 702, meshId, -1 ); // "Mesh" menu
2761 createMenu( 703, meshId, -1 );
2762 createMenu( 704, meshId, -1 );
2763 createMenu( 710, meshId, -1 );
2764 createMenu( separator(), meshId, -1 );
2765 createMenu( 701, meshId, -1 );
2766 createMenu( separator(), meshId, -1 );
2767 createMenu( 801, meshId, -1 );
2768 createMenu( 806, meshId, -1 );
2769 createMenu( 802, meshId, -1 );
2770 createMenu( 803, meshId, -1 );
2771 createMenu( separator(), meshId, -1 );
2772 createMenu( 810, meshId, -1 );
2773 createMenu( 811, meshId, -1 );
2774 createMenu( 812, meshId, -1 );
2775 createMenu( separator(), meshId, -1 );
2776 createMenu( 813, meshId, -1 );
2777 createMenu( separator(), meshId, -1 );
2778 createMenu( 900, meshId, -1 );
2779 createMenu( 902, meshId, -1 );
2780 createMenu( 903, meshId, -1 );
2781 createMenu( separator(), meshId, -1 );
2783 createMenu( 6003, ctrlId, -1 );
2784 createMenu( 6001, ctrlId, -1 );
2785 createMenu( 6004, ctrlId, -1 );
2786 createMenu( separator(), ctrlId, -1 );
2787 createMenu( 6002, ctrlId, -1 );
2788 createMenu( 6018, ctrlId, -1 );
2789 createMenu( 6019, ctrlId, -1 );
2790 createMenu( 6011, ctrlId, -1 );
2791 createMenu( 6012, ctrlId, -1 );
2792 createMenu( 6013, ctrlId, -1 );
2793 createMenu( 6014, ctrlId, -1 );
2794 createMenu( 6015, ctrlId, -1 );
2795 createMenu( 6016, ctrlId, -1 );
2796 createMenu( separator(), ctrlId, -1 );
2797 createMenu( 6017, ctrlId, -1 );
2798 createMenu( 6009, ctrlId, -1 );
2799 createMenu( separator(), ctrlId, -1 );
2801 createMenu( 400, addId, -1 );
2802 createMenu( 401, addId, -1 );
2803 createMenu( 4021, addId, -1 );
2804 createMenu( 4022, addId, -1 );
2805 createMenu( 4023, addId, -1 );
2806 createMenu( 4031, addId, -1 );
2807 createMenu( 4032, addId, -1 );
2808 createMenu( 4033, addId, -1 );
2809 createMenu( separator(), addId, -1 );
2810 createMenu( 4034, addId, -1 );
2811 createMenu( 4035, addId, -1 );
2812 createMenu( 4036, addId, -1 );
2813 createMenu( 4037, addId, -1 );
2814 createMenu( 4038, addId, -1 );
2815 createMenu( 4039, addId, -1 );
2816 createMenu( 4040, addId, -1 );
2818 createMenu( 4041, removeId, -1 );
2819 createMenu( 4042, removeId, -1 );
2820 createMenu( 4043, removeId, -1 );
2822 createMenu( 4051, renumId, -1 );
2823 createMenu( 4052, renumId, -1 );
2825 createMenu( 4061, transfId, -1 );
2826 createMenu( 4062, transfId, -1 );
2827 createMenu( 4063, transfId, -1 );
2828 createMenu( 4064, transfId, -1 );
2829 createMenu( 4065, transfId, -1 );
2830 createMenu( 4066, transfId, -1 );
2832 createMenu( 406, modifyId, -1 );
2833 createMenu( 4067,modifyId, -1 );
2834 createMenu( 407, modifyId, -1 );
2835 createMenu( 408, modifyId, -1 );
2836 createMenu( 409, modifyId, -1 );
2837 createMenu( 410, modifyId, -1 );
2838 createMenu( 411, modifyId, -1 );
2839 createMenu( 412, modifyId, -1 );
2840 createMenu( 413, modifyId, -1 );
2841 createMenu( 416, modifyId, -1 );
2842 createMenu( 414, modifyId, -1 );
2843 createMenu( 415, modifyId, -1 );
2844 createMenu( 417, modifyId, -1 );
2846 createMenu( 214, viewId, -1 );
2848 // ----- create toolbars --------------
2849 int meshTb = createTool( tr( "TB_MESH" ) ),
2850 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2851 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2852 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2853 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2855 createTool( 702, meshTb );
2856 createTool( 703, meshTb );
2857 createTool( 704, meshTb );
2858 createTool( 710, meshTb );
2859 createTool( separator(), meshTb );
2860 createTool( 701, meshTb );
2861 createTool( separator(), meshTb );
2862 createTool( 801, meshTb );
2863 createTool( 806, meshTb );
2864 createTool( 802, meshTb );
2865 createTool( 803, meshTb );
2866 createTool( separator(), meshTb );
2867 createTool( 900, meshTb );
2868 createTool( 902, meshTb );
2869 createTool( 903, meshTb );
2870 createTool( separator(), meshTb );
2872 createTool( 6001, ctrlTb );
2873 createTool( 6003, ctrlTb );
2874 createTool( 6004, ctrlTb );
2875 createTool( separator(), ctrlTb );
2876 createTool( 6002, ctrlTb );
2877 createTool( 6018, ctrlTb );
2878 createTool( 6019, ctrlTb );
2879 createTool( 6011, ctrlTb );
2880 createTool( 6012, ctrlTb );
2881 createTool( 6013, ctrlTb );
2882 createTool( 6014, ctrlTb );
2883 createTool( 6015, ctrlTb );
2884 createTool( 6016, ctrlTb );
2885 createTool( separator(), ctrlTb );
2886 createTool( 6017, ctrlTb );
2887 createTool( 6009, ctrlTb );
2888 createTool( separator(), ctrlTb );
2890 createTool( 400, addRemTb );
2891 createTool( 401, addRemTb );
2892 createTool( 4021, addRemTb );
2893 createTool( 4022, addRemTb );
2894 createTool( 4023, addRemTb );
2895 createTool( 4031, addRemTb );
2896 createTool( 4032, addRemTb );
2897 createTool( 4033, addRemTb );
2898 createTool( separator(), addRemTb );
2899 createTool( 4034, addRemTb );
2900 createTool( 4035, addRemTb );
2901 createTool( 4036, addRemTb );
2902 createTool( 4037, addRemTb );
2903 createTool( 4038, addRemTb );
2904 createTool( 4039, addRemTb );
2905 createTool( 4040, addRemTb );
2906 createTool( separator(), addRemTb );
2907 createTool( 4041, addRemTb );
2908 createTool( 4042, addRemTb );
2909 createTool( 4043, addRemTb );
2910 createTool( separator(), addRemTb );
2911 createTool( 4051, addRemTb );
2912 createTool( 4052, addRemTb );
2913 createTool( separator(), addRemTb );
2914 createTool( 4061, addRemTb );
2915 createTool( 4062, addRemTb );
2916 createTool( 4063, addRemTb );
2917 createTool( 4064, addRemTb );
2918 createTool( 4065, addRemTb );
2919 createTool( 4066, addRemTb );
2920 createTool( separator(), addRemTb );
2922 createTool( 406, modifyTb );
2923 createTool( 4067,modifyTb );
2924 createTool( 407, modifyTb );
2925 createTool( 408, modifyTb );
2926 createTool( 409, modifyTb );
2927 createTool( 410, modifyTb );
2928 createTool( 411, modifyTb );
2929 createTool( 412, modifyTb );
2930 createTool( 413, modifyTb );
2931 createTool( 416, modifyTb );
2932 createTool( 414, modifyTb );
2933 createTool( 415, modifyTb );
2934 createTool( 417, modifyTb );
2936 createTool( 214, dispModeTb );
2940 QString OB = "'ObjectBrowser'",
2941 View = "'" + SVTK_Viewer::Type() + "'",
2943 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2944 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2945 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2946 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2947 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2948 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2949 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2950 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2951 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2952 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2953 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2955 mesh_group = mesh + " " + subMesh + " " + group,
2956 hyp_alg = hypo + " " + algo;
2958 // popup for object browser
2960 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2962 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2963 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2964 createPopupItem( 803, OB, group ); // EDIT_GROUP
2965 popupMgr()->insert( separator(), -1, 0 );
2966 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2967 createPopupItem( 214, OB, mesh_group ); // UPDATE
2968 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2969 createPopupItem( 902, OB, mesh ); // STD_INFO
2970 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2971 popupMgr()->insert( separator(), -1, 0 );
2972 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2973 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
2974 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2975 popupMgr()->insert( separator(), -1, 0 );
2976 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2977 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2978 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2979 popupMgr()->insert( separator(), -1, 0 );
2980 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2981 popupMgr()->insert( separator(), -1, 0 );
2983 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2984 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2986 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2987 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2988 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2989 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2990 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2991 popupMgr()->insert( separator(), -1, 0 );
2994 createPopupItem( 803, View, group ); // EDIT_GROUP
2995 createPopupItem( 804, View, elems ); // ADD
2996 createPopupItem( 805, View, elems ); // REMOVE
2997 popupMgr()->insert( separator(), -1, 0 );
2998 createPopupItem( 214, View, mesh_group ); // UPDATE
2999 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3000 createPopupItem( 902, View, mesh ); // STD_INFO
3001 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3002 popupMgr()->insert( separator(), -1, 0 );
3004 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3005 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3006 popupMgr()->insert( separator(), -1, 0 );
3010 isInvisible("not( isVisible )"),
3011 isEmpty("numberOfNodes = 0"),
3012 isNotEmpty("numberOfNodes <> 0"),
3014 // has nodes, edges, etc in VISIBLE! actor
3015 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3016 hasElems("(count( elemTypes ) > 0)"),
3017 hasDifferentElems("(count( elemTypes ) > 1)"),
3018 hasEdges("({'Edge'} in elemTypes)"),
3019 hasFaces("({'Face'} in elemTypes)"),
3020 hasVolumes("({'Volume'} in elemTypes)");
3022 QString lc = QtxPopupMgr::Selection::defEquality();
3023 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3024 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
3025 aType = aType.arg( mesh_group );
3026 QString aMeshInVTK = aClient + "&&" + aType;
3028 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3029 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3030 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
3032 //-------------------------------------------------
3034 //-------------------------------------------------
3035 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3037 popupMgr()->insert( action( 9010 ), anId, -1 );
3038 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
3039 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
3041 popupMgr()->insert( action( 9011 ), anId, -1 );
3042 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
3043 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
3045 popupMgr()->insert( separator(), -1, -1 );
3047 //-------------------------------------------------
3049 //-------------------------------------------------
3050 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3052 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3053 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3054 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3056 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3057 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3058 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3060 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3061 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3062 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3064 popupMgr()->insert( separator(), anId, -1 );
3066 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3067 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3068 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3070 //-------------------------------------------------
3072 //-------------------------------------------------
3073 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3075 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3077 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3078 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3079 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3081 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3082 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3083 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3085 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3086 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3087 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3089 popupMgr()->insert( separator(), anId, -1 );
3091 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3092 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3094 //-------------------------------------------------
3096 //-------------------------------------------------
3097 popupMgr()->insert( action( 1132 ), -1, -1 );
3098 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3100 //-------------------------------------------------
3102 //-------------------------------------------------
3103 popupMgr()->insert( action( 1133 ), -1, -1 );
3104 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3106 //-------------------------------------------------
3108 //-------------------------------------------------
3109 popupMgr()->insert( action( 1134 ), -1, -1 );
3110 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", true );
3112 popupMgr()->insert( separator(), -1, -1 );
3114 //-------------------------------------------------
3116 //-------------------------------------------------
3118 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3119 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3120 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3122 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3124 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3125 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3127 popupMgr()->insert( separator(), anId, -1 );
3129 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3130 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3131 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3133 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3134 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3135 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3137 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3138 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3139 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3141 popupMgr()->insert( separator(), anId, -1 );
3143 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3144 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3145 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3147 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3148 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3149 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3151 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3152 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3153 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3155 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3156 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3157 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3159 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3160 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3161 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3163 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3164 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3165 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3167 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3168 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3169 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3171 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3172 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3173 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3175 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3176 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3177 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3179 popupMgr()->insert( separator(), anId, -1 );
3181 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3182 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3183 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3185 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3186 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3187 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3189 popupMgr()->insert( separator(), anId, -1 );
3191 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3192 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3194 popupMgr()->insert( separator(), -1, -1 );
3196 //-------------------------------------------------
3198 //-------------------------------------------------
3199 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3200 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3201 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3202 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3204 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3205 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3207 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3208 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3210 popupMgr()->insert( separator(), -1, -1 );
3212 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3213 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3216 //================================================================================
3218 * \brief Return true if SMESH or GEOM objects are selected.
3219 * Is called form LightApp_Module::activateModule() which clear selection if
3220 * not isSelectionCompatible()
3222 //================================================================================
3224 bool SMESHGUI::isSelectionCompatible()
3226 bool isCompatible = true;
3227 SALOME_ListIO selected;
3228 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3229 Sel->selectedObjects( selected );
3231 SALOME_ListIteratorOfListIO It( selected );
3232 for ( ; isCompatible && It.More(); It.Next())
3234 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3235 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3237 return isCompatible;
3240 bool SMESHGUI::activateModule( SUIT_Study* study )
3242 bool res = SalomeApp_Module::activateModule( study );
3244 setMenuShown( true );
3245 setToolShown( true );
3247 // Reset actions accelerator keys
3248 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3249 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3250 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3252 action( 33)->setEnabled(true); // Delete: Key_Delete
3253 action(1101)->setEnabled(true); // Rename: Key_F2
3258 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3260 setMenuShown( false );
3261 setToolShown( false );
3263 EmitSignalCloseAllDialogs();
3265 // Unset actions accelerator keys
3266 action(111)->setAccel(QKeySequence()); // Import DAT
3267 action(112)->setAccel(QKeySequence()); // Import UNV
3268 action(113)->setAccel(QKeySequence()); // Import MED
3270 action( 33)->setEnabled(false); // Delete: Key_Delete
3271 action(1101)->setEnabled(false); // Rename: Key_F2
3273 return SalomeApp_Module::deactivateModule( study );
3276 void SMESHGUI::studyClosed( SUIT_Study* s )
3278 SMESH::RemoveVisuData( s->id() );
3279 SalomeApp_Module::studyClosed( s );
3282 void SMESHGUI::OnGUIEvent()
3284 const QObject* obj = sender();
3285 if ( !obj || !obj->inherits( "QAction" ) )
3287 int id = actionId((QAction*)obj);
3292 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3294 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3295 if ( CORBA::is_nil( myComponentSMESH ) )
3297 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3299 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3300 return aGUI.myComponentSMESH;
3303 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3304 return myComponentSMESH;
3307 QString SMESHGUI::engineIOR() const
3309 CORBA::ORB_var anORB = getApp()->orb();
3310 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3311 return QString( anIOR.in() );
3314 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3316 SMESHGUI_Selection sel;
3317 sel.init( client, selectionMgr() );
3318 popupMgr()->updatePopup( menu, &sel );
3321 selectionMgr()->selectedObjects( lst );
3322 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3323 Handle(SALOME_InteractiveObject) io = lst.First();
3324 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3325 _PTR(Study) study = appStudy->studyDS();
3326 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3328 QString aName = QString( obj->GetName().c_str() );
3329 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3330 aName.remove( (aName.length() - 1), 1 );
3336 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3338 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3339 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3342 void SMESHGUI::viewManagers( QStringList& list ) const
3344 list.append( SVTK_Viewer::Type() );
3347 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3349 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3350 SMESH::UpdateSelectionProp( this );
3353 void SMESHGUI::createPreferences()
3355 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3357 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3358 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3360 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3361 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3362 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3364 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3365 setPreferenceProperty( precGroup, "columns", 1 );
3367 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3369 setPreferenceProperty( prec, "min", 0 );
3370 setPreferenceProperty( prec, "max", 16 );
3372 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3373 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3375 modes.append( "Wireframe" );
3376 modes.append( "Shading" );
3377 modes.append( "Nodes" );
3378 modes.append( "Shrink" );
3379 QValueList<QVariant> indices;
3380 indices.append( 0 );
3381 indices.append( 1 );
3382 indices.append( 2 );
3383 indices.append( 3 );
3384 setPreferenceProperty( dispmode, "strings", modes );
3385 setPreferenceProperty( dispmode, "indexes", indices );
3387 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3388 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3389 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3391 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3392 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3394 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3395 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3397 setPreferenceProperty( nodeSz, "min", 1 );
3398 setPreferenceProperty( nodeSz, "max", 5 );
3400 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3402 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3403 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3404 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3405 addPreference( "", elemGroup, LightApp_Preferences::Space );
3407 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3408 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3410 setPreferenceProperty( elemW, "min", 1 );
3411 setPreferenceProperty( elemW, "max", 5 );
3413 setPreferenceProperty( shrink, "min", 0 );
3414 setPreferenceProperty( shrink, "max", 100 );
3416 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3418 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3420 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3421 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3422 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3424 setPreferenceProperty( selW, "min", 1 );
3425 setPreferenceProperty( selW, "max", 5 );
3427 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3429 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3430 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3432 setPreferenceProperty( preW, "min", 1 );
3433 setPreferenceProperty( preW, "max", 5 );
3435 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3437 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3438 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3439 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3441 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3442 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3444 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3445 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3446 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3447 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3450 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3451 fam.append( tr( "SMESH_FONT_COURIER" ) );
3452 fam.append( tr( "SMESH_FONT_TIMES" ) );
3453 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3455 setPreferenceProperty( tfont, "families", fam );
3456 setPreferenceProperty( tfont, "system", false );
3457 setPreferenceProperty( tfont, "widget_flags", wflag );
3458 setPreferenceProperty( lfont, "families", fam );
3459 setPreferenceProperty( lfont, "system", false );
3460 setPreferenceProperty( lfont, "widget_flags", wflag );
3462 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3464 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3465 setPreferenceProperty( numcol, "min", 2 );
3466 setPreferenceProperty( numcol, "max", 256 );
3468 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3469 setPreferenceProperty( numlab, "min", 2 );
3470 setPreferenceProperty( numlab, "max", 65 );
3472 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3473 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3474 QStringList orients;
3475 orients.append( tr( "SMESH_VERTICAL" ) );
3476 orients.append( tr( "SMESH_HORIZONTAL" ) );
3477 indices.clear(); indices.append( 0 ); indices.append( 1 );
3478 setPreferenceProperty( orient, "strings", orients );
3479 setPreferenceProperty( orient, "indexes", indices );
3481 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3482 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3483 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3484 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3485 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3486 setPreferenceProperty( xv, "step", 0.1 );
3487 setPreferenceProperty( xv, "min", 0.0 );
3488 setPreferenceProperty( xv, "max", 1.0 );
3489 setPreferenceProperty( yv, "step", 0.1 );
3490 setPreferenceProperty( yv, "min", 0.0 );
3491 setPreferenceProperty( yv, "max", 1.0 );
3492 setPreferenceProperty( wv, "step", 0.1 );
3493 setPreferenceProperty( wv, "min", 0.0 );
3494 setPreferenceProperty( wv, "max", 1.0 );
3495 setPreferenceProperty( hv, "min", 0.0 );
3496 setPreferenceProperty( hv, "max", 1.0 );
3497 setPreferenceProperty( hv, "step", 0.1 );
3499 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3500 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3501 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3502 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3503 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3504 setPreferenceProperty( xv, "min", 0.0 );
3505 setPreferenceProperty( xv, "max", 1.0 );
3506 setPreferenceProperty( xv, "step", 0.1 );
3507 setPreferenceProperty( xh, "min", 0.0 );
3508 setPreferenceProperty( xh, "max", 1.0 );
3509 setPreferenceProperty( xh, "step", 0.1 );
3510 setPreferenceProperty( yh, "min", 0.0 );
3511 setPreferenceProperty( yh, "max", 1.0 );
3512 setPreferenceProperty( yh, "step", 0.1 );
3513 setPreferenceProperty( wh, "min", 0.0 );
3514 setPreferenceProperty( wh, "max", 1.0 );
3515 setPreferenceProperty( wh, "step", 0.1 );
3516 setPreferenceProperty( hh, "min", 0.0 );
3517 setPreferenceProperty( hh, "max", 1.0 );
3518 setPreferenceProperty( hh, "step", 0.1 );
3521 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3523 if( sect=="SMESH" ){
3524 float sbX1,sbY1,sbW,sbH;
3525 float aTol = 1.00000009999999;
3526 std::string aWarning;
3527 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3528 if( name=="selection_object_color" || name=="selection_element_color" ||
3529 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3530 name=="selection_precision_node" || name=="selection_precision_element" ||
3531 name=="selection_precision_object")
3532 SMESH::UpdateSelectionProp( this );
3533 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3534 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3535 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3536 if(sbX1+sbW > aTol){
3537 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3540 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3541 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3544 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3545 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3546 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3547 if(sbY1+sbH > aTol){
3548 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3549 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3550 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3553 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3554 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3555 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3556 if(sbX1+sbW > aTol){
3557 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3560 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3561 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3564 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3565 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3566 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3567 if(sbY1+sbH > aTol){
3568 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3571 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3572 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3576 if(aWarning.size() != 0){
3577 aWarning += "The default values are applied instead.";
3578 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3579 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3580 QObject::tr(aWarning.c_str()),
3581 QObject::tr("SMESH_BUT_OK"));
3586 //================================================================================
3588 * \brief Update something in accordance with update flags
3589 * \param theFlags - update flags
3591 * Update viewer or/and object browser etc. in accordance with update flags ( see
3592 * LightApp_UpdateFlags enumeration ).
3594 //================================================================================
3595 void SMESHGUI::update( const int flags )
3597 if ( flags & UF_Viewer | flags & UF_Forced )
3598 SMESH::UpdateView();
3600 SalomeApp_Module::update( flags );
3603 //================================================================================
3605 * \brief Set default selection mode
3607 * SLOT called when operation commited. Sets default selection mode
3609 //================================================================================
3610 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3612 SVTK_ViewWindow* vtkWnd =
3613 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3615 vtkWnd->SetSelectionMode( ActorSelection );
3618 //================================================================================
3620 * \brief Set default selection mode
3622 * SLOT called when operation aborted. Sets default selection mode
3624 //================================================================================
3625 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3627 SVTK_ViewWindow* vtkWnd =
3628 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3630 vtkWnd->SetSelectionMode( ActorSelection );
3633 //================================================================================
3635 * \brief Creates operation with given identifier
3636 * \param id - identifier of operation to be started
3637 * \return Pointer on created operation or NULL if operation is not created
3639 * Virtual method redefined from the base class creates operation with given id.
3640 * It is called called automatically from startOperation method of base class.
3642 //================================================================================
3643 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3645 LightApp_Operation* op = 0;
3646 // to do : create operation here
3649 case 701: // Compute mesh
3650 op = new SMESHGUI_ComputeOp();
3652 case 702: // Create mesh
3653 op = new SMESHGUI_MeshOp( true, true );
3655 case 703: // Create sub-mesh
3656 op = new SMESHGUI_MeshOp( true, false );
3658 case 704: // Edit mesh/sub-mesh
3659 op = new SMESHGUI_MeshOp( false );
3661 case 806: // Create group on geom
3662 op = new SMESHGUI_GroupOnShapeOp();
3664 case 417: //convert to quadratic
3665 op = new SMESHGUI_ConvToQuadOp();
3667 case 4067: // make mesh pass through point
3668 op = new SMESHGUI_MakeNodeAtPointOp();
3675 op = SalomeApp_Module::createOperation( id );
3679 //================================================================================
3681 * \brief Stops current operations and starts a given one
3682 * \param id - The id of the operation to start
3684 //================================================================================
3686 void SMESHGUI::switchToOperation(int id)
3688 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3689 activeStudy()->abortAllOperations();
3690 startOperation( id );
3693 LightApp_Displayer* SMESHGUI::displayer()
3696 myDisplayer = new SMESHGUI_Displayer( getApp() );
3700 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3703 int aTolerance = 64;
3704 int anIterations = 0;
3710 if( anIterations % aPeriod == 0 )
3713 if( aTolerance < 1 )
3716 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3718 aHue = (int)( 360.0 * rand() / RAND_MAX );
3719 //cout << "Hue = " << aHue << endl;
3721 //cout << "Auto colors : ";
3723 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3724 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3725 for( ; it != itEnd; ++it )
3727 SALOMEDS::Color anAutoColor = *it;
3728 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3731 aQColor.getHsv( &h, &s, &v );
3733 if( abs( h - aHue ) < aTolerance )
3736 //cout << "break (diff = " << abs( h - aHue ) << ")";
3746 //cout << "Hue of the returned color = " << aHue << endl;
3748 aColor.setHsv( aHue, 255, 255 );
3750 SALOMEDS::Color aSColor;
3751 aSColor.R = (double)aColor.red() / 255.0;
3752 aSColor.G = (double)aColor.green() / 255.0;
3753 aSColor.B = (double)aColor.blue() / 255.0;