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"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_GEOMGenUtils.h"
74 #include "SMESHGUI_MeshUtils.h"
75 #include "SMESHGUI_GroupUtils.h"
76 #include "SMESHGUI_FilterUtils.h"
77 #include "SMESHGUI_PatternUtils.h"
78 #include "SMESHGUI_VTKUtils.h"
79 #include "SMESHGUI_HypothesesUtils.h"
81 #include "SMESH_Actor.h"
82 #include "SMESH_Object.h"
83 #include "SMESH_TypeFilter.hxx"
85 #include "SalomeApp_Tools.h"
86 #include "SalomeApp_Study.h"
87 #include "SalomeApp_Application.h"
88 #include "SalomeApp_CheckFileDlg.h"
89 #include "SalomeApp_ImportOperation.h"
91 #include "LightApp_DataOwner.h"
92 #include "LightApp_Preferences.h"
93 #include "LightApp_VTKSelector.h"
94 #include "LightApp_Operation.h"
95 #include "LightApp_UpdateFlags.h"
96 #include "LightApp_NameDlg.h"
98 #include <SVTK_ViewWindow.h>
99 #include <SVTK_ViewModel.h>
100 #include <SVTK_InteractorStyle.h>
101 #include <SVTK_RenderWindowInteractor.h>
102 #include <SVTK_ViewManager.h>
104 #include "OB_Browser.h"
106 #include "SUIT_Tools.h"
107 #include "SUIT_MessageBox.h"
108 #include "SUIT_ResourceMgr.h"
109 #include "SUIT_FileDlg.h"
110 #include "SUIT_Desktop.h"
111 #include "SUIT_OverrideCursor.h"
112 #include "SUIT_Study.h"
113 #include "SUIT_Session.h"
115 #include "QtxPopupMgr.h"
117 #include "SALOME_ListIO.hxx"
118 #include "SALOME_ListIteratorOfListIO.hxx"
119 #include "SALOME_InteractiveObject.hxx"
120 #include "SALOME_NamingService.hxx"
121 #include "SALOME_LifeCycleCORBA.hxx"
123 #include "SALOMEconfig.h"
124 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
128 #define INCLUDE_MENUITEM_DEF
129 #include <qpopupmenu.h>
135 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
150 #include <Standard_ErrorHandler.hxx>
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
186 QString anInitialPath = "";
187 //if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
188 // anInitialPath = QDir::currentDirPath();
190 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
193 QObject::tr("Import mesh"),
195 if(!filename.isEmpty()) {
196 SUIT_OverrideCursor wc;
197 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
200 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
201 switch ( theCommandID ) {
204 aMeshes->length( 1 );
205 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
210 SMESH::DriverMED_ReadStatus res;
211 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
212 if ( res != SMESH::DRS_OK ) {
214 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
215 QObject::tr("SMESH_WRN_WARNING"),
216 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
217 QObject::tr("SMESH_BUT_OK"));
218 aMeshes->length( 0 );
225 bool isEmpty = false;
226 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
227 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
229 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
230 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
231 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
232 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
233 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
240 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
241 QObject::tr("SMESH_WRN_WARNING"),
242 QObject::tr("SMESH_DRS_EMPTY"),
243 QObject::tr("SMESH_BUT_OK"));
247 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
249 catch (const SALOME::SALOME_Exception& S_ex){
251 SalomeApp_Tools::QtCatchCorbaException(S_ex);
258 void ExportMeshToFile( int theCommandID )
260 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
261 SALOME_ListIO selected;
263 aSel->selectedObjects( selected );
265 if(selected.Extent()){
266 Handle(SALOME_InteractiveObject) anIObject = selected.First();
267 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
268 if ( !aMesh->_is_nil() ) {
269 QString aFilter, aTitle = QObject::tr("Export mesh");
270 QMap<QString, SMESH::MED_VERSION> aFilterMap;
271 QMap<QString, int> aFilterMapSTL;
272 switch ( theCommandID ) {
276 if (aMesh->HasDuplicatedGroupNamesMED()) {
277 int aRet = SUIT_MessageBox::warn2
278 (SMESHGUI::desktop(),
279 QObject::tr("SMESH_WRN_WARNING"),
280 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
281 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
287 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
288 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
289 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
290 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
295 aFilter = QObject::tr("DAT files (*.dat)");
300 if (aMesh->NbPyramids()) {
301 int aRet = SUIT_MessageBox::warn2
302 (SMESHGUI::desktop(),
303 QObject::tr("SMESH_WRN_WARNING"),
304 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
305 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
310 aFilter = QObject::tr("IDEAS files (*.unv)");
318 there must be check on others mesh elements not equal triangles
320 if (aMesh->NbTriangles() < 1) {
321 SUIT_MessageBox::warn1
322 (SMESHGUI::desktop(),
323 QObject::tr("SMESH_WRN_WARNING"),
324 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
325 QObject::tr("SMESH_BUT_OK"));
328 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
329 int aRet = SUIT_MessageBox::warn2
330 (SMESHGUI::desktop(),
331 QObject::tr("SMESH_WRN_WARNING"),
332 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
333 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
339 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
340 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
348 SMESH::MED_VERSION aFormat;
349 // Init the parameter with the default value
350 bool aIsASCII_STL = true;
351 bool toCreateGroups = false;
352 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
354 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
356 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
358 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
360 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
362 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
363 for ( ; it != aFilterMapSTL.end(); ++it )
364 filters.push_back( it.key() );
366 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
367 fd->setCaption( aTitle );
368 fd->setFilters( filters );
369 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
373 aFilename = fd->selectedFile();
374 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
379 else { // Export to MED
381 QString aDefaultFilter;
382 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
383 for ( ; it != aFilterMap.end(); ++it ) {
384 filters.push_back( it.key() );
385 if (it.data() == SMESH::MED_V2_2)
386 aDefaultFilter = it.key();
389 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
390 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
391 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
392 fd->setCaption( aTitle );
393 fd->setFilters( filters );
394 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
395 fd->setSelectedFilter(aDefaultFilter);
396 fd->SetChecked(toCreateGroups);
400 aFilename = fd->selectedFile();
401 aFormat = aFilterMap[fd->selectedFilter()];
403 if ( !aFilename.isEmpty()
404 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
405 && aFormat==SMESH::MED_V2_1) {
406 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
407 QObject::tr("SMESH_WRN_WARNING"),
408 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
409 QObject::tr("SMESH_BUT_YES"),
410 QObject::tr("SMESH_BUT_NO"),
417 toCreateGroups = fd->IsChecked();
420 if ( !aFilename.isEmpty() ) {
421 // Check whether the file already exists and delete it if yes
422 QFile aFile( aFilename );
423 if ( aFile.exists() )
425 SUIT_OverrideCursor wc;
428 bool Renumber = false ;
429 // PAL 14172 : Check of we have to renumber or not from the preferences before export
431 Renumber= resMgr->booleanValue("SMESH","renumbering");
433 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
434 aMeshEditor->RenumberNodes();
435 aMeshEditor->RenumberElements();
436 if ( SMESHGUI::automaticUpdate() )
439 switch ( theCommandID ) {
442 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
446 aMesh->ExportDAT( aFilename.latin1() );
450 aMesh->ExportUNV( aFilename.latin1() );
454 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
460 catch (const SALOME::SALOME_Exception& S_ex){
462 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
463 QObject::tr("SMESH_WRN_WARNING"),
464 QObject::tr("SMESH_EXPORT_FAILED"),
465 QObject::tr("SMESH_BUT_OK"));
473 inline void InverseEntityMode(unsigned int& theOutputMode,
474 unsigned int theMode)
476 bool anIsNotPresent = ~theOutputMode & theMode;
478 theOutputMode |= theMode;
480 theOutputMode &= ~theMode;
483 void SetDisplayEntity(int theCommandID){
484 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
485 SALOME_ListIO selected;
487 aSel->selectedObjects( selected );
489 if(selected.Extent() >= 1){
490 SALOME_ListIteratorOfListIO It( selected );
491 for(; It.More(); It.Next()){
492 Handle(SALOME_InteractiveObject) IObject = It.Value();
493 if(IObject->hasEntry()){
494 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
495 unsigned int aMode = anActor->GetEntityMode();
496 switch(theCommandID){
498 InverseEntityMode(aMode,SMESH_Actor::eEdges);
501 InverseEntityMode(aMode,SMESH_Actor::eFaces);
504 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
507 aMode = SMESH_Actor::eAllEntity;
511 anActor->SetEntityMode(aMode);
519 SALOME_ListIO selected;
520 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
524 LightApp_SelectionMgr* aSel = app->selectionMgr();
525 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
526 if( !aSel || !appStudy )
529 aSel->selectedObjects( selected );
530 if( selected.IsEmpty() )
533 Handle(SALOME_InteractiveObject) anIObject = selected.First();
535 _PTR(Study) aStudy = appStudy->studyDS();
536 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
537 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
538 if( aMainObject->_is_nil() )
541 aMainObject->SetAutoColor( true );
543 QValueList<SALOMEDS::Color> aReservedColors;
545 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
546 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
548 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
549 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
551 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
552 aGroupObject->SetColor( aColor );
553 aReservedColors.append( aColor );
555 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
556 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
558 if( aGroupObject->GetType() == SMESH::NODE )
559 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
560 else if( aGroupObject->GetType() == SMESH::EDGE )
561 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
563 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
567 SMESH::RepaintCurrentView();
570 void DisableAutoColor(){
571 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
572 SALOME_ListIO selected;
574 aSel->selectedObjects( selected );
576 if(selected.Extent()){
577 Handle(SALOME_InteractiveObject) anIObject = selected.First();
578 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
579 if ( !aMesh->_is_nil() ) {
580 aMesh->SetAutoColor( false );
585 void SetDisplayMode(int theCommandID){
586 SALOME_ListIO selected;
587 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
591 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
592 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
593 if( !aSel || !appStudy )
596 _PTR(Study) aStudy = appStudy->studyDS();
598 aSel->selectedObjects( selected );
600 if(selected.Extent() >= 1){
601 switch(theCommandID){
603 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
604 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
608 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
609 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
612 SALOME_ListIteratorOfListIO It( selected );
613 for(; It.More(); It.Next()){
614 Handle(SALOME_InteractiveObject) IObject = It.Value();
615 if(IObject->hasEntry()){
616 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
617 switch(theCommandID){
619 anActor->SetRepresentation(SMESH_Actor::eEdge);
622 anActor->SetRepresentation(SMESH_Actor::eSurface);
625 if(anActor->IsShrunk())
628 anActor->SetShrink();
631 anActor->SetRepresentation(SMESH_Actor::ePoint);
634 vtkFloatingPointType color[3];
635 anActor->GetSufaceColor(color[0], color[1], color[2]);
636 int c0 = int (color[0] * 255);
637 int c1 = int (color[1] * 255);
638 int c2 = int (color[2] * 255);
639 QColor c(c0, c1, c2);
641 vtkFloatingPointType edgecolor[3];
642 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
643 c0 = int (edgecolor[0] * 255);
644 c1 = int (edgecolor[1] * 255);
645 c2 = int (edgecolor[2] * 255);
646 QColor e(c0, c1, c2);
648 vtkFloatingPointType backfacecolor[3];
649 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
650 c0 = int (backfacecolor[0] * 255);
651 c1 = int (backfacecolor[1] * 255);
652 c2 = int (backfacecolor[2] * 255);
653 QColor b(c0, c1, c2);
655 vtkFloatingPointType nodecolor[3];
656 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
657 c0 = int (nodecolor[0] * 255);
658 c1 = int (nodecolor[1] * 255);
659 c2 = int (nodecolor[2] * 255);
660 QColor n(c0, c1, c2);
662 int Edgewidth = (int)anActor->GetLineWidth();
665 int intValue = int(anActor->GetNodeSize());
666 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
668 SMESHGUI_Preferences_ColorDlg *aDlg =
669 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
670 aDlg->SetColor(1, c);
671 aDlg->SetColor(2, e);
672 aDlg->SetColor(3, n);
673 aDlg->SetColor(4, b);
674 aDlg->SetIntValue(1, Edgewidth);
675 aDlg->SetIntValue(2, intValue);
676 aDlg->SetIntValue(3, int(Shrink*100.));
678 QColor color = aDlg->GetColor(1);
679 QColor edgecolor = aDlg->GetColor(2);
680 QColor nodecolor = aDlg->GetColor(3);
681 QColor backfacecolor = aDlg->GetColor(4);
682 /* actor color and backface color */
683 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
684 vtkFloatingPointType (color.green()) / 255.,
685 vtkFloatingPointType (color.blue()) / 255.);
686 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
687 vtkFloatingPointType (backfacecolor.green()) / 255.,
688 vtkFloatingPointType (backfacecolor.blue()) / 255.);
691 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
692 vtkFloatingPointType (edgecolor.green()) / 255.,
693 vtkFloatingPointType (edgecolor.blue()) / 255.);
695 /* Shrink factor and size edges */
696 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
697 anActor->SetLineWidth(aDlg->GetIntValue(1));
699 /* Nodes color and size */
700 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
701 vtkFloatingPointType (nodecolor.green()) / 255.,
702 vtkFloatingPointType (nodecolor.blue()) / 255.);
703 anActor->SetNodeSize(aDlg->GetIntValue(2));
705 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
706 if( !aGroupObject->_is_nil() )
708 SALOMEDS::Color aColor;
709 aColor.R = (float)color.red() / 255.0;
710 aColor.G = (float)color.green() / 255.0;
711 aColor.B = (float)color.blue() / 255.0;
712 aGroupObject->SetColor( aColor );
722 SMESH::RepaintCurrentView();
726 void Control( int theCommandID )
728 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
729 SALOME_ListIO selected;
731 aSel->selectedObjects( selected );
733 if( !selected.IsEmpty() ){
734 Handle(SALOME_InteractiveObject) anIO = selected.First();
737 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
738 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
739 switch ( theCommandID ){
741 aTitle = QObject::tr( "LENGTH_EDGES" );
742 aControl = SMESH_Actor::eLength;
745 aTitle = QObject::tr( "LENGTH2D_EDGES" );
746 aControl = SMESH_Actor::eLength2D;
749 aTitle = QObject::tr( "FREE_EDGES" );
750 aControl = SMESH_Actor::eFreeEdges;
753 aTitle = QObject::tr( "FREE_BORDERS" );
754 aControl = SMESH_Actor::eFreeBorders;
757 aTitle = QObject::tr( "MULTI_BORDERS" );
758 aControl = SMESH_Actor::eMultiConnection;
761 aTitle = QObject::tr( "MULTI2D_BORDERS" );
762 aControl = SMESH_Actor::eMultiConnection2D;
765 aTitle = QObject::tr( "AREA_ELEMENTS" );
766 aControl = SMESH_Actor::eArea;
769 aTitle = QObject::tr( "TAPER_ELEMENTS" );
770 aControl = SMESH_Actor::eTaper;
773 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
774 aControl = SMESH_Actor::eAspectRatio;
777 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
778 aControl = SMESH_Actor::eAspectRatio3D;
781 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
782 aControl = SMESH_Actor::eMinimumAngle;
785 aTitle = QObject::tr( "WARP_ELEMENTS" );
786 aControl = SMESH_Actor::eWarping;
789 aTitle = QObject::tr( "SKEW_ELEMENTS" );
790 aControl = SMESH_Actor::eSkew;
793 aTitle = QObject::tr( "SMESH_VOLUME" );
794 aControl = SMESH_Actor::eVolume3D;
797 anActor->SetControlMode(aControl);
798 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
799 SMESH::RepaintCurrentView();
806 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
807 MeshObjectType theType,
808 const QString theInTypeName,
809 QString & theOutTypeName)
811 SMESH_TypeFilter aTypeFilter( theType );
813 if( !theIO.IsNull() )
815 entry = theIO->getEntry();
816 LightApp_DataOwner owner( entry );
817 if ( aTypeFilter.isOk( &owner )) {
818 theOutTypeName = theInTypeName;
826 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
828 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
829 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
831 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
832 CORBA::String_var anID = aSComp->GetID().c_str();
833 if (!strcmp(anID.in(),theIO->getEntry()))
839 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
840 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
841 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
842 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
843 CheckOIType ( theIO, GROUP, "Group", aTypeName )
851 QString CheckHomogeneousSelection()
853 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
854 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
855 SALOME_ListIO selected;
857 aSel->selectedObjects( selected );
859 QString RefType = CheckTypeObject(selected.First());
860 SALOME_ListIteratorOfListIO It(selected);
861 for (; It.More(); It.Next())
863 Handle(SALOME_InteractiveObject) IObject = It.Value();
864 QString Type = CheckTypeObject(IObject);
865 if (Type.compare(RefType) != 0)
866 return "Heterogeneous Selection";
873 void SMESHGUI::OnEditDelete()
875 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
876 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
877 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
879 QString aParentComponent = QString::null;
880 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
882 QString cur = anIt.Value()->getComponentDataType();
883 if( aParentComponent.isNull() )
884 aParentComponent = cur;
885 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
886 aParentComponent = "";
889 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
890 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
891 QObject::tr("ERR_ERROR"),
892 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
893 QObject::tr("BUT_OK") );
896 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
897 if (SUIT_MessageBox::warn2
898 (SMESHGUI::desktop(),
899 QObject::tr("SMESH_WRN_WARNING"),
900 QObject::tr("SMESH_REALLY_DELETE"),
901 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
904 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
905 SUIT_ViewManager* vm = anApp->activeViewManager();
906 int nbSf = vm->getViewsCount();
908 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
909 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
910 _PTR(GenericAttribute) anAttr;
911 _PTR(AttributeIOR) anIOR;
913 SALOME_ListIteratorOfListIO It(selected);
915 aStudyBuilder->NewCommand(); // There is a transaction
916 for(; It.More(); It.Next()){ // loop on selected IO's
917 Handle(SALOME_InteractiveObject) IObject = It.Value();
918 if(IObject->hasEntry()) {
919 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
921 // disable removal of "SMESH" component object
922 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
924 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
928 // put the whole hierarchy of sub-objects of the selected SO into a list and
929 // then treat them all starting from the deepest objects (at list back)
931 list< _PTR(SObject) > listSO;
932 listSO.push_back( aSO );
933 list< _PTR(SObject) >::iterator itSO = listSO.begin();
934 for ( ; itSO != listSO.end(); ++itSO ) {
935 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
936 for (it->InitEx(false); it->More(); it->Next())
937 listSO.push_back( it->Value() );
940 // treat SO's in the list starting from the back
942 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
943 for ( ; ritSO != listSO.rend(); ++ritSO ) {
944 _PTR(SObject) SO = *ritSO;
946 string anEntry = SO->GetID();
948 /** Erase graphical object **/
949 if(SO->FindAttribute(anAttr, "AttributeIOR")){
950 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
951 for(int i = 0; i < nbSf; i++){
952 SUIT_ViewWindow *sf = aViews[i];
953 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
954 SMESH::RemoveActor(sf,anActor);
959 /** Remove an object from data structures **/
960 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
961 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
962 if ( !aGroup->_is_nil() ) { // DELETE GROUP
963 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
964 aMesh->RemoveGroup( aGroup );
966 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
967 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
968 aMesh->RemoveSubMesh( aSubMesh );
970 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
972 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
975 IObject = new SALOME_InteractiveObject
976 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
977 QString objType = CheckTypeObject(IObject);
978 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
979 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
980 aStudyBuilder->RemoveObjectWithChildren( SO );
982 else {// default action: remove SObject from the study
983 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
984 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
986 aStudyBuilder->RemoveObjectWithChildren( SO );
990 } /* listSO back loop */
991 } /* IObject->hasEntry() */
993 aStudyBuilder->CommitCommand();
995 /* Clear any previous selection */
997 aSel->setSelectedObjects( l1 );
999 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1004 SMESHGUI_EXPORT CAM_Module* createModule()
1006 return new SMESHGUI();
1010 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1012 //=============================================================================
1016 //=============================================================================
1017 SMESHGUI::SMESHGUI() :
1018 SalomeApp_Module( "SMESH" )
1020 if ( CORBA::is_nil( myComponentSMESH ) )
1022 CORBA::Boolean anIsEmbeddedMode;
1023 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1026 myActiveDialogBox = 0;
1027 myFilterLibraryDlg = 0;
1031 SMESH::GetFilterManager();
1032 SMESH::GetPattern();
1034 /* load resources for all available meshers */
1035 SMESH::InitAvailableHypotheses();
1038 //=============================================================================
1042 //=============================================================================
1043 SMESHGUI::~SMESHGUI()
1045 SMESH::GetFilterManager()->Destroy();
1046 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1049 //=============================================================================
1053 //=============================================================================
1054 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1056 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1058 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1063 bool SMESHGUI::automaticUpdate()
1065 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1069 return resMgr->booleanValue( "SMESH", "auto_update", false );
1072 //=============================================================================
1076 //=============================================================================
1077 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1079 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1082 //=============================================================================
1086 //=============================================================================
1087 SMESHGUI* SMESHGUI::GetSMESHGUI()
1089 SMESHGUI* smeshMod = 0;
1090 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1093 CAM_Module* module = app->module( "Mesh" );
1094 smeshMod = dynamic_cast<SMESHGUI*>( module );
1097 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1099 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1102 _PTR(Study) aStudy = study->studyDS();
1104 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1113 Standard_EXPORT SMESHGUI* GetComponentGUI()
1115 return SMESHGUI::GetSMESHGUI();
1119 //=============================================================================
1123 //=============================================================================
1124 void SMESHGUI::SetState(int aState)
1129 //=============================================================================
1133 //=============================================================================
1134 void SMESHGUI::ResetState()
1139 //=============================================================================
1143 //=============================================================================
1144 void SMESHGUI::EmitSignalDeactivateDialog()
1146 emit SignalDeactivateActiveDialog();
1149 //=============================================================================
1153 //=============================================================================
1154 void SMESHGUI::EmitSignalStudyFrameChanged()
1156 emit SignalStudyFrameChanged();
1159 //=============================================================================
1163 //=============================================================================
1164 void SMESHGUI::EmitSignalCloseAllDialogs()
1166 emit SignalCloseAllDialogs();
1169 //=============================================================================
1173 //=============================================================================
1174 QDialog *SMESHGUI::GetActiveDialogBox()
1176 return myActiveDialogBox;
1179 //=============================================================================
1183 //=============================================================================
1184 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1186 myActiveDialogBox = (QDialog *) aDlg;
1190 //=============================================================================
1194 //=============================================================================
1195 SUIT_Desktop* SMESHGUI::desktop()
1197 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1199 return app->desktop();
1204 //=============================================================================
1208 //=============================================================================
1209 SalomeApp_Study* SMESHGUI::activeStudy()
1211 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1213 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1218 //=============================================================================
1222 //=============================================================================
1223 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1225 /* Here the position is on the bottom right corner - 10 */
1226 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1228 SUIT_Desktop *PP = desktop();
1229 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1230 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1234 //=============================================================================
1238 //=============================================================================
1239 static int isStudyLocked(_PTR(Study) theStudy){
1240 return theStudy->GetProperties()->IsLocked();
1243 static bool checkLock(_PTR(Study) theStudy) {
1244 if (isStudyLocked(theStudy)) {
1245 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1246 QObject::tr("WRN_WARNING"),
1247 QObject::tr("WRN_STUDY_LOCKED"),
1248 QObject::tr("BUT_OK") );
1254 //=======================================================================
1255 //function : CheckActiveStudyLocked
1257 //=======================================================================
1259 bool SMESHGUI::isActiveStudyLocked()
1261 _PTR(Study) aStudy = activeStudy()->studyDS();
1262 return checkLock( aStudy );
1265 //=============================================================================
1269 //=============================================================================
1270 bool SMESHGUI::OnGUIEvent( int theCommandID )
1272 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1276 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1277 SUIT_ResourceMgr* mgr = resourceMgr();
1281 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1282 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1285 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1286 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1288 //QAction* act = action( theCommandID );
1290 switch (theCommandID) {
1292 if(checkLock(aStudy)) break;
1300 if(checkLock(aStudy)) break;
1301 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1305 case 122: // EXPORT MED
1314 ::ExportMeshToFile(theCommandID);
1318 case 200: // SCALAR BAR
1320 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1321 SALOME_ListIO selected;
1323 aSel->selectedObjects( selected );
1325 if( selected.Extent() ) {
1326 Handle(SALOME_InteractiveObject) anIO = selected.First();
1327 if( anIO->hasEntry() ) {
1328 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1329 anActor->SetControlMode( SMESH_Actor::eNone );
1337 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1347 ::DisableAutoColor();
1350 case 1134: // Clipping
1351 case 1133: // Tranparency
1352 case 1132: // Colors / Size
1359 ::SetDisplayMode(theCommandID);
1365 case 219: // Volumes
1366 case 220: // All Entity
1367 ::SetDisplayEntity(theCommandID);
1372 if(checkLock(aStudy)) break;
1374 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1377 SMESH::UpdateView();
1379 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1380 SMESH::OnVisuException();
1382 catch (...) { // PAL16774 (Crash after display of many groups)
1383 SMESH::OnVisuException();
1387 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1388 aSel->selectedObjects( l );
1389 aSel->setSelectedObjects( l );
1394 case 301: // DISPLAY
1395 case 302: // DISPLAY ONLY
1397 SMESH::EDisplaing anAction;
1398 switch (theCommandID) {
1399 case 300: anAction = SMESH::eErase; break;
1400 case 301: anAction = SMESH::eDisplay; break;
1401 case 302: anAction = SMESH::eDisplayOnly; break;
1404 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1405 SALOME_ListIO sel_objects, to_process;
1407 aSel->selectedObjects( sel_objects );
1409 if( theCommandID==302 )
1410 startOperation( myEraseAll );
1412 extractContainers( sel_objects, to_process );
1415 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1419 SALOME_ListIteratorOfListIO It( to_process );
1420 for (; It.More(); It.Next()) {
1421 Handle(SALOME_InteractiveObject) IOS = It.Value();
1422 if (IOS->hasEntry()) {
1423 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1424 break; // PAL16774 (Crash after display of many groups)
1425 if (anAction == SMESH::eDisplayOnly)
1426 anAction = SMESH::eDisplay;
1431 // PAL13338 + PAL15161 -->
1432 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1433 SMESH::UpdateView();
1434 // PAL13338 + PAL15161 <--
1436 catch (...) { // PAL16774 (Crash after display of many groups)
1437 SMESH::OnVisuException();
1440 if (anAction == SMESH::eErase) {
1442 aSel->setSelectedObjects( l1 );
1445 aSel->setSelectedObjects( to_process );
1452 if(checkLock(aStudy)) break;
1455 EmitSignalDeactivateDialog();
1457 new SMESHGUI_NodesDlg(this);
1460 SUIT_MessageBox::warn1(desktop(),
1461 tr("SMESH_WRN_WARNING"),
1462 tr("SMESH_WRN_VIEWER_VTK"),
1463 tr("SMESH_BUT_OK"));
1468 case 2151: // FILTER
1472 EmitSignalDeactivateDialog();
1473 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1478 case 406: // MOVE NODE
1482 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1483 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1487 if(checkLock(aStudy)) break;
1488 new SMESHGUI_MoveNodesDlg(this);
1492 case 701: // COMPUTE MESH
1494 if (checkLock(aStudy)) break;
1496 startOperation( 701 );
1500 case 702: // Create mesh
1501 startOperation( 702 );
1503 case 703: // Create sub-mesh
1504 startOperation( 703 );
1506 case 704: // Edit mesh/sub-mesh
1507 startOperation( 704 );
1509 case 710: // Build compound mesh
1511 if (checkLock(aStudy)) break;
1512 EmitSignalDeactivateDialog();
1513 new SMESHGUI_BuildCompoundDlg( this );
1517 case 407: // DIAGONAL INVERSION
1518 case 408: // Delete diagonal
1522 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1523 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1527 if ( checkLock( aStudy ) )
1530 /*Standard_Boolean aRes;
1531 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1532 if ( aMesh->_is_nil() )
1534 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1535 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1539 EmitSignalDeactivateDialog();
1540 if ( theCommandID == 407 )
1541 new SMESHGUI_TrianglesInversionDlg(this);
1543 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1546 case 409: // Change orientation
1547 case 410: // Union of triangles
1548 case 411: // Cutting of quadrangles
1552 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1553 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1557 if ( checkLock( aStudy ) )
1560 EmitSignalDeactivateDialog();
1561 SMESHGUI_MultiEditDlg* aDlg = NULL;
1562 if ( theCommandID == 409 )
1563 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1564 else if ( theCommandID == 410 )
1565 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1567 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1572 case 412: // Smoothing
1574 if(checkLock(aStudy)) break;
1576 EmitSignalDeactivateDialog();
1577 new SMESHGUI_SmoothingDlg( this );
1580 SUIT_MessageBox::warn1(desktop(),
1581 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1582 tr("SMESH_BUT_OK"));
1586 case 413: // Extrusion
1588 if (checkLock(aStudy)) break;
1590 EmitSignalDeactivateDialog();
1591 new SMESHGUI_ExtrusionDlg ( this );
1593 SUIT_MessageBox::warn1(desktop(),
1594 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1595 tr("SMESH_BUT_OK"));
1599 case 414: // Revolution
1601 if(checkLock(aStudy)) break;
1603 EmitSignalDeactivateDialog();
1604 new SMESHGUI_RevolutionDlg( this );
1607 SUIT_MessageBox::warn1(desktop(),
1608 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1609 tr("SMESH_BUT_OK"));
1613 case 415: // Pattern mapping
1615 if ( checkLock( aStudy ) )
1619 EmitSignalDeactivateDialog();
1620 new SMESHGUI_MeshPatternDlg( this );
1623 SUIT_MessageBox::warn1(desktop(),
1624 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1625 tr("SMESH_BUT_OK"));
1629 case 416: // Extrusion along a path
1631 if (checkLock(aStudy)) break;
1633 EmitSignalDeactivateDialog();
1634 new SMESHGUI_ExtrusionAlongPathDlg( this );
1636 SUIT_MessageBox::warn1(desktop(),
1637 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1638 tr("SMESH_BUT_OK"));
1642 case 417: // Convert mesh to quadratic
1644 startOperation( 417 );
1645 /* if (checkLock(aStudy)) break;
1647 EmitSignalDeactivateDialog();
1648 new SMESHGUI_ConvToQuadDlg();
1650 SUIT_MessageBox::warn1(desktop(),
1651 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1652 tr("SMESH_BUT_OK"));
1656 case 801: // CREATE GROUP
1660 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1661 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1665 if(checkLock(aStudy)) break;
1666 EmitSignalDeactivateDialog();
1667 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1669 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1670 SALOME_ListIO selected;
1672 aSel->selectedObjects( selected );
1674 int nbSel = selected.Extent();
1676 // check if mesh is selected
1677 aMesh = SMESH::GetMeshByIO( selected.First() );
1679 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1684 case 802: // CONSTRUCT GROUP
1688 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1689 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1693 if(checkLock(aStudy)) break;
1694 EmitSignalDeactivateDialog();
1696 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1697 SALOME_ListIO selected;
1699 aSel->selectedObjects( selected );
1701 int nbSel = selected.Extent();
1703 // check if submesh is selected
1704 Handle(SALOME_InteractiveObject) IObject = selected.First();
1705 if (IObject->hasEntry()) {
1706 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1708 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1709 if (!aSubMesh->_is_nil()) {
1711 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1712 // get submesh elements list by types
1713 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1714 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1715 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1716 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1717 // create group for each type o elements
1718 QString aName = IObject->getName();
1719 if (aNodes->length() > 0) {
1720 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1721 aGroup->Add(aNodes.inout());
1723 if (aEdges->length() > 0) {
1724 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1725 aGroup->Add(aEdges.inout());
1727 if (aFaces->length() > 0) {
1728 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1729 aGroup->Add(aFaces.inout());
1731 if (aVolumes->length() > 0) {
1732 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1733 aGroup->Add(aVolumes.inout());
1738 catch(const SALOME::SALOME_Exception & S_ex){
1739 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1746 SUIT_MessageBox::warn1(desktop(),
1747 tr("SMESH_WRN_WARNING"),
1748 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1749 tr("SMESH_BUT_OK"));
1754 case 803: // EDIT GROUP
1758 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1759 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1763 if(checkLock(aStudy)) break;
1764 EmitSignalDeactivateDialog();
1766 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1767 SALOME_ListIO selected;
1769 aSel->selectedObjects( selected );
1771 SALOME_ListIteratorOfListIO It (selected);
1772 int nbSelectedGroups = 0;
1773 for ( ; It.More(); It.Next() )
1775 SMESH::SMESH_GroupBase_var aGroup =
1776 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1777 if (!aGroup->_is_nil()) {
1779 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1783 if (nbSelectedGroups == 0)
1785 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1791 case 804: // Add elements to group
1793 if(checkLock(aStudy)) break;
1794 if (myState == 800) {
1795 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1796 if (aDlg) aDlg->onAdd();
1801 case 805: // Remove elements from group
1803 if(checkLock(aStudy)) break;
1804 if (myState == 800) {
1805 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1806 if (aDlg) aDlg->onRemove();
1811 case 810: // Union Groups
1812 case 811: // Intersect groups
1813 case 812: // Cut groups
1817 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1818 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1822 if ( checkLock( aStudy ) )
1825 EmitSignalDeactivateDialog();
1828 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1829 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1830 else aMode = SMESHGUI_GroupOpDlg::CUT;
1832 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1836 case 813: // Delete groups with their contents
1840 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1841 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1845 if ( checkLock( aStudy ) )
1848 EmitSignalDeactivateDialog();
1850 new SMESHGUI_DeleteGroupDlg( this );
1854 case 900: // MESH INFOS
1856 EmitSignalDeactivateDialog();
1857 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1858 SALOME_ListIO selected;
1860 aSel->selectedObjects( selected );
1862 if ( selected.Extent() > 1 ) { // a dlg for each IO
1864 SALOME_ListIteratorOfListIO It (selected);
1865 for ( ; It.More(); It.Next() ) {
1866 IOs.Clear(); IOs.Append( It.Value() );
1867 aSel->setSelectedObjects( IOs );
1868 new SMESHGUI_MeshInfosDlg(this, "", false);
1870 // restore selection
1871 aSel->setSelectedObjects( selected );
1874 new SMESHGUI_MeshInfosDlg(this, "", false);
1878 case 902: // STANDARD MESH INFOS
1880 EmitSignalDeactivateDialog();
1881 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1882 SALOME_ListIO selected;
1884 aSel->selectedObjects( selected );
1886 if ( selected.Extent() > 1 ) { // a dlg for each IO
1888 SALOME_ListIteratorOfListIO It (selected);
1889 for ( ; It.More(); It.Next() ) {
1891 IOs.Append( It.Value() );
1892 aSel->setSelectedObjects( IOs );
1893 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1895 // restore selection
1896 aSel->setSelectedObjects( selected );
1899 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1903 case 903: // WHAT IS
1905 EmitSignalDeactivateDialog();
1906 new SMESHGUI_WhatIsDlg( this, "", false);
1910 case 1100: // EDIT HYPOTHESIS
1912 if(checkLock(aStudy)) break;
1914 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1915 SALOME_ListIO selected;
1917 aSel->selectedObjects( selected );
1919 int nbSel = selected.Extent();
1922 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1923 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1925 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1926 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1927 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1928 if ( !aHypothesis->_is_nil() )
1930 CORBA::String_var aHypType = aHypothesis->GetName();
1931 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1933 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1940 updateObjBrowser( true );
1944 case 1101: // RENAME
1946 if ( checkLock( aStudy ) )
1949 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1950 SALOME_ListIO selected;
1952 aSel->selectedObjects( selected );
1954 bool isAny = false; // iss there any appropriate object selected
1956 SALOME_ListIteratorOfListIO It( selected );
1957 for ( ; It.More(); It.Next() )
1959 Handle(SALOME_InteractiveObject) IObject = It.Value();
1960 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1961 _PTR(GenericAttribute) anAttr;
1962 _PTR(AttributeName) aName;
1965 if ( obj->FindAttribute(anAttr, "AttributeName") )
1968 QString newName = QString(aName->Value().c_str());
1970 // check type to prevent renaming of inappropriate objects
1971 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
1972 if (aType == MESH || aType == GROUP ||
1973 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
1974 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
1975 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
1976 aType == HYPOTHESIS || aType == ALGORITHM)
1979 newName = LightApp_NameDlg::getName(desktop(), newName);
1980 if ( !newName.isEmpty() )
1982 //old source: aStudy->renameIObject( IObject, newName );
1983 aName->SetValue( newName.latin1() );
1985 // if current object is group update group's name
1986 SMESH::SMESH_GroupBase_var aGroup =
1987 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1988 if (!aGroup->_is_nil() )
1989 aGroup->SetName( newName.latin1() );
1999 SUIT_MessageBox::warn1(desktop(),
2000 QObject::tr("SMESH_WRN_WARNING"),
2001 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2002 QObject::tr("SMESH_BUT_OK"));
2007 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2009 if(checkLock(aStudy)) break;
2010 SUIT_OverrideCursor wc;
2012 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2013 SALOME_ListIO selected;
2015 aSel->selectedObjects( selected, QString::null, false );
2017 SALOME_ListIteratorOfListIO It(selected);
2018 for (int i = 0; It.More(); It.Next(), i++) {
2019 Handle(SALOME_InteractiveObject) IObject = It.Value();
2020 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2023 aSel->setSelectedObjects( l1 );
2028 case 401: // GEOM::EDGE
2029 case 4021: // TRIANGLE
2031 case 4023: // POLYGON
2035 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2038 SMDSAbs_ElementType type = SMDSAbs_Edge;
2040 switch (theCommandID) {
2041 case 4021: // TRIANGLE
2042 type = SMDSAbs_Face; nbNodes = 3; break;
2044 type = SMDSAbs_Face; nbNodes = 4; break;
2046 type = SMDSAbs_Volume; nbNodes = 4; break;
2047 case 4023: // POLYGON
2048 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2050 type = SMDSAbs_Volume; nbNodes = 8; break;
2051 case 4033: // POLYHEDRE
2052 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2055 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2058 SUIT_MessageBox::warn1(desktop(),
2059 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2060 tr("SMESH_BUT_OK"));
2064 case 4033: // POLYHEDRON
2066 if(checkLock(aStudy)) break;
2068 EmitSignalDeactivateDialog();
2069 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2072 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2073 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2074 tr("SMESH_BUT_OK"));
2078 case 4034: // QUADRATIC EDGE
2079 case 4035: // QUADRATIC TRIANGLE
2080 case 4036: // QUADRATIC QUADRANGLE
2081 case 4037: // QUADRATIC TETRAHEDRON
2082 case 4038: // QUADRATIC PYRAMID
2083 case 4039: // QUADRATIC PENTAHEDRON
2084 case 4040: // QUADRATIC HEXAHEDRON
2086 if(checkLock(aStudy)) break;
2088 EmitSignalDeactivateDialog();
2091 switch (theCommandID) {
2093 type = QUAD_EDGE; break;
2095 type = QUAD_TRIANGLE; break;
2097 type = QUAD_QUADRANGLE; break;
2099 type = QUAD_TETRAHEDRON; break;
2101 type = QUAD_PYRAMID; break;
2103 type = QUAD_PENTAHEDRON; break;
2105 type = QUAD_HEXAHEDRON;
2109 new SMESHGUI_AddQuadraticElementDlg( this, type );
2112 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2113 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2114 tr("SMESH_BUT_OK"));
2118 case 4041: // REMOVES NODES
2120 if(checkLock(aStudy)) break;
2122 EmitSignalDeactivateDialog();
2123 new SMESHGUI_RemoveNodesDlg(this);
2126 SUIT_MessageBox::warn1(desktop(),
2127 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2128 tr("SMESH_BUT_OK"));
2132 case 4042: // REMOVES ELEMENTS
2134 if(checkLock(aStudy)) break;
2136 EmitSignalDeactivateDialog();
2137 new SMESHGUI_RemoveElementsDlg(this);
2141 SUIT_MessageBox::warn1(desktop(),
2142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2143 tr("SMESH_BUT_OK"));
2147 case 4043: { // CLEAR_MESH
2149 if(checkLock(aStudy)) break;
2151 SALOME_ListIO selected;
2152 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2153 aSel->selectedObjects( selected );
2155 SUIT_OverrideCursor wc;
2156 SALOME_ListIteratorOfListIO It (selected);
2157 for ( ; It.More(); It.Next() )
2159 Handle(SALOME_InteractiveObject) IOS = It.Value();
2160 SMESH::SMESH_Mesh_var aMesh =
2161 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2162 if ( aMesh->_is_nil()) continue;
2164 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2166 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2167 SMESH::ModifiedMesh( aMeshSObj, false, true);
2169 catch (const SALOME::SALOME_Exception& S_ex){
2171 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2175 SMESH::UpdateView();
2179 case 4051: // RENUMBERING NODES
2181 if(checkLock(aStudy)) break;
2183 EmitSignalDeactivateDialog();
2184 new SMESHGUI_RenumberingDlg( this, "", 0);
2188 SUIT_MessageBox::warn1(desktop(),
2189 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2190 tr("SMESH_BUT_OK"));
2194 case 4052: // RENUMBERING ELEMENTS
2196 if(checkLock(aStudy)) break;
2198 EmitSignalDeactivateDialog();
2199 new SMESHGUI_RenumberingDlg( this, "", 1);
2203 SUIT_MessageBox::warn1(desktop(),
2204 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2205 tr("SMESH_BUT_OK"));
2209 case 4061: // TRANSLATION
2211 if(checkLock(aStudy)) break;
2213 EmitSignalDeactivateDialog();
2214 new SMESHGUI_TranslationDlg( this );
2217 SUIT_MessageBox::warn1(desktop(),
2218 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2219 tr("SMESH_BUT_OK"));
2223 case 4062: // ROTATION
2225 if(checkLock(aStudy)) break;
2227 EmitSignalDeactivateDialog();
2228 new SMESHGUI_RotationDlg( this );
2231 SUIT_MessageBox::warn1(desktop(),
2232 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2233 tr("SMESH_BUT_OK"));
2237 case 4063: // SYMMETRY
2239 if(checkLock(aStudy)) break;
2241 EmitSignalDeactivateDialog();
2242 new SMESHGUI_SymmetryDlg( this );
2245 SUIT_MessageBox::warn1(desktop(),
2246 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2247 tr("SMESH_BUT_OK"));
2251 case 4064: // SEWING
2253 if(checkLock(aStudy)) break;
2255 EmitSignalDeactivateDialog();
2256 new SMESHGUI_SewingDlg( this );
2259 SUIT_MessageBox::warn1(desktop(),
2260 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2261 tr("SMESH_BUT_OK"));
2265 case 4065: // MERGE NODES
2267 if(checkLock(aStudy)) break;
2269 EmitSignalDeactivateDialog();
2270 new SMESHGUI_EditMeshDlg( this, 0 );
2273 SUIT_MessageBox::warn1(desktop(),
2274 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2275 tr("SMESH_BUT_OK"));
2279 case 4066: // MERGE EQUAL ELEMENTS
2281 if (checkLock(aStudy)) break;
2283 EmitSignalDeactivateDialog();
2284 new SMESHGUI_EditMeshDlg( this, 1 );
2286 SUIT_MessageBox::warn1(desktop(),
2287 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2288 tr("SMESH_BUT_OK"));
2293 case 4067: // MAKE MESH PASS THROUGH POINT
2294 startOperation( 4067 );
2297 case 5105: // Library of selection filters
2299 static QValueList<int> aTypes;
2300 if ( aTypes.isEmpty() )
2302 aTypes.append( SMESH::NODE );
2303 aTypes.append( SMESH::EDGE );
2304 aTypes.append( SMESH::FACE );
2305 aTypes.append( SMESH::VOLUME );
2307 if (!myFilterLibraryDlg)
2308 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2309 else if (myFilterLibraryDlg->isHidden())
2310 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2311 myFilterLibraryDlg->raise();
2315 case 6017: // CONTROLS
2331 LightApp_SelectionMgr* mgr = selectionMgr();
2332 SALOME_ListIO selected; mgr->selectedObjects( selected );
2334 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2335 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2337 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2338 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2339 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2340 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2341 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2342 ::Control( theCommandID );
2347 SUIT_MessageBox::warn1(desktop(),
2348 tr( "SMESH_WRN_WARNING" ),
2349 tr( "SMESH_BAD_SELECTION" ),
2350 tr( "SMESH_BUT_OK" ) );
2354 SUIT_MessageBox::warn1(desktop(),
2355 tr( "SMESH_WRN_WARNING" ),
2356 tr( "NOT_A_VTK_VIEWER" ),
2357 tr( "SMESH_BUT_OK" ) );
2362 LightApp_SelectionMgr* mgr = selectionMgr();
2363 SALOME_ListIO selected; mgr->selectedObjects( selected );
2365 SALOME_ListIteratorOfListIO it(selected);
2366 for(; it.More(); it.Next()) {
2367 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2368 if(anIObject->hasEntry()) {
2369 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2370 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2378 LightApp_SelectionMgr* mgr = selectionMgr();
2379 SALOME_ListIO selected; mgr->selectedObjects( selected );
2381 if (selected.Extent() == 1) {
2382 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2383 if(anIObject->hasEntry())
2384 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2385 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2392 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2393 //updateObjBrowser();
2397 //=============================================================================
2401 //=============================================================================
2402 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2407 //=============================================================================
2411 //=============================================================================
2412 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2417 //=============================================================================
2421 //=============================================================================
2422 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2427 //=============================================================================
2428 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2429 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2431 //=============================================================================
2432 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2433 SUIT_ViewWindow* wnd )
2435 if(theIO->hasEntry()){
2436 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2437 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2441 //=======================================================================
2442 // function : createSMESHAction
2444 //=======================================================================
2445 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2448 QWidget* parent = application()->desktop();
2449 SUIT_ResourceMgr* resMgr = resourceMgr();
2451 if ( icon_id.length() )
2452 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2454 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2455 if ( !pix.isNull() )
2456 icon = QIconSet( pix );
2458 QString tooltip = tr( QString( "TOP_" )+po_id ),
2459 menu = tr( QString( "MEN_" )+po_id ),
2460 status_bar = tr( QString( "STB_" )+po_id );
2462 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2465 //=======================================================================
2466 // function : createPopupItem
2468 //=======================================================================
2469 void SMESHGUI::createPopupItem( const int id,
2470 const QString& clients,
2471 const QString& types,
2472 const QString& theRule,
2477 parentId = popupMgr()->actionId( action( pId ) );
2479 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2480 popupMgr()->insert( action( id ), parentId, 0 );
2482 QChar lc = QtxPopupMgr::Selection::defEquality();
2483 QString rule = "(%1) and (%2) and (%3)";
2484 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2485 if( clients.isEmpty() )
2486 rule = rule.arg( QString( "true" ) );
2488 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2489 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2492 bool cont = myRules.contains( id );
2494 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2496 popupMgr()->setRule( action( id ), rule, true );
2497 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2500 //=======================================================================
2501 // function : initialize
2503 //=======================================================================
2504 void SMESHGUI::initialize( CAM_Application* app )
2506 SalomeApp_Module::initialize( app );
2508 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2510 /* Automatic Update flag */
2511 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2513 // ----- create actions --------------
2515 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2516 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2517 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2518 createSMESHAction( 114, "NUM" );
2519 createSMESHAction( 121, "DAT" );
2520 createSMESHAction( 122, "MED" );
2521 createSMESHAction( 123, "UNV" );
2522 createSMESHAction( 140, "STL" );
2523 createSMESHAction( 124, "EXPORT_DAT" );
2524 createSMESHAction( 125, "EXPORT_MED" );
2525 createSMESHAction( 126, "EXPORT_UNV" );
2526 createSMESHAction( 141, "EXPORT_STL" );
2527 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2528 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2529 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2530 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2531 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2532 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2533 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2534 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2535 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2536 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2537 createSMESHAction( 804, "ADD" );
2538 createSMESHAction( 805, "REMOVE" );
2539 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2540 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2541 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2542 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2543 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2544 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2545 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2546 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2547 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2548 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2549 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2550 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2551 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2552 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2553 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2554 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2555 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2556 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2557 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2558 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2559 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2560 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2561 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2562 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2563 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2564 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2565 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2566 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2567 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2568 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2569 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2570 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2571 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2572 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2573 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2574 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2575 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2576 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2577 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2578 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2579 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2580 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2581 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2582 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2583 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2584 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2585 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2586 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2587 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2588 createSMESHAction( 415, "MAP", "ICON_MAP" );
2589 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2590 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2591 createSMESHAction( 200, "RESET" );
2592 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2593 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2594 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2595 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2596 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2597 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2598 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2599 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2600 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2601 createSMESHAction( 220, "ALL" );
2602 createSMESHAction( 1100, "EDIT_HYPO" );
2603 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2604 createSMESHAction( 1102, "UNASSIGN" );
2605 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2606 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2607 createSMESHAction( 1131, "DISPMODE" );
2608 createSMESHAction( 1132, "COLORS" );
2609 createSMESHAction( 1133, "TRANSP" );
2610 createSMESHAction( 1134, "CLIP" );
2611 createSMESHAction( 1135, "DISP_ENT" );
2612 createSMESHAction( 1136, "AUTO_COLOR" );
2613 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2614 createSMESHAction( 2000, "CTRL" );
2616 createSMESHAction( 300, "ERASE" );
2617 createSMESHAction( 301, "DISPLAY" );
2618 createSMESHAction( 302, "DISPLAY_ONLY" );
2619 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2620 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2621 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2622 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2623 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2624 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2625 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2626 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2628 // ----- create menu --------------
2629 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2630 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2631 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2632 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2633 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2634 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2635 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2637 createMenu( separator(), fileId );
2639 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2640 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2641 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2642 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2643 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2644 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2646 createMenu( 111, importId, -1 );
2647 createMenu( 112, importId, -1 );
2648 createMenu( 113, importId, -1 );
2650 createMenu( 121, exportId, -1 );
2651 createMenu( 122, exportId, -1 );
2652 createMenu( 123, exportId, -1 );
2653 createMenu( 140, exportId, -1 ); // export to stl STL
2655 createMenu( separator(), fileId, 10 );
2657 createMenu( 33, editId, -1 );
2659 createMenu( 5105, toolsId, -1 );
2661 createMenu( 702, meshId, -1 ); // "Mesh" menu
2662 createMenu( 703, meshId, -1 );
2663 createMenu( 704, meshId, -1 );
2664 createMenu( 710, meshId, -1 );
2665 createMenu( separator(), meshId, -1 );
2666 createMenu( 701, meshId, -1 );
2667 createMenu( separator(), meshId, -1 );
2668 createMenu( 801, meshId, -1 );
2669 createMenu( 802, meshId, -1 );
2670 createMenu( 803, meshId, -1 );
2671 createMenu( separator(), meshId, -1 );
2672 createMenu( 810, meshId, -1 );
2673 createMenu( 811, meshId, -1 );
2674 createMenu( 812, meshId, -1 );
2675 createMenu( separator(), meshId, -1 );
2676 createMenu( 813, meshId, -1 );
2677 createMenu( separator(), meshId, -1 );
2678 createMenu( 900, meshId, -1 );
2679 createMenu( 902, meshId, -1 );
2680 createMenu( 903, meshId, -1 );
2681 createMenu( separator(), meshId, -1 );
2683 createMenu( 6003, ctrlId, -1 );
2684 createMenu( 6001, ctrlId, -1 );
2685 createMenu( 6004, ctrlId, -1 );
2686 createMenu( separator(), ctrlId, -1 );
2687 createMenu( 6002, ctrlId, -1 );
2688 createMenu( 6018, ctrlId, -1 );
2689 createMenu( 6019, ctrlId, -1 );
2690 createMenu( 6011, ctrlId, -1 );
2691 createMenu( 6012, ctrlId, -1 );
2692 createMenu( 6013, ctrlId, -1 );
2693 createMenu( 6014, ctrlId, -1 );
2694 createMenu( 6015, ctrlId, -1 );
2695 createMenu( 6016, ctrlId, -1 );
2696 createMenu( separator(), ctrlId, -1 );
2697 createMenu( 6017, ctrlId, -1 );
2698 createMenu( 6009, ctrlId, -1 );
2699 createMenu( separator(), ctrlId, -1 );
2701 createMenu( 400, addId, -1 );
2702 createMenu( 401, addId, -1 );
2703 createMenu( 4021, addId, -1 );
2704 createMenu( 4022, addId, -1 );
2705 createMenu( 4023, addId, -1 );
2706 createMenu( 4031, addId, -1 );
2707 createMenu( 4032, addId, -1 );
2708 createMenu( 4033, addId, -1 );
2709 createMenu( separator(), addId, -1 );
2710 createMenu( 4034, addId, -1 );
2711 createMenu( 4035, addId, -1 );
2712 createMenu( 4036, addId, -1 );
2713 createMenu( 4037, addId, -1 );
2714 createMenu( 4038, addId, -1 );
2715 createMenu( 4039, addId, -1 );
2716 createMenu( 4040, addId, -1 );
2718 createMenu( 4041, removeId, -1 );
2719 createMenu( 4042, removeId, -1 );
2720 createMenu( 4043, removeId, -1 );
2722 createMenu( 4051, renumId, -1 );
2723 createMenu( 4052, renumId, -1 );
2725 createMenu( 4061, transfId, -1 );
2726 createMenu( 4062, transfId, -1 );
2727 createMenu( 4063, transfId, -1 );
2728 createMenu( 4064, transfId, -1 );
2729 createMenu( 4065, transfId, -1 );
2730 createMenu( 4066, transfId, -1 );
2732 createMenu( 406, modifyId, -1 );
2733 createMenu( 4067,modifyId, -1 );
2734 createMenu( 407, modifyId, -1 );
2735 createMenu( 408, modifyId, -1 );
2736 createMenu( 409, modifyId, -1 );
2737 createMenu( 410, modifyId, -1 );
2738 createMenu( 411, modifyId, -1 );
2739 createMenu( 412, modifyId, -1 );
2740 createMenu( 413, modifyId, -1 );
2741 createMenu( 416, modifyId, -1 );
2742 createMenu( 414, modifyId, -1 );
2743 createMenu( 415, modifyId, -1 );
2744 createMenu( 417, modifyId, -1 );
2746 createMenu( 214, viewId, -1 );
2748 // ----- create toolbars --------------
2749 int meshTb = createTool( tr( "TB_MESH" ) ),
2750 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2751 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2752 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2753 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2755 createTool( 702, meshTb );
2756 createTool( 703, meshTb );
2757 createTool( 704, meshTb );
2758 createTool( 710, meshTb );
2759 createTool( separator(), meshTb );
2760 createTool( 701, meshTb );
2761 createTool( separator(), meshTb );
2762 createTool( 801, meshTb );
2763 createTool( 802, meshTb );
2764 createTool( 803, meshTb );
2765 createTool( separator(), meshTb );
2766 createTool( 900, meshTb );
2767 createTool( 902, meshTb );
2768 createTool( 903, meshTb );
2769 createTool( separator(), meshTb );
2771 createTool( 6001, ctrlTb );
2772 createTool( 6003, ctrlTb );
2773 createTool( 6004, ctrlTb );
2774 createTool( separator(), ctrlTb );
2775 createTool( 6002, ctrlTb );
2776 createTool( 6018, ctrlTb );
2777 createTool( 6019, ctrlTb );
2778 createTool( 6011, ctrlTb );
2779 createTool( 6012, ctrlTb );
2780 createTool( 6013, ctrlTb );
2781 createTool( 6014, ctrlTb );
2782 createTool( 6015, ctrlTb );
2783 createTool( 6016, ctrlTb );
2784 createTool( separator(), ctrlTb );
2785 createTool( 6017, ctrlTb );
2786 createTool( 6009, ctrlTb );
2787 createTool( separator(), ctrlTb );
2789 createTool( 400, addRemTb );
2790 createTool( 401, addRemTb );
2791 createTool( 4021, addRemTb );
2792 createTool( 4022, addRemTb );
2793 createTool( 4023, addRemTb );
2794 createTool( 4031, addRemTb );
2795 createTool( 4032, addRemTb );
2796 createTool( 4033, addRemTb );
2797 createTool( separator(), addRemTb );
2798 createTool( 4034, addRemTb );
2799 createTool( 4035, addRemTb );
2800 createTool( 4036, addRemTb );
2801 createTool( 4037, addRemTb );
2802 createTool( 4038, addRemTb );
2803 createTool( 4039, addRemTb );
2804 createTool( 4040, addRemTb );
2805 createTool( separator(), addRemTb );
2806 createTool( 4041, addRemTb );
2807 createTool( 4042, addRemTb );
2808 createTool( 4043, addRemTb );
2809 createTool( separator(), addRemTb );
2810 createTool( 4051, addRemTb );
2811 createTool( 4052, addRemTb );
2812 createTool( separator(), addRemTb );
2813 createTool( 4061, addRemTb );
2814 createTool( 4062, addRemTb );
2815 createTool( 4063, addRemTb );
2816 createTool( 4064, addRemTb );
2817 createTool( 4065, addRemTb );
2818 createTool( 4066, addRemTb );
2819 createTool( separator(), addRemTb );
2821 createTool( 406, modifyTb );
2822 createTool( 4067,modifyTb );
2823 createTool( 407, modifyTb );
2824 createTool( 408, modifyTb );
2825 createTool( 409, modifyTb );
2826 createTool( 410, modifyTb );
2827 createTool( 411, modifyTb );
2828 createTool( 412, modifyTb );
2829 createTool( 413, modifyTb );
2830 createTool( 416, modifyTb );
2831 createTool( 414, modifyTb );
2832 createTool( 415, modifyTb );
2833 createTool( 417, modifyTb );
2835 createTool( 214, dispModeTb );
2839 QString OB = "'ObjectBrowser'",
2840 View = "'" + SVTK_Viewer::Type() + "'",
2842 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2843 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2844 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2845 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2846 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2847 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2848 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2849 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2850 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2851 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2852 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2854 mesh_group = mesh + " " + subMesh + " " + group,
2855 hyp_alg = hypo + " " + algo;
2857 // popup for object browser
2859 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2860 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2861 createPopupItem( 803, OB, group ); // EDIT_GROUP
2862 popupMgr()->insert( separator(), -1, 0 );
2863 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2864 createPopupItem( 214, OB, mesh_group ); // UPDATE
2865 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2866 createPopupItem( 902, OB, mesh ); // STD_INFO
2867 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2868 popupMgr()->insert( separator(), -1, 0 );
2869 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2870 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2871 popupMgr()->insert( separator(), -1, 0 );
2872 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2873 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2874 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2875 popupMgr()->insert( separator(), -1, 0 );
2876 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2877 popupMgr()->insert( separator(), -1, 0 );
2879 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2880 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2882 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2883 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2884 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2885 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2886 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2887 popupMgr()->insert( separator(), -1, 0 );
2890 createPopupItem( 803, View, group ); // EDIT_GROUP
2891 createPopupItem( 804, View, elems ); // ADD
2892 createPopupItem( 805, View, elems ); // REMOVE
2893 popupMgr()->insert( separator(), -1, 0 );
2894 createPopupItem( 214, View, mesh_group ); // UPDATE
2895 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2896 createPopupItem( 902, View, mesh ); // STD_INFO
2897 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2898 popupMgr()->insert( separator(), -1, 0 );
2900 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2901 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2902 popupMgr()->insert( separator(), -1, 0 );
2906 isInvisible("not( isVisible )"),
2907 isEmpty("numberOfNodes = 0"),
2908 isNotEmpty("numberOfNodes <> 0"),
2910 // has nodes, edges, etc in VISIBLE! actor
2911 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2912 hasElems("(count( elemTypes ) > 0)"),
2913 hasDifferentElems("(count( elemTypes ) > 1)"),
2914 hasEdges("({'Edge'} in elemTypes)"),
2915 hasFaces("({'Face'} in elemTypes)"),
2916 hasVolumes("({'Volume'} in elemTypes)");
2918 QString lc = QtxPopupMgr::Selection::defEquality();
2919 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2920 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2921 aType = aType.arg( mesh_group );
2922 QString aMeshInVTK = aClient + "&&" + aType;
2924 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2925 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2926 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2928 //-------------------------------------------------
2930 //-------------------------------------------------
2931 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2933 popupMgr()->insert( action( 9010 ), anId, -1 );
2934 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2935 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2937 popupMgr()->insert( action( 9011 ), anId, -1 );
2938 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2939 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2941 popupMgr()->insert( separator(), -1, -1 );
2943 //-------------------------------------------------
2945 //-------------------------------------------------
2946 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2948 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2949 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2950 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2952 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2953 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2954 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2956 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2957 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2958 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2960 popupMgr()->insert( separator(), anId, -1 );
2962 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2963 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2964 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2966 //-------------------------------------------------
2968 //-------------------------------------------------
2969 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2971 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2973 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2974 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2975 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2977 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2978 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2979 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2981 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2982 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2983 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2985 popupMgr()->insert( separator(), anId, -1 );
2987 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2988 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2990 //-------------------------------------------------
2992 //-------------------------------------------------
2993 popupMgr()->insert( action( 1132 ), -1, -1 );
2994 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2996 //-------------------------------------------------
2998 //-------------------------------------------------
2999 popupMgr()->insert( action( 1133 ), -1, -1 );
3000 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3002 //-------------------------------------------------
3004 //-------------------------------------------------
3005 popupMgr()->insert( action( 1134 ), -1, -1 );
3006 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3008 popupMgr()->insert( separator(), -1, -1 );
3010 //-------------------------------------------------
3012 //-------------------------------------------------
3014 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3015 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3016 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3018 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3020 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3021 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3023 popupMgr()->insert( separator(), anId, -1 );
3025 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3026 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3027 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3029 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3030 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3031 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3033 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3034 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3035 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3037 popupMgr()->insert( separator(), anId, -1 );
3039 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3040 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3041 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3043 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3044 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3045 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3047 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3048 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3049 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3051 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3052 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3053 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3055 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3056 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3057 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3059 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3060 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3061 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3063 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3064 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3065 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3067 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3068 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3069 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3071 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3072 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3073 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3075 popupMgr()->insert( separator(), anId, -1 );
3077 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3078 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3079 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3081 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3082 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3083 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3085 popupMgr()->insert( separator(), anId, -1 );
3087 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3088 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3090 popupMgr()->insert( separator(), -1, -1 );
3092 //-------------------------------------------------
3094 //-------------------------------------------------
3095 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3096 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3097 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3098 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3100 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3101 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3103 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3104 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3106 popupMgr()->insert( separator(), -1, -1 );
3108 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3109 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3112 //================================================================================
3114 * \brief Return true if SMESH or GEOM objects are selected.
3115 * Is called form LightApp_Module::activateModule() which clear selection if
3116 * not isSelectionCompatible()
3118 //================================================================================
3120 bool SMESHGUI::isSelectionCompatible()
3122 bool isCompatible = true;
3123 SALOME_ListIO selected;
3124 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3125 Sel->selectedObjects( selected );
3127 SALOME_ListIteratorOfListIO It( selected );
3128 for ( ; isCompatible && It.More(); It.Next())
3130 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3131 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3133 return isCompatible;
3136 bool SMESHGUI::activateModule( SUIT_Study* study )
3138 bool res = SalomeApp_Module::activateModule( study );
3140 setMenuShown( true );
3141 setToolShown( true );
3143 // Reset actions accelerator keys
3144 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3145 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3146 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3148 action( 33)->setEnabled(true); // Delete: Key_Delete
3149 action(1101)->setEnabled(true); // Rename: Key_F2
3154 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3156 setMenuShown( false );
3157 setToolShown( false );
3159 EmitSignalCloseAllDialogs();
3161 // Unset actions accelerator keys
3162 action(111)->setAccel(QKeySequence()); // Import DAT
3163 action(112)->setAccel(QKeySequence()); // Import UNV
3164 action(113)->setAccel(QKeySequence()); // Import MED
3166 action( 33)->setEnabled(false); // Delete: Key_Delete
3167 action(1101)->setEnabled(false); // Rename: Key_F2
3169 return SalomeApp_Module::deactivateModule( study );
3172 void SMESHGUI::studyClosed( SUIT_Study* s )
3174 SMESH::RemoveVisuData( s->id() );
3175 SalomeApp_Module::studyClosed( s );
3178 void SMESHGUI::OnGUIEvent()
3180 const QObject* obj = sender();
3181 if ( !obj || !obj->inherits( "QAction" ) )
3183 int id = actionId((QAction*)obj);
3188 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3190 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3191 if ( CORBA::is_nil( myComponentSMESH ) )
3193 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3195 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3196 return aGUI.myComponentSMESH;
3199 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3200 return myComponentSMESH;
3203 QString SMESHGUI::engineIOR() const
3205 CORBA::ORB_var anORB = getApp()->orb();
3206 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3207 return QString( anIOR.in() );
3210 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3212 SMESHGUI_Selection sel;
3213 sel.init( client, selectionMgr() );
3214 popupMgr()->updatePopup( menu, &sel );
3217 selectionMgr()->selectedObjects( lst );
3218 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3219 Handle(SALOME_InteractiveObject) io = lst.First();
3220 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3221 _PTR(Study) study = appStudy->studyDS();
3222 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3224 QString aName = QString( obj->GetName().c_str() );
3225 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3226 aName.remove( (aName.length() - 1), 1 );
3232 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3234 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3235 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3238 void SMESHGUI::viewManagers( QStringList& list ) const
3240 list.append( SVTK_Viewer::Type() );
3243 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3245 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3246 SMESH::UpdateSelectionProp( this );
3249 void SMESHGUI::createPreferences()
3251 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3253 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3254 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3256 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3257 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3258 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3260 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3261 setPreferenceProperty( precGroup, "columns", 1 );
3263 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3265 setPreferenceProperty( prec, "min", 0 );
3266 setPreferenceProperty( prec, "max", 16 );
3268 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3269 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3271 modes.append( "Wireframe" );
3272 modes.append( "Shading" );
3273 modes.append( "Nodes" );
3274 modes.append( "Shrink" );
3275 QValueList<QVariant> indices;
3276 indices.append( 0 );
3277 indices.append( 1 );
3278 indices.append( 2 );
3279 indices.append( 3 );
3280 setPreferenceProperty( dispmode, "strings", modes );
3281 setPreferenceProperty( dispmode, "indexes", indices );
3283 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3284 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3285 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3287 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3288 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3290 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3291 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3293 setPreferenceProperty( nodeSz, "min", 1 );
3294 setPreferenceProperty( nodeSz, "max", 5 );
3296 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3298 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3299 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3300 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3301 addPreference( "", elemGroup, LightApp_Preferences::Space );
3303 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3304 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3306 setPreferenceProperty( elemW, "min", 1 );
3307 setPreferenceProperty( elemW, "max", 5 );
3309 setPreferenceProperty( shrink, "min", 0 );
3310 setPreferenceProperty( shrink, "max", 100 );
3312 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3314 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3316 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3317 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3318 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3320 setPreferenceProperty( selW, "min", 1 );
3321 setPreferenceProperty( selW, "max", 5 );
3323 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3325 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3326 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3328 setPreferenceProperty( preW, "min", 1 );
3329 setPreferenceProperty( preW, "max", 5 );
3331 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3333 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3334 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3335 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3337 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3338 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3340 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3341 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3342 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3343 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3346 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3347 fam.append( tr( "SMESH_FONT_COURIER" ) );
3348 fam.append( tr( "SMESH_FONT_TIMES" ) );
3349 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3351 setPreferenceProperty( tfont, "families", fam );
3352 setPreferenceProperty( tfont, "system", false );
3353 setPreferenceProperty( tfont, "widget_flags", wflag );
3354 setPreferenceProperty( lfont, "families", fam );
3355 setPreferenceProperty( lfont, "system", false );
3356 setPreferenceProperty( lfont, "widget_flags", wflag );
3358 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3360 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3361 setPreferenceProperty( numcol, "min", 2 );
3362 setPreferenceProperty( numcol, "max", 256 );
3364 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3365 setPreferenceProperty( numlab, "min", 2 );
3366 setPreferenceProperty( numlab, "max", 65 );
3368 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3369 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3370 QStringList orients;
3371 orients.append( tr( "SMESH_VERTICAL" ) );
3372 orients.append( tr( "SMESH_HORIZONTAL" ) );
3373 indices.clear(); indices.append( 0 ); indices.append( 1 );
3374 setPreferenceProperty( orient, "strings", orients );
3375 setPreferenceProperty( orient, "indexes", indices );
3377 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3378 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3379 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3380 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3381 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3382 setPreferenceProperty( xv, "step", 0.1 );
3383 setPreferenceProperty( xv, "min", 0.0 );
3384 setPreferenceProperty( xv, "max", 1.0 );
3385 setPreferenceProperty( yv, "step", 0.1 );
3386 setPreferenceProperty( yv, "min", 0.0 );
3387 setPreferenceProperty( yv, "max", 1.0 );
3388 setPreferenceProperty( wv, "step", 0.1 );
3389 setPreferenceProperty( wv, "min", 0.0 );
3390 setPreferenceProperty( wv, "max", 1.0 );
3391 setPreferenceProperty( hv, "min", 0.0 );
3392 setPreferenceProperty( hv, "max", 1.0 );
3393 setPreferenceProperty( hv, "step", 0.1 );
3395 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3396 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3397 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3398 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3399 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3400 setPreferenceProperty( xv, "min", 0.0 );
3401 setPreferenceProperty( xv, "max", 1.0 );
3402 setPreferenceProperty( xv, "step", 0.1 );
3403 setPreferenceProperty( xh, "min", 0.0 );
3404 setPreferenceProperty( xh, "max", 1.0 );
3405 setPreferenceProperty( xh, "step", 0.1 );
3406 setPreferenceProperty( yh, "min", 0.0 );
3407 setPreferenceProperty( yh, "max", 1.0 );
3408 setPreferenceProperty( yh, "step", 0.1 );
3409 setPreferenceProperty( wh, "min", 0.0 );
3410 setPreferenceProperty( wh, "max", 1.0 );
3411 setPreferenceProperty( wh, "step", 0.1 );
3412 setPreferenceProperty( hh, "min", 0.0 );
3413 setPreferenceProperty( hh, "max", 1.0 );
3414 setPreferenceProperty( hh, "step", 0.1 );
3417 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3419 if( sect=="SMESH" ){
3420 float sbX1,sbY1,sbW,sbH;
3421 float aTol = 1.00000009999999;
3422 std::string aWarning;
3423 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3424 if( name=="selection_object_color" || name=="selection_element_color" ||
3425 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3426 name=="selection_precision_node" || name=="selection_precision_element" ||
3427 name=="selection_precision_object")
3428 SMESH::UpdateSelectionProp( this );
3429 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3430 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3431 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3432 if(sbX1+sbW > aTol){
3433 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3436 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3437 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3440 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3441 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3442 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3443 if(sbY1+sbH > aTol){
3444 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3445 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3446 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3449 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3450 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3451 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3452 if(sbX1+sbW > aTol){
3453 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3456 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3457 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3460 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3461 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3462 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3463 if(sbY1+sbH > aTol){
3464 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3467 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3468 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3472 if(aWarning.size() != 0){
3473 aWarning += "The default values are applied instead.";
3474 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3475 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3476 QObject::tr(aWarning.c_str()),
3477 QObject::tr("SMESH_BUT_OK"));
3482 //================================================================================
3484 * \brief Update something in accordance with update flags
3485 * \param theFlags - update flags
3487 * Update viewer or/and object browser etc. in accordance with update flags ( see
3488 * LightApp_UpdateFlags enumeration ).
3490 //================================================================================
3491 void SMESHGUI::update( const int flags )
3493 if ( flags & UF_Viewer | flags & UF_Forced )
3494 SMESH::UpdateView();
3496 SalomeApp_Module::update( flags );
3499 //================================================================================
3501 * \brief Set default selection mode
3503 * SLOT called when operation commited. Sets default selection mode
3505 //================================================================================
3506 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3508 SVTK_ViewWindow* vtkWnd =
3509 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3511 vtkWnd->SetSelectionMode( ActorSelection );
3514 //================================================================================
3516 * \brief Set default selection mode
3518 * SLOT called when operation aborted. Sets default selection mode
3520 //================================================================================
3521 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3523 SVTK_ViewWindow* vtkWnd =
3524 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3526 vtkWnd->SetSelectionMode( ActorSelection );
3529 //================================================================================
3531 * \brief Creates operation with given identifier
3532 * \param id - identifier of operation to be started
3533 * \return Pointer on created operation or NULL if operation is not created
3535 * Virtual method redefined from the base class creates operation with given id.
3536 * It is called called automatically from startOperation method of base class.
3538 //================================================================================
3539 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3541 LightApp_Operation* op = 0;
3542 // to do : create operation here
3545 case 701: // Compute mesh
3546 op = new SMESHGUI_ComputeOp();
3548 case 702: // Create mesh
3549 op = new SMESHGUI_MeshOp( true, true );
3551 case 703: // Create sub-mesh
3552 op = new SMESHGUI_MeshOp( true, false );
3554 case 704: // Edit mesh/sub-mesh
3555 op = new SMESHGUI_MeshOp( false );
3557 case 417: //convert to quadratic
3558 op = new SMESHGUI_ConvToQuadOp();
3560 case 4067: // make mesh pass through point
3561 op = new SMESHGUI_MakeNodeAtPointOp();
3568 op = SalomeApp_Module::createOperation( id );
3572 //================================================================================
3574 * \brief Stops current operations and starts a given one
3575 * \param id - The id of the operation to start
3577 //================================================================================
3579 void SMESHGUI::switchToOperation(int id)
3581 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3582 activeStudy()->abortAllOperations();
3583 startOperation( id );
3586 LightApp_Displayer* SMESHGUI::displayer()
3589 myDisplayer = new SMESHGUI_Displayer( getApp() );
3593 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3596 int aTolerance = 64;
3597 int anIterations = 0;
3603 if( anIterations % aPeriod == 0 )
3606 if( aTolerance < 1 )
3609 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3611 aHue = (int)( 360.0 * rand() / RAND_MAX );
3612 //cout << "Hue = " << aHue << endl;
3614 //cout << "Auto colors : ";
3616 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3617 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3618 for( ; it != itEnd; ++it )
3620 SALOMEDS::Color anAutoColor = *it;
3621 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3624 aQColor.getHsv( &h, &s, &v );
3626 if( abs( h - aHue ) < aTolerance )
3629 //cout << "break (diff = " << abs( h - aHue ) << ")";
3639 //cout << "Hue of the returned color = " << aHue << endl;
3641 aColor.setHsv( aHue, 255, 255 );
3643 SALOMEDS::Color aSColor;
3644 aSColor.R = (double)aColor.red() / 255.0;
3645 aSColor.G = (double)aColor.green() / 255.0;
3646 aSColor.B = (double)aColor.blue() / 255.0;