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_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_EditMeshDlg.h"
61 #include "SMESHGUI_MeshPatternDlg.h"
62 #include "SMESHGUI_Selection.h"
63 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
64 #include "SMESHGUI_ConvToQuadOp.h"
65 #include "SMESHGUI_MeshOp.h"
66 #include "SMESHGUI_Displayer.h"
67 #include "SMESHGUI_MakeNodeAtPointDlg.h"
68 #include "SMESHGUI_BuildCompoundDlg.h"
69 #include "SMESHGUI_ComputeDlg.h"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_GEOMGenUtils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include "SMESH_Actor.h"
81 #include "SMESH_Object.h"
82 #include "SMESH_TypeFilter.hxx"
84 #include "SalomeApp_Tools.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_CheckFileDlg.h"
88 #include "SalomeApp_ImportOperation.h"
90 #include "LightApp_DataOwner.h"
91 #include "LightApp_Preferences.h"
92 #include "LightApp_VTKSelector.h"
93 #include "LightApp_Operation.h"
94 #include "LightApp_UpdateFlags.h"
95 #include "LightApp_NameDlg.h"
97 #include <SVTK_ViewWindow.h>
98 #include <SVTK_ViewModel.h>
99 #include <SVTK_InteractorStyle.h>
100 #include <SVTK_RenderWindowInteractor.h>
101 #include <SVTK_ViewManager.h>
103 #include "OB_Browser.h"
105 #include "SUIT_Tools.h"
106 #include "SUIT_MessageBox.h"
107 #include "SUIT_ResourceMgr.h"
108 #include "SUIT_FileDlg.h"
109 #include "SUIT_Desktop.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
127 #define INCLUDE_MENUITEM_DEF
128 #include <qpopupmenu.h>
134 #include <boost/shared_ptr.hpp>
137 #include <vtkRenderer.h>
138 #include <vtkRenderWindow.h>
139 #include <vtkActorCollection.h>
140 #include <vtkScalarBarActor.h>
141 #include <vtkUnstructuredGrid.h>
143 #include "utilities.h"
145 #include "SALOMEDS_Study.hxx"
146 #include "SALOMEDSClient_StudyBuilder.hxx"
147 #include "SALOMEDSClient_SComponent.hxx"
153 //=============================================================
154 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
157 void ExportMeshToFile(int theCommandID);
159 void SetDisplayMode(int theCommandID);
161 void SetDisplayEntity(int theCommandID);
163 void Control( int theCommandID );
167 //=============================================================
168 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
174 if(theCommandID == 113){
175 filter.append(QObject::tr("MED files (*.med)"));
176 filter.append(QObject::tr("All files (*)"));
177 }else if (theCommandID == 112){
178 filter.append(QObject::tr("IDEAS files (*.unv)"));
179 }else if (theCommandID == 111){
180 filter.append(QObject::tr("DAT files (*.dat)"));
182 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
185 QObject::tr("Import mesh"),
187 if(!filename.isEmpty()) {
188 SUIT_OverrideCursor wc;
189 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
192 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 aMeshes->length( 1 );
197 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
202 SMESH::DriverMED_ReadStatus res;
203 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
204 if ( res != SMESH::DRS_OK ) {
206 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
207 QObject::tr("SMESH_WRN_WARNING"),
208 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
209 QObject::tr("SMESH_BUT_OK"));
210 aMeshes->length( 0 );
217 bool isEmpty = false;
218 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
219 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
221 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
222 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
223 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
224 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
225 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
232 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
233 QObject::tr("SMESH_WRN_WARNING"),
234 QObject::tr("SMESH_DRS_EMPTY"),
235 QObject::tr("SMESH_BUT_OK"));
239 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
241 catch (const SALOME::SALOME_Exception& S_ex){
243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
250 void ExportMeshToFile( int theCommandID )
252 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
253 SALOME_ListIO selected;
255 aSel->selectedObjects( selected );
257 if(selected.Extent()){
258 Handle(SALOME_InteractiveObject) anIObject = selected.First();
259 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
260 if ( !aMesh->_is_nil() ) {
261 QString aFilter, aTitle = QObject::tr("Export mesh");
262 QMap<QString, SMESH::MED_VERSION> aFilterMap;
263 QMap<QString, int> aFilterMapSTL;
264 switch ( theCommandID ) {
268 if (aMesh->HasDuplicatedGroupNamesMED()) {
269 int aRet = SUIT_MessageBox::warn2
270 (SMESHGUI::desktop(),
271 QObject::tr("SMESH_WRN_WARNING"),
272 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
273 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
279 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
280 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
285 aFilter = QObject::tr("DAT files (*.dat)");
290 if (aMesh->NbPyramids()) {
291 int aRet = SUIT_MessageBox::warn2
292 (SMESHGUI::desktop(),
293 QObject::tr("SMESH_WRN_WARNING"),
294 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
295 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
300 aFilter = QObject::tr("IDEAS files (*.unv)");
308 there must be check on others mesh elements not equal triangles
310 if (aMesh->NbTriangles() < 1) {
311 SUIT_MessageBox::warn1
312 (SMESHGUI::desktop(),
313 QObject::tr("SMESH_WRN_WARNING"),
314 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
315 QObject::tr("SMESH_BUT_OK"));
318 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
319 int aRet = SUIT_MessageBox::warn2
320 (SMESHGUI::desktop(),
321 QObject::tr("SMESH_WRN_WARNING"),
322 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
323 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
329 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
330 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
338 SMESH::MED_VERSION aFormat;
339 // Init the parameter with the default value
340 bool aIsASCII_STL = true;
341 bool toCreateGroups = false;
342 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
344 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
346 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
348 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
350 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
352 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
353 for ( ; it != aFilterMapSTL.end(); ++it )
354 filters.push_back( it.key() );
356 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
357 fd->setCaption( aTitle );
358 fd->setFilters( filters );
359 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
363 aFilename = fd->selectedFile();
364 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
371 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
372 for ( ; it != aFilterMap.end(); ++it )
373 filters.push_back( it.key() );
375 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
376 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
377 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
378 fd->setCaption( aTitle );
379 fd->setFilters( filters );
380 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
381 fd->SetChecked(toCreateGroups);
385 aFilename = fd->selectedFile();
386 aFormat = aFilterMap[fd->selectedFilter()];
388 if ( !aFilename.isEmpty()
389 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
390 && aFormat==SMESH::MED_V2_1) {
391 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
392 QObject::tr("SMESH_WRN_WARNING"),
393 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
394 QObject::tr("SMESH_BUT_YES"),
395 QObject::tr("SMESH_BUT_NO"),
402 toCreateGroups = fd->IsChecked();
405 if ( !aFilename.isEmpty() ) {
406 // Check whether the file already exists and delete it if yes
407 QFile aFile( aFilename );
408 if ( aFile.exists() )
410 SUIT_OverrideCursor wc;
413 bool Renumber = false ;
414 // PAL 14172 : Check of we have to renumber or not from the preferences before export
416 Renumber= resMgr->booleanValue("SMESH","renumbering");
418 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
419 aMeshEditor->RenumberNodes();
420 aMeshEditor->RenumberElements();
421 if ( SMESHGUI::automaticUpdate() )
424 switch ( theCommandID ) {
427 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
431 aMesh->ExportDAT( aFilename.latin1() );
435 aMesh->ExportUNV( aFilename.latin1() );
439 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
445 catch (const SALOME::SALOME_Exception& S_ex){
447 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
448 QObject::tr("SMESH_WRN_WARNING"),
449 QObject::tr("SMESH_EXPORT_FAILED"),
450 QObject::tr("SMESH_BUT_OK"));
458 inline void InverseEntityMode(unsigned int& theOutputMode,
459 unsigned int theMode)
461 bool anIsNotPresent = ~theOutputMode & theMode;
463 theOutputMode |= theMode;
465 theOutputMode &= ~theMode;
468 void SetDisplayEntity(int theCommandID){
469 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
470 SALOME_ListIO selected;
472 aSel->selectedObjects( selected );
474 if(selected.Extent() >= 1){
475 SALOME_ListIteratorOfListIO It( selected );
476 for(; It.More(); It.Next()){
477 Handle(SALOME_InteractiveObject) IObject = It.Value();
478 if(IObject->hasEntry()){
479 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
480 unsigned int aMode = anActor->GetEntityMode();
481 switch(theCommandID){
483 InverseEntityMode(aMode,SMESH_Actor::eEdges);
486 InverseEntityMode(aMode,SMESH_Actor::eFaces);
489 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
492 aMode = SMESH_Actor::eAllEntity;
496 anActor->SetEntityMode(aMode);
504 SALOME_ListIO selected;
505 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
509 LightApp_SelectionMgr* aSel = app->selectionMgr();
510 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
511 if( !aSel || !appStudy )
514 aSel->selectedObjects( selected );
515 if( selected.IsEmpty() )
518 Handle(SALOME_InteractiveObject) anIObject = selected.First();
520 _PTR(Study) aStudy = appStudy->studyDS();
521 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
522 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
523 if( aMainObject->_is_nil() )
526 aMainObject->SetAutoColor( true );
528 QValueList<SALOMEDS::Color> aReservedColors;
530 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
531 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
533 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
534 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
536 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
537 aGroupObject->SetColor( aColor );
538 aReservedColors.append( aColor );
540 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
541 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
542 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
545 SMESH::RepaintCurrentView();
548 void DisableAutoColor(){
549 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
550 SALOME_ListIO selected;
552 aSel->selectedObjects( selected );
554 if(selected.Extent()){
555 Handle(SALOME_InteractiveObject) anIObject = selected.First();
556 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
557 if ( !aMesh->_is_nil() ) {
558 aMesh->SetAutoColor( false );
563 void SetDisplayMode(int theCommandID){
564 SALOME_ListIO selected;
565 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
570 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
571 if( !aSel || !appStudy )
574 _PTR(Study) aStudy = appStudy->studyDS();
576 aSel->selectedObjects( selected );
578 if(selected.Extent() >= 1){
579 switch(theCommandID){
581 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
582 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
586 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
587 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
590 SALOME_ListIteratorOfListIO It( selected );
591 for(; It.More(); It.Next()){
592 Handle(SALOME_InteractiveObject) IObject = It.Value();
593 if(IObject->hasEntry()){
594 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
595 switch(theCommandID){
597 anActor->SetRepresentation(SMESH_Actor::eEdge);
600 anActor->SetRepresentation(SMESH_Actor::eSurface);
603 if(anActor->IsShrunk())
606 anActor->SetShrink();
609 anActor->SetRepresentation(SMESH_Actor::ePoint);
612 vtkFloatingPointType color[3];
613 anActor->GetSufaceColor(color[0], color[1], color[2]);
614 int c0 = int (color[0] * 255);
615 int c1 = int (color[1] * 255);
616 int c2 = int (color[2] * 255);
617 QColor c(c0, c1, c2);
619 vtkFloatingPointType edgecolor[3];
620 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
621 c0 = int (edgecolor[0] * 255);
622 c1 = int (edgecolor[1] * 255);
623 c2 = int (edgecolor[2] * 255);
624 QColor e(c0, c1, c2);
626 vtkFloatingPointType backfacecolor[3];
627 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
628 c0 = int (backfacecolor[0] * 255);
629 c1 = int (backfacecolor[1] * 255);
630 c2 = int (backfacecolor[2] * 255);
631 QColor b(c0, c1, c2);
633 vtkFloatingPointType nodecolor[3];
634 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
635 c0 = int (nodecolor[0] * 255);
636 c1 = int (nodecolor[1] * 255);
637 c2 = int (nodecolor[2] * 255);
638 QColor n(c0, c1, c2);
640 int Edgewidth = (int)anActor->GetLineWidth();
643 int intValue = int(anActor->GetNodeSize());
644 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
646 SMESHGUI_Preferences_ColorDlg *aDlg =
647 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
648 aDlg->SetColor(1, c);
649 aDlg->SetColor(2, e);
650 aDlg->SetColor(3, n);
651 aDlg->SetColor(4, b);
652 aDlg->SetIntValue(1, Edgewidth);
653 aDlg->SetIntValue(2, intValue);
654 aDlg->SetIntValue(3, int(Shrink*100.));
656 QColor color = aDlg->GetColor(1);
657 QColor edgecolor = aDlg->GetColor(2);
658 QColor nodecolor = aDlg->GetColor(3);
659 QColor backfacecolor = aDlg->GetColor(4);
660 /* actor color and backface color */
661 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
662 vtkFloatingPointType (color.green()) / 255.,
663 vtkFloatingPointType (color.blue()) / 255.);
664 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
665 vtkFloatingPointType (backfacecolor.green()) / 255.,
666 vtkFloatingPointType (backfacecolor.blue()) / 255.);
669 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
670 vtkFloatingPointType (edgecolor.green()) / 255.,
671 vtkFloatingPointType (edgecolor.blue()) / 255.);
673 /* Shrink factor and size edges */
674 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
675 anActor->SetLineWidth(aDlg->GetIntValue(1));
677 /* Nodes color and size */
678 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
679 vtkFloatingPointType (nodecolor.green()) / 255.,
680 vtkFloatingPointType (nodecolor.blue()) / 255.);
681 anActor->SetNodeSize(aDlg->GetIntValue(2));
683 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
684 if( !aGroupObject->_is_nil() )
686 SALOMEDS::Color aColor;
687 aColor.R = (float)color.red() / 255.0;
688 aColor.G = (float)color.green() / 255.0;
689 aColor.B = (float)color.blue() / 255.0;
690 aGroupObject->SetColor( aColor );
700 SMESH::RepaintCurrentView();
704 void Control( int theCommandID )
706 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
707 SALOME_ListIO selected;
709 aSel->selectedObjects( selected );
711 if( !selected.IsEmpty() ){
712 Handle(SALOME_InteractiveObject) anIO = selected.First();
715 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
716 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
717 switch ( theCommandID ){
719 aTitle = QObject::tr( "LENGTH_EDGES" );
720 aControl = SMESH_Actor::eLength;
723 aTitle = QObject::tr( "LENGTH2D_EDGES" );
724 aControl = SMESH_Actor::eLength2D;
727 aTitle = QObject::tr( "FREE_EDGES" );
728 aControl = SMESH_Actor::eFreeEdges;
731 aTitle = QObject::tr( "FREE_BORDERS" );
732 aControl = SMESH_Actor::eFreeBorders;
735 aTitle = QObject::tr( "MULTI_BORDERS" );
736 aControl = SMESH_Actor::eMultiConnection;
739 aTitle = QObject::tr( "MULTI2D_BORDERS" );
740 aControl = SMESH_Actor::eMultiConnection2D;
743 aTitle = QObject::tr( "AREA_ELEMENTS" );
744 aControl = SMESH_Actor::eArea;
747 aTitle = QObject::tr( "TAPER_ELEMENTS" );
748 aControl = SMESH_Actor::eTaper;
751 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
752 aControl = SMESH_Actor::eAspectRatio;
755 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
756 aControl = SMESH_Actor::eAspectRatio3D;
759 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
760 aControl = SMESH_Actor::eMinimumAngle;
763 aTitle = QObject::tr( "WARP_ELEMENTS" );
764 aControl = SMESH_Actor::eWarping;
767 aTitle = QObject::tr( "SKEW_ELEMENTS" );
768 aControl = SMESH_Actor::eSkew;
771 aTitle = QObject::tr( "SMESH_VOLUME" );
772 aControl = SMESH_Actor::eVolume3D;
775 anActor->SetControlMode(aControl);
776 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
777 SMESH::RepaintCurrentView();
784 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
785 MeshObjectType theType,
786 const QString theInTypeName,
787 QString & theOutTypeName)
789 SMESH_TypeFilter aTypeFilter( theType );
791 if( !theIO.IsNull() )
793 entry = theIO->getEntry();
794 LightApp_DataOwner owner( entry );
795 if ( aTypeFilter.isOk( &owner )) {
796 theOutTypeName = theInTypeName;
804 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
806 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
807 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
809 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
810 CORBA::String_var anID = aSComp->GetID().c_str();
811 if (!strcmp(anID.in(),theIO->getEntry()))
817 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
818 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
819 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
820 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
821 CheckOIType ( theIO, GROUP, "Group", aTypeName )
829 QString CheckHomogeneousSelection()
831 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
832 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
833 SALOME_ListIO selected;
835 aSel->selectedObjects( selected );
837 QString RefType = CheckTypeObject(selected.First());
838 SALOME_ListIteratorOfListIO It(selected);
839 for (; It.More(); It.Next())
841 Handle(SALOME_InteractiveObject) IObject = It.Value();
842 QString Type = CheckTypeObject(IObject);
843 if (Type.compare(RefType) != 0)
844 return "Heterogeneous Selection";
851 void SMESHGUI::OnEditDelete()
853 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
854 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
855 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
857 QString aParentComponent = QString::null;
858 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
860 QString cur = anIt.Value()->getComponentDataType();
861 if( aParentComponent.isNull() )
862 aParentComponent = cur;
863 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
864 aParentComponent = "";
867 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
868 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
869 QObject::tr("ERR_ERROR"),
870 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
871 QObject::tr("BUT_OK") );
874 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
875 if (SUIT_MessageBox::warn2
876 (SMESHGUI::desktop(),
877 QObject::tr("SMESH_WRN_WARNING"),
878 QObject::tr("SMESH_REALLY_DELETE"),
879 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
882 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
883 SUIT_ViewManager* vm = anApp->activeViewManager();
884 int nbSf = vm->getViewsCount();
886 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
887 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
888 _PTR(GenericAttribute) anAttr;
889 _PTR(AttributeIOR) anIOR;
891 SALOME_ListIteratorOfListIO It(selected);
893 aStudyBuilder->NewCommand(); // There is a transaction
894 for(; It.More(); It.Next()){ // loop on selected IO's
895 Handle(SALOME_InteractiveObject) IObject = It.Value();
896 if(IObject->hasEntry()) {
897 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
899 // disable removal of "SMESH" component object
900 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
902 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
906 // put the whole hierarchy of sub-objects of the selected SO into a list and
907 // then treat them all starting from the deepest objects (at list back)
909 list< _PTR(SObject) > listSO;
910 listSO.push_back( aSO );
911 list< _PTR(SObject) >::iterator itSO = listSO.begin();
912 for ( ; itSO != listSO.end(); ++itSO ) {
913 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
914 for (it->InitEx(false); it->More(); it->Next())
915 listSO.push_back( it->Value() );
918 // treat SO's in the list starting from the back
920 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
921 for ( ; ritSO != listSO.rend(); ++ritSO ) {
922 _PTR(SObject) SO = *ritSO;
924 string anEntry = SO->GetID();
926 /** Erase graphical object **/
927 if(SO->FindAttribute(anAttr, "AttributeIOR")){
928 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
929 for(int i = 0; i < nbSf; i++){
930 SUIT_ViewWindow *sf = aViews[i];
931 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
932 SMESH::RemoveActor(sf,anActor);
937 /** Remove an object from data structures **/
938 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
939 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
940 if ( !aGroup->_is_nil() ) { // DELETE GROUP
941 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
942 aMesh->RemoveGroup( aGroup );
944 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
945 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
946 aMesh->RemoveSubMesh( aSubMesh );
948 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
950 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
953 IObject = new SALOME_InteractiveObject
954 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
955 QString objType = CheckTypeObject(IObject);
956 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
957 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
958 aStudyBuilder->RemoveObjectWithChildren( SO );
960 else {// default action: remove SObject from the study
961 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
962 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
964 aStudyBuilder->RemoveObjectWithChildren( SO );
968 } /* listSO back loop */
969 } /* IObject->hasEntry() */
971 aStudyBuilder->CommitCommand();
973 /* Clear any previous selection */
975 aSel->setSelectedObjects( l1 );
977 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
982 SMESHGUI_EXPORT CAM_Module* createModule()
984 return new SMESHGUI();
988 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
990 //=============================================================================
994 //=============================================================================
995 SMESHGUI::SMESHGUI() :
996 SalomeApp_Module( "SMESH" )
998 if ( CORBA::is_nil( myComponentSMESH ) )
1000 CORBA::Boolean anIsEmbeddedMode;
1001 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1004 myActiveDialogBox = 0;
1005 myFilterLibraryDlg = 0;
1009 SMESH::GetFilterManager();
1010 SMESH::GetPattern();
1012 /* load resources for all available meshers */
1013 SMESH::InitAvailableHypotheses();
1016 //=============================================================================
1020 //=============================================================================
1021 SMESHGUI::~SMESHGUI()
1023 SMESH::GetFilterManager()->Destroy();
1024 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1027 //=============================================================================
1031 //=============================================================================
1032 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1034 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1036 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1041 bool SMESHGUI::automaticUpdate()
1043 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1047 return resMgr->booleanValue( "SMESH", "auto_update", false );
1050 //=============================================================================
1054 //=============================================================================
1055 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1057 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1060 //=============================================================================
1064 //=============================================================================
1065 SMESHGUI* SMESHGUI::GetSMESHGUI()
1067 SMESHGUI* smeshMod = 0;
1068 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1071 CAM_Module* module = app->module( "Mesh" );
1072 smeshMod = dynamic_cast<SMESHGUI*>( module );
1075 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1077 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1080 _PTR(Study) aStudy = study->studyDS();
1082 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1091 Standard_EXPORT SMESHGUI* GetComponentGUI()
1093 return SMESHGUI::GetSMESHGUI();
1097 //=============================================================================
1101 //=============================================================================
1102 void SMESHGUI::SetState(int aState)
1107 //=============================================================================
1111 //=============================================================================
1112 void SMESHGUI::ResetState()
1117 //=============================================================================
1121 //=============================================================================
1122 void SMESHGUI::EmitSignalDeactivateDialog()
1124 emit SignalDeactivateActiveDialog();
1127 //=============================================================================
1131 //=============================================================================
1132 void SMESHGUI::EmitSignalStudyFrameChanged()
1134 emit SignalStudyFrameChanged();
1137 //=============================================================================
1141 //=============================================================================
1142 void SMESHGUI::EmitSignalCloseAllDialogs()
1144 emit SignalCloseAllDialogs();
1147 //=============================================================================
1151 //=============================================================================
1152 QDialog *SMESHGUI::GetActiveDialogBox()
1154 return myActiveDialogBox;
1157 //=============================================================================
1161 //=============================================================================
1162 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1164 myActiveDialogBox = (QDialog *) aDlg;
1168 //=============================================================================
1172 //=============================================================================
1173 SUIT_Desktop* SMESHGUI::desktop()
1175 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1177 return app->desktop();
1182 //=============================================================================
1186 //=============================================================================
1187 SalomeApp_Study* SMESHGUI::activeStudy()
1189 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1191 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1196 //=============================================================================
1200 //=============================================================================
1201 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1203 /* Here the position is on the bottom right corner - 10 */
1204 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1206 SUIT_Desktop *PP = desktop();
1207 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1208 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1212 //=============================================================================
1216 //=============================================================================
1217 static int isStudyLocked(_PTR(Study) theStudy){
1218 return theStudy->GetProperties()->IsLocked();
1221 static bool checkLock(_PTR(Study) theStudy) {
1222 if (isStudyLocked(theStudy)) {
1223 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1224 QObject::tr("WRN_WARNING"),
1225 QObject::tr("WRN_STUDY_LOCKED"),
1226 QObject::tr("BUT_OK") );
1232 //=======================================================================
1233 //function : CheckActiveStudyLocked
1235 //=======================================================================
1237 bool SMESHGUI::isActiveStudyLocked()
1239 _PTR(Study) aStudy = activeStudy()->studyDS();
1240 return checkLock( aStudy );
1243 //=============================================================================
1247 //=============================================================================
1248 bool SMESHGUI::OnGUIEvent( int theCommandID )
1250 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1254 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1255 SUIT_ResourceMgr* mgr = resourceMgr();
1259 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1260 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1263 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1264 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1266 //QAction* act = action( theCommandID );
1268 switch (theCommandID) {
1270 if(checkLock(aStudy)) break;
1278 if(checkLock(aStudy)) break;
1279 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1283 case 122: // EXPORT MED
1292 ::ExportMeshToFile(theCommandID);
1296 case 200: // SCALAR BAR
1298 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1299 SALOME_ListIO selected;
1301 aSel->selectedObjects( selected );
1303 if( selected.Extent() ) {
1304 Handle(SALOME_InteractiveObject) anIO = selected.First();
1305 if( anIO->hasEntry() ) {
1306 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1307 anActor->SetControlMode( SMESH_Actor::eNone );
1315 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1325 ::DisableAutoColor();
1328 case 1134: // Clipping
1329 case 1133: // Tranparency
1330 case 1132: // Colors / Size
1337 ::SetDisplayMode(theCommandID);
1343 case 219: // Volumes
1344 case 220: // All Entity
1345 ::SetDisplayEntity(theCommandID);
1350 if(checkLock(aStudy)) break;
1351 SMESH::UpdateView();
1354 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1355 aSel->selectedObjects( l );
1356 aSel->setSelectedObjects( l );
1361 case 301: // DISPLAY
1362 case 302: // DISPLAY ONLY
1364 SMESH::EDisplaing anAction;
1365 switch (theCommandID) {
1366 case 300: anAction = SMESH::eErase; break;
1367 case 301: anAction = SMESH::eDisplay; break;
1368 case 302: anAction = SMESH::eDisplayOnly; break;
1371 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1372 SALOME_ListIO sel_objects, to_process;
1374 aSel->selectedObjects( sel_objects );
1376 if( theCommandID==302 )
1377 startOperation( myEraseAll );
1379 extractContainers( sel_objects, to_process );
1383 SALOME_ListIteratorOfListIO It( to_process );
1384 for (; It.More(); It.Next()) {
1385 Handle(SALOME_InteractiveObject) IOS = It.Value();
1386 if (IOS->hasEntry()) {
1387 SMESH::UpdateView(anAction, IOS->getEntry());
1388 if (anAction == SMESH::eDisplayOnly)
1389 anAction = SMESH::eDisplay;
1394 // PAL13338 + PAL15161 -->
1395 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1396 SMESH::UpdateView();
1397 // PAL13338 + PAL15161 <--
1399 catch (...) { // PAL16774 (Crash after display of many groups)
1400 SMESH::OnVisuException();
1403 if (anAction == SMESH::eErase) {
1405 aSel->setSelectedObjects( l1 );
1408 aSel->setSelectedObjects( to_process );
1415 if(checkLock(aStudy)) break;
1418 EmitSignalDeactivateDialog();
1420 new SMESHGUI_NodesDlg(this);
1423 SUIT_MessageBox::warn1(desktop(),
1424 tr("SMESH_WRN_WARNING"),
1425 tr("SMESH_WRN_VIEWER_VTK"),
1426 tr("SMESH_BUT_OK"));
1431 case 2151: // FILTER
1435 EmitSignalDeactivateDialog();
1436 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1441 case 406: // MOVE NODE
1445 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1446 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1450 if(checkLock(aStudy)) break;
1451 new SMESHGUI_MoveNodesDlg(this);
1455 case 701: // COMPUTE MESH
1457 if (checkLock(aStudy)) break;
1459 startOperation( 701 );
1463 case 702: // Create mesh
1464 startOperation( 702 );
1466 case 703: // Create sub-mesh
1467 startOperation( 703 );
1469 case 704: // Edit mesh/sub-mesh
1470 startOperation( 704 );
1472 case 710: // Build compound mesh
1474 if (checkLock(aStudy)) break;
1475 EmitSignalDeactivateDialog();
1476 new SMESHGUI_BuildCompoundDlg( this );
1479 case 407: // DIAGONAL INVERSION
1480 case 408: // Delete diagonal
1484 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1485 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1489 if ( checkLock( aStudy ) )
1492 /*Standard_Boolean aRes;
1493 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1494 if ( aMesh->_is_nil() )
1496 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1497 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1501 EmitSignalDeactivateDialog();
1502 if ( theCommandID == 407 )
1503 new SMESHGUI_TrianglesInversionDlg(this);
1505 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1508 case 409: // Change orientation
1509 case 410: // Union of triangles
1510 case 411: // Cutting of quadrangles
1514 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1515 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1519 if ( checkLock( aStudy ) )
1522 EmitSignalDeactivateDialog();
1523 SMESHGUI_MultiEditDlg* aDlg = NULL;
1524 if ( theCommandID == 409 )
1525 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1526 else if ( theCommandID == 410 )
1527 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1529 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1534 case 412: // Smoothing
1536 if(checkLock(aStudy)) break;
1538 EmitSignalDeactivateDialog();
1539 new SMESHGUI_SmoothingDlg( this );
1542 SUIT_MessageBox::warn1(desktop(),
1543 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1544 tr("SMESH_BUT_OK"));
1548 case 413: // Extrusion
1550 if (checkLock(aStudy)) break;
1552 EmitSignalDeactivateDialog();
1553 new SMESHGUI_ExtrusionDlg ( this );
1555 SUIT_MessageBox::warn1(desktop(),
1556 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1557 tr("SMESH_BUT_OK"));
1561 case 414: // Revolution
1563 if(checkLock(aStudy)) break;
1565 EmitSignalDeactivateDialog();
1566 new SMESHGUI_RevolutionDlg( this );
1569 SUIT_MessageBox::warn1(desktop(),
1570 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1571 tr("SMESH_BUT_OK"));
1575 case 415: // Pattern mapping
1577 if ( checkLock( aStudy ) )
1581 EmitSignalDeactivateDialog();
1582 new SMESHGUI_MeshPatternDlg( this );
1585 SUIT_MessageBox::warn1(desktop(),
1586 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1587 tr("SMESH_BUT_OK"));
1591 case 416: // Extrusion along a path
1593 if (checkLock(aStudy)) break;
1595 EmitSignalDeactivateDialog();
1596 new SMESHGUI_ExtrusionAlongPathDlg( this );
1598 SUIT_MessageBox::warn1(desktop(),
1599 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1600 tr("SMESH_BUT_OK"));
1604 case 417: // Convert mesh to quadratic
1606 startOperation( 417 );
1607 /* if (checkLock(aStudy)) break;
1609 EmitSignalDeactivateDialog();
1610 new SMESHGUI_ConvToQuadDlg();
1612 SUIT_MessageBox::warn1(desktop(),
1613 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1614 tr("SMESH_BUT_OK"));
1618 case 801: // CREATE GROUP
1622 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1623 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1627 if(checkLock(aStudy)) break;
1628 EmitSignalDeactivateDialog();
1629 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1631 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1632 SALOME_ListIO selected;
1634 aSel->selectedObjects( selected );
1636 int nbSel = selected.Extent();
1638 // check if mesh is selected
1639 aMesh = SMESH::GetMeshByIO( selected.First() );
1641 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1646 case 802: // CONSTRUCT GROUP
1650 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1651 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1655 if(checkLock(aStudy)) break;
1656 EmitSignalDeactivateDialog();
1658 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1659 SALOME_ListIO selected;
1661 aSel->selectedObjects( selected );
1663 int nbSel = selected.Extent();
1665 // check if submesh is selected
1666 Handle(SALOME_InteractiveObject) IObject = selected.First();
1667 if (IObject->hasEntry()) {
1668 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1670 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1671 if (!aSubMesh->_is_nil()) {
1673 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1674 // get submesh elements list by types
1675 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1676 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1677 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1678 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1679 // create group for each type o elements
1680 QString aName = IObject->getName();
1681 if (aNodes->length() > 0) {
1682 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1683 aGroup->Add(aNodes.inout());
1685 if (aEdges->length() > 0) {
1686 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1687 aGroup->Add(aEdges.inout());
1689 if (aFaces->length() > 0) {
1690 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1691 aGroup->Add(aFaces.inout());
1693 if (aVolumes->length() > 0) {
1694 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1695 aGroup->Add(aVolumes.inout());
1700 catch(const SALOME::SALOME_Exception & S_ex){
1701 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1708 SUIT_MessageBox::warn1(desktop(),
1709 tr("SMESH_WRN_WARNING"),
1710 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1711 tr("SMESH_BUT_OK"));
1716 case 803: // EDIT GROUP
1720 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1721 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1725 if(checkLock(aStudy)) break;
1726 EmitSignalDeactivateDialog();
1728 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1729 SALOME_ListIO selected;
1731 aSel->selectedObjects( selected );
1733 SALOME_ListIteratorOfListIO It (selected);
1734 int nbSelectedGroups = 0;
1735 for ( ; It.More(); It.Next() )
1737 SMESH::SMESH_GroupBase_var aGroup =
1738 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1739 if (!aGroup->_is_nil()) {
1741 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1745 if (nbSelectedGroups == 0)
1747 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1753 case 804: // Add elements to group
1755 if(checkLock(aStudy)) break;
1756 if (myState == 800) {
1757 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1758 if (aDlg) aDlg->onAdd();
1763 case 805: // Remove elements from group
1765 if(checkLock(aStudy)) break;
1766 if (myState == 800) {
1767 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1768 if (aDlg) aDlg->onRemove();
1773 case 810: // Union Groups
1774 case 811: // Intersect groups
1775 case 812: // Cut groups
1779 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1780 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1784 if ( checkLock( aStudy ) )
1787 EmitSignalDeactivateDialog();
1790 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1791 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1792 else aMode = SMESHGUI_GroupOpDlg::CUT;
1794 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1798 case 813: // Delete groups with their contents
1802 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1803 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1807 if ( checkLock( aStudy ) )
1810 EmitSignalDeactivateDialog();
1812 new SMESHGUI_DeleteGroupDlg( this );
1816 case 900: // MESH INFOS
1818 EmitSignalDeactivateDialog();
1819 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1820 SALOME_ListIO selected;
1822 aSel->selectedObjects( selected );
1824 if ( selected.Extent() > 1 ) { // a dlg for each IO
1826 SALOME_ListIteratorOfListIO It (selected);
1827 for ( ; It.More(); It.Next() ) {
1828 IOs.Clear(); IOs.Append( It.Value() );
1829 aSel->setSelectedObjects( IOs );
1830 new SMESHGUI_MeshInfosDlg(this, "", false);
1832 // restore selection
1833 aSel->setSelectedObjects( selected );
1836 new SMESHGUI_MeshInfosDlg(this, "", false);
1840 case 902: // STANDARD MESH INFOS
1842 EmitSignalDeactivateDialog();
1843 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1844 SALOME_ListIO selected;
1846 aSel->selectedObjects( selected );
1848 if ( selected.Extent() > 1 ) { // a dlg for each IO
1850 SALOME_ListIteratorOfListIO It (selected);
1851 for ( ; It.More(); It.Next() ) {
1853 IOs.Append( It.Value() );
1854 aSel->setSelectedObjects( IOs );
1855 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1857 // restore selection
1858 aSel->setSelectedObjects( selected );
1861 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1865 case 1100: // EDIT HYPOTHESIS
1867 if(checkLock(aStudy)) break;
1869 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1870 SALOME_ListIO selected;
1872 aSel->selectedObjects( selected );
1874 int nbSel = selected.Extent();
1877 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1878 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1880 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1881 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1882 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1883 if ( !aHypothesis->_is_nil() )
1885 CORBA::String_var aHypType = aHypothesis->GetName();
1886 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1888 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1895 updateObjBrowser( true );
1899 case 1101: // RENAME
1901 if ( checkLock( aStudy ) )
1904 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1905 SALOME_ListIO selected;
1907 aSel->selectedObjects( selected );
1909 SALOME_ListIteratorOfListIO It( selected );
1910 for ( ; It.More(); It.Next() )
1912 Handle(SALOME_InteractiveObject) IObject = It.Value();
1913 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1914 _PTR(GenericAttribute) anAttr;
1915 _PTR(AttributeName) aName;
1918 if ( obj->FindAttribute(anAttr, "AttributeName") )
1921 QString newName = QString(aName->Value().c_str());
1922 newName = LightApp_NameDlg::getName(desktop(), newName);
1923 if ( !newName.isEmpty() )
1925 //old source: aStudy->renameIObject( IObject, newName );
1926 aName->SetValue( newName.latin1() );
1928 // if current object is group update group's name
1929 SMESH::SMESH_GroupBase_var aGroup =
1930 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1931 if (!aGroup->_is_nil() )
1932 aGroup->SetName( newName.latin1() );
1942 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1944 if(checkLock(aStudy)) break;
1945 SUIT_OverrideCursor wc;
1947 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1948 SALOME_ListIO selected;
1950 aSel->selectedObjects( selected, QString::null, false );
1952 SALOME_ListIteratorOfListIO It(selected);
1953 for (int i = 0; It.More(); It.Next(), i++) {
1954 Handle(SALOME_InteractiveObject) IObject = It.Value();
1955 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1958 aSel->setSelectedObjects( l1 );
1963 case 401: // GEOM::EDGE
1964 case 4021: // TRIANGLE
1966 case 4023: // POLYGON
1970 if(checkLock(aStudy)) break;
1972 EmitSignalDeactivateDialog();
1973 SMDSAbs_ElementType type = SMDSAbs_Edge;
1975 switch (theCommandID) {
1976 case 4021: // TRIANGLE
1977 type = SMDSAbs_Face; nbNodes = 3; break;
1979 type = SMDSAbs_Face; nbNodes = 4; break;
1981 type = SMDSAbs_Volume; nbNodes = 4; break;
1982 case 4023: // POLYGON
1983 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1985 type = SMDSAbs_Volume; nbNodes = 8; break;
1986 case 4033: // POLYHEDRE
1987 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1990 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1993 SUIT_MessageBox::warn1(desktop(),
1994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1995 tr("SMESH_BUT_OK"));
1999 case 4033: // POLYHEDRON
2001 if(checkLock(aStudy)) break;
2003 EmitSignalDeactivateDialog();
2004 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2007 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2008 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2009 tr("SMESH_BUT_OK"));
2013 case 4034: // QUADRATIC EDGE
2014 case 4035: // QUADRATIC TRIANGLE
2015 case 4036: // QUADRATIC QUADRANGLE
2016 case 4037: // QUADRATIC TETRAHEDRON
2017 case 4038: // QUADRATIC PYRAMID
2018 case 4039: // QUADRATIC PENTAHEDRON
2019 case 4040: // QUADRATIC HEXAHEDRON
2021 if(checkLock(aStudy)) break;
2023 EmitSignalDeactivateDialog();
2026 switch (theCommandID) {
2028 type = QUAD_EDGE; break;
2030 type = QUAD_TRIANGLE; break;
2032 type = QUAD_QUADRANGLE; break;
2034 type = QUAD_TETRAHEDRON; break;
2036 type = QUAD_PYRAMID; break;
2038 type = QUAD_PENTAHEDRON; break;
2040 type = QUAD_HEXAHEDRON;
2044 new SMESHGUI_AddQuadraticElementDlg( this, type );
2047 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2048 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2049 tr("SMESH_BUT_OK"));
2053 case 4041: // REMOVES NODES
2055 if(checkLock(aStudy)) break;
2057 EmitSignalDeactivateDialog();
2058 new SMESHGUI_RemoveNodesDlg(this);
2061 SUIT_MessageBox::warn1(desktop(),
2062 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2063 tr("SMESH_BUT_OK"));
2067 case 4042: // REMOVES ELEMENTS
2069 if(checkLock(aStudy)) break;
2071 EmitSignalDeactivateDialog();
2072 new SMESHGUI_RemoveElementsDlg(this);
2076 SUIT_MessageBox::warn1(desktop(),
2077 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2078 tr("SMESH_BUT_OK"));
2082 case 4051: // RENUMBERING NODES
2084 if(checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 new SMESHGUI_RenumberingDlg( this, "", 0);
2091 SUIT_MessageBox::warn1(desktop(),
2092 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2093 tr("SMESH_BUT_OK"));
2097 case 4052: // RENUMBERING ELEMENTS
2099 if(checkLock(aStudy)) break;
2101 EmitSignalDeactivateDialog();
2102 new SMESHGUI_RenumberingDlg( this, "", 1);
2106 SUIT_MessageBox::warn1(desktop(),
2107 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2108 tr("SMESH_BUT_OK"));
2112 case 4061: // TRANSLATION
2114 if(checkLock(aStudy)) break;
2116 EmitSignalDeactivateDialog();
2117 new SMESHGUI_TranslationDlg( this );
2120 SUIT_MessageBox::warn1(desktop(),
2121 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2122 tr("SMESH_BUT_OK"));
2126 case 4062: // ROTATION
2128 if(checkLock(aStudy)) break;
2130 EmitSignalDeactivateDialog();
2131 new SMESHGUI_RotationDlg( this );
2134 SUIT_MessageBox::warn1(desktop(),
2135 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2136 tr("SMESH_BUT_OK"));
2140 case 4063: // SYMMETRY
2142 if(checkLock(aStudy)) break;
2144 EmitSignalDeactivateDialog();
2145 new SMESHGUI_SymmetryDlg( this );
2148 SUIT_MessageBox::warn1(desktop(),
2149 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2150 tr("SMESH_BUT_OK"));
2154 case 4064: // SEWING
2156 if(checkLock(aStudy)) break;
2158 EmitSignalDeactivateDialog();
2159 new SMESHGUI_SewingDlg( this );
2162 SUIT_MessageBox::warn1(desktop(),
2163 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2164 tr("SMESH_BUT_OK"));
2168 case 4065: // MERGE NODES
2170 if(checkLock(aStudy)) break;
2172 EmitSignalDeactivateDialog();
2173 new SMESHGUI_EditMeshDlg( this, 0 );
2176 SUIT_MessageBox::warn1(desktop(),
2177 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2178 tr("SMESH_BUT_OK"));
2182 case 4066: // MERGE EQUAL ELEMENTS
2184 if (checkLock(aStudy)) break;
2186 EmitSignalDeactivateDialog();
2187 new SMESHGUI_EditMeshDlg( this, 1 );
2189 SUIT_MessageBox::warn1(desktop(),
2190 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2191 tr("SMESH_BUT_OK"));
2196 case 4067: // MAKE MESH PASS THROUGH POINT
2197 startOperation( 4067 );
2200 case 5105: // Library of selection filters
2202 static QValueList<int> aTypes;
2203 if ( aTypes.isEmpty() )
2205 aTypes.append( SMESH::NODE );
2206 aTypes.append( SMESH::EDGE );
2207 aTypes.append( SMESH::FACE );
2208 aTypes.append( SMESH::VOLUME );
2210 if (!myFilterLibraryDlg)
2211 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2212 else if (myFilterLibraryDlg->isHidden())
2213 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2214 myFilterLibraryDlg->raise();
2218 case 6017: // CONTROLS
2234 LightApp_SelectionMgr* mgr = selectionMgr();
2235 SALOME_ListIO selected; mgr->selectedObjects( selected );
2237 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2238 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2240 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2241 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2242 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2243 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2244 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2245 ::Control( theCommandID );
2250 SUIT_MessageBox::warn1(desktop(),
2251 tr( "SMESH_WRN_WARNING" ),
2252 tr( "SMESH_BAD_SELECTION" ),
2253 tr( "SMESH_BUT_OK" ) );
2257 SUIT_MessageBox::warn1(desktop(),
2258 tr( "SMESH_WRN_WARNING" ),
2259 tr( "NOT_A_VTK_VIEWER" ),
2260 tr( "SMESH_BUT_OK" ) );
2265 LightApp_SelectionMgr* mgr = selectionMgr();
2266 SALOME_ListIO selected; mgr->selectedObjects( selected );
2268 SALOME_ListIteratorOfListIO it(selected);
2269 for(; it.More(); it.Next()) {
2270 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2271 if(anIObject->hasEntry()) {
2272 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2273 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2281 LightApp_SelectionMgr* mgr = selectionMgr();
2282 SALOME_ListIO selected; mgr->selectedObjects( selected );
2284 if (selected.Extent() == 1) {
2285 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2286 if(anIObject->hasEntry())
2287 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2288 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2295 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2296 //updateObjBrowser();
2300 //=============================================================================
2304 //=============================================================================
2305 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2310 //=============================================================================
2314 //=============================================================================
2315 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2320 //=============================================================================
2324 //=============================================================================
2325 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2330 //=============================================================================
2331 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2332 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2334 //=============================================================================
2335 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2336 SUIT_ViewWindow* wnd )
2338 if(theIO->hasEntry()){
2339 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2340 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2344 //=======================================================================
2345 // function : createSMESHAction
2347 //=======================================================================
2348 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2351 QWidget* parent = application()->desktop();
2352 SUIT_ResourceMgr* resMgr = resourceMgr();
2354 if ( icon_id.length() )
2355 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2357 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2358 if ( !pix.isNull() )
2359 icon = QIconSet( pix );
2361 QString tooltip = tr( QString( "TOP_" )+po_id ),
2362 menu = tr( QString( "MEN_" )+po_id ),
2363 status_bar = tr( QString( "STB_" )+po_id );
2365 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2368 //=======================================================================
2369 // function : createPopupItem
2371 //=======================================================================
2372 void SMESHGUI::createPopupItem( const int id,
2373 const QString& clients,
2374 const QString& types,
2375 const QString& theRule,
2380 parentId = popupMgr()->actionId( action( pId ) );
2382 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2383 popupMgr()->insert( action( id ), parentId, 0 );
2385 QChar lc = QtxPopupMgr::Selection::defEquality();
2386 QString rule = "(%1) and (%2) and (%3)";
2387 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2388 if( clients.isEmpty() )
2389 rule = rule.arg( QString( "true" ) );
2391 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2392 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2395 bool cont = myRules.contains( id );
2397 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2399 popupMgr()->setRule( action( id ), rule, true );
2400 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2403 //=======================================================================
2404 // function : initialize
2406 //=======================================================================
2407 void SMESHGUI::initialize( CAM_Application* app )
2409 SalomeApp_Module::initialize( app );
2411 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2413 /* Automatic Update flag */
2414 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2416 // ----- create actions --------------
2418 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2419 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2420 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2421 createSMESHAction( 114, "NUM" );
2422 createSMESHAction( 121, "DAT" );
2423 createSMESHAction( 122, "MED" );
2424 createSMESHAction( 123, "UNV" );
2425 createSMESHAction( 140, "STL" );
2426 createSMESHAction( 124, "EXPORT_DAT" );
2427 createSMESHAction( 125, "EXPORT_MED" );
2428 createSMESHAction( 126, "EXPORT_UNV" );
2429 createSMESHAction( 141, "EXPORT_STL" );
2430 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2431 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2432 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2433 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2434 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2435 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2436 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2437 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2438 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2439 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2440 createSMESHAction( 804, "ADD" );
2441 createSMESHAction( 805, "REMOVE" );
2442 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2443 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2444 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2445 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2446 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2447 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2448 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2449 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2450 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2451 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2452 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2453 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2454 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2455 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2456 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2457 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2458 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2459 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2460 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2461 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2462 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2463 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2464 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2465 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2466 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2467 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2468 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2469 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2470 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2471 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2472 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2473 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2474 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2475 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2476 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2477 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2478 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2479 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2480 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2481 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2482 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2483 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2484 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2485 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2486 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2487 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2488 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2489 createSMESHAction( 415, "MAP", "ICON_MAP" );
2490 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2491 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2492 createSMESHAction( 200, "RESET" );
2493 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2494 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2495 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2496 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2497 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2498 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2499 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2500 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2501 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2502 createSMESHAction( 220, "ALL" );
2503 createSMESHAction( 1100, "EDIT_HYPO" );
2504 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2505 createSMESHAction( 1102, "UNASSIGN" );
2506 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2507 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2508 createSMESHAction( 1131, "DISPMODE" );
2509 createSMESHAction( 1132, "COLORS" );
2510 createSMESHAction( 1133, "TRANSP" );
2511 createSMESHAction( 1134, "CLIP" );
2512 createSMESHAction( 1135, "DISP_ENT" );
2513 createSMESHAction( 1136, "AUTO_COLOR" );
2514 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2515 createSMESHAction( 2000, "CTRL" );
2517 createSMESHAction( 300, "ERASE" );
2518 createSMESHAction( 301, "DISPLAY" );
2519 createSMESHAction( 302, "DISPLAY_ONLY" );
2520 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2521 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2522 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2523 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2524 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2525 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2526 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2527 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2529 // ----- create menu --------------
2530 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2531 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2532 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2533 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2534 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2535 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2536 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2538 createMenu( separator(), fileId );
2540 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2541 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2542 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2543 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2544 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2545 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2547 createMenu( 111, importId, -1 );
2548 createMenu( 112, importId, -1 );
2549 createMenu( 113, importId, -1 );
2551 createMenu( 121, exportId, -1 );
2552 createMenu( 122, exportId, -1 );
2553 createMenu( 123, exportId, -1 );
2554 createMenu( 140, exportId, -1 ); // export to stl STL
2556 createMenu( separator(), fileId, 10 );
2558 createMenu( 33, editId, -1 );
2560 createMenu( 5105, toolsId, -1 );
2562 createMenu( 702, meshId, -1 );
2563 createMenu( 703, meshId, -1 );
2564 createMenu( 704, meshId, -1 );
2565 createMenu( 710, meshId, -1 );
2566 createMenu( separator(), meshId, -1 );
2567 createMenu( 701, meshId, -1 );
2568 createMenu( separator(), meshId, -1 );
2569 createMenu( 801, meshId, -1 );
2570 createMenu( 802, meshId, -1 );
2571 createMenu( 803, meshId, -1 );
2572 createMenu( separator(), meshId, -1 );
2573 createMenu( 810, meshId, -1 );
2574 createMenu( 811, meshId, -1 );
2575 createMenu( 812, meshId, -1 );
2576 createMenu( separator(), meshId, -1 );
2577 createMenu( 813, meshId, -1 );
2578 createMenu( separator(), meshId, -1 );
2579 createMenu( 900, meshId, -1 );
2580 createMenu( 902, meshId, -1 );
2581 createMenu( separator(), meshId, -1 );
2583 createMenu( 6003, ctrlId, -1 );
2584 createMenu( 6001, ctrlId, -1 );
2585 createMenu( 6004, ctrlId, -1 );
2586 createMenu( separator(), ctrlId, -1 );
2587 createMenu( 6002, ctrlId, -1 );
2588 createMenu( 6018, ctrlId, -1 );
2589 createMenu( 6019, ctrlId, -1 );
2590 createMenu( 6011, ctrlId, -1 );
2591 createMenu( 6012, ctrlId, -1 );
2592 createMenu( 6013, ctrlId, -1 );
2593 createMenu( 6014, ctrlId, -1 );
2594 createMenu( 6015, ctrlId, -1 );
2595 createMenu( 6016, ctrlId, -1 );
2596 createMenu( separator(), ctrlId, -1 );
2597 createMenu( 6017, ctrlId, -1 );
2598 createMenu( 6009, ctrlId, -1 );
2599 createMenu( separator(), ctrlId, -1 );
2601 createMenu( 400, addId, -1 );
2602 createMenu( 401, addId, -1 );
2603 createMenu( 4021, addId, -1 );
2604 createMenu( 4022, addId, -1 );
2605 createMenu( 4023, addId, -1 );
2606 createMenu( 4031, addId, -1 );
2607 createMenu( 4032, addId, -1 );
2608 createMenu( 4033, addId, -1 );
2609 createMenu( separator(), addId, -1 );
2610 createMenu( 4034, addId, -1 );
2611 createMenu( 4035, addId, -1 );
2612 createMenu( 4036, addId, -1 );
2613 createMenu( 4037, addId, -1 );
2614 createMenu( 4038, addId, -1 );
2615 createMenu( 4039, addId, -1 );
2616 createMenu( 4040, addId, -1 );
2618 createMenu( 4041, removeId, -1 );
2619 createMenu( 4042, removeId, -1 );
2621 createMenu( 4051, renumId, -1 );
2622 createMenu( 4052, renumId, -1 );
2624 createMenu( 4061, transfId, -1 );
2625 createMenu( 4062, transfId, -1 );
2626 createMenu( 4063, transfId, -1 );
2627 createMenu( 4064, transfId, -1 );
2628 createMenu( 4065, transfId, -1 );
2629 createMenu( 4066, transfId, -1 );
2631 createMenu( 406, modifyId, -1 );
2632 createMenu( 4067,modifyId, -1 );
2633 createMenu( 407, modifyId, -1 );
2634 createMenu( 408, modifyId, -1 );
2635 createMenu( 409, modifyId, -1 );
2636 createMenu( 410, modifyId, -1 );
2637 createMenu( 411, modifyId, -1 );
2638 createMenu( 412, modifyId, -1 );
2639 createMenu( 413, modifyId, -1 );
2640 createMenu( 416, modifyId, -1 );
2641 createMenu( 414, modifyId, -1 );
2642 createMenu( 415, modifyId, -1 );
2643 createMenu( 417, modifyId, -1 );
2645 createMenu( 214, viewId, -1 );
2647 // ----- create toolbars --------------
2648 int meshTb = createTool( tr( "TB_MESH" ) ),
2649 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2650 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2651 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2652 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2654 createTool( 702, meshTb );
2655 createTool( 703, meshTb );
2656 createTool( 704, meshTb );
2657 createTool( 710, meshTb );
2658 createTool( separator(), meshTb );
2659 createTool( 701, meshTb );
2660 createTool( separator(), meshTb );
2661 createTool( 801, meshTb );
2662 createTool( 802, meshTb );
2663 createTool( 803, meshTb );
2664 createTool( separator(), meshTb );
2665 createTool( 900, meshTb );
2666 createTool( 902, meshTb );
2667 createTool( separator(), meshTb );
2669 createTool( 6001, ctrlTb );
2670 createTool( 6003, ctrlTb );
2671 createTool( 6004, ctrlTb );
2672 createTool( separator(), ctrlTb );
2673 createTool( 6002, ctrlTb );
2674 createTool( 6018, ctrlTb );
2675 createTool( 6019, ctrlTb );
2676 createTool( 6011, ctrlTb );
2677 createTool( 6012, ctrlTb );
2678 createTool( 6013, ctrlTb );
2679 createTool( 6014, ctrlTb );
2680 createTool( 6015, ctrlTb );
2681 createTool( 6016, ctrlTb );
2682 createTool( separator(), ctrlTb );
2683 createTool( 6017, ctrlTb );
2684 createTool( 6009, ctrlTb );
2685 createTool( separator(), ctrlTb );
2687 createTool( 400, addRemTb );
2688 createTool( 401, addRemTb );
2689 createTool( 4021, addRemTb );
2690 createTool( 4022, addRemTb );
2691 createTool( 4023, addRemTb );
2692 createTool( 4031, addRemTb );
2693 createTool( 4032, addRemTb );
2694 createTool( 4033, addRemTb );
2695 createTool( separator(), addRemTb );
2696 createTool( 4034, addRemTb );
2697 createTool( 4035, addRemTb );
2698 createTool( 4036, addRemTb );
2699 createTool( 4037, addRemTb );
2700 createTool( 4038, addRemTb );
2701 createTool( 4039, addRemTb );
2702 createTool( 4040, addRemTb );
2703 createTool( separator(), addRemTb );
2704 createTool( 4041, addRemTb );
2705 createTool( 4042, addRemTb );
2706 createTool( separator(), addRemTb );
2707 createTool( 4051, addRemTb );
2708 createTool( 4052, addRemTb );
2709 createTool( separator(), addRemTb );
2710 createTool( 4061, addRemTb );
2711 createTool( 4062, addRemTb );
2712 createTool( 4063, addRemTb );
2713 createTool( 4064, addRemTb );
2714 createTool( 4065, addRemTb );
2715 createTool( 4066, addRemTb );
2716 createTool( separator(), addRemTb );
2718 createTool( 406, modifyTb );
2719 createTool( 4067,modifyTb );
2720 createTool( 407, modifyTb );
2721 createTool( 408, modifyTb );
2722 createTool( 409, modifyTb );
2723 createTool( 410, modifyTb );
2724 createTool( 411, modifyTb );
2725 createTool( 412, modifyTb );
2726 createTool( 413, modifyTb );
2727 createTool( 416, modifyTb );
2728 createTool( 414, modifyTb );
2729 createTool( 415, modifyTb );
2730 createTool( 417, modifyTb );
2732 createTool( 214, dispModeTb );
2736 QString OB = "'ObjectBrowser'",
2737 View = "'" + SVTK_Viewer::Type() + "'",
2739 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2740 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2741 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2742 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2743 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2744 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2745 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2746 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2747 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2748 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2749 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2751 mesh_group = mesh + " " + subMesh + " " + group,
2752 hyp_alg = hypo + " " + algo;
2754 // popup for object browser
2756 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2757 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2758 createPopupItem( 803, OB, group ); // EDIT_GROUP
2759 popupMgr()->insert( separator(), -1, 0 );
2760 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2761 createPopupItem( 214, OB, mesh_group ); // UPDATE
2762 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2763 createPopupItem( 902, OB, mesh ); // STD_INFO
2764 popupMgr()->insert( separator(), -1, 0 );
2765 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2766 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2767 popupMgr()->insert( separator(), -1, 0 );
2768 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2769 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2770 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2771 popupMgr()->insert( separator(), -1, 0 );
2773 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2774 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2775 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2776 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2777 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2778 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2779 popupMgr()->insert( separator(), -1, 0 );
2782 createPopupItem( 803, View, group ); // EDIT_GROUP
2783 createPopupItem( 804, View, elems ); // ADD
2784 createPopupItem( 805, View, elems ); // REMOVE
2785 popupMgr()->insert( separator(), -1, 0 );
2786 createPopupItem( 214, View, mesh_group ); // UPDATE
2787 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2788 createPopupItem( 902, View, mesh ); // STD_INFO
2789 popupMgr()->insert( separator(), -1, 0 );
2791 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2792 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2793 popupMgr()->insert( separator(), -1, 0 );
2797 isInvisible("not( isVisible )"),
2798 isEmpty("numberOfNodes = 0"),
2799 isNotEmpty("numberOfNodes <> 0"),
2801 // has nodes, edges, etc in VISIBLE! actor
2802 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2803 hasElems("(count( elemTypes ) > 0)"),
2804 hasDifferentElems("(count( elemTypes ) > 1)"),
2805 hasEdges("({'Edge'} in elemTypes)"),
2806 hasFaces("({'Face'} in elemTypes)"),
2807 hasVolumes("({'Volume'} in elemTypes)");
2809 QString lc = QtxPopupMgr::Selection::defEquality();
2810 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2811 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2812 aType = aType.arg( mesh_group );
2813 QString aMeshInVTK = aClient + "&&" + aType;
2815 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2816 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2817 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2819 //-------------------------------------------------
2821 //-------------------------------------------------
2822 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2824 popupMgr()->insert( action( 9010 ), anId, -1 );
2825 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2826 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2828 popupMgr()->insert( action( 9011 ), anId, -1 );
2829 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2830 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2832 popupMgr()->insert( separator(), -1, -1 );
2834 //-------------------------------------------------
2836 //-------------------------------------------------
2837 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2839 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2840 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2841 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2843 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2844 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2845 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2847 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2848 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2849 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2851 popupMgr()->insert( separator(), anId, -1 );
2853 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2854 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2855 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2857 //-------------------------------------------------
2859 //-------------------------------------------------
2860 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2862 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2864 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2865 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2866 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2868 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2869 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2870 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2872 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2873 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2874 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2876 popupMgr()->insert( separator(), anId, -1 );
2878 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2879 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2881 //-------------------------------------------------
2883 //-------------------------------------------------
2884 popupMgr()->insert( action( 1132 ), -1, -1 );
2885 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2887 //-------------------------------------------------
2889 //-------------------------------------------------
2890 popupMgr()->insert( action( 1133 ), -1, -1 );
2891 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2893 //-------------------------------------------------
2895 //-------------------------------------------------
2896 popupMgr()->insert( action( 1134 ), -1, -1 );
2897 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2899 popupMgr()->insert( separator(), -1, -1 );
2901 //-------------------------------------------------
2903 //-------------------------------------------------
2905 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2906 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2907 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2909 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2911 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2912 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2914 popupMgr()->insert( separator(), anId, -1 );
2916 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2917 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2918 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2920 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2921 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2922 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2924 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2925 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2926 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2928 popupMgr()->insert( separator(), anId, -1 );
2930 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2931 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2932 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2934 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2935 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2936 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2938 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2939 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2940 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2942 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2943 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2944 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2946 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2947 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2948 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2950 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2951 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2952 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2954 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2955 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2956 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2958 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2959 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2960 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2962 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2963 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2964 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2966 popupMgr()->insert( separator(), anId, -1 );
2968 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2969 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2970 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2972 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2973 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2974 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2976 popupMgr()->insert( separator(), anId, -1 );
2978 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2979 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2981 popupMgr()->insert( separator(), -1, -1 );
2983 //-------------------------------------------------
2985 //-------------------------------------------------
2986 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2987 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2988 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2989 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2991 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2992 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2994 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2995 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2997 popupMgr()->insert( separator(), -1, -1 );
2999 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3000 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3003 bool SMESHGUI::activateModule( SUIT_Study* study )
3005 bool res = SalomeApp_Module::activateModule( study );
3007 setMenuShown( true );
3008 setToolShown( true );
3010 // Reset actions accelerator keys
3011 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3012 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3013 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3018 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3020 setMenuShown( false );
3021 setToolShown( false );
3023 EmitSignalCloseAllDialogs();
3025 // Unset actions accelerator keys
3026 action(111)->setAccel(QKeySequence()); // Import DAT
3027 action(112)->setAccel(QKeySequence()); // Import UNV
3028 action(113)->setAccel(QKeySequence()); // Import MED
3030 return SalomeApp_Module::deactivateModule( study );
3033 void SMESHGUI::OnGUIEvent()
3035 const QObject* obj = sender();
3036 if ( !obj || !obj->inherits( "QAction" ) )
3038 int id = actionId((QAction*)obj);
3043 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3045 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3046 if ( CORBA::is_nil( myComponentSMESH ) )
3048 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3050 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3051 return aGUI.myComponentSMESH;
3054 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3055 return myComponentSMESH;
3058 QString SMESHGUI::engineIOR() const
3060 CORBA::ORB_var anORB = getApp()->orb();
3061 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3062 return QString( anIOR.in() );
3065 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3067 SMESHGUI_Selection sel;
3068 sel.init( client, selectionMgr() );
3069 popupMgr()->updatePopup( menu, &sel );
3072 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3074 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3075 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3078 void SMESHGUI::viewManagers( QStringList& list ) const
3080 list.append( SVTK_Viewer::Type() );
3083 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3085 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3086 SMESH::UpdateSelectionProp( this );
3089 void SMESHGUI::createPreferences()
3091 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3093 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3094 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3096 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3097 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3098 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3100 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3101 setPreferenceProperty( precGroup, "columns", 1 );
3103 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3105 setPreferenceProperty( prec, "min", 0 );
3106 setPreferenceProperty( prec, "max", 16 );
3108 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3109 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3111 modes.append( "Wireframe" );
3112 modes.append( "Shading" );
3113 modes.append( "Nodes" );
3114 modes.append( "Shrink" );
3115 QValueList<QVariant> indices;
3116 indices.append( 0 );
3117 indices.append( 1 );
3118 indices.append( 2 );
3119 indices.append( 3 );
3120 setPreferenceProperty( dispmode, "strings", modes );
3121 setPreferenceProperty( dispmode, "indexes", indices );
3123 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3124 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3125 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3127 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3128 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3130 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3131 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3133 setPreferenceProperty( nodeSz, "min", 1 );
3134 setPreferenceProperty( nodeSz, "max", 5 );
3136 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3138 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3139 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3140 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3141 addPreference( "", elemGroup, LightApp_Preferences::Space );
3143 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3144 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3146 setPreferenceProperty( elemW, "min", 1 );
3147 setPreferenceProperty( elemW, "max", 5 );
3149 setPreferenceProperty( shrink, "min", 0 );
3150 setPreferenceProperty( shrink, "max", 100 );
3152 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3154 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3156 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3157 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3158 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3160 setPreferenceProperty( selW, "min", 1 );
3161 setPreferenceProperty( selW, "max", 5 );
3163 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3165 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3166 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3168 setPreferenceProperty( preW, "min", 1 );
3169 setPreferenceProperty( preW, "max", 5 );
3171 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3173 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3174 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3175 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3177 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3178 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3180 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3181 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3182 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3183 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3186 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3187 fam.append( tr( "SMESH_FONT_COURIER" ) );
3188 fam.append( tr( "SMESH_FONT_TIMES" ) );
3189 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3191 setPreferenceProperty( tfont, "families", fam );
3192 setPreferenceProperty( tfont, "system", false );
3193 setPreferenceProperty( tfont, "widget_flags", wflag );
3194 setPreferenceProperty( lfont, "families", fam );
3195 setPreferenceProperty( lfont, "system", false );
3196 setPreferenceProperty( lfont, "widget_flags", wflag );
3198 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3200 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3201 setPreferenceProperty( numcol, "min", 2 );
3202 setPreferenceProperty( numcol, "max", 256 );
3204 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3205 setPreferenceProperty( numlab, "min", 2 );
3206 setPreferenceProperty( numlab, "max", 65 );
3208 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3209 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3210 QStringList orients;
3211 orients.append( tr( "SMESH_VERTICAL" ) );
3212 orients.append( tr( "SMESH_HORIZONTAL" ) );
3213 indices.clear(); indices.append( 0 ); indices.append( 1 );
3214 setPreferenceProperty( orient, "strings", orients );
3215 setPreferenceProperty( orient, "indexes", indices );
3217 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3218 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3219 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3220 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3221 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3222 setPreferenceProperty( xv, "step", 0.1 );
3223 setPreferenceProperty( xv, "min", 0.0 );
3224 setPreferenceProperty( xv, "max", 1.0 );
3225 setPreferenceProperty( yv, "step", 0.1 );
3226 setPreferenceProperty( yv, "min", 0.0 );
3227 setPreferenceProperty( yv, "max", 1.0 );
3228 setPreferenceProperty( wv, "step", 0.1 );
3229 setPreferenceProperty( wv, "min", 0.0 );
3230 setPreferenceProperty( wv, "max", 1.0 );
3231 setPreferenceProperty( hv, "min", 0.0 );
3232 setPreferenceProperty( hv, "max", 1.0 );
3233 setPreferenceProperty( hv, "step", 0.1 );
3235 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3236 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3237 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3238 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3239 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3240 setPreferenceProperty( xv, "min", 0.0 );
3241 setPreferenceProperty( xv, "max", 1.0 );
3242 setPreferenceProperty( xv, "step", 0.1 );
3243 setPreferenceProperty( xh, "min", 0.0 );
3244 setPreferenceProperty( xh, "max", 1.0 );
3245 setPreferenceProperty( xh, "step", 0.1 );
3246 setPreferenceProperty( yh, "min", 0.0 );
3247 setPreferenceProperty( yh, "max", 1.0 );
3248 setPreferenceProperty( yh, "step", 0.1 );
3249 setPreferenceProperty( wh, "min", 0.0 );
3250 setPreferenceProperty( wh, "max", 1.0 );
3251 setPreferenceProperty( wh, "step", 0.1 );
3252 setPreferenceProperty( hh, "min", 0.0 );
3253 setPreferenceProperty( hh, "max", 1.0 );
3254 setPreferenceProperty( hh, "step", 0.1 );
3257 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3259 if( sect=="SMESH" ){
3260 float sbX1,sbY1,sbW,sbH;
3261 float aTol = 1.00000009999999;
3262 std::string aWarning;
3263 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3264 if( name=="selection_object_color" || name=="selection_element_color" ||
3265 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3266 name=="selection_precision_node" || name=="selection_precision_element" ||
3267 name=="selection_precision_object")
3268 SMESH::UpdateSelectionProp( this );
3269 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3270 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3271 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3272 if(sbX1+sbW > aTol){
3273 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3276 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3277 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3280 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3281 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3282 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3283 if(sbY1+sbH > aTol){
3284 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3285 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3286 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3289 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3290 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3291 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3292 if(sbX1+sbW > aTol){
3293 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3296 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3297 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3300 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3301 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3302 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3303 if(sbY1+sbH > aTol){
3304 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3307 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3308 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3312 if(aWarning.size() != 0){
3313 aWarning += "The default values are applied instead.";
3314 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3315 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3316 QObject::tr(aWarning.c_str()),
3317 QObject::tr("SMESH_BUT_OK"));
3322 //================================================================================
3324 * \brief Update something in accordance with update flags
3325 * \param theFlags - update flags
3327 * Update viewer or/and object browser etc. in accordance with update flags ( see
3328 * LightApp_UpdateFlags enumeration ).
3330 //================================================================================
3331 void SMESHGUI::update( const int flags )
3333 if ( flags & UF_Viewer | flags & UF_Forced )
3334 SMESH::UpdateView();
3336 SalomeApp_Module::update( flags );
3339 //================================================================================
3341 * \brief Set default selection mode
3343 * SLOT called when operation commited. Sets default selection mode
3345 //================================================================================
3346 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3348 SVTK_ViewWindow* vtkWnd =
3349 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3351 vtkWnd->SetSelectionMode( ActorSelection );
3354 //================================================================================
3356 * \brief Set default selection mode
3358 * SLOT called when operation aborted. Sets default selection mode
3360 //================================================================================
3361 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3363 SVTK_ViewWindow* vtkWnd =
3364 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3366 vtkWnd->SetSelectionMode( ActorSelection );
3369 //================================================================================
3371 * \brief Creates operation with given identifier
3372 * \param id - identifier of operation to be started
3373 * \return Pointer on created operation or NULL if operation is not created
3375 * Virtual method redefined from the base class creates operation with given id.
3376 * It is called called automatically from startOperation method of base class.
3378 //================================================================================
3379 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3381 LightApp_Operation* op = 0;
3382 // to do : create operation here
3385 case 701: // Compute mesh
3386 op = new SMESHGUI_ComputeOp();
3388 case 702: // Create mesh
3389 op = new SMESHGUI_MeshOp( true, true );
3391 case 703: // Create sub-mesh
3392 op = new SMESHGUI_MeshOp( true, false );
3394 case 704: // Edit mesh/sub-mesh
3395 op = new SMESHGUI_MeshOp( false );
3397 case 417: //convert to quadratic
3398 op = new SMESHGUI_ConvToQuadOp();
3400 case 4067: // make mesh pass through point
3401 op = new SMESHGUI_MakeNodeAtPointOp();
3408 op = SalomeApp_Module::createOperation( id );
3412 //================================================================================
3414 * \brief Stops current operations and starts a given one
3415 * \param id - The id of the operation to start
3417 //================================================================================
3419 void SMESHGUI::switchToOperation(int id)
3421 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3422 activeStudy()->abortAllOperations();
3423 startOperation( id );
3426 LightApp_Displayer* SMESHGUI::displayer()
3429 myDisplayer = new SMESHGUI_Displayer( getApp() );
3433 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3436 int aTolerance = 64;
3437 int anIterations = 0;
3443 if( anIterations % aPeriod == 0 )
3446 if( aTolerance < 1 )
3449 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3451 aHue = (int)( 360.0 * rand() / RAND_MAX );
3452 //cout << "Hue = " << aHue << endl;
3454 //cout << "Auto colors : ";
3456 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3457 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3458 for( ; it != itEnd; ++it )
3460 SALOMEDS::Color anAutoColor = *it;
3461 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3464 aQColor.getHsv( &h, &s, &v );
3466 if( abs( h - aHue ) < aTolerance )
3469 //cout << "break (diff = " << abs( h - aHue ) << ")";
3479 //cout << "Hue of the returned color = " << aHue << endl;
3481 aColor.setHsv( aHue, 255, 255 );
3483 SALOMEDS::Color aSColor;
3484 aSColor.R = (double)aColor.red() / 255.0;
3485 aSColor.G = (double)aColor.green() / 255.0;
3486 aSColor.B = (double)aColor.blue() / 255.0;