1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
71 #include "SMESHGUI_FileInfoDlg.h"
72 #include "SMESHGUI_GroupOnShapeDlg.h"
74 #include "SMESHGUI_Utils.h"
75 #include "SMESHGUI_GEOMGenUtils.h"
76 #include "SMESHGUI_MeshUtils.h"
77 #include "SMESHGUI_GroupUtils.h"
78 #include "SMESHGUI_FilterUtils.h"
79 #include "SMESHGUI_PatternUtils.h"
80 #include "SMESHGUI_VTKUtils.h"
81 #include "SMESHGUI_HypothesesUtils.h"
83 #include "SMESH_Actor.h"
84 #include "SMESH_Object.h"
85 #include "SMESH_TypeFilter.hxx"
87 #include "SalomeApp_Tools.h"
88 #include "SalomeApp_Study.h"
89 #include "SalomeApp_Application.h"
90 #include "SalomeApp_CheckFileDlg.h"
91 #include "SalomeApp_ImportOperation.h"
93 #include "LightApp_DataOwner.h"
94 #include "LightApp_Preferences.h"
95 #include "LightApp_VTKSelector.h"
96 #include "LightApp_Operation.h"
97 #include "LightApp_UpdateFlags.h"
98 #include "LightApp_NameDlg.h"
100 #include <SVTK_ViewWindow.h>
101 #include <SVTK_ViewModel.h>
102 #include <SVTK_InteractorStyle.h>
103 #include <SVTK_RenderWindowInteractor.h>
104 #include <SVTK_ViewManager.h>
106 #include "OB_Browser.h"
108 #include "SUIT_Tools.h"
109 #include "SUIT_MessageBox.h"
110 #include "SUIT_ResourceMgr.h"
111 #include "SUIT_FileDlg.h"
112 #include "SUIT_Desktop.h"
113 #include "SUIT_OverrideCursor.h"
114 #include "SUIT_Study.h"
115 #include "SUIT_Session.h"
117 #include "QtxPopupMgr.h"
119 #include "SALOME_ListIO.hxx"
120 #include "SALOME_ListIteratorOfListIO.hxx"
121 #include "SALOME_InteractiveObject.hxx"
122 #include "SALOME_NamingService.hxx"
123 #include "SALOME_LifeCycleCORBA.hxx"
125 #include "SALOMEconfig.h"
126 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
127 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
130 #define INCLUDE_MENUITEM_DEF
131 #include <qpopupmenu.h>
137 #include <boost/shared_ptr.hpp>
140 #include <vtkRenderer.h>
141 #include <vtkRenderWindow.h>
142 #include <vtkActorCollection.h>
143 #include <vtkScalarBarActor.h>
144 #include <vtkUnstructuredGrid.h>
146 #include "utilities.h"
148 #include "SALOMEDS_Study.hxx"
149 #include "SALOMEDSClient_StudyBuilder.hxx"
150 #include "SALOMEDSClient_SComponent.hxx"
152 #include <Standard_ErrorHandler.hxx>
158 //=============================================================
159 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
162 void ExportMeshToFile(int theCommandID);
164 void SetDisplayMode(int theCommandID);
166 void SetDisplayEntity(int theCommandID);
168 void Control( int theCommandID );
172 //=============================================================
173 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
179 if ( theCommandID == 113 ) {
180 filter.append( QObject::tr( "MED files (*.med)" ) );
181 filter.append( QObject::tr( "All files (*)" ) );
183 else if ( theCommandID == 112 ) {
184 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
186 else if ( theCommandID == 111 ) {
187 filter.append( QObject::tr( "DAT files (*.dat)" ) );
190 QString anInitialPath = "";
191 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
192 anInitialPath = QDir::currentDirPath();
194 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
197 QObject::tr( "SMESH_IMPORT_MESH" ) );
198 if ( filenames.count() > 0 ) {
199 SUIT_OverrideCursor wc;
200 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
203 bool isEmpty = false;
204 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
205 QString filename = *it;
206 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
208 switch ( theCommandID ) {
211 // DAT format (currently unsupported)
212 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
213 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
219 aMeshes->length( 1 );
220 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.latin1() );
221 if ( aMeshes[0]->_is_nil() )
222 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
223 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
229 SMESH::DriverMED_ReadStatus res;
230 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.latin1(), res );
231 if ( res != SMESH::DRS_OK ) {
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
239 catch ( const SALOME::SALOME_Exception& S_ex ) {
240 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
241 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
244 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
245 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
247 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
248 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
249 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
250 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
251 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
259 // update Object browser
260 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
262 // show Error message box if there were errors
263 if ( errors.count() > 0 ) {
264 SUIT_MessageBox::error1( SMESHGUI::desktop(),
265 QObject::tr( "SMESH_ERROR" ),
266 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
267 QObject::tr( "SMESH_BUT_OK" ) );
270 // show warning message box, if some imported mesh is empty
272 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
273 QObject::tr( "SMESH_WRN_WARNING" ),
274 QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
275 QObject::tr( "SMESH_BUT_OK" ) );
280 void ExportMeshToFile( int theCommandID )
282 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
283 SALOME_ListIO selected;
285 aSel->selectedObjects( selected );
287 SMESH::SMESH_Mesh_var aMesh;
288 if(selected.Extent() == 1)
289 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
290 if ( aMesh->_is_nil() ) {
291 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
292 QObject::tr( "SMESH_WRN_WARNING" ),
293 QObject::tr( "SMESH_BAD_MESH_SELECTION" ),
294 QObject::tr( "SMESH_BUT_OK" ) );
298 Handle(SALOME_InteractiveObject) anIObject = selected.First();
299 QString aFilter, aTitle = QObject::tr("Export mesh");
300 QMap<QString, SMESH::MED_VERSION> aFilterMap;
301 QMap<QString, int> aFilterMapSTL;
302 switch ( theCommandID ) {
306 if (aMesh->HasDuplicatedGroupNamesMED()) {
307 int aRet = SUIT_MessageBox::warn2
308 (SMESHGUI::desktop(),
309 QObject::tr("SMESH_WRN_WARNING"),
310 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
311 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
317 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
318 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
319 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
320 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
325 aFilter = QObject::tr("DAT files (*.dat)");
330 if (aMesh->NbPyramids()) {
331 int aRet = SUIT_MessageBox::warn2
332 (SMESHGUI::desktop(),
333 QObject::tr("SMESH_WRN_WARNING"),
334 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
335 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
340 aFilter = QObject::tr("IDEAS files (*.unv)");
348 there must be check on others mesh elements not equal triangles
350 if (aMesh->NbTriangles() < 1) {
351 SUIT_MessageBox::warn1
352 (SMESHGUI::desktop(),
353 QObject::tr("SMESH_WRN_WARNING"),
354 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
355 QObject::tr("SMESH_BUT_OK"));
358 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
359 int aRet = SUIT_MessageBox::warn2
360 (SMESHGUI::desktop(),
361 QObject::tr("SMESH_WRN_WARNING"),
362 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
363 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
369 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
370 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
378 SMESH::MED_VERSION aFormat;
379 // Init the parameter with the default value
380 bool aIsASCII_STL = true;
381 bool toCreateGroups = false;
382 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
384 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
386 QString anInitialPath = "";
387 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
388 anInitialPath = QDir::currentDirPath();
390 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
391 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
392 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
393 aFilter, aTitle, false);
395 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
397 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
398 for ( ; it != aFilterMapSTL.end(); ++it )
399 filters.push_back( it.key() );
401 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
402 fd->setCaption( aTitle );
403 fd->setFilters( filters );
404 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
405 if ( !anInitialPath.isEmpty() )
406 fd->setDir( anInitialPath );
407 fd->setSelection(anIObject->getName());
411 aFilename = fd->selectedFile();
412 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
417 else { // Export to MED
419 QString aDefaultFilter;
420 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
421 for ( ; it != aFilterMap.end(); ++it ) {
422 filters.push_back( it.key() );
423 if (it.data() == SMESH::MED_V2_2)
424 aDefaultFilter = it.key();
427 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
428 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
429 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
430 fd->setCaption( aTitle );
431 fd->setFilters( filters );
432 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
433 fd->setSelectedFilter(aDefaultFilter);
434 fd->SetChecked(toCreateGroups);
435 if ( !anInitialPath.isEmpty() )
436 fd->setDir( anInitialPath );
437 fd->setSelection(anIObject->getName());
441 aFilename = fd->selectedFile();
442 aFormat = aFilterMap[fd->selectedFilter()];
444 if ( !aFilename.isEmpty()
445 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
446 && aFormat==SMESH::MED_V2_1) {
447 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
448 QObject::tr("SMESH_WRN_WARNING"),
449 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
450 QObject::tr("SMESH_BUT_YES"),
451 QObject::tr("SMESH_BUT_NO"),
458 toCreateGroups = fd->IsChecked();
461 if ( !aFilename.isEmpty() ) {
462 // Check whether the file already exists and delete it if yes
463 QFile aFile( aFilename );
464 if ( aFile.exists() )
466 SUIT_OverrideCursor wc;
469 bool Renumber = false ;
470 // PAL 14172 : Check of we have to renumber or not from the preferences before export
472 Renumber= resMgr->booleanValue("SMESH","renumbering");
474 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
475 aMeshEditor->RenumberNodes();
476 aMeshEditor->RenumberElements();
477 if ( SMESHGUI::automaticUpdate() )
480 switch ( theCommandID ) {
483 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
487 aMesh->ExportDAT( aFilename.latin1() );
491 aMesh->ExportUNV( aFilename.latin1() );
495 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
501 catch (const SALOME::SALOME_Exception& S_ex){
503 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
504 QObject::tr("SMESH_WRN_WARNING"),
505 QObject::tr("SMESH_EXPORT_FAILED"),
506 QObject::tr("SMESH_BUT_OK"));
512 inline void InverseEntityMode(unsigned int& theOutputMode,
513 unsigned int theMode)
515 bool anIsNotPresent = ~theOutputMode & theMode;
517 theOutputMode |= theMode;
519 theOutputMode &= ~theMode;
522 void SetDisplayEntity(int theCommandID){
523 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
524 SALOME_ListIO selected;
526 aSel->selectedObjects( selected );
528 if(selected.Extent() >= 1){
529 SALOME_ListIteratorOfListIO It( selected );
530 for(; It.More(); It.Next()){
531 Handle(SALOME_InteractiveObject) IObject = It.Value();
532 if(IObject->hasEntry()){
533 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
534 unsigned int aMode = anActor->GetEntityMode();
535 switch(theCommandID){
537 InverseEntityMode(aMode,SMESH_Actor::eEdges);
540 InverseEntityMode(aMode,SMESH_Actor::eFaces);
543 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
546 aMode = SMESH_Actor::eAllEntity;
550 anActor->SetEntityMode(aMode);
558 SALOME_ListIO selected;
559 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
563 LightApp_SelectionMgr* aSel = app->selectionMgr();
564 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
565 if( !aSel || !appStudy )
568 aSel->selectedObjects( selected );
569 if( selected.IsEmpty() )
572 Handle(SALOME_InteractiveObject) anIObject = selected.First();
574 _PTR(Study) aStudy = appStudy->studyDS();
575 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
576 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
577 if( aMainObject->_is_nil() )
580 aMainObject->SetAutoColor( true );
582 QValueList<SALOMEDS::Color> aReservedColors;
584 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
585 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
587 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
588 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
590 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
591 aGroupObject->SetColor( aColor );
592 aReservedColors.append( aColor );
594 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
595 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
597 if( aGroupObject->GetType() == SMESH::NODE )
598 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
599 else if( aGroupObject->GetType() == SMESH::EDGE )
600 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
602 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
606 SMESH::RepaintCurrentView();
609 void DisableAutoColor(){
610 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
611 SALOME_ListIO selected;
613 aSel->selectedObjects( selected );
615 if(selected.Extent()){
616 Handle(SALOME_InteractiveObject) anIObject = selected.First();
617 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
618 if ( !aMesh->_is_nil() ) {
619 aMesh->SetAutoColor( false );
624 void SetDisplayMode(int theCommandID){
625 SALOME_ListIO selected;
626 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
630 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
631 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
632 if( !aSel || !appStudy )
635 _PTR(Study) aStudy = appStudy->studyDS();
637 aSel->selectedObjects( selected );
639 if(selected.Extent() >= 1){
640 switch(theCommandID){
642 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
643 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
647 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
648 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
651 SALOME_ListIteratorOfListIO It( selected );
652 for(; It.More(); It.Next()){
653 Handle(SALOME_InteractiveObject) IObject = It.Value();
654 if(IObject->hasEntry()){
655 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
656 switch(theCommandID){
658 anActor->SetRepresentation(SMESH_Actor::eEdge);
661 anActor->SetRepresentation(SMESH_Actor::eSurface);
664 if(anActor->IsShrunk())
667 anActor->SetShrink();
670 anActor->SetRepresentation(SMESH_Actor::ePoint);
673 vtkFloatingPointType color[3];
674 anActor->GetSufaceColor(color[0], color[1], color[2]);
675 int c0 = int (color[0] * 255);
676 int c1 = int (color[1] * 255);
677 int c2 = int (color[2] * 255);
678 QColor c(c0, c1, c2);
680 vtkFloatingPointType edgecolor[3];
681 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
682 c0 = int (edgecolor[0] * 255);
683 c1 = int (edgecolor[1] * 255);
684 c2 = int (edgecolor[2] * 255);
685 QColor e(c0, c1, c2);
687 vtkFloatingPointType backfacecolor[3];
688 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
689 c0 = int (backfacecolor[0] * 255);
690 c1 = int (backfacecolor[1] * 255);
691 c2 = int (backfacecolor[2] * 255);
692 QColor b(c0, c1, c2);
694 vtkFloatingPointType nodecolor[3];
695 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
696 c0 = int (nodecolor[0] * 255);
697 c1 = int (nodecolor[1] * 255);
698 c2 = int (nodecolor[2] * 255);
699 QColor n(c0, c1, c2);
701 int Edgewidth = (int)anActor->GetLineWidth();
704 int intValue = int(anActor->GetNodeSize());
705 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
707 SMESHGUI_Preferences_ColorDlg *aDlg =
708 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
709 aDlg->SetColor(1, c);
710 aDlg->SetColor(2, e);
711 aDlg->SetColor(3, n);
712 aDlg->SetColor(4, b);
713 aDlg->SetIntValue(1, Edgewidth);
714 aDlg->SetIntValue(2, intValue);
715 aDlg->SetIntValue(3, int(Shrink*100.));
717 QColor color = aDlg->GetColor(1);
718 QColor edgecolor = aDlg->GetColor(2);
719 QColor nodecolor = aDlg->GetColor(3);
720 QColor backfacecolor = aDlg->GetColor(4);
721 /* actor color and backface color */
722 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
723 vtkFloatingPointType (color.green()) / 255.,
724 vtkFloatingPointType (color.blue()) / 255.);
725 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
726 vtkFloatingPointType (backfacecolor.green()) / 255.,
727 vtkFloatingPointType (backfacecolor.blue()) / 255.);
730 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
731 vtkFloatingPointType (edgecolor.green()) / 255.,
732 vtkFloatingPointType (edgecolor.blue()) / 255.);
734 /* Shrink factor and size edges */
735 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
736 anActor->SetLineWidth(aDlg->GetIntValue(1));
738 /* Nodes color and size */
739 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
740 vtkFloatingPointType (nodecolor.green()) / 255.,
741 vtkFloatingPointType (nodecolor.blue()) / 255.);
742 anActor->SetNodeSize(aDlg->GetIntValue(2));
744 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
745 if( !aGroupObject->_is_nil() )
747 SALOMEDS::Color aColor;
748 aColor.R = (float)color.red() / 255.0;
749 aColor.G = (float)color.green() / 255.0;
750 aColor.B = (float)color.blue() / 255.0;
751 aGroupObject->SetColor( aColor );
761 SMESH::RepaintCurrentView();
765 void Control( int theCommandID )
767 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
768 SALOME_ListIO selected;
770 aSel->selectedObjects( selected );
772 if( !selected.IsEmpty() ){
773 Handle(SALOME_InteractiveObject) anIO = selected.First();
776 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
777 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
778 switch ( theCommandID ){
780 aTitle = QObject::tr( "LENGTH_EDGES" );
781 aControl = SMESH_Actor::eLength;
784 aTitle = QObject::tr( "LENGTH2D_EDGES" );
785 aControl = SMESH_Actor::eLength2D;
788 aTitle = QObject::tr( "FREE_EDGES" );
789 aControl = SMESH_Actor::eFreeEdges;
792 aTitle = QObject::tr( "FREE_BORDERS" );
793 aControl = SMESH_Actor::eFreeBorders;
796 aTitle = QObject::tr( "MULTI_BORDERS" );
797 aControl = SMESH_Actor::eMultiConnection;
800 aTitle = QObject::tr( "MULTI2D_BORDERS" );
801 aControl = SMESH_Actor::eMultiConnection2D;
804 aTitle = QObject::tr( "AREA_ELEMENTS" );
805 aControl = SMESH_Actor::eArea;
808 aTitle = QObject::tr( "TAPER_ELEMENTS" );
809 aControl = SMESH_Actor::eTaper;
812 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
813 aControl = SMESH_Actor::eAspectRatio;
816 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
817 aControl = SMESH_Actor::eAspectRatio3D;
820 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
821 aControl = SMESH_Actor::eMinimumAngle;
824 aTitle = QObject::tr( "WARP_ELEMENTS" );
825 aControl = SMESH_Actor::eWarping;
828 aTitle = QObject::tr( "SKEW_ELEMENTS" );
829 aControl = SMESH_Actor::eSkew;
832 aTitle = QObject::tr( "SMESH_VOLUME" );
833 aControl = SMESH_Actor::eVolume3D;
836 anActor->SetControlMode(aControl);
837 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
838 SMESH::RepaintCurrentView();
845 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
846 MeshObjectType theType,
847 const QString theInTypeName,
848 QString & theOutTypeName)
850 SMESH_TypeFilter aTypeFilter( theType );
852 if( !theIO.IsNull() )
854 entry = theIO->getEntry();
855 LightApp_DataOwner owner( entry );
856 if ( aTypeFilter.isOk( &owner )) {
857 theOutTypeName = theInTypeName;
865 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
867 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
868 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
870 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
871 CORBA::String_var anID = aSComp->GetID().c_str();
872 if (!strcmp(anID.in(),theIO->getEntry()))
878 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
879 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
880 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
881 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
882 CheckOIType ( theIO, GROUP, "Group", aTypeName )
890 QString CheckHomogeneousSelection()
892 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
893 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
894 SALOME_ListIO selected;
896 aSel->selectedObjects( selected );
898 QString RefType = CheckTypeObject(selected.First());
899 SALOME_ListIteratorOfListIO It(selected);
900 for (; It.More(); It.Next())
902 Handle(SALOME_InteractiveObject) IObject = It.Value();
903 QString Type = CheckTypeObject(IObject);
904 if (Type.compare(RefType) != 0)
905 return "Heterogeneous Selection";
912 void SMESHGUI::OnEditDelete()
914 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
915 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
916 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
918 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
919 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
920 _PTR(GenericAttribute) anAttr;
921 _PTR(AttributeIOR) anIOR;
924 QString aParentComponent = QString::null;
925 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
927 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
929 // check if object is not reference
930 _PTR(SObject) refobj;
931 if ( !aSO->ReferencedObject( refobj ) )
935 QString cur = anIt.Value()->getComponentDataType();
936 if( aParentComponent.isNull() )
937 aParentComponent = cur;
938 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
939 aParentComponent = "";
942 if ( objectCount == 0 )
943 return; // No Valid Objects Selected
945 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
946 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
947 QObject::tr("ERR_ERROR"),
948 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
949 QObject::tr("BUT_OK") );
952 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
953 if (SUIT_MessageBox::warn2
954 (SMESHGUI::desktop(),
955 QObject::tr("SMESH_WRN_WARNING"),
956 QObject::tr("SMESH_REALLY_DELETE"),
957 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
960 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
961 SUIT_ViewManager* vm = anApp->activeViewManager();
962 int nbSf = vm->getViewsCount();
964 SALOME_ListIteratorOfListIO It(selected);
966 aStudyBuilder->NewCommand(); // There is a transaction
967 for(; It.More(); It.Next()){ // loop on selected IO's
968 Handle(SALOME_InteractiveObject) IObject = It.Value();
969 if(IObject->hasEntry()) {
970 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
972 // disable removal of "SMESH" component object
973 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
975 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
979 _PTR(SObject) refobj;
980 if ( aSO && aSO->ReferencedObject( refobj ) )
981 continue; // skip references
983 // put the whole hierarchy of sub-objects of the selected SO into a list and
984 // then treat them all starting from the deepest objects (at list back)
986 list< _PTR(SObject) > listSO;
987 listSO.push_back( aSO );
988 list< _PTR(SObject) >::iterator itSO = listSO.begin();
989 for ( ; itSO != listSO.end(); ++itSO ) {
990 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
991 for (it->InitEx(false); it->More(); it->Next())
992 listSO.push_back( it->Value() );
995 // treat SO's in the list starting from the back
997 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
998 for ( ; ritSO != listSO.rend(); ++ritSO ) {
999 _PTR(SObject) SO = *ritSO;
1000 if ( !SO ) continue;
1001 string anEntry = SO->GetID();
1003 /** Erase graphical object **/
1004 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1005 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
1006 for(int i = 0; i < nbSf; i++){
1007 SUIT_ViewWindow *sf = aViews[i];
1008 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1009 SMESH::RemoveActor(sf,anActor);
1014 /** Remove an object from data structures **/
1015 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1016 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1017 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1018 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1019 aMesh->RemoveGroup( aGroup );
1021 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1022 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1023 aMesh->RemoveSubMesh( aSubMesh );
1025 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1027 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1030 IObject = new SALOME_InteractiveObject
1031 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1032 QString objType = CheckTypeObject(IObject);
1033 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1034 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1035 aStudyBuilder->RemoveObjectWithChildren( SO );
1037 else {// default action: remove SObject from the study
1038 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1039 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1041 aStudyBuilder->RemoveObjectWithChildren( SO );
1045 } /* listSO back loop */
1046 } /* IObject->hasEntry() */
1048 aStudyBuilder->CommitCommand();
1050 /* Clear any previous selection */
1052 aSel->setSelectedObjects( l1 );
1054 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1059 SMESHGUI_EXPORT CAM_Module* createModule()
1061 return new SMESHGUI();
1065 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1067 //=============================================================================
1071 //=============================================================================
1072 SMESHGUI::SMESHGUI() :
1073 SalomeApp_Module( "SMESH" )
1075 if ( CORBA::is_nil( myComponentSMESH ) )
1077 CORBA::Boolean anIsEmbeddedMode;
1078 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1081 myActiveDialogBox = 0;
1082 myFilterLibraryDlg = 0;
1086 SMESH::GetFilterManager();
1087 SMESH::GetPattern();
1089 /* load resources for all available meshers */
1090 SMESH::InitAvailableHypotheses();
1093 //=============================================================================
1097 //=============================================================================
1098 SMESHGUI::~SMESHGUI()
1100 SMESH::GetFilterManager()->Destroy();
1101 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1104 //=============================================================================
1108 //=============================================================================
1109 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1111 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1113 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1118 bool SMESHGUI::automaticUpdate()
1120 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1124 return resMgr->booleanValue( "SMESH", "auto_update", false );
1127 //=============================================================================
1131 //=============================================================================
1132 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1134 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1137 //=============================================================================
1141 //=============================================================================
1142 SMESHGUI* SMESHGUI::GetSMESHGUI()
1144 SMESHGUI* smeshMod = 0;
1145 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1148 CAM_Module* module = app->module( "Mesh" );
1149 smeshMod = dynamic_cast<SMESHGUI*>( module );
1152 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1154 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1157 _PTR(Study) aStudy = study->studyDS();
1159 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1168 Standard_EXPORT SMESHGUI* GetComponentGUI()
1170 return SMESHGUI::GetSMESHGUI();
1174 //=============================================================================
1178 //=============================================================================
1179 void SMESHGUI::SetState(int aState)
1184 //=============================================================================
1188 //=============================================================================
1189 void SMESHGUI::ResetState()
1194 //=============================================================================
1198 //=============================================================================
1199 void SMESHGUI::EmitSignalDeactivateDialog()
1201 emit SignalDeactivateActiveDialog();
1204 //=============================================================================
1208 //=============================================================================
1209 void SMESHGUI::EmitSignalStudyFrameChanged()
1211 emit SignalStudyFrameChanged();
1214 //=============================================================================
1218 //=============================================================================
1219 void SMESHGUI::EmitSignalCloseAllDialogs()
1221 emit SignalCloseAllDialogs();
1224 //=============================================================================
1228 //=============================================================================
1229 QDialog *SMESHGUI::GetActiveDialogBox()
1231 return myActiveDialogBox;
1234 //=============================================================================
1238 //=============================================================================
1239 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1241 myActiveDialogBox = (QDialog *) aDlg;
1245 //=============================================================================
1249 //=============================================================================
1250 SUIT_Desktop* SMESHGUI::desktop()
1252 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1254 return app->desktop();
1259 //=============================================================================
1263 //=============================================================================
1264 SalomeApp_Study* SMESHGUI::activeStudy()
1266 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1268 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1273 //=============================================================================
1277 //=============================================================================
1278 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1280 /* Here the position is on the bottom right corner - 10 */
1281 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1283 SUIT_Desktop *PP = desktop();
1284 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1285 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1289 //=============================================================================
1293 //=============================================================================
1294 static int isStudyLocked(_PTR(Study) theStudy){
1295 return theStudy->GetProperties()->IsLocked();
1298 static bool checkLock(_PTR(Study) theStudy) {
1299 if (isStudyLocked(theStudy)) {
1300 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1301 QObject::tr("WRN_WARNING"),
1302 QObject::tr("WRN_STUDY_LOCKED"),
1303 QObject::tr("BUT_OK") );
1309 //=======================================================================
1310 //function : CheckActiveStudyLocked
1312 //=======================================================================
1314 bool SMESHGUI::isActiveStudyLocked()
1316 _PTR(Study) aStudy = activeStudy()->studyDS();
1317 return checkLock( aStudy );
1320 //=============================================================================
1324 //=============================================================================
1325 bool SMESHGUI::OnGUIEvent( int theCommandID )
1327 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1331 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1332 SUIT_ResourceMgr* mgr = resourceMgr();
1336 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1337 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1340 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1341 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1343 //QAction* act = action( theCommandID );
1345 switch (theCommandID) {
1347 if(checkLock(aStudy)) break;
1355 if(checkLock(aStudy)) break;
1356 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1360 case 150: //MED FILE INFORMATION
1362 SALOME_ListIO selected;
1363 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1365 aSel->selectedObjects( selected );
1366 if( selected.Extent() )
1368 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1369 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1370 if ( !aMesh->_is_nil() )
1372 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1378 case 122: // EXPORT MED
1387 ::ExportMeshToFile(theCommandID);
1391 case 200: // SCALAR BAR
1393 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1394 SALOME_ListIO selected;
1396 aSel->selectedObjects( selected );
1398 if( selected.Extent() ) {
1399 Handle(SALOME_InteractiveObject) anIO = selected.First();
1400 if( anIO->hasEntry() ) {
1401 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1402 anActor->SetControlMode( SMESH_Actor::eNone );
1410 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1420 ::DisableAutoColor();
1423 case 1134: // Clipping
1424 case 1133: // Tranparency
1425 case 1132: // Colors / Size
1432 ::SetDisplayMode(theCommandID);
1438 case 219: // Volumes
1439 case 220: // All Entity
1440 ::SetDisplayEntity(theCommandID);
1445 if(checkLock(aStudy)) break;
1447 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1450 SMESH::UpdateView();
1452 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1453 SMESH::OnVisuException();
1455 catch (...) { // PAL16774 (Crash after display of many groups)
1456 SMESH::OnVisuException();
1460 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1461 aSel->selectedObjects( l );
1462 aSel->setSelectedObjects( l );
1467 case 301: // DISPLAY
1468 case 302: // DISPLAY ONLY
1470 SMESH::EDisplaing anAction;
1471 switch (theCommandID) {
1472 case 300: anAction = SMESH::eErase; break;
1473 case 301: anAction = SMESH::eDisplay; break;
1474 case 302: anAction = SMESH::eDisplayOnly; break;
1477 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1478 SALOME_ListIO sel_objects, to_process;
1480 aSel->selectedObjects( sel_objects );
1482 if( theCommandID==302 )
1483 startOperation( myEraseAll );
1485 extractContainers( sel_objects, to_process );
1488 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1492 SALOME_ListIteratorOfListIO It( to_process );
1493 for (; It.More(); It.Next()) {
1494 Handle(SALOME_InteractiveObject) IOS = It.Value();
1495 if (IOS->hasEntry()) {
1496 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1497 break; // PAL16774 (Crash after display of many groups)
1498 if (anAction == SMESH::eDisplayOnly)
1499 anAction = SMESH::eDisplay;
1504 // PAL13338 + PAL15161 -->
1505 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1506 SMESH::UpdateView();
1507 // PAL13338 + PAL15161 <--
1509 catch (...) { // PAL16774 (Crash after display of many groups)
1510 SMESH::OnVisuException();
1513 if (anAction == SMESH::eErase) {
1515 aSel->setSelectedObjects( l1 );
1518 aSel->setSelectedObjects( to_process );
1525 if(checkLock(aStudy)) break;
1528 EmitSignalDeactivateDialog();
1530 new SMESHGUI_NodesDlg(this);
1533 SUIT_MessageBox::warn1(desktop(),
1534 tr("SMESH_WRN_WARNING"),
1535 tr("SMESH_WRN_VIEWER_VTK"),
1536 tr("SMESH_BUT_OK"));
1541 case 2151: // FILTER
1545 EmitSignalDeactivateDialog();
1546 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1551 case 406: // MOVE NODE
1555 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1556 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1560 if(checkLock(aStudy)) break;
1561 new SMESHGUI_MoveNodesDlg(this);
1565 case 701: // COMPUTE MESH
1567 if (checkLock(aStudy)) break;
1569 startOperation( 701 );
1573 case 702: // Create mesh
1574 startOperation( 702 );
1576 case 703: // Create sub-mesh
1577 startOperation( 703 );
1579 case 704: // Edit mesh/sub-mesh
1580 startOperation( 704 );
1582 case 710: // Build compound mesh
1584 if (checkLock(aStudy)) break;
1585 EmitSignalDeactivateDialog();
1586 new SMESHGUI_BuildCompoundDlg( this );
1590 case 407: // DIAGONAL INVERSION
1591 case 408: // Delete diagonal
1595 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1596 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1600 if ( checkLock( aStudy ) )
1603 /*Standard_Boolean aRes;
1604 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1605 if ( aMesh->_is_nil() )
1607 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1608 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1612 EmitSignalDeactivateDialog();
1613 if ( theCommandID == 407 )
1614 new SMESHGUI_TrianglesInversionDlg(this);
1616 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1619 case 409: // Change orientation
1620 case 410: // Union of triangles
1621 case 411: // Cutting of quadrangles
1625 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1626 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1630 if ( checkLock( aStudy ) )
1633 EmitSignalDeactivateDialog();
1634 SMESHGUI_MultiEditDlg* aDlg = NULL;
1635 if ( theCommandID == 409 )
1636 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1637 else if ( theCommandID == 410 )
1638 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1640 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1645 case 412: // Smoothing
1647 if(checkLock(aStudy)) break;
1649 EmitSignalDeactivateDialog();
1650 new SMESHGUI_SmoothingDlg( this );
1653 SUIT_MessageBox::warn1(desktop(),
1654 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1655 tr("SMESH_BUT_OK"));
1659 case 413: // Extrusion
1661 if (checkLock(aStudy)) break;
1663 EmitSignalDeactivateDialog();
1664 new SMESHGUI_ExtrusionDlg ( this );
1666 SUIT_MessageBox::warn1(desktop(),
1667 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1668 tr("SMESH_BUT_OK"));
1672 case 414: // Revolution
1674 if(checkLock(aStudy)) break;
1676 EmitSignalDeactivateDialog();
1677 new SMESHGUI_RevolutionDlg( this );
1680 SUIT_MessageBox::warn1(desktop(),
1681 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1682 tr("SMESH_BUT_OK"));
1686 case 415: // Pattern mapping
1688 if ( checkLock( aStudy ) )
1692 EmitSignalDeactivateDialog();
1693 new SMESHGUI_MeshPatternDlg( this );
1696 SUIT_MessageBox::warn1(desktop(),
1697 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1698 tr("SMESH_BUT_OK"));
1702 case 416: // Extrusion along a path
1704 if (checkLock(aStudy)) break;
1706 EmitSignalDeactivateDialog();
1707 new SMESHGUI_ExtrusionAlongPathDlg( this );
1709 SUIT_MessageBox::warn1(desktop(),
1710 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1711 tr("SMESH_BUT_OK"));
1715 case 417: // Convert mesh to quadratic
1717 startOperation( 417 );
1718 /* if (checkLock(aStudy)) break;
1720 EmitSignalDeactivateDialog();
1721 new SMESHGUI_ConvToQuadDlg();
1723 SUIT_MessageBox::warn1(desktop(),
1724 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1725 tr("SMESH_BUT_OK"));
1729 case 806: // CREATE GEO GROUP
1731 startOperation( 806 );
1734 case 801: // CREATE GROUP
1738 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1739 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1743 if(checkLock(aStudy)) break;
1744 EmitSignalDeactivateDialog();
1745 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1747 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1748 SALOME_ListIO selected;
1750 aSel->selectedObjects( selected );
1752 int nbSel = selected.Extent();
1754 // check if mesh is selected
1755 aMesh = SMESH::GetMeshByIO( selected.First() );
1757 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1762 case 802: // CONSTRUCT GROUP
1766 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1767 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1771 if(checkLock(aStudy)) break;
1772 EmitSignalDeactivateDialog();
1774 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1775 SALOME_ListIO selected;
1777 aSel->selectedObjects( selected );
1779 int nbSel = selected.Extent();
1781 // check if submesh is selected
1782 Handle(SALOME_InteractiveObject) IObject = selected.First();
1783 if (IObject->hasEntry()) {
1784 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1786 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1787 if (!aSubMesh->_is_nil()) {
1789 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1790 // get submesh elements list by types
1791 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1792 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1793 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1794 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1795 // create group for each type o elements
1796 QString aName = IObject->getName();
1797 if (aNodes->length() > 0) {
1798 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1799 aGroup->Add(aNodes.inout());
1801 if (aEdges->length() > 0) {
1802 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1803 aGroup->Add(aEdges.inout());
1805 if (aFaces->length() > 0) {
1806 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1807 aGroup->Add(aFaces.inout());
1809 if (aVolumes->length() > 0) {
1810 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1811 aGroup->Add(aVolumes.inout());
1816 catch(const SALOME::SALOME_Exception & S_ex){
1817 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1824 SUIT_MessageBox::warn1(desktop(),
1825 tr("SMESH_WRN_WARNING"),
1826 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1827 tr("SMESH_BUT_OK"));
1832 case 803: // EDIT GROUP
1836 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1837 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1841 if(checkLock(aStudy)) break;
1842 EmitSignalDeactivateDialog();
1844 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1845 SALOME_ListIO selected;
1847 aSel->selectedObjects( selected );
1849 SALOME_ListIteratorOfListIO It (selected);
1850 int nbSelectedGroups = 0;
1851 for ( ; It.More(); It.Next() )
1853 SMESH::SMESH_GroupBase_var aGroup =
1854 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1855 if (!aGroup->_is_nil()) {
1857 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1861 if (nbSelectedGroups == 0)
1863 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1869 case 804: // Add elements to group
1871 if(checkLock(aStudy)) break;
1872 if (myState == 800) {
1873 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1874 if (aDlg) aDlg->onAdd();
1879 case 805: // Remove elements from group
1881 if(checkLock(aStudy)) break;
1882 if (myState == 800) {
1883 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1884 if (aDlg) aDlg->onRemove();
1889 case 810: // Union Groups
1890 case 811: // Intersect groups
1891 case 812: // Cut groups
1895 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1896 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1900 if ( checkLock( aStudy ) )
1903 EmitSignalDeactivateDialog();
1906 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1907 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1908 else aMode = SMESHGUI_GroupOpDlg::CUT;
1910 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1914 case 813: // Delete groups with their contents
1918 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1919 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1923 if ( checkLock( aStudy ) )
1926 EmitSignalDeactivateDialog();
1928 new SMESHGUI_DeleteGroupDlg( this );
1932 case 900: // MESH INFOS
1934 EmitSignalDeactivateDialog();
1935 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1936 SALOME_ListIO selected;
1938 aSel->selectedObjects( selected );
1940 if ( selected.Extent() > 1 ) { // a dlg for each IO
1942 SALOME_ListIteratorOfListIO It (selected);
1943 for ( ; It.More(); It.Next() ) {
1944 IOs.Clear(); IOs.Append( It.Value() );
1945 aSel->setSelectedObjects( IOs );
1946 new SMESHGUI_MeshInfosDlg(this, "", false);
1948 // restore selection
1949 aSel->setSelectedObjects( selected );
1952 new SMESHGUI_MeshInfosDlg(this, "", false);
1956 case 902: // STANDARD MESH INFOS
1958 EmitSignalDeactivateDialog();
1959 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1960 SALOME_ListIO selected;
1962 aSel->selectedObjects( selected );
1964 if ( selected.Extent() > 1 ) { // a dlg for each IO
1966 SALOME_ListIteratorOfListIO It (selected);
1967 for ( ; It.More(); It.Next() ) {
1969 IOs.Append( It.Value() );
1970 aSel->setSelectedObjects( IOs );
1971 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1973 // restore selection
1974 aSel->setSelectedObjects( selected );
1977 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1981 case 903: // WHAT IS
1983 EmitSignalDeactivateDialog();
1984 new SMESHGUI_WhatIsDlg( this, "", false);
1988 case 1100: // EDIT HYPOTHESIS
1990 if(checkLock(aStudy)) break;
1992 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1993 SALOME_ListIO selected;
1995 aSel->selectedObjects( selected );
1997 int nbSel = selected.Extent();
2000 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2001 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2003 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2004 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2005 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2006 if ( !aHypothesis->_is_nil() )
2008 CORBA::String_var aHypType = aHypothesis->GetName();
2009 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
2011 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2018 updateObjBrowser( true );
2022 case 1101: // RENAME
2024 if ( checkLock( aStudy ) )
2027 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2028 SALOME_ListIO selected;
2030 aSel->selectedObjects( selected );
2032 bool isAny = false; // iss there any appropriate object selected
2034 SALOME_ListIteratorOfListIO It( selected );
2035 for ( ; It.More(); It.Next() )
2037 Handle(SALOME_InteractiveObject) IObject = It.Value();
2038 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2039 _PTR(GenericAttribute) anAttr;
2040 _PTR(AttributeName) aName;
2043 if ( obj->FindAttribute(anAttr, "AttributeName") )
2046 QString newName = QString(aName->Value().c_str());
2048 // check type to prevent renaming of inappropriate objects
2049 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2050 if (aType == MESH || aType == GROUP ||
2051 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2052 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2053 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2054 aType == HYPOTHESIS || aType == ALGORITHM)
2057 newName = LightApp_NameDlg::getName(desktop(), newName);
2058 if ( !newName.isEmpty() )
2060 //old source: aStudy->renameIObject( IObject, newName );
2061 aName->SetValue( newName.latin1() );
2063 // if current object is group update group's name
2064 SMESH::SMESH_GroupBase_var aGroup =
2065 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2066 if (!aGroup->_is_nil() )
2067 aGroup->SetName( newName.latin1() );
2077 SUIT_MessageBox::warn1(desktop(),
2078 QObject::tr("SMESH_WRN_WARNING"),
2079 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2080 QObject::tr("SMESH_BUT_OK"));
2085 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2087 if(checkLock(aStudy)) break;
2088 SUIT_OverrideCursor wc;
2090 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2091 SALOME_ListIO selected;
2093 aSel->selectedObjects( selected, QString::null, false );
2095 SALOME_ListIteratorOfListIO It(selected);
2096 for (int i = 0; It.More(); It.Next(), i++) {
2097 Handle(SALOME_InteractiveObject) IObject = It.Value();
2098 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2101 aSel->setSelectedObjects( l1 );
2106 case 401: // GEOM::EDGE
2107 case 4021: // TRIANGLE
2109 case 4023: // POLYGON
2113 if(checkLock(aStudy)) break;
2115 EmitSignalDeactivateDialog();
2116 SMDSAbs_ElementType type = SMDSAbs_Edge;
2118 switch (theCommandID) {
2119 case 4021: // TRIANGLE
2120 type = SMDSAbs_Face; nbNodes = 3; break;
2122 type = SMDSAbs_Face; nbNodes = 4; break;
2124 type = SMDSAbs_Volume; nbNodes = 4; break;
2125 case 4023: // POLYGON
2126 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2128 type = SMDSAbs_Volume; nbNodes = 8; break;
2129 case 4033: // POLYHEDRE
2130 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2133 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2136 SUIT_MessageBox::warn1(desktop(),
2137 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2138 tr("SMESH_BUT_OK"));
2142 case 4033: // POLYHEDRON
2144 if(checkLock(aStudy)) break;
2146 EmitSignalDeactivateDialog();
2147 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2150 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2151 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2152 tr("SMESH_BUT_OK"));
2156 case 4034: // QUADRATIC EDGE
2157 case 4035: // QUADRATIC TRIANGLE
2158 case 4036: // QUADRATIC QUADRANGLE
2159 case 4037: // QUADRATIC TETRAHEDRON
2160 case 4038: // QUADRATIC PYRAMID
2161 case 4039: // QUADRATIC PENTAHEDRON
2162 case 4040: // QUADRATIC HEXAHEDRON
2164 if(checkLock(aStudy)) break;
2166 EmitSignalDeactivateDialog();
2169 switch (theCommandID) {
2171 type = QUAD_EDGE; break;
2173 type = QUAD_TRIANGLE; break;
2175 type = QUAD_QUADRANGLE; break;
2177 type = QUAD_TETRAHEDRON; break;
2179 type = QUAD_PYRAMID; break;
2181 type = QUAD_PENTAHEDRON; break;
2183 type = QUAD_HEXAHEDRON;
2187 new SMESHGUI_AddQuadraticElementDlg( this, type );
2190 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2191 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2192 tr("SMESH_BUT_OK"));
2196 case 4041: // REMOVES NODES
2198 if(checkLock(aStudy)) break;
2200 EmitSignalDeactivateDialog();
2201 new SMESHGUI_RemoveNodesDlg(this);
2204 SUIT_MessageBox::warn1(desktop(),
2205 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2206 tr("SMESH_BUT_OK"));
2210 case 4042: // REMOVES ELEMENTS
2212 if(checkLock(aStudy)) break;
2214 EmitSignalDeactivateDialog();
2215 new SMESHGUI_RemoveElementsDlg(this);
2219 SUIT_MessageBox::warn1(desktop(),
2220 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2221 tr("SMESH_BUT_OK"));
2225 case 4043: { // CLEAR_MESH
2227 if(checkLock(aStudy)) break;
2229 SALOME_ListIO selected;
2230 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2231 aSel->selectedObjects( selected );
2233 SUIT_OverrideCursor wc;
2234 SALOME_ListIteratorOfListIO It (selected);
2235 for ( ; It.More(); It.Next() )
2237 Handle(SALOME_InteractiveObject) IOS = It.Value();
2238 SMESH::SMESH_Mesh_var aMesh =
2239 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2240 if ( aMesh->_is_nil()) continue;
2242 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2244 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2245 SMESH::ModifiedMesh( aMeshSObj, false, true);
2246 // hide groups and submeshes
2247 _PTR(ChildIterator) anIter =
2248 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2249 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2251 _PTR(SObject) so = anIter->Value();
2252 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2255 catch (const SALOME::SALOME_Exception& S_ex){
2257 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2261 SMESH::UpdateView();
2265 case 4051: // RENUMBERING NODES
2267 if(checkLock(aStudy)) break;
2269 EmitSignalDeactivateDialog();
2270 new SMESHGUI_RenumberingDlg( this, "", 0);
2274 SUIT_MessageBox::warn1(desktop(),
2275 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2276 tr("SMESH_BUT_OK"));
2280 case 4052: // RENUMBERING ELEMENTS
2282 if(checkLock(aStudy)) break;
2284 EmitSignalDeactivateDialog();
2285 new SMESHGUI_RenumberingDlg( this, "", 1);
2289 SUIT_MessageBox::warn1(desktop(),
2290 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2291 tr("SMESH_BUT_OK"));
2295 case 4061: // TRANSLATION
2297 if(checkLock(aStudy)) break;
2299 EmitSignalDeactivateDialog();
2300 new SMESHGUI_TranslationDlg( this );
2303 SUIT_MessageBox::warn1(desktop(),
2304 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2305 tr("SMESH_BUT_OK"));
2309 case 4062: // ROTATION
2311 if(checkLock(aStudy)) break;
2313 EmitSignalDeactivateDialog();
2314 new SMESHGUI_RotationDlg( this );
2317 SUIT_MessageBox::warn1(desktop(),
2318 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2319 tr("SMESH_BUT_OK"));
2323 case 4063: // SYMMETRY
2325 if(checkLock(aStudy)) break;
2327 EmitSignalDeactivateDialog();
2328 new SMESHGUI_SymmetryDlg( this );
2331 SUIT_MessageBox::warn1(desktop(),
2332 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2333 tr("SMESH_BUT_OK"));
2337 case 4064: // SEWING
2339 if(checkLock(aStudy)) break;
2341 EmitSignalDeactivateDialog();
2342 new SMESHGUI_SewingDlg( this );
2345 SUIT_MessageBox::warn1(desktop(),
2346 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2347 tr("SMESH_BUT_OK"));
2351 case 4065: // MERGE NODES
2353 if(checkLock(aStudy)) break;
2355 EmitSignalDeactivateDialog();
2356 new SMESHGUI_EditMeshDlg( this, 0 );
2359 SUIT_MessageBox::warn1(desktop(),
2360 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2361 tr("SMESH_BUT_OK"));
2365 case 4066: // MERGE EQUAL ELEMENTS
2367 if (checkLock(aStudy)) break;
2369 EmitSignalDeactivateDialog();
2370 new SMESHGUI_EditMeshDlg( this, 1 );
2372 SUIT_MessageBox::warn1(desktop(),
2373 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2374 tr("SMESH_BUT_OK"));
2379 case 4067: // MAKE MESH PASS THROUGH POINT
2380 startOperation( 4067 );
2383 case 5105: // Library of selection filters
2385 static QValueList<int> aTypes;
2386 if ( aTypes.isEmpty() )
2388 aTypes.append( SMESH::NODE );
2389 aTypes.append( SMESH::EDGE );
2390 aTypes.append( SMESH::FACE );
2391 aTypes.append( SMESH::VOLUME );
2393 if (!myFilterLibraryDlg)
2394 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2395 else if (myFilterLibraryDlg->isHidden())
2396 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2397 myFilterLibraryDlg->raise();
2401 case 6017: // CONTROLS
2417 LightApp_SelectionMgr* mgr = selectionMgr();
2418 SALOME_ListIO selected; mgr->selectedObjects( selected );
2420 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2421 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2423 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2424 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2425 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2426 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2427 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2428 ::Control( theCommandID );
2433 SUIT_MessageBox::warn1(desktop(),
2434 tr( "SMESH_WRN_WARNING" ),
2435 tr( "SMESH_BAD_SELECTION" ),
2436 tr( "SMESH_BUT_OK" ) );
2440 SUIT_MessageBox::warn1(desktop(),
2441 tr( "SMESH_WRN_WARNING" ),
2442 tr( "NOT_A_VTK_VIEWER" ),
2443 tr( "SMESH_BUT_OK" ) );
2448 LightApp_SelectionMgr* mgr = selectionMgr();
2449 SALOME_ListIO selected; mgr->selectedObjects( selected );
2451 SALOME_ListIteratorOfListIO it(selected);
2452 for(; it.More(); it.Next()) {
2453 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2454 if(anIObject->hasEntry()) {
2455 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2456 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2464 LightApp_SelectionMgr* mgr = selectionMgr();
2465 SALOME_ListIO selected; mgr->selectedObjects( selected );
2467 if (selected.Extent() == 1) {
2468 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2469 if(anIObject->hasEntry())
2470 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2471 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2478 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2479 //updateObjBrowser();
2483 //=============================================================================
2487 //=============================================================================
2488 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2493 //=============================================================================
2497 //=============================================================================
2498 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2503 //=============================================================================
2507 //=============================================================================
2508 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2513 //=============================================================================
2514 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2515 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2517 //=============================================================================
2518 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2519 SUIT_ViewWindow* wnd )
2521 if(theIO->hasEntry()){
2522 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2523 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2527 //=======================================================================
2528 // function : createSMESHAction
2530 //=======================================================================
2531 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2534 QWidget* parent = application()->desktop();
2535 SUIT_ResourceMgr* resMgr = resourceMgr();
2537 if ( icon_id.length() )
2538 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2540 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2541 if ( !pix.isNull() )
2542 icon = QIconSet( pix );
2544 QString tooltip = tr( QString( "TOP_" )+po_id ),
2545 menu = tr( QString( "MEN_" )+po_id ),
2546 status_bar = tr( QString( "STB_" )+po_id );
2548 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2551 //=======================================================================
2552 // function : createPopupItem
2554 //=======================================================================
2555 void SMESHGUI::createPopupItem( const int id,
2556 const QString& clients,
2557 const QString& types,
2558 const QString& theRule,
2563 parentId = popupMgr()->actionId( action( pId ) );
2565 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2566 popupMgr()->insert( action( id ), parentId, 0 );
2568 QChar lc = QtxPopupMgr::Selection::defEquality();
2569 QString rule = "(%1) and (%2) and (%3)";
2570 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2571 if( clients.isEmpty() )
2572 rule = rule.arg( QString( "true" ) );
2574 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2575 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2578 bool cont = myRules.contains( id );
2580 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2582 popupMgr()->setRule( action( id ), rule, true );
2583 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2586 //=======================================================================
2587 // function : initialize
2589 //=======================================================================
2590 void SMESHGUI::initialize( CAM_Application* app )
2592 SalomeApp_Module::initialize( app );
2594 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2596 /* Automatic Update flag */
2597 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2599 // ----- create actions --------------
2601 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2602 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2603 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2604 createSMESHAction( 114, "NUM" );
2605 createSMESHAction( 121, "DAT" );
2606 createSMESHAction( 122, "MED" );
2607 createSMESHAction( 123, "UNV" );
2608 createSMESHAction( 140, "STL" );
2609 createSMESHAction( 124, "EXPORT_DAT" );
2610 createSMESHAction( 125, "EXPORT_MED" );
2611 createSMESHAction( 126, "EXPORT_UNV" );
2612 createSMESHAction( 141, "EXPORT_STL" );
2613 createSMESHAction( 150, "FILE_INFO" );
2614 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2615 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2616 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2617 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2618 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2619 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2620 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2621 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" );
2622 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2623 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2624 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2625 createSMESHAction( 804, "ADD" );
2626 createSMESHAction( 805, "REMOVE" );
2627 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2628 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2629 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2630 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2631 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2632 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2633 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2634 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2635 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2636 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2637 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2638 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2639 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2640 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2641 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2642 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2643 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2644 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2645 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2646 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2647 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2648 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2649 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2650 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2651 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2652 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2653 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2654 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2655 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2656 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2657 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2658 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2659 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2660 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2661 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2662 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2663 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2664 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2665 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2666 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2667 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2668 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2669 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2670 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2671 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2672 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2673 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2674 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2675 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2676 createSMESHAction( 415, "MAP", "ICON_MAP" );
2677 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2678 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2679 createSMESHAction( 200, "RESET" );
2680 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2681 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2682 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2683 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2684 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2685 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2686 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2687 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2688 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2689 createSMESHAction( 220, "ALL" );
2690 createSMESHAction( 1100, "EDIT_HYPO" );
2691 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2692 createSMESHAction( 1102, "UNASSIGN" );
2693 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2694 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2695 createSMESHAction( 1131, "DISPMODE" );
2696 createSMESHAction( 1132, "COLORS" );
2697 createSMESHAction( 1133, "TRANSP" );
2698 createSMESHAction( 1134, "CLIP" );
2699 createSMESHAction( 1135, "DISP_ENT" );
2700 createSMESHAction( 1136, "AUTO_COLOR" );
2701 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2702 createSMESHAction( 2000, "CTRL" );
2704 createSMESHAction( 300, "ERASE" );
2705 createSMESHAction( 301, "DISPLAY" );
2706 createSMESHAction( 302, "DISPLAY_ONLY" );
2707 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2708 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2709 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2710 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2711 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2712 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2713 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2714 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2716 // ----- create menu --------------
2717 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2718 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2719 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2720 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2721 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2722 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2723 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2725 createMenu( separator(), fileId );
2727 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2728 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2729 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2730 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2731 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2732 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2734 createMenu( 111, importId, -1 );
2735 createMenu( 112, importId, -1 );
2736 createMenu( 113, importId, -1 );
2738 createMenu( 121, exportId, -1 );
2739 createMenu( 122, exportId, -1 );
2740 createMenu( 123, exportId, -1 );
2741 createMenu( 140, exportId, -1 ); // export to stl STL
2743 createMenu( separator(), fileId, 10 );
2745 createMenu( 33, editId, -1 );
2747 createMenu( 5105, toolsId, -1 );
2749 createMenu( 702, meshId, -1 ); // "Mesh" menu
2750 createMenu( 703, meshId, -1 );
2751 createMenu( 704, meshId, -1 );
2752 createMenu( 710, meshId, -1 );
2753 createMenu( separator(), meshId, -1 );
2754 createMenu( 701, meshId, -1 );
2755 createMenu( separator(), meshId, -1 );
2756 createMenu( 801, meshId, -1 );
2757 createMenu( 806, meshId, -1 );
2758 createMenu( 802, meshId, -1 );
2759 createMenu( 803, meshId, -1 );
2760 createMenu( separator(), meshId, -1 );
2761 createMenu( 810, meshId, -1 );
2762 createMenu( 811, meshId, -1 );
2763 createMenu( 812, meshId, -1 );
2764 createMenu( separator(), meshId, -1 );
2765 createMenu( 813, meshId, -1 );
2766 createMenu( separator(), meshId, -1 );
2767 createMenu( 900, meshId, -1 );
2768 createMenu( 902, meshId, -1 );
2769 createMenu( 903, meshId, -1 );
2770 createMenu( separator(), meshId, -1 );
2772 createMenu( 6003, ctrlId, -1 );
2773 createMenu( 6001, ctrlId, -1 );
2774 createMenu( 6004, ctrlId, -1 );
2775 createMenu( separator(), ctrlId, -1 );
2776 createMenu( 6002, ctrlId, -1 );
2777 createMenu( 6018, ctrlId, -1 );
2778 createMenu( 6019, ctrlId, -1 );
2779 createMenu( 6011, ctrlId, -1 );
2780 createMenu( 6012, ctrlId, -1 );
2781 createMenu( 6013, ctrlId, -1 );
2782 createMenu( 6014, ctrlId, -1 );
2783 createMenu( 6015, ctrlId, -1 );
2784 createMenu( 6016, ctrlId, -1 );
2785 createMenu( separator(), ctrlId, -1 );
2786 createMenu( 6017, ctrlId, -1 );
2787 createMenu( 6009, ctrlId, -1 );
2788 createMenu( separator(), ctrlId, -1 );
2790 createMenu( 400, addId, -1 );
2791 createMenu( 401, addId, -1 );
2792 createMenu( 4021, addId, -1 );
2793 createMenu( 4022, addId, -1 );
2794 createMenu( 4023, addId, -1 );
2795 createMenu( 4031, addId, -1 );
2796 createMenu( 4032, addId, -1 );
2797 createMenu( 4033, addId, -1 );
2798 createMenu( separator(), addId, -1 );
2799 createMenu( 4034, addId, -1 );
2800 createMenu( 4035, addId, -1 );
2801 createMenu( 4036, addId, -1 );
2802 createMenu( 4037, addId, -1 );
2803 createMenu( 4038, addId, -1 );
2804 createMenu( 4039, addId, -1 );
2805 createMenu( 4040, addId, -1 );
2807 createMenu( 4041, removeId, -1 );
2808 createMenu( 4042, removeId, -1 );
2809 createMenu( 4043, removeId, -1 );
2811 createMenu( 4051, renumId, -1 );
2812 createMenu( 4052, renumId, -1 );
2814 createMenu( 4061, transfId, -1 );
2815 createMenu( 4062, transfId, -1 );
2816 createMenu( 4063, transfId, -1 );
2817 createMenu( 4064, transfId, -1 );
2818 createMenu( 4065, transfId, -1 );
2819 createMenu( 4066, transfId, -1 );
2821 createMenu( 406, modifyId, -1 );
2822 createMenu( 4067,modifyId, -1 );
2823 createMenu( 407, modifyId, -1 );
2824 createMenu( 408, modifyId, -1 );
2825 createMenu( 409, modifyId, -1 );
2826 createMenu( 410, modifyId, -1 );
2827 createMenu( 411, modifyId, -1 );
2828 createMenu( 412, modifyId, -1 );
2829 createMenu( 413, modifyId, -1 );
2830 createMenu( 416, modifyId, -1 );
2831 createMenu( 414, modifyId, -1 );
2832 createMenu( 415, modifyId, -1 );
2833 createMenu( 417, modifyId, -1 );
2835 createMenu( 214, viewId, -1 );
2837 // ----- create toolbars --------------
2838 int meshTb = createTool( tr( "TB_MESH" ) ),
2839 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2840 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2841 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2842 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2844 createTool( 702, meshTb );
2845 createTool( 703, meshTb );
2846 createTool( 704, meshTb );
2847 createTool( 710, meshTb );
2848 createTool( separator(), meshTb );
2849 createTool( 701, meshTb );
2850 createTool( separator(), meshTb );
2851 createTool( 801, meshTb );
2852 createTool( 806, meshTb );
2853 createTool( 802, meshTb );
2854 createTool( 803, meshTb );
2855 createTool( separator(), meshTb );
2856 createTool( 900, meshTb );
2857 createTool( 902, meshTb );
2858 createTool( 903, meshTb );
2859 createTool( separator(), meshTb );
2861 createTool( 6001, ctrlTb );
2862 createTool( 6003, ctrlTb );
2863 createTool( 6004, ctrlTb );
2864 createTool( separator(), ctrlTb );
2865 createTool( 6002, ctrlTb );
2866 createTool( 6018, ctrlTb );
2867 createTool( 6019, ctrlTb );
2868 createTool( 6011, ctrlTb );
2869 createTool( 6012, ctrlTb );
2870 createTool( 6013, ctrlTb );
2871 createTool( 6014, ctrlTb );
2872 createTool( 6015, ctrlTb );
2873 createTool( 6016, ctrlTb );
2874 createTool( separator(), ctrlTb );
2875 createTool( 6017, ctrlTb );
2876 createTool( 6009, ctrlTb );
2877 createTool( separator(), ctrlTb );
2879 createTool( 400, addRemTb );
2880 createTool( 401, addRemTb );
2881 createTool( 4021, addRemTb );
2882 createTool( 4022, addRemTb );
2883 createTool( 4023, addRemTb );
2884 createTool( 4031, addRemTb );
2885 createTool( 4032, addRemTb );
2886 createTool( 4033, addRemTb );
2887 createTool( separator(), addRemTb );
2888 createTool( 4034, addRemTb );
2889 createTool( 4035, addRemTb );
2890 createTool( 4036, addRemTb );
2891 createTool( 4037, addRemTb );
2892 createTool( 4038, addRemTb );
2893 createTool( 4039, addRemTb );
2894 createTool( 4040, addRemTb );
2895 createTool( separator(), addRemTb );
2896 createTool( 4041, addRemTb );
2897 createTool( 4042, addRemTb );
2898 createTool( 4043, addRemTb );
2899 createTool( separator(), addRemTb );
2900 createTool( 4051, addRemTb );
2901 createTool( 4052, addRemTb );
2902 createTool( separator(), addRemTb );
2903 createTool( 4061, addRemTb );
2904 createTool( 4062, addRemTb );
2905 createTool( 4063, addRemTb );
2906 createTool( 4064, addRemTb );
2907 createTool( 4065, addRemTb );
2908 createTool( 4066, addRemTb );
2909 createTool( separator(), addRemTb );
2911 createTool( 406, modifyTb );
2912 createTool( 4067,modifyTb );
2913 createTool( 407, modifyTb );
2914 createTool( 408, modifyTb );
2915 createTool( 409, modifyTb );
2916 createTool( 410, modifyTb );
2917 createTool( 411, modifyTb );
2918 createTool( 412, modifyTb );
2919 createTool( 413, modifyTb );
2920 createTool( 416, modifyTb );
2921 createTool( 414, modifyTb );
2922 createTool( 415, modifyTb );
2923 createTool( 417, modifyTb );
2925 createTool( 214, dispModeTb );
2929 QString OB = "'ObjectBrowser'",
2930 View = "'" + SVTK_Viewer::Type() + "'",
2932 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2933 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2934 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2935 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2936 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2937 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2938 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2939 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2940 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2941 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2942 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2944 mesh_group = mesh + " " + subMesh + " " + group,
2945 hyp_alg = hypo + " " + algo;
2947 // popup for object browser
2949 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2951 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2952 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2953 createPopupItem( 803, OB, group ); // EDIT_GROUP
2954 popupMgr()->insert( separator(), -1, 0 );
2955 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2956 createPopupItem( 214, OB, mesh_group ); // UPDATE
2957 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2958 createPopupItem( 902, OB, mesh ); // STD_INFO
2959 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2960 popupMgr()->insert( separator(), -1, 0 );
2961 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2962 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
2963 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2964 popupMgr()->insert( separator(), -1, 0 );
2965 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2966 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2967 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2968 popupMgr()->insert( separator(), -1, 0 );
2969 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2970 popupMgr()->insert( separator(), -1, 0 );
2972 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2973 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2975 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2976 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2977 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2978 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2979 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2980 popupMgr()->insert( separator(), -1, 0 );
2983 createPopupItem( 803, View, group ); // EDIT_GROUP
2984 createPopupItem( 804, View, elems ); // ADD
2985 createPopupItem( 805, View, elems ); // REMOVE
2986 popupMgr()->insert( separator(), -1, 0 );
2987 createPopupItem( 214, View, mesh_group ); // UPDATE
2988 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2989 createPopupItem( 902, View, mesh ); // STD_INFO
2990 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2991 popupMgr()->insert( separator(), -1, 0 );
2993 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2994 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2995 popupMgr()->insert( separator(), -1, 0 );
2999 isInvisible("not( isVisible )"),
3000 isEmpty("numberOfNodes = 0"),
3001 isNotEmpty("numberOfNodes <> 0"),
3003 // has nodes, edges, etc in VISIBLE! actor
3004 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3005 hasElems("(count( elemTypes ) > 0)"),
3006 hasDifferentElems("(count( elemTypes ) > 1)"),
3007 hasEdges("({'Edge'} in elemTypes)"),
3008 hasFaces("({'Face'} in elemTypes)"),
3009 hasVolumes("({'Volume'} in elemTypes)");
3011 QString lc = QtxPopupMgr::Selection::defEquality();
3012 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3013 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
3014 aType = aType.arg( mesh_group );
3015 QString aMeshInVTK = aClient + "&&" + aType;
3017 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3018 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3019 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
3021 //-------------------------------------------------
3023 //-------------------------------------------------
3024 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3026 popupMgr()->insert( action( 9010 ), anId, -1 );
3027 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
3028 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
3030 popupMgr()->insert( action( 9011 ), anId, -1 );
3031 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
3032 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
3034 popupMgr()->insert( separator(), -1, -1 );
3036 //-------------------------------------------------
3038 //-------------------------------------------------
3039 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3041 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3042 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3043 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3045 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3046 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3047 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3049 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3050 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3051 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3053 popupMgr()->insert( separator(), anId, -1 );
3055 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3056 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3057 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3059 //-------------------------------------------------
3061 //-------------------------------------------------
3062 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3064 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3066 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3067 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3068 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3070 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3071 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3072 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3074 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3075 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3076 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3078 popupMgr()->insert( separator(), anId, -1 );
3080 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3081 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3083 //-------------------------------------------------
3085 //-------------------------------------------------
3086 popupMgr()->insert( action( 1132 ), -1, -1 );
3087 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3089 //-------------------------------------------------
3091 //-------------------------------------------------
3092 popupMgr()->insert( action( 1133 ), -1, -1 );
3093 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3095 //-------------------------------------------------
3097 //-------------------------------------------------
3098 popupMgr()->insert( action( 1134 ), -1, -1 );
3099 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3101 popupMgr()->insert( separator(), -1, -1 );
3103 //-------------------------------------------------
3105 //-------------------------------------------------
3107 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3108 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3109 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3111 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3113 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3114 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3116 popupMgr()->insert( separator(), anId, -1 );
3118 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3119 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3120 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3122 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3123 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3124 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3126 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3127 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3128 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3130 popupMgr()->insert( separator(), anId, -1 );
3132 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3133 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3134 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3136 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3137 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3138 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3140 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3141 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3142 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3144 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3145 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3146 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3148 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3149 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3150 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3152 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3153 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3154 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3156 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3157 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3158 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3160 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3161 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3162 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3164 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3165 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3166 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3168 popupMgr()->insert( separator(), anId, -1 );
3170 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3171 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3172 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3174 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3175 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3176 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3178 popupMgr()->insert( separator(), anId, -1 );
3180 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3181 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3183 popupMgr()->insert( separator(), -1, -1 );
3185 //-------------------------------------------------
3187 //-------------------------------------------------
3188 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3189 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3190 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3191 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3193 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3194 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3196 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3197 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3199 popupMgr()->insert( separator(), -1, -1 );
3201 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3202 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3205 //================================================================================
3207 * \brief Return true if SMESH or GEOM objects are selected.
3208 * Is called form LightApp_Module::activateModule() which clear selection if
3209 * not isSelectionCompatible()
3211 //================================================================================
3213 bool SMESHGUI::isSelectionCompatible()
3215 bool isCompatible = true;
3216 SALOME_ListIO selected;
3217 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3218 Sel->selectedObjects( selected );
3220 SALOME_ListIteratorOfListIO It( selected );
3221 for ( ; isCompatible && It.More(); It.Next())
3223 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3224 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3226 return isCompatible;
3229 bool SMESHGUI::activateModule( SUIT_Study* study )
3231 bool res = SalomeApp_Module::activateModule( study );
3233 setMenuShown( true );
3234 setToolShown( true );
3236 // Reset actions accelerator keys
3237 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3238 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3239 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3241 action( 33)->setEnabled(true); // Delete: Key_Delete
3242 action(1101)->setEnabled(true); // Rename: Key_F2
3247 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3249 setMenuShown( false );
3250 setToolShown( false );
3252 EmitSignalCloseAllDialogs();
3254 // Unset actions accelerator keys
3255 action(111)->setAccel(QKeySequence()); // Import DAT
3256 action(112)->setAccel(QKeySequence()); // Import UNV
3257 action(113)->setAccel(QKeySequence()); // Import MED
3259 action( 33)->setEnabled(false); // Delete: Key_Delete
3260 action(1101)->setEnabled(false); // Rename: Key_F2
3262 return SalomeApp_Module::deactivateModule( study );
3265 void SMESHGUI::studyClosed( SUIT_Study* s )
3267 SMESH::RemoveVisuData( s->id() );
3268 SalomeApp_Module::studyClosed( s );
3271 void SMESHGUI::OnGUIEvent()
3273 const QObject* obj = sender();
3274 if ( !obj || !obj->inherits( "QAction" ) )
3276 int id = actionId((QAction*)obj);
3281 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3283 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3284 if ( CORBA::is_nil( myComponentSMESH ) )
3286 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3288 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3289 return aGUI.myComponentSMESH;
3292 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3293 return myComponentSMESH;
3296 QString SMESHGUI::engineIOR() const
3298 CORBA::ORB_var anORB = getApp()->orb();
3299 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3300 return QString( anIOR.in() );
3303 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3305 SMESHGUI_Selection sel;
3306 sel.init( client, selectionMgr() );
3307 popupMgr()->updatePopup( menu, &sel );
3310 selectionMgr()->selectedObjects( lst );
3311 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3312 Handle(SALOME_InteractiveObject) io = lst.First();
3313 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3314 _PTR(Study) study = appStudy->studyDS();
3315 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3317 QString aName = QString( obj->GetName().c_str() );
3318 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3319 aName.remove( (aName.length() - 1), 1 );
3325 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3327 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3328 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3331 void SMESHGUI::viewManagers( QStringList& list ) const
3333 list.append( SVTK_Viewer::Type() );
3336 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3338 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3339 SMESH::UpdateSelectionProp( this );
3342 void SMESHGUI::createPreferences()
3344 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3346 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3347 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3349 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3350 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3351 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3353 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3354 setPreferenceProperty( precGroup, "columns", 1 );
3356 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3358 setPreferenceProperty( prec, "min", 0 );
3359 setPreferenceProperty( prec, "max", 16 );
3361 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3362 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3364 modes.append( "Wireframe" );
3365 modes.append( "Shading" );
3366 modes.append( "Nodes" );
3367 modes.append( "Shrink" );
3368 QValueList<QVariant> indices;
3369 indices.append( 0 );
3370 indices.append( 1 );
3371 indices.append( 2 );
3372 indices.append( 3 );
3373 setPreferenceProperty( dispmode, "strings", modes );
3374 setPreferenceProperty( dispmode, "indexes", indices );
3376 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3377 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3378 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3380 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3381 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3383 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3384 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3386 setPreferenceProperty( nodeSz, "min", 1 );
3387 setPreferenceProperty( nodeSz, "max", 5 );
3389 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3391 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3392 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3393 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3394 addPreference( "", elemGroup, LightApp_Preferences::Space );
3396 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3397 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3399 setPreferenceProperty( elemW, "min", 1 );
3400 setPreferenceProperty( elemW, "max", 5 );
3402 setPreferenceProperty( shrink, "min", 0 );
3403 setPreferenceProperty( shrink, "max", 100 );
3405 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3407 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3409 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3410 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3411 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3413 setPreferenceProperty( selW, "min", 1 );
3414 setPreferenceProperty( selW, "max", 5 );
3416 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3418 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3419 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3421 setPreferenceProperty( preW, "min", 1 );
3422 setPreferenceProperty( preW, "max", 5 );
3424 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3426 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3427 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3428 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3430 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3431 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3433 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3434 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3435 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3436 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3439 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3440 fam.append( tr( "SMESH_FONT_COURIER" ) );
3441 fam.append( tr( "SMESH_FONT_TIMES" ) );
3442 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3444 setPreferenceProperty( tfont, "families", fam );
3445 setPreferenceProperty( tfont, "system", false );
3446 setPreferenceProperty( tfont, "widget_flags", wflag );
3447 setPreferenceProperty( lfont, "families", fam );
3448 setPreferenceProperty( lfont, "system", false );
3449 setPreferenceProperty( lfont, "widget_flags", wflag );
3451 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3453 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3454 setPreferenceProperty( numcol, "min", 2 );
3455 setPreferenceProperty( numcol, "max", 256 );
3457 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3458 setPreferenceProperty( numlab, "min", 2 );
3459 setPreferenceProperty( numlab, "max", 65 );
3461 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3462 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3463 QStringList orients;
3464 orients.append( tr( "SMESH_VERTICAL" ) );
3465 orients.append( tr( "SMESH_HORIZONTAL" ) );
3466 indices.clear(); indices.append( 0 ); indices.append( 1 );
3467 setPreferenceProperty( orient, "strings", orients );
3468 setPreferenceProperty( orient, "indexes", indices );
3470 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3471 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3472 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3473 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3474 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3475 setPreferenceProperty( xv, "step", 0.1 );
3476 setPreferenceProperty( xv, "min", 0.0 );
3477 setPreferenceProperty( xv, "max", 1.0 );
3478 setPreferenceProperty( yv, "step", 0.1 );
3479 setPreferenceProperty( yv, "min", 0.0 );
3480 setPreferenceProperty( yv, "max", 1.0 );
3481 setPreferenceProperty( wv, "step", 0.1 );
3482 setPreferenceProperty( wv, "min", 0.0 );
3483 setPreferenceProperty( wv, "max", 1.0 );
3484 setPreferenceProperty( hv, "min", 0.0 );
3485 setPreferenceProperty( hv, "max", 1.0 );
3486 setPreferenceProperty( hv, "step", 0.1 );
3488 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3489 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3490 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3491 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3492 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3493 setPreferenceProperty( xv, "min", 0.0 );
3494 setPreferenceProperty( xv, "max", 1.0 );
3495 setPreferenceProperty( xv, "step", 0.1 );
3496 setPreferenceProperty( xh, "min", 0.0 );
3497 setPreferenceProperty( xh, "max", 1.0 );
3498 setPreferenceProperty( xh, "step", 0.1 );
3499 setPreferenceProperty( yh, "min", 0.0 );
3500 setPreferenceProperty( yh, "max", 1.0 );
3501 setPreferenceProperty( yh, "step", 0.1 );
3502 setPreferenceProperty( wh, "min", 0.0 );
3503 setPreferenceProperty( wh, "max", 1.0 );
3504 setPreferenceProperty( wh, "step", 0.1 );
3505 setPreferenceProperty( hh, "min", 0.0 );
3506 setPreferenceProperty( hh, "max", 1.0 );
3507 setPreferenceProperty( hh, "step", 0.1 );
3510 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3512 if( sect=="SMESH" ){
3513 float sbX1,sbY1,sbW,sbH;
3514 float aTol = 1.00000009999999;
3515 std::string aWarning;
3516 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3517 if( name=="selection_object_color" || name=="selection_element_color" ||
3518 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3519 name=="selection_precision_node" || name=="selection_precision_element" ||
3520 name=="selection_precision_object")
3521 SMESH::UpdateSelectionProp( this );
3522 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3523 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3524 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3525 if(sbX1+sbW > aTol){
3526 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3529 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3530 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3533 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3534 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3535 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3536 if(sbY1+sbH > aTol){
3537 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3538 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3539 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3542 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3543 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3544 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3545 if(sbX1+sbW > aTol){
3546 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3549 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3550 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3553 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3554 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3555 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3556 if(sbY1+sbH > aTol){
3557 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3560 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3561 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3565 if(aWarning.size() != 0){
3566 aWarning += "The default values are applied instead.";
3567 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3568 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3569 QObject::tr(aWarning.c_str()),
3570 QObject::tr("SMESH_BUT_OK"));
3575 //================================================================================
3577 * \brief Update something in accordance with update flags
3578 * \param theFlags - update flags
3580 * Update viewer or/and object browser etc. in accordance with update flags ( see
3581 * LightApp_UpdateFlags enumeration ).
3583 //================================================================================
3584 void SMESHGUI::update( const int flags )
3586 if ( flags & UF_Viewer | flags & UF_Forced )
3587 SMESH::UpdateView();
3589 SalomeApp_Module::update( flags );
3592 //================================================================================
3594 * \brief Set default selection mode
3596 * SLOT called when operation commited. Sets default selection mode
3598 //================================================================================
3599 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3601 SVTK_ViewWindow* vtkWnd =
3602 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3604 vtkWnd->SetSelectionMode( ActorSelection );
3607 //================================================================================
3609 * \brief Set default selection mode
3611 * SLOT called when operation aborted. Sets default selection mode
3613 //================================================================================
3614 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3616 SVTK_ViewWindow* vtkWnd =
3617 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3619 vtkWnd->SetSelectionMode( ActorSelection );
3622 //================================================================================
3624 * \brief Creates operation with given identifier
3625 * \param id - identifier of operation to be started
3626 * \return Pointer on created operation or NULL if operation is not created
3628 * Virtual method redefined from the base class creates operation with given id.
3629 * It is called called automatically from startOperation method of base class.
3631 //================================================================================
3632 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3634 LightApp_Operation* op = 0;
3635 // to do : create operation here
3638 case 701: // Compute mesh
3639 op = new SMESHGUI_ComputeOp();
3641 case 702: // Create mesh
3642 op = new SMESHGUI_MeshOp( true, true );
3644 case 703: // Create sub-mesh
3645 op = new SMESHGUI_MeshOp( true, false );
3647 case 704: // Edit mesh/sub-mesh
3648 op = new SMESHGUI_MeshOp( false );
3650 case 806: // Create group on geom
3651 op = new SMESHGUI_GroupOnShapeOp();
3653 case 417: //convert to quadratic
3654 op = new SMESHGUI_ConvToQuadOp();
3656 case 4067: // make mesh pass through point
3657 op = new SMESHGUI_MakeNodeAtPointOp();
3664 op = SalomeApp_Module::createOperation( id );
3668 //================================================================================
3670 * \brief Stops current operations and starts a given one
3671 * \param id - The id of the operation to start
3673 //================================================================================
3675 void SMESHGUI::switchToOperation(int id)
3677 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3678 activeStudy()->abortAllOperations();
3679 startOperation( id );
3682 LightApp_Displayer* SMESHGUI::displayer()
3685 myDisplayer = new SMESHGUI_Displayer( getApp() );
3689 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3692 int aTolerance = 64;
3693 int anIterations = 0;
3699 if( anIterations % aPeriod == 0 )
3702 if( aTolerance < 1 )
3705 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3707 aHue = (int)( 360.0 * rand() / RAND_MAX );
3708 //cout << "Hue = " << aHue << endl;
3710 //cout << "Auto colors : ";
3712 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3713 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3714 for( ; it != itEnd; ++it )
3716 SALOMEDS::Color anAutoColor = *it;
3717 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3720 aQColor.getHsv( &h, &s, &v );
3722 if( abs( h - aHue ) < aTolerance )
3725 //cout << "break (diff = " << abs( h - aHue ) << ")";
3735 //cout << "Hue of the returned color = " << aHue << endl;
3737 aColor.setHsv( aHue, 255, 255 );
3739 SALOMEDS::Color aSColor;
3740 aSColor.R = (double)aColor.red() / 255.0;
3741 aSColor.G = (double)aColor.green() / 255.0;
3742 aSColor.B = (double)aColor.blue() / 255.0;