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)"));
185 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
186 QDir::currentDirPath(),
188 QObject::tr("Import mesh"),
190 if(!filename.isEmpty()) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 aMeshes->length( 1 );
200 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
205 SMESH::DriverMED_ReadStatus res;
206 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
207 if ( res != SMESH::DRS_OK ) {
209 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
210 QObject::tr("SMESH_WRN_WARNING"),
211 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
212 QObject::tr("SMESH_BUT_OK"));
213 aMeshes->length( 0 );
220 bool isEmpty = false;
221 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
222 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
224 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
225 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
226 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
227 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
228 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
235 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
236 QObject::tr("SMESH_WRN_WARNING"),
237 QObject::tr("SMESH_DRS_EMPTY"),
238 QObject::tr("SMESH_BUT_OK"));
242 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
244 catch (const SALOME::SALOME_Exception& S_ex){
246 SalomeApp_Tools::QtCatchCorbaException(S_ex);
253 void ExportMeshToFile( int theCommandID )
255 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
256 SALOME_ListIO selected;
258 aSel->selectedObjects( selected );
260 if(selected.Extent()){
261 Handle(SALOME_InteractiveObject) anIObject = selected.First();
262 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
263 if ( !aMesh->_is_nil() ) {
264 QString aFilter, aTitle = QObject::tr("Export mesh");
265 QMap<QString, SMESH::MED_VERSION> aFilterMap;
266 QMap<QString, int> aFilterMapSTL;
267 switch ( theCommandID ) {
271 if (aMesh->HasDuplicatedGroupNamesMED()) {
272 int aRet = SUIT_MessageBox::warn2
273 (SMESHGUI::desktop(),
274 QObject::tr("SMESH_WRN_WARNING"),
275 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
276 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
282 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
283 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
284 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
285 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
290 aFilter = QObject::tr("DAT files (*.dat)");
295 if (aMesh->NbPyramids()) {
296 int aRet = SUIT_MessageBox::warn2
297 (SMESHGUI::desktop(),
298 QObject::tr("SMESH_WRN_WARNING"),
299 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
300 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
305 aFilter = QObject::tr("IDEAS files (*.unv)");
313 there must be check on others mesh elements not equal triangles
315 if (aMesh->NbTriangles() < 1) {
316 SUIT_MessageBox::warn1
317 (SMESHGUI::desktop(),
318 QObject::tr("SMESH_WRN_WARNING"),
319 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
320 QObject::tr("SMESH_BUT_OK"));
323 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
324 int aRet = SUIT_MessageBox::warn2
325 (SMESHGUI::desktop(),
326 QObject::tr("SMESH_WRN_WARNING"),
327 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
328 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
334 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
335 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
343 SMESH::MED_VERSION aFormat;
344 // Init the parameter with the default value
345 bool aIsASCII_STL = true;
346 bool toCreateGroups = false;
347 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
349 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
351 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
353 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
355 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
357 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
358 for ( ; it != aFilterMapSTL.end(); ++it )
359 filters.push_back( it.key() );
361 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
362 fd->setCaption( aTitle );
363 fd->setFilters( filters );
364 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
368 aFilename = fd->selectedFile();
369 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
376 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
377 for ( ; it != aFilterMap.end(); ++it )
378 filters.push_back( it.key() );
380 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
381 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
382 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
383 fd->setCaption( aTitle );
384 fd->setFilters( filters );
385 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
386 fd->SetChecked(toCreateGroups);
390 aFilename = fd->selectedFile();
391 aFormat = aFilterMap[fd->selectedFilter()];
393 if ( !aFilename.isEmpty()
394 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
395 && aFormat==SMESH::MED_V2_1) {
396 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
397 QObject::tr("SMESH_WRN_WARNING"),
398 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
399 QObject::tr("SMESH_BUT_YES"),
400 QObject::tr("SMESH_BUT_NO"),
407 toCreateGroups = fd->IsChecked();
410 if ( !aFilename.isEmpty() ) {
411 // Check whether the file already exists and delete it if yes
412 QFile aFile( aFilename );
413 if ( aFile.exists() )
415 SUIT_OverrideCursor wc;
418 bool Renumber = false ;
419 // PAL 14172 : Check of we have to renumber or not from the preferences before export
421 Renumber= resMgr->booleanValue("SMESH","renumbering");
423 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
424 aMeshEditor->RenumberNodes();
425 aMeshEditor->RenumberElements();
426 if ( SMESHGUI::automaticUpdate() )
429 switch ( theCommandID ) {
432 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
436 aMesh->ExportDAT( aFilename.latin1() );
440 aMesh->ExportUNV( aFilename.latin1() );
444 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
450 catch (const SALOME::SALOME_Exception& S_ex){
452 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
453 QObject::tr("SMESH_WRN_WARNING"),
454 QObject::tr("SMESH_EXPORT_FAILED"),
455 QObject::tr("SMESH_BUT_OK"));
463 inline void InverseEntityMode(unsigned int& theOutputMode,
464 unsigned int theMode)
466 bool anIsNotPresent = ~theOutputMode & theMode;
468 theOutputMode |= theMode;
470 theOutputMode &= ~theMode;
473 void SetDisplayEntity(int theCommandID){
474 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
475 SALOME_ListIO selected;
477 aSel->selectedObjects( selected );
479 if(selected.Extent() >= 1){
480 SALOME_ListIteratorOfListIO It( selected );
481 for(; It.More(); It.Next()){
482 Handle(SALOME_InteractiveObject) IObject = It.Value();
483 if(IObject->hasEntry()){
484 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
485 unsigned int aMode = anActor->GetEntityMode();
486 switch(theCommandID){
488 InverseEntityMode(aMode,SMESH_Actor::eEdges);
491 InverseEntityMode(aMode,SMESH_Actor::eFaces);
494 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
497 aMode = SMESH_Actor::eAllEntity;
501 anActor->SetEntityMode(aMode);
509 SALOME_ListIO selected;
510 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
514 LightApp_SelectionMgr* aSel = app->selectionMgr();
515 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
516 if( !aSel || !appStudy )
519 aSel->selectedObjects( selected );
520 if( selected.IsEmpty() )
523 Handle(SALOME_InteractiveObject) anIObject = selected.First();
525 _PTR(Study) aStudy = appStudy->studyDS();
526 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
527 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
528 if( aMainObject->_is_nil() )
531 aMainObject->SetAutoColor( true );
533 QValueList<SALOMEDS::Color> aReservedColors;
535 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
536 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
538 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
539 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
541 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
542 aGroupObject->SetColor( aColor );
543 aReservedColors.append( aColor );
545 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
546 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
548 if( aGroupObject->GetType() == SMESH::NODE )
549 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
550 else if( aGroupObject->GetType() == SMESH::EDGE )
551 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
553 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
557 SMESH::RepaintCurrentView();
560 void DisableAutoColor(){
561 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
562 SALOME_ListIO selected;
564 aSel->selectedObjects( selected );
566 if(selected.Extent()){
567 Handle(SALOME_InteractiveObject) anIObject = selected.First();
568 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
569 if ( !aMesh->_is_nil() ) {
570 aMesh->SetAutoColor( false );
575 void SetDisplayMode(int theCommandID){
576 SALOME_ListIO selected;
577 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
581 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
582 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
583 if( !aSel || !appStudy )
586 _PTR(Study) aStudy = appStudy->studyDS();
588 aSel->selectedObjects( selected );
590 if(selected.Extent() >= 1){
591 switch(theCommandID){
593 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
594 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
598 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
599 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
602 SALOME_ListIteratorOfListIO It( selected );
603 for(; It.More(); It.Next()){
604 Handle(SALOME_InteractiveObject) IObject = It.Value();
605 if(IObject->hasEntry()){
606 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
607 switch(theCommandID){
609 anActor->SetRepresentation(SMESH_Actor::eEdge);
612 anActor->SetRepresentation(SMESH_Actor::eSurface);
615 if(anActor->IsShrunk())
618 anActor->SetShrink();
621 anActor->SetRepresentation(SMESH_Actor::ePoint);
624 vtkFloatingPointType color[3];
625 anActor->GetSufaceColor(color[0], color[1], color[2]);
626 int c0 = int (color[0] * 255);
627 int c1 = int (color[1] * 255);
628 int c2 = int (color[2] * 255);
629 QColor c(c0, c1, c2);
631 vtkFloatingPointType edgecolor[3];
632 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
633 c0 = int (edgecolor[0] * 255);
634 c1 = int (edgecolor[1] * 255);
635 c2 = int (edgecolor[2] * 255);
636 QColor e(c0, c1, c2);
638 vtkFloatingPointType backfacecolor[3];
639 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
640 c0 = int (backfacecolor[0] * 255);
641 c1 = int (backfacecolor[1] * 255);
642 c2 = int (backfacecolor[2] * 255);
643 QColor b(c0, c1, c2);
645 vtkFloatingPointType nodecolor[3];
646 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
647 c0 = int (nodecolor[0] * 255);
648 c1 = int (nodecolor[1] * 255);
649 c2 = int (nodecolor[2] * 255);
650 QColor n(c0, c1, c2);
652 int Edgewidth = (int)anActor->GetLineWidth();
655 int intValue = int(anActor->GetNodeSize());
656 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
658 SMESHGUI_Preferences_ColorDlg *aDlg =
659 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
660 aDlg->SetColor(1, c);
661 aDlg->SetColor(2, e);
662 aDlg->SetColor(3, n);
663 aDlg->SetColor(4, b);
664 aDlg->SetIntValue(1, Edgewidth);
665 aDlg->SetIntValue(2, intValue);
666 aDlg->SetIntValue(3, int(Shrink*100.));
668 QColor color = aDlg->GetColor(1);
669 QColor edgecolor = aDlg->GetColor(2);
670 QColor nodecolor = aDlg->GetColor(3);
671 QColor backfacecolor = aDlg->GetColor(4);
672 /* actor color and backface color */
673 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
674 vtkFloatingPointType (color.green()) / 255.,
675 vtkFloatingPointType (color.blue()) / 255.);
676 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
677 vtkFloatingPointType (backfacecolor.green()) / 255.,
678 vtkFloatingPointType (backfacecolor.blue()) / 255.);
681 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
682 vtkFloatingPointType (edgecolor.green()) / 255.,
683 vtkFloatingPointType (edgecolor.blue()) / 255.);
685 /* Shrink factor and size edges */
686 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
687 anActor->SetLineWidth(aDlg->GetIntValue(1));
689 /* Nodes color and size */
690 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
691 vtkFloatingPointType (nodecolor.green()) / 255.,
692 vtkFloatingPointType (nodecolor.blue()) / 255.);
693 anActor->SetNodeSize(aDlg->GetIntValue(2));
695 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
696 if( !aGroupObject->_is_nil() )
698 SALOMEDS::Color aColor;
699 aColor.R = (float)color.red() / 255.0;
700 aColor.G = (float)color.green() / 255.0;
701 aColor.B = (float)color.blue() / 255.0;
702 aGroupObject->SetColor( aColor );
712 SMESH::RepaintCurrentView();
716 void Control( int theCommandID )
718 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
719 SALOME_ListIO selected;
721 aSel->selectedObjects( selected );
723 if( !selected.IsEmpty() ){
724 Handle(SALOME_InteractiveObject) anIO = selected.First();
727 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
728 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
729 switch ( theCommandID ){
731 aTitle = QObject::tr( "LENGTH_EDGES" );
732 aControl = SMESH_Actor::eLength;
735 aTitle = QObject::tr( "LENGTH2D_EDGES" );
736 aControl = SMESH_Actor::eLength2D;
739 aTitle = QObject::tr( "FREE_EDGES" );
740 aControl = SMESH_Actor::eFreeEdges;
743 aTitle = QObject::tr( "FREE_BORDERS" );
744 aControl = SMESH_Actor::eFreeBorders;
747 aTitle = QObject::tr( "MULTI_BORDERS" );
748 aControl = SMESH_Actor::eMultiConnection;
751 aTitle = QObject::tr( "MULTI2D_BORDERS" );
752 aControl = SMESH_Actor::eMultiConnection2D;
755 aTitle = QObject::tr( "AREA_ELEMENTS" );
756 aControl = SMESH_Actor::eArea;
759 aTitle = QObject::tr( "TAPER_ELEMENTS" );
760 aControl = SMESH_Actor::eTaper;
763 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
764 aControl = SMESH_Actor::eAspectRatio;
767 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
768 aControl = SMESH_Actor::eAspectRatio3D;
771 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
772 aControl = SMESH_Actor::eMinimumAngle;
775 aTitle = QObject::tr( "WARP_ELEMENTS" );
776 aControl = SMESH_Actor::eWarping;
779 aTitle = QObject::tr( "SKEW_ELEMENTS" );
780 aControl = SMESH_Actor::eSkew;
783 aTitle = QObject::tr( "SMESH_VOLUME" );
784 aControl = SMESH_Actor::eVolume3D;
787 anActor->SetControlMode(aControl);
788 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
789 SMESH::RepaintCurrentView();
796 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
797 MeshObjectType theType,
798 const QString theInTypeName,
799 QString & theOutTypeName)
801 SMESH_TypeFilter aTypeFilter( theType );
803 if( !theIO.IsNull() )
805 entry = theIO->getEntry();
806 LightApp_DataOwner owner( entry );
807 if ( aTypeFilter.isOk( &owner )) {
808 theOutTypeName = theInTypeName;
816 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
818 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
819 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
821 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
822 CORBA::String_var anID = aSComp->GetID().c_str();
823 if (!strcmp(anID.in(),theIO->getEntry()))
829 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
830 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
831 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
832 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
833 CheckOIType ( theIO, GROUP, "Group", aTypeName )
841 QString CheckHomogeneousSelection()
843 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
844 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
845 SALOME_ListIO selected;
847 aSel->selectedObjects( selected );
849 QString RefType = CheckTypeObject(selected.First());
850 SALOME_ListIteratorOfListIO It(selected);
851 for (; It.More(); It.Next())
853 Handle(SALOME_InteractiveObject) IObject = It.Value();
854 QString Type = CheckTypeObject(IObject);
855 if (Type.compare(RefType) != 0)
856 return "Heterogeneous Selection";
863 void SMESHGUI::OnEditDelete()
865 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
866 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
867 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
869 QString aParentComponent = QString::null;
870 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
872 QString cur = anIt.Value()->getComponentDataType();
873 if( aParentComponent.isNull() )
874 aParentComponent = cur;
875 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
876 aParentComponent = "";
879 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
880 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
881 QObject::tr("ERR_ERROR"),
882 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
883 QObject::tr("BUT_OK") );
886 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
887 if (SUIT_MessageBox::warn2
888 (SMESHGUI::desktop(),
889 QObject::tr("SMESH_WRN_WARNING"),
890 QObject::tr("SMESH_REALLY_DELETE"),
891 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
894 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
895 SUIT_ViewManager* vm = anApp->activeViewManager();
896 int nbSf = vm->getViewsCount();
898 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
899 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
900 _PTR(GenericAttribute) anAttr;
901 _PTR(AttributeIOR) anIOR;
903 SALOME_ListIteratorOfListIO It(selected);
905 aStudyBuilder->NewCommand(); // There is a transaction
906 for(; It.More(); It.Next()){ // loop on selected IO's
907 Handle(SALOME_InteractiveObject) IObject = It.Value();
908 if(IObject->hasEntry()) {
909 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
911 // disable removal of "SMESH" component object
912 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
914 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
918 // put the whole hierarchy of sub-objects of the selected SO into a list and
919 // then treat them all starting from the deepest objects (at list back)
921 list< _PTR(SObject) > listSO;
922 listSO.push_back( aSO );
923 list< _PTR(SObject) >::iterator itSO = listSO.begin();
924 for ( ; itSO != listSO.end(); ++itSO ) {
925 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
926 for (it->InitEx(false); it->More(); it->Next())
927 listSO.push_back( it->Value() );
930 // treat SO's in the list starting from the back
932 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
933 for ( ; ritSO != listSO.rend(); ++ritSO ) {
934 _PTR(SObject) SO = *ritSO;
936 string anEntry = SO->GetID();
938 /** Erase graphical object **/
939 if(SO->FindAttribute(anAttr, "AttributeIOR")){
940 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
941 for(int i = 0; i < nbSf; i++){
942 SUIT_ViewWindow *sf = aViews[i];
943 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
944 SMESH::RemoveActor(sf,anActor);
949 /** Remove an object from data structures **/
950 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
951 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
952 if ( !aGroup->_is_nil() ) { // DELETE GROUP
953 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
954 aMesh->RemoveGroup( aGroup );
956 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
957 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
958 aMesh->RemoveSubMesh( aSubMesh );
960 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
962 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
965 IObject = new SALOME_InteractiveObject
966 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
967 QString objType = CheckTypeObject(IObject);
968 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
969 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
970 aStudyBuilder->RemoveObjectWithChildren( SO );
972 else {// default action: remove SObject from the study
973 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
974 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
976 aStudyBuilder->RemoveObjectWithChildren( SO );
980 } /* listSO back loop */
981 } /* IObject->hasEntry() */
983 aStudyBuilder->CommitCommand();
985 /* Clear any previous selection */
987 aSel->setSelectedObjects( l1 );
989 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
994 SMESHGUI_EXPORT CAM_Module* createModule()
996 return new SMESHGUI();
1000 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1002 //=============================================================================
1006 //=============================================================================
1007 SMESHGUI::SMESHGUI() :
1008 SalomeApp_Module( "SMESH" )
1010 if ( CORBA::is_nil( myComponentSMESH ) )
1012 CORBA::Boolean anIsEmbeddedMode;
1013 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1016 myActiveDialogBox = 0;
1017 myFilterLibraryDlg = 0;
1021 SMESH::GetFilterManager();
1022 SMESH::GetPattern();
1024 /* load resources for all available meshers */
1025 SMESH::InitAvailableHypotheses();
1028 //=============================================================================
1032 //=============================================================================
1033 SMESHGUI::~SMESHGUI()
1035 SMESH::GetFilterManager()->Destroy();
1036 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1039 //=============================================================================
1043 //=============================================================================
1044 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1046 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1048 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1053 bool SMESHGUI::automaticUpdate()
1055 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1059 return resMgr->booleanValue( "SMESH", "auto_update", false );
1062 //=============================================================================
1066 //=============================================================================
1067 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1069 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1072 //=============================================================================
1076 //=============================================================================
1077 SMESHGUI* SMESHGUI::GetSMESHGUI()
1079 SMESHGUI* smeshMod = 0;
1080 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1083 CAM_Module* module = app->module( "Mesh" );
1084 smeshMod = dynamic_cast<SMESHGUI*>( module );
1087 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1089 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1092 _PTR(Study) aStudy = study->studyDS();
1094 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1103 Standard_EXPORT SMESHGUI* GetComponentGUI()
1105 return SMESHGUI::GetSMESHGUI();
1109 //=============================================================================
1113 //=============================================================================
1114 void SMESHGUI::SetState(int aState)
1119 //=============================================================================
1123 //=============================================================================
1124 void SMESHGUI::ResetState()
1129 //=============================================================================
1133 //=============================================================================
1134 void SMESHGUI::EmitSignalDeactivateDialog()
1136 emit SignalDeactivateActiveDialog();
1139 //=============================================================================
1143 //=============================================================================
1144 void SMESHGUI::EmitSignalStudyFrameChanged()
1146 emit SignalStudyFrameChanged();
1149 //=============================================================================
1153 //=============================================================================
1154 void SMESHGUI::EmitSignalCloseAllDialogs()
1156 emit SignalCloseAllDialogs();
1159 //=============================================================================
1163 //=============================================================================
1164 QDialog *SMESHGUI::GetActiveDialogBox()
1166 return myActiveDialogBox;
1169 //=============================================================================
1173 //=============================================================================
1174 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1176 myActiveDialogBox = (QDialog *) aDlg;
1180 //=============================================================================
1184 //=============================================================================
1185 SUIT_Desktop* SMESHGUI::desktop()
1187 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1189 return app->desktop();
1194 //=============================================================================
1198 //=============================================================================
1199 SalomeApp_Study* SMESHGUI::activeStudy()
1201 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1203 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1208 //=============================================================================
1212 //=============================================================================
1213 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1215 /* Here the position is on the bottom right corner - 10 */
1216 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1218 SUIT_Desktop *PP = desktop();
1219 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1220 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1224 //=============================================================================
1228 //=============================================================================
1229 static int isStudyLocked(_PTR(Study) theStudy){
1230 return theStudy->GetProperties()->IsLocked();
1233 static bool checkLock(_PTR(Study) theStudy) {
1234 if (isStudyLocked(theStudy)) {
1235 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1236 QObject::tr("WRN_WARNING"),
1237 QObject::tr("WRN_STUDY_LOCKED"),
1238 QObject::tr("BUT_OK") );
1244 //=======================================================================
1245 //function : CheckActiveStudyLocked
1247 //=======================================================================
1249 bool SMESHGUI::isActiveStudyLocked()
1251 _PTR(Study) aStudy = activeStudy()->studyDS();
1252 return checkLock( aStudy );
1255 //=============================================================================
1259 //=============================================================================
1260 bool SMESHGUI::OnGUIEvent( int theCommandID )
1262 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1266 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1267 SUIT_ResourceMgr* mgr = resourceMgr();
1271 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1272 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1275 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1276 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1278 //QAction* act = action( theCommandID );
1280 switch (theCommandID) {
1282 if(checkLock(aStudy)) break;
1290 if(checkLock(aStudy)) break;
1291 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1295 case 122: // EXPORT MED
1304 ::ExportMeshToFile(theCommandID);
1308 case 200: // SCALAR BAR
1310 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1311 SALOME_ListIO selected;
1313 aSel->selectedObjects( selected );
1315 if( selected.Extent() ) {
1316 Handle(SALOME_InteractiveObject) anIO = selected.First();
1317 if( anIO->hasEntry() ) {
1318 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1319 anActor->SetControlMode( SMESH_Actor::eNone );
1327 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1337 ::DisableAutoColor();
1340 case 1134: // Clipping
1341 case 1133: // Tranparency
1342 case 1132: // Colors / Size
1349 ::SetDisplayMode(theCommandID);
1355 case 219: // Volumes
1356 case 220: // All Entity
1357 ::SetDisplayEntity(theCommandID);
1362 if(checkLock(aStudy)) break;
1364 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1367 SMESH::UpdateView();
1369 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1370 SMESH::OnVisuException();
1372 catch (...) { // PAL16774 (Crash after display of many groups)
1373 SMESH::OnVisuException();
1377 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1378 aSel->selectedObjects( l );
1379 aSel->setSelectedObjects( l );
1384 case 301: // DISPLAY
1385 case 302: // DISPLAY ONLY
1387 SMESH::EDisplaing anAction;
1388 switch (theCommandID) {
1389 case 300: anAction = SMESH::eErase; break;
1390 case 301: anAction = SMESH::eDisplay; break;
1391 case 302: anAction = SMESH::eDisplayOnly; break;
1394 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1395 SALOME_ListIO sel_objects, to_process;
1397 aSel->selectedObjects( sel_objects );
1399 if( theCommandID==302 )
1400 startOperation( myEraseAll );
1402 extractContainers( sel_objects, to_process );
1405 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1409 SALOME_ListIteratorOfListIO It( to_process );
1410 for (; It.More(); It.Next()) {
1411 Handle(SALOME_InteractiveObject) IOS = It.Value();
1412 if (IOS->hasEntry()) {
1413 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1414 break; // PAL16774 (Crash after display of many groups)
1415 if (anAction == SMESH::eDisplayOnly)
1416 anAction = SMESH::eDisplay;
1421 // PAL13338 + PAL15161 -->
1422 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1423 SMESH::UpdateView();
1424 // PAL13338 + PAL15161 <--
1426 catch (...) { // PAL16774 (Crash after display of many groups)
1427 SMESH::OnVisuException();
1430 if (anAction == SMESH::eErase) {
1432 aSel->setSelectedObjects( l1 );
1435 aSel->setSelectedObjects( to_process );
1442 if(checkLock(aStudy)) break;
1445 EmitSignalDeactivateDialog();
1447 new SMESHGUI_NodesDlg(this);
1450 SUIT_MessageBox::warn1(desktop(),
1451 tr("SMESH_WRN_WARNING"),
1452 tr("SMESH_WRN_VIEWER_VTK"),
1453 tr("SMESH_BUT_OK"));
1458 case 2151: // FILTER
1462 EmitSignalDeactivateDialog();
1463 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1468 case 406: // MOVE NODE
1472 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1473 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1477 if(checkLock(aStudy)) break;
1478 new SMESHGUI_MoveNodesDlg(this);
1482 case 701: // COMPUTE MESH
1484 if (checkLock(aStudy)) break;
1486 startOperation( 701 );
1490 case 702: // Create mesh
1491 startOperation( 702 );
1493 case 703: // Create sub-mesh
1494 startOperation( 703 );
1496 case 704: // Edit mesh/sub-mesh
1497 startOperation( 704 );
1499 case 710: // Build compound mesh
1501 if (checkLock(aStudy)) break;
1502 EmitSignalDeactivateDialog();
1503 new SMESHGUI_BuildCompoundDlg( this );
1506 case 407: // DIAGONAL INVERSION
1507 case 408: // Delete diagonal
1511 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1512 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1516 if ( checkLock( aStudy ) )
1519 /*Standard_Boolean aRes;
1520 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1521 if ( aMesh->_is_nil() )
1523 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1524 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1528 EmitSignalDeactivateDialog();
1529 if ( theCommandID == 407 )
1530 new SMESHGUI_TrianglesInversionDlg(this);
1532 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1535 case 409: // Change orientation
1536 case 410: // Union of triangles
1537 case 411: // Cutting of quadrangles
1541 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1542 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1546 if ( checkLock( aStudy ) )
1549 EmitSignalDeactivateDialog();
1550 SMESHGUI_MultiEditDlg* aDlg = NULL;
1551 if ( theCommandID == 409 )
1552 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1553 else if ( theCommandID == 410 )
1554 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1556 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1561 case 412: // Smoothing
1563 if(checkLock(aStudy)) break;
1565 EmitSignalDeactivateDialog();
1566 new SMESHGUI_SmoothingDlg( this );
1569 SUIT_MessageBox::warn1(desktop(),
1570 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1571 tr("SMESH_BUT_OK"));
1575 case 413: // Extrusion
1577 if (checkLock(aStudy)) break;
1579 EmitSignalDeactivateDialog();
1580 new SMESHGUI_ExtrusionDlg ( this );
1582 SUIT_MessageBox::warn1(desktop(),
1583 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1584 tr("SMESH_BUT_OK"));
1588 case 414: // Revolution
1590 if(checkLock(aStudy)) break;
1592 EmitSignalDeactivateDialog();
1593 new SMESHGUI_RevolutionDlg( this );
1596 SUIT_MessageBox::warn1(desktop(),
1597 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1598 tr("SMESH_BUT_OK"));
1602 case 415: // Pattern mapping
1604 if ( checkLock( aStudy ) )
1608 EmitSignalDeactivateDialog();
1609 new SMESHGUI_MeshPatternDlg( this );
1612 SUIT_MessageBox::warn1(desktop(),
1613 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1614 tr("SMESH_BUT_OK"));
1618 case 416: // Extrusion along a path
1620 if (checkLock(aStudy)) break;
1622 EmitSignalDeactivateDialog();
1623 new SMESHGUI_ExtrusionAlongPathDlg( this );
1625 SUIT_MessageBox::warn1(desktop(),
1626 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1627 tr("SMESH_BUT_OK"));
1631 case 417: // Convert mesh to quadratic
1633 startOperation( 417 );
1634 /* if (checkLock(aStudy)) break;
1636 EmitSignalDeactivateDialog();
1637 new SMESHGUI_ConvToQuadDlg();
1639 SUIT_MessageBox::warn1(desktop(),
1640 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1641 tr("SMESH_BUT_OK"));
1645 case 801: // CREATE GROUP
1649 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1650 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1654 if(checkLock(aStudy)) break;
1655 EmitSignalDeactivateDialog();
1656 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1658 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1659 SALOME_ListIO selected;
1661 aSel->selectedObjects( selected );
1663 int nbSel = selected.Extent();
1665 // check if mesh is selected
1666 aMesh = SMESH::GetMeshByIO( selected.First() );
1668 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1673 case 802: // CONSTRUCT GROUP
1677 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1678 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1682 if(checkLock(aStudy)) break;
1683 EmitSignalDeactivateDialog();
1685 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1686 SALOME_ListIO selected;
1688 aSel->selectedObjects( selected );
1690 int nbSel = selected.Extent();
1692 // check if submesh is selected
1693 Handle(SALOME_InteractiveObject) IObject = selected.First();
1694 if (IObject->hasEntry()) {
1695 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1697 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1698 if (!aSubMesh->_is_nil()) {
1700 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1701 // get submesh elements list by types
1702 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1703 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1704 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1705 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1706 // create group for each type o elements
1707 QString aName = IObject->getName();
1708 if (aNodes->length() > 0) {
1709 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1710 aGroup->Add(aNodes.inout());
1712 if (aEdges->length() > 0) {
1713 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1714 aGroup->Add(aEdges.inout());
1716 if (aFaces->length() > 0) {
1717 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1718 aGroup->Add(aFaces.inout());
1720 if (aVolumes->length() > 0) {
1721 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1722 aGroup->Add(aVolumes.inout());
1727 catch(const SALOME::SALOME_Exception & S_ex){
1728 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1735 SUIT_MessageBox::warn1(desktop(),
1736 tr("SMESH_WRN_WARNING"),
1737 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1738 tr("SMESH_BUT_OK"));
1743 case 803: // EDIT GROUP
1747 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1748 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1752 if(checkLock(aStudy)) break;
1753 EmitSignalDeactivateDialog();
1755 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1756 SALOME_ListIO selected;
1758 aSel->selectedObjects( selected );
1760 SALOME_ListIteratorOfListIO It (selected);
1761 int nbSelectedGroups = 0;
1762 for ( ; It.More(); It.Next() )
1764 SMESH::SMESH_GroupBase_var aGroup =
1765 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1766 if (!aGroup->_is_nil()) {
1768 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1772 if (nbSelectedGroups == 0)
1774 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1780 case 804: // Add elements to group
1782 if(checkLock(aStudy)) break;
1783 if (myState == 800) {
1784 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1785 if (aDlg) aDlg->onAdd();
1790 case 805: // Remove elements from group
1792 if(checkLock(aStudy)) break;
1793 if (myState == 800) {
1794 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1795 if (aDlg) aDlg->onRemove();
1800 case 810: // Union Groups
1801 case 811: // Intersect groups
1802 case 812: // Cut groups
1806 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1807 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1811 if ( checkLock( aStudy ) )
1814 EmitSignalDeactivateDialog();
1817 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1818 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1819 else aMode = SMESHGUI_GroupOpDlg::CUT;
1821 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1825 case 813: // Delete groups with their contents
1829 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1830 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1834 if ( checkLock( aStudy ) )
1837 EmitSignalDeactivateDialog();
1839 new SMESHGUI_DeleteGroupDlg( this );
1843 case 900: // MESH INFOS
1845 EmitSignalDeactivateDialog();
1846 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1847 SALOME_ListIO selected;
1849 aSel->selectedObjects( selected );
1851 if ( selected.Extent() > 1 ) { // a dlg for each IO
1853 SALOME_ListIteratorOfListIO It (selected);
1854 for ( ; It.More(); It.Next() ) {
1855 IOs.Clear(); IOs.Append( It.Value() );
1856 aSel->setSelectedObjects( IOs );
1857 new SMESHGUI_MeshInfosDlg(this, "", false);
1859 // restore selection
1860 aSel->setSelectedObjects( selected );
1863 new SMESHGUI_MeshInfosDlg(this, "", false);
1867 case 902: // STANDARD MESH INFOS
1869 EmitSignalDeactivateDialog();
1870 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1871 SALOME_ListIO selected;
1873 aSel->selectedObjects( selected );
1875 if ( selected.Extent() > 1 ) { // a dlg for each IO
1877 SALOME_ListIteratorOfListIO It (selected);
1878 for ( ; It.More(); It.Next() ) {
1880 IOs.Append( It.Value() );
1881 aSel->setSelectedObjects( IOs );
1882 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1884 // restore selection
1885 aSel->setSelectedObjects( selected );
1888 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1892 case 903: // WHAT IS
1894 EmitSignalDeactivateDialog();
1895 new SMESHGUI_WhatIsDlg( this, "", false);
1899 case 1100: // EDIT HYPOTHESIS
1901 if(checkLock(aStudy)) break;
1903 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1904 SALOME_ListIO selected;
1906 aSel->selectedObjects( selected );
1908 int nbSel = selected.Extent();
1911 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1912 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1914 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1915 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1916 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1917 if ( !aHypothesis->_is_nil() )
1919 CORBA::String_var aHypType = aHypothesis->GetName();
1920 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1922 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1929 updateObjBrowser( true );
1933 case 1101: // RENAME
1935 if ( checkLock( aStudy ) )
1938 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1939 SALOME_ListIO selected;
1941 aSel->selectedObjects( selected );
1943 SALOME_ListIteratorOfListIO It( selected );
1944 for ( ; It.More(); It.Next() )
1946 Handle(SALOME_InteractiveObject) IObject = It.Value();
1947 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1948 _PTR(GenericAttribute) anAttr;
1949 _PTR(AttributeName) aName;
1952 if ( obj->FindAttribute(anAttr, "AttributeName") )
1955 QString newName = QString(aName->Value().c_str());
1956 newName = LightApp_NameDlg::getName(desktop(), newName);
1957 if ( !newName.isEmpty() )
1959 //old source: aStudy->renameIObject( IObject, newName );
1960 aName->SetValue( newName.latin1() );
1962 // if current object is group update group's name
1963 SMESH::SMESH_GroupBase_var aGroup =
1964 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1965 if (!aGroup->_is_nil() )
1966 aGroup->SetName( newName.latin1() );
1976 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1978 if(checkLock(aStudy)) break;
1979 SUIT_OverrideCursor wc;
1981 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1982 SALOME_ListIO selected;
1984 aSel->selectedObjects( selected, QString::null, false );
1986 SALOME_ListIteratorOfListIO It(selected);
1987 for (int i = 0; It.More(); It.Next(), i++) {
1988 Handle(SALOME_InteractiveObject) IObject = It.Value();
1989 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1992 aSel->setSelectedObjects( l1 );
1997 case 401: // GEOM::EDGE
1998 case 4021: // TRIANGLE
2000 case 4023: // POLYGON
2004 if(checkLock(aStudy)) break;
2006 EmitSignalDeactivateDialog();
2007 SMDSAbs_ElementType type = SMDSAbs_Edge;
2009 switch (theCommandID) {
2010 case 4021: // TRIANGLE
2011 type = SMDSAbs_Face; nbNodes = 3; break;
2013 type = SMDSAbs_Face; nbNodes = 4; break;
2015 type = SMDSAbs_Volume; nbNodes = 4; break;
2016 case 4023: // POLYGON
2017 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2019 type = SMDSAbs_Volume; nbNodes = 8; break;
2020 case 4033: // POLYHEDRE
2021 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2024 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2027 SUIT_MessageBox::warn1(desktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2033 case 4033: // POLYHEDRON
2035 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2038 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2041 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4034: // QUADRATIC EDGE
2048 case 4035: // QUADRATIC TRIANGLE
2049 case 4036: // QUADRATIC QUADRANGLE
2050 case 4037: // QUADRATIC TETRAHEDRON
2051 case 4038: // QUADRATIC PYRAMID
2052 case 4039: // QUADRATIC PENTAHEDRON
2053 case 4040: // QUADRATIC HEXAHEDRON
2055 if(checkLock(aStudy)) break;
2057 EmitSignalDeactivateDialog();
2060 switch (theCommandID) {
2062 type = QUAD_EDGE; break;
2064 type = QUAD_TRIANGLE; break;
2066 type = QUAD_QUADRANGLE; break;
2068 type = QUAD_TETRAHEDRON; break;
2070 type = QUAD_PYRAMID; break;
2072 type = QUAD_PENTAHEDRON; break;
2074 type = QUAD_HEXAHEDRON;
2078 new SMESHGUI_AddQuadraticElementDlg( this, type );
2081 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2082 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2083 tr("SMESH_BUT_OK"));
2087 case 4041: // REMOVES NODES
2089 if(checkLock(aStudy)) break;
2091 EmitSignalDeactivateDialog();
2092 new SMESHGUI_RemoveNodesDlg(this);
2095 SUIT_MessageBox::warn1(desktop(),
2096 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2097 tr("SMESH_BUT_OK"));
2101 case 4042: // REMOVES ELEMENTS
2103 if(checkLock(aStudy)) break;
2105 EmitSignalDeactivateDialog();
2106 new SMESHGUI_RemoveElementsDlg(this);
2110 SUIT_MessageBox::warn1(desktop(),
2111 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2112 tr("SMESH_BUT_OK"));
2116 case 4051: // RENUMBERING NODES
2118 if(checkLock(aStudy)) break;
2120 EmitSignalDeactivateDialog();
2121 new SMESHGUI_RenumberingDlg( this, "", 0);
2125 SUIT_MessageBox::warn1(desktop(),
2126 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2127 tr("SMESH_BUT_OK"));
2131 case 4052: // RENUMBERING ELEMENTS
2133 if(checkLock(aStudy)) break;
2135 EmitSignalDeactivateDialog();
2136 new SMESHGUI_RenumberingDlg( this, "", 1);
2140 SUIT_MessageBox::warn1(desktop(),
2141 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2142 tr("SMESH_BUT_OK"));
2146 case 4061: // TRANSLATION
2148 if(checkLock(aStudy)) break;
2150 EmitSignalDeactivateDialog();
2151 new SMESHGUI_TranslationDlg( this );
2154 SUIT_MessageBox::warn1(desktop(),
2155 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2156 tr("SMESH_BUT_OK"));
2160 case 4062: // ROTATION
2162 if(checkLock(aStudy)) break;
2164 EmitSignalDeactivateDialog();
2165 new SMESHGUI_RotationDlg( this );
2168 SUIT_MessageBox::warn1(desktop(),
2169 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2170 tr("SMESH_BUT_OK"));
2174 case 4063: // SYMMETRY
2176 if(checkLock(aStudy)) break;
2178 EmitSignalDeactivateDialog();
2179 new SMESHGUI_SymmetryDlg( this );
2182 SUIT_MessageBox::warn1(desktop(),
2183 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2184 tr("SMESH_BUT_OK"));
2188 case 4064: // SEWING
2190 if(checkLock(aStudy)) break;
2192 EmitSignalDeactivateDialog();
2193 new SMESHGUI_SewingDlg( this );
2196 SUIT_MessageBox::warn1(desktop(),
2197 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2198 tr("SMESH_BUT_OK"));
2202 case 4065: // MERGE NODES
2204 if(checkLock(aStudy)) break;
2206 EmitSignalDeactivateDialog();
2207 new SMESHGUI_EditMeshDlg( this, 0 );
2210 SUIT_MessageBox::warn1(desktop(),
2211 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2212 tr("SMESH_BUT_OK"));
2216 case 4066: // MERGE EQUAL ELEMENTS
2218 if (checkLock(aStudy)) break;
2220 EmitSignalDeactivateDialog();
2221 new SMESHGUI_EditMeshDlg( this, 1 );
2223 SUIT_MessageBox::warn1(desktop(),
2224 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2225 tr("SMESH_BUT_OK"));
2230 case 4067: // MAKE MESH PASS THROUGH POINT
2231 startOperation( 4067 );
2234 case 5105: // Library of selection filters
2236 static QValueList<int> aTypes;
2237 if ( aTypes.isEmpty() )
2239 aTypes.append( SMESH::NODE );
2240 aTypes.append( SMESH::EDGE );
2241 aTypes.append( SMESH::FACE );
2242 aTypes.append( SMESH::VOLUME );
2244 if (!myFilterLibraryDlg)
2245 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2246 else if (myFilterLibraryDlg->isHidden())
2247 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2248 myFilterLibraryDlg->raise();
2252 case 6017: // CONTROLS
2268 LightApp_SelectionMgr* mgr = selectionMgr();
2269 SALOME_ListIO selected; mgr->selectedObjects( selected );
2271 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2272 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2274 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2275 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2276 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2277 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2278 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2279 ::Control( theCommandID );
2284 SUIT_MessageBox::warn1(desktop(),
2285 tr( "SMESH_WRN_WARNING" ),
2286 tr( "SMESH_BAD_SELECTION" ),
2287 tr( "SMESH_BUT_OK" ) );
2291 SUIT_MessageBox::warn1(desktop(),
2292 tr( "SMESH_WRN_WARNING" ),
2293 tr( "NOT_A_VTK_VIEWER" ),
2294 tr( "SMESH_BUT_OK" ) );
2299 LightApp_SelectionMgr* mgr = selectionMgr();
2300 SALOME_ListIO selected; mgr->selectedObjects( selected );
2302 SALOME_ListIteratorOfListIO it(selected);
2303 for(; it.More(); it.Next()) {
2304 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2305 if(anIObject->hasEntry()) {
2306 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2307 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2315 LightApp_SelectionMgr* mgr = selectionMgr();
2316 SALOME_ListIO selected; mgr->selectedObjects( selected );
2318 if (selected.Extent() == 1) {
2319 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2320 if(anIObject->hasEntry())
2321 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2322 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2329 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2330 //updateObjBrowser();
2334 //=============================================================================
2338 //=============================================================================
2339 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2344 //=============================================================================
2348 //=============================================================================
2349 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2354 //=============================================================================
2358 //=============================================================================
2359 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2364 //=============================================================================
2365 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2366 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2368 //=============================================================================
2369 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2370 SUIT_ViewWindow* wnd )
2372 if(theIO->hasEntry()){
2373 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2374 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2378 //=======================================================================
2379 // function : createSMESHAction
2381 //=======================================================================
2382 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2385 QWidget* parent = application()->desktop();
2386 SUIT_ResourceMgr* resMgr = resourceMgr();
2388 if ( icon_id.length() )
2389 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2391 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2392 if ( !pix.isNull() )
2393 icon = QIconSet( pix );
2395 QString tooltip = tr( QString( "TOP_" )+po_id ),
2396 menu = tr( QString( "MEN_" )+po_id ),
2397 status_bar = tr( QString( "STB_" )+po_id );
2399 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2402 //=======================================================================
2403 // function : createPopupItem
2405 //=======================================================================
2406 void SMESHGUI::createPopupItem( const int id,
2407 const QString& clients,
2408 const QString& types,
2409 const QString& theRule,
2414 parentId = popupMgr()->actionId( action( pId ) );
2416 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2417 popupMgr()->insert( action( id ), parentId, 0 );
2419 QChar lc = QtxPopupMgr::Selection::defEquality();
2420 QString rule = "(%1) and (%2) and (%3)";
2421 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2422 if( clients.isEmpty() )
2423 rule = rule.arg( QString( "true" ) );
2425 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2426 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2429 bool cont = myRules.contains( id );
2431 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2433 popupMgr()->setRule( action( id ), rule, true );
2434 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2437 //=======================================================================
2438 // function : initialize
2440 //=======================================================================
2441 void SMESHGUI::initialize( CAM_Application* app )
2443 SalomeApp_Module::initialize( app );
2445 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2447 /* Automatic Update flag */
2448 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2450 // ----- create actions --------------
2452 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2453 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2454 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2455 createSMESHAction( 114, "NUM" );
2456 createSMESHAction( 121, "DAT" );
2457 createSMESHAction( 122, "MED" );
2458 createSMESHAction( 123, "UNV" );
2459 createSMESHAction( 140, "STL" );
2460 createSMESHAction( 124, "EXPORT_DAT" );
2461 createSMESHAction( 125, "EXPORT_MED" );
2462 createSMESHAction( 126, "EXPORT_UNV" );
2463 createSMESHAction( 141, "EXPORT_STL" );
2464 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2465 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2466 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2467 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2468 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2469 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2470 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2471 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2472 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2473 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2474 createSMESHAction( 804, "ADD" );
2475 createSMESHAction( 805, "REMOVE" );
2476 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2477 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2478 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2479 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2480 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2481 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2482 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2483 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2484 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2485 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2486 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2487 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2488 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2489 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2490 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2491 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2492 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2493 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2494 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2495 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2496 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2497 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2498 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2499 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2500 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2501 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2502 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2503 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2504 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2505 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2506 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2507 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2508 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2509 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2510 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2511 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2512 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2513 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2514 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2515 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2516 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2517 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2518 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2519 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2520 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2521 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2522 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2523 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2524 createSMESHAction( 415, "MAP", "ICON_MAP" );
2525 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2526 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2527 createSMESHAction( 200, "RESET" );
2528 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2529 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2530 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2531 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2532 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2533 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2534 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2535 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2536 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2537 createSMESHAction( 220, "ALL" );
2538 createSMESHAction( 1100, "EDIT_HYPO" );
2539 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2540 createSMESHAction( 1102, "UNASSIGN" );
2541 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2542 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2543 createSMESHAction( 1131, "DISPMODE" );
2544 createSMESHAction( 1132, "COLORS" );
2545 createSMESHAction( 1133, "TRANSP" );
2546 createSMESHAction( 1134, "CLIP" );
2547 createSMESHAction( 1135, "DISP_ENT" );
2548 createSMESHAction( 1136, "AUTO_COLOR" );
2549 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2550 createSMESHAction( 2000, "CTRL" );
2552 createSMESHAction( 300, "ERASE" );
2553 createSMESHAction( 301, "DISPLAY" );
2554 createSMESHAction( 302, "DISPLAY_ONLY" );
2555 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2556 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2557 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2558 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2559 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2560 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2561 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2562 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2564 // ----- create menu --------------
2565 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2566 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2567 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2568 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2569 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2570 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2571 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2573 createMenu( separator(), fileId );
2575 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2576 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2577 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2578 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2579 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2580 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2582 createMenu( 111, importId, -1 );
2583 createMenu( 112, importId, -1 );
2584 createMenu( 113, importId, -1 );
2586 createMenu( 121, exportId, -1 );
2587 createMenu( 122, exportId, -1 );
2588 createMenu( 123, exportId, -1 );
2589 createMenu( 140, exportId, -1 ); // export to stl STL
2591 createMenu( separator(), fileId, 10 );
2593 createMenu( 33, editId, -1 );
2595 createMenu( 5105, toolsId, -1 );
2597 createMenu( 702, meshId, -1 );
2598 createMenu( 703, meshId, -1 );
2599 createMenu( 704, meshId, -1 );
2600 createMenu( 710, meshId, -1 );
2601 createMenu( separator(), meshId, -1 );
2602 createMenu( 701, meshId, -1 );
2603 createMenu( separator(), meshId, -1 );
2604 createMenu( 801, meshId, -1 );
2605 createMenu( 802, meshId, -1 );
2606 createMenu( 803, meshId, -1 );
2607 createMenu( separator(), meshId, -1 );
2608 createMenu( 810, meshId, -1 );
2609 createMenu( 811, meshId, -1 );
2610 createMenu( 812, meshId, -1 );
2611 createMenu( separator(), meshId, -1 );
2612 createMenu( 813, meshId, -1 );
2613 createMenu( separator(), meshId, -1 );
2614 createMenu( 900, meshId, -1 );
2615 createMenu( 902, meshId, -1 );
2616 createMenu( 903, meshId, -1 );
2617 createMenu( separator(), meshId, -1 );
2619 createMenu( 6003, ctrlId, -1 );
2620 createMenu( 6001, ctrlId, -1 );
2621 createMenu( 6004, ctrlId, -1 );
2622 createMenu( separator(), ctrlId, -1 );
2623 createMenu( 6002, ctrlId, -1 );
2624 createMenu( 6018, ctrlId, -1 );
2625 createMenu( 6019, ctrlId, -1 );
2626 createMenu( 6011, ctrlId, -1 );
2627 createMenu( 6012, ctrlId, -1 );
2628 createMenu( 6013, ctrlId, -1 );
2629 createMenu( 6014, ctrlId, -1 );
2630 createMenu( 6015, ctrlId, -1 );
2631 createMenu( 6016, ctrlId, -1 );
2632 createMenu( separator(), ctrlId, -1 );
2633 createMenu( 6017, ctrlId, -1 );
2634 createMenu( 6009, ctrlId, -1 );
2635 createMenu( separator(), ctrlId, -1 );
2637 createMenu( 400, addId, -1 );
2638 createMenu( 401, addId, -1 );
2639 createMenu( 4021, addId, -1 );
2640 createMenu( 4022, addId, -1 );
2641 createMenu( 4023, addId, -1 );
2642 createMenu( 4031, addId, -1 );
2643 createMenu( 4032, addId, -1 );
2644 createMenu( 4033, addId, -1 );
2645 createMenu( separator(), addId, -1 );
2646 createMenu( 4034, addId, -1 );
2647 createMenu( 4035, addId, -1 );
2648 createMenu( 4036, addId, -1 );
2649 createMenu( 4037, addId, -1 );
2650 createMenu( 4038, addId, -1 );
2651 createMenu( 4039, addId, -1 );
2652 createMenu( 4040, addId, -1 );
2654 createMenu( 4041, removeId, -1 );
2655 createMenu( 4042, removeId, -1 );
2657 createMenu( 4051, renumId, -1 );
2658 createMenu( 4052, renumId, -1 );
2660 createMenu( 4061, transfId, -1 );
2661 createMenu( 4062, transfId, -1 );
2662 createMenu( 4063, transfId, -1 );
2663 createMenu( 4064, transfId, -1 );
2664 createMenu( 4065, transfId, -1 );
2665 createMenu( 4066, transfId, -1 );
2667 createMenu( 406, modifyId, -1 );
2668 createMenu( 4067,modifyId, -1 );
2669 createMenu( 407, modifyId, -1 );
2670 createMenu( 408, modifyId, -1 );
2671 createMenu( 409, modifyId, -1 );
2672 createMenu( 410, modifyId, -1 );
2673 createMenu( 411, modifyId, -1 );
2674 createMenu( 412, modifyId, -1 );
2675 createMenu( 413, modifyId, -1 );
2676 createMenu( 416, modifyId, -1 );
2677 createMenu( 414, modifyId, -1 );
2678 createMenu( 415, modifyId, -1 );
2679 createMenu( 417, modifyId, -1 );
2681 createMenu( 214, viewId, -1 );
2683 // ----- create toolbars --------------
2684 int meshTb = createTool( tr( "TB_MESH" ) ),
2685 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2686 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2687 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2688 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2690 createTool( 702, meshTb );
2691 createTool( 703, meshTb );
2692 createTool( 704, meshTb );
2693 createTool( 710, meshTb );
2694 createTool( separator(), meshTb );
2695 createTool( 701, meshTb );
2696 createTool( separator(), meshTb );
2697 createTool( 801, meshTb );
2698 createTool( 802, meshTb );
2699 createTool( 803, meshTb );
2700 createTool( separator(), meshTb );
2701 createTool( 900, meshTb );
2702 createTool( 902, meshTb );
2703 createTool( 903, meshTb );
2704 createTool( separator(), meshTb );
2706 createTool( 6001, ctrlTb );
2707 createTool( 6003, ctrlTb );
2708 createTool( 6004, ctrlTb );
2709 createTool( separator(), ctrlTb );
2710 createTool( 6002, ctrlTb );
2711 createTool( 6018, ctrlTb );
2712 createTool( 6019, ctrlTb );
2713 createTool( 6011, ctrlTb );
2714 createTool( 6012, ctrlTb );
2715 createTool( 6013, ctrlTb );
2716 createTool( 6014, ctrlTb );
2717 createTool( 6015, ctrlTb );
2718 createTool( 6016, ctrlTb );
2719 createTool( separator(), ctrlTb );
2720 createTool( 6017, ctrlTb );
2721 createTool( 6009, ctrlTb );
2722 createTool( separator(), ctrlTb );
2724 createTool( 400, addRemTb );
2725 createTool( 401, addRemTb );
2726 createTool( 4021, addRemTb );
2727 createTool( 4022, addRemTb );
2728 createTool( 4023, addRemTb );
2729 createTool( 4031, addRemTb );
2730 createTool( 4032, addRemTb );
2731 createTool( 4033, addRemTb );
2732 createTool( separator(), addRemTb );
2733 createTool( 4034, addRemTb );
2734 createTool( 4035, addRemTb );
2735 createTool( 4036, addRemTb );
2736 createTool( 4037, addRemTb );
2737 createTool( 4038, addRemTb );
2738 createTool( 4039, addRemTb );
2739 createTool( 4040, addRemTb );
2740 createTool( separator(), addRemTb );
2741 createTool( 4041, addRemTb );
2742 createTool( 4042, addRemTb );
2743 createTool( separator(), addRemTb );
2744 createTool( 4051, addRemTb );
2745 createTool( 4052, addRemTb );
2746 createTool( separator(), addRemTb );
2747 createTool( 4061, addRemTb );
2748 createTool( 4062, addRemTb );
2749 createTool( 4063, addRemTb );
2750 createTool( 4064, addRemTb );
2751 createTool( 4065, addRemTb );
2752 createTool( 4066, addRemTb );
2753 createTool( separator(), addRemTb );
2755 createTool( 406, modifyTb );
2756 createTool( 4067,modifyTb );
2757 createTool( 407, modifyTb );
2758 createTool( 408, modifyTb );
2759 createTool( 409, modifyTb );
2760 createTool( 410, modifyTb );
2761 createTool( 411, modifyTb );
2762 createTool( 412, modifyTb );
2763 createTool( 413, modifyTb );
2764 createTool( 416, modifyTb );
2765 createTool( 414, modifyTb );
2766 createTool( 415, modifyTb );
2767 createTool( 417, modifyTb );
2769 createTool( 214, dispModeTb );
2773 QString OB = "'ObjectBrowser'",
2774 View = "'" + SVTK_Viewer::Type() + "'",
2776 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2777 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2778 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2779 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2780 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2781 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2782 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2783 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2784 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2785 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2786 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2788 mesh_group = mesh + " " + subMesh + " " + group,
2789 hyp_alg = hypo + " " + algo;
2791 // popup for object browser
2793 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2794 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2795 createPopupItem( 803, OB, group ); // EDIT_GROUP
2796 popupMgr()->insert( separator(), -1, 0 );
2797 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2798 createPopupItem( 214, OB, mesh_group ); // UPDATE
2799 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2800 createPopupItem( 902, OB, mesh ); // STD_INFO
2801 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2802 popupMgr()->insert( separator(), -1, 0 );
2803 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2804 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2805 popupMgr()->insert( separator(), -1, 0 );
2806 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2807 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2808 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2809 popupMgr()->insert( separator(), -1, 0 );
2811 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2812 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2813 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2814 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2815 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2816 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2817 popupMgr()->insert( separator(), -1, 0 );
2820 createPopupItem( 803, View, group ); // EDIT_GROUP
2821 createPopupItem( 804, View, elems ); // ADD
2822 createPopupItem( 805, View, elems ); // REMOVE
2823 popupMgr()->insert( separator(), -1, 0 );
2824 createPopupItem( 214, View, mesh_group ); // UPDATE
2825 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2826 createPopupItem( 902, View, mesh ); // STD_INFO
2827 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2828 popupMgr()->insert( separator(), -1, 0 );
2830 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2831 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2832 popupMgr()->insert( separator(), -1, 0 );
2836 isInvisible("not( isVisible )"),
2837 isEmpty("numberOfNodes = 0"),
2838 isNotEmpty("numberOfNodes <> 0"),
2840 // has nodes, edges, etc in VISIBLE! actor
2841 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2842 hasElems("(count( elemTypes ) > 0)"),
2843 hasDifferentElems("(count( elemTypes ) > 1)"),
2844 hasEdges("({'Edge'} in elemTypes)"),
2845 hasFaces("({'Face'} in elemTypes)"),
2846 hasVolumes("({'Volume'} in elemTypes)");
2848 QString lc = QtxPopupMgr::Selection::defEquality();
2849 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2850 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2851 aType = aType.arg( mesh_group );
2852 QString aMeshInVTK = aClient + "&&" + aType;
2854 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2855 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2856 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2858 //-------------------------------------------------
2860 //-------------------------------------------------
2861 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2863 popupMgr()->insert( action( 9010 ), anId, -1 );
2864 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2865 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2867 popupMgr()->insert( action( 9011 ), anId, -1 );
2868 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2869 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2871 popupMgr()->insert( separator(), -1, -1 );
2873 //-------------------------------------------------
2875 //-------------------------------------------------
2876 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2878 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2879 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2880 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2882 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2883 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2884 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2886 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2887 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2888 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2890 popupMgr()->insert( separator(), anId, -1 );
2892 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2893 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2894 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2896 //-------------------------------------------------
2898 //-------------------------------------------------
2899 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2901 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2903 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2904 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2905 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2907 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2908 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2909 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2911 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2912 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2913 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2915 popupMgr()->insert( separator(), anId, -1 );
2917 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2918 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2920 //-------------------------------------------------
2922 //-------------------------------------------------
2923 popupMgr()->insert( action( 1132 ), -1, -1 );
2924 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2926 //-------------------------------------------------
2928 //-------------------------------------------------
2929 popupMgr()->insert( action( 1133 ), -1, -1 );
2930 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2932 //-------------------------------------------------
2934 //-------------------------------------------------
2935 popupMgr()->insert( action( 1134 ), -1, -1 );
2936 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2938 popupMgr()->insert( separator(), -1, -1 );
2940 //-------------------------------------------------
2942 //-------------------------------------------------
2944 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2945 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2946 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2948 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2950 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2951 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2953 popupMgr()->insert( separator(), anId, -1 );
2955 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2956 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2957 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2959 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2960 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2961 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2963 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2964 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2965 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2967 popupMgr()->insert( separator(), anId, -1 );
2969 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2970 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2971 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2973 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2974 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2975 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2977 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2978 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2979 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2981 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2982 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2983 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2985 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2986 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2987 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2989 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2990 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2991 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2993 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2994 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2995 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2997 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2998 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2999 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3001 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3002 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3003 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3005 popupMgr()->insert( separator(), anId, -1 );
3007 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3008 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3009 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3011 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3012 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3013 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3015 popupMgr()->insert( separator(), anId, -1 );
3017 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3018 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3020 popupMgr()->insert( separator(), -1, -1 );
3022 //-------------------------------------------------
3024 //-------------------------------------------------
3025 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3026 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3027 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3028 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3030 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3031 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3033 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3034 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3036 popupMgr()->insert( separator(), -1, -1 );
3038 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3039 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3042 //================================================================================
3044 * \brief Return true if SMESH or GEOM objects are selected.
3045 * Is called form LightApp_Module::activateModule() which clear selection if
3046 * not isSelectionCompatible()
3048 //================================================================================
3050 bool SMESHGUI::isSelectionCompatible()
3052 bool isCompatible = true;
3053 SALOME_ListIO selected;
3054 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3055 Sel->selectedObjects( selected );
3057 SALOME_ListIteratorOfListIO It( selected );
3058 for ( ; isCompatible && It.More(); It.Next())
3060 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3061 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3063 return isCompatible;
3066 bool SMESHGUI::activateModule( SUIT_Study* study )
3068 bool res = SalomeApp_Module::activateModule( study );
3070 setMenuShown( true );
3071 setToolShown( true );
3073 // Reset actions accelerator keys
3074 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3075 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3076 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3081 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3083 setMenuShown( false );
3084 setToolShown( false );
3086 EmitSignalCloseAllDialogs();
3088 // Unset actions accelerator keys
3089 action(111)->setAccel(QKeySequence()); // Import DAT
3090 action(112)->setAccel(QKeySequence()); // Import UNV
3091 action(113)->setAccel(QKeySequence()); // Import MED
3093 return SalomeApp_Module::deactivateModule( study );
3096 void SMESHGUI::studyClosed( SUIT_Study* s )
3098 SMESH::RemoveVisuData( s->id() );
3099 SalomeApp_Module::studyClosed( s );
3102 void SMESHGUI::OnGUIEvent()
3104 const QObject* obj = sender();
3105 if ( !obj || !obj->inherits( "QAction" ) )
3107 int id = actionId((QAction*)obj);
3112 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3114 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3115 if ( CORBA::is_nil( myComponentSMESH ) )
3117 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3119 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3120 return aGUI.myComponentSMESH;
3123 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3124 return myComponentSMESH;
3127 QString SMESHGUI::engineIOR() const
3129 CORBA::ORB_var anORB = getApp()->orb();
3130 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3131 return QString( anIOR.in() );
3134 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3136 SMESHGUI_Selection sel;
3137 sel.init( client, selectionMgr() );
3138 popupMgr()->updatePopup( menu, &sel );
3140 SalomeApp_Module::contextMenuPopup( client, menu, title );
3142 getApp()->selectionMgr()->selectedObjects( lst );
3143 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3144 Handle(SALOME_InteractiveObject) io = lst.First();
3145 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3146 _PTR(Study) study = appStudy->studyDS();
3147 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3149 title = QString( obj->GetName().c_str() );
3153 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3155 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3156 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3159 void SMESHGUI::viewManagers( QStringList& list ) const
3161 list.append( SVTK_Viewer::Type() );
3164 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3166 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3167 SMESH::UpdateSelectionProp( this );
3170 void SMESHGUI::createPreferences()
3172 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3174 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3175 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3177 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3178 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3179 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3181 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3182 setPreferenceProperty( precGroup, "columns", 1 );
3184 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3186 setPreferenceProperty( prec, "min", 0 );
3187 setPreferenceProperty( prec, "max", 16 );
3189 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3190 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3192 modes.append( "Wireframe" );
3193 modes.append( "Shading" );
3194 modes.append( "Nodes" );
3195 modes.append( "Shrink" );
3196 QValueList<QVariant> indices;
3197 indices.append( 0 );
3198 indices.append( 1 );
3199 indices.append( 2 );
3200 indices.append( 3 );
3201 setPreferenceProperty( dispmode, "strings", modes );
3202 setPreferenceProperty( dispmode, "indexes", indices );
3204 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3205 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3206 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3208 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3209 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3211 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3212 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3214 setPreferenceProperty( nodeSz, "min", 1 );
3215 setPreferenceProperty( nodeSz, "max", 5 );
3217 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3219 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3220 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3221 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3222 addPreference( "", elemGroup, LightApp_Preferences::Space );
3224 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3225 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3227 setPreferenceProperty( elemW, "min", 1 );
3228 setPreferenceProperty( elemW, "max", 5 );
3230 setPreferenceProperty( shrink, "min", 0 );
3231 setPreferenceProperty( shrink, "max", 100 );
3233 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3235 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3237 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3238 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3239 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3241 setPreferenceProperty( selW, "min", 1 );
3242 setPreferenceProperty( selW, "max", 5 );
3244 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3246 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3247 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3249 setPreferenceProperty( preW, "min", 1 );
3250 setPreferenceProperty( preW, "max", 5 );
3252 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3254 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3255 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3256 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3258 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3259 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3261 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3262 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3263 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3264 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3267 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3268 fam.append( tr( "SMESH_FONT_COURIER" ) );
3269 fam.append( tr( "SMESH_FONT_TIMES" ) );
3270 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3272 setPreferenceProperty( tfont, "families", fam );
3273 setPreferenceProperty( tfont, "system", false );
3274 setPreferenceProperty( tfont, "widget_flags", wflag );
3275 setPreferenceProperty( lfont, "families", fam );
3276 setPreferenceProperty( lfont, "system", false );
3277 setPreferenceProperty( lfont, "widget_flags", wflag );
3279 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3281 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3282 setPreferenceProperty( numcol, "min", 2 );
3283 setPreferenceProperty( numcol, "max", 256 );
3285 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3286 setPreferenceProperty( numlab, "min", 2 );
3287 setPreferenceProperty( numlab, "max", 65 );
3289 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3290 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3291 QStringList orients;
3292 orients.append( tr( "SMESH_VERTICAL" ) );
3293 orients.append( tr( "SMESH_HORIZONTAL" ) );
3294 indices.clear(); indices.append( 0 ); indices.append( 1 );
3295 setPreferenceProperty( orient, "strings", orients );
3296 setPreferenceProperty( orient, "indexes", indices );
3298 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3299 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3300 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3301 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3302 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3303 setPreferenceProperty( xv, "step", 0.1 );
3304 setPreferenceProperty( xv, "min", 0.0 );
3305 setPreferenceProperty( xv, "max", 1.0 );
3306 setPreferenceProperty( yv, "step", 0.1 );
3307 setPreferenceProperty( yv, "min", 0.0 );
3308 setPreferenceProperty( yv, "max", 1.0 );
3309 setPreferenceProperty( wv, "step", 0.1 );
3310 setPreferenceProperty( wv, "min", 0.0 );
3311 setPreferenceProperty( wv, "max", 1.0 );
3312 setPreferenceProperty( hv, "min", 0.0 );
3313 setPreferenceProperty( hv, "max", 1.0 );
3314 setPreferenceProperty( hv, "step", 0.1 );
3316 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3317 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3318 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3319 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3320 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3321 setPreferenceProperty( xv, "min", 0.0 );
3322 setPreferenceProperty( xv, "max", 1.0 );
3323 setPreferenceProperty( xv, "step", 0.1 );
3324 setPreferenceProperty( xh, "min", 0.0 );
3325 setPreferenceProperty( xh, "max", 1.0 );
3326 setPreferenceProperty( xh, "step", 0.1 );
3327 setPreferenceProperty( yh, "min", 0.0 );
3328 setPreferenceProperty( yh, "max", 1.0 );
3329 setPreferenceProperty( yh, "step", 0.1 );
3330 setPreferenceProperty( wh, "min", 0.0 );
3331 setPreferenceProperty( wh, "max", 1.0 );
3332 setPreferenceProperty( wh, "step", 0.1 );
3333 setPreferenceProperty( hh, "min", 0.0 );
3334 setPreferenceProperty( hh, "max", 1.0 );
3335 setPreferenceProperty( hh, "step", 0.1 );
3338 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3340 if( sect=="SMESH" ){
3341 float sbX1,sbY1,sbW,sbH;
3342 float aTol = 1.00000009999999;
3343 std::string aWarning;
3344 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3345 if( name=="selection_object_color" || name=="selection_element_color" ||
3346 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3347 name=="selection_precision_node" || name=="selection_precision_element" ||
3348 name=="selection_precision_object")
3349 SMESH::UpdateSelectionProp( this );
3350 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3351 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3352 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3353 if(sbX1+sbW > aTol){
3354 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3357 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3358 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3361 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3362 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3363 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3364 if(sbY1+sbH > aTol){
3365 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3366 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3367 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3370 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3371 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3372 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3373 if(sbX1+sbW > aTol){
3374 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3377 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3378 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3381 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3382 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3383 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3384 if(sbY1+sbH > aTol){
3385 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3388 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3389 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3393 if(aWarning.size() != 0){
3394 aWarning += "The default values are applied instead.";
3395 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3396 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3397 QObject::tr(aWarning.c_str()),
3398 QObject::tr("SMESH_BUT_OK"));
3403 //================================================================================
3405 * \brief Update something in accordance with update flags
3406 * \param theFlags - update flags
3408 * Update viewer or/and object browser etc. in accordance with update flags ( see
3409 * LightApp_UpdateFlags enumeration ).
3411 //================================================================================
3412 void SMESHGUI::update( const int flags )
3414 if ( flags & UF_Viewer | flags & UF_Forced )
3415 SMESH::UpdateView();
3417 SalomeApp_Module::update( flags );
3420 //================================================================================
3422 * \brief Set default selection mode
3424 * SLOT called when operation commited. Sets default selection mode
3426 //================================================================================
3427 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3429 SVTK_ViewWindow* vtkWnd =
3430 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3432 vtkWnd->SetSelectionMode( ActorSelection );
3435 //================================================================================
3437 * \brief Set default selection mode
3439 * SLOT called when operation aborted. Sets default selection mode
3441 //================================================================================
3442 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3444 SVTK_ViewWindow* vtkWnd =
3445 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3447 vtkWnd->SetSelectionMode( ActorSelection );
3450 //================================================================================
3452 * \brief Creates operation with given identifier
3453 * \param id - identifier of operation to be started
3454 * \return Pointer on created operation or NULL if operation is not created
3456 * Virtual method redefined from the base class creates operation with given id.
3457 * It is called called automatically from startOperation method of base class.
3459 //================================================================================
3460 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3462 LightApp_Operation* op = 0;
3463 // to do : create operation here
3466 case 701: // Compute mesh
3467 op = new SMESHGUI_ComputeOp();
3469 case 702: // Create mesh
3470 op = new SMESHGUI_MeshOp( true, true );
3472 case 703: // Create sub-mesh
3473 op = new SMESHGUI_MeshOp( true, false );
3475 case 704: // Edit mesh/sub-mesh
3476 op = new SMESHGUI_MeshOp( false );
3478 case 417: //convert to quadratic
3479 op = new SMESHGUI_ConvToQuadOp();
3481 case 4067: // make mesh pass through point
3482 op = new SMESHGUI_MakeNodeAtPointOp();
3489 op = SalomeApp_Module::createOperation( id );
3493 //================================================================================
3495 * \brief Stops current operations and starts a given one
3496 * \param id - The id of the operation to start
3498 //================================================================================
3500 void SMESHGUI::switchToOperation(int id)
3502 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3503 activeStudy()->abortAllOperations();
3504 startOperation( id );
3507 LightApp_Displayer* SMESHGUI::displayer()
3510 myDisplayer = new SMESHGUI_Displayer( getApp() );
3514 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3517 int aTolerance = 64;
3518 int anIterations = 0;
3524 if( anIterations % aPeriod == 0 )
3527 if( aTolerance < 1 )
3530 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3532 aHue = (int)( 360.0 * rand() / RAND_MAX );
3533 //cout << "Hue = " << aHue << endl;
3535 //cout << "Auto colors : ";
3537 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3538 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3539 for( ; it != itEnd; ++it )
3541 SALOMEDS::Color anAutoColor = *it;
3542 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3545 aQColor.getHsv( &h, &s, &v );
3547 if( abs( h - aHue ) < aTolerance )
3550 //cout << "break (diff = " << abs( h - aHue ) << ")";
3560 //cout << "Hue of the returned color = " << aHue << endl;
3562 aColor.setHsv( aHue, 255, 255 );
3564 SALOMEDS::Color aSColor;
3565 aSColor.R = (double)aColor.red() / 255.0;
3566 aSColor.G = (double)aColor.green() / 255.0;
3567 aSColor.B = (double)aColor.blue() / 255.0;