1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
71 #include "SMESHGUI_FileInfoDlg.h"
72 #include "SMESHGUI_GroupOnShapeDlg.h"
74 #include "SMESHGUI_Utils.h"
75 #include "SMESHGUI_GEOMGenUtils.h"
76 #include "SMESHGUI_MeshUtils.h"
77 #include "SMESHGUI_GroupUtils.h"
78 #include "SMESHGUI_FilterUtils.h"
79 #include "SMESHGUI_PatternUtils.h"
80 #include "SMESHGUI_VTKUtils.h"
81 #include "SMESHGUI_HypothesesUtils.h"
83 #include "SMESH_Actor.h"
84 #include "SMESH_Object.h"
85 #include "SMESH_TypeFilter.hxx"
87 #include "SalomeApp_Tools.h"
88 #include "SalomeApp_Study.h"
89 #include "SalomeApp_Application.h"
90 #include "SalomeApp_CheckFileDlg.h"
91 #include "SalomeApp_ImportOperation.h"
93 #include "LightApp_DataOwner.h"
94 #include "LightApp_Preferences.h"
95 #include "LightApp_VTKSelector.h"
96 #include "LightApp_Operation.h"
97 #include "LightApp_UpdateFlags.h"
98 #include "LightApp_NameDlg.h"
100 #include <SVTK_ViewWindow.h>
101 #include <SVTK_ViewModel.h>
102 #include <SVTK_InteractorStyle.h>
103 #include <SVTK_RenderWindowInteractor.h>
104 #include <SVTK_ViewManager.h>
106 #include "OB_Browser.h"
108 #include "SUIT_Tools.h"
109 #include "SUIT_MessageBox.h"
110 #include "SUIT_ResourceMgr.h"
111 #include "SUIT_FileDlg.h"
112 #include "SUIT_Desktop.h"
113 #include "SUIT_OverrideCursor.h"
114 #include "SUIT_Study.h"
115 #include "SUIT_Session.h"
117 #include "QtxPopupMgr.h"
119 #include "SALOME_ListIO.hxx"
120 #include "SALOME_ListIteratorOfListIO.hxx"
121 #include "SALOME_InteractiveObject.hxx"
122 #include "SALOME_NamingService.hxx"
123 #include "SALOME_LifeCycleCORBA.hxx"
125 #include "SALOMEconfig.h"
126 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
127 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
130 #define INCLUDE_MENUITEM_DEF
131 #include <qpopupmenu.h>
137 #include <boost/shared_ptr.hpp>
140 #include <vtkRenderer.h>
141 #include <vtkRenderWindow.h>
142 #include <vtkActorCollection.h>
143 #include <vtkScalarBarActor.h>
144 #include <vtkUnstructuredGrid.h>
146 #include "utilities.h"
148 #include "SALOMEDS_Study.hxx"
149 #include "SALOMEDSClient_StudyBuilder.hxx"
150 #include "SALOMEDSClient_SComponent.hxx"
152 #include <Standard_ErrorHandler.hxx>
158 //=============================================================
159 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
162 void ExportMeshToFile(int theCommandID);
164 void SetDisplayMode(int theCommandID);
166 void SetDisplayEntity(int theCommandID);
168 void Control( int theCommandID );
172 //=============================================================
173 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
179 if ( theCommandID == 113 ) {
180 filter.append( QObject::tr( "MED files (*.med)" ) );
181 filter.append( QObject::tr( "All files (*)" ) );
183 else if ( theCommandID == 112 ) {
184 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
186 else if ( theCommandID == 111 ) {
187 filter.append( QObject::tr( "DAT files (*.dat)" ) );
190 QString anInitialPath = "";
191 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
192 anInitialPath = QDir::currentDirPath();
194 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
197 QObject::tr( "SMESH_IMPORT_MESH" ) );
198 if ( filenames.count() > 0 ) {
199 SUIT_OverrideCursor wc;
200 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
203 bool isEmpty = false;
204 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
205 QString filename = *it;
206 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
208 switch ( theCommandID ) {
211 // DAT format (currently unsupported)
212 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
213 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
219 aMeshes->length( 1 );
220 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.latin1() );
221 if ( aMeshes[0]->_is_nil() )
222 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
223 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
229 SMESH::DriverMED_ReadStatus res;
230 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.latin1(), res );
231 if ( res != SMESH::DRS_OK ) {
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ) ) ) );
239 catch ( const SALOME::SALOME_Exception& S_ex ) {
240 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
241 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
244 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
245 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
247 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
248 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
249 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
250 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
251 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
259 // update Object browser
260 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
262 // show Error message box if there were errors
263 if ( errors.count() > 0 ) {
264 SUIT_MessageBox::error1( SMESHGUI::desktop(),
265 QObject::tr( "SMESH_ERROR" ),
266 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ),
267 QObject::tr( "SMESH_BUT_OK" ) );
270 // show warning message box, if some imported mesh is empty
272 SUIT_MessageBox::warn1( SMESHGUI::desktop(),
273 QObject::tr( "SMESH_WRN_WARNING" ),
274 QObject::tr( "SMESH_DRS_SOME_EMPTY" ),
275 QObject::tr( "SMESH_BUT_OK" ) );
280 void ExportMeshToFile( int theCommandID )
282 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
283 SALOME_ListIO selected;
285 aSel->selectedObjects( selected );
287 if(selected.Extent()){
288 Handle(SALOME_InteractiveObject) anIObject = selected.First();
289 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
290 if ( !aMesh->_is_nil() ) {
291 QString aFilter, aTitle = QObject::tr("Export mesh");
292 QMap<QString, SMESH::MED_VERSION> aFilterMap;
293 QMap<QString, int> aFilterMapSTL;
294 switch ( theCommandID ) {
298 if (aMesh->HasDuplicatedGroupNamesMED()) {
299 int aRet = SUIT_MessageBox::warn2
300 (SMESHGUI::desktop(),
301 QObject::tr("SMESH_WRN_WARNING"),
302 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
303 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
309 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
310 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
311 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
312 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
317 aFilter = QObject::tr("DAT files (*.dat)");
322 if (aMesh->NbPyramids()) {
323 int aRet = SUIT_MessageBox::warn2
324 (SMESHGUI::desktop(),
325 QObject::tr("SMESH_WRN_WARNING"),
326 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
327 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
332 aFilter = QObject::tr("IDEAS files (*.unv)");
340 there must be check on others mesh elements not equal triangles
342 if (aMesh->NbTriangles() < 1) {
343 SUIT_MessageBox::warn1
344 (SMESHGUI::desktop(),
345 QObject::tr("SMESH_WRN_WARNING"),
346 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
347 QObject::tr("SMESH_BUT_OK"));
350 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
351 int aRet = SUIT_MessageBox::warn2
352 (SMESHGUI::desktop(),
353 QObject::tr("SMESH_WRN_WARNING"),
354 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
355 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
361 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
362 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
370 SMESH::MED_VERSION aFormat;
371 // Init the parameter with the default value
372 bool aIsASCII_STL = true;
373 bool toCreateGroups = false;
374 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
376 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
378 QString anInitialPath = "";
379 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
380 anInitialPath = QDir::currentDirPath();
382 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
383 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
384 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
385 aFilter, aTitle, false);
387 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
389 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
390 for ( ; it != aFilterMapSTL.end(); ++it )
391 filters.push_back( it.key() );
393 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
394 fd->setCaption( aTitle );
395 fd->setFilters( filters );
396 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
397 if ( !anInitialPath.isEmpty() )
398 fd->setDir( anInitialPath );
399 fd->setSelection(anIObject->getName());
403 aFilename = fd->selectedFile();
404 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
409 else { // Export to MED
411 QString aDefaultFilter;
412 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
413 for ( ; it != aFilterMap.end(); ++it ) {
414 filters.push_back( it.key() );
415 if (it.data() == SMESH::MED_V2_2)
416 aDefaultFilter = it.key();
419 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
420 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
421 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
422 fd->setCaption( aTitle );
423 fd->setFilters( filters );
424 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
425 fd->setSelectedFilter(aDefaultFilter);
426 fd->SetChecked(toCreateGroups);
427 if ( !anInitialPath.isEmpty() )
428 fd->setDir( anInitialPath );
429 fd->setSelection(anIObject->getName());
433 aFilename = fd->selectedFile();
434 aFormat = aFilterMap[fd->selectedFilter()];
436 if ( !aFilename.isEmpty()
437 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
438 && aFormat==SMESH::MED_V2_1) {
439 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
440 QObject::tr("SMESH_WRN_WARNING"),
441 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
442 QObject::tr("SMESH_BUT_YES"),
443 QObject::tr("SMESH_BUT_NO"),
450 toCreateGroups = fd->IsChecked();
453 if ( !aFilename.isEmpty() ) {
454 // Check whether the file already exists and delete it if yes
455 QFile aFile( aFilename );
456 if ( aFile.exists() )
458 SUIT_OverrideCursor wc;
461 bool Renumber = false ;
462 // PAL 14172 : Check of we have to renumber or not from the preferences before export
464 Renumber= resMgr->booleanValue("SMESH","renumbering");
466 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
467 aMeshEditor->RenumberNodes();
468 aMeshEditor->RenumberElements();
469 if ( SMESHGUI::automaticUpdate() )
472 switch ( theCommandID ) {
475 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
479 aMesh->ExportDAT( aFilename.latin1() );
483 aMesh->ExportUNV( aFilename.latin1() );
487 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
493 catch (const SALOME::SALOME_Exception& S_ex){
495 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
496 QObject::tr("SMESH_WRN_WARNING"),
497 QObject::tr("SMESH_EXPORT_FAILED"),
498 QObject::tr("SMESH_BUT_OK"));
506 inline void InverseEntityMode(unsigned int& theOutputMode,
507 unsigned int theMode)
509 bool anIsNotPresent = ~theOutputMode & theMode;
511 theOutputMode |= theMode;
513 theOutputMode &= ~theMode;
516 void SetDisplayEntity(int theCommandID){
517 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
518 SALOME_ListIO selected;
520 aSel->selectedObjects( selected );
522 if(selected.Extent() >= 1){
523 SALOME_ListIteratorOfListIO It( selected );
524 for(; It.More(); It.Next()){
525 Handle(SALOME_InteractiveObject) IObject = It.Value();
526 if(IObject->hasEntry()){
527 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
528 unsigned int aMode = anActor->GetEntityMode();
529 switch(theCommandID){
531 InverseEntityMode(aMode,SMESH_Actor::eEdges);
534 InverseEntityMode(aMode,SMESH_Actor::eFaces);
537 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
540 aMode = SMESH_Actor::eAllEntity;
544 anActor->SetEntityMode(aMode);
552 SALOME_ListIO selected;
553 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
557 LightApp_SelectionMgr* aSel = app->selectionMgr();
558 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
559 if( !aSel || !appStudy )
562 aSel->selectedObjects( selected );
563 if( selected.IsEmpty() )
566 Handle(SALOME_InteractiveObject) anIObject = selected.First();
568 _PTR(Study) aStudy = appStudy->studyDS();
569 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
570 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
571 if( aMainObject->_is_nil() )
574 aMainObject->SetAutoColor( true );
576 QValueList<SALOMEDS::Color> aReservedColors;
578 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
579 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
581 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
582 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
584 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
585 aGroupObject->SetColor( aColor );
586 aReservedColors.append( aColor );
588 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
589 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
591 if( aGroupObject->GetType() == SMESH::NODE )
592 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
593 else if( aGroupObject->GetType() == SMESH::EDGE )
594 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
596 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
600 SMESH::RepaintCurrentView();
603 void DisableAutoColor(){
604 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
605 SALOME_ListIO selected;
607 aSel->selectedObjects( selected );
609 if(selected.Extent()){
610 Handle(SALOME_InteractiveObject) anIObject = selected.First();
611 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
612 if ( !aMesh->_is_nil() ) {
613 aMesh->SetAutoColor( false );
618 void SetDisplayMode(int theCommandID){
619 SALOME_ListIO selected;
620 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
624 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
625 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
626 if( !aSel || !appStudy )
629 _PTR(Study) aStudy = appStudy->studyDS();
631 aSel->selectedObjects( selected );
633 if(selected.Extent() >= 1){
634 switch(theCommandID){
636 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
637 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
641 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
642 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
645 SALOME_ListIteratorOfListIO It( selected );
646 for(; It.More(); It.Next()){
647 Handle(SALOME_InteractiveObject) IObject = It.Value();
648 if(IObject->hasEntry()){
649 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
650 switch(theCommandID){
652 anActor->SetRepresentation(SMESH_Actor::eEdge);
655 anActor->SetRepresentation(SMESH_Actor::eSurface);
658 if(anActor->IsShrunk())
661 anActor->SetShrink();
664 anActor->SetRepresentation(SMESH_Actor::ePoint);
667 vtkFloatingPointType color[3];
668 anActor->GetSufaceColor(color[0], color[1], color[2]);
669 int c0 = int (color[0] * 255);
670 int c1 = int (color[1] * 255);
671 int c2 = int (color[2] * 255);
672 QColor c(c0, c1, c2);
674 vtkFloatingPointType edgecolor[3];
675 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
676 c0 = int (edgecolor[0] * 255);
677 c1 = int (edgecolor[1] * 255);
678 c2 = int (edgecolor[2] * 255);
679 QColor e(c0, c1, c2);
681 vtkFloatingPointType backfacecolor[3];
682 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
683 c0 = int (backfacecolor[0] * 255);
684 c1 = int (backfacecolor[1] * 255);
685 c2 = int (backfacecolor[2] * 255);
686 QColor b(c0, c1, c2);
688 vtkFloatingPointType nodecolor[3];
689 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
690 c0 = int (nodecolor[0] * 255);
691 c1 = int (nodecolor[1] * 255);
692 c2 = int (nodecolor[2] * 255);
693 QColor n(c0, c1, c2);
695 int Edgewidth = (int)anActor->GetLineWidth();
698 int intValue = int(anActor->GetNodeSize());
699 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
701 SMESHGUI_Preferences_ColorDlg *aDlg =
702 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
703 aDlg->SetColor(1, c);
704 aDlg->SetColor(2, e);
705 aDlg->SetColor(3, n);
706 aDlg->SetColor(4, b);
707 aDlg->SetIntValue(1, Edgewidth);
708 aDlg->SetIntValue(2, intValue);
709 aDlg->SetIntValue(3, int(Shrink*100.));
711 QColor color = aDlg->GetColor(1);
712 QColor edgecolor = aDlg->GetColor(2);
713 QColor nodecolor = aDlg->GetColor(3);
714 QColor backfacecolor = aDlg->GetColor(4);
715 /* actor color and backface color */
716 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
717 vtkFloatingPointType (color.green()) / 255.,
718 vtkFloatingPointType (color.blue()) / 255.);
719 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
720 vtkFloatingPointType (backfacecolor.green()) / 255.,
721 vtkFloatingPointType (backfacecolor.blue()) / 255.);
724 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
725 vtkFloatingPointType (edgecolor.green()) / 255.,
726 vtkFloatingPointType (edgecolor.blue()) / 255.);
728 /* Shrink factor and size edges */
729 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
730 anActor->SetLineWidth(aDlg->GetIntValue(1));
732 /* Nodes color and size */
733 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
734 vtkFloatingPointType (nodecolor.green()) / 255.,
735 vtkFloatingPointType (nodecolor.blue()) / 255.);
736 anActor->SetNodeSize(aDlg->GetIntValue(2));
738 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
739 if( !aGroupObject->_is_nil() )
741 SALOMEDS::Color aColor;
742 aColor.R = (float)color.red() / 255.0;
743 aColor.G = (float)color.green() / 255.0;
744 aColor.B = (float)color.blue() / 255.0;
745 aGroupObject->SetColor( aColor );
755 SMESH::RepaintCurrentView();
759 void Control( int theCommandID )
761 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
762 SALOME_ListIO selected;
764 aSel->selectedObjects( selected );
766 if( !selected.IsEmpty() ){
767 Handle(SALOME_InteractiveObject) anIO = selected.First();
770 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
771 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
772 switch ( theCommandID ){
774 aTitle = QObject::tr( "LENGTH_EDGES" );
775 aControl = SMESH_Actor::eLength;
778 aTitle = QObject::tr( "LENGTH2D_EDGES" );
779 aControl = SMESH_Actor::eLength2D;
782 aTitle = QObject::tr( "FREE_EDGES" );
783 aControl = SMESH_Actor::eFreeEdges;
786 aTitle = QObject::tr( "FREE_BORDERS" );
787 aControl = SMESH_Actor::eFreeBorders;
790 aTitle = QObject::tr( "MULTI_BORDERS" );
791 aControl = SMESH_Actor::eMultiConnection;
794 aTitle = QObject::tr( "MULTI2D_BORDERS" );
795 aControl = SMESH_Actor::eMultiConnection2D;
798 aTitle = QObject::tr( "AREA_ELEMENTS" );
799 aControl = SMESH_Actor::eArea;
802 aTitle = QObject::tr( "TAPER_ELEMENTS" );
803 aControl = SMESH_Actor::eTaper;
806 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
807 aControl = SMESH_Actor::eAspectRatio;
810 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
811 aControl = SMESH_Actor::eAspectRatio3D;
814 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
815 aControl = SMESH_Actor::eMinimumAngle;
818 aTitle = QObject::tr( "WARP_ELEMENTS" );
819 aControl = SMESH_Actor::eWarping;
822 aTitle = QObject::tr( "SKEW_ELEMENTS" );
823 aControl = SMESH_Actor::eSkew;
826 aTitle = QObject::tr( "SMESH_VOLUME" );
827 aControl = SMESH_Actor::eVolume3D;
830 anActor->SetControlMode(aControl);
831 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
832 SMESH::RepaintCurrentView();
839 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
840 MeshObjectType theType,
841 const QString theInTypeName,
842 QString & theOutTypeName)
844 SMESH_TypeFilter aTypeFilter( theType );
846 if( !theIO.IsNull() )
848 entry = theIO->getEntry();
849 LightApp_DataOwner owner( entry );
850 if ( aTypeFilter.isOk( &owner )) {
851 theOutTypeName = theInTypeName;
859 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
861 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
862 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
864 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
865 CORBA::String_var anID = aSComp->GetID().c_str();
866 if (!strcmp(anID.in(),theIO->getEntry()))
872 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
873 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
874 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
875 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
876 CheckOIType ( theIO, GROUP, "Group", aTypeName )
884 QString CheckHomogeneousSelection()
886 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
887 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
888 SALOME_ListIO selected;
890 aSel->selectedObjects( selected );
892 QString RefType = CheckTypeObject(selected.First());
893 SALOME_ListIteratorOfListIO It(selected);
894 for (; It.More(); It.Next())
896 Handle(SALOME_InteractiveObject) IObject = It.Value();
897 QString Type = CheckTypeObject(IObject);
898 if (Type.compare(RefType) != 0)
899 return "Heterogeneous Selection";
906 void SMESHGUI::OnEditDelete()
908 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
909 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
910 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
912 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
913 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
914 _PTR(GenericAttribute) anAttr;
915 _PTR(AttributeIOR) anIOR;
918 QString aParentComponent = QString::null;
919 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
921 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
923 // check if object is not reference
924 _PTR(SObject) refobj;
925 if ( !aSO->ReferencedObject( refobj ) )
929 QString cur = anIt.Value()->getComponentDataType();
930 if( aParentComponent.isNull() )
931 aParentComponent = cur;
932 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
933 aParentComponent = "";
936 if ( objectCount == 0 )
937 return; // No Valid Objects Selected
939 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
940 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
941 QObject::tr("ERR_ERROR"),
942 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
943 QObject::tr("BUT_OK") );
946 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
947 if (SUIT_MessageBox::warn2
948 (SMESHGUI::desktop(),
949 QObject::tr("SMESH_WRN_WARNING"),
950 QObject::tr("SMESH_REALLY_DELETE"),
951 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
954 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
955 SUIT_ViewManager* vm = anApp->activeViewManager();
956 int nbSf = vm->getViewsCount();
958 SALOME_ListIteratorOfListIO It(selected);
960 aStudyBuilder->NewCommand(); // There is a transaction
961 for(; It.More(); It.Next()){ // loop on selected IO's
962 Handle(SALOME_InteractiveObject) IObject = It.Value();
963 if(IObject->hasEntry()) {
964 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
966 // disable removal of "SMESH" component object
967 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
969 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
973 _PTR(SObject) refobj;
974 if ( aSO && aSO->ReferencedObject( refobj ) )
975 continue; // skip references
977 // put the whole hierarchy of sub-objects of the selected SO into a list and
978 // then treat them all starting from the deepest objects (at list back)
980 list< _PTR(SObject) > listSO;
981 listSO.push_back( aSO );
982 list< _PTR(SObject) >::iterator itSO = listSO.begin();
983 for ( ; itSO != listSO.end(); ++itSO ) {
984 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
985 for (it->InitEx(false); it->More(); it->Next())
986 listSO.push_back( it->Value() );
989 // treat SO's in the list starting from the back
991 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
992 for ( ; ritSO != listSO.rend(); ++ritSO ) {
993 _PTR(SObject) SO = *ritSO;
995 string anEntry = SO->GetID();
997 /** Erase graphical object **/
998 if(SO->FindAttribute(anAttr, "AttributeIOR")){
999 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
1000 for(int i = 0; i < nbSf; i++){
1001 SUIT_ViewWindow *sf = aViews[i];
1002 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1003 SMESH::RemoveActor(sf,anActor);
1008 /** Remove an object from data structures **/
1009 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1010 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1011 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1012 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1013 aMesh->RemoveGroup( aGroup );
1015 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1016 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1017 aMesh->RemoveSubMesh( aSubMesh );
1019 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1021 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1024 IObject = new SALOME_InteractiveObject
1025 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1026 QString objType = CheckTypeObject(IObject);
1027 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1028 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1029 aStudyBuilder->RemoveObjectWithChildren( SO );
1031 else {// default action: remove SObject from the study
1032 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1033 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1035 aStudyBuilder->RemoveObjectWithChildren( SO );
1039 } /* listSO back loop */
1040 } /* IObject->hasEntry() */
1042 aStudyBuilder->CommitCommand();
1044 /* Clear any previous selection */
1046 aSel->setSelectedObjects( l1 );
1048 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1053 SMESHGUI_EXPORT CAM_Module* createModule()
1055 return new SMESHGUI();
1059 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1061 //=============================================================================
1065 //=============================================================================
1066 SMESHGUI::SMESHGUI() :
1067 SalomeApp_Module( "SMESH" )
1069 if ( CORBA::is_nil( myComponentSMESH ) )
1071 CORBA::Boolean anIsEmbeddedMode;
1072 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1075 myActiveDialogBox = 0;
1076 myFilterLibraryDlg = 0;
1080 SMESH::GetFilterManager();
1081 SMESH::GetPattern();
1083 /* load resources for all available meshers */
1084 SMESH::InitAvailableHypotheses();
1087 //=============================================================================
1091 //=============================================================================
1092 SMESHGUI::~SMESHGUI()
1094 SMESH::GetFilterManager()->Destroy();
1095 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1098 //=============================================================================
1102 //=============================================================================
1103 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1105 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1107 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1112 bool SMESHGUI::automaticUpdate()
1114 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1118 return resMgr->booleanValue( "SMESH", "auto_update", false );
1121 //=============================================================================
1125 //=============================================================================
1126 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1128 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1131 //=============================================================================
1135 //=============================================================================
1136 SMESHGUI* SMESHGUI::GetSMESHGUI()
1138 SMESHGUI* smeshMod = 0;
1139 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1142 CAM_Module* module = app->module( "Mesh" );
1143 smeshMod = dynamic_cast<SMESHGUI*>( module );
1146 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1148 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1151 _PTR(Study) aStudy = study->studyDS();
1153 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1162 Standard_EXPORT SMESHGUI* GetComponentGUI()
1164 return SMESHGUI::GetSMESHGUI();
1168 //=============================================================================
1172 //=============================================================================
1173 void SMESHGUI::SetState(int aState)
1178 //=============================================================================
1182 //=============================================================================
1183 void SMESHGUI::ResetState()
1188 //=============================================================================
1192 //=============================================================================
1193 void SMESHGUI::EmitSignalDeactivateDialog()
1195 emit SignalDeactivateActiveDialog();
1198 //=============================================================================
1202 //=============================================================================
1203 void SMESHGUI::EmitSignalStudyFrameChanged()
1205 emit SignalStudyFrameChanged();
1208 //=============================================================================
1212 //=============================================================================
1213 void SMESHGUI::EmitSignalCloseAllDialogs()
1215 emit SignalCloseAllDialogs();
1218 //=============================================================================
1222 //=============================================================================
1223 QDialog *SMESHGUI::GetActiveDialogBox()
1225 return myActiveDialogBox;
1228 //=============================================================================
1232 //=============================================================================
1233 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1235 myActiveDialogBox = (QDialog *) aDlg;
1239 //=============================================================================
1243 //=============================================================================
1244 SUIT_Desktop* SMESHGUI::desktop()
1246 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1248 return app->desktop();
1253 //=============================================================================
1257 //=============================================================================
1258 SalomeApp_Study* SMESHGUI::activeStudy()
1260 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1262 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1267 //=============================================================================
1271 //=============================================================================
1272 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1274 /* Here the position is on the bottom right corner - 10 */
1275 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1277 SUIT_Desktop *PP = desktop();
1278 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1279 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1283 //=============================================================================
1287 //=============================================================================
1288 static int isStudyLocked(_PTR(Study) theStudy){
1289 return theStudy->GetProperties()->IsLocked();
1292 static bool checkLock(_PTR(Study) theStudy) {
1293 if (isStudyLocked(theStudy)) {
1294 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1295 QObject::tr("WRN_WARNING"),
1296 QObject::tr("WRN_STUDY_LOCKED"),
1297 QObject::tr("BUT_OK") );
1303 //=======================================================================
1304 //function : CheckActiveStudyLocked
1306 //=======================================================================
1308 bool SMESHGUI::isActiveStudyLocked()
1310 _PTR(Study) aStudy = activeStudy()->studyDS();
1311 return checkLock( aStudy );
1314 //=============================================================================
1318 //=============================================================================
1319 bool SMESHGUI::OnGUIEvent( int theCommandID )
1321 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1325 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1326 SUIT_ResourceMgr* mgr = resourceMgr();
1330 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1331 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1334 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1335 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1337 //QAction* act = action( theCommandID );
1339 switch (theCommandID) {
1341 if(checkLock(aStudy)) break;
1349 if(checkLock(aStudy)) break;
1350 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1354 case 150: //MED FILE INFORMATION
1356 SALOME_ListIO selected;
1357 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1359 aSel->selectedObjects( selected );
1360 if( selected.Extent() )
1362 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1363 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1364 if ( !aMesh->_is_nil() )
1366 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1372 case 122: // EXPORT MED
1381 ::ExportMeshToFile(theCommandID);
1385 case 200: // SCALAR BAR
1387 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1388 SALOME_ListIO selected;
1390 aSel->selectedObjects( selected );
1392 if( selected.Extent() ) {
1393 Handle(SALOME_InteractiveObject) anIO = selected.First();
1394 if( anIO->hasEntry() ) {
1395 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1396 anActor->SetControlMode( SMESH_Actor::eNone );
1404 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1414 ::DisableAutoColor();
1417 case 1134: // Clipping
1418 case 1133: // Tranparency
1419 case 1132: // Colors / Size
1426 ::SetDisplayMode(theCommandID);
1432 case 219: // Volumes
1433 case 220: // All Entity
1434 ::SetDisplayEntity(theCommandID);
1439 if(checkLock(aStudy)) break;
1441 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1444 SMESH::UpdateView();
1446 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1447 SMESH::OnVisuException();
1449 catch (...) { // PAL16774 (Crash after display of many groups)
1450 SMESH::OnVisuException();
1454 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1455 aSel->selectedObjects( l );
1456 aSel->setSelectedObjects( l );
1461 case 301: // DISPLAY
1462 case 302: // DISPLAY ONLY
1464 SMESH::EDisplaing anAction;
1465 switch (theCommandID) {
1466 case 300: anAction = SMESH::eErase; break;
1467 case 301: anAction = SMESH::eDisplay; break;
1468 case 302: anAction = SMESH::eDisplayOnly; break;
1471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1472 SALOME_ListIO sel_objects, to_process;
1474 aSel->selectedObjects( sel_objects );
1476 if( theCommandID==302 )
1477 startOperation( myEraseAll );
1479 extractContainers( sel_objects, to_process );
1482 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1486 SALOME_ListIteratorOfListIO It( to_process );
1487 for (; It.More(); It.Next()) {
1488 Handle(SALOME_InteractiveObject) IOS = It.Value();
1489 if (IOS->hasEntry()) {
1490 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1491 break; // PAL16774 (Crash after display of many groups)
1492 if (anAction == SMESH::eDisplayOnly)
1493 anAction = SMESH::eDisplay;
1498 // PAL13338 + PAL15161 -->
1499 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1500 SMESH::UpdateView();
1501 // PAL13338 + PAL15161 <--
1503 catch (...) { // PAL16774 (Crash after display of many groups)
1504 SMESH::OnVisuException();
1507 if (anAction == SMESH::eErase) {
1509 aSel->setSelectedObjects( l1 );
1512 aSel->setSelectedObjects( to_process );
1519 if(checkLock(aStudy)) break;
1522 EmitSignalDeactivateDialog();
1524 new SMESHGUI_NodesDlg(this);
1527 SUIT_MessageBox::warn1(desktop(),
1528 tr("SMESH_WRN_WARNING"),
1529 tr("SMESH_WRN_VIEWER_VTK"),
1530 tr("SMESH_BUT_OK"));
1535 case 2151: // FILTER
1539 EmitSignalDeactivateDialog();
1540 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1545 case 406: // MOVE NODE
1549 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1550 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1554 if(checkLock(aStudy)) break;
1555 new SMESHGUI_MoveNodesDlg(this);
1559 case 701: // COMPUTE MESH
1561 if (checkLock(aStudy)) break;
1563 startOperation( 701 );
1567 case 702: // Create mesh
1568 startOperation( 702 );
1570 case 703: // Create sub-mesh
1571 startOperation( 703 );
1573 case 704: // Edit mesh/sub-mesh
1574 startOperation( 704 );
1576 case 710: // Build compound mesh
1578 if (checkLock(aStudy)) break;
1579 EmitSignalDeactivateDialog();
1580 new SMESHGUI_BuildCompoundDlg( this );
1584 case 407: // DIAGONAL INVERSION
1585 case 408: // Delete diagonal
1589 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1590 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1594 if ( checkLock( aStudy ) )
1597 /*Standard_Boolean aRes;
1598 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1599 if ( aMesh->_is_nil() )
1601 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1602 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1606 EmitSignalDeactivateDialog();
1607 if ( theCommandID == 407 )
1608 new SMESHGUI_TrianglesInversionDlg(this);
1610 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1613 case 409: // Change orientation
1614 case 410: // Union of triangles
1615 case 411: // Cutting of quadrangles
1619 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1620 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1624 if ( checkLock( aStudy ) )
1627 EmitSignalDeactivateDialog();
1628 SMESHGUI_MultiEditDlg* aDlg = NULL;
1629 if ( theCommandID == 409 )
1630 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1631 else if ( theCommandID == 410 )
1632 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1634 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1639 case 412: // Smoothing
1641 if(checkLock(aStudy)) break;
1643 EmitSignalDeactivateDialog();
1644 new SMESHGUI_SmoothingDlg( this );
1647 SUIT_MessageBox::warn1(desktop(),
1648 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1649 tr("SMESH_BUT_OK"));
1653 case 413: // Extrusion
1655 if (checkLock(aStudy)) break;
1657 EmitSignalDeactivateDialog();
1658 new SMESHGUI_ExtrusionDlg ( this );
1660 SUIT_MessageBox::warn1(desktop(),
1661 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1662 tr("SMESH_BUT_OK"));
1666 case 414: // Revolution
1668 if(checkLock(aStudy)) break;
1670 EmitSignalDeactivateDialog();
1671 new SMESHGUI_RevolutionDlg( this );
1674 SUIT_MessageBox::warn1(desktop(),
1675 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1676 tr("SMESH_BUT_OK"));
1680 case 415: // Pattern mapping
1682 if ( checkLock( aStudy ) )
1686 EmitSignalDeactivateDialog();
1687 new SMESHGUI_MeshPatternDlg( this );
1690 SUIT_MessageBox::warn1(desktop(),
1691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1692 tr("SMESH_BUT_OK"));
1696 case 416: // Extrusion along a path
1698 if (checkLock(aStudy)) break;
1700 EmitSignalDeactivateDialog();
1701 new SMESHGUI_ExtrusionAlongPathDlg( this );
1703 SUIT_MessageBox::warn1(desktop(),
1704 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1705 tr("SMESH_BUT_OK"));
1709 case 417: // Convert mesh to quadratic
1711 startOperation( 417 );
1712 /* if (checkLock(aStudy)) break;
1714 EmitSignalDeactivateDialog();
1715 new SMESHGUI_ConvToQuadDlg();
1717 SUIT_MessageBox::warn1(desktop(),
1718 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1719 tr("SMESH_BUT_OK"));
1723 case 806: // CREATE GEO GROUP
1725 startOperation( 806 );
1728 case 801: // CREATE GROUP
1732 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1733 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1737 if(checkLock(aStudy)) break;
1738 EmitSignalDeactivateDialog();
1739 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1741 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1742 SALOME_ListIO selected;
1744 aSel->selectedObjects( selected );
1746 int nbSel = selected.Extent();
1748 // check if mesh is selected
1749 aMesh = SMESH::GetMeshByIO( selected.First() );
1751 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1756 case 802: // CONSTRUCT GROUP
1760 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1761 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1765 if(checkLock(aStudy)) break;
1766 EmitSignalDeactivateDialog();
1768 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1769 SALOME_ListIO selected;
1771 aSel->selectedObjects( selected );
1773 int nbSel = selected.Extent();
1775 // check if submesh is selected
1776 Handle(SALOME_InteractiveObject) IObject = selected.First();
1777 if (IObject->hasEntry()) {
1778 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1780 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1781 if (!aSubMesh->_is_nil()) {
1783 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1784 // get submesh elements list by types
1785 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1786 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1787 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1788 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1789 // create group for each type o elements
1790 QString aName = IObject->getName();
1791 if (aNodes->length() > 0) {
1792 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1793 aGroup->Add(aNodes.inout());
1795 if (aEdges->length() > 0) {
1796 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1797 aGroup->Add(aEdges.inout());
1799 if (aFaces->length() > 0) {
1800 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1801 aGroup->Add(aFaces.inout());
1803 if (aVolumes->length() > 0) {
1804 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1805 aGroup->Add(aVolumes.inout());
1810 catch(const SALOME::SALOME_Exception & S_ex){
1811 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1818 SUIT_MessageBox::warn1(desktop(),
1819 tr("SMESH_WRN_WARNING"),
1820 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1821 tr("SMESH_BUT_OK"));
1826 case 803: // EDIT GROUP
1830 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1831 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1835 if(checkLock(aStudy)) break;
1836 EmitSignalDeactivateDialog();
1838 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1839 SALOME_ListIO selected;
1841 aSel->selectedObjects( selected );
1843 SALOME_ListIteratorOfListIO It (selected);
1844 int nbSelectedGroups = 0;
1845 for ( ; It.More(); It.Next() )
1847 SMESH::SMESH_GroupBase_var aGroup =
1848 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1849 if (!aGroup->_is_nil()) {
1851 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1855 if (nbSelectedGroups == 0)
1857 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1863 case 804: // Add elements to group
1865 if(checkLock(aStudy)) break;
1866 if (myState == 800) {
1867 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1868 if (aDlg) aDlg->onAdd();
1873 case 805: // Remove elements from group
1875 if(checkLock(aStudy)) break;
1876 if (myState == 800) {
1877 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1878 if (aDlg) aDlg->onRemove();
1883 case 810: // Union Groups
1884 case 811: // Intersect groups
1885 case 812: // Cut groups
1889 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1890 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1894 if ( checkLock( aStudy ) )
1897 EmitSignalDeactivateDialog();
1900 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1901 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1902 else aMode = SMESHGUI_GroupOpDlg::CUT;
1904 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1908 case 813: // Delete groups with their contents
1912 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1913 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1917 if ( checkLock( aStudy ) )
1920 EmitSignalDeactivateDialog();
1922 new SMESHGUI_DeleteGroupDlg( this );
1926 case 900: // MESH INFOS
1928 EmitSignalDeactivateDialog();
1929 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1930 SALOME_ListIO selected;
1932 aSel->selectedObjects( selected );
1934 if ( selected.Extent() > 1 ) { // a dlg for each IO
1936 SALOME_ListIteratorOfListIO It (selected);
1937 for ( ; It.More(); It.Next() ) {
1938 IOs.Clear(); IOs.Append( It.Value() );
1939 aSel->setSelectedObjects( IOs );
1940 new SMESHGUI_MeshInfosDlg(this, "", false);
1942 // restore selection
1943 aSel->setSelectedObjects( selected );
1946 new SMESHGUI_MeshInfosDlg(this, "", false);
1950 case 902: // STANDARD MESH INFOS
1952 EmitSignalDeactivateDialog();
1953 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1954 SALOME_ListIO selected;
1956 aSel->selectedObjects( selected );
1958 if ( selected.Extent() > 1 ) { // a dlg for each IO
1960 SALOME_ListIteratorOfListIO It (selected);
1961 for ( ; It.More(); It.Next() ) {
1963 IOs.Append( It.Value() );
1964 aSel->setSelectedObjects( IOs );
1965 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1967 // restore selection
1968 aSel->setSelectedObjects( selected );
1971 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1975 case 903: // WHAT IS
1977 EmitSignalDeactivateDialog();
1978 new SMESHGUI_WhatIsDlg( this, "", false);
1982 case 1100: // EDIT HYPOTHESIS
1984 if(checkLock(aStudy)) break;
1986 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1987 SALOME_ListIO selected;
1989 aSel->selectedObjects( selected );
1991 int nbSel = selected.Extent();
1994 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1995 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1997 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1998 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1999 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2000 if ( !aHypothesis->_is_nil() )
2002 CORBA::String_var aHypType = aHypothesis->GetName();
2003 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
2005 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2012 updateObjBrowser( true );
2016 case 1101: // RENAME
2018 if ( checkLock( aStudy ) )
2021 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2022 SALOME_ListIO selected;
2024 aSel->selectedObjects( selected );
2026 bool isAny = false; // iss there any appropriate object selected
2028 SALOME_ListIteratorOfListIO It( selected );
2029 for ( ; It.More(); It.Next() )
2031 Handle(SALOME_InteractiveObject) IObject = It.Value();
2032 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2033 _PTR(GenericAttribute) anAttr;
2034 _PTR(AttributeName) aName;
2037 if ( obj->FindAttribute(anAttr, "AttributeName") )
2040 QString newName = QString(aName->Value().c_str());
2042 // check type to prevent renaming of inappropriate objects
2043 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2044 if (aType == MESH || aType == GROUP ||
2045 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2046 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2047 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2048 aType == HYPOTHESIS || aType == ALGORITHM)
2051 newName = LightApp_NameDlg::getName(desktop(), newName);
2052 if ( !newName.isEmpty() )
2054 //old source: aStudy->renameIObject( IObject, newName );
2055 aName->SetValue( newName.latin1() );
2057 // if current object is group update group's name
2058 SMESH::SMESH_GroupBase_var aGroup =
2059 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2060 if (!aGroup->_is_nil() )
2061 aGroup->SetName( newName.latin1() );
2071 SUIT_MessageBox::warn1(desktop(),
2072 QObject::tr("SMESH_WRN_WARNING"),
2073 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2074 QObject::tr("SMESH_BUT_OK"));
2079 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2081 if(checkLock(aStudy)) break;
2082 SUIT_OverrideCursor wc;
2084 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2085 SALOME_ListIO selected;
2087 aSel->selectedObjects( selected, QString::null, false );
2089 SALOME_ListIteratorOfListIO It(selected);
2090 for (int i = 0; It.More(); It.Next(), i++) {
2091 Handle(SALOME_InteractiveObject) IObject = It.Value();
2092 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2095 aSel->setSelectedObjects( l1 );
2100 case 401: // GEOM::EDGE
2101 case 4021: // TRIANGLE
2103 case 4023: // POLYGON
2107 if(checkLock(aStudy)) break;
2109 EmitSignalDeactivateDialog();
2110 SMDSAbs_ElementType type = SMDSAbs_Edge;
2112 switch (theCommandID) {
2113 case 4021: // TRIANGLE
2114 type = SMDSAbs_Face; nbNodes = 3; break;
2116 type = SMDSAbs_Face; nbNodes = 4; break;
2118 type = SMDSAbs_Volume; nbNodes = 4; break;
2119 case 4023: // POLYGON
2120 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2122 type = SMDSAbs_Volume; nbNodes = 8; break;
2123 case 4033: // POLYHEDRE
2124 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2127 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2130 SUIT_MessageBox::warn1(desktop(),
2131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2132 tr("SMESH_BUT_OK"));
2136 case 4033: // POLYHEDRON
2138 if(checkLock(aStudy)) break;
2140 EmitSignalDeactivateDialog();
2141 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2144 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2145 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2146 tr("SMESH_BUT_OK"));
2150 case 4034: // QUADRATIC EDGE
2151 case 4035: // QUADRATIC TRIANGLE
2152 case 4036: // QUADRATIC QUADRANGLE
2153 case 4037: // QUADRATIC TETRAHEDRON
2154 case 4038: // QUADRATIC PYRAMID
2155 case 4039: // QUADRATIC PENTAHEDRON
2156 case 4040: // QUADRATIC HEXAHEDRON
2158 if(checkLock(aStudy)) break;
2160 EmitSignalDeactivateDialog();
2163 switch (theCommandID) {
2165 type = QUAD_EDGE; break;
2167 type = QUAD_TRIANGLE; break;
2169 type = QUAD_QUADRANGLE; break;
2171 type = QUAD_TETRAHEDRON; break;
2173 type = QUAD_PYRAMID; break;
2175 type = QUAD_PENTAHEDRON; break;
2177 type = QUAD_HEXAHEDRON;
2181 new SMESHGUI_AddQuadraticElementDlg( this, type );
2184 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2185 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2186 tr("SMESH_BUT_OK"));
2190 case 4041: // REMOVES NODES
2192 if(checkLock(aStudy)) break;
2194 EmitSignalDeactivateDialog();
2195 new SMESHGUI_RemoveNodesDlg(this);
2198 SUIT_MessageBox::warn1(desktop(),
2199 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2200 tr("SMESH_BUT_OK"));
2204 case 4042: // REMOVES ELEMENTS
2206 if(checkLock(aStudy)) break;
2208 EmitSignalDeactivateDialog();
2209 new SMESHGUI_RemoveElementsDlg(this);
2213 SUIT_MessageBox::warn1(desktop(),
2214 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2215 tr("SMESH_BUT_OK"));
2219 case 4043: { // CLEAR_MESH
2221 if(checkLock(aStudy)) break;
2223 SALOME_ListIO selected;
2224 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2225 aSel->selectedObjects( selected );
2227 SUIT_OverrideCursor wc;
2228 SALOME_ListIteratorOfListIO It (selected);
2229 for ( ; It.More(); It.Next() )
2231 Handle(SALOME_InteractiveObject) IOS = It.Value();
2232 SMESH::SMESH_Mesh_var aMesh =
2233 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2234 if ( aMesh->_is_nil()) continue;
2236 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2238 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2239 SMESH::ModifiedMesh( aMeshSObj, false, true);
2240 // hide groups and submeshes
2241 _PTR(ChildIterator) anIter =
2242 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2243 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2245 _PTR(SObject) so = anIter->Value();
2246 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2249 catch (const SALOME::SALOME_Exception& S_ex){
2251 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2255 SMESH::UpdateView();
2259 case 4051: // RENUMBERING NODES
2261 if(checkLock(aStudy)) break;
2263 EmitSignalDeactivateDialog();
2264 new SMESHGUI_RenumberingDlg( this, "", 0);
2268 SUIT_MessageBox::warn1(desktop(),
2269 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2270 tr("SMESH_BUT_OK"));
2274 case 4052: // RENUMBERING ELEMENTS
2276 if(checkLock(aStudy)) break;
2278 EmitSignalDeactivateDialog();
2279 new SMESHGUI_RenumberingDlg( this, "", 1);
2283 SUIT_MessageBox::warn1(desktop(),
2284 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2285 tr("SMESH_BUT_OK"));
2289 case 4061: // TRANSLATION
2291 if(checkLock(aStudy)) break;
2293 EmitSignalDeactivateDialog();
2294 new SMESHGUI_TranslationDlg( this );
2297 SUIT_MessageBox::warn1(desktop(),
2298 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2299 tr("SMESH_BUT_OK"));
2303 case 4062: // ROTATION
2305 if(checkLock(aStudy)) break;
2307 EmitSignalDeactivateDialog();
2308 new SMESHGUI_RotationDlg( this );
2311 SUIT_MessageBox::warn1(desktop(),
2312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2313 tr("SMESH_BUT_OK"));
2317 case 4063: // SYMMETRY
2319 if(checkLock(aStudy)) break;
2321 EmitSignalDeactivateDialog();
2322 new SMESHGUI_SymmetryDlg( this );
2325 SUIT_MessageBox::warn1(desktop(),
2326 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2327 tr("SMESH_BUT_OK"));
2331 case 4064: // SEWING
2333 if(checkLock(aStudy)) break;
2335 EmitSignalDeactivateDialog();
2336 new SMESHGUI_SewingDlg( this );
2339 SUIT_MessageBox::warn1(desktop(),
2340 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2341 tr("SMESH_BUT_OK"));
2345 case 4065: // MERGE NODES
2347 if(checkLock(aStudy)) break;
2349 EmitSignalDeactivateDialog();
2350 new SMESHGUI_EditMeshDlg( this, 0 );
2353 SUIT_MessageBox::warn1(desktop(),
2354 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2355 tr("SMESH_BUT_OK"));
2359 case 4066: // MERGE EQUAL ELEMENTS
2361 if (checkLock(aStudy)) break;
2363 EmitSignalDeactivateDialog();
2364 new SMESHGUI_EditMeshDlg( this, 1 );
2366 SUIT_MessageBox::warn1(desktop(),
2367 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2368 tr("SMESH_BUT_OK"));
2373 case 4067: // MAKE MESH PASS THROUGH POINT
2374 startOperation( 4067 );
2377 case 5105: // Library of selection filters
2379 static QValueList<int> aTypes;
2380 if ( aTypes.isEmpty() )
2382 aTypes.append( SMESH::NODE );
2383 aTypes.append( SMESH::EDGE );
2384 aTypes.append( SMESH::FACE );
2385 aTypes.append( SMESH::VOLUME );
2387 if (!myFilterLibraryDlg)
2388 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2389 else if (myFilterLibraryDlg->isHidden())
2390 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2391 myFilterLibraryDlg->raise();
2395 case 6017: // CONTROLS
2411 LightApp_SelectionMgr* mgr = selectionMgr();
2412 SALOME_ListIO selected; mgr->selectedObjects( selected );
2414 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2415 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2417 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2418 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2419 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2420 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2421 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2422 ::Control( theCommandID );
2427 SUIT_MessageBox::warn1(desktop(),
2428 tr( "SMESH_WRN_WARNING" ),
2429 tr( "SMESH_BAD_SELECTION" ),
2430 tr( "SMESH_BUT_OK" ) );
2434 SUIT_MessageBox::warn1(desktop(),
2435 tr( "SMESH_WRN_WARNING" ),
2436 tr( "NOT_A_VTK_VIEWER" ),
2437 tr( "SMESH_BUT_OK" ) );
2442 LightApp_SelectionMgr* mgr = selectionMgr();
2443 SALOME_ListIO selected; mgr->selectedObjects( selected );
2445 SALOME_ListIteratorOfListIO it(selected);
2446 for(; it.More(); it.Next()) {
2447 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2448 if(anIObject->hasEntry()) {
2449 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2450 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2458 LightApp_SelectionMgr* mgr = selectionMgr();
2459 SALOME_ListIO selected; mgr->selectedObjects( selected );
2461 if (selected.Extent() == 1) {
2462 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2463 if(anIObject->hasEntry())
2464 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2465 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2472 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2473 //updateObjBrowser();
2477 //=============================================================================
2481 //=============================================================================
2482 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2487 //=============================================================================
2491 //=============================================================================
2492 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2497 //=============================================================================
2501 //=============================================================================
2502 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2507 //=============================================================================
2508 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2509 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2511 //=============================================================================
2512 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2513 SUIT_ViewWindow* wnd )
2515 if(theIO->hasEntry()){
2516 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2517 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2521 //=======================================================================
2522 // function : createSMESHAction
2524 //=======================================================================
2525 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2528 QWidget* parent = application()->desktop();
2529 SUIT_ResourceMgr* resMgr = resourceMgr();
2531 if ( icon_id.length() )
2532 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2534 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2535 if ( !pix.isNull() )
2536 icon = QIconSet( pix );
2538 QString tooltip = tr( QString( "TOP_" )+po_id ),
2539 menu = tr( QString( "MEN_" )+po_id ),
2540 status_bar = tr( QString( "STB_" )+po_id );
2542 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2545 //=======================================================================
2546 // function : createPopupItem
2548 //=======================================================================
2549 void SMESHGUI::createPopupItem( const int id,
2550 const QString& clients,
2551 const QString& types,
2552 const QString& theRule,
2557 parentId = popupMgr()->actionId( action( pId ) );
2559 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2560 popupMgr()->insert( action( id ), parentId, 0 );
2562 QChar lc = QtxPopupMgr::Selection::defEquality();
2563 QString rule = "(%1) and (%2) and (%3)";
2564 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2565 if( clients.isEmpty() )
2566 rule = rule.arg( QString( "true" ) );
2568 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2569 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2572 bool cont = myRules.contains( id );
2574 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2576 popupMgr()->setRule( action( id ), rule, true );
2577 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2580 //=======================================================================
2581 // function : initialize
2583 //=======================================================================
2584 void SMESHGUI::initialize( CAM_Application* app )
2586 SalomeApp_Module::initialize( app );
2588 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2590 /* Automatic Update flag */
2591 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2593 // ----- create actions --------------
2595 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2596 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2597 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2598 createSMESHAction( 114, "NUM" );
2599 createSMESHAction( 121, "DAT" );
2600 createSMESHAction( 122, "MED" );
2601 createSMESHAction( 123, "UNV" );
2602 createSMESHAction( 140, "STL" );
2603 createSMESHAction( 124, "EXPORT_DAT" );
2604 createSMESHAction( 125, "EXPORT_MED" );
2605 createSMESHAction( 126, "EXPORT_UNV" );
2606 createSMESHAction( 141, "EXPORT_STL" );
2607 createSMESHAction( 150, "FILE_INFO" );
2608 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2609 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2610 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2611 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2612 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2613 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2614 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2615 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" );
2616 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2617 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2618 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2619 createSMESHAction( 804, "ADD" );
2620 createSMESHAction( 805, "REMOVE" );
2621 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2622 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2623 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2624 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2625 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2626 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2627 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2628 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2629 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2630 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2631 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2632 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2633 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2634 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2635 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2636 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2637 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2638 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2639 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2640 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2641 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2642 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2643 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2644 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2645 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2646 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2647 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2648 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2649 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2650 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2651 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2652 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2653 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2654 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2655 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2656 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2657 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2658 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2659 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2660 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2661 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2662 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2663 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2664 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2665 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2666 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2667 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2668 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2669 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2670 createSMESHAction( 415, "MAP", "ICON_MAP" );
2671 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2672 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2673 createSMESHAction( 200, "RESET" );
2674 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2675 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2676 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2677 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2678 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2679 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2680 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2681 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2682 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2683 createSMESHAction( 220, "ALL" );
2684 createSMESHAction( 1100, "EDIT_HYPO" );
2685 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2686 createSMESHAction( 1102, "UNASSIGN" );
2687 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2688 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2689 createSMESHAction( 1131, "DISPMODE" );
2690 createSMESHAction( 1132, "COLORS" );
2691 createSMESHAction( 1133, "TRANSP" );
2692 createSMESHAction( 1134, "CLIP" );
2693 createSMESHAction( 1135, "DISP_ENT" );
2694 createSMESHAction( 1136, "AUTO_COLOR" );
2695 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2696 createSMESHAction( 2000, "CTRL" );
2698 createSMESHAction( 300, "ERASE" );
2699 createSMESHAction( 301, "DISPLAY" );
2700 createSMESHAction( 302, "DISPLAY_ONLY" );
2701 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2702 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2703 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2704 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2705 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2706 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2707 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2708 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2710 // ----- create menu --------------
2711 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2712 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2713 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2714 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2715 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2716 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2717 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2719 createMenu( separator(), fileId );
2721 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2722 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2723 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2724 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2725 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2726 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2728 createMenu( 111, importId, -1 );
2729 createMenu( 112, importId, -1 );
2730 createMenu( 113, importId, -1 );
2732 createMenu( 121, exportId, -1 );
2733 createMenu( 122, exportId, -1 );
2734 createMenu( 123, exportId, -1 );
2735 createMenu( 140, exportId, -1 ); // export to stl STL
2737 createMenu( separator(), fileId, 10 );
2739 createMenu( 33, editId, -1 );
2741 createMenu( 5105, toolsId, -1 );
2743 createMenu( 702, meshId, -1 ); // "Mesh" menu
2744 createMenu( 703, meshId, -1 );
2745 createMenu( 704, meshId, -1 );
2746 createMenu( 710, meshId, -1 );
2747 createMenu( separator(), meshId, -1 );
2748 createMenu( 701, meshId, -1 );
2749 createMenu( separator(), meshId, -1 );
2750 createMenu( 801, meshId, -1 );
2751 createMenu( 806, meshId, -1 );
2752 createMenu( 802, meshId, -1 );
2753 createMenu( 803, meshId, -1 );
2754 createMenu( separator(), meshId, -1 );
2755 createMenu( 810, meshId, -1 );
2756 createMenu( 811, meshId, -1 );
2757 createMenu( 812, meshId, -1 );
2758 createMenu( separator(), meshId, -1 );
2759 createMenu( 813, meshId, -1 );
2760 createMenu( separator(), meshId, -1 );
2761 createMenu( 900, meshId, -1 );
2762 createMenu( 902, meshId, -1 );
2763 createMenu( 903, meshId, -1 );
2764 createMenu( separator(), meshId, -1 );
2766 createMenu( 6003, ctrlId, -1 );
2767 createMenu( 6001, ctrlId, -1 );
2768 createMenu( 6004, ctrlId, -1 );
2769 createMenu( separator(), ctrlId, -1 );
2770 createMenu( 6002, ctrlId, -1 );
2771 createMenu( 6018, ctrlId, -1 );
2772 createMenu( 6019, ctrlId, -1 );
2773 createMenu( 6011, ctrlId, -1 );
2774 createMenu( 6012, ctrlId, -1 );
2775 createMenu( 6013, ctrlId, -1 );
2776 createMenu( 6014, ctrlId, -1 );
2777 createMenu( 6015, ctrlId, -1 );
2778 createMenu( 6016, ctrlId, -1 );
2779 createMenu( separator(), ctrlId, -1 );
2780 createMenu( 6017, ctrlId, -1 );
2781 createMenu( 6009, ctrlId, -1 );
2782 createMenu( separator(), ctrlId, -1 );
2784 createMenu( 400, addId, -1 );
2785 createMenu( 401, addId, -1 );
2786 createMenu( 4021, addId, -1 );
2787 createMenu( 4022, addId, -1 );
2788 createMenu( 4023, addId, -1 );
2789 createMenu( 4031, addId, -1 );
2790 createMenu( 4032, addId, -1 );
2791 createMenu( 4033, addId, -1 );
2792 createMenu( separator(), addId, -1 );
2793 createMenu( 4034, addId, -1 );
2794 createMenu( 4035, addId, -1 );
2795 createMenu( 4036, addId, -1 );
2796 createMenu( 4037, addId, -1 );
2797 createMenu( 4038, addId, -1 );
2798 createMenu( 4039, addId, -1 );
2799 createMenu( 4040, addId, -1 );
2801 createMenu( 4041, removeId, -1 );
2802 createMenu( 4042, removeId, -1 );
2803 createMenu( 4043, removeId, -1 );
2805 createMenu( 4051, renumId, -1 );
2806 createMenu( 4052, renumId, -1 );
2808 createMenu( 4061, transfId, -1 );
2809 createMenu( 4062, transfId, -1 );
2810 createMenu( 4063, transfId, -1 );
2811 createMenu( 4064, transfId, -1 );
2812 createMenu( 4065, transfId, -1 );
2813 createMenu( 4066, transfId, -1 );
2815 createMenu( 406, modifyId, -1 );
2816 createMenu( 4067,modifyId, -1 );
2817 createMenu( 407, modifyId, -1 );
2818 createMenu( 408, modifyId, -1 );
2819 createMenu( 409, modifyId, -1 );
2820 createMenu( 410, modifyId, -1 );
2821 createMenu( 411, modifyId, -1 );
2822 createMenu( 412, modifyId, -1 );
2823 createMenu( 413, modifyId, -1 );
2824 createMenu( 416, modifyId, -1 );
2825 createMenu( 414, modifyId, -1 );
2826 createMenu( 415, modifyId, -1 );
2827 createMenu( 417, modifyId, -1 );
2829 createMenu( 214, viewId, -1 );
2831 // ----- create toolbars --------------
2832 int meshTb = createTool( tr( "TB_MESH" ) ),
2833 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2834 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2835 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2836 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2838 createTool( 702, meshTb );
2839 createTool( 703, meshTb );
2840 createTool( 704, meshTb );
2841 createTool( 710, meshTb );
2842 createTool( separator(), meshTb );
2843 createTool( 701, meshTb );
2844 createTool( separator(), meshTb );
2845 createTool( 801, meshTb );
2846 createTool( 806, meshTb );
2847 createTool( 802, meshTb );
2848 createTool( 803, meshTb );
2849 createTool( separator(), meshTb );
2850 createTool( 900, meshTb );
2851 createTool( 902, meshTb );
2852 createTool( 903, meshTb );
2853 createTool( separator(), meshTb );
2855 createTool( 6001, ctrlTb );
2856 createTool( 6003, ctrlTb );
2857 createTool( 6004, ctrlTb );
2858 createTool( separator(), ctrlTb );
2859 createTool( 6002, ctrlTb );
2860 createTool( 6018, ctrlTb );
2861 createTool( 6019, ctrlTb );
2862 createTool( 6011, ctrlTb );
2863 createTool( 6012, ctrlTb );
2864 createTool( 6013, ctrlTb );
2865 createTool( 6014, ctrlTb );
2866 createTool( 6015, ctrlTb );
2867 createTool( 6016, ctrlTb );
2868 createTool( separator(), ctrlTb );
2869 createTool( 6017, ctrlTb );
2870 createTool( 6009, ctrlTb );
2871 createTool( separator(), ctrlTb );
2873 createTool( 400, addRemTb );
2874 createTool( 401, addRemTb );
2875 createTool( 4021, addRemTb );
2876 createTool( 4022, addRemTb );
2877 createTool( 4023, addRemTb );
2878 createTool( 4031, addRemTb );
2879 createTool( 4032, addRemTb );
2880 createTool( 4033, addRemTb );
2881 createTool( separator(), addRemTb );
2882 createTool( 4034, addRemTb );
2883 createTool( 4035, addRemTb );
2884 createTool( 4036, addRemTb );
2885 createTool( 4037, addRemTb );
2886 createTool( 4038, addRemTb );
2887 createTool( 4039, addRemTb );
2888 createTool( 4040, addRemTb );
2889 createTool( separator(), addRemTb );
2890 createTool( 4041, addRemTb );
2891 createTool( 4042, addRemTb );
2892 createTool( 4043, addRemTb );
2893 createTool( separator(), addRemTb );
2894 createTool( 4051, addRemTb );
2895 createTool( 4052, addRemTb );
2896 createTool( separator(), addRemTb );
2897 createTool( 4061, addRemTb );
2898 createTool( 4062, addRemTb );
2899 createTool( 4063, addRemTb );
2900 createTool( 4064, addRemTb );
2901 createTool( 4065, addRemTb );
2902 createTool( 4066, addRemTb );
2903 createTool( separator(), addRemTb );
2905 createTool( 406, modifyTb );
2906 createTool( 4067,modifyTb );
2907 createTool( 407, modifyTb );
2908 createTool( 408, modifyTb );
2909 createTool( 409, modifyTb );
2910 createTool( 410, modifyTb );
2911 createTool( 411, modifyTb );
2912 createTool( 412, modifyTb );
2913 createTool( 413, modifyTb );
2914 createTool( 416, modifyTb );
2915 createTool( 414, modifyTb );
2916 createTool( 415, modifyTb );
2917 createTool( 417, modifyTb );
2919 createTool( 214, dispModeTb );
2923 QString OB = "'ObjectBrowser'",
2924 View = "'" + SVTK_Viewer::Type() + "'",
2926 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2927 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2928 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2929 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2930 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2931 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2932 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2933 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2934 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2935 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2936 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2938 mesh_group = mesh + " " + subMesh + " " + group,
2939 hyp_alg = hypo + " " + algo;
2941 // popup for object browser
2943 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2945 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2946 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2947 createPopupItem( 803, OB, group ); // EDIT_GROUP
2948 popupMgr()->insert( separator(), -1, 0 );
2949 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2950 createPopupItem( 214, OB, mesh_group ); // UPDATE
2951 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2952 createPopupItem( 902, OB, mesh ); // STD_INFO
2953 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2954 popupMgr()->insert( separator(), -1, 0 );
2955 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2956 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
2957 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2958 popupMgr()->insert( separator(), -1, 0 );
2959 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2960 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2961 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2962 popupMgr()->insert( separator(), -1, 0 );
2963 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2964 popupMgr()->insert( separator(), -1, 0 );
2966 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2967 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2969 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2970 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2971 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2972 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2973 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2974 popupMgr()->insert( separator(), -1, 0 );
2977 createPopupItem( 803, View, group ); // EDIT_GROUP
2978 createPopupItem( 804, View, elems ); // ADD
2979 createPopupItem( 805, View, elems ); // REMOVE
2980 popupMgr()->insert( separator(), -1, 0 );
2981 createPopupItem( 214, View, mesh_group ); // UPDATE
2982 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2983 createPopupItem( 902, View, mesh ); // STD_INFO
2984 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2985 popupMgr()->insert( separator(), -1, 0 );
2987 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2988 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2989 popupMgr()->insert( separator(), -1, 0 );
2993 isInvisible("not( isVisible )"),
2994 isEmpty("numberOfNodes = 0"),
2995 isNotEmpty("numberOfNodes <> 0"),
2997 // has nodes, edges, etc in VISIBLE! actor
2998 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2999 hasElems("(count( elemTypes ) > 0)"),
3000 hasDifferentElems("(count( elemTypes ) > 1)"),
3001 hasEdges("({'Edge'} in elemTypes)"),
3002 hasFaces("({'Face'} in elemTypes)"),
3003 hasVolumes("({'Volume'} in elemTypes)");
3005 QString lc = QtxPopupMgr::Selection::defEquality();
3006 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3007 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
3008 aType = aType.arg( mesh_group );
3009 QString aMeshInVTK = aClient + "&&" + aType;
3011 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3012 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3013 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
3015 //-------------------------------------------------
3017 //-------------------------------------------------
3018 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3020 popupMgr()->insert( action( 9010 ), anId, -1 );
3021 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
3022 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
3024 popupMgr()->insert( action( 9011 ), anId, -1 );
3025 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
3026 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
3028 popupMgr()->insert( separator(), -1, -1 );
3030 //-------------------------------------------------
3032 //-------------------------------------------------
3033 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3035 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3036 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3037 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3039 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3040 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3041 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3043 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3044 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3045 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3047 popupMgr()->insert( separator(), anId, -1 );
3049 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3050 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3051 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3053 //-------------------------------------------------
3055 //-------------------------------------------------
3056 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3058 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3060 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3061 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3062 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3064 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3065 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3066 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3068 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3069 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3070 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3072 popupMgr()->insert( separator(), anId, -1 );
3074 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3075 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3077 //-------------------------------------------------
3079 //-------------------------------------------------
3080 popupMgr()->insert( action( 1132 ), -1, -1 );
3081 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3083 //-------------------------------------------------
3085 //-------------------------------------------------
3086 popupMgr()->insert( action( 1133 ), -1, -1 );
3087 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3089 //-------------------------------------------------
3091 //-------------------------------------------------
3092 popupMgr()->insert( action( 1134 ), -1, -1 );
3093 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3095 popupMgr()->insert( separator(), -1, -1 );
3097 //-------------------------------------------------
3099 //-------------------------------------------------
3101 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3102 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3103 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3105 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3107 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3108 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3110 popupMgr()->insert( separator(), anId, -1 );
3112 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3113 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3114 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3116 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3117 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3118 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3120 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3121 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3122 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3124 popupMgr()->insert( separator(), anId, -1 );
3126 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3127 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3128 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3130 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3131 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3132 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3134 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3135 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3136 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3138 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3139 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3140 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3142 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3143 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3144 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3146 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3147 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3148 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3150 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3151 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3152 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3154 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3155 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3156 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3158 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3159 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3160 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3162 popupMgr()->insert( separator(), anId, -1 );
3164 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3165 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3166 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3168 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3169 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3170 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3172 popupMgr()->insert( separator(), anId, -1 );
3174 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3175 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3177 popupMgr()->insert( separator(), -1, -1 );
3179 //-------------------------------------------------
3181 //-------------------------------------------------
3182 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3183 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3184 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3185 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3187 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3188 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3190 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3191 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3193 popupMgr()->insert( separator(), -1, -1 );
3195 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3196 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3199 //================================================================================
3201 * \brief Return true if SMESH or GEOM objects are selected.
3202 * Is called form LightApp_Module::activateModule() which clear selection if
3203 * not isSelectionCompatible()
3205 //================================================================================
3207 bool SMESHGUI::isSelectionCompatible()
3209 bool isCompatible = true;
3210 SALOME_ListIO selected;
3211 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3212 Sel->selectedObjects( selected );
3214 SALOME_ListIteratorOfListIO It( selected );
3215 for ( ; isCompatible && It.More(); It.Next())
3217 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3218 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3220 return isCompatible;
3223 bool SMESHGUI::activateModule( SUIT_Study* study )
3225 bool res = SalomeApp_Module::activateModule( study );
3227 setMenuShown( true );
3228 setToolShown( true );
3230 // Reset actions accelerator keys
3231 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3232 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3233 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3235 action( 33)->setEnabled(true); // Delete: Key_Delete
3236 action(1101)->setEnabled(true); // Rename: Key_F2
3241 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3243 setMenuShown( false );
3244 setToolShown( false );
3246 EmitSignalCloseAllDialogs();
3248 // Unset actions accelerator keys
3249 action(111)->setAccel(QKeySequence()); // Import DAT
3250 action(112)->setAccel(QKeySequence()); // Import UNV
3251 action(113)->setAccel(QKeySequence()); // Import MED
3253 action( 33)->setEnabled(false); // Delete: Key_Delete
3254 action(1101)->setEnabled(false); // Rename: Key_F2
3256 return SalomeApp_Module::deactivateModule( study );
3259 void SMESHGUI::studyClosed( SUIT_Study* s )
3261 SMESH::RemoveVisuData( s->id() );
3262 SalomeApp_Module::studyClosed( s );
3265 void SMESHGUI::OnGUIEvent()
3267 const QObject* obj = sender();
3268 if ( !obj || !obj->inherits( "QAction" ) )
3270 int id = actionId((QAction*)obj);
3275 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3277 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3278 if ( CORBA::is_nil( myComponentSMESH ) )
3280 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3282 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3283 return aGUI.myComponentSMESH;
3286 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3287 return myComponentSMESH;
3290 QString SMESHGUI::engineIOR() const
3292 CORBA::ORB_var anORB = getApp()->orb();
3293 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3294 return QString( anIOR.in() );
3297 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3299 SMESHGUI_Selection sel;
3300 sel.init( client, selectionMgr() );
3301 popupMgr()->updatePopup( menu, &sel );
3304 selectionMgr()->selectedObjects( lst );
3305 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3306 Handle(SALOME_InteractiveObject) io = lst.First();
3307 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3308 _PTR(Study) study = appStudy->studyDS();
3309 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3311 QString aName = QString( obj->GetName().c_str() );
3312 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3313 aName.remove( (aName.length() - 1), 1 );
3319 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3321 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3322 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3325 void SMESHGUI::viewManagers( QStringList& list ) const
3327 list.append( SVTK_Viewer::Type() );
3330 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3332 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3333 SMESH::UpdateSelectionProp( this );
3336 void SMESHGUI::createPreferences()
3338 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3340 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3341 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3343 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3344 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3345 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3347 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3348 setPreferenceProperty( precGroup, "columns", 1 );
3350 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3352 setPreferenceProperty( prec, "min", 0 );
3353 setPreferenceProperty( prec, "max", 16 );
3355 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3356 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3358 modes.append( "Wireframe" );
3359 modes.append( "Shading" );
3360 modes.append( "Nodes" );
3361 modes.append( "Shrink" );
3362 QValueList<QVariant> indices;
3363 indices.append( 0 );
3364 indices.append( 1 );
3365 indices.append( 2 );
3366 indices.append( 3 );
3367 setPreferenceProperty( dispmode, "strings", modes );
3368 setPreferenceProperty( dispmode, "indexes", indices );
3370 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3371 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3372 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3374 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3375 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3377 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3378 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3380 setPreferenceProperty( nodeSz, "min", 1 );
3381 setPreferenceProperty( nodeSz, "max", 5 );
3383 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3385 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3386 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3387 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3388 addPreference( "", elemGroup, LightApp_Preferences::Space );
3390 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3391 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3393 setPreferenceProperty( elemW, "min", 1 );
3394 setPreferenceProperty( elemW, "max", 5 );
3396 setPreferenceProperty( shrink, "min", 0 );
3397 setPreferenceProperty( shrink, "max", 100 );
3399 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3401 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3403 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3404 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3405 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3407 setPreferenceProperty( selW, "min", 1 );
3408 setPreferenceProperty( selW, "max", 5 );
3410 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3412 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3413 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3415 setPreferenceProperty( preW, "min", 1 );
3416 setPreferenceProperty( preW, "max", 5 );
3418 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3420 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3421 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3422 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3424 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3425 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3427 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3428 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3429 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3430 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3433 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3434 fam.append( tr( "SMESH_FONT_COURIER" ) );
3435 fam.append( tr( "SMESH_FONT_TIMES" ) );
3436 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3438 setPreferenceProperty( tfont, "families", fam );
3439 setPreferenceProperty( tfont, "system", false );
3440 setPreferenceProperty( tfont, "widget_flags", wflag );
3441 setPreferenceProperty( lfont, "families", fam );
3442 setPreferenceProperty( lfont, "system", false );
3443 setPreferenceProperty( lfont, "widget_flags", wflag );
3445 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3447 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3448 setPreferenceProperty( numcol, "min", 2 );
3449 setPreferenceProperty( numcol, "max", 256 );
3451 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3452 setPreferenceProperty( numlab, "min", 2 );
3453 setPreferenceProperty( numlab, "max", 65 );
3455 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3456 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3457 QStringList orients;
3458 orients.append( tr( "SMESH_VERTICAL" ) );
3459 orients.append( tr( "SMESH_HORIZONTAL" ) );
3460 indices.clear(); indices.append( 0 ); indices.append( 1 );
3461 setPreferenceProperty( orient, "strings", orients );
3462 setPreferenceProperty( orient, "indexes", indices );
3464 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3465 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3466 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3467 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3468 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3469 setPreferenceProperty( xv, "step", 0.1 );
3470 setPreferenceProperty( xv, "min", 0.0 );
3471 setPreferenceProperty( xv, "max", 1.0 );
3472 setPreferenceProperty( yv, "step", 0.1 );
3473 setPreferenceProperty( yv, "min", 0.0 );
3474 setPreferenceProperty( yv, "max", 1.0 );
3475 setPreferenceProperty( wv, "step", 0.1 );
3476 setPreferenceProperty( wv, "min", 0.0 );
3477 setPreferenceProperty( wv, "max", 1.0 );
3478 setPreferenceProperty( hv, "min", 0.0 );
3479 setPreferenceProperty( hv, "max", 1.0 );
3480 setPreferenceProperty( hv, "step", 0.1 );
3482 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3483 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3484 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3485 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3486 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3487 setPreferenceProperty( xv, "min", 0.0 );
3488 setPreferenceProperty( xv, "max", 1.0 );
3489 setPreferenceProperty( xv, "step", 0.1 );
3490 setPreferenceProperty( xh, "min", 0.0 );
3491 setPreferenceProperty( xh, "max", 1.0 );
3492 setPreferenceProperty( xh, "step", 0.1 );
3493 setPreferenceProperty( yh, "min", 0.0 );
3494 setPreferenceProperty( yh, "max", 1.0 );
3495 setPreferenceProperty( yh, "step", 0.1 );
3496 setPreferenceProperty( wh, "min", 0.0 );
3497 setPreferenceProperty( wh, "max", 1.0 );
3498 setPreferenceProperty( wh, "step", 0.1 );
3499 setPreferenceProperty( hh, "min", 0.0 );
3500 setPreferenceProperty( hh, "max", 1.0 );
3501 setPreferenceProperty( hh, "step", 0.1 );
3504 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3506 if( sect=="SMESH" ){
3507 float sbX1,sbY1,sbW,sbH;
3508 float aTol = 1.00000009999999;
3509 std::string aWarning;
3510 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3511 if( name=="selection_object_color" || name=="selection_element_color" ||
3512 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3513 name=="selection_precision_node" || name=="selection_precision_element" ||
3514 name=="selection_precision_object")
3515 SMESH::UpdateSelectionProp( this );
3516 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3517 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3518 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3519 if(sbX1+sbW > aTol){
3520 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3523 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3524 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3527 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3528 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3529 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3530 if(sbY1+sbH > aTol){
3531 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3532 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3533 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3536 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3537 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3538 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3539 if(sbX1+sbW > aTol){
3540 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3543 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3544 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3547 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3548 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3549 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3550 if(sbY1+sbH > aTol){
3551 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3554 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3555 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3559 if(aWarning.size() != 0){
3560 aWarning += "The default values are applied instead.";
3561 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3562 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3563 QObject::tr(aWarning.c_str()),
3564 QObject::tr("SMESH_BUT_OK"));
3569 //================================================================================
3571 * \brief Update something in accordance with update flags
3572 * \param theFlags - update flags
3574 * Update viewer or/and object browser etc. in accordance with update flags ( see
3575 * LightApp_UpdateFlags enumeration ).
3577 //================================================================================
3578 void SMESHGUI::update( const int flags )
3580 if ( flags & UF_Viewer | flags & UF_Forced )
3581 SMESH::UpdateView();
3583 SalomeApp_Module::update( flags );
3586 //================================================================================
3588 * \brief Set default selection mode
3590 * SLOT called when operation commited. Sets default selection mode
3592 //================================================================================
3593 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3595 SVTK_ViewWindow* vtkWnd =
3596 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3598 vtkWnd->SetSelectionMode( ActorSelection );
3601 //================================================================================
3603 * \brief Set default selection mode
3605 * SLOT called when operation aborted. Sets default selection mode
3607 //================================================================================
3608 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3610 SVTK_ViewWindow* vtkWnd =
3611 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3613 vtkWnd->SetSelectionMode( ActorSelection );
3616 //================================================================================
3618 * \brief Creates operation with given identifier
3619 * \param id - identifier of operation to be started
3620 * \return Pointer on created operation or NULL if operation is not created
3622 * Virtual method redefined from the base class creates operation with given id.
3623 * It is called called automatically from startOperation method of base class.
3625 //================================================================================
3626 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3628 LightApp_Operation* op = 0;
3629 // to do : create operation here
3632 case 701: // Compute mesh
3633 op = new SMESHGUI_ComputeOp();
3635 case 702: // Create mesh
3636 op = new SMESHGUI_MeshOp( true, true );
3638 case 703: // Create sub-mesh
3639 op = new SMESHGUI_MeshOp( true, false );
3641 case 704: // Edit mesh/sub-mesh
3642 op = new SMESHGUI_MeshOp( false );
3644 case 806: // Create group on geom
3645 op = new SMESHGUI_GroupOnShapeOp();
3647 case 417: //convert to quadratic
3648 op = new SMESHGUI_ConvToQuadOp();
3650 case 4067: // make mesh pass through point
3651 op = new SMESHGUI_MakeNodeAtPointOp();
3658 op = SalomeApp_Module::createOperation( id );
3662 //================================================================================
3664 * \brief Stops current operations and starts a given one
3665 * \param id - The id of the operation to start
3667 //================================================================================
3669 void SMESHGUI::switchToOperation(int id)
3671 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3672 activeStudy()->abortAllOperations();
3673 startOperation( id );
3676 LightApp_Displayer* SMESHGUI::displayer()
3679 myDisplayer = new SMESHGUI_Displayer( getApp() );
3683 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3686 int aTolerance = 64;
3687 int anIterations = 0;
3693 if( anIterations % aPeriod == 0 )
3696 if( aTolerance < 1 )
3699 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3701 aHue = (int)( 360.0 * rand() / RAND_MAX );
3702 //cout << "Hue = " << aHue << endl;
3704 //cout << "Auto colors : ";
3706 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3707 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3708 for( ; it != itEnd; ++it )
3710 SALOMEDS::Color anAutoColor = *it;
3711 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3714 aQColor.getHsv( &h, &s, &v );
3716 if( abs( h - aHue ) < aTolerance )
3719 //cout << "break (diff = " << abs( h - aHue ) << ")";
3729 //cout << "Hue of the returned color = " << aHue << endl;
3731 aColor.setHsv( aHue, 255, 255 );
3733 SALOMEDS::Color aSColor;
3734 aSColor.R = (double)aColor.red() / 255.0;
3735 aSColor.G = (double)aColor.green() / 255.0;
3736 aSColor.B = (double)aColor.blue() / 255.0;