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"
73 #include "SMESHGUI_Utils.h"
74 #include "SMESHGUI_GEOMGenUtils.h"
75 #include "SMESHGUI_MeshUtils.h"
76 #include "SMESHGUI_GroupUtils.h"
77 #include "SMESHGUI_FilterUtils.h"
78 #include "SMESHGUI_PatternUtils.h"
79 #include "SMESHGUI_VTKUtils.h"
80 #include "SMESHGUI_HypothesesUtils.h"
82 #include "SMESH_Actor.h"
83 #include "SMESH_Object.h"
84 #include "SMESH_TypeFilter.hxx"
86 #include "SalomeApp_Tools.h"
87 #include "SalomeApp_Study.h"
88 #include "SalomeApp_Application.h"
89 #include "SalomeApp_CheckFileDlg.h"
90 #include "SalomeApp_ImportOperation.h"
92 #include "LightApp_DataOwner.h"
93 #include "LightApp_Preferences.h"
94 #include "LightApp_VTKSelector.h"
95 #include "LightApp_Operation.h"
96 #include "LightApp_UpdateFlags.h"
97 #include "LightApp_NameDlg.h"
99 #include <SVTK_ViewWindow.h>
100 #include <SVTK_ViewModel.h>
101 #include <SVTK_InteractorStyle.h>
102 #include <SVTK_RenderWindowInteractor.h>
103 #include <SVTK_ViewManager.h>
105 #include "OB_Browser.h"
107 #include "SUIT_Tools.h"
108 #include "SUIT_MessageBox.h"
109 #include "SUIT_ResourceMgr.h"
110 #include "SUIT_FileDlg.h"
111 #include "SUIT_Desktop.h"
112 #include "SUIT_OverrideCursor.h"
113 #include "SUIT_Study.h"
114 #include "SUIT_Session.h"
116 #include "QtxPopupMgr.h"
118 #include "SALOME_ListIO.hxx"
119 #include "SALOME_ListIteratorOfListIO.hxx"
120 #include "SALOME_InteractiveObject.hxx"
121 #include "SALOME_NamingService.hxx"
122 #include "SALOME_LifeCycleCORBA.hxx"
124 #include "SALOMEconfig.h"
125 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
126 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
129 #define INCLUDE_MENUITEM_DEF
130 #include <qpopupmenu.h>
136 #include <boost/shared_ptr.hpp>
139 #include <vtkRenderer.h>
140 #include <vtkRenderWindow.h>
141 #include <vtkActorCollection.h>
142 #include <vtkScalarBarActor.h>
143 #include <vtkUnstructuredGrid.h>
145 #include "utilities.h"
147 #include "SALOMEDS_Study.hxx"
148 #include "SALOMEDSClient_StudyBuilder.hxx"
149 #include "SALOMEDSClient_SComponent.hxx"
151 #include <Standard_ErrorHandler.hxx>
157 //=============================================================
158 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
161 void ExportMeshToFile(int theCommandID);
163 void SetDisplayMode(int theCommandID);
165 void SetDisplayEntity(int theCommandID);
167 void Control( int theCommandID );
171 //=============================================================
172 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
178 if ( theCommandID == 113 ) {
179 filter.append( QObject::tr( "MED files (*.med)" ) );
180 filter.append( QObject::tr( "All files (*)" ) );
182 else if ( theCommandID == 112 ) {
183 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
185 else if ( theCommandID == 111 ) {
186 filter.append( QObject::tr( "DAT files (*.dat)" ) );
189 QString anInitialPath = "";
190 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
191 anInitialPath = QDir::currentDirPath();
193 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
196 QObject::tr( "SMESH_IMPORT_MESH" ) );
197 if ( filenames.count() > 0 ) {
198 SUIT_OverrideCursor wc;
199 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
202 bool isEmpty = false;
203 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
204 QString filename = *it;
205 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
207 switch ( theCommandID ) {
210 // DAT format (currently unsupported)
211 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
212 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
218 aMeshes->length( 1 );
219 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.latin1() );
220 if ( aMeshes[0]->_is_nil() )
221 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
222 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
228 SMESH::DriverMED_ReadStatus res;
229 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.latin1(), res );
230 if ( res != SMESH::DRS_OK ) {
231 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
232 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
238 catch ( const SALOME::SALOME_Exception& S_ex ) {
239 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
240 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
243 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
244 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
246 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
247 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
248 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
249 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
250 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
258 // update Object browser
259 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
261 // show Error message box if there were errors
262 if ( errors.count() > 0 ) {
263 SUIT_MessageBox::error1( SMESHGUI::desktop(),
264 QObject::tr( "SMESH_ERROR" ),
265 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
266 QObject::tr( "SMESH_BUT_OK" ) );
269 // show warning message box, if some imported mesh is empty
271 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
272 QObject::tr( "SMESH_WRN_WARNING" ),
273 QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
274 QObject::tr( "SMESH_BUT_OK" ) );
279 void ExportMeshToFile( int theCommandID )
281 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
282 SALOME_ListIO selected;
284 aSel->selectedObjects( selected );
286 if(selected.Extent()){
287 Handle(SALOME_InteractiveObject) anIObject = selected.First();
288 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
289 if ( !aMesh->_is_nil() ) {
290 QString aFilter, aTitle = QObject::tr("Export mesh");
291 QMap<QString, SMESH::MED_VERSION> aFilterMap;
292 QMap<QString, int> aFilterMapSTL;
293 switch ( theCommandID ) {
297 if (aMesh->HasDuplicatedGroupNamesMED()) {
298 int aRet = SUIT_MessageBox::warn2
299 (SMESHGUI::desktop(),
300 QObject::tr("SMESH_WRN_WARNING"),
301 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
302 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
308 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
309 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
310 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
311 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
316 aFilter = QObject::tr("DAT files (*.dat)");
321 if (aMesh->NbPyramids()) {
322 int aRet = SUIT_MessageBox::warn2
323 (SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
326 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
331 aFilter = QObject::tr("IDEAS files (*.unv)");
339 there must be check on others mesh elements not equal triangles
341 if (aMesh->NbTriangles() < 1) {
342 SUIT_MessageBox::warn1
343 (SMESHGUI::desktop(),
344 QObject::tr("SMESH_WRN_WARNING"),
345 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
346 QObject::tr("SMESH_BUT_OK"));
349 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
350 int aRet = SUIT_MessageBox::warn2
351 (SMESHGUI::desktop(),
352 QObject::tr("SMESH_WRN_WARNING"),
353 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
354 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
360 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
361 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
369 SMESH::MED_VERSION aFormat;
370 // Init the parameter with the default value
371 bool aIsASCII_STL = true;
372 bool toCreateGroups = false;
373 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
375 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
377 QString anInitialPath = "";
378 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
379 anInitialPath = QDir::currentDirPath();
381 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
382 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
383 aFilter, aTitle, false);
384 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
386 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
387 for ( ; it != aFilterMapSTL.end(); ++it )
388 filters.push_back( it.key() );
390 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
391 fd->setCaption( aTitle );
392 fd->setFilters( filters );
393 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
394 if ( !anInitialPath.isEmpty() )
395 fd->setDir( anInitialPath );
396 fd->setSelection(anIObject->getName());
400 aFilename = fd->selectedFile();
401 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
406 else { // Export to MED
408 QString aDefaultFilter;
409 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
410 for ( ; it != aFilterMap.end(); ++it ) {
411 filters.push_back( it.key() );
412 if (it.data() == SMESH::MED_V2_2)
413 aDefaultFilter = it.key();
416 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
417 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
418 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
419 fd->setCaption( aTitle );
420 fd->setFilters( filters );
421 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
422 fd->setSelectedFilter(aDefaultFilter);
423 fd->SetChecked(toCreateGroups);
424 if ( !anInitialPath.isEmpty() )
425 fd->setDir( anInitialPath );
426 fd->setSelection(anIObject->getName());
430 aFilename = fd->selectedFile();
431 aFormat = aFilterMap[fd->selectedFilter()];
433 if ( !aFilename.isEmpty()
434 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
435 && aFormat==SMESH::MED_V2_1) {
436 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
437 QObject::tr("SMESH_WRN_WARNING"),
438 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
439 QObject::tr("SMESH_BUT_YES"),
440 QObject::tr("SMESH_BUT_NO"),
447 toCreateGroups = fd->IsChecked();
450 if ( !aFilename.isEmpty() ) {
451 // Check whether the file already exists and delete it if yes
452 QFile aFile( aFilename );
453 if ( aFile.exists() )
455 SUIT_OverrideCursor wc;
458 bool Renumber = false ;
459 // PAL 14172 : Check of we have to renumber or not from the preferences before export
461 Renumber= resMgr->booleanValue("SMESH","renumbering");
463 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
464 aMeshEditor->RenumberNodes();
465 aMeshEditor->RenumberElements();
466 if ( SMESHGUI::automaticUpdate() )
469 switch ( theCommandID ) {
472 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
476 aMesh->ExportDAT( aFilename.latin1() );
480 aMesh->ExportUNV( aFilename.latin1() );
484 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
490 catch (const SALOME::SALOME_Exception& S_ex){
492 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
493 QObject::tr("SMESH_WRN_WARNING"),
494 QObject::tr("SMESH_EXPORT_FAILED"),
495 QObject::tr("SMESH_BUT_OK"));
503 inline void InverseEntityMode(unsigned int& theOutputMode,
504 unsigned int theMode)
506 bool anIsNotPresent = ~theOutputMode & theMode;
508 theOutputMode |= theMode;
510 theOutputMode &= ~theMode;
513 void SetDisplayEntity(int theCommandID){
514 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
515 SALOME_ListIO selected;
517 aSel->selectedObjects( selected );
519 if(selected.Extent() >= 1){
520 SALOME_ListIteratorOfListIO It( selected );
521 for(; It.More(); It.Next()){
522 Handle(SALOME_InteractiveObject) IObject = It.Value();
523 if(IObject->hasEntry()){
524 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
525 unsigned int aMode = anActor->GetEntityMode();
526 switch(theCommandID){
528 InverseEntityMode(aMode,SMESH_Actor::eEdges);
531 InverseEntityMode(aMode,SMESH_Actor::eFaces);
534 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
537 aMode = SMESH_Actor::eAllEntity;
541 anActor->SetEntityMode(aMode);
549 SALOME_ListIO selected;
550 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
554 LightApp_SelectionMgr* aSel = app->selectionMgr();
555 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
556 if( !aSel || !appStudy )
559 aSel->selectedObjects( selected );
560 if( selected.IsEmpty() )
563 Handle(SALOME_InteractiveObject) anIObject = selected.First();
565 _PTR(Study) aStudy = appStudy->studyDS();
566 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
567 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
568 if( aMainObject->_is_nil() )
571 aMainObject->SetAutoColor( true );
573 QValueList<SALOMEDS::Color> aReservedColors;
575 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
576 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
578 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
579 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
581 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
582 aGroupObject->SetColor( aColor );
583 aReservedColors.append( aColor );
585 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
586 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
588 if( aGroupObject->GetType() == SMESH::NODE )
589 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
590 else if( aGroupObject->GetType() == SMESH::EDGE )
591 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
593 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
597 SMESH::RepaintCurrentView();
600 void DisableAutoColor(){
601 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
602 SALOME_ListIO selected;
604 aSel->selectedObjects( selected );
606 if(selected.Extent()){
607 Handle(SALOME_InteractiveObject) anIObject = selected.First();
608 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
609 if ( !aMesh->_is_nil() ) {
610 aMesh->SetAutoColor( false );
615 void SetDisplayMode(int theCommandID){
616 SALOME_ListIO selected;
617 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
621 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
622 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
623 if( !aSel || !appStudy )
626 _PTR(Study) aStudy = appStudy->studyDS();
628 aSel->selectedObjects( selected );
630 if(selected.Extent() >= 1){
631 switch(theCommandID){
633 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
634 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
638 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
639 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
642 SALOME_ListIteratorOfListIO It( selected );
643 for(; It.More(); It.Next()){
644 Handle(SALOME_InteractiveObject) IObject = It.Value();
645 if(IObject->hasEntry()){
646 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
647 switch(theCommandID){
649 anActor->SetRepresentation(SMESH_Actor::eEdge);
652 anActor->SetRepresentation(SMESH_Actor::eSurface);
655 if(anActor->IsShrunk())
658 anActor->SetShrink();
661 anActor->SetRepresentation(SMESH_Actor::ePoint);
664 vtkFloatingPointType color[3];
665 anActor->GetSufaceColor(color[0], color[1], color[2]);
666 int c0 = int (color[0] * 255);
667 int c1 = int (color[1] * 255);
668 int c2 = int (color[2] * 255);
669 QColor c(c0, c1, c2);
671 vtkFloatingPointType edgecolor[3];
672 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
673 c0 = int (edgecolor[0] * 255);
674 c1 = int (edgecolor[1] * 255);
675 c2 = int (edgecolor[2] * 255);
676 QColor e(c0, c1, c2);
678 vtkFloatingPointType backfacecolor[3];
679 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
680 c0 = int (backfacecolor[0] * 255);
681 c1 = int (backfacecolor[1] * 255);
682 c2 = int (backfacecolor[2] * 255);
683 QColor b(c0, c1, c2);
685 vtkFloatingPointType nodecolor[3];
686 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
687 c0 = int (nodecolor[0] * 255);
688 c1 = int (nodecolor[1] * 255);
689 c2 = int (nodecolor[2] * 255);
690 QColor n(c0, c1, c2);
692 int Edgewidth = (int)anActor->GetLineWidth();
695 int intValue = int(anActor->GetNodeSize());
696 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
698 SMESHGUI_Preferences_ColorDlg *aDlg =
699 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
700 aDlg->SetColor(1, c);
701 aDlg->SetColor(2, e);
702 aDlg->SetColor(3, n);
703 aDlg->SetColor(4, b);
704 aDlg->SetIntValue(1, Edgewidth);
705 aDlg->SetIntValue(2, intValue);
706 aDlg->SetIntValue(3, int(Shrink*100.));
708 QColor color = aDlg->GetColor(1);
709 QColor edgecolor = aDlg->GetColor(2);
710 QColor nodecolor = aDlg->GetColor(3);
711 QColor backfacecolor = aDlg->GetColor(4);
712 /* actor color and backface color */
713 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
714 vtkFloatingPointType (color.green()) / 255.,
715 vtkFloatingPointType (color.blue()) / 255.);
716 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
717 vtkFloatingPointType (backfacecolor.green()) / 255.,
718 vtkFloatingPointType (backfacecolor.blue()) / 255.);
721 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
722 vtkFloatingPointType (edgecolor.green()) / 255.,
723 vtkFloatingPointType (edgecolor.blue()) / 255.);
725 /* Shrink factor and size edges */
726 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
727 anActor->SetLineWidth(aDlg->GetIntValue(1));
729 /* Nodes color and size */
730 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
731 vtkFloatingPointType (nodecolor.green()) / 255.,
732 vtkFloatingPointType (nodecolor.blue()) / 255.);
733 anActor->SetNodeSize(aDlg->GetIntValue(2));
735 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
736 if( !aGroupObject->_is_nil() )
738 SALOMEDS::Color aColor;
739 aColor.R = (float)color.red() / 255.0;
740 aColor.G = (float)color.green() / 255.0;
741 aColor.B = (float)color.blue() / 255.0;
742 aGroupObject->SetColor( aColor );
752 SMESH::RepaintCurrentView();
756 void Control( int theCommandID )
758 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
759 SALOME_ListIO selected;
761 aSel->selectedObjects( selected );
763 if( !selected.IsEmpty() ){
764 Handle(SALOME_InteractiveObject) anIO = selected.First();
767 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
768 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
769 switch ( theCommandID ){
771 aTitle = QObject::tr( "LENGTH_EDGES" );
772 aControl = SMESH_Actor::eLength;
775 aTitle = QObject::tr( "LENGTH2D_EDGES" );
776 aControl = SMESH_Actor::eLength2D;
779 aTitle = QObject::tr( "FREE_EDGES" );
780 aControl = SMESH_Actor::eFreeEdges;
783 aTitle = QObject::tr( "FREE_BORDERS" );
784 aControl = SMESH_Actor::eFreeBorders;
787 aTitle = QObject::tr( "MULTI_BORDERS" );
788 aControl = SMESH_Actor::eMultiConnection;
791 aTitle = QObject::tr( "MULTI2D_BORDERS" );
792 aControl = SMESH_Actor::eMultiConnection2D;
795 aTitle = QObject::tr( "AREA_ELEMENTS" );
796 aControl = SMESH_Actor::eArea;
799 aTitle = QObject::tr( "TAPER_ELEMENTS" );
800 aControl = SMESH_Actor::eTaper;
803 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
804 aControl = SMESH_Actor::eAspectRatio;
807 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
808 aControl = SMESH_Actor::eAspectRatio3D;
811 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
812 aControl = SMESH_Actor::eMinimumAngle;
815 aTitle = QObject::tr( "WARP_ELEMENTS" );
816 aControl = SMESH_Actor::eWarping;
819 aTitle = QObject::tr( "SKEW_ELEMENTS" );
820 aControl = SMESH_Actor::eSkew;
823 aTitle = QObject::tr( "SMESH_VOLUME" );
824 aControl = SMESH_Actor::eVolume3D;
827 anActor->SetControlMode(aControl);
828 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
829 SMESH::RepaintCurrentView();
836 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
837 MeshObjectType theType,
838 const QString theInTypeName,
839 QString & theOutTypeName)
841 SMESH_TypeFilter aTypeFilter( theType );
843 if( !theIO.IsNull() )
845 entry = theIO->getEntry();
846 LightApp_DataOwner owner( entry );
847 if ( aTypeFilter.isOk( &owner )) {
848 theOutTypeName = theInTypeName;
856 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
858 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
859 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
861 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
862 CORBA::String_var anID = aSComp->GetID().c_str();
863 if (!strcmp(anID.in(),theIO->getEntry()))
869 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
870 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
871 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
872 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
873 CheckOIType ( theIO, GROUP, "Group", aTypeName )
881 QString CheckHomogeneousSelection()
883 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
884 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
885 SALOME_ListIO selected;
887 aSel->selectedObjects( selected );
889 QString RefType = CheckTypeObject(selected.First());
890 SALOME_ListIteratorOfListIO It(selected);
891 for (; It.More(); It.Next())
893 Handle(SALOME_InteractiveObject) IObject = It.Value();
894 QString Type = CheckTypeObject(IObject);
895 if (Type.compare(RefType) != 0)
896 return "Heterogeneous Selection";
903 void SMESHGUI::OnEditDelete()
905 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
906 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
907 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
909 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
910 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
911 _PTR(GenericAttribute) anAttr;
912 _PTR(AttributeIOR) anIOR;
915 QString aParentComponent = QString::null;
916 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
918 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
920 // check if object is not reference
921 _PTR(SObject) refobj;
922 if ( !aSO->ReferencedObject( refobj ) )
926 QString cur = anIt.Value()->getComponentDataType();
927 if( aParentComponent.isNull() )
928 aParentComponent = cur;
929 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
930 aParentComponent = "";
933 if ( objectCount == 0 )
934 return; // No Valid Objects Selected
936 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
937 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
938 QObject::tr("ERR_ERROR"),
939 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
940 QObject::tr("BUT_OK") );
943 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
944 if (SUIT_MessageBox::warn2
945 (SMESHGUI::desktop(),
946 QObject::tr("SMESH_WRN_WARNING"),
947 QObject::tr("SMESH_REALLY_DELETE"),
948 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
951 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
952 SUIT_ViewManager* vm = anApp->activeViewManager();
953 int nbSf = vm->getViewsCount();
955 SALOME_ListIteratorOfListIO It(selected);
957 aStudyBuilder->NewCommand(); // There is a transaction
958 for(; It.More(); It.Next()){ // loop on selected IO's
959 Handle(SALOME_InteractiveObject) IObject = It.Value();
960 if(IObject->hasEntry()) {
961 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
963 // disable removal of "SMESH" component object
964 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
966 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
970 _PTR(SObject) refobj;
971 if ( aSO && aSO->ReferencedObject( refobj ) )
972 continue; // skip references
974 // put the whole hierarchy of sub-objects of the selected SO into a list and
975 // then treat them all starting from the deepest objects (at list back)
977 list< _PTR(SObject) > listSO;
978 listSO.push_back( aSO );
979 list< _PTR(SObject) >::iterator itSO = listSO.begin();
980 for ( ; itSO != listSO.end(); ++itSO ) {
981 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
982 for (it->InitEx(false); it->More(); it->Next())
983 listSO.push_back( it->Value() );
986 // treat SO's in the list starting from the back
988 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
989 for ( ; ritSO != listSO.rend(); ++ritSO ) {
990 _PTR(SObject) SO = *ritSO;
992 string anEntry = SO->GetID();
994 /** Erase graphical object **/
995 if(SO->FindAttribute(anAttr, "AttributeIOR")){
996 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
997 for(int i = 0; i < nbSf; i++){
998 SUIT_ViewWindow *sf = aViews[i];
999 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1000 SMESH::RemoveActor(sf,anActor);
1005 /** Remove an object from data structures **/
1006 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1007 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1008 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1009 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1010 aMesh->RemoveGroup( aGroup );
1012 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1013 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1014 aMesh->RemoveSubMesh( aSubMesh );
1016 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1018 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1021 IObject = new SALOME_InteractiveObject
1022 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1023 QString objType = CheckTypeObject(IObject);
1024 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1025 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1026 aStudyBuilder->RemoveObjectWithChildren( SO );
1028 else {// default action: remove SObject from the study
1029 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1030 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1032 aStudyBuilder->RemoveObjectWithChildren( SO );
1036 } /* listSO back loop */
1037 } /* IObject->hasEntry() */
1039 aStudyBuilder->CommitCommand();
1041 /* Clear any previous selection */
1043 aSel->setSelectedObjects( l1 );
1045 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1050 SMESHGUI_EXPORT CAM_Module* createModule()
1052 return new SMESHGUI();
1056 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1058 //=============================================================================
1062 //=============================================================================
1063 SMESHGUI::SMESHGUI() :
1064 SalomeApp_Module( "SMESH" )
1066 if ( CORBA::is_nil( myComponentSMESH ) )
1068 CORBA::Boolean anIsEmbeddedMode;
1069 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1072 myActiveDialogBox = 0;
1073 myFilterLibraryDlg = 0;
1077 SMESH::GetFilterManager();
1078 SMESH::GetPattern();
1080 /* load resources for all available meshers */
1081 SMESH::InitAvailableHypotheses();
1084 //=============================================================================
1088 //=============================================================================
1089 SMESHGUI::~SMESHGUI()
1091 SMESH::GetFilterManager()->Destroy();
1092 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1095 //=============================================================================
1099 //=============================================================================
1100 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1102 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1104 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1109 bool SMESHGUI::automaticUpdate()
1111 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1115 return resMgr->booleanValue( "SMESH", "auto_update", false );
1118 //=============================================================================
1122 //=============================================================================
1123 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1125 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1128 //=============================================================================
1132 //=============================================================================
1133 SMESHGUI* SMESHGUI::GetSMESHGUI()
1135 SMESHGUI* smeshMod = 0;
1136 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1139 CAM_Module* module = app->module( "Mesh" );
1140 smeshMod = dynamic_cast<SMESHGUI*>( module );
1143 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1145 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1148 _PTR(Study) aStudy = study->studyDS();
1150 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1159 Standard_EXPORT SMESHGUI* GetComponentGUI()
1161 return SMESHGUI::GetSMESHGUI();
1165 //=============================================================================
1169 //=============================================================================
1170 void SMESHGUI::SetState(int aState)
1175 //=============================================================================
1179 //=============================================================================
1180 void SMESHGUI::ResetState()
1185 //=============================================================================
1189 //=============================================================================
1190 void SMESHGUI::EmitSignalDeactivateDialog()
1192 emit SignalDeactivateActiveDialog();
1195 //=============================================================================
1199 //=============================================================================
1200 void SMESHGUI::EmitSignalStudyFrameChanged()
1202 emit SignalStudyFrameChanged();
1205 //=============================================================================
1209 //=============================================================================
1210 void SMESHGUI::EmitSignalCloseAllDialogs()
1212 emit SignalCloseAllDialogs();
1215 //=============================================================================
1219 //=============================================================================
1220 QDialog *SMESHGUI::GetActiveDialogBox()
1222 return myActiveDialogBox;
1225 //=============================================================================
1229 //=============================================================================
1230 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1232 myActiveDialogBox = (QDialog *) aDlg;
1236 //=============================================================================
1240 //=============================================================================
1241 SUIT_Desktop* SMESHGUI::desktop()
1243 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1245 return app->desktop();
1250 //=============================================================================
1254 //=============================================================================
1255 SalomeApp_Study* SMESHGUI::activeStudy()
1257 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1259 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1264 //=============================================================================
1268 //=============================================================================
1269 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1271 /* Here the position is on the bottom right corner - 10 */
1272 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1274 SUIT_Desktop *PP = desktop();
1275 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1276 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1280 //=============================================================================
1284 //=============================================================================
1285 static int isStudyLocked(_PTR(Study) theStudy){
1286 return theStudy->GetProperties()->IsLocked();
1289 static bool checkLock(_PTR(Study) theStudy) {
1290 if (isStudyLocked(theStudy)) {
1291 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1292 QObject::tr("WRN_WARNING"),
1293 QObject::tr("WRN_STUDY_LOCKED"),
1294 QObject::tr("BUT_OK") );
1300 //=======================================================================
1301 //function : CheckActiveStudyLocked
1303 //=======================================================================
1305 bool SMESHGUI::isActiveStudyLocked()
1307 _PTR(Study) aStudy = activeStudy()->studyDS();
1308 return checkLock( aStudy );
1311 //=============================================================================
1315 //=============================================================================
1316 bool SMESHGUI::OnGUIEvent( int theCommandID )
1318 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1322 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1323 SUIT_ResourceMgr* mgr = resourceMgr();
1327 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1328 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1331 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1332 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1334 //QAction* act = action( theCommandID );
1336 switch (theCommandID) {
1338 if(checkLock(aStudy)) break;
1346 if(checkLock(aStudy)) break;
1347 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1351 case 150: //MED FILE INFORMATION
1353 SALOME_ListIO selected;
1354 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1356 aSel->selectedObjects( selected );
1357 if( selected.Extent() )
1359 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1360 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1361 if ( !aMesh->_is_nil() )
1363 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1369 case 122: // EXPORT MED
1378 ::ExportMeshToFile(theCommandID);
1382 case 200: // SCALAR BAR
1384 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1385 SALOME_ListIO selected;
1387 aSel->selectedObjects( selected );
1389 if( selected.Extent() ) {
1390 Handle(SALOME_InteractiveObject) anIO = selected.First();
1391 if( anIO->hasEntry() ) {
1392 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1393 anActor->SetControlMode( SMESH_Actor::eNone );
1401 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1411 ::DisableAutoColor();
1414 case 1134: // Clipping
1415 case 1133: // Tranparency
1416 case 1132: // Colors / Size
1423 ::SetDisplayMode(theCommandID);
1429 case 219: // Volumes
1430 case 220: // All Entity
1431 ::SetDisplayEntity(theCommandID);
1436 if(checkLock(aStudy)) break;
1438 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1441 SMESH::UpdateView();
1443 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1444 SMESH::OnVisuException();
1446 catch (...) { // PAL16774 (Crash after display of many groups)
1447 SMESH::OnVisuException();
1451 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1452 aSel->selectedObjects( l );
1453 aSel->setSelectedObjects( l );
1458 case 301: // DISPLAY
1459 case 302: // DISPLAY ONLY
1461 SMESH::EDisplaing anAction;
1462 switch (theCommandID) {
1463 case 300: anAction = SMESH::eErase; break;
1464 case 301: anAction = SMESH::eDisplay; break;
1465 case 302: anAction = SMESH::eDisplayOnly; break;
1468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1469 SALOME_ListIO sel_objects, to_process;
1471 aSel->selectedObjects( sel_objects );
1473 if( theCommandID==302 )
1474 startOperation( myEraseAll );
1476 extractContainers( sel_objects, to_process );
1479 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1483 SALOME_ListIteratorOfListIO It( to_process );
1484 for (; It.More(); It.Next()) {
1485 Handle(SALOME_InteractiveObject) IOS = It.Value();
1486 if (IOS->hasEntry()) {
1487 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1488 break; // PAL16774 (Crash after display of many groups)
1489 if (anAction == SMESH::eDisplayOnly)
1490 anAction = SMESH::eDisplay;
1495 // PAL13338 + PAL15161 -->
1496 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1497 SMESH::UpdateView();
1498 // PAL13338 + PAL15161 <--
1500 catch (...) { // PAL16774 (Crash after display of many groups)
1501 SMESH::OnVisuException();
1504 if (anAction == SMESH::eErase) {
1506 aSel->setSelectedObjects( l1 );
1509 aSel->setSelectedObjects( to_process );
1516 if(checkLock(aStudy)) break;
1519 EmitSignalDeactivateDialog();
1521 new SMESHGUI_NodesDlg(this);
1524 SUIT_MessageBox::warn1(desktop(),
1525 tr("SMESH_WRN_WARNING"),
1526 tr("SMESH_WRN_VIEWER_VTK"),
1527 tr("SMESH_BUT_OK"));
1532 case 2151: // FILTER
1536 EmitSignalDeactivateDialog();
1537 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1542 case 406: // MOVE NODE
1546 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1547 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1551 if(checkLock(aStudy)) break;
1552 new SMESHGUI_MoveNodesDlg(this);
1556 case 701: // COMPUTE MESH
1558 if (checkLock(aStudy)) break;
1560 startOperation( 701 );
1564 case 702: // Create mesh
1565 startOperation( 702 );
1567 case 703: // Create sub-mesh
1568 startOperation( 703 );
1570 case 704: // Edit mesh/sub-mesh
1571 startOperation( 704 );
1573 case 710: // Build compound mesh
1575 if (checkLock(aStudy)) break;
1576 EmitSignalDeactivateDialog();
1577 new SMESHGUI_BuildCompoundDlg( this );
1581 case 407: // DIAGONAL INVERSION
1582 case 408: // Delete diagonal
1586 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1587 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1591 if ( checkLock( aStudy ) )
1594 /*Standard_Boolean aRes;
1595 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1596 if ( aMesh->_is_nil() )
1598 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1599 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1603 EmitSignalDeactivateDialog();
1604 if ( theCommandID == 407 )
1605 new SMESHGUI_TrianglesInversionDlg(this);
1607 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1610 case 409: // Change orientation
1611 case 410: // Union of triangles
1612 case 411: // Cutting of quadrangles
1616 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1617 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1621 if ( checkLock( aStudy ) )
1624 EmitSignalDeactivateDialog();
1625 SMESHGUI_MultiEditDlg* aDlg = NULL;
1626 if ( theCommandID == 409 )
1627 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1628 else if ( theCommandID == 410 )
1629 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1631 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1636 case 412: // Smoothing
1638 if(checkLock(aStudy)) break;
1640 EmitSignalDeactivateDialog();
1641 new SMESHGUI_SmoothingDlg( this );
1644 SUIT_MessageBox::warn1(desktop(),
1645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1646 tr("SMESH_BUT_OK"));
1650 case 413: // Extrusion
1652 if (checkLock(aStudy)) break;
1654 EmitSignalDeactivateDialog();
1655 new SMESHGUI_ExtrusionDlg ( this );
1657 SUIT_MessageBox::warn1(desktop(),
1658 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1659 tr("SMESH_BUT_OK"));
1663 case 414: // Revolution
1665 if(checkLock(aStudy)) break;
1667 EmitSignalDeactivateDialog();
1668 new SMESHGUI_RevolutionDlg( this );
1671 SUIT_MessageBox::warn1(desktop(),
1672 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1673 tr("SMESH_BUT_OK"));
1677 case 415: // Pattern mapping
1679 if ( checkLock( aStudy ) )
1683 EmitSignalDeactivateDialog();
1684 new SMESHGUI_MeshPatternDlg( this );
1687 SUIT_MessageBox::warn1(desktop(),
1688 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1689 tr("SMESH_BUT_OK"));
1693 case 416: // Extrusion along a path
1695 if (checkLock(aStudy)) break;
1697 EmitSignalDeactivateDialog();
1698 new SMESHGUI_ExtrusionAlongPathDlg( this );
1700 SUIT_MessageBox::warn1(desktop(),
1701 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1702 tr("SMESH_BUT_OK"));
1706 case 417: // Convert mesh to quadratic
1708 startOperation( 417 );
1709 /* if (checkLock(aStudy)) break;
1711 EmitSignalDeactivateDialog();
1712 new SMESHGUI_ConvToQuadDlg();
1714 SUIT_MessageBox::warn1(desktop(),
1715 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1716 tr("SMESH_BUT_OK"));
1720 case 801: // CREATE GROUP
1724 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1725 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1729 if(checkLock(aStudy)) break;
1730 EmitSignalDeactivateDialog();
1731 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1733 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1734 SALOME_ListIO selected;
1736 aSel->selectedObjects( selected );
1738 int nbSel = selected.Extent();
1740 // check if mesh is selected
1741 aMesh = SMESH::GetMeshByIO( selected.First() );
1743 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1748 case 802: // CONSTRUCT GROUP
1752 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1753 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1757 if(checkLock(aStudy)) break;
1758 EmitSignalDeactivateDialog();
1760 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1761 SALOME_ListIO selected;
1763 aSel->selectedObjects( selected );
1765 int nbSel = selected.Extent();
1767 // check if submesh is selected
1768 Handle(SALOME_InteractiveObject) IObject = selected.First();
1769 if (IObject->hasEntry()) {
1770 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1772 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1773 if (!aSubMesh->_is_nil()) {
1775 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1776 // get submesh elements list by types
1777 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1778 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1779 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1780 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1781 // create group for each type o elements
1782 QString aName = IObject->getName();
1783 if (aNodes->length() > 0) {
1784 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1785 aGroup->Add(aNodes.inout());
1787 if (aEdges->length() > 0) {
1788 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1789 aGroup->Add(aEdges.inout());
1791 if (aFaces->length() > 0) {
1792 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1793 aGroup->Add(aFaces.inout());
1795 if (aVolumes->length() > 0) {
1796 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1797 aGroup->Add(aVolumes.inout());
1802 catch(const SALOME::SALOME_Exception & S_ex){
1803 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1810 SUIT_MessageBox::warn1(desktop(),
1811 tr("SMESH_WRN_WARNING"),
1812 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1813 tr("SMESH_BUT_OK"));
1818 case 803: // EDIT GROUP
1822 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1823 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1827 if(checkLock(aStudy)) break;
1828 EmitSignalDeactivateDialog();
1830 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1831 SALOME_ListIO selected;
1833 aSel->selectedObjects( selected );
1835 SALOME_ListIteratorOfListIO It (selected);
1836 int nbSelectedGroups = 0;
1837 for ( ; It.More(); It.Next() )
1839 SMESH::SMESH_GroupBase_var aGroup =
1840 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1841 if (!aGroup->_is_nil()) {
1843 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1847 if (nbSelectedGroups == 0)
1849 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1855 case 804: // Add elements to group
1857 if(checkLock(aStudy)) break;
1858 if (myState == 800) {
1859 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1860 if (aDlg) aDlg->onAdd();
1865 case 805: // Remove elements from group
1867 if(checkLock(aStudy)) break;
1868 if (myState == 800) {
1869 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1870 if (aDlg) aDlg->onRemove();
1875 case 810: // Union Groups
1876 case 811: // Intersect groups
1877 case 812: // Cut groups
1881 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1882 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1886 if ( checkLock( aStudy ) )
1889 EmitSignalDeactivateDialog();
1892 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1893 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1894 else aMode = SMESHGUI_GroupOpDlg::CUT;
1896 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1900 case 813: // Delete groups with their contents
1904 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1905 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1909 if ( checkLock( aStudy ) )
1912 EmitSignalDeactivateDialog();
1914 new SMESHGUI_DeleteGroupDlg( this );
1918 case 900: // MESH INFOS
1920 EmitSignalDeactivateDialog();
1921 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1922 SALOME_ListIO selected;
1924 aSel->selectedObjects( selected );
1926 if ( selected.Extent() > 1 ) { // a dlg for each IO
1928 SALOME_ListIteratorOfListIO It (selected);
1929 for ( ; It.More(); It.Next() ) {
1930 IOs.Clear(); IOs.Append( It.Value() );
1931 aSel->setSelectedObjects( IOs );
1932 new SMESHGUI_MeshInfosDlg(this, "", false);
1934 // restore selection
1935 aSel->setSelectedObjects( selected );
1938 new SMESHGUI_MeshInfosDlg(this, "", false);
1942 case 902: // STANDARD 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() ) {
1955 IOs.Append( It.Value() );
1956 aSel->setSelectedObjects( IOs );
1957 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1959 // restore selection
1960 aSel->setSelectedObjects( selected );
1963 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1967 case 903: // WHAT IS
1969 EmitSignalDeactivateDialog();
1970 new SMESHGUI_WhatIsDlg( this, "", false);
1974 case 1100: // EDIT HYPOTHESIS
1976 if(checkLock(aStudy)) break;
1978 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1979 SALOME_ListIO selected;
1981 aSel->selectedObjects( selected );
1983 int nbSel = selected.Extent();
1986 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1987 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1989 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1990 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1991 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1992 if ( !aHypothesis->_is_nil() )
1994 CORBA::String_var aHypType = aHypothesis->GetName();
1995 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1997 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2004 updateObjBrowser( true );
2008 case 1101: // RENAME
2010 if ( checkLock( aStudy ) )
2013 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2014 SALOME_ListIO selected;
2016 aSel->selectedObjects( selected );
2018 bool isAny = false; // iss there any appropriate object selected
2020 SALOME_ListIteratorOfListIO It( selected );
2021 for ( ; It.More(); It.Next() )
2023 Handle(SALOME_InteractiveObject) IObject = It.Value();
2024 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2025 _PTR(GenericAttribute) anAttr;
2026 _PTR(AttributeName) aName;
2029 if ( obj->FindAttribute(anAttr, "AttributeName") )
2032 QString newName = QString(aName->Value().c_str());
2034 // check type to prevent renaming of inappropriate objects
2035 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2036 if (aType == MESH || aType == GROUP ||
2037 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2038 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2039 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2040 aType == HYPOTHESIS || aType == ALGORITHM)
2043 newName = LightApp_NameDlg::getName(desktop(), newName);
2044 if ( !newName.isEmpty() )
2046 //old source: aStudy->renameIObject( IObject, newName );
2047 aName->SetValue( newName.latin1() );
2049 // if current object is group update group's name
2050 SMESH::SMESH_GroupBase_var aGroup =
2051 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2052 if (!aGroup->_is_nil() )
2053 aGroup->SetName( newName.latin1() );
2063 SUIT_MessageBox::warn1(desktop(),
2064 QObject::tr("SMESH_WRN_WARNING"),
2065 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2066 QObject::tr("SMESH_BUT_OK"));
2071 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2073 if(checkLock(aStudy)) break;
2074 SUIT_OverrideCursor wc;
2076 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2077 SALOME_ListIO selected;
2079 aSel->selectedObjects( selected, QString::null, false );
2081 SALOME_ListIteratorOfListIO It(selected);
2082 for (int i = 0; It.More(); It.Next(), i++) {
2083 Handle(SALOME_InteractiveObject) IObject = It.Value();
2084 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2087 aSel->setSelectedObjects( l1 );
2092 case 401: // GEOM::EDGE
2093 case 4021: // TRIANGLE
2095 case 4023: // POLYGON
2099 if(checkLock(aStudy)) break;
2101 EmitSignalDeactivateDialog();
2102 SMDSAbs_ElementType type = SMDSAbs_Edge;
2104 switch (theCommandID) {
2105 case 4021: // TRIANGLE
2106 type = SMDSAbs_Face; nbNodes = 3; break;
2108 type = SMDSAbs_Face; nbNodes = 4; break;
2110 type = SMDSAbs_Volume; nbNodes = 4; break;
2111 case 4023: // POLYGON
2112 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2114 type = SMDSAbs_Volume; nbNodes = 8; break;
2115 case 4033: // POLYHEDRE
2116 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2119 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2122 SUIT_MessageBox::warn1(desktop(),
2123 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2124 tr("SMESH_BUT_OK"));
2128 case 4033: // POLYHEDRON
2130 if(checkLock(aStudy)) break;
2132 EmitSignalDeactivateDialog();
2133 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2136 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2137 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2138 tr("SMESH_BUT_OK"));
2142 case 4034: // QUADRATIC EDGE
2143 case 4035: // QUADRATIC TRIANGLE
2144 case 4036: // QUADRATIC QUADRANGLE
2145 case 4037: // QUADRATIC TETRAHEDRON
2146 case 4038: // QUADRATIC PYRAMID
2147 case 4039: // QUADRATIC PENTAHEDRON
2148 case 4040: // QUADRATIC HEXAHEDRON
2150 if(checkLock(aStudy)) break;
2152 EmitSignalDeactivateDialog();
2155 switch (theCommandID) {
2157 type = QUAD_EDGE; break;
2159 type = QUAD_TRIANGLE; break;
2161 type = QUAD_QUADRANGLE; break;
2163 type = QUAD_TETRAHEDRON; break;
2165 type = QUAD_PYRAMID; break;
2167 type = QUAD_PENTAHEDRON; break;
2169 type = QUAD_HEXAHEDRON;
2173 new SMESHGUI_AddQuadraticElementDlg( this, type );
2176 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2177 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2178 tr("SMESH_BUT_OK"));
2182 case 4041: // REMOVES NODES
2184 if(checkLock(aStudy)) break;
2186 EmitSignalDeactivateDialog();
2187 new SMESHGUI_RemoveNodesDlg(this);
2190 SUIT_MessageBox::warn1(desktop(),
2191 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2192 tr("SMESH_BUT_OK"));
2196 case 4042: // REMOVES ELEMENTS
2198 if(checkLock(aStudy)) break;
2200 EmitSignalDeactivateDialog();
2201 new SMESHGUI_RemoveElementsDlg(this);
2205 SUIT_MessageBox::warn1(desktop(),
2206 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2207 tr("SMESH_BUT_OK"));
2211 case 4043: { // CLEAR_MESH
2213 if(checkLock(aStudy)) break;
2215 SALOME_ListIO selected;
2216 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2217 aSel->selectedObjects( selected );
2219 SUIT_OverrideCursor wc;
2220 SALOME_ListIteratorOfListIO It (selected);
2221 for ( ; It.More(); It.Next() )
2223 Handle(SALOME_InteractiveObject) IOS = It.Value();
2224 SMESH::SMESH_Mesh_var aMesh =
2225 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2226 if ( aMesh->_is_nil()) continue;
2228 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2230 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2231 SMESH::ModifiedMesh( aMeshSObj, false, true);
2232 // hide groups and submeshes
2233 _PTR(ChildIterator) anIter =
2234 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2235 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2237 _PTR(SObject) so = anIter->Value();
2238 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2241 catch (const SALOME::SALOME_Exception& S_ex){
2243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2247 SMESH::UpdateView();
2251 case 4051: // RENUMBERING NODES
2253 if(checkLock(aStudy)) break;
2255 EmitSignalDeactivateDialog();
2256 new SMESHGUI_RenumberingDlg( this, "", 0);
2260 SUIT_MessageBox::warn1(desktop(),
2261 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2262 tr("SMESH_BUT_OK"));
2266 case 4052: // RENUMBERING ELEMENTS
2268 if(checkLock(aStudy)) break;
2270 EmitSignalDeactivateDialog();
2271 new SMESHGUI_RenumberingDlg( this, "", 1);
2275 SUIT_MessageBox::warn1(desktop(),
2276 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2277 tr("SMESH_BUT_OK"));
2281 case 4061: // TRANSLATION
2283 if(checkLock(aStudy)) break;
2285 EmitSignalDeactivateDialog();
2286 new SMESHGUI_TranslationDlg( this );
2289 SUIT_MessageBox::warn1(desktop(),
2290 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2291 tr("SMESH_BUT_OK"));
2295 case 4062: // ROTATION
2297 if(checkLock(aStudy)) break;
2299 EmitSignalDeactivateDialog();
2300 new SMESHGUI_RotationDlg( this );
2303 SUIT_MessageBox::warn1(desktop(),
2304 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2305 tr("SMESH_BUT_OK"));
2309 case 4063: // SYMMETRY
2311 if(checkLock(aStudy)) break;
2313 EmitSignalDeactivateDialog();
2314 new SMESHGUI_SymmetryDlg( this );
2317 SUIT_MessageBox::warn1(desktop(),
2318 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2319 tr("SMESH_BUT_OK"));
2323 case 4064: // SEWING
2325 if(checkLock(aStudy)) break;
2327 EmitSignalDeactivateDialog();
2328 new SMESHGUI_SewingDlg( this );
2331 SUIT_MessageBox::warn1(desktop(),
2332 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2333 tr("SMESH_BUT_OK"));
2337 case 4065: // MERGE NODES
2339 if(checkLock(aStudy)) break;
2341 EmitSignalDeactivateDialog();
2342 new SMESHGUI_EditMeshDlg( this, 0 );
2345 SUIT_MessageBox::warn1(desktop(),
2346 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2347 tr("SMESH_BUT_OK"));
2351 case 4066: // MERGE EQUAL ELEMENTS
2353 if (checkLock(aStudy)) break;
2355 EmitSignalDeactivateDialog();
2356 new SMESHGUI_EditMeshDlg( this, 1 );
2358 SUIT_MessageBox::warn1(desktop(),
2359 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2360 tr("SMESH_BUT_OK"));
2365 case 4067: // MAKE MESH PASS THROUGH POINT
2366 startOperation( 4067 );
2369 case 5105: // Library of selection filters
2371 static QValueList<int> aTypes;
2372 if ( aTypes.isEmpty() )
2374 aTypes.append( SMESH::NODE );
2375 aTypes.append( SMESH::EDGE );
2376 aTypes.append( SMESH::FACE );
2377 aTypes.append( SMESH::VOLUME );
2379 if (!myFilterLibraryDlg)
2380 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2381 else if (myFilterLibraryDlg->isHidden())
2382 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2383 myFilterLibraryDlg->raise();
2387 case 6017: // CONTROLS
2403 LightApp_SelectionMgr* mgr = selectionMgr();
2404 SALOME_ListIO selected; mgr->selectedObjects( selected );
2406 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2407 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2409 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2410 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2411 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2412 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2413 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2414 ::Control( theCommandID );
2419 SUIT_MessageBox::warn1(desktop(),
2420 tr( "SMESH_WRN_WARNING" ),
2421 tr( "SMESH_BAD_SELECTION" ),
2422 tr( "SMESH_BUT_OK" ) );
2426 SUIT_MessageBox::warn1(desktop(),
2427 tr( "SMESH_WRN_WARNING" ),
2428 tr( "NOT_A_VTK_VIEWER" ),
2429 tr( "SMESH_BUT_OK" ) );
2434 LightApp_SelectionMgr* mgr = selectionMgr();
2435 SALOME_ListIO selected; mgr->selectedObjects( selected );
2437 SALOME_ListIteratorOfListIO it(selected);
2438 for(; it.More(); it.Next()) {
2439 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2440 if(anIObject->hasEntry()) {
2441 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2442 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2450 LightApp_SelectionMgr* mgr = selectionMgr();
2451 SALOME_ListIO selected; mgr->selectedObjects( selected );
2453 if (selected.Extent() == 1) {
2454 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2455 if(anIObject->hasEntry())
2456 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2457 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2464 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2465 //updateObjBrowser();
2469 //=============================================================================
2473 //=============================================================================
2474 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2479 //=============================================================================
2483 //=============================================================================
2484 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2489 //=============================================================================
2493 //=============================================================================
2494 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2499 //=============================================================================
2500 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2501 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2503 //=============================================================================
2504 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2505 SUIT_ViewWindow* wnd )
2507 if(theIO->hasEntry()){
2508 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2509 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2513 //=======================================================================
2514 // function : createSMESHAction
2516 //=======================================================================
2517 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2520 QWidget* parent = application()->desktop();
2521 SUIT_ResourceMgr* resMgr = resourceMgr();
2523 if ( icon_id.length() )
2524 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2526 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2527 if ( !pix.isNull() )
2528 icon = QIconSet( pix );
2530 QString tooltip = tr( QString( "TOP_" )+po_id ),
2531 menu = tr( QString( "MEN_" )+po_id ),
2532 status_bar = tr( QString( "STB_" )+po_id );
2534 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2537 //=======================================================================
2538 // function : createPopupItem
2540 //=======================================================================
2541 void SMESHGUI::createPopupItem( const int id,
2542 const QString& clients,
2543 const QString& types,
2544 const QString& theRule,
2549 parentId = popupMgr()->actionId( action( pId ) );
2551 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2552 popupMgr()->insert( action( id ), parentId, 0 );
2554 QChar lc = QtxPopupMgr::Selection::defEquality();
2555 QString rule = "(%1) and (%2) and (%3)";
2556 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2557 if( clients.isEmpty() )
2558 rule = rule.arg( QString( "true" ) );
2560 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2561 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2564 bool cont = myRules.contains( id );
2566 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2568 popupMgr()->setRule( action( id ), rule, true );
2569 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2572 //=======================================================================
2573 // function : initialize
2575 //=======================================================================
2576 void SMESHGUI::initialize( CAM_Application* app )
2578 SalomeApp_Module::initialize( app );
2580 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2582 /* Automatic Update flag */
2583 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2585 // ----- create actions --------------
2587 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2588 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2589 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2590 createSMESHAction( 114, "NUM" );
2591 createSMESHAction( 121, "DAT" );
2592 createSMESHAction( 122, "MED" );
2593 createSMESHAction( 123, "UNV" );
2594 createSMESHAction( 140, "STL" );
2595 createSMESHAction( 124, "EXPORT_DAT" );
2596 createSMESHAction( 125, "EXPORT_MED" );
2597 createSMESHAction( 126, "EXPORT_UNV" );
2598 createSMESHAction( 141, "EXPORT_STL" );
2599 createSMESHAction( 150, "FILE_INFO" );
2600 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2601 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2602 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2603 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2604 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2605 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2606 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2607 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2608 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2609 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2610 createSMESHAction( 804, "ADD" );
2611 createSMESHAction( 805, "REMOVE" );
2612 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2613 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2614 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2615 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2616 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2617 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2618 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2619 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2620 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2621 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2622 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2623 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2624 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2625 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2626 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2627 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2628 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2629 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2630 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2631 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2632 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2633 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2634 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2635 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2636 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2637 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2638 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2639 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2640 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2641 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2642 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2643 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2644 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2645 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2646 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2647 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2648 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2649 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2650 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2651 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2652 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2653 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2654 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2655 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2656 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2657 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2658 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2659 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2660 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2661 createSMESHAction( 415, "MAP", "ICON_MAP" );
2662 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2663 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2664 createSMESHAction( 200, "RESET" );
2665 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2666 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2667 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2668 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2669 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2670 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2671 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2672 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2673 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2674 createSMESHAction( 220, "ALL" );
2675 createSMESHAction( 1100, "EDIT_HYPO" );
2676 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2677 createSMESHAction( 1102, "UNASSIGN" );
2678 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2679 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2680 createSMESHAction( 1131, "DISPMODE" );
2681 createSMESHAction( 1132, "COLORS" );
2682 createSMESHAction( 1133, "TRANSP" );
2683 createSMESHAction( 1134, "CLIP" );
2684 createSMESHAction( 1135, "DISP_ENT" );
2685 createSMESHAction( 1136, "AUTO_COLOR" );
2686 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2687 createSMESHAction( 2000, "CTRL" );
2689 createSMESHAction( 300, "ERASE" );
2690 createSMESHAction( 301, "DISPLAY" );
2691 createSMESHAction( 302, "DISPLAY_ONLY" );
2692 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2693 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2694 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2695 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2696 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2697 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2698 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2699 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2701 // ----- create menu --------------
2702 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2703 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2704 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2705 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2706 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2707 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2708 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2710 createMenu( separator(), fileId );
2712 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2713 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2714 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2715 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2716 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2717 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2719 createMenu( 111, importId, -1 );
2720 createMenu( 112, importId, -1 );
2721 createMenu( 113, importId, -1 );
2723 createMenu( 121, exportId, -1 );
2724 createMenu( 122, exportId, -1 );
2725 createMenu( 123, exportId, -1 );
2726 createMenu( 140, exportId, -1 ); // export to stl STL
2728 createMenu( separator(), fileId, 10 );
2730 createMenu( 33, editId, -1 );
2732 createMenu( 5105, toolsId, -1 );
2734 createMenu( 702, meshId, -1 ); // "Mesh" menu
2735 createMenu( 703, meshId, -1 );
2736 createMenu( 704, meshId, -1 );
2737 createMenu( 710, meshId, -1 );
2738 createMenu( separator(), meshId, -1 );
2739 createMenu( 701, meshId, -1 );
2740 createMenu( separator(), meshId, -1 );
2741 createMenu( 801, meshId, -1 );
2742 createMenu( 802, meshId, -1 );
2743 createMenu( 803, meshId, -1 );
2744 createMenu( separator(), meshId, -1 );
2745 createMenu( 810, meshId, -1 );
2746 createMenu( 811, meshId, -1 );
2747 createMenu( 812, meshId, -1 );
2748 createMenu( separator(), meshId, -1 );
2749 createMenu( 813, meshId, -1 );
2750 createMenu( separator(), meshId, -1 );
2751 createMenu( 900, meshId, -1 );
2752 createMenu( 902, meshId, -1 );
2753 createMenu( 903, meshId, -1 );
2754 createMenu( separator(), meshId, -1 );
2756 createMenu( 6003, ctrlId, -1 );
2757 createMenu( 6001, ctrlId, -1 );
2758 createMenu( 6004, ctrlId, -1 );
2759 createMenu( separator(), ctrlId, -1 );
2760 createMenu( 6002, ctrlId, -1 );
2761 createMenu( 6018, ctrlId, -1 );
2762 createMenu( 6019, ctrlId, -1 );
2763 createMenu( 6011, ctrlId, -1 );
2764 createMenu( 6012, ctrlId, -1 );
2765 createMenu( 6013, ctrlId, -1 );
2766 createMenu( 6014, ctrlId, -1 );
2767 createMenu( 6015, ctrlId, -1 );
2768 createMenu( 6016, ctrlId, -1 );
2769 createMenu( separator(), ctrlId, -1 );
2770 createMenu( 6017, ctrlId, -1 );
2771 createMenu( 6009, ctrlId, -1 );
2772 createMenu( separator(), ctrlId, -1 );
2774 createMenu( 400, addId, -1 );
2775 createMenu( 401, addId, -1 );
2776 createMenu( 4021, addId, -1 );
2777 createMenu( 4022, addId, -1 );
2778 createMenu( 4023, addId, -1 );
2779 createMenu( 4031, addId, -1 );
2780 createMenu( 4032, addId, -1 );
2781 createMenu( 4033, addId, -1 );
2782 createMenu( separator(), addId, -1 );
2783 createMenu( 4034, addId, -1 );
2784 createMenu( 4035, addId, -1 );
2785 createMenu( 4036, addId, -1 );
2786 createMenu( 4037, addId, -1 );
2787 createMenu( 4038, addId, -1 );
2788 createMenu( 4039, addId, -1 );
2789 createMenu( 4040, addId, -1 );
2791 createMenu( 4041, removeId, -1 );
2792 createMenu( 4042, removeId, -1 );
2793 createMenu( 4043, removeId, -1 );
2795 createMenu( 4051, renumId, -1 );
2796 createMenu( 4052, renumId, -1 );
2798 createMenu( 4061, transfId, -1 );
2799 createMenu( 4062, transfId, -1 );
2800 createMenu( 4063, transfId, -1 );
2801 createMenu( 4064, transfId, -1 );
2802 createMenu( 4065, transfId, -1 );
2803 createMenu( 4066, transfId, -1 );
2805 createMenu( 406, modifyId, -1 );
2806 createMenu( 4067,modifyId, -1 );
2807 createMenu( 407, modifyId, -1 );
2808 createMenu( 408, modifyId, -1 );
2809 createMenu( 409, modifyId, -1 );
2810 createMenu( 410, modifyId, -1 );
2811 createMenu( 411, modifyId, -1 );
2812 createMenu( 412, modifyId, -1 );
2813 createMenu( 413, modifyId, -1 );
2814 createMenu( 416, modifyId, -1 );
2815 createMenu( 414, modifyId, -1 );
2816 createMenu( 415, modifyId, -1 );
2817 createMenu( 417, modifyId, -1 );
2819 createMenu( 214, viewId, -1 );
2821 // ----- create toolbars --------------
2822 int meshTb = createTool( tr( "TB_MESH" ) ),
2823 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2824 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2825 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2826 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2828 createTool( 702, meshTb );
2829 createTool( 703, meshTb );
2830 createTool( 704, meshTb );
2831 createTool( 710, meshTb );
2832 createTool( separator(), meshTb );
2833 createTool( 701, meshTb );
2834 createTool( separator(), meshTb );
2835 createTool( 801, meshTb );
2836 createTool( 802, meshTb );
2837 createTool( 803, meshTb );
2838 createTool( separator(), meshTb );
2839 createTool( 900, meshTb );
2840 createTool( 902, meshTb );
2841 createTool( 903, meshTb );
2842 createTool( separator(), meshTb );
2844 createTool( 6001, ctrlTb );
2845 createTool( 6003, ctrlTb );
2846 createTool( 6004, ctrlTb );
2847 createTool( separator(), ctrlTb );
2848 createTool( 6002, ctrlTb );
2849 createTool( 6018, ctrlTb );
2850 createTool( 6019, ctrlTb );
2851 createTool( 6011, ctrlTb );
2852 createTool( 6012, ctrlTb );
2853 createTool( 6013, ctrlTb );
2854 createTool( 6014, ctrlTb );
2855 createTool( 6015, ctrlTb );
2856 createTool( 6016, ctrlTb );
2857 createTool( separator(), ctrlTb );
2858 createTool( 6017, ctrlTb );
2859 createTool( 6009, ctrlTb );
2860 createTool( separator(), ctrlTb );
2862 createTool( 400, addRemTb );
2863 createTool( 401, addRemTb );
2864 createTool( 4021, addRemTb );
2865 createTool( 4022, addRemTb );
2866 createTool( 4023, addRemTb );
2867 createTool( 4031, addRemTb );
2868 createTool( 4032, addRemTb );
2869 createTool( 4033, addRemTb );
2870 createTool( separator(), addRemTb );
2871 createTool( 4034, addRemTb );
2872 createTool( 4035, addRemTb );
2873 createTool( 4036, addRemTb );
2874 createTool( 4037, addRemTb );
2875 createTool( 4038, addRemTb );
2876 createTool( 4039, addRemTb );
2877 createTool( 4040, addRemTb );
2878 createTool( separator(), addRemTb );
2879 createTool( 4041, addRemTb );
2880 createTool( 4042, addRemTb );
2881 createTool( 4043, addRemTb );
2882 createTool( separator(), addRemTb );
2883 createTool( 4051, addRemTb );
2884 createTool( 4052, addRemTb );
2885 createTool( separator(), addRemTb );
2886 createTool( 4061, addRemTb );
2887 createTool( 4062, addRemTb );
2888 createTool( 4063, addRemTb );
2889 createTool( 4064, addRemTb );
2890 createTool( 4065, addRemTb );
2891 createTool( 4066, addRemTb );
2892 createTool( separator(), addRemTb );
2894 createTool( 406, modifyTb );
2895 createTool( 4067,modifyTb );
2896 createTool( 407, modifyTb );
2897 createTool( 408, modifyTb );
2898 createTool( 409, modifyTb );
2899 createTool( 410, modifyTb );
2900 createTool( 411, modifyTb );
2901 createTool( 412, modifyTb );
2902 createTool( 413, modifyTb );
2903 createTool( 416, modifyTb );
2904 createTool( 414, modifyTb );
2905 createTool( 415, modifyTb );
2906 createTool( 417, modifyTb );
2908 createTool( 214, dispModeTb );
2912 QString OB = "'ObjectBrowser'",
2913 View = "'" + SVTK_Viewer::Type() + "'",
2915 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2916 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2917 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2918 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2919 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2920 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2921 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2922 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2923 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2924 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2925 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2927 mesh_group = mesh + " " + subMesh + " " + group,
2928 hyp_alg = hypo + " " + algo;
2930 // popup for object browser
2932 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2934 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2935 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2936 createPopupItem( 803, OB, group ); // EDIT_GROUP
2937 popupMgr()->insert( separator(), -1, 0 );
2938 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2939 createPopupItem( 214, OB, mesh_group ); // UPDATE
2940 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2941 createPopupItem( 902, OB, mesh ); // STD_INFO
2942 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2943 popupMgr()->insert( separator(), -1, 0 );
2944 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2945 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2946 popupMgr()->insert( separator(), -1, 0 );
2947 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2948 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2949 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2950 popupMgr()->insert( separator(), -1, 0 );
2951 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2952 popupMgr()->insert( separator(), -1, 0 );
2954 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2955 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2957 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2958 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2959 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2960 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2961 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2962 popupMgr()->insert( separator(), -1, 0 );
2965 createPopupItem( 803, View, group ); // EDIT_GROUP
2966 createPopupItem( 804, View, elems ); // ADD
2967 createPopupItem( 805, View, elems ); // REMOVE
2968 popupMgr()->insert( separator(), -1, 0 );
2969 createPopupItem( 214, View, mesh_group ); // UPDATE
2970 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2971 createPopupItem( 902, View, mesh ); // STD_INFO
2972 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2973 popupMgr()->insert( separator(), -1, 0 );
2975 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2976 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2977 popupMgr()->insert( separator(), -1, 0 );
2981 isInvisible("not( isVisible )"),
2982 isEmpty("numberOfNodes = 0"),
2983 isNotEmpty("numberOfNodes <> 0"),
2985 // has nodes, edges, etc in VISIBLE! actor
2986 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2987 hasElems("(count( elemTypes ) > 0)"),
2988 hasDifferentElems("(count( elemTypes ) > 1)"),
2989 hasEdges("({'Edge'} in elemTypes)"),
2990 hasFaces("({'Face'} in elemTypes)"),
2991 hasVolumes("({'Volume'} in elemTypes)");
2993 QString lc = QtxPopupMgr::Selection::defEquality();
2994 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2995 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2996 aType = aType.arg( mesh_group );
2997 QString aMeshInVTK = aClient + "&&" + aType;
2999 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3000 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3001 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
3003 //-------------------------------------------------
3005 //-------------------------------------------------
3006 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3008 popupMgr()->insert( action( 9010 ), anId, -1 );
3009 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
3010 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
3012 popupMgr()->insert( action( 9011 ), anId, -1 );
3013 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
3014 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
3016 popupMgr()->insert( separator(), -1, -1 );
3018 //-------------------------------------------------
3020 //-------------------------------------------------
3021 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3023 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3024 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3025 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3027 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3028 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3029 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3031 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3032 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3033 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3035 popupMgr()->insert( separator(), anId, -1 );
3037 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3038 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3039 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3041 //-------------------------------------------------
3043 //-------------------------------------------------
3044 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3046 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3048 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3049 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3050 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3052 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3053 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3054 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3056 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3057 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3058 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3060 popupMgr()->insert( separator(), anId, -1 );
3062 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3063 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3065 //-------------------------------------------------
3067 //-------------------------------------------------
3068 popupMgr()->insert( action( 1132 ), -1, -1 );
3069 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3071 //-------------------------------------------------
3073 //-------------------------------------------------
3074 popupMgr()->insert( action( 1133 ), -1, -1 );
3075 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3077 //-------------------------------------------------
3079 //-------------------------------------------------
3080 popupMgr()->insert( action( 1134 ), -1, -1 );
3081 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3083 popupMgr()->insert( separator(), -1, -1 );
3085 //-------------------------------------------------
3087 //-------------------------------------------------
3089 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3090 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3091 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3093 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3095 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3096 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3098 popupMgr()->insert( separator(), anId, -1 );
3100 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3101 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3102 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3104 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3105 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3106 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3108 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3109 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3110 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3112 popupMgr()->insert( separator(), anId, -1 );
3114 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3115 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3116 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3118 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3119 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3120 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3122 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3123 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3124 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3126 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3127 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3128 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3130 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3131 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3132 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3134 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3135 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3136 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3138 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3139 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3140 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3142 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3143 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3144 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3146 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3147 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3148 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3150 popupMgr()->insert( separator(), anId, -1 );
3152 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3153 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3154 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3156 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3157 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3158 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3160 popupMgr()->insert( separator(), anId, -1 );
3162 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3163 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3165 popupMgr()->insert( separator(), -1, -1 );
3167 //-------------------------------------------------
3169 //-------------------------------------------------
3170 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3171 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3172 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3173 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3175 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3176 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3178 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3179 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3181 popupMgr()->insert( separator(), -1, -1 );
3183 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3184 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3187 //================================================================================
3189 * \brief Return true if SMESH or GEOM objects are selected.
3190 * Is called form LightApp_Module::activateModule() which clear selection if
3191 * not isSelectionCompatible()
3193 //================================================================================
3195 bool SMESHGUI::isSelectionCompatible()
3197 bool isCompatible = true;
3198 SALOME_ListIO selected;
3199 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3200 Sel->selectedObjects( selected );
3202 SALOME_ListIteratorOfListIO It( selected );
3203 for ( ; isCompatible && It.More(); It.Next())
3205 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3206 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3208 return isCompatible;
3211 bool SMESHGUI::activateModule( SUIT_Study* study )
3213 bool res = SalomeApp_Module::activateModule( study );
3215 setMenuShown( true );
3216 setToolShown( true );
3218 // Reset actions accelerator keys
3219 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3220 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3221 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3223 action( 33)->setEnabled(true); // Delete: Key_Delete
3224 action(1101)->setEnabled(true); // Rename: Key_F2
3229 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3231 setMenuShown( false );
3232 setToolShown( false );
3234 EmitSignalCloseAllDialogs();
3236 // Unset actions accelerator keys
3237 action(111)->setAccel(QKeySequence()); // Import DAT
3238 action(112)->setAccel(QKeySequence()); // Import UNV
3239 action(113)->setAccel(QKeySequence()); // Import MED
3241 action( 33)->setEnabled(false); // Delete: Key_Delete
3242 action(1101)->setEnabled(false); // Rename: Key_F2
3244 return SalomeApp_Module::deactivateModule( study );
3247 void SMESHGUI::studyClosed( SUIT_Study* s )
3249 SMESH::RemoveVisuData( s->id() );
3250 SalomeApp_Module::studyClosed( s );
3253 void SMESHGUI::OnGUIEvent()
3255 const QObject* obj = sender();
3256 if ( !obj || !obj->inherits( "QAction" ) )
3258 int id = actionId((QAction*)obj);
3263 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3265 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3266 if ( CORBA::is_nil( myComponentSMESH ) )
3268 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3270 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3271 return aGUI.myComponentSMESH;
3274 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3275 return myComponentSMESH;
3278 QString SMESHGUI::engineIOR() const
3280 CORBA::ORB_var anORB = getApp()->orb();
3281 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3282 return QString( anIOR.in() );
3285 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3287 SMESHGUI_Selection sel;
3288 sel.init( client, selectionMgr() );
3289 popupMgr()->updatePopup( menu, &sel );
3292 selectionMgr()->selectedObjects( lst );
3293 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3294 Handle(SALOME_InteractiveObject) io = lst.First();
3295 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3296 _PTR(Study) study = appStudy->studyDS();
3297 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3299 QString aName = QString( obj->GetName().c_str() );
3300 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3301 aName.remove( (aName.length() - 1), 1 );
3307 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3309 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3310 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3313 void SMESHGUI::viewManagers( QStringList& list ) const
3315 list.append( SVTK_Viewer::Type() );
3318 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3320 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3321 SMESH::UpdateSelectionProp( this );
3324 void SMESHGUI::createPreferences()
3326 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3328 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3329 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3331 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3332 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3333 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3335 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3336 setPreferenceProperty( precGroup, "columns", 1 );
3338 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3340 setPreferenceProperty( prec, "min", 0 );
3341 setPreferenceProperty( prec, "max", 16 );
3343 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3344 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3346 modes.append( "Wireframe" );
3347 modes.append( "Shading" );
3348 modes.append( "Nodes" );
3349 modes.append( "Shrink" );
3350 QValueList<QVariant> indices;
3351 indices.append( 0 );
3352 indices.append( 1 );
3353 indices.append( 2 );
3354 indices.append( 3 );
3355 setPreferenceProperty( dispmode, "strings", modes );
3356 setPreferenceProperty( dispmode, "indexes", indices );
3358 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3359 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3360 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3362 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3363 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3365 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3366 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3368 setPreferenceProperty( nodeSz, "min", 1 );
3369 setPreferenceProperty( nodeSz, "max", 5 );
3371 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3373 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3374 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3375 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3376 addPreference( "", elemGroup, LightApp_Preferences::Space );
3378 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3379 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3381 setPreferenceProperty( elemW, "min", 1 );
3382 setPreferenceProperty( elemW, "max", 5 );
3384 setPreferenceProperty( shrink, "min", 0 );
3385 setPreferenceProperty( shrink, "max", 100 );
3387 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3389 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3391 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3392 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3393 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3395 setPreferenceProperty( selW, "min", 1 );
3396 setPreferenceProperty( selW, "max", 5 );
3398 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3400 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3401 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3403 setPreferenceProperty( preW, "min", 1 );
3404 setPreferenceProperty( preW, "max", 5 );
3406 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3408 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3409 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3410 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3412 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3413 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3415 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3416 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3417 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3418 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3421 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3422 fam.append( tr( "SMESH_FONT_COURIER" ) );
3423 fam.append( tr( "SMESH_FONT_TIMES" ) );
3424 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3426 setPreferenceProperty( tfont, "families", fam );
3427 setPreferenceProperty( tfont, "system", false );
3428 setPreferenceProperty( tfont, "widget_flags", wflag );
3429 setPreferenceProperty( lfont, "families", fam );
3430 setPreferenceProperty( lfont, "system", false );
3431 setPreferenceProperty( lfont, "widget_flags", wflag );
3433 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3435 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3436 setPreferenceProperty( numcol, "min", 2 );
3437 setPreferenceProperty( numcol, "max", 256 );
3439 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3440 setPreferenceProperty( numlab, "min", 2 );
3441 setPreferenceProperty( numlab, "max", 65 );
3443 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3444 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3445 QStringList orients;
3446 orients.append( tr( "SMESH_VERTICAL" ) );
3447 orients.append( tr( "SMESH_HORIZONTAL" ) );
3448 indices.clear(); indices.append( 0 ); indices.append( 1 );
3449 setPreferenceProperty( orient, "strings", orients );
3450 setPreferenceProperty( orient, "indexes", indices );
3452 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3453 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3454 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3455 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3456 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3457 setPreferenceProperty( xv, "step", 0.1 );
3458 setPreferenceProperty( xv, "min", 0.0 );
3459 setPreferenceProperty( xv, "max", 1.0 );
3460 setPreferenceProperty( yv, "step", 0.1 );
3461 setPreferenceProperty( yv, "min", 0.0 );
3462 setPreferenceProperty( yv, "max", 1.0 );
3463 setPreferenceProperty( wv, "step", 0.1 );
3464 setPreferenceProperty( wv, "min", 0.0 );
3465 setPreferenceProperty( wv, "max", 1.0 );
3466 setPreferenceProperty( hv, "min", 0.0 );
3467 setPreferenceProperty( hv, "max", 1.0 );
3468 setPreferenceProperty( hv, "step", 0.1 );
3470 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3471 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3472 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3473 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3474 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3475 setPreferenceProperty( xv, "min", 0.0 );
3476 setPreferenceProperty( xv, "max", 1.0 );
3477 setPreferenceProperty( xv, "step", 0.1 );
3478 setPreferenceProperty( xh, "min", 0.0 );
3479 setPreferenceProperty( xh, "max", 1.0 );
3480 setPreferenceProperty( xh, "step", 0.1 );
3481 setPreferenceProperty( yh, "min", 0.0 );
3482 setPreferenceProperty( yh, "max", 1.0 );
3483 setPreferenceProperty( yh, "step", 0.1 );
3484 setPreferenceProperty( wh, "min", 0.0 );
3485 setPreferenceProperty( wh, "max", 1.0 );
3486 setPreferenceProperty( wh, "step", 0.1 );
3487 setPreferenceProperty( hh, "min", 0.0 );
3488 setPreferenceProperty( hh, "max", 1.0 );
3489 setPreferenceProperty( hh, "step", 0.1 );
3492 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3494 if( sect=="SMESH" ){
3495 float sbX1,sbY1,sbW,sbH;
3496 float aTol = 1.00000009999999;
3497 std::string aWarning;
3498 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3499 if( name=="selection_object_color" || name=="selection_element_color" ||
3500 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3501 name=="selection_precision_node" || name=="selection_precision_element" ||
3502 name=="selection_precision_object")
3503 SMESH::UpdateSelectionProp( this );
3504 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3505 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3506 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3507 if(sbX1+sbW > aTol){
3508 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3511 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3512 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3515 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3516 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3517 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3518 if(sbY1+sbH > aTol){
3519 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3520 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3521 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3524 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3525 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3526 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3527 if(sbX1+sbW > aTol){
3528 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3531 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3532 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3535 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3536 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3537 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3538 if(sbY1+sbH > aTol){
3539 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3542 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3543 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3547 if(aWarning.size() != 0){
3548 aWarning += "The default values are applied instead.";
3549 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3550 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3551 QObject::tr(aWarning.c_str()),
3552 QObject::tr("SMESH_BUT_OK"));
3557 //================================================================================
3559 * \brief Update something in accordance with update flags
3560 * \param theFlags - update flags
3562 * Update viewer or/and object browser etc. in accordance with update flags ( see
3563 * LightApp_UpdateFlags enumeration ).
3565 //================================================================================
3566 void SMESHGUI::update( const int flags )
3568 if ( flags & UF_Viewer | flags & UF_Forced )
3569 SMESH::UpdateView();
3571 SalomeApp_Module::update( flags );
3574 //================================================================================
3576 * \brief Set default selection mode
3578 * SLOT called when operation commited. Sets default selection mode
3580 //================================================================================
3581 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3583 SVTK_ViewWindow* vtkWnd =
3584 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3586 vtkWnd->SetSelectionMode( ActorSelection );
3589 //================================================================================
3591 * \brief Set default selection mode
3593 * SLOT called when operation aborted. Sets default selection mode
3595 //================================================================================
3596 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3598 SVTK_ViewWindow* vtkWnd =
3599 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3601 vtkWnd->SetSelectionMode( ActorSelection );
3604 //================================================================================
3606 * \brief Creates operation with given identifier
3607 * \param id - identifier of operation to be started
3608 * \return Pointer on created operation or NULL if operation is not created
3610 * Virtual method redefined from the base class creates operation with given id.
3611 * It is called called automatically from startOperation method of base class.
3613 //================================================================================
3614 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3616 LightApp_Operation* op = 0;
3617 // to do : create operation here
3620 case 701: // Compute mesh
3621 op = new SMESHGUI_ComputeOp();
3623 case 702: // Create mesh
3624 op = new SMESHGUI_MeshOp( true, true );
3626 case 703: // Create sub-mesh
3627 op = new SMESHGUI_MeshOp( true, false );
3629 case 704: // Edit mesh/sub-mesh
3630 op = new SMESHGUI_MeshOp( false );
3632 case 417: //convert to quadratic
3633 op = new SMESHGUI_ConvToQuadOp();
3635 case 4067: // make mesh pass through point
3636 op = new SMESHGUI_MakeNodeAtPointOp();
3643 op = SalomeApp_Module::createOperation( id );
3647 //================================================================================
3649 * \brief Stops current operations and starts a given one
3650 * \param id - The id of the operation to start
3652 //================================================================================
3654 void SMESHGUI::switchToOperation(int id)
3656 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3657 activeStudy()->abortAllOperations();
3658 startOperation( id );
3661 LightApp_Displayer* SMESHGUI::displayer()
3664 myDisplayer = new SMESHGUI_Displayer( getApp() );
3668 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3671 int aTolerance = 64;
3672 int anIterations = 0;
3678 if( anIterations % aPeriod == 0 )
3681 if( aTolerance < 1 )
3684 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3686 aHue = (int)( 360.0 * rand() / RAND_MAX );
3687 //cout << "Hue = " << aHue << endl;
3689 //cout << "Auto colors : ";
3691 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3692 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3693 for( ; it != itEnd; ++it )
3695 SALOMEDS::Color anAutoColor = *it;
3696 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3699 aQColor.getHsv( &h, &s, &v );
3701 if( abs( h - aHue ) < aTolerance )
3704 //cout << "break (diff = " << abs( h - aHue ) << ")";
3714 //cout << "Hue of the returned color = " << aHue << endl;
3716 aColor.setHsv( aHue, 255, 255 );
3718 SALOMEDS::Color aSColor;
3719 aSColor.R = (double)aColor.red() / 255.0;
3720 aSColor.G = (double)aColor.green() / 255.0;
3721 aSColor.B = (double)aColor.blue() / 255.0;