1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_GEOMGenUtils.h"
74 #include "SMESHGUI_MeshUtils.h"
75 #include "SMESHGUI_GroupUtils.h"
76 #include "SMESHGUI_FilterUtils.h"
77 #include "SMESHGUI_PatternUtils.h"
78 #include "SMESHGUI_VTKUtils.h"
79 #include "SMESHGUI_HypothesesUtils.h"
81 #include "SMESH_Actor.h"
82 #include "SMESH_Object.h"
83 #include "SMESH_TypeFilter.hxx"
85 #include "SalomeApp_Tools.h"
86 #include "SalomeApp_Study.h"
87 #include "SalomeApp_Application.h"
88 #include "SalomeApp_CheckFileDlg.h"
89 #include "SalomeApp_ImportOperation.h"
91 #include "LightApp_DataOwner.h"
92 #include "LightApp_Preferences.h"
93 #include "LightApp_VTKSelector.h"
94 #include "LightApp_Operation.h"
95 #include "LightApp_UpdateFlags.h"
96 #include "LightApp_NameDlg.h"
98 #include <SVTK_ViewWindow.h>
99 #include <SVTK_ViewModel.h>
100 #include <SVTK_InteractorStyle.h>
101 #include <SVTK_RenderWindowInteractor.h>
102 #include <SVTK_ViewManager.h>
104 #include "OB_Browser.h"
106 #include "SUIT_Tools.h"
107 #include "SUIT_MessageBox.h"
108 #include "SUIT_ResourceMgr.h"
109 #include "SUIT_FileDlg.h"
110 #include "SUIT_Desktop.h"
111 #include "SUIT_OverrideCursor.h"
112 #include "SUIT_Study.h"
113 #include "SUIT_Session.h"
115 #include "QtxPopupMgr.h"
117 #include "SALOME_ListIO.hxx"
118 #include "SALOME_ListIteratorOfListIO.hxx"
119 #include "SALOME_InteractiveObject.hxx"
120 #include "SALOME_NamingService.hxx"
121 #include "SALOME_LifeCycleCORBA.hxx"
123 #include "SALOMEconfig.h"
124 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
128 #define INCLUDE_MENUITEM_DEF
129 #include <qpopupmenu.h>
135 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
150 #include <Standard_ErrorHandler.hxx>
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
186 QString anInitialPath = "";
187 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
188 anInitialPath = QDir::currentDirPath();
190 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
193 QObject::tr("Import mesh"),
195 if(!filename.isEmpty()) {
196 SUIT_OverrideCursor wc;
197 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
200 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
201 switch ( theCommandID ) {
204 aMeshes->length( 1 );
205 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
210 SMESH::DriverMED_ReadStatus res;
211 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
212 if ( res != SMESH::DRS_OK ) {
214 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
215 QObject::tr("SMESH_WRN_WARNING"),
216 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
217 QObject::tr("SMESH_BUT_OK"));
218 aMeshes->length( 0 );
225 bool isEmpty = false;
226 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
227 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
229 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
230 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
231 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
232 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
233 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
240 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
241 QObject::tr("SMESH_WRN_WARNING"),
242 QObject::tr("SMESH_DRS_EMPTY"),
243 QObject::tr("SMESH_BUT_OK"));
247 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
249 catch (const SALOME::SALOME_Exception& S_ex){
251 SalomeApp_Tools::QtCatchCorbaException(S_ex);
258 void ExportMeshToFile( int theCommandID )
260 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
261 SALOME_ListIO selected;
263 aSel->selectedObjects( selected );
265 if(selected.Extent()){
266 Handle(SALOME_InteractiveObject) anIObject = selected.First();
267 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
268 if ( !aMesh->_is_nil() ) {
269 QString aFilter, aTitle = QObject::tr("Export mesh");
270 QMap<QString, SMESH::MED_VERSION> aFilterMap;
271 QMap<QString, int> aFilterMapSTL;
272 switch ( theCommandID ) {
276 if (aMesh->HasDuplicatedGroupNamesMED()) {
277 int aRet = SUIT_MessageBox::warn2
278 (SMESHGUI::desktop(),
279 QObject::tr("SMESH_WRN_WARNING"),
280 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
281 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
287 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
288 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
289 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
290 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
295 aFilter = QObject::tr("DAT files (*.dat)");
300 if (aMesh->NbPyramids()) {
301 int aRet = SUIT_MessageBox::warn2
302 (SMESHGUI::desktop(),
303 QObject::tr("SMESH_WRN_WARNING"),
304 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
305 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
310 aFilter = QObject::tr("IDEAS files (*.unv)");
318 there must be check on others mesh elements not equal triangles
320 if (aMesh->NbTriangles() < 1) {
321 SUIT_MessageBox::warn1
322 (SMESHGUI::desktop(),
323 QObject::tr("SMESH_WRN_WARNING"),
324 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
325 QObject::tr("SMESH_BUT_OK"));
328 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
329 int aRet = SUIT_MessageBox::warn2
330 (SMESHGUI::desktop(),
331 QObject::tr("SMESH_WRN_WARNING"),
332 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
333 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
339 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
340 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
348 SMESH::MED_VERSION aFormat;
349 // Init the parameter with the default value
350 bool aIsASCII_STL = true;
351 bool toCreateGroups = false;
352 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
354 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
356 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
358 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
360 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
362 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
363 for ( ; it != aFilterMapSTL.end(); ++it )
364 filters.push_back( it.key() );
366 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
367 fd->setCaption( aTitle );
368 fd->setFilters( filters );
369 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
373 aFilename = fd->selectedFile();
374 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
381 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
382 for ( ; it != aFilterMap.end(); ++it )
383 filters.push_back( it.key() );
385 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
386 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
387 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
388 fd->setCaption( aTitle );
389 fd->setFilters( filters );
390 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
391 fd->SetChecked(toCreateGroups);
395 aFilename = fd->selectedFile();
396 aFormat = aFilterMap[fd->selectedFilter()];
398 if ( !aFilename.isEmpty()
399 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
400 && aFormat==SMESH::MED_V2_1) {
401 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
402 QObject::tr("SMESH_WRN_WARNING"),
403 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
404 QObject::tr("SMESH_BUT_YES"),
405 QObject::tr("SMESH_BUT_NO"),
412 toCreateGroups = fd->IsChecked();
415 if ( !aFilename.isEmpty() ) {
416 // Check whether the file already exists and delete it if yes
417 QFile aFile( aFilename );
418 if ( aFile.exists() )
420 SUIT_OverrideCursor wc;
423 bool Renumber = false ;
424 // PAL 14172 : Check of we have to renumber or not from the preferences before export
426 Renumber= resMgr->booleanValue("SMESH","renumbering");
428 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
429 aMeshEditor->RenumberNodes();
430 aMeshEditor->RenumberElements();
431 if ( SMESHGUI::automaticUpdate() )
434 switch ( theCommandID ) {
437 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
441 aMesh->ExportDAT( aFilename.latin1() );
445 aMesh->ExportUNV( aFilename.latin1() );
449 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
455 catch (const SALOME::SALOME_Exception& S_ex){
457 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
458 QObject::tr("SMESH_WRN_WARNING"),
459 QObject::tr("SMESH_EXPORT_FAILED"),
460 QObject::tr("SMESH_BUT_OK"));
468 inline void InverseEntityMode(unsigned int& theOutputMode,
469 unsigned int theMode)
471 bool anIsNotPresent = ~theOutputMode & theMode;
473 theOutputMode |= theMode;
475 theOutputMode &= ~theMode;
478 void SetDisplayEntity(int theCommandID){
479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
480 SALOME_ListIO selected;
482 aSel->selectedObjects( selected );
484 if(selected.Extent() >= 1){
485 SALOME_ListIteratorOfListIO It( selected );
486 for(; It.More(); It.Next()){
487 Handle(SALOME_InteractiveObject) IObject = It.Value();
488 if(IObject->hasEntry()){
489 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
490 unsigned int aMode = anActor->GetEntityMode();
491 switch(theCommandID){
493 InverseEntityMode(aMode,SMESH_Actor::eEdges);
496 InverseEntityMode(aMode,SMESH_Actor::eFaces);
499 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
502 aMode = SMESH_Actor::eAllEntity;
506 anActor->SetEntityMode(aMode);
514 SALOME_ListIO selected;
515 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
519 LightApp_SelectionMgr* aSel = app->selectionMgr();
520 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
521 if( !aSel || !appStudy )
524 aSel->selectedObjects( selected );
525 if( selected.IsEmpty() )
528 Handle(SALOME_InteractiveObject) anIObject = selected.First();
530 _PTR(Study) aStudy = appStudy->studyDS();
531 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
532 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
533 if( aMainObject->_is_nil() )
536 aMainObject->SetAutoColor( true );
538 QValueList<SALOMEDS::Color> aReservedColors;
540 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
541 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
543 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
544 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
546 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
547 aGroupObject->SetColor( aColor );
548 aReservedColors.append( aColor );
550 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
551 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
553 if( aGroupObject->GetType() == SMESH::NODE )
554 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
555 else if( aGroupObject->GetType() == SMESH::EDGE )
556 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
558 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
562 SMESH::RepaintCurrentView();
565 void DisableAutoColor(){
566 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
567 SALOME_ListIO selected;
569 aSel->selectedObjects( selected );
571 if(selected.Extent()){
572 Handle(SALOME_InteractiveObject) anIObject = selected.First();
573 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
574 if ( !aMesh->_is_nil() ) {
575 aMesh->SetAutoColor( false );
580 void SetDisplayMode(int theCommandID){
581 SALOME_ListIO selected;
582 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
586 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
587 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
588 if( !aSel || !appStudy )
591 _PTR(Study) aStudy = appStudy->studyDS();
593 aSel->selectedObjects( selected );
595 if(selected.Extent() >= 1){
596 switch(theCommandID){
598 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
599 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
603 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
604 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
607 SALOME_ListIteratorOfListIO It( selected );
608 for(; It.More(); It.Next()){
609 Handle(SALOME_InteractiveObject) IObject = It.Value();
610 if(IObject->hasEntry()){
611 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
612 switch(theCommandID){
614 anActor->SetRepresentation(SMESH_Actor::eEdge);
617 anActor->SetRepresentation(SMESH_Actor::eSurface);
620 if(anActor->IsShrunk())
623 anActor->SetShrink();
626 anActor->SetRepresentation(SMESH_Actor::ePoint);
629 vtkFloatingPointType color[3];
630 anActor->GetSufaceColor(color[0], color[1], color[2]);
631 int c0 = int (color[0] * 255);
632 int c1 = int (color[1] * 255);
633 int c2 = int (color[2] * 255);
634 QColor c(c0, c1, c2);
636 vtkFloatingPointType edgecolor[3];
637 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
638 c0 = int (edgecolor[0] * 255);
639 c1 = int (edgecolor[1] * 255);
640 c2 = int (edgecolor[2] * 255);
641 QColor e(c0, c1, c2);
643 vtkFloatingPointType backfacecolor[3];
644 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
645 c0 = int (backfacecolor[0] * 255);
646 c1 = int (backfacecolor[1] * 255);
647 c2 = int (backfacecolor[2] * 255);
648 QColor b(c0, c1, c2);
650 vtkFloatingPointType nodecolor[3];
651 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
652 c0 = int (nodecolor[0] * 255);
653 c1 = int (nodecolor[1] * 255);
654 c2 = int (nodecolor[2] * 255);
655 QColor n(c0, c1, c2);
657 int Edgewidth = (int)anActor->GetLineWidth();
660 int intValue = int(anActor->GetNodeSize());
661 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
663 SMESHGUI_Preferences_ColorDlg *aDlg =
664 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
665 aDlg->SetColor(1, c);
666 aDlg->SetColor(2, e);
667 aDlg->SetColor(3, n);
668 aDlg->SetColor(4, b);
669 aDlg->SetIntValue(1, Edgewidth);
670 aDlg->SetIntValue(2, intValue);
671 aDlg->SetIntValue(3, int(Shrink*100.));
673 QColor color = aDlg->GetColor(1);
674 QColor edgecolor = aDlg->GetColor(2);
675 QColor nodecolor = aDlg->GetColor(3);
676 QColor backfacecolor = aDlg->GetColor(4);
677 /* actor color and backface color */
678 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
679 vtkFloatingPointType (color.green()) / 255.,
680 vtkFloatingPointType (color.blue()) / 255.);
681 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
682 vtkFloatingPointType (backfacecolor.green()) / 255.,
683 vtkFloatingPointType (backfacecolor.blue()) / 255.);
686 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
687 vtkFloatingPointType (edgecolor.green()) / 255.,
688 vtkFloatingPointType (edgecolor.blue()) / 255.);
690 /* Shrink factor and size edges */
691 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
692 anActor->SetLineWidth(aDlg->GetIntValue(1));
694 /* Nodes color and size */
695 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
696 vtkFloatingPointType (nodecolor.green()) / 255.,
697 vtkFloatingPointType (nodecolor.blue()) / 255.);
698 anActor->SetNodeSize(aDlg->GetIntValue(2));
700 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
701 if( !aGroupObject->_is_nil() )
703 SALOMEDS::Color aColor;
704 aColor.R = (float)color.red() / 255.0;
705 aColor.G = (float)color.green() / 255.0;
706 aColor.B = (float)color.blue() / 255.0;
707 aGroupObject->SetColor( aColor );
717 SMESH::RepaintCurrentView();
721 void Control( int theCommandID )
723 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
724 SALOME_ListIO selected;
726 aSel->selectedObjects( selected );
728 if( !selected.IsEmpty() ){
729 Handle(SALOME_InteractiveObject) anIO = selected.First();
732 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
733 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
734 switch ( theCommandID ){
736 aTitle = QObject::tr( "LENGTH_EDGES" );
737 aControl = SMESH_Actor::eLength;
740 aTitle = QObject::tr( "LENGTH2D_EDGES" );
741 aControl = SMESH_Actor::eLength2D;
744 aTitle = QObject::tr( "FREE_EDGES" );
745 aControl = SMESH_Actor::eFreeEdges;
748 aTitle = QObject::tr( "FREE_BORDERS" );
749 aControl = SMESH_Actor::eFreeBorders;
752 aTitle = QObject::tr( "MULTI_BORDERS" );
753 aControl = SMESH_Actor::eMultiConnection;
756 aTitle = QObject::tr( "MULTI2D_BORDERS" );
757 aControl = SMESH_Actor::eMultiConnection2D;
760 aTitle = QObject::tr( "AREA_ELEMENTS" );
761 aControl = SMESH_Actor::eArea;
764 aTitle = QObject::tr( "TAPER_ELEMENTS" );
765 aControl = SMESH_Actor::eTaper;
768 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
769 aControl = SMESH_Actor::eAspectRatio;
772 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
773 aControl = SMESH_Actor::eAspectRatio3D;
776 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
777 aControl = SMESH_Actor::eMinimumAngle;
780 aTitle = QObject::tr( "WARP_ELEMENTS" );
781 aControl = SMESH_Actor::eWarping;
784 aTitle = QObject::tr( "SKEW_ELEMENTS" );
785 aControl = SMESH_Actor::eSkew;
788 aTitle = QObject::tr( "SMESH_VOLUME" );
789 aControl = SMESH_Actor::eVolume3D;
792 anActor->SetControlMode(aControl);
793 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
794 SMESH::RepaintCurrentView();
801 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
802 MeshObjectType theType,
803 const QString theInTypeName,
804 QString & theOutTypeName)
806 SMESH_TypeFilter aTypeFilter( theType );
808 if( !theIO.IsNull() )
810 entry = theIO->getEntry();
811 LightApp_DataOwner owner( entry );
812 if ( aTypeFilter.isOk( &owner )) {
813 theOutTypeName = theInTypeName;
821 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
823 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
824 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
826 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
827 CORBA::String_var anID = aSComp->GetID().c_str();
828 if (!strcmp(anID.in(),theIO->getEntry()))
834 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
835 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
836 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
837 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
838 CheckOIType ( theIO, GROUP, "Group", aTypeName )
846 QString CheckHomogeneousSelection()
848 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
849 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
850 SALOME_ListIO selected;
852 aSel->selectedObjects( selected );
854 QString RefType = CheckTypeObject(selected.First());
855 SALOME_ListIteratorOfListIO It(selected);
856 for (; It.More(); It.Next())
858 Handle(SALOME_InteractiveObject) IObject = It.Value();
859 QString Type = CheckTypeObject(IObject);
860 if (Type.compare(RefType) != 0)
861 return "Heterogeneous Selection";
868 void SMESHGUI::OnEditDelete()
870 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
871 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
872 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
874 QString aParentComponent = QString::null;
875 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
877 QString cur = anIt.Value()->getComponentDataType();
878 if( aParentComponent.isNull() )
879 aParentComponent = cur;
880 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
881 aParentComponent = "";
884 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
885 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
886 QObject::tr("ERR_ERROR"),
887 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
888 QObject::tr("BUT_OK") );
891 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
892 if (SUIT_MessageBox::warn2
893 (SMESHGUI::desktop(),
894 QObject::tr("SMESH_WRN_WARNING"),
895 QObject::tr("SMESH_REALLY_DELETE"),
896 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
899 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
900 SUIT_ViewManager* vm = anApp->activeViewManager();
901 int nbSf = vm->getViewsCount();
903 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
904 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
905 _PTR(GenericAttribute) anAttr;
906 _PTR(AttributeIOR) anIOR;
908 SALOME_ListIteratorOfListIO It(selected);
910 aStudyBuilder->NewCommand(); // There is a transaction
911 for(; It.More(); It.Next()){ // loop on selected IO's
912 Handle(SALOME_InteractiveObject) IObject = It.Value();
913 if(IObject->hasEntry()) {
914 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
916 // disable removal of "SMESH" component object
917 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
919 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
923 // put the whole hierarchy of sub-objects of the selected SO into a list and
924 // then treat them all starting from the deepest objects (at list back)
926 list< _PTR(SObject) > listSO;
927 listSO.push_back( aSO );
928 list< _PTR(SObject) >::iterator itSO = listSO.begin();
929 for ( ; itSO != listSO.end(); ++itSO ) {
930 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
931 for (it->InitEx(false); it->More(); it->Next())
932 listSO.push_back( it->Value() );
935 // treat SO's in the list starting from the back
937 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
938 for ( ; ritSO != listSO.rend(); ++ritSO ) {
939 _PTR(SObject) SO = *ritSO;
941 string anEntry = SO->GetID();
943 /** Erase graphical object **/
944 if(SO->FindAttribute(anAttr, "AttributeIOR")){
945 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
946 for(int i = 0; i < nbSf; i++){
947 SUIT_ViewWindow *sf = aViews[i];
948 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
949 SMESH::RemoveActor(sf,anActor);
954 /** Remove an object from data structures **/
955 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
956 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
957 if ( !aGroup->_is_nil() ) { // DELETE GROUP
958 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
959 aMesh->RemoveGroup( aGroup );
961 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
962 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
963 aMesh->RemoveSubMesh( aSubMesh );
965 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
967 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
970 IObject = new SALOME_InteractiveObject
971 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
972 QString objType = CheckTypeObject(IObject);
973 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
974 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
975 aStudyBuilder->RemoveObjectWithChildren( SO );
977 else {// default action: remove SObject from the study
978 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
979 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
981 aStudyBuilder->RemoveObjectWithChildren( SO );
985 } /* listSO back loop */
986 } /* IObject->hasEntry() */
988 aStudyBuilder->CommitCommand();
990 /* Clear any previous selection */
992 aSel->setSelectedObjects( l1 );
994 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
999 SMESHGUI_EXPORT CAM_Module* createModule()
1001 return new SMESHGUI();
1005 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1007 //=============================================================================
1011 //=============================================================================
1012 SMESHGUI::SMESHGUI() :
1013 SalomeApp_Module( "SMESH" )
1015 if ( CORBA::is_nil( myComponentSMESH ) )
1017 CORBA::Boolean anIsEmbeddedMode;
1018 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1021 myActiveDialogBox = 0;
1022 myFilterLibraryDlg = 0;
1026 SMESH::GetFilterManager();
1027 SMESH::GetPattern();
1029 /* load resources for all available meshers */
1030 SMESH::InitAvailableHypotheses();
1033 //=============================================================================
1037 //=============================================================================
1038 SMESHGUI::~SMESHGUI()
1040 SMESH::GetFilterManager()->Destroy();
1041 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1044 //=============================================================================
1048 //=============================================================================
1049 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1051 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1053 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1058 bool SMESHGUI::automaticUpdate()
1060 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1064 return resMgr->booleanValue( "SMESH", "auto_update", false );
1067 //=============================================================================
1071 //=============================================================================
1072 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1074 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1077 //=============================================================================
1081 //=============================================================================
1082 SMESHGUI* SMESHGUI::GetSMESHGUI()
1084 SMESHGUI* smeshMod = 0;
1085 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1088 CAM_Module* module = app->module( "Mesh" );
1089 smeshMod = dynamic_cast<SMESHGUI*>( module );
1092 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1094 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1097 _PTR(Study) aStudy = study->studyDS();
1099 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1108 Standard_EXPORT SMESHGUI* GetComponentGUI()
1110 return SMESHGUI::GetSMESHGUI();
1114 //=============================================================================
1118 //=============================================================================
1119 void SMESHGUI::SetState(int aState)
1124 //=============================================================================
1128 //=============================================================================
1129 void SMESHGUI::ResetState()
1134 //=============================================================================
1138 //=============================================================================
1139 void SMESHGUI::EmitSignalDeactivateDialog()
1141 emit SignalDeactivateActiveDialog();
1144 //=============================================================================
1148 //=============================================================================
1149 void SMESHGUI::EmitSignalStudyFrameChanged()
1151 emit SignalStudyFrameChanged();
1154 //=============================================================================
1158 //=============================================================================
1159 void SMESHGUI::EmitSignalCloseAllDialogs()
1161 emit SignalCloseAllDialogs();
1164 //=============================================================================
1168 //=============================================================================
1169 QDialog *SMESHGUI::GetActiveDialogBox()
1171 return myActiveDialogBox;
1174 //=============================================================================
1178 //=============================================================================
1179 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1181 myActiveDialogBox = (QDialog *) aDlg;
1185 //=============================================================================
1189 //=============================================================================
1190 SUIT_Desktop* SMESHGUI::desktop()
1192 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1194 return app->desktop();
1199 //=============================================================================
1203 //=============================================================================
1204 SalomeApp_Study* SMESHGUI::activeStudy()
1206 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1208 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1213 //=============================================================================
1217 //=============================================================================
1218 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1220 /* Here the position is on the bottom right corner - 10 */
1221 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1223 SUIT_Desktop *PP = desktop();
1224 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1225 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1229 //=============================================================================
1233 //=============================================================================
1234 static int isStudyLocked(_PTR(Study) theStudy){
1235 return theStudy->GetProperties()->IsLocked();
1238 static bool checkLock(_PTR(Study) theStudy) {
1239 if (isStudyLocked(theStudy)) {
1240 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1241 QObject::tr("WRN_WARNING"),
1242 QObject::tr("WRN_STUDY_LOCKED"),
1243 QObject::tr("BUT_OK") );
1249 //=======================================================================
1250 //function : CheckActiveStudyLocked
1252 //=======================================================================
1254 bool SMESHGUI::isActiveStudyLocked()
1256 _PTR(Study) aStudy = activeStudy()->studyDS();
1257 return checkLock( aStudy );
1260 //=============================================================================
1264 //=============================================================================
1265 bool SMESHGUI::OnGUIEvent( int theCommandID )
1267 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1271 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1272 SUIT_ResourceMgr* mgr = resourceMgr();
1276 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1277 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1280 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1281 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1283 //QAction* act = action( theCommandID );
1285 switch (theCommandID) {
1287 if(checkLock(aStudy)) break;
1295 if(checkLock(aStudy)) break;
1296 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1300 case 122: // EXPORT MED
1309 ::ExportMeshToFile(theCommandID);
1313 case 200: // SCALAR BAR
1315 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1316 SALOME_ListIO selected;
1318 aSel->selectedObjects( selected );
1320 if( selected.Extent() ) {
1321 Handle(SALOME_InteractiveObject) anIO = selected.First();
1322 if( anIO->hasEntry() ) {
1323 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1324 anActor->SetControlMode( SMESH_Actor::eNone );
1332 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1342 ::DisableAutoColor();
1345 case 1134: // Clipping
1346 case 1133: // Tranparency
1347 case 1132: // Colors / Size
1354 ::SetDisplayMode(theCommandID);
1360 case 219: // Volumes
1361 case 220: // All Entity
1362 ::SetDisplayEntity(theCommandID);
1367 if(checkLock(aStudy)) break;
1369 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1372 SMESH::UpdateView();
1374 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1375 SMESH::OnVisuException();
1377 catch (...) { // PAL16774 (Crash after display of many groups)
1378 SMESH::OnVisuException();
1382 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1383 aSel->selectedObjects( l );
1384 aSel->setSelectedObjects( l );
1389 case 301: // DISPLAY
1390 case 302: // DISPLAY ONLY
1392 SMESH::EDisplaing anAction;
1393 switch (theCommandID) {
1394 case 300: anAction = SMESH::eErase; break;
1395 case 301: anAction = SMESH::eDisplay; break;
1396 case 302: anAction = SMESH::eDisplayOnly; break;
1399 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1400 SALOME_ListIO sel_objects, to_process;
1402 aSel->selectedObjects( sel_objects );
1404 if( theCommandID==302 )
1405 startOperation( myEraseAll );
1407 extractContainers( sel_objects, to_process );
1410 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1414 SALOME_ListIteratorOfListIO It( to_process );
1415 for (; It.More(); It.Next()) {
1416 Handle(SALOME_InteractiveObject) IOS = It.Value();
1417 if (IOS->hasEntry()) {
1418 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1419 break; // PAL16774 (Crash after display of many groups)
1420 if (anAction == SMESH::eDisplayOnly)
1421 anAction = SMESH::eDisplay;
1426 // PAL13338 + PAL15161 -->
1427 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1428 SMESH::UpdateView();
1429 // PAL13338 + PAL15161 <--
1431 catch (...) { // PAL16774 (Crash after display of many groups)
1432 SMESH::OnVisuException();
1435 if (anAction == SMESH::eErase) {
1437 aSel->setSelectedObjects( l1 );
1440 aSel->setSelectedObjects( to_process );
1447 if(checkLock(aStudy)) break;
1450 EmitSignalDeactivateDialog();
1452 new SMESHGUI_NodesDlg(this);
1455 SUIT_MessageBox::warn1(desktop(),
1456 tr("SMESH_WRN_WARNING"),
1457 tr("SMESH_WRN_VIEWER_VTK"),
1458 tr("SMESH_BUT_OK"));
1463 case 2151: // FILTER
1467 EmitSignalDeactivateDialog();
1468 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1473 case 406: // MOVE NODE
1477 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1478 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1482 if(checkLock(aStudy)) break;
1483 new SMESHGUI_MoveNodesDlg(this);
1487 case 701: // COMPUTE MESH
1489 if (checkLock(aStudy)) break;
1491 startOperation( 701 );
1495 case 702: // Create mesh
1496 startOperation( 702 );
1498 case 703: // Create sub-mesh
1499 startOperation( 703 );
1501 case 704: // Edit mesh/sub-mesh
1502 startOperation( 704 );
1504 case 710: // Build compound mesh
1506 if (checkLock(aStudy)) break;
1507 EmitSignalDeactivateDialog();
1508 new SMESHGUI_BuildCompoundDlg( this );
1511 case 407: // DIAGONAL INVERSION
1512 case 408: // Delete diagonal
1516 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1517 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1521 if ( checkLock( aStudy ) )
1524 /*Standard_Boolean aRes;
1525 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1526 if ( aMesh->_is_nil() )
1528 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1529 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1533 EmitSignalDeactivateDialog();
1534 if ( theCommandID == 407 )
1535 new SMESHGUI_TrianglesInversionDlg(this);
1537 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1540 case 409: // Change orientation
1541 case 410: // Union of triangles
1542 case 411: // Cutting of quadrangles
1546 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1547 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1551 if ( checkLock( aStudy ) )
1554 EmitSignalDeactivateDialog();
1555 SMESHGUI_MultiEditDlg* aDlg = NULL;
1556 if ( theCommandID == 409 )
1557 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1558 else if ( theCommandID == 410 )
1559 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1561 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1566 case 412: // Smoothing
1568 if(checkLock(aStudy)) break;
1570 EmitSignalDeactivateDialog();
1571 new SMESHGUI_SmoothingDlg( this );
1574 SUIT_MessageBox::warn1(desktop(),
1575 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1576 tr("SMESH_BUT_OK"));
1580 case 413: // Extrusion
1582 if (checkLock(aStudy)) break;
1584 EmitSignalDeactivateDialog();
1585 new SMESHGUI_ExtrusionDlg ( this );
1587 SUIT_MessageBox::warn1(desktop(),
1588 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1589 tr("SMESH_BUT_OK"));
1593 case 414: // Revolution
1595 if(checkLock(aStudy)) break;
1597 EmitSignalDeactivateDialog();
1598 new SMESHGUI_RevolutionDlg( this );
1601 SUIT_MessageBox::warn1(desktop(),
1602 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1603 tr("SMESH_BUT_OK"));
1607 case 415: // Pattern mapping
1609 if ( checkLock( aStudy ) )
1613 EmitSignalDeactivateDialog();
1614 new SMESHGUI_MeshPatternDlg( this );
1617 SUIT_MessageBox::warn1(desktop(),
1618 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1619 tr("SMESH_BUT_OK"));
1623 case 416: // Extrusion along a path
1625 if (checkLock(aStudy)) break;
1627 EmitSignalDeactivateDialog();
1628 new SMESHGUI_ExtrusionAlongPathDlg( this );
1630 SUIT_MessageBox::warn1(desktop(),
1631 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1632 tr("SMESH_BUT_OK"));
1636 case 417: // Convert mesh to quadratic
1638 startOperation( 417 );
1639 /* if (checkLock(aStudy)) break;
1641 EmitSignalDeactivateDialog();
1642 new SMESHGUI_ConvToQuadDlg();
1644 SUIT_MessageBox::warn1(desktop(),
1645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1646 tr("SMESH_BUT_OK"));
1650 case 801: // CREATE GROUP
1654 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1655 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1659 if(checkLock(aStudy)) break;
1660 EmitSignalDeactivateDialog();
1661 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1663 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1664 SALOME_ListIO selected;
1666 aSel->selectedObjects( selected );
1668 int nbSel = selected.Extent();
1670 // check if mesh is selected
1671 aMesh = SMESH::GetMeshByIO( selected.First() );
1673 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1678 case 802: // CONSTRUCT GROUP
1682 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1683 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1687 if(checkLock(aStudy)) break;
1688 EmitSignalDeactivateDialog();
1690 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1691 SALOME_ListIO selected;
1693 aSel->selectedObjects( selected );
1695 int nbSel = selected.Extent();
1697 // check if submesh is selected
1698 Handle(SALOME_InteractiveObject) IObject = selected.First();
1699 if (IObject->hasEntry()) {
1700 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1702 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1703 if (!aSubMesh->_is_nil()) {
1705 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1706 // get submesh elements list by types
1707 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1708 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1709 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1710 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1711 // create group for each type o elements
1712 QString aName = IObject->getName();
1713 if (aNodes->length() > 0) {
1714 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1715 aGroup->Add(aNodes.inout());
1717 if (aEdges->length() > 0) {
1718 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1719 aGroup->Add(aEdges.inout());
1721 if (aFaces->length() > 0) {
1722 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1723 aGroup->Add(aFaces.inout());
1725 if (aVolumes->length() > 0) {
1726 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1727 aGroup->Add(aVolumes.inout());
1732 catch(const SALOME::SALOME_Exception & S_ex){
1733 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1740 SUIT_MessageBox::warn1(desktop(),
1741 tr("SMESH_WRN_WARNING"),
1742 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1743 tr("SMESH_BUT_OK"));
1748 case 803: // EDIT GROUP
1752 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1753 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1757 if(checkLock(aStudy)) break;
1758 EmitSignalDeactivateDialog();
1760 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1761 SALOME_ListIO selected;
1763 aSel->selectedObjects( selected );
1765 SALOME_ListIteratorOfListIO It (selected);
1766 int nbSelectedGroups = 0;
1767 for ( ; It.More(); It.Next() )
1769 SMESH::SMESH_GroupBase_var aGroup =
1770 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1771 if (!aGroup->_is_nil()) {
1773 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1777 if (nbSelectedGroups == 0)
1779 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1785 case 804: // Add elements to group
1787 if(checkLock(aStudy)) break;
1788 if (myState == 800) {
1789 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1790 if (aDlg) aDlg->onAdd();
1795 case 805: // Remove elements from group
1797 if(checkLock(aStudy)) break;
1798 if (myState == 800) {
1799 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1800 if (aDlg) aDlg->onRemove();
1805 case 810: // Union Groups
1806 case 811: // Intersect groups
1807 case 812: // Cut groups
1811 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1812 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1816 if ( checkLock( aStudy ) )
1819 EmitSignalDeactivateDialog();
1822 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1823 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1824 else aMode = SMESHGUI_GroupOpDlg::CUT;
1826 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1830 case 813: // Delete groups with their contents
1834 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1835 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1839 if ( checkLock( aStudy ) )
1842 EmitSignalDeactivateDialog();
1844 new SMESHGUI_DeleteGroupDlg( this );
1848 case 900: // MESH INFOS
1850 EmitSignalDeactivateDialog();
1851 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1852 SALOME_ListIO selected;
1854 aSel->selectedObjects( selected );
1856 if ( selected.Extent() > 1 ) { // a dlg for each IO
1858 SALOME_ListIteratorOfListIO It (selected);
1859 for ( ; It.More(); It.Next() ) {
1860 IOs.Clear(); IOs.Append( It.Value() );
1861 aSel->setSelectedObjects( IOs );
1862 new SMESHGUI_MeshInfosDlg(this, "", false);
1864 // restore selection
1865 aSel->setSelectedObjects( selected );
1868 new SMESHGUI_MeshInfosDlg(this, "", false);
1872 case 902: // STANDARD MESH INFOS
1874 EmitSignalDeactivateDialog();
1875 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1876 SALOME_ListIO selected;
1878 aSel->selectedObjects( selected );
1880 if ( selected.Extent() > 1 ) { // a dlg for each IO
1882 SALOME_ListIteratorOfListIO It (selected);
1883 for ( ; It.More(); It.Next() ) {
1885 IOs.Append( It.Value() );
1886 aSel->setSelectedObjects( IOs );
1887 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1889 // restore selection
1890 aSel->setSelectedObjects( selected );
1893 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1897 case 903: // WHAT IS
1899 EmitSignalDeactivateDialog();
1900 new SMESHGUI_WhatIsDlg( this, "", false);
1904 case 1100: // EDIT HYPOTHESIS
1906 if(checkLock(aStudy)) break;
1908 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1909 SALOME_ListIO selected;
1911 aSel->selectedObjects( selected );
1913 int nbSel = selected.Extent();
1916 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1917 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1919 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1920 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1921 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1922 if ( !aHypothesis->_is_nil() )
1924 CORBA::String_var aHypType = aHypothesis->GetName();
1925 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1927 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1934 updateObjBrowser( true );
1938 case 1101: // RENAME
1940 if ( checkLock( aStudy ) )
1943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1944 SALOME_ListIO selected;
1946 aSel->selectedObjects( selected );
1948 SALOME_ListIteratorOfListIO It( selected );
1949 for ( ; It.More(); It.Next() )
1951 Handle(SALOME_InteractiveObject) IObject = It.Value();
1952 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1953 _PTR(GenericAttribute) anAttr;
1954 _PTR(AttributeName) aName;
1957 if ( obj->FindAttribute(anAttr, "AttributeName") )
1960 QString newName = QString(aName->Value().c_str());
1961 newName = LightApp_NameDlg::getName(desktop(), newName);
1962 if ( !newName.isEmpty() )
1964 //old source: aStudy->renameIObject( IObject, newName );
1965 aName->SetValue( newName.latin1() );
1967 // if current object is group update group's name
1968 SMESH::SMESH_GroupBase_var aGroup =
1969 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1970 if (!aGroup->_is_nil() )
1971 aGroup->SetName( newName.latin1() );
1981 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1983 if(checkLock(aStudy)) break;
1984 SUIT_OverrideCursor wc;
1986 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1987 SALOME_ListIO selected;
1989 aSel->selectedObjects( selected, QString::null, false );
1991 SALOME_ListIteratorOfListIO It(selected);
1992 for (int i = 0; It.More(); It.Next(), i++) {
1993 Handle(SALOME_InteractiveObject) IObject = It.Value();
1994 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1997 aSel->setSelectedObjects( l1 );
2002 case 401: // GEOM::EDGE
2003 case 4021: // TRIANGLE
2005 case 4023: // POLYGON
2009 if(checkLock(aStudy)) break;
2011 EmitSignalDeactivateDialog();
2012 SMDSAbs_ElementType type = SMDSAbs_Edge;
2014 switch (theCommandID) {
2015 case 4021: // TRIANGLE
2016 type = SMDSAbs_Face; nbNodes = 3; break;
2018 type = SMDSAbs_Face; nbNodes = 4; break;
2020 type = SMDSAbs_Volume; nbNodes = 4; break;
2021 case 4023: // POLYGON
2022 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2024 type = SMDSAbs_Volume; nbNodes = 8; break;
2025 case 4033: // POLYHEDRE
2026 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2029 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2032 SUIT_MessageBox::warn1(desktop(),
2033 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2034 tr("SMESH_BUT_OK"));
2038 case 4033: // POLYHEDRON
2040 if(checkLock(aStudy)) break;
2042 EmitSignalDeactivateDialog();
2043 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2046 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2048 tr("SMESH_BUT_OK"));
2052 case 4034: // QUADRATIC EDGE
2053 case 4035: // QUADRATIC TRIANGLE
2054 case 4036: // QUADRATIC QUADRANGLE
2055 case 4037: // QUADRATIC TETRAHEDRON
2056 case 4038: // QUADRATIC PYRAMID
2057 case 4039: // QUADRATIC PENTAHEDRON
2058 case 4040: // QUADRATIC HEXAHEDRON
2060 if(checkLock(aStudy)) break;
2062 EmitSignalDeactivateDialog();
2065 switch (theCommandID) {
2067 type = QUAD_EDGE; break;
2069 type = QUAD_TRIANGLE; break;
2071 type = QUAD_QUADRANGLE; break;
2073 type = QUAD_TETRAHEDRON; break;
2075 type = QUAD_PYRAMID; break;
2077 type = QUAD_PENTAHEDRON; break;
2079 type = QUAD_HEXAHEDRON;
2083 new SMESHGUI_AddQuadraticElementDlg( this, type );
2086 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2087 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2088 tr("SMESH_BUT_OK"));
2092 case 4041: // REMOVES NODES
2094 if(checkLock(aStudy)) break;
2096 EmitSignalDeactivateDialog();
2097 new SMESHGUI_RemoveNodesDlg(this);
2100 SUIT_MessageBox::warn1(desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2102 tr("SMESH_BUT_OK"));
2106 case 4042: // REMOVES ELEMENTS
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 new SMESHGUI_RemoveElementsDlg(this);
2115 SUIT_MessageBox::warn1(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2117 tr("SMESH_BUT_OK"));
2121 case 4051: // RENUMBERING NODES
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_RenumberingDlg( this, "", 0);
2130 SUIT_MessageBox::warn1(desktop(),
2131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2132 tr("SMESH_BUT_OK"));
2136 case 4052: // RENUMBERING ELEMENTS
2138 if(checkLock(aStudy)) break;
2140 EmitSignalDeactivateDialog();
2141 new SMESHGUI_RenumberingDlg( this, "", 1);
2145 SUIT_MessageBox::warn1(desktop(),
2146 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2147 tr("SMESH_BUT_OK"));
2151 case 4061: // TRANSLATION
2153 if(checkLock(aStudy)) break;
2155 EmitSignalDeactivateDialog();
2156 new SMESHGUI_TranslationDlg( this );
2159 SUIT_MessageBox::warn1(desktop(),
2160 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2161 tr("SMESH_BUT_OK"));
2165 case 4062: // ROTATION
2167 if(checkLock(aStudy)) break;
2169 EmitSignalDeactivateDialog();
2170 new SMESHGUI_RotationDlg( this );
2173 SUIT_MessageBox::warn1(desktop(),
2174 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2175 tr("SMESH_BUT_OK"));
2179 case 4063: // SYMMETRY
2181 if(checkLock(aStudy)) break;
2183 EmitSignalDeactivateDialog();
2184 new SMESHGUI_SymmetryDlg( this );
2187 SUIT_MessageBox::warn1(desktop(),
2188 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2189 tr("SMESH_BUT_OK"));
2193 case 4064: // SEWING
2195 if(checkLock(aStudy)) break;
2197 EmitSignalDeactivateDialog();
2198 new SMESHGUI_SewingDlg( this );
2201 SUIT_MessageBox::warn1(desktop(),
2202 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2203 tr("SMESH_BUT_OK"));
2207 case 4065: // MERGE NODES
2209 if(checkLock(aStudy)) break;
2211 EmitSignalDeactivateDialog();
2212 new SMESHGUI_EditMeshDlg( this, 0 );
2215 SUIT_MessageBox::warn1(desktop(),
2216 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2217 tr("SMESH_BUT_OK"));
2221 case 4066: // MERGE EQUAL ELEMENTS
2223 if (checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 new SMESHGUI_EditMeshDlg( this, 1 );
2228 SUIT_MessageBox::warn1(desktop(),
2229 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2230 tr("SMESH_BUT_OK"));
2235 case 4067: // MAKE MESH PASS THROUGH POINT
2236 startOperation( 4067 );
2239 case 5105: // Library of selection filters
2241 static QValueList<int> aTypes;
2242 if ( aTypes.isEmpty() )
2244 aTypes.append( SMESH::NODE );
2245 aTypes.append( SMESH::EDGE );
2246 aTypes.append( SMESH::FACE );
2247 aTypes.append( SMESH::VOLUME );
2249 if (!myFilterLibraryDlg)
2250 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2251 else if (myFilterLibraryDlg->isHidden())
2252 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2253 myFilterLibraryDlg->raise();
2257 case 6017: // CONTROLS
2273 LightApp_SelectionMgr* mgr = selectionMgr();
2274 SALOME_ListIO selected; mgr->selectedObjects( selected );
2276 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2277 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2279 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2280 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2281 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2282 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2283 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2284 ::Control( theCommandID );
2289 SUIT_MessageBox::warn1(desktop(),
2290 tr( "SMESH_WRN_WARNING" ),
2291 tr( "SMESH_BAD_SELECTION" ),
2292 tr( "SMESH_BUT_OK" ) );
2296 SUIT_MessageBox::warn1(desktop(),
2297 tr( "SMESH_WRN_WARNING" ),
2298 tr( "NOT_A_VTK_VIEWER" ),
2299 tr( "SMESH_BUT_OK" ) );
2304 LightApp_SelectionMgr* mgr = selectionMgr();
2305 SALOME_ListIO selected; mgr->selectedObjects( selected );
2307 SALOME_ListIteratorOfListIO it(selected);
2308 for(; it.More(); it.Next()) {
2309 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2310 if(anIObject->hasEntry()) {
2311 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2312 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2320 LightApp_SelectionMgr* mgr = selectionMgr();
2321 SALOME_ListIO selected; mgr->selectedObjects( selected );
2323 if (selected.Extent() == 1) {
2324 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2325 if(anIObject->hasEntry())
2326 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2327 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2334 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2335 //updateObjBrowser();
2339 //=============================================================================
2343 //=============================================================================
2344 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2349 //=============================================================================
2353 //=============================================================================
2354 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2359 //=============================================================================
2363 //=============================================================================
2364 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2369 //=============================================================================
2370 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2371 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2373 //=============================================================================
2374 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2375 SUIT_ViewWindow* wnd )
2377 if(theIO->hasEntry()){
2378 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2379 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2383 //=======================================================================
2384 // function : createSMESHAction
2386 //=======================================================================
2387 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2390 QWidget* parent = application()->desktop();
2391 SUIT_ResourceMgr* resMgr = resourceMgr();
2393 if ( icon_id.length() )
2394 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2396 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2397 if ( !pix.isNull() )
2398 icon = QIconSet( pix );
2400 QString tooltip = tr( QString( "TOP_" )+po_id ),
2401 menu = tr( QString( "MEN_" )+po_id ),
2402 status_bar = tr( QString( "STB_" )+po_id );
2404 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2407 //=======================================================================
2408 // function : createPopupItem
2410 //=======================================================================
2411 void SMESHGUI::createPopupItem( const int id,
2412 const QString& clients,
2413 const QString& types,
2414 const QString& theRule,
2419 parentId = popupMgr()->actionId( action( pId ) );
2421 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2422 popupMgr()->insert( action( id ), parentId, 0 );
2424 QChar lc = QtxPopupMgr::Selection::defEquality();
2425 QString rule = "(%1) and (%2) and (%3)";
2426 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2427 if( clients.isEmpty() )
2428 rule = rule.arg( QString( "true" ) );
2430 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2431 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2434 bool cont = myRules.contains( id );
2436 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2438 popupMgr()->setRule( action( id ), rule, true );
2439 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2442 //=======================================================================
2443 // function : initialize
2445 //=======================================================================
2446 void SMESHGUI::initialize( CAM_Application* app )
2448 SalomeApp_Module::initialize( app );
2450 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2452 /* Automatic Update flag */
2453 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2455 // ----- create actions --------------
2457 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2458 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2459 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2460 createSMESHAction( 114, "NUM" );
2461 createSMESHAction( 121, "DAT" );
2462 createSMESHAction( 122, "MED" );
2463 createSMESHAction( 123, "UNV" );
2464 createSMESHAction( 140, "STL" );
2465 createSMESHAction( 124, "EXPORT_DAT" );
2466 createSMESHAction( 125, "EXPORT_MED" );
2467 createSMESHAction( 126, "EXPORT_UNV" );
2468 createSMESHAction( 141, "EXPORT_STL" );
2469 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2470 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2471 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2472 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2473 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2474 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2475 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2476 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2477 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2478 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2479 createSMESHAction( 804, "ADD" );
2480 createSMESHAction( 805, "REMOVE" );
2481 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2482 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2483 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2484 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2485 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2486 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2487 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2488 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2489 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2490 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2491 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2492 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2493 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2494 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2495 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2496 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2497 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2498 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2499 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2500 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2501 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2502 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2503 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2504 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2505 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2506 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2507 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2508 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2509 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2510 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2511 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2512 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2513 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2514 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2515 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2516 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2517 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2518 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2519 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2520 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2521 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2522 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2523 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2524 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2525 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2526 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2527 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2528 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2529 createSMESHAction( 415, "MAP", "ICON_MAP" );
2530 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2531 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2532 createSMESHAction( 200, "RESET" );
2533 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2534 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2535 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2536 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2537 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2538 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2539 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2540 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2541 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2542 createSMESHAction( 220, "ALL" );
2543 createSMESHAction( 1100, "EDIT_HYPO" );
2544 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2545 createSMESHAction( 1102, "UNASSIGN" );
2546 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2547 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2548 createSMESHAction( 1131, "DISPMODE" );
2549 createSMESHAction( 1132, "COLORS" );
2550 createSMESHAction( 1133, "TRANSP" );
2551 createSMESHAction( 1134, "CLIP" );
2552 createSMESHAction( 1135, "DISP_ENT" );
2553 createSMESHAction( 1136, "AUTO_COLOR" );
2554 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2555 createSMESHAction( 2000, "CTRL" );
2557 createSMESHAction( 300, "ERASE" );
2558 createSMESHAction( 301, "DISPLAY" );
2559 createSMESHAction( 302, "DISPLAY_ONLY" );
2560 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2561 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2562 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2563 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2564 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2565 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2566 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2567 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2569 // ----- create menu --------------
2570 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2571 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2572 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2573 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2574 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2575 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2576 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2578 createMenu( separator(), fileId );
2580 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2581 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2582 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2583 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2584 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2585 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2587 createMenu( 111, importId, -1 );
2588 createMenu( 112, importId, -1 );
2589 createMenu( 113, importId, -1 );
2591 createMenu( 121, exportId, -1 );
2592 createMenu( 122, exportId, -1 );
2593 createMenu( 123, exportId, -1 );
2594 createMenu( 140, exportId, -1 ); // export to stl STL
2596 createMenu( separator(), fileId, 10 );
2598 createMenu( 33, editId, -1 );
2600 createMenu( 5105, toolsId, -1 );
2602 createMenu( 702, meshId, -1 );
2603 createMenu( 703, meshId, -1 );
2604 createMenu( 704, meshId, -1 );
2605 createMenu( 710, meshId, -1 );
2606 createMenu( separator(), meshId, -1 );
2607 createMenu( 701, meshId, -1 );
2608 createMenu( separator(), meshId, -1 );
2609 createMenu( 801, meshId, -1 );
2610 createMenu( 802, meshId, -1 );
2611 createMenu( 803, meshId, -1 );
2612 createMenu( separator(), meshId, -1 );
2613 createMenu( 810, meshId, -1 );
2614 createMenu( 811, meshId, -1 );
2615 createMenu( 812, meshId, -1 );
2616 createMenu( separator(), meshId, -1 );
2617 createMenu( 813, meshId, -1 );
2618 createMenu( separator(), meshId, -1 );
2619 createMenu( 900, meshId, -1 );
2620 createMenu( 902, meshId, -1 );
2621 createMenu( 903, meshId, -1 );
2622 createMenu( separator(), meshId, -1 );
2624 createMenu( 6003, ctrlId, -1 );
2625 createMenu( 6001, ctrlId, -1 );
2626 createMenu( 6004, ctrlId, -1 );
2627 createMenu( separator(), ctrlId, -1 );
2628 createMenu( 6002, ctrlId, -1 );
2629 createMenu( 6018, ctrlId, -1 );
2630 createMenu( 6019, ctrlId, -1 );
2631 createMenu( 6011, ctrlId, -1 );
2632 createMenu( 6012, ctrlId, -1 );
2633 createMenu( 6013, ctrlId, -1 );
2634 createMenu( 6014, ctrlId, -1 );
2635 createMenu( 6015, ctrlId, -1 );
2636 createMenu( 6016, ctrlId, -1 );
2637 createMenu( separator(), ctrlId, -1 );
2638 createMenu( 6017, ctrlId, -1 );
2639 createMenu( 6009, ctrlId, -1 );
2640 createMenu( separator(), ctrlId, -1 );
2642 createMenu( 400, addId, -1 );
2643 createMenu( 401, addId, -1 );
2644 createMenu( 4021, addId, -1 );
2645 createMenu( 4022, addId, -1 );
2646 createMenu( 4023, addId, -1 );
2647 createMenu( 4031, addId, -1 );
2648 createMenu( 4032, addId, -1 );
2649 createMenu( 4033, addId, -1 );
2650 createMenu( separator(), addId, -1 );
2651 createMenu( 4034, addId, -1 );
2652 createMenu( 4035, addId, -1 );
2653 createMenu( 4036, addId, -1 );
2654 createMenu( 4037, addId, -1 );
2655 createMenu( 4038, addId, -1 );
2656 createMenu( 4039, addId, -1 );
2657 createMenu( 4040, addId, -1 );
2659 createMenu( 4041, removeId, -1 );
2660 createMenu( 4042, removeId, -1 );
2662 createMenu( 4051, renumId, -1 );
2663 createMenu( 4052, renumId, -1 );
2665 createMenu( 4061, transfId, -1 );
2666 createMenu( 4062, transfId, -1 );
2667 createMenu( 4063, transfId, -1 );
2668 createMenu( 4064, transfId, -1 );
2669 createMenu( 4065, transfId, -1 );
2670 createMenu( 4066, transfId, -1 );
2672 createMenu( 406, modifyId, -1 );
2673 createMenu( 4067,modifyId, -1 );
2674 createMenu( 407, modifyId, -1 );
2675 createMenu( 408, modifyId, -1 );
2676 createMenu( 409, modifyId, -1 );
2677 createMenu( 410, modifyId, -1 );
2678 createMenu( 411, modifyId, -1 );
2679 createMenu( 412, modifyId, -1 );
2680 createMenu( 413, modifyId, -1 );
2681 createMenu( 416, modifyId, -1 );
2682 createMenu( 414, modifyId, -1 );
2683 createMenu( 415, modifyId, -1 );
2684 createMenu( 417, modifyId, -1 );
2686 createMenu( 214, viewId, -1 );
2688 // ----- create toolbars --------------
2689 int meshTb = createTool( tr( "TB_MESH" ) ),
2690 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2691 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2692 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2693 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2695 createTool( 702, meshTb );
2696 createTool( 703, meshTb );
2697 createTool( 704, meshTb );
2698 createTool( 710, meshTb );
2699 createTool( separator(), meshTb );
2700 createTool( 701, meshTb );
2701 createTool( separator(), meshTb );
2702 createTool( 801, meshTb );
2703 createTool( 802, meshTb );
2704 createTool( 803, meshTb );
2705 createTool( separator(), meshTb );
2706 createTool( 900, meshTb );
2707 createTool( 902, meshTb );
2708 createTool( 903, meshTb );
2709 createTool( separator(), meshTb );
2711 createTool( 6001, ctrlTb );
2712 createTool( 6003, ctrlTb );
2713 createTool( 6004, ctrlTb );
2714 createTool( separator(), ctrlTb );
2715 createTool( 6002, ctrlTb );
2716 createTool( 6018, ctrlTb );
2717 createTool( 6019, ctrlTb );
2718 createTool( 6011, ctrlTb );
2719 createTool( 6012, ctrlTb );
2720 createTool( 6013, ctrlTb );
2721 createTool( 6014, ctrlTb );
2722 createTool( 6015, ctrlTb );
2723 createTool( 6016, ctrlTb );
2724 createTool( separator(), ctrlTb );
2725 createTool( 6017, ctrlTb );
2726 createTool( 6009, ctrlTb );
2727 createTool( separator(), ctrlTb );
2729 createTool( 400, addRemTb );
2730 createTool( 401, addRemTb );
2731 createTool( 4021, addRemTb );
2732 createTool( 4022, addRemTb );
2733 createTool( 4023, addRemTb );
2734 createTool( 4031, addRemTb );
2735 createTool( 4032, addRemTb );
2736 createTool( 4033, addRemTb );
2737 createTool( separator(), addRemTb );
2738 createTool( 4034, addRemTb );
2739 createTool( 4035, addRemTb );
2740 createTool( 4036, addRemTb );
2741 createTool( 4037, addRemTb );
2742 createTool( 4038, addRemTb );
2743 createTool( 4039, addRemTb );
2744 createTool( 4040, addRemTb );
2745 createTool( separator(), addRemTb );
2746 createTool( 4041, addRemTb );
2747 createTool( 4042, addRemTb );
2748 createTool( separator(), addRemTb );
2749 createTool( 4051, addRemTb );
2750 createTool( 4052, addRemTb );
2751 createTool( separator(), addRemTb );
2752 createTool( 4061, addRemTb );
2753 createTool( 4062, addRemTb );
2754 createTool( 4063, addRemTb );
2755 createTool( 4064, addRemTb );
2756 createTool( 4065, addRemTb );
2757 createTool( 4066, addRemTb );
2758 createTool( separator(), addRemTb );
2760 createTool( 406, modifyTb );
2761 createTool( 4067,modifyTb );
2762 createTool( 407, modifyTb );
2763 createTool( 408, modifyTb );
2764 createTool( 409, modifyTb );
2765 createTool( 410, modifyTb );
2766 createTool( 411, modifyTb );
2767 createTool( 412, modifyTb );
2768 createTool( 413, modifyTb );
2769 createTool( 416, modifyTb );
2770 createTool( 414, modifyTb );
2771 createTool( 415, modifyTb );
2772 createTool( 417, modifyTb );
2774 createTool( 214, dispModeTb );
2778 QString OB = "'ObjectBrowser'",
2779 View = "'" + SVTK_Viewer::Type() + "'",
2781 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2782 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2783 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2784 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2785 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2786 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2787 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2788 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2789 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2790 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2791 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2793 mesh_group = mesh + " " + subMesh + " " + group,
2794 hyp_alg = hypo + " " + algo;
2796 // popup for object browser
2798 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2799 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2800 createPopupItem( 803, OB, group ); // EDIT_GROUP
2801 popupMgr()->insert( separator(), -1, 0 );
2802 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2803 createPopupItem( 214, OB, mesh_group ); // UPDATE
2804 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2805 createPopupItem( 902, OB, mesh ); // STD_INFO
2806 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2807 popupMgr()->insert( separator(), -1, 0 );
2808 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2809 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2810 popupMgr()->insert( separator(), -1, 0 );
2811 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2812 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2813 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2814 popupMgr()->insert( separator(), -1, 0 );
2816 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2817 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2818 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2819 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2820 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2821 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2822 popupMgr()->insert( separator(), -1, 0 );
2825 createPopupItem( 803, View, group ); // EDIT_GROUP
2826 createPopupItem( 804, View, elems ); // ADD
2827 createPopupItem( 805, View, elems ); // REMOVE
2828 popupMgr()->insert( separator(), -1, 0 );
2829 createPopupItem( 214, View, mesh_group ); // UPDATE
2830 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2831 createPopupItem( 902, View, mesh ); // STD_INFO
2832 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2833 popupMgr()->insert( separator(), -1, 0 );
2835 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2836 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2837 popupMgr()->insert( separator(), -1, 0 );
2841 isInvisible("not( isVisible )"),
2842 isEmpty("numberOfNodes = 0"),
2843 isNotEmpty("numberOfNodes <> 0"),
2845 // has nodes, edges, etc in VISIBLE! actor
2846 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2847 hasElems("(count( elemTypes ) > 0)"),
2848 hasDifferentElems("(count( elemTypes ) > 1)"),
2849 hasEdges("({'Edge'} in elemTypes)"),
2850 hasFaces("({'Face'} in elemTypes)"),
2851 hasVolumes("({'Volume'} in elemTypes)");
2853 QString lc = QtxPopupMgr::Selection::defEquality();
2854 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2855 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2856 aType = aType.arg( mesh_group );
2857 QString aMeshInVTK = aClient + "&&" + aType;
2859 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2860 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2861 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2863 //-------------------------------------------------
2865 //-------------------------------------------------
2866 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2868 popupMgr()->insert( action( 9010 ), anId, -1 );
2869 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2870 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2872 popupMgr()->insert( action( 9011 ), anId, -1 );
2873 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2874 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2876 popupMgr()->insert( separator(), -1, -1 );
2878 //-------------------------------------------------
2880 //-------------------------------------------------
2881 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2883 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2884 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2885 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2887 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2888 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2889 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2891 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2892 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2893 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2895 popupMgr()->insert( separator(), anId, -1 );
2897 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2898 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2899 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2901 //-------------------------------------------------
2903 //-------------------------------------------------
2904 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2906 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2908 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2909 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2910 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2912 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2913 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2914 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2916 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2917 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2918 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2920 popupMgr()->insert( separator(), anId, -1 );
2922 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2923 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2925 //-------------------------------------------------
2927 //-------------------------------------------------
2928 popupMgr()->insert( action( 1132 ), -1, -1 );
2929 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2931 //-------------------------------------------------
2933 //-------------------------------------------------
2934 popupMgr()->insert( action( 1133 ), -1, -1 );
2935 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2937 //-------------------------------------------------
2939 //-------------------------------------------------
2940 popupMgr()->insert( action( 1134 ), -1, -1 );
2941 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2943 popupMgr()->insert( separator(), -1, -1 );
2945 //-------------------------------------------------
2947 //-------------------------------------------------
2949 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2950 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2951 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2953 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2955 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2956 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2958 popupMgr()->insert( separator(), anId, -1 );
2960 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2961 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2962 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2964 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2965 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2966 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2968 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2969 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2970 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2972 popupMgr()->insert( separator(), anId, -1 );
2974 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2975 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2976 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2978 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2979 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2980 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2982 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2983 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2984 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2986 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2987 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2988 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2990 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2991 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2992 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2994 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2995 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2996 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2998 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2999 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3000 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3002 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3003 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3004 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3006 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3007 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3008 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3010 popupMgr()->insert( separator(), anId, -1 );
3012 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3013 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3014 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3016 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3017 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3018 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3020 popupMgr()->insert( separator(), anId, -1 );
3022 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3023 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3025 popupMgr()->insert( separator(), -1, -1 );
3027 //-------------------------------------------------
3029 //-------------------------------------------------
3030 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3031 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3032 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3033 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3035 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3036 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3038 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3039 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3041 popupMgr()->insert( separator(), -1, -1 );
3043 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3044 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3047 //================================================================================
3049 * \brief Return true if SMESH or GEOM objects are selected.
3050 * Is called form LightApp_Module::activateModule() which clear selection if
3051 * not isSelectionCompatible()
3053 //================================================================================
3055 bool SMESHGUI::isSelectionCompatible()
3057 bool isCompatible = true;
3058 SALOME_ListIO selected;
3059 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3060 Sel->selectedObjects( selected );
3062 SALOME_ListIteratorOfListIO It( selected );
3063 for ( ; isCompatible && It.More(); It.Next())
3065 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3066 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3068 return isCompatible;
3071 bool SMESHGUI::activateModule( SUIT_Study* study )
3073 bool res = SalomeApp_Module::activateModule( study );
3075 setMenuShown( true );
3076 setToolShown( true );
3078 // Reset actions accelerator keys
3079 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3080 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3081 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3086 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3088 setMenuShown( false );
3089 setToolShown( false );
3091 EmitSignalCloseAllDialogs();
3093 // Unset actions accelerator keys
3094 action(111)->setAccel(QKeySequence()); // Import DAT
3095 action(112)->setAccel(QKeySequence()); // Import UNV
3096 action(113)->setAccel(QKeySequence()); // Import MED
3098 return SalomeApp_Module::deactivateModule( study );
3101 void SMESHGUI::studyClosed( SUIT_Study* s )
3103 SMESH::RemoveVisuData( s->id() );
3104 SalomeApp_Module::studyClosed( s );
3107 void SMESHGUI::OnGUIEvent()
3109 const QObject* obj = sender();
3110 if ( !obj || !obj->inherits( "QAction" ) )
3112 int id = actionId((QAction*)obj);
3117 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3119 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3120 if ( CORBA::is_nil( myComponentSMESH ) )
3122 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3124 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3125 return aGUI.myComponentSMESH;
3128 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3129 return myComponentSMESH;
3132 QString SMESHGUI::engineIOR() const
3134 CORBA::ORB_var anORB = getApp()->orb();
3135 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3136 return QString( anIOR.in() );
3139 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3141 SMESHGUI_Selection sel;
3142 sel.init( client, selectionMgr() );
3143 popupMgr()->updatePopup( menu, &sel );
3146 selectionMgr()->selectedObjects( lst );
3147 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3148 Handle(SALOME_InteractiveObject) io = lst.First();
3149 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3150 _PTR(Study) study = appStudy->studyDS();
3151 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3153 title = QString( obj->GetName().c_str() );
3157 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3159 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3160 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3163 void SMESHGUI::viewManagers( QStringList& list ) const
3165 list.append( SVTK_Viewer::Type() );
3168 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3170 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3171 SMESH::UpdateSelectionProp( this );
3174 void SMESHGUI::createPreferences()
3176 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3178 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3179 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3181 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3182 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3183 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3185 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3186 setPreferenceProperty( precGroup, "columns", 1 );
3188 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3190 setPreferenceProperty( prec, "min", 0 );
3191 setPreferenceProperty( prec, "max", 16 );
3193 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3194 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3196 modes.append( "Wireframe" );
3197 modes.append( "Shading" );
3198 modes.append( "Nodes" );
3199 modes.append( "Shrink" );
3200 QValueList<QVariant> indices;
3201 indices.append( 0 );
3202 indices.append( 1 );
3203 indices.append( 2 );
3204 indices.append( 3 );
3205 setPreferenceProperty( dispmode, "strings", modes );
3206 setPreferenceProperty( dispmode, "indexes", indices );
3208 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3209 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3210 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3212 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3213 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3215 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3216 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3218 setPreferenceProperty( nodeSz, "min", 1 );
3219 setPreferenceProperty( nodeSz, "max", 5 );
3221 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3223 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3224 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3225 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3226 addPreference( "", elemGroup, LightApp_Preferences::Space );
3228 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3229 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3231 setPreferenceProperty( elemW, "min", 1 );
3232 setPreferenceProperty( elemW, "max", 5 );
3234 setPreferenceProperty( shrink, "min", 0 );
3235 setPreferenceProperty( shrink, "max", 100 );
3237 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3239 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3241 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3242 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3243 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3245 setPreferenceProperty( selW, "min", 1 );
3246 setPreferenceProperty( selW, "max", 5 );
3248 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3250 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3251 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3253 setPreferenceProperty( preW, "min", 1 );
3254 setPreferenceProperty( preW, "max", 5 );
3256 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3258 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3259 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3260 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3262 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3263 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3265 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3266 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3267 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3268 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3271 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3272 fam.append( tr( "SMESH_FONT_COURIER" ) );
3273 fam.append( tr( "SMESH_FONT_TIMES" ) );
3274 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3276 setPreferenceProperty( tfont, "families", fam );
3277 setPreferenceProperty( tfont, "system", false );
3278 setPreferenceProperty( tfont, "widget_flags", wflag );
3279 setPreferenceProperty( lfont, "families", fam );
3280 setPreferenceProperty( lfont, "system", false );
3281 setPreferenceProperty( lfont, "widget_flags", wflag );
3283 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3285 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3286 setPreferenceProperty( numcol, "min", 2 );
3287 setPreferenceProperty( numcol, "max", 256 );
3289 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3290 setPreferenceProperty( numlab, "min", 2 );
3291 setPreferenceProperty( numlab, "max", 65 );
3293 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3294 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3295 QStringList orients;
3296 orients.append( tr( "SMESH_VERTICAL" ) );
3297 orients.append( tr( "SMESH_HORIZONTAL" ) );
3298 indices.clear(); indices.append( 0 ); indices.append( 1 );
3299 setPreferenceProperty( orient, "strings", orients );
3300 setPreferenceProperty( orient, "indexes", indices );
3302 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3303 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3304 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3305 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3306 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3307 setPreferenceProperty( xv, "step", 0.1 );
3308 setPreferenceProperty( xv, "min", 0.0 );
3309 setPreferenceProperty( xv, "max", 1.0 );
3310 setPreferenceProperty( yv, "step", 0.1 );
3311 setPreferenceProperty( yv, "min", 0.0 );
3312 setPreferenceProperty( yv, "max", 1.0 );
3313 setPreferenceProperty( wv, "step", 0.1 );
3314 setPreferenceProperty( wv, "min", 0.0 );
3315 setPreferenceProperty( wv, "max", 1.0 );
3316 setPreferenceProperty( hv, "min", 0.0 );
3317 setPreferenceProperty( hv, "max", 1.0 );
3318 setPreferenceProperty( hv, "step", 0.1 );
3320 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3321 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3322 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3323 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3324 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3325 setPreferenceProperty( xv, "min", 0.0 );
3326 setPreferenceProperty( xv, "max", 1.0 );
3327 setPreferenceProperty( xv, "step", 0.1 );
3328 setPreferenceProperty( xh, "min", 0.0 );
3329 setPreferenceProperty( xh, "max", 1.0 );
3330 setPreferenceProperty( xh, "step", 0.1 );
3331 setPreferenceProperty( yh, "min", 0.0 );
3332 setPreferenceProperty( yh, "max", 1.0 );
3333 setPreferenceProperty( yh, "step", 0.1 );
3334 setPreferenceProperty( wh, "min", 0.0 );
3335 setPreferenceProperty( wh, "max", 1.0 );
3336 setPreferenceProperty( wh, "step", 0.1 );
3337 setPreferenceProperty( hh, "min", 0.0 );
3338 setPreferenceProperty( hh, "max", 1.0 );
3339 setPreferenceProperty( hh, "step", 0.1 );
3342 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3344 if( sect=="SMESH" ){
3345 float sbX1,sbY1,sbW,sbH;
3346 float aTol = 1.00000009999999;
3347 std::string aWarning;
3348 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3349 if( name=="selection_object_color" || name=="selection_element_color" ||
3350 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3351 name=="selection_precision_node" || name=="selection_precision_element" ||
3352 name=="selection_precision_object")
3353 SMESH::UpdateSelectionProp( this );
3354 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3355 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3356 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3357 if(sbX1+sbW > aTol){
3358 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3361 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3362 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3365 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3366 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3367 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3368 if(sbY1+sbH > aTol){
3369 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3370 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3371 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3374 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3375 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3376 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3377 if(sbX1+sbW > aTol){
3378 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3381 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3382 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3385 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3386 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3387 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3388 if(sbY1+sbH > aTol){
3389 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3392 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3393 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3397 if(aWarning.size() != 0){
3398 aWarning += "The default values are applied instead.";
3399 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3400 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3401 QObject::tr(aWarning.c_str()),
3402 QObject::tr("SMESH_BUT_OK"));
3407 //================================================================================
3409 * \brief Update something in accordance with update flags
3410 * \param theFlags - update flags
3412 * Update viewer or/and object browser etc. in accordance with update flags ( see
3413 * LightApp_UpdateFlags enumeration ).
3415 //================================================================================
3416 void SMESHGUI::update( const int flags )
3418 if ( flags & UF_Viewer | flags & UF_Forced )
3419 SMESH::UpdateView();
3421 SalomeApp_Module::update( flags );
3424 //================================================================================
3426 * \brief Set default selection mode
3428 * SLOT called when operation commited. Sets default selection mode
3430 //================================================================================
3431 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3433 SVTK_ViewWindow* vtkWnd =
3434 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3436 vtkWnd->SetSelectionMode( ActorSelection );
3439 //================================================================================
3441 * \brief Set default selection mode
3443 * SLOT called when operation aborted. Sets default selection mode
3445 //================================================================================
3446 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3448 SVTK_ViewWindow* vtkWnd =
3449 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3451 vtkWnd->SetSelectionMode( ActorSelection );
3454 //================================================================================
3456 * \brief Creates operation with given identifier
3457 * \param id - identifier of operation to be started
3458 * \return Pointer on created operation or NULL if operation is not created
3460 * Virtual method redefined from the base class creates operation with given id.
3461 * It is called called automatically from startOperation method of base class.
3463 //================================================================================
3464 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3466 LightApp_Operation* op = 0;
3467 // to do : create operation here
3470 case 701: // Compute mesh
3471 op = new SMESHGUI_ComputeOp();
3473 case 702: // Create mesh
3474 op = new SMESHGUI_MeshOp( true, true );
3476 case 703: // Create sub-mesh
3477 op = new SMESHGUI_MeshOp( true, false );
3479 case 704: // Edit mesh/sub-mesh
3480 op = new SMESHGUI_MeshOp( false );
3482 case 417: //convert to quadratic
3483 op = new SMESHGUI_ConvToQuadOp();
3485 case 4067: // make mesh pass through point
3486 op = new SMESHGUI_MakeNodeAtPointOp();
3493 op = SalomeApp_Module::createOperation( id );
3497 //================================================================================
3499 * \brief Stops current operations and starts a given one
3500 * \param id - The id of the operation to start
3502 //================================================================================
3504 void SMESHGUI::switchToOperation(int id)
3506 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3507 activeStudy()->abortAllOperations();
3508 startOperation( id );
3511 LightApp_Displayer* SMESHGUI::displayer()
3514 myDisplayer = new SMESHGUI_Displayer( getApp() );
3518 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3521 int aTolerance = 64;
3522 int anIterations = 0;
3528 if( anIterations % aPeriod == 0 )
3531 if( aTolerance < 1 )
3534 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3536 aHue = (int)( 360.0 * rand() / RAND_MAX );
3537 //cout << "Hue = " << aHue << endl;
3539 //cout << "Auto colors : ";
3541 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3542 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3543 for( ; it != itEnd; ++it )
3545 SALOMEDS::Color anAutoColor = *it;
3546 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3549 aQColor.getHsv( &h, &s, &v );
3551 if( abs( h - aHue ) < aTolerance )
3554 //cout << "break (diff = " << abs( h - aHue ) << ")";
3564 //cout << "Hue of the returned color = " << aHue << endl;
3566 aColor.setHsv( aHue, 255, 255 );
3568 SALOMEDS::Color aSColor;
3569 aSColor.R = (double)aColor.red() / 255.0;
3570 aSColor.G = (double)aColor.green() / 255.0;
3571 aSColor.B = (double)aColor.blue() / 255.0;