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;
925 QString aParentComponent = QString::null;
926 Handle(SALOME_InteractiveObject) anIO;
927 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
930 QString cur = anIt.Value()->getComponentDataType();
931 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
933 // check if object is reference
934 _PTR(SObject) aRefSObj;
935 aNameList.append("\n - ");
936 if ( aSO->ReferencedObject( aRefSObj ) ) {
937 QString aRefName = aRefSObj->GetName();
938 aNameList.append( aRefName );
939 cur = aRefSObj->GetFatherComponent()->ComponentDataType();
942 aNameList.append(anIO->getName());
946 if( aParentComponent.isNull() )
947 aParentComponent = cur;
948 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
949 aParentComponent = "";
952 if ( objectCount == 0 )
953 return; // No Valid Objects Selected
955 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
956 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
957 QObject::tr("ERR_ERROR"),
958 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
959 QObject::tr("BUT_OK") );
962 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
963 if (SUIT_MessageBox::warn2
964 (SMESHGUI::desktop(),
965 QObject::tr("SMESH_WRN_WARNING"),
966 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
967 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
970 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
971 SUIT_ViewManager* vm = anApp->activeViewManager();
972 int nbSf = vm->getViewsCount();
974 SALOME_ListIteratorOfListIO It(selected);
976 aStudyBuilder->NewCommand(); // There is a transaction
977 for(; It.More(); It.Next()){ // loop on selected IO's
978 Handle(SALOME_InteractiveObject) IObject = It.Value();
979 if(IObject->hasEntry()) {
980 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
982 // disable removal of "SMESH" component object
983 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
985 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
988 //Check the referenced object
989 _PTR(SObject) refobj;
990 if ( aSO && aSO->ReferencedObject( refobj ) )
991 aSO = refobj; // Delete main Object instead of reference
993 // put the whole hierarchy of sub-objects of the selected SO into a list and
994 // then treat them all starting from the deepest objects (at list back)
996 list< _PTR(SObject) > listSO;
997 listSO.push_back( aSO );
998 list< _PTR(SObject) >::iterator itSO = listSO.begin();
999 for ( ; itSO != listSO.end(); ++itSO ) {
1000 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1001 for (it->InitEx(false); it->More(); it->Next())
1002 listSO.push_back( it->Value() );
1005 // treat SO's in the list starting from the back
1007 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1008 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1009 _PTR(SObject) SO = *ritSO;
1010 if ( !SO ) continue;
1011 string anEntry = SO->GetID();
1013 /** Erase graphical object **/
1014 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1015 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
1016 for(int i = 0; i < nbSf; i++){
1017 SUIT_ViewWindow *sf = aViews[i];
1018 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1019 SMESH::RemoveActor(sf,anActor);
1024 /** Remove an object from data structures **/
1025 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1026 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1027 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1028 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1029 aMesh->RemoveGroup( aGroup );
1031 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1032 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1033 aMesh->RemoveSubMesh( aSubMesh );
1035 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1037 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1040 IObject = new SALOME_InteractiveObject
1041 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1042 QString objType = CheckTypeObject(IObject);
1043 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1044 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1045 aStudyBuilder->RemoveObjectWithChildren( SO );
1047 else {// default action: remove SObject from the study
1048 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1049 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1051 aStudyBuilder->RemoveObjectWithChildren( SO );
1055 } /* listSO back loop */
1056 } /* IObject->hasEntry() */
1058 aStudyBuilder->CommitCommand();
1060 /* Clear any previous selection */
1062 aSel->setSelectedObjects( l1 );
1064 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1069 SMESHGUI_EXPORT CAM_Module* createModule()
1071 return new SMESHGUI();
1075 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1077 //=============================================================================
1081 //=============================================================================
1082 SMESHGUI::SMESHGUI() :
1083 SalomeApp_Module( "SMESH" )
1085 if ( CORBA::is_nil( myComponentSMESH ) )
1087 CORBA::Boolean anIsEmbeddedMode;
1088 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1091 myActiveDialogBox = 0;
1092 myFilterLibraryDlg = 0;
1096 SMESH::GetFilterManager();
1097 SMESH::GetPattern();
1099 /* load resources for all available meshers */
1100 SMESH::InitAvailableHypotheses();
1103 //=============================================================================
1107 //=============================================================================
1108 SMESHGUI::~SMESHGUI()
1110 SMESH::GetFilterManager()->Destroy();
1111 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1114 //=============================================================================
1118 //=============================================================================
1119 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1121 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1123 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1128 bool SMESHGUI::automaticUpdate()
1130 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1134 return resMgr->booleanValue( "SMESH", "auto_update", false );
1137 //=============================================================================
1141 //=============================================================================
1142 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1144 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1147 //=============================================================================
1151 //=============================================================================
1152 SMESHGUI* SMESHGUI::GetSMESHGUI()
1154 SMESHGUI* smeshMod = 0;
1155 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1158 CAM_Module* module = app->module( "Mesh" );
1159 smeshMod = dynamic_cast<SMESHGUI*>( module );
1162 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1164 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1167 _PTR(Study) aStudy = study->studyDS();
1169 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1178 Standard_EXPORT SMESHGUI* GetComponentGUI()
1180 return SMESHGUI::GetSMESHGUI();
1184 //=============================================================================
1188 //=============================================================================
1189 void SMESHGUI::SetState(int aState)
1194 //=============================================================================
1198 //=============================================================================
1199 void SMESHGUI::ResetState()
1204 //=============================================================================
1208 //=============================================================================
1209 void SMESHGUI::EmitSignalDeactivateDialog()
1211 emit SignalDeactivateActiveDialog();
1214 //=============================================================================
1218 //=============================================================================
1219 void SMESHGUI::EmitSignalStudyFrameChanged()
1221 emit SignalStudyFrameChanged();
1224 //=============================================================================
1228 //=============================================================================
1229 void SMESHGUI::EmitSignalCloseAllDialogs()
1231 emit SignalCloseAllDialogs();
1234 //=============================================================================
1238 //=============================================================================
1239 QDialog *SMESHGUI::GetActiveDialogBox()
1241 return myActiveDialogBox;
1244 //=============================================================================
1248 //=============================================================================
1249 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1251 myActiveDialogBox = (QDialog *) aDlg;
1255 //=============================================================================
1259 //=============================================================================
1260 SUIT_Desktop* SMESHGUI::desktop()
1262 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1264 return app->desktop();
1269 //=============================================================================
1273 //=============================================================================
1274 SalomeApp_Study* SMESHGUI::activeStudy()
1276 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1278 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1283 //=============================================================================
1287 //=============================================================================
1288 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1290 /* Here the position is on the bottom right corner - 10 */
1291 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1293 SUIT_Desktop *PP = desktop();
1294 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1295 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1299 //=============================================================================
1303 //=============================================================================
1304 static int isStudyLocked(_PTR(Study) theStudy){
1305 return theStudy->GetProperties()->IsLocked();
1308 static bool checkLock(_PTR(Study) theStudy) {
1309 if (isStudyLocked(theStudy)) {
1310 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1311 QObject::tr("WRN_WARNING"),
1312 QObject::tr("WRN_STUDY_LOCKED"),
1313 QObject::tr("BUT_OK") );
1319 //=======================================================================
1320 //function : CheckActiveStudyLocked
1322 //=======================================================================
1324 bool SMESHGUI::isActiveStudyLocked()
1326 _PTR(Study) aStudy = activeStudy()->studyDS();
1327 return checkLock( aStudy );
1330 //=============================================================================
1334 //=============================================================================
1335 bool SMESHGUI::OnGUIEvent( int theCommandID )
1337 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1341 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1342 SUIT_ResourceMgr* mgr = resourceMgr();
1346 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1347 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1350 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1351 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1353 //QAction* act = action( theCommandID );
1355 switch (theCommandID) {
1357 if(checkLock(aStudy)) break;
1365 if(checkLock(aStudy)) break;
1366 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1370 case 150: //MED FILE INFORMATION
1372 SALOME_ListIO selected;
1373 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1375 aSel->selectedObjects( selected );
1376 if( selected.Extent() )
1378 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1379 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1380 if ( !aMesh->_is_nil() )
1382 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1388 case 122: // EXPORT MED
1397 ::ExportMeshToFile(theCommandID);
1401 case 200: // SCALAR BAR
1403 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1404 SALOME_ListIO selected;
1406 aSel->selectedObjects( selected );
1408 if( selected.Extent() ) {
1409 Handle(SALOME_InteractiveObject) anIO = selected.First();
1410 if( anIO->hasEntry() ) {
1411 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1412 anActor->SetControlMode( SMESH_Actor::eNone );
1420 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1430 ::DisableAutoColor();
1433 case 1134: // Clipping
1434 case 1133: // Tranparency
1435 case 1132: // Colors / Size
1442 ::SetDisplayMode(theCommandID);
1448 case 219: // Volumes
1449 case 220: // All Entity
1450 ::SetDisplayEntity(theCommandID);
1455 if(checkLock(aStudy)) break;
1457 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1460 SMESH::UpdateView();
1462 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1463 SMESH::OnVisuException();
1465 catch (...) { // PAL16774 (Crash after display of many groups)
1466 SMESH::OnVisuException();
1470 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1471 aSel->selectedObjects( l );
1472 aSel->setSelectedObjects( l );
1477 case 301: // DISPLAY
1478 case 302: // DISPLAY ONLY
1480 SMESH::EDisplaing anAction;
1481 switch (theCommandID) {
1482 case 300: anAction = SMESH::eErase; break;
1483 case 301: anAction = SMESH::eDisplay; break;
1484 case 302: anAction = SMESH::eDisplayOnly; break;
1487 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1488 SALOME_ListIO sel_objects, to_process;
1490 aSel->selectedObjects( sel_objects );
1492 if( theCommandID==302 )
1493 startOperation( myEraseAll );
1495 extractContainers( sel_objects, to_process );
1498 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1502 SALOME_ListIteratorOfListIO It( to_process );
1503 for (; It.More(); It.Next()) {
1504 Handle(SALOME_InteractiveObject) IOS = It.Value();
1505 if (IOS->hasEntry()) {
1506 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1507 break; // PAL16774 (Crash after display of many groups)
1508 if (anAction == SMESH::eDisplayOnly)
1509 anAction = SMESH::eDisplay;
1514 // PAL13338 + PAL15161 -->
1515 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1516 SMESH::UpdateView();
1517 // PAL13338 + PAL15161 <--
1519 catch (...) { // PAL16774 (Crash after display of many groups)
1520 SMESH::OnVisuException();
1523 if (anAction == SMESH::eErase) {
1525 aSel->setSelectedObjects( l1 );
1528 aSel->setSelectedObjects( to_process );
1535 if(checkLock(aStudy)) break;
1538 EmitSignalDeactivateDialog();
1540 new SMESHGUI_NodesDlg(this);
1543 SUIT_MessageBox::warn1(desktop(),
1544 tr("SMESH_WRN_WARNING"),
1545 tr("SMESH_WRN_VIEWER_VTK"),
1546 tr("SMESH_BUT_OK"));
1551 case 2151: // FILTER
1555 EmitSignalDeactivateDialog();
1556 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1561 case 406: // MOVE NODE
1565 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1566 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1570 if(checkLock(aStudy)) break;
1571 new SMESHGUI_MoveNodesDlg(this);
1575 case 701: // COMPUTE MESH
1577 if (checkLock(aStudy)) break;
1579 startOperation( 701 );
1583 case 702: // Create mesh
1584 startOperation( 702 );
1586 case 703: // Create sub-mesh
1587 startOperation( 703 );
1589 case 704: // Edit mesh/sub-mesh
1590 startOperation( 704 );
1592 case 710: // Build compound mesh
1594 if (checkLock(aStudy)) break;
1595 EmitSignalDeactivateDialog();
1596 new SMESHGUI_BuildCompoundDlg( this );
1600 case 407: // DIAGONAL INVERSION
1601 case 408: // Delete diagonal
1605 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1606 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1610 if ( checkLock( aStudy ) )
1613 /*Standard_Boolean aRes;
1614 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1615 if ( aMesh->_is_nil() )
1617 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1618 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1622 EmitSignalDeactivateDialog();
1623 if ( theCommandID == 407 )
1624 new SMESHGUI_TrianglesInversionDlg(this);
1626 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1629 case 409: // Change orientation
1630 case 410: // Union of triangles
1631 case 411: // Cutting of quadrangles
1635 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1636 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1640 if ( checkLock( aStudy ) )
1643 EmitSignalDeactivateDialog();
1644 SMESHGUI_MultiEditDlg* aDlg = NULL;
1645 if ( theCommandID == 409 )
1646 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1647 else if ( theCommandID == 410 )
1648 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1650 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1655 case 412: // Smoothing
1657 if(checkLock(aStudy)) break;
1659 EmitSignalDeactivateDialog();
1660 new SMESHGUI_SmoothingDlg( this );
1663 SUIT_MessageBox::warn1(desktop(),
1664 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1665 tr("SMESH_BUT_OK"));
1669 case 413: // Extrusion
1671 if (checkLock(aStudy)) break;
1673 EmitSignalDeactivateDialog();
1674 new SMESHGUI_ExtrusionDlg ( this );
1676 SUIT_MessageBox::warn1(desktop(),
1677 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1678 tr("SMESH_BUT_OK"));
1682 case 414: // Revolution
1684 if(checkLock(aStudy)) break;
1686 EmitSignalDeactivateDialog();
1687 new SMESHGUI_RevolutionDlg( this );
1690 SUIT_MessageBox::warn1(desktop(),
1691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1692 tr("SMESH_BUT_OK"));
1696 case 415: // Pattern mapping
1698 if ( checkLock( aStudy ) )
1702 EmitSignalDeactivateDialog();
1703 new SMESHGUI_MeshPatternDlg( this );
1706 SUIT_MessageBox::warn1(desktop(),
1707 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1708 tr("SMESH_BUT_OK"));
1712 case 416: // Extrusion along a path
1714 if (checkLock(aStudy)) break;
1716 EmitSignalDeactivateDialog();
1717 new SMESHGUI_ExtrusionAlongPathDlg( this );
1719 SUIT_MessageBox::warn1(desktop(),
1720 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1721 tr("SMESH_BUT_OK"));
1725 case 417: // Convert mesh to quadratic
1727 startOperation( 417 );
1728 /* if (checkLock(aStudy)) break;
1730 EmitSignalDeactivateDialog();
1731 new SMESHGUI_ConvToQuadDlg();
1733 SUIT_MessageBox::warn1(desktop(),
1734 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1735 tr("SMESH_BUT_OK"));
1739 case 806: // CREATE GEO GROUP
1741 startOperation( 806 );
1744 case 801: // CREATE GROUP
1748 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1749 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1753 if(checkLock(aStudy)) break;
1754 EmitSignalDeactivateDialog();
1755 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1757 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1758 SALOME_ListIO selected;
1760 aSel->selectedObjects( selected );
1762 int nbSel = selected.Extent();
1764 // check if mesh is selected
1765 aMesh = SMESH::GetMeshByIO( selected.First() );
1767 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1772 case 802: // CONSTRUCT GROUP
1776 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1777 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1781 if(checkLock(aStudy)) break;
1782 EmitSignalDeactivateDialog();
1784 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1785 SALOME_ListIO selected;
1787 aSel->selectedObjects( selected );
1789 int nbSel = selected.Extent();
1791 // check if submesh is selected
1792 Handle(SALOME_InteractiveObject) IObject = selected.First();
1793 if (IObject->hasEntry()) {
1794 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1796 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1797 if (!aSubMesh->_is_nil()) {
1799 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1800 // get submesh elements list by types
1801 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1802 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1803 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1804 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1805 // create group for each type o elements
1806 QString aName = IObject->getName();
1807 if (aNodes->length() > 0) {
1808 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1809 aGroup->Add(aNodes.inout());
1811 if (aEdges->length() > 0) {
1812 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1813 aGroup->Add(aEdges.inout());
1815 if (aFaces->length() > 0) {
1816 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1817 aGroup->Add(aFaces.inout());
1819 if (aVolumes->length() > 0) {
1820 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1821 aGroup->Add(aVolumes.inout());
1826 catch(const SALOME::SALOME_Exception & S_ex){
1827 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1834 SUIT_MessageBox::warn1(desktop(),
1835 tr("SMESH_WRN_WARNING"),
1836 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1837 tr("SMESH_BUT_OK"));
1842 case 803: // EDIT GROUP
1846 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1847 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1851 if(checkLock(aStudy)) break;
1852 EmitSignalDeactivateDialog();
1854 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1855 SALOME_ListIO selected;
1857 aSel->selectedObjects( selected );
1859 SALOME_ListIteratorOfListIO It (selected);
1860 int nbSelectedGroups = 0;
1861 for ( ; It.More(); It.Next() )
1863 SMESH::SMESH_GroupBase_var aGroup =
1864 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1865 if (!aGroup->_is_nil()) {
1867 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1871 if (nbSelectedGroups == 0)
1873 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1879 case 804: // Add elements to group
1881 if(checkLock(aStudy)) break;
1882 if (myState == 800) {
1883 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1884 if (aDlg) aDlg->onAdd();
1889 case 805: // Remove elements from group
1891 if(checkLock(aStudy)) break;
1892 if (myState == 800) {
1893 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1894 if (aDlg) aDlg->onRemove();
1899 case 810: // Union Groups
1900 case 811: // Intersect groups
1901 case 812: // Cut groups
1905 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1906 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1910 if ( checkLock( aStudy ) )
1913 EmitSignalDeactivateDialog();
1916 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1917 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1918 else aMode = SMESHGUI_GroupOpDlg::CUT;
1920 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1924 case 813: // Delete groups with their contents
1928 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1929 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1933 if ( checkLock( aStudy ) )
1936 EmitSignalDeactivateDialog();
1938 new SMESHGUI_DeleteGroupDlg( this );
1942 case 900: // MESH INFOS
1944 EmitSignalDeactivateDialog();
1945 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1946 SALOME_ListIO selected;
1948 aSel->selectedObjects( selected );
1950 if ( selected.Extent() > 1 ) { // a dlg for each IO
1952 SALOME_ListIteratorOfListIO It (selected);
1953 for ( ; It.More(); It.Next() ) {
1954 IOs.Clear(); IOs.Append( It.Value() );
1955 aSel->setSelectedObjects( IOs );
1956 new SMESHGUI_MeshInfosDlg(this, "", false);
1958 // restore selection
1959 aSel->setSelectedObjects( selected );
1962 new SMESHGUI_MeshInfosDlg(this, "", false);
1966 case 902: // STANDARD MESH INFOS
1968 EmitSignalDeactivateDialog();
1969 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1970 SALOME_ListIO selected;
1972 aSel->selectedObjects( selected );
1974 if ( selected.Extent() > 1 ) { // a dlg for each IO
1976 SALOME_ListIteratorOfListIO It (selected);
1977 for ( ; It.More(); It.Next() ) {
1979 IOs.Append( It.Value() );
1980 aSel->setSelectedObjects( IOs );
1981 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1983 // restore selection
1984 aSel->setSelectedObjects( selected );
1987 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1991 case 903: // WHAT IS
1993 EmitSignalDeactivateDialog();
1994 new SMESHGUI_WhatIsDlg( this, "", false);
1998 case 1100: // EDIT HYPOTHESIS
2000 if(checkLock(aStudy)) break;
2002 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2003 SALOME_ListIO selected;
2005 aSel->selectedObjects( selected );
2007 int nbSel = selected.Extent();
2010 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2011 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2013 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2014 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2015 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2016 if ( !aHypothesis->_is_nil() )
2018 CORBA::String_var aHypType = aHypothesis->GetName();
2019 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
2021 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2028 updateObjBrowser( true );
2032 case 1101: // RENAME
2034 if ( checkLock( aStudy ) )
2037 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2038 SALOME_ListIO selected;
2040 aSel->selectedObjects( selected );
2042 bool isAny = false; // iss there any appropriate object selected
2044 SALOME_ListIteratorOfListIO It( selected );
2045 for ( ; It.More(); It.Next() )
2047 Handle(SALOME_InteractiveObject) IObject = It.Value();
2048 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2049 _PTR(GenericAttribute) anAttr;
2050 _PTR(AttributeName) aName;
2053 if ( obj->FindAttribute(anAttr, "AttributeName") )
2056 QString newName = QString(aName->Value().c_str());
2058 // check type to prevent renaming of inappropriate objects
2059 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2060 if (aType == MESH || aType == GROUP ||
2061 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2062 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2063 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2064 aType == HYPOTHESIS || aType == ALGORITHM)
2067 newName = LightApp_NameDlg::getName(desktop(), newName);
2068 if ( !newName.isEmpty() )
2070 //old source: aStudy->renameIObject( IObject, newName );
2071 aName->SetValue( newName.latin1() );
2073 // if current object is group update group's name
2074 SMESH::SMESH_GroupBase_var aGroup =
2075 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2076 if (!aGroup->_is_nil() )
2077 aGroup->SetName( newName.latin1() );
2087 SUIT_MessageBox::warn1(desktop(),
2088 QObject::tr("SMESH_WRN_WARNING"),
2089 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2090 QObject::tr("SMESH_BUT_OK"));
2095 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2097 if(checkLock(aStudy)) break;
2098 SUIT_OverrideCursor wc;
2100 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2101 SALOME_ListIO selected;
2103 aSel->selectedObjects( selected, QString::null, false );
2105 SALOME_ListIteratorOfListIO It(selected);
2106 for (int i = 0; It.More(); It.Next(), i++) {
2107 Handle(SALOME_InteractiveObject) IObject = It.Value();
2108 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2111 aSel->setSelectedObjects( l1 );
2116 case 401: // GEOM::EDGE
2117 case 4021: // TRIANGLE
2119 case 4023: // POLYGON
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 SMDSAbs_ElementType type = SMDSAbs_Edge;
2128 switch (theCommandID) {
2129 case 4021: // TRIANGLE
2130 type = SMDSAbs_Face; nbNodes = 3; break;
2132 type = SMDSAbs_Face; nbNodes = 4; break;
2134 type = SMDSAbs_Volume; nbNodes = 4; break;
2135 case 4023: // POLYGON
2136 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2138 type = SMDSAbs_Volume; nbNodes = 8; break;
2139 case 4033: // POLYHEDRE
2140 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2143 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2146 SUIT_MessageBox::warn1(desktop(),
2147 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2148 tr("SMESH_BUT_OK"));
2152 case 4033: // POLYHEDRON
2154 if(checkLock(aStudy)) break;
2156 EmitSignalDeactivateDialog();
2157 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2160 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2162 tr("SMESH_BUT_OK"));
2166 case 4034: // QUADRATIC EDGE
2167 case 4035: // QUADRATIC TRIANGLE
2168 case 4036: // QUADRATIC QUADRANGLE
2169 case 4037: // QUADRATIC TETRAHEDRON
2170 case 4038: // QUADRATIC PYRAMID
2171 case 4039: // QUADRATIC PENTAHEDRON
2172 case 4040: // QUADRATIC HEXAHEDRON
2174 if(checkLock(aStudy)) break;
2176 EmitSignalDeactivateDialog();
2179 switch (theCommandID) {
2181 type = QUAD_EDGE; break;
2183 type = QUAD_TRIANGLE; break;
2185 type = QUAD_QUADRANGLE; break;
2187 type = QUAD_TETRAHEDRON; break;
2189 type = QUAD_PYRAMID; break;
2191 type = QUAD_PENTAHEDRON; break;
2193 type = QUAD_HEXAHEDRON;
2197 new SMESHGUI_AddQuadraticElementDlg( this, type );
2200 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2201 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2202 tr("SMESH_BUT_OK"));
2206 case 4041: // REMOVES NODES
2208 if(checkLock(aStudy)) break;
2210 EmitSignalDeactivateDialog();
2211 new SMESHGUI_RemoveNodesDlg(this);
2214 SUIT_MessageBox::warn1(desktop(),
2215 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2216 tr("SMESH_BUT_OK"));
2220 case 4042: // REMOVES ELEMENTS
2222 if(checkLock(aStudy)) break;
2224 EmitSignalDeactivateDialog();
2225 new SMESHGUI_RemoveElementsDlg(this);
2229 SUIT_MessageBox::warn1(desktop(),
2230 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2231 tr("SMESH_BUT_OK"));
2235 case 4043: { // CLEAR_MESH
2237 if(checkLock(aStudy)) break;
2239 SALOME_ListIO selected;
2240 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2241 aSel->selectedObjects( selected );
2243 SUIT_OverrideCursor wc;
2244 SALOME_ListIteratorOfListIO It (selected);
2245 for ( ; It.More(); It.Next() )
2247 Handle(SALOME_InteractiveObject) IOS = It.Value();
2248 SMESH::SMESH_Mesh_var aMesh =
2249 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2250 if ( aMesh->_is_nil()) continue;
2252 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2254 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2255 SMESH::ModifiedMesh( aMeshSObj, false, true);
2256 // hide groups and submeshes
2257 _PTR(ChildIterator) anIter =
2258 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2259 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2261 _PTR(SObject) so = anIter->Value();
2262 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2265 catch (const SALOME::SALOME_Exception& S_ex){
2267 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2271 SMESH::UpdateView();
2275 case 4051: // RENUMBERING NODES
2277 if(checkLock(aStudy)) break;
2279 EmitSignalDeactivateDialog();
2280 new SMESHGUI_RenumberingDlg( this, "", 0);
2284 SUIT_MessageBox::warn1(desktop(),
2285 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2286 tr("SMESH_BUT_OK"));
2290 case 4052: // RENUMBERING ELEMENTS
2292 if(checkLock(aStudy)) break;
2294 EmitSignalDeactivateDialog();
2295 new SMESHGUI_RenumberingDlg( this, "", 1);
2299 SUIT_MessageBox::warn1(desktop(),
2300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2301 tr("SMESH_BUT_OK"));
2305 case 4061: // TRANSLATION
2307 if(checkLock(aStudy)) break;
2309 EmitSignalDeactivateDialog();
2310 new SMESHGUI_TranslationDlg( this );
2313 SUIT_MessageBox::warn1(desktop(),
2314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2315 tr("SMESH_BUT_OK"));
2319 case 4062: // ROTATION
2321 if(checkLock(aStudy)) break;
2323 EmitSignalDeactivateDialog();
2324 new SMESHGUI_RotationDlg( this );
2327 SUIT_MessageBox::warn1(desktop(),
2328 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2329 tr("SMESH_BUT_OK"));
2333 case 4063: // SYMMETRY
2335 if(checkLock(aStudy)) break;
2337 EmitSignalDeactivateDialog();
2338 new SMESHGUI_SymmetryDlg( this );
2341 SUIT_MessageBox::warn1(desktop(),
2342 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2343 tr("SMESH_BUT_OK"));
2347 case 4064: // SEWING
2349 if(checkLock(aStudy)) break;
2351 EmitSignalDeactivateDialog();
2352 new SMESHGUI_SewingDlg( this );
2355 SUIT_MessageBox::warn1(desktop(),
2356 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2357 tr("SMESH_BUT_OK"));
2361 case 4065: // MERGE NODES
2363 if(checkLock(aStudy)) break;
2365 EmitSignalDeactivateDialog();
2366 new SMESHGUI_EditMeshDlg( this, 0 );
2369 SUIT_MessageBox::warn1(desktop(),
2370 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2371 tr("SMESH_BUT_OK"));
2375 case 4066: // MERGE EQUAL ELEMENTS
2377 if (checkLock(aStudy)) break;
2379 EmitSignalDeactivateDialog();
2380 new SMESHGUI_EditMeshDlg( this, 1 );
2382 SUIT_MessageBox::warn1(desktop(),
2383 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2384 tr("SMESH_BUT_OK"));
2389 case 4067: // MAKE MESH PASS THROUGH POINT
2390 startOperation( 4067 );
2393 case 5105: // Library of selection filters
2395 static QValueList<int> aTypes;
2396 if ( aTypes.isEmpty() )
2398 aTypes.append( SMESH::NODE );
2399 aTypes.append( SMESH::EDGE );
2400 aTypes.append( SMESH::FACE );
2401 aTypes.append( SMESH::VOLUME );
2403 if (!myFilterLibraryDlg)
2404 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2405 else if (myFilterLibraryDlg->isHidden())
2406 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2407 myFilterLibraryDlg->raise();
2411 case 6017: // CONTROLS
2427 LightApp_SelectionMgr* mgr = selectionMgr();
2428 SALOME_ListIO selected; mgr->selectedObjects( selected );
2430 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2431 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2433 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2434 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2435 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2436 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2437 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2438 ::Control( theCommandID );
2443 SUIT_MessageBox::warn1(desktop(),
2444 tr( "SMESH_WRN_WARNING" ),
2445 tr( "SMESH_BAD_SELECTION" ),
2446 tr( "SMESH_BUT_OK" ) );
2450 SUIT_MessageBox::warn1(desktop(),
2451 tr( "SMESH_WRN_WARNING" ),
2452 tr( "NOT_A_VTK_VIEWER" ),
2453 tr( "SMESH_BUT_OK" ) );
2458 LightApp_SelectionMgr* mgr = selectionMgr();
2459 SALOME_ListIO selected; mgr->selectedObjects( selected );
2461 SALOME_ListIteratorOfListIO it(selected);
2462 for(; it.More(); it.Next()) {
2463 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2464 if(anIObject->hasEntry()) {
2465 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2466 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2474 LightApp_SelectionMgr* mgr = selectionMgr();
2475 SALOME_ListIO selected; mgr->selectedObjects( selected );
2477 if (selected.Extent() == 1) {
2478 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2479 if(anIObject->hasEntry())
2480 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2481 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2488 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2489 //updateObjBrowser();
2493 //=============================================================================
2497 //=============================================================================
2498 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2503 //=============================================================================
2507 //=============================================================================
2508 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2513 //=============================================================================
2517 //=============================================================================
2518 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2523 //=============================================================================
2524 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2525 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2527 //=============================================================================
2528 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2529 SUIT_ViewWindow* wnd )
2531 if(theIO->hasEntry()){
2532 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2533 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2537 //=======================================================================
2538 // function : createSMESHAction
2540 //=======================================================================
2541 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2544 QWidget* parent = application()->desktop();
2545 SUIT_ResourceMgr* resMgr = resourceMgr();
2547 if ( icon_id.length() )
2548 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2550 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2551 if ( !pix.isNull() )
2552 icon = QIconSet( pix );
2554 QString tooltip = tr( QString( "TOP_" )+po_id ),
2555 menu = tr( QString( "MEN_" )+po_id ),
2556 status_bar = tr( QString( "STB_" )+po_id );
2558 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2561 //=======================================================================
2562 // function : createPopupItem
2564 //=======================================================================
2565 void SMESHGUI::createPopupItem( const int id,
2566 const QString& clients,
2567 const QString& types,
2568 const QString& theRule,
2573 parentId = popupMgr()->actionId( action( pId ) );
2575 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2576 popupMgr()->insert( action( id ), parentId, 0 );
2578 QChar lc = QtxPopupMgr::Selection::defEquality();
2579 QString rule = "(%1) and (%2) and (%3)";
2580 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2581 if( clients.isEmpty() )
2582 rule = rule.arg( QString( "true" ) );
2584 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2585 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2588 bool cont = myRules.contains( id );
2590 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2592 popupMgr()->setRule( action( id ), rule, true );
2593 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2596 //=======================================================================
2597 // function : initialize
2599 //=======================================================================
2600 void SMESHGUI::initialize( CAM_Application* app )
2602 SalomeApp_Module::initialize( app );
2604 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2606 /* Automatic Update flag */
2607 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2609 // ----- create actions --------------
2611 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2612 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2613 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2614 createSMESHAction( 114, "NUM" );
2615 createSMESHAction( 121, "DAT" );
2616 createSMESHAction( 122, "MED" );
2617 createSMESHAction( 123, "UNV" );
2618 createSMESHAction( 140, "STL" );
2619 createSMESHAction( 124, "EXPORT_DAT" );
2620 createSMESHAction( 125, "EXPORT_MED" );
2621 createSMESHAction( 126, "EXPORT_UNV" );
2622 createSMESHAction( 141, "EXPORT_STL" );
2623 createSMESHAction( 150, "FILE_INFO" );
2624 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2625 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2626 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2627 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2628 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2629 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2630 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2631 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" );
2632 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2633 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2634 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2635 createSMESHAction( 804, "ADD" );
2636 createSMESHAction( 805, "REMOVE" );
2637 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2638 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2639 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2640 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2641 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2642 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2643 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2644 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2645 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2646 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2647 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2648 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2649 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2650 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2651 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2652 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2653 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2654 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2655 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2656 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2657 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2658 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2659 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2660 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2661 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2662 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2663 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2664 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2665 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2666 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2667 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2668 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2669 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2670 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2671 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2672 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2673 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2674 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2675 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2676 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2677 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2678 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2679 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2680 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2681 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2682 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2683 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2684 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2685 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2686 createSMESHAction( 415, "MAP", "ICON_MAP" );
2687 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2688 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2689 createSMESHAction( 200, "RESET" );
2690 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2691 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2692 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2693 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2694 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2695 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2696 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2697 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2698 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2699 createSMESHAction( 220, "ALL" );
2700 createSMESHAction( 1100, "EDIT_HYPO" );
2701 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2702 createSMESHAction( 1102, "UNASSIGN" );
2703 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2704 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2705 createSMESHAction( 1131, "DISPMODE" );
2706 createSMESHAction( 1132, "COLORS" );
2707 createSMESHAction( 1133, "TRANSP" );
2708 createSMESHAction( 1134, "CLIP" );
2709 createSMESHAction( 1135, "DISP_ENT" );
2710 createSMESHAction( 1136, "AUTO_COLOR" );
2711 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2712 createSMESHAction( 2000, "CTRL" );
2714 createSMESHAction( 300, "ERASE" );
2715 createSMESHAction( 301, "DISPLAY" );
2716 createSMESHAction( 302, "DISPLAY_ONLY" );
2717 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2718 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2719 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2720 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2721 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2722 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2723 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2724 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2726 // ----- create menu --------------
2727 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2728 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2729 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2730 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2731 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2732 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2733 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2735 createMenu( separator(), fileId );
2737 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2738 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2739 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2740 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2741 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2742 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2744 createMenu( 111, importId, -1 );
2745 createMenu( 112, importId, -1 );
2746 createMenu( 113, importId, -1 );
2748 createMenu( 121, exportId, -1 );
2749 createMenu( 122, exportId, -1 );
2750 createMenu( 123, exportId, -1 );
2751 createMenu( 140, exportId, -1 ); // export to stl STL
2753 createMenu( separator(), fileId, 10 );
2755 createMenu( 33, editId, -1 );
2757 createMenu( 5105, toolsId, -1 );
2759 createMenu( 702, meshId, -1 ); // "Mesh" menu
2760 createMenu( 703, meshId, -1 );
2761 createMenu( 704, meshId, -1 );
2762 createMenu( 710, meshId, -1 );
2763 createMenu( separator(), meshId, -1 );
2764 createMenu( 701, meshId, -1 );
2765 createMenu( separator(), meshId, -1 );
2766 createMenu( 801, meshId, -1 );
2767 createMenu( 806, meshId, -1 );
2768 createMenu( 802, meshId, -1 );
2769 createMenu( 803, meshId, -1 );
2770 createMenu( separator(), meshId, -1 );
2771 createMenu( 810, meshId, -1 );
2772 createMenu( 811, meshId, -1 );
2773 createMenu( 812, meshId, -1 );
2774 createMenu( separator(), meshId, -1 );
2775 createMenu( 813, meshId, -1 );
2776 createMenu( separator(), meshId, -1 );
2777 createMenu( 900, meshId, -1 );
2778 createMenu( 902, meshId, -1 );
2779 createMenu( 903, meshId, -1 );
2780 createMenu( separator(), meshId, -1 );
2782 createMenu( 6003, ctrlId, -1 );
2783 createMenu( 6001, ctrlId, -1 );
2784 createMenu( 6004, ctrlId, -1 );
2785 createMenu( separator(), ctrlId, -1 );
2786 createMenu( 6002, ctrlId, -1 );
2787 createMenu( 6018, ctrlId, -1 );
2788 createMenu( 6019, ctrlId, -1 );
2789 createMenu( 6011, ctrlId, -1 );
2790 createMenu( 6012, ctrlId, -1 );
2791 createMenu( 6013, ctrlId, -1 );
2792 createMenu( 6014, ctrlId, -1 );
2793 createMenu( 6015, ctrlId, -1 );
2794 createMenu( 6016, ctrlId, -1 );
2795 createMenu( separator(), ctrlId, -1 );
2796 createMenu( 6017, ctrlId, -1 );
2797 createMenu( 6009, ctrlId, -1 );
2798 createMenu( separator(), ctrlId, -1 );
2800 createMenu( 400, addId, -1 );
2801 createMenu( 401, addId, -1 );
2802 createMenu( 4021, addId, -1 );
2803 createMenu( 4022, addId, -1 );
2804 createMenu( 4023, addId, -1 );
2805 createMenu( 4031, addId, -1 );
2806 createMenu( 4032, addId, -1 );
2807 createMenu( 4033, addId, -1 );
2808 createMenu( separator(), addId, -1 );
2809 createMenu( 4034, addId, -1 );
2810 createMenu( 4035, addId, -1 );
2811 createMenu( 4036, addId, -1 );
2812 createMenu( 4037, addId, -1 );
2813 createMenu( 4038, addId, -1 );
2814 createMenu( 4039, addId, -1 );
2815 createMenu( 4040, addId, -1 );
2817 createMenu( 4041, removeId, -1 );
2818 createMenu( 4042, removeId, -1 );
2819 createMenu( 4043, removeId, -1 );
2821 createMenu( 4051, renumId, -1 );
2822 createMenu( 4052, renumId, -1 );
2824 createMenu( 4061, transfId, -1 );
2825 createMenu( 4062, transfId, -1 );
2826 createMenu( 4063, transfId, -1 );
2827 createMenu( 4064, transfId, -1 );
2828 createMenu( 4065, transfId, -1 );
2829 createMenu( 4066, transfId, -1 );
2831 createMenu( 406, modifyId, -1 );
2832 createMenu( 4067,modifyId, -1 );
2833 createMenu( 407, modifyId, -1 );
2834 createMenu( 408, modifyId, -1 );
2835 createMenu( 409, modifyId, -1 );
2836 createMenu( 410, modifyId, -1 );
2837 createMenu( 411, modifyId, -1 );
2838 createMenu( 412, modifyId, -1 );
2839 createMenu( 413, modifyId, -1 );
2840 createMenu( 416, modifyId, -1 );
2841 createMenu( 414, modifyId, -1 );
2842 createMenu( 415, modifyId, -1 );
2843 createMenu( 417, modifyId, -1 );
2845 createMenu( 214, viewId, -1 );
2847 // ----- create toolbars --------------
2848 int meshTb = createTool( tr( "TB_MESH" ) ),
2849 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2850 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2851 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2852 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2854 createTool( 702, meshTb );
2855 createTool( 703, meshTb );
2856 createTool( 704, meshTb );
2857 createTool( 710, meshTb );
2858 createTool( separator(), meshTb );
2859 createTool( 701, meshTb );
2860 createTool( separator(), meshTb );
2861 createTool( 801, meshTb );
2862 createTool( 806, meshTb );
2863 createTool( 802, meshTb );
2864 createTool( 803, meshTb );
2865 createTool( separator(), meshTb );
2866 createTool( 900, meshTb );
2867 createTool( 902, meshTb );
2868 createTool( 903, meshTb );
2869 createTool( separator(), meshTb );
2871 createTool( 6001, ctrlTb );
2872 createTool( 6003, ctrlTb );
2873 createTool( 6004, ctrlTb );
2874 createTool( separator(), ctrlTb );
2875 createTool( 6002, ctrlTb );
2876 createTool( 6018, ctrlTb );
2877 createTool( 6019, ctrlTb );
2878 createTool( 6011, ctrlTb );
2879 createTool( 6012, ctrlTb );
2880 createTool( 6013, ctrlTb );
2881 createTool( 6014, ctrlTb );
2882 createTool( 6015, ctrlTb );
2883 createTool( 6016, ctrlTb );
2884 createTool( separator(), ctrlTb );
2885 createTool( 6017, ctrlTb );
2886 createTool( 6009, ctrlTb );
2887 createTool( separator(), ctrlTb );
2889 createTool( 400, addRemTb );
2890 createTool( 401, addRemTb );
2891 createTool( 4021, addRemTb );
2892 createTool( 4022, addRemTb );
2893 createTool( 4023, addRemTb );
2894 createTool( 4031, addRemTb );
2895 createTool( 4032, addRemTb );
2896 createTool( 4033, addRemTb );
2897 createTool( separator(), addRemTb );
2898 createTool( 4034, addRemTb );
2899 createTool( 4035, addRemTb );
2900 createTool( 4036, addRemTb );
2901 createTool( 4037, addRemTb );
2902 createTool( 4038, addRemTb );
2903 createTool( 4039, addRemTb );
2904 createTool( 4040, addRemTb );
2905 createTool( separator(), addRemTb );
2906 createTool( 4041, addRemTb );
2907 createTool( 4042, addRemTb );
2908 createTool( 4043, addRemTb );
2909 createTool( separator(), addRemTb );
2910 createTool( 4051, addRemTb );
2911 createTool( 4052, addRemTb );
2912 createTool( separator(), addRemTb );
2913 createTool( 4061, addRemTb );
2914 createTool( 4062, addRemTb );
2915 createTool( 4063, addRemTb );
2916 createTool( 4064, addRemTb );
2917 createTool( 4065, addRemTb );
2918 createTool( 4066, addRemTb );
2919 createTool( separator(), addRemTb );
2921 createTool( 406, modifyTb );
2922 createTool( 4067,modifyTb );
2923 createTool( 407, modifyTb );
2924 createTool( 408, modifyTb );
2925 createTool( 409, modifyTb );
2926 createTool( 410, modifyTb );
2927 createTool( 411, modifyTb );
2928 createTool( 412, modifyTb );
2929 createTool( 413, modifyTb );
2930 createTool( 416, modifyTb );
2931 createTool( 414, modifyTb );
2932 createTool( 415, modifyTb );
2933 createTool( 417, modifyTb );
2935 createTool( 214, dispModeTb );
2939 QString OB = "'ObjectBrowser'",
2940 View = "'" + SVTK_Viewer::Type() + "'",
2942 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2943 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2944 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2945 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2946 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2947 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2948 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2949 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2950 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2951 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2952 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2954 mesh_group = mesh + " " + subMesh + " " + group,
2955 hyp_alg = hypo + " " + algo;
2957 // popup for object browser
2959 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2961 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2962 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2963 createPopupItem( 803, OB, group ); // EDIT_GROUP
2964 popupMgr()->insert( separator(), -1, 0 );
2965 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2966 createPopupItem( 214, OB, mesh_group ); // UPDATE
2967 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2968 createPopupItem( 902, OB, mesh ); // STD_INFO
2969 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2970 popupMgr()->insert( separator(), -1, 0 );
2971 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2972 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
2973 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2974 popupMgr()->insert( separator(), -1, 0 );
2975 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2976 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2977 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2978 popupMgr()->insert( separator(), -1, 0 );
2979 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2980 popupMgr()->insert( separator(), -1, 0 );
2982 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2983 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2985 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2986 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2987 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2988 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2989 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2990 popupMgr()->insert( separator(), -1, 0 );
2993 createPopupItem( 803, View, group ); // EDIT_GROUP
2994 createPopupItem( 804, View, elems ); // ADD
2995 createPopupItem( 805, View, elems ); // REMOVE
2996 popupMgr()->insert( separator(), -1, 0 );
2997 createPopupItem( 214, View, mesh_group ); // UPDATE
2998 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2999 createPopupItem( 902, View, mesh ); // STD_INFO
3000 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3001 popupMgr()->insert( separator(), -1, 0 );
3003 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3004 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3005 popupMgr()->insert( separator(), -1, 0 );
3009 isInvisible("not( isVisible )"),
3010 isEmpty("numberOfNodes = 0"),
3011 isNotEmpty("numberOfNodes <> 0"),
3013 // has nodes, edges, etc in VISIBLE! actor
3014 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3015 hasElems("(count( elemTypes ) > 0)"),
3016 hasDifferentElems("(count( elemTypes ) > 1)"),
3017 hasEdges("({'Edge'} in elemTypes)"),
3018 hasFaces("({'Face'} in elemTypes)"),
3019 hasVolumes("({'Volume'} in elemTypes)");
3021 QString lc = QtxPopupMgr::Selection::defEquality();
3022 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3023 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
3024 aType = aType.arg( mesh_group );
3025 QString aMeshInVTK = aClient + "&&" + aType;
3027 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3028 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3029 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
3031 //-------------------------------------------------
3033 //-------------------------------------------------
3034 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3036 popupMgr()->insert( action( 9010 ), anId, -1 );
3037 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
3038 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
3040 popupMgr()->insert( action( 9011 ), anId, -1 );
3041 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
3042 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
3044 popupMgr()->insert( separator(), -1, -1 );
3046 //-------------------------------------------------
3048 //-------------------------------------------------
3049 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3051 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3052 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3053 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3055 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3056 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3057 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3059 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3060 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3061 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3063 popupMgr()->insert( separator(), anId, -1 );
3065 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3066 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3067 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3069 //-------------------------------------------------
3071 //-------------------------------------------------
3072 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3074 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3076 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3077 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3078 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3080 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3081 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3082 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3084 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3085 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3086 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3088 popupMgr()->insert( separator(), anId, -1 );
3090 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3091 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3093 //-------------------------------------------------
3095 //-------------------------------------------------
3096 popupMgr()->insert( action( 1132 ), -1, -1 );
3097 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3099 //-------------------------------------------------
3101 //-------------------------------------------------
3102 popupMgr()->insert( action( 1133 ), -1, -1 );
3103 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3105 //-------------------------------------------------
3107 //-------------------------------------------------
3108 popupMgr()->insert( action( 1134 ), -1, -1 );
3109 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3111 popupMgr()->insert( separator(), -1, -1 );
3113 //-------------------------------------------------
3115 //-------------------------------------------------
3117 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3118 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3119 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3121 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3123 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3124 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3126 popupMgr()->insert( separator(), anId, -1 );
3128 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3129 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3130 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3132 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3133 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3134 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3136 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3137 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3138 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3140 popupMgr()->insert( separator(), anId, -1 );
3142 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3143 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3144 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3146 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3147 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3148 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3150 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3151 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3152 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3154 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3155 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3156 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3158 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3159 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3160 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3162 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3163 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3164 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3166 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3167 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3168 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3170 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3171 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3172 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3174 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3175 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3176 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3178 popupMgr()->insert( separator(), anId, -1 );
3180 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3181 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3182 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3184 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3185 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3186 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3188 popupMgr()->insert( separator(), anId, -1 );
3190 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3191 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3193 popupMgr()->insert( separator(), -1, -1 );
3195 //-------------------------------------------------
3197 //-------------------------------------------------
3198 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3199 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3200 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3201 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3203 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3204 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3206 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3207 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3209 popupMgr()->insert( separator(), -1, -1 );
3211 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3212 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3215 //================================================================================
3217 * \brief Return true if SMESH or GEOM objects are selected.
3218 * Is called form LightApp_Module::activateModule() which clear selection if
3219 * not isSelectionCompatible()
3221 //================================================================================
3223 bool SMESHGUI::isSelectionCompatible()
3225 bool isCompatible = true;
3226 SALOME_ListIO selected;
3227 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3228 Sel->selectedObjects( selected );
3230 SALOME_ListIteratorOfListIO It( selected );
3231 for ( ; isCompatible && It.More(); It.Next())
3233 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3234 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3236 return isCompatible;
3239 bool SMESHGUI::activateModule( SUIT_Study* study )
3241 bool res = SalomeApp_Module::activateModule( study );
3243 setMenuShown( true );
3244 setToolShown( true );
3246 // Reset actions accelerator keys
3247 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3248 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3249 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3251 action( 33)->setEnabled(true); // Delete: Key_Delete
3252 action(1101)->setEnabled(true); // Rename: Key_F2
3257 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3259 setMenuShown( false );
3260 setToolShown( false );
3262 EmitSignalCloseAllDialogs();
3264 // Unset actions accelerator keys
3265 action(111)->setAccel(QKeySequence()); // Import DAT
3266 action(112)->setAccel(QKeySequence()); // Import UNV
3267 action(113)->setAccel(QKeySequence()); // Import MED
3269 action( 33)->setEnabled(false); // Delete: Key_Delete
3270 action(1101)->setEnabled(false); // Rename: Key_F2
3272 return SalomeApp_Module::deactivateModule( study );
3275 void SMESHGUI::studyClosed( SUIT_Study* s )
3277 SMESH::RemoveVisuData( s->id() );
3278 SalomeApp_Module::studyClosed( s );
3281 void SMESHGUI::OnGUIEvent()
3283 const QObject* obj = sender();
3284 if ( !obj || !obj->inherits( "QAction" ) )
3286 int id = actionId((QAction*)obj);
3291 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3293 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3294 if ( CORBA::is_nil( myComponentSMESH ) )
3296 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3298 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3299 return aGUI.myComponentSMESH;
3302 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3303 return myComponentSMESH;
3306 QString SMESHGUI::engineIOR() const
3308 CORBA::ORB_var anORB = getApp()->orb();
3309 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3310 return QString( anIOR.in() );
3313 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3315 SMESHGUI_Selection sel;
3316 sel.init( client, selectionMgr() );
3317 popupMgr()->updatePopup( menu, &sel );
3320 selectionMgr()->selectedObjects( lst );
3321 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3322 Handle(SALOME_InteractiveObject) io = lst.First();
3323 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3324 _PTR(Study) study = appStudy->studyDS();
3325 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3327 QString aName = QString( obj->GetName().c_str() );
3328 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3329 aName.remove( (aName.length() - 1), 1 );
3335 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3337 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3338 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3341 void SMESHGUI::viewManagers( QStringList& list ) const
3343 list.append( SVTK_Viewer::Type() );
3346 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3348 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3349 SMESH::UpdateSelectionProp( this );
3352 void SMESHGUI::createPreferences()
3354 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3356 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3357 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3359 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3360 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3361 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3363 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3364 setPreferenceProperty( precGroup, "columns", 1 );
3366 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3368 setPreferenceProperty( prec, "min", 0 );
3369 setPreferenceProperty( prec, "max", 16 );
3371 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3372 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3374 modes.append( "Wireframe" );
3375 modes.append( "Shading" );
3376 modes.append( "Nodes" );
3377 modes.append( "Shrink" );
3378 QValueList<QVariant> indices;
3379 indices.append( 0 );
3380 indices.append( 1 );
3381 indices.append( 2 );
3382 indices.append( 3 );
3383 setPreferenceProperty( dispmode, "strings", modes );
3384 setPreferenceProperty( dispmode, "indexes", indices );
3386 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3387 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3388 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3390 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3391 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3393 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3394 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3396 setPreferenceProperty( nodeSz, "min", 1 );
3397 setPreferenceProperty( nodeSz, "max", 5 );
3399 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3401 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3402 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3403 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3404 addPreference( "", elemGroup, LightApp_Preferences::Space );
3406 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3407 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3409 setPreferenceProperty( elemW, "min", 1 );
3410 setPreferenceProperty( elemW, "max", 5 );
3412 setPreferenceProperty( shrink, "min", 0 );
3413 setPreferenceProperty( shrink, "max", 100 );
3415 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3417 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3419 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3420 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3421 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3423 setPreferenceProperty( selW, "min", 1 );
3424 setPreferenceProperty( selW, "max", 5 );
3426 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3428 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3429 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3431 setPreferenceProperty( preW, "min", 1 );
3432 setPreferenceProperty( preW, "max", 5 );
3434 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3436 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3437 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3438 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3440 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3441 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3443 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3444 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3445 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3446 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3449 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3450 fam.append( tr( "SMESH_FONT_COURIER" ) );
3451 fam.append( tr( "SMESH_FONT_TIMES" ) );
3452 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3454 setPreferenceProperty( tfont, "families", fam );
3455 setPreferenceProperty( tfont, "system", false );
3456 setPreferenceProperty( tfont, "widget_flags", wflag );
3457 setPreferenceProperty( lfont, "families", fam );
3458 setPreferenceProperty( lfont, "system", false );
3459 setPreferenceProperty( lfont, "widget_flags", wflag );
3461 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3463 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3464 setPreferenceProperty( numcol, "min", 2 );
3465 setPreferenceProperty( numcol, "max", 256 );
3467 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3468 setPreferenceProperty( numlab, "min", 2 );
3469 setPreferenceProperty( numlab, "max", 65 );
3471 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3472 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3473 QStringList orients;
3474 orients.append( tr( "SMESH_VERTICAL" ) );
3475 orients.append( tr( "SMESH_HORIZONTAL" ) );
3476 indices.clear(); indices.append( 0 ); indices.append( 1 );
3477 setPreferenceProperty( orient, "strings", orients );
3478 setPreferenceProperty( orient, "indexes", indices );
3480 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3481 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3482 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3483 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3484 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3485 setPreferenceProperty( xv, "step", 0.1 );
3486 setPreferenceProperty( xv, "min", 0.0 );
3487 setPreferenceProperty( xv, "max", 1.0 );
3488 setPreferenceProperty( yv, "step", 0.1 );
3489 setPreferenceProperty( yv, "min", 0.0 );
3490 setPreferenceProperty( yv, "max", 1.0 );
3491 setPreferenceProperty( wv, "step", 0.1 );
3492 setPreferenceProperty( wv, "min", 0.0 );
3493 setPreferenceProperty( wv, "max", 1.0 );
3494 setPreferenceProperty( hv, "min", 0.0 );
3495 setPreferenceProperty( hv, "max", 1.0 );
3496 setPreferenceProperty( hv, "step", 0.1 );
3498 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3499 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3500 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3501 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3502 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3503 setPreferenceProperty( xv, "min", 0.0 );
3504 setPreferenceProperty( xv, "max", 1.0 );
3505 setPreferenceProperty( xv, "step", 0.1 );
3506 setPreferenceProperty( xh, "min", 0.0 );
3507 setPreferenceProperty( xh, "max", 1.0 );
3508 setPreferenceProperty( xh, "step", 0.1 );
3509 setPreferenceProperty( yh, "min", 0.0 );
3510 setPreferenceProperty( yh, "max", 1.0 );
3511 setPreferenceProperty( yh, "step", 0.1 );
3512 setPreferenceProperty( wh, "min", 0.0 );
3513 setPreferenceProperty( wh, "max", 1.0 );
3514 setPreferenceProperty( wh, "step", 0.1 );
3515 setPreferenceProperty( hh, "min", 0.0 );
3516 setPreferenceProperty( hh, "max", 1.0 );
3517 setPreferenceProperty( hh, "step", 0.1 );
3520 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3522 if( sect=="SMESH" ){
3523 float sbX1,sbY1,sbW,sbH;
3524 float aTol = 1.00000009999999;
3525 std::string aWarning;
3526 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3527 if( name=="selection_object_color" || name=="selection_element_color" ||
3528 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3529 name=="selection_precision_node" || name=="selection_precision_element" ||
3530 name=="selection_precision_object")
3531 SMESH::UpdateSelectionProp( this );
3532 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3533 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3534 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3535 if(sbX1+sbW > aTol){
3536 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3539 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3540 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3543 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3544 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3545 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3546 if(sbY1+sbH > aTol){
3547 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3548 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3549 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3552 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3553 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3554 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3555 if(sbX1+sbW > aTol){
3556 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3559 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3560 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3563 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3564 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3565 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3566 if(sbY1+sbH > aTol){
3567 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3570 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3571 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3575 if(aWarning.size() != 0){
3576 aWarning += "The default values are applied instead.";
3577 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3578 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3579 QObject::tr(aWarning.c_str()),
3580 QObject::tr("SMESH_BUT_OK"));
3585 //================================================================================
3587 * \brief Update something in accordance with update flags
3588 * \param theFlags - update flags
3590 * Update viewer or/and object browser etc. in accordance with update flags ( see
3591 * LightApp_UpdateFlags enumeration ).
3593 //================================================================================
3594 void SMESHGUI::update( const int flags )
3596 if ( flags & UF_Viewer | flags & UF_Forced )
3597 SMESH::UpdateView();
3599 SalomeApp_Module::update( flags );
3602 //================================================================================
3604 * \brief Set default selection mode
3606 * SLOT called when operation commited. Sets default selection mode
3608 //================================================================================
3609 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3611 SVTK_ViewWindow* vtkWnd =
3612 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3614 vtkWnd->SetSelectionMode( ActorSelection );
3617 //================================================================================
3619 * \brief Set default selection mode
3621 * SLOT called when operation aborted. Sets default selection mode
3623 //================================================================================
3624 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3626 SVTK_ViewWindow* vtkWnd =
3627 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3629 vtkWnd->SetSelectionMode( ActorSelection );
3632 //================================================================================
3634 * \brief Creates operation with given identifier
3635 * \param id - identifier of operation to be started
3636 * \return Pointer on created operation or NULL if operation is not created
3638 * Virtual method redefined from the base class creates operation with given id.
3639 * It is called called automatically from startOperation method of base class.
3641 //================================================================================
3642 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3644 LightApp_Operation* op = 0;
3645 // to do : create operation here
3648 case 701: // Compute mesh
3649 op = new SMESHGUI_ComputeOp();
3651 case 702: // Create mesh
3652 op = new SMESHGUI_MeshOp( true, true );
3654 case 703: // Create sub-mesh
3655 op = new SMESHGUI_MeshOp( true, false );
3657 case 704: // Edit mesh/sub-mesh
3658 op = new SMESHGUI_MeshOp( false );
3660 case 806: // Create group on geom
3661 op = new SMESHGUI_GroupOnShapeOp();
3663 case 417: //convert to quadratic
3664 op = new SMESHGUI_ConvToQuadOp();
3666 case 4067: // make mesh pass through point
3667 op = new SMESHGUI_MakeNodeAtPointOp();
3674 op = SalomeApp_Module::createOperation( id );
3678 //================================================================================
3680 * \brief Stops current operations and starts a given one
3681 * \param id - The id of the operation to start
3683 //================================================================================
3685 void SMESHGUI::switchToOperation(int id)
3687 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3688 activeStudy()->abortAllOperations();
3689 startOperation( id );
3692 LightApp_Displayer* SMESHGUI::displayer()
3695 myDisplayer = new SMESHGUI_Displayer( getApp() );
3699 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3702 int aTolerance = 64;
3703 int anIterations = 0;
3709 if( anIterations % aPeriod == 0 )
3712 if( aTolerance < 1 )
3715 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3717 aHue = (int)( 360.0 * rand() / RAND_MAX );
3718 //cout << "Hue = " << aHue << endl;
3720 //cout << "Auto colors : ";
3722 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3723 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3724 for( ; it != itEnd; ++it )
3726 SALOMEDS::Color anAutoColor = *it;
3727 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3730 aQColor.getHsv( &h, &s, &v );
3732 if( abs( h - aHue ) < aTolerance )
3735 //cout << "break (diff = " << abs( h - aHue ) << ")";
3745 //cout << "Hue of the returned color = " << aHue << endl;
3747 aColor.setHsv( aHue, 255, 255 );
3749 SALOMEDS::Color aSColor;
3750 aSColor.R = (double)aColor.red() / 255.0;
3751 aSColor.G = (double)aColor.green() / 255.0;
3752 aSColor.B = (double)aColor.blue() / 255.0;