1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
71 #include "SMESHGUI_FileInfoDlg.h"
73 #include "SMESHGUI_Utils.h"
74 #include "SMESHGUI_GEOMGenUtils.h"
75 #include "SMESHGUI_MeshUtils.h"
76 #include "SMESHGUI_GroupUtils.h"
77 #include "SMESHGUI_FilterUtils.h"
78 #include "SMESHGUI_PatternUtils.h"
79 #include "SMESHGUI_VTKUtils.h"
80 #include "SMESHGUI_HypothesesUtils.h"
82 #include "SMESH_Actor.h"
83 #include "SMESH_Object.h"
84 #include "SMESH_TypeFilter.hxx"
86 #include "SalomeApp_Tools.h"
87 #include "SalomeApp_Study.h"
88 #include "SalomeApp_Application.h"
89 #include "SalomeApp_CheckFileDlg.h"
90 #include "SalomeApp_ImportOperation.h"
92 #include "LightApp_DataOwner.h"
93 #include "LightApp_Preferences.h"
94 #include "LightApp_VTKSelector.h"
95 #include "LightApp_Operation.h"
96 #include "LightApp_UpdateFlags.h"
97 #include "LightApp_NameDlg.h"
99 #include <SVTK_ViewWindow.h>
100 #include <SVTK_ViewModel.h>
101 #include <SVTK_InteractorStyle.h>
102 #include <SVTK_RenderWindowInteractor.h>
103 #include <SVTK_ViewManager.h>
105 #include "OB_Browser.h"
107 #include "SUIT_Tools.h"
108 #include "SUIT_MessageBox.h"
109 #include "SUIT_ResourceMgr.h"
110 #include "SUIT_FileDlg.h"
111 #include "SUIT_Desktop.h"
112 #include "SUIT_OverrideCursor.h"
113 #include "SUIT_Study.h"
114 #include "SUIT_Session.h"
116 #include "QtxPopupMgr.h"
118 #include "SALOME_ListIO.hxx"
119 #include "SALOME_ListIteratorOfListIO.hxx"
120 #include "SALOME_InteractiveObject.hxx"
121 #include "SALOME_NamingService.hxx"
122 #include "SALOME_LifeCycleCORBA.hxx"
124 #include "SALOMEconfig.h"
125 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
126 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
129 #define INCLUDE_MENUITEM_DEF
130 #include <qpopupmenu.h>
136 #include <boost/shared_ptr.hpp>
139 #include <vtkRenderer.h>
140 #include <vtkRenderWindow.h>
141 #include <vtkActorCollection.h>
142 #include <vtkScalarBarActor.h>
143 #include <vtkUnstructuredGrid.h>
145 #include "utilities.h"
147 #include "SALOMEDS_Study.hxx"
148 #include "SALOMEDSClient_StudyBuilder.hxx"
149 #include "SALOMEDSClient_SComponent.hxx"
151 #include <Standard_ErrorHandler.hxx>
157 //=============================================================
158 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
161 void ExportMeshToFile(int theCommandID);
163 void SetDisplayMode(int theCommandID);
165 void SetDisplayEntity(int theCommandID);
167 void Control( int theCommandID );
171 //=============================================================
172 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
178 if(theCommandID == 113){
179 filter.append(QObject::tr("MED files (*.med)"));
180 filter.append(QObject::tr("All files (*)"));
181 }else if (theCommandID == 112){
182 filter.append(QObject::tr("IDEAS files (*.unv)"));
183 }else if (theCommandID == 111){
184 filter.append(QObject::tr("DAT files (*.dat)"));
187 QString anInitialPath = "";
188 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
189 anInitialPath = QDir::currentDirPath();
191 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
194 QObject::tr("Import mesh"),
196 if(!filename.isEmpty()) {
197 SUIT_OverrideCursor wc;
198 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
201 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
202 switch ( theCommandID ) {
205 aMeshes->length( 1 );
206 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
211 SMESH::DriverMED_ReadStatus res;
212 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
213 if ( res != SMESH::DRS_OK ) {
215 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
216 QObject::tr("SMESH_WRN_WARNING"),
217 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
218 QObject::tr("SMESH_BUT_OK"));
219 aMeshes->length( 0 );
226 bool isEmpty = false;
227 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
228 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
230 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
231 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
232 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
233 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
234 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
241 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
242 QObject::tr("SMESH_WRN_WARNING"),
243 QObject::tr("SMESH_DRS_EMPTY"),
244 QObject::tr("SMESH_BUT_OK"));
248 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
250 catch (const SALOME::SALOME_Exception& S_ex){
252 SalomeApp_Tools::QtCatchCorbaException(S_ex);
259 void ExportMeshToFile( int theCommandID )
261 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
262 SALOME_ListIO selected;
264 aSel->selectedObjects( selected );
266 if(selected.Extent()){
267 Handle(SALOME_InteractiveObject) anIObject = selected.First();
268 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
269 if ( !aMesh->_is_nil() ) {
270 QString aFilter, aTitle = QObject::tr("Export mesh");
271 QMap<QString, SMESH::MED_VERSION> aFilterMap;
272 QMap<QString, int> aFilterMapSTL;
273 switch ( theCommandID ) {
277 if (aMesh->HasDuplicatedGroupNamesMED()) {
278 int aRet = SUIT_MessageBox::warn2
279 (SMESHGUI::desktop(),
280 QObject::tr("SMESH_WRN_WARNING"),
281 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
282 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
288 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
289 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
290 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
291 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
296 aFilter = QObject::tr("DAT files (*.dat)");
301 if (aMesh->NbPyramids()) {
302 int aRet = SUIT_MessageBox::warn2
303 (SMESHGUI::desktop(),
304 QObject::tr("SMESH_WRN_WARNING"),
305 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
306 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
311 aFilter = QObject::tr("IDEAS files (*.unv)");
319 there must be check on others mesh elements not equal triangles
321 if (aMesh->NbTriangles() < 1) {
322 SUIT_MessageBox::warn1
323 (SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
326 QObject::tr("SMESH_BUT_OK"));
329 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
330 int aRet = SUIT_MessageBox::warn2
331 (SMESHGUI::desktop(),
332 QObject::tr("SMESH_WRN_WARNING"),
333 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
334 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
340 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
341 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
349 SMESH::MED_VERSION aFormat;
350 // Init the parameter with the default value
351 bool aIsASCII_STL = true;
352 bool toCreateGroups = false;
353 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
355 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
357 QString anInitialPath = "";
358 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
359 anInitialPath = QDir::currentDirPath();
361 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
362 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
363 aFilter, aTitle, false);
364 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
366 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
367 for ( ; it != aFilterMapSTL.end(); ++it )
368 filters.push_back( it.key() );
370 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
371 fd->setCaption( aTitle );
372 fd->setFilters( filters );
373 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
374 if ( !anInitialPath.isEmpty() )
375 fd->setDir( anInitialPath );
376 fd->setSelection(anIObject->getName());
380 aFilename = fd->selectedFile();
381 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
386 else { // Export to MED
388 QString aDefaultFilter;
389 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
390 for ( ; it != aFilterMap.end(); ++it ) {
391 filters.push_back( it.key() );
392 if (it.data() == SMESH::MED_V2_2)
393 aDefaultFilter = it.key();
396 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
397 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
398 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
399 fd->setCaption( aTitle );
400 fd->setFilters( filters );
401 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
402 fd->setSelectedFilter(aDefaultFilter);
403 fd->SetChecked(toCreateGroups);
404 if ( !anInitialPath.isEmpty() )
405 fd->setDir( anInitialPath );
406 fd->setSelection(anIObject->getName());
410 aFilename = fd->selectedFile();
411 aFormat = aFilterMap[fd->selectedFilter()];
413 if ( !aFilename.isEmpty()
414 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
415 && aFormat==SMESH::MED_V2_1) {
416 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
417 QObject::tr("SMESH_WRN_WARNING"),
418 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
419 QObject::tr("SMESH_BUT_YES"),
420 QObject::tr("SMESH_BUT_NO"),
427 toCreateGroups = fd->IsChecked();
430 if ( !aFilename.isEmpty() ) {
431 // Check whether the file already exists and delete it if yes
432 QFile aFile( aFilename );
433 if ( aFile.exists() )
435 SUIT_OverrideCursor wc;
438 bool Renumber = false ;
439 // PAL 14172 : Check of we have to renumber or not from the preferences before export
441 Renumber= resMgr->booleanValue("SMESH","renumbering");
443 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
444 aMeshEditor->RenumberNodes();
445 aMeshEditor->RenumberElements();
446 if ( SMESHGUI::automaticUpdate() )
449 switch ( theCommandID ) {
452 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
456 aMesh->ExportDAT( aFilename.latin1() );
460 aMesh->ExportUNV( aFilename.latin1() );
464 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
470 catch (const SALOME::SALOME_Exception& S_ex){
472 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
473 QObject::tr("SMESH_WRN_WARNING"),
474 QObject::tr("SMESH_EXPORT_FAILED"),
475 QObject::tr("SMESH_BUT_OK"));
483 inline void InverseEntityMode(unsigned int& theOutputMode,
484 unsigned int theMode)
486 bool anIsNotPresent = ~theOutputMode & theMode;
488 theOutputMode |= theMode;
490 theOutputMode &= ~theMode;
493 void SetDisplayEntity(int theCommandID){
494 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
495 SALOME_ListIO selected;
497 aSel->selectedObjects( selected );
499 if(selected.Extent() >= 1){
500 SALOME_ListIteratorOfListIO It( selected );
501 for(; It.More(); It.Next()){
502 Handle(SALOME_InteractiveObject) IObject = It.Value();
503 if(IObject->hasEntry()){
504 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
505 unsigned int aMode = anActor->GetEntityMode();
506 switch(theCommandID){
508 InverseEntityMode(aMode,SMESH_Actor::eEdges);
511 InverseEntityMode(aMode,SMESH_Actor::eFaces);
514 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
517 aMode = SMESH_Actor::eAllEntity;
521 anActor->SetEntityMode(aMode);
529 SALOME_ListIO selected;
530 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
534 LightApp_SelectionMgr* aSel = app->selectionMgr();
535 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
536 if( !aSel || !appStudy )
539 aSel->selectedObjects( selected );
540 if( selected.IsEmpty() )
543 Handle(SALOME_InteractiveObject) anIObject = selected.First();
545 _PTR(Study) aStudy = appStudy->studyDS();
546 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
547 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
548 if( aMainObject->_is_nil() )
551 aMainObject->SetAutoColor( true );
553 QValueList<SALOMEDS::Color> aReservedColors;
555 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
556 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
558 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
559 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
561 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
562 aGroupObject->SetColor( aColor );
563 aReservedColors.append( aColor );
565 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
566 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
568 if( aGroupObject->GetType() == SMESH::NODE )
569 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
570 else if( aGroupObject->GetType() == SMESH::EDGE )
571 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
573 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
577 SMESH::RepaintCurrentView();
580 void DisableAutoColor(){
581 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
582 SALOME_ListIO selected;
584 aSel->selectedObjects( selected );
586 if(selected.Extent()){
587 Handle(SALOME_InteractiveObject) anIObject = selected.First();
588 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
589 if ( !aMesh->_is_nil() ) {
590 aMesh->SetAutoColor( false );
595 void SetDisplayMode(int theCommandID){
596 SALOME_ListIO selected;
597 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
601 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
602 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
603 if( !aSel || !appStudy )
606 _PTR(Study) aStudy = appStudy->studyDS();
608 aSel->selectedObjects( selected );
610 if(selected.Extent() >= 1){
611 switch(theCommandID){
613 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
614 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
618 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
619 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
622 SALOME_ListIteratorOfListIO It( selected );
623 for(; It.More(); It.Next()){
624 Handle(SALOME_InteractiveObject) IObject = It.Value();
625 if(IObject->hasEntry()){
626 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
627 switch(theCommandID){
629 anActor->SetRepresentation(SMESH_Actor::eEdge);
632 anActor->SetRepresentation(SMESH_Actor::eSurface);
635 if(anActor->IsShrunk())
638 anActor->SetShrink();
641 anActor->SetRepresentation(SMESH_Actor::ePoint);
644 vtkFloatingPointType color[3];
645 anActor->GetSufaceColor(color[0], color[1], color[2]);
646 int c0 = int (color[0] * 255);
647 int c1 = int (color[1] * 255);
648 int c2 = int (color[2] * 255);
649 QColor c(c0, c1, c2);
651 vtkFloatingPointType edgecolor[3];
652 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
653 c0 = int (edgecolor[0] * 255);
654 c1 = int (edgecolor[1] * 255);
655 c2 = int (edgecolor[2] * 255);
656 QColor e(c0, c1, c2);
658 vtkFloatingPointType backfacecolor[3];
659 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
660 c0 = int (backfacecolor[0] * 255);
661 c1 = int (backfacecolor[1] * 255);
662 c2 = int (backfacecolor[2] * 255);
663 QColor b(c0, c1, c2);
665 vtkFloatingPointType nodecolor[3];
666 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
667 c0 = int (nodecolor[0] * 255);
668 c1 = int (nodecolor[1] * 255);
669 c2 = int (nodecolor[2] * 255);
670 QColor n(c0, c1, c2);
672 int Edgewidth = (int)anActor->GetLineWidth();
675 int intValue = int(anActor->GetNodeSize());
676 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
678 SMESHGUI_Preferences_ColorDlg *aDlg =
679 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
680 aDlg->SetColor(1, c);
681 aDlg->SetColor(2, e);
682 aDlg->SetColor(3, n);
683 aDlg->SetColor(4, b);
684 aDlg->SetIntValue(1, Edgewidth);
685 aDlg->SetIntValue(2, intValue);
686 aDlg->SetIntValue(3, int(Shrink*100.));
688 QColor color = aDlg->GetColor(1);
689 QColor edgecolor = aDlg->GetColor(2);
690 QColor nodecolor = aDlg->GetColor(3);
691 QColor backfacecolor = aDlg->GetColor(4);
692 /* actor color and backface color */
693 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
694 vtkFloatingPointType (color.green()) / 255.,
695 vtkFloatingPointType (color.blue()) / 255.);
696 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
697 vtkFloatingPointType (backfacecolor.green()) / 255.,
698 vtkFloatingPointType (backfacecolor.blue()) / 255.);
701 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
702 vtkFloatingPointType (edgecolor.green()) / 255.,
703 vtkFloatingPointType (edgecolor.blue()) / 255.);
705 /* Shrink factor and size edges */
706 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
707 anActor->SetLineWidth(aDlg->GetIntValue(1));
709 /* Nodes color and size */
710 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
711 vtkFloatingPointType (nodecolor.green()) / 255.,
712 vtkFloatingPointType (nodecolor.blue()) / 255.);
713 anActor->SetNodeSize(aDlg->GetIntValue(2));
715 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
716 if( !aGroupObject->_is_nil() )
718 SALOMEDS::Color aColor;
719 aColor.R = (float)color.red() / 255.0;
720 aColor.G = (float)color.green() / 255.0;
721 aColor.B = (float)color.blue() / 255.0;
722 aGroupObject->SetColor( aColor );
732 SMESH::RepaintCurrentView();
736 void Control( int theCommandID )
738 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
739 SALOME_ListIO selected;
741 aSel->selectedObjects( selected );
743 if( !selected.IsEmpty() ){
744 Handle(SALOME_InteractiveObject) anIO = selected.First();
747 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
748 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
749 switch ( theCommandID ){
751 aTitle = QObject::tr( "LENGTH_EDGES" );
752 aControl = SMESH_Actor::eLength;
755 aTitle = QObject::tr( "LENGTH2D_EDGES" );
756 aControl = SMESH_Actor::eLength2D;
759 aTitle = QObject::tr( "FREE_EDGES" );
760 aControl = SMESH_Actor::eFreeEdges;
763 aTitle = QObject::tr( "FREE_BORDERS" );
764 aControl = SMESH_Actor::eFreeBorders;
767 aTitle = QObject::tr( "MULTI_BORDERS" );
768 aControl = SMESH_Actor::eMultiConnection;
771 aTitle = QObject::tr( "MULTI2D_BORDERS" );
772 aControl = SMESH_Actor::eMultiConnection2D;
775 aTitle = QObject::tr( "AREA_ELEMENTS" );
776 aControl = SMESH_Actor::eArea;
779 aTitle = QObject::tr( "TAPER_ELEMENTS" );
780 aControl = SMESH_Actor::eTaper;
783 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
784 aControl = SMESH_Actor::eAspectRatio;
787 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
788 aControl = SMESH_Actor::eAspectRatio3D;
791 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
792 aControl = SMESH_Actor::eMinimumAngle;
795 aTitle = QObject::tr( "WARP_ELEMENTS" );
796 aControl = SMESH_Actor::eWarping;
799 aTitle = QObject::tr( "SKEW_ELEMENTS" );
800 aControl = SMESH_Actor::eSkew;
803 aTitle = QObject::tr( "SMESH_VOLUME" );
804 aControl = SMESH_Actor::eVolume3D;
807 anActor->SetControlMode(aControl);
808 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
809 SMESH::RepaintCurrentView();
816 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
817 MeshObjectType theType,
818 const QString theInTypeName,
819 QString & theOutTypeName)
821 SMESH_TypeFilter aTypeFilter( theType );
823 if( !theIO.IsNull() )
825 entry = theIO->getEntry();
826 LightApp_DataOwner owner( entry );
827 if ( aTypeFilter.isOk( &owner )) {
828 theOutTypeName = theInTypeName;
836 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
838 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
839 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
841 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
842 CORBA::String_var anID = aSComp->GetID().c_str();
843 if (!strcmp(anID.in(),theIO->getEntry()))
849 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
850 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
851 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
852 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
853 CheckOIType ( theIO, GROUP, "Group", aTypeName )
861 QString CheckHomogeneousSelection()
863 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
864 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
865 SALOME_ListIO selected;
867 aSel->selectedObjects( selected );
869 QString RefType = CheckTypeObject(selected.First());
870 SALOME_ListIteratorOfListIO It(selected);
871 for (; It.More(); It.Next())
873 Handle(SALOME_InteractiveObject) IObject = It.Value();
874 QString Type = CheckTypeObject(IObject);
875 if (Type.compare(RefType) != 0)
876 return "Heterogeneous Selection";
883 void SMESHGUI::OnEditDelete()
885 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
886 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
887 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
889 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
890 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
891 _PTR(GenericAttribute) anAttr;
892 _PTR(AttributeIOR) anIOR;
895 QString aParentComponent = QString::null;
896 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
898 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
900 // check if object is not reference
901 _PTR(SObject) refobj;
902 if ( !aSO->ReferencedObject( refobj ) )
906 QString cur = anIt.Value()->getComponentDataType();
907 if( aParentComponent.isNull() )
908 aParentComponent = cur;
909 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
910 aParentComponent = "";
913 if ( objectCount == 0 )
914 return; // No Valid Objects Selected
916 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
917 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
918 QObject::tr("ERR_ERROR"),
919 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
920 QObject::tr("BUT_OK") );
923 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
924 if (SUIT_MessageBox::warn2
925 (SMESHGUI::desktop(),
926 QObject::tr("SMESH_WRN_WARNING"),
927 QObject::tr("SMESH_REALLY_DELETE"),
928 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
931 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
932 SUIT_ViewManager* vm = anApp->activeViewManager();
933 int nbSf = vm->getViewsCount();
935 SALOME_ListIteratorOfListIO It(selected);
937 aStudyBuilder->NewCommand(); // There is a transaction
938 for(; It.More(); It.Next()){ // loop on selected IO's
939 Handle(SALOME_InteractiveObject) IObject = It.Value();
940 if(IObject->hasEntry()) {
941 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
943 // disable removal of "SMESH" component object
944 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
946 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
950 _PTR(SObject) refobj;
951 if ( aSO && aSO->ReferencedObject( refobj ) )
952 continue; // skip references
954 // put the whole hierarchy of sub-objects of the selected SO into a list and
955 // then treat them all starting from the deepest objects (at list back)
957 list< _PTR(SObject) > listSO;
958 listSO.push_back( aSO );
959 list< _PTR(SObject) >::iterator itSO = listSO.begin();
960 for ( ; itSO != listSO.end(); ++itSO ) {
961 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
962 for (it->InitEx(false); it->More(); it->Next())
963 listSO.push_back( it->Value() );
966 // treat SO's in the list starting from the back
968 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
969 for ( ; ritSO != listSO.rend(); ++ritSO ) {
970 _PTR(SObject) SO = *ritSO;
972 string anEntry = SO->GetID();
974 /** Erase graphical object **/
975 if(SO->FindAttribute(anAttr, "AttributeIOR")){
976 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
977 for(int i = 0; i < nbSf; i++){
978 SUIT_ViewWindow *sf = aViews[i];
979 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
980 SMESH::RemoveActor(sf,anActor);
985 /** Remove an object from data structures **/
986 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
987 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
988 if ( !aGroup->_is_nil() ) { // DELETE GROUP
989 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
990 aMesh->RemoveGroup( aGroup );
992 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
993 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
994 aMesh->RemoveSubMesh( aSubMesh );
996 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
998 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1001 IObject = new SALOME_InteractiveObject
1002 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
1003 QString objType = CheckTypeObject(IObject);
1004 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1005 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1006 aStudyBuilder->RemoveObjectWithChildren( SO );
1008 else {// default action: remove SObject from the study
1009 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1010 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1012 aStudyBuilder->RemoveObjectWithChildren( SO );
1016 } /* listSO back loop */
1017 } /* IObject->hasEntry() */
1019 aStudyBuilder->CommitCommand();
1021 /* Clear any previous selection */
1023 aSel->setSelectedObjects( l1 );
1025 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1030 SMESHGUI_EXPORT CAM_Module* createModule()
1032 return new SMESHGUI();
1036 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1038 //=============================================================================
1042 //=============================================================================
1043 SMESHGUI::SMESHGUI() :
1044 SalomeApp_Module( "SMESH" )
1046 if ( CORBA::is_nil( myComponentSMESH ) )
1048 CORBA::Boolean anIsEmbeddedMode;
1049 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1052 myActiveDialogBox = 0;
1053 myFilterLibraryDlg = 0;
1057 SMESH::GetFilterManager();
1058 SMESH::GetPattern();
1060 /* load resources for all available meshers */
1061 SMESH::InitAvailableHypotheses();
1064 //=============================================================================
1068 //=============================================================================
1069 SMESHGUI::~SMESHGUI()
1071 SMESH::GetFilterManager()->Destroy();
1072 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1075 //=============================================================================
1079 //=============================================================================
1080 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1082 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1084 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1089 bool SMESHGUI::automaticUpdate()
1091 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1095 return resMgr->booleanValue( "SMESH", "auto_update", false );
1098 //=============================================================================
1102 //=============================================================================
1103 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1105 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1108 //=============================================================================
1112 //=============================================================================
1113 SMESHGUI* SMESHGUI::GetSMESHGUI()
1115 SMESHGUI* smeshMod = 0;
1116 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1119 CAM_Module* module = app->module( "Mesh" );
1120 smeshMod = dynamic_cast<SMESHGUI*>( module );
1123 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1125 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1128 _PTR(Study) aStudy = study->studyDS();
1130 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1139 Standard_EXPORT SMESHGUI* GetComponentGUI()
1141 return SMESHGUI::GetSMESHGUI();
1145 //=============================================================================
1149 //=============================================================================
1150 void SMESHGUI::SetState(int aState)
1155 //=============================================================================
1159 //=============================================================================
1160 void SMESHGUI::ResetState()
1165 //=============================================================================
1169 //=============================================================================
1170 void SMESHGUI::EmitSignalDeactivateDialog()
1172 emit SignalDeactivateActiveDialog();
1175 //=============================================================================
1179 //=============================================================================
1180 void SMESHGUI::EmitSignalStudyFrameChanged()
1182 emit SignalStudyFrameChanged();
1185 //=============================================================================
1189 //=============================================================================
1190 void SMESHGUI::EmitSignalCloseAllDialogs()
1192 emit SignalCloseAllDialogs();
1195 //=============================================================================
1199 //=============================================================================
1200 QDialog *SMESHGUI::GetActiveDialogBox()
1202 return myActiveDialogBox;
1205 //=============================================================================
1209 //=============================================================================
1210 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1212 myActiveDialogBox = (QDialog *) aDlg;
1216 //=============================================================================
1220 //=============================================================================
1221 SUIT_Desktop* SMESHGUI::desktop()
1223 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1225 return app->desktop();
1230 //=============================================================================
1234 //=============================================================================
1235 SalomeApp_Study* SMESHGUI::activeStudy()
1237 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1239 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1244 //=============================================================================
1248 //=============================================================================
1249 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1251 /* Here the position is on the bottom right corner - 10 */
1252 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1254 SUIT_Desktop *PP = desktop();
1255 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1256 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1260 //=============================================================================
1264 //=============================================================================
1265 static int isStudyLocked(_PTR(Study) theStudy){
1266 return theStudy->GetProperties()->IsLocked();
1269 static bool checkLock(_PTR(Study) theStudy) {
1270 if (isStudyLocked(theStudy)) {
1271 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1272 QObject::tr("WRN_WARNING"),
1273 QObject::tr("WRN_STUDY_LOCKED"),
1274 QObject::tr("BUT_OK") );
1280 //=======================================================================
1281 //function : CheckActiveStudyLocked
1283 //=======================================================================
1285 bool SMESHGUI::isActiveStudyLocked()
1287 _PTR(Study) aStudy = activeStudy()->studyDS();
1288 return checkLock( aStudy );
1291 //=============================================================================
1295 //=============================================================================
1296 bool SMESHGUI::OnGUIEvent( int theCommandID )
1298 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1302 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1303 SUIT_ResourceMgr* mgr = resourceMgr();
1307 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1308 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1311 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1312 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1314 //QAction* act = action( theCommandID );
1316 switch (theCommandID) {
1318 if(checkLock(aStudy)) break;
1326 if(checkLock(aStudy)) break;
1327 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1331 case 150: //MED FILE INFORMATION
1333 SALOME_ListIO selected;
1334 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1336 aSel->selectedObjects( selected );
1337 if( selected.Extent() )
1339 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1340 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1341 if ( !aMesh->_is_nil() )
1343 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1349 case 122: // EXPORT MED
1358 ::ExportMeshToFile(theCommandID);
1362 case 200: // SCALAR BAR
1364 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1365 SALOME_ListIO selected;
1367 aSel->selectedObjects( selected );
1369 if( selected.Extent() ) {
1370 Handle(SALOME_InteractiveObject) anIO = selected.First();
1371 if( anIO->hasEntry() ) {
1372 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1373 anActor->SetControlMode( SMESH_Actor::eNone );
1381 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1391 ::DisableAutoColor();
1394 case 1134: // Clipping
1395 case 1133: // Tranparency
1396 case 1132: // Colors / Size
1403 ::SetDisplayMode(theCommandID);
1409 case 219: // Volumes
1410 case 220: // All Entity
1411 ::SetDisplayEntity(theCommandID);
1416 if(checkLock(aStudy)) break;
1418 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1421 SMESH::UpdateView();
1423 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1424 SMESH::OnVisuException();
1426 catch (...) { // PAL16774 (Crash after display of many groups)
1427 SMESH::OnVisuException();
1431 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1432 aSel->selectedObjects( l );
1433 aSel->setSelectedObjects( l );
1438 case 301: // DISPLAY
1439 case 302: // DISPLAY ONLY
1441 SMESH::EDisplaing anAction;
1442 switch (theCommandID) {
1443 case 300: anAction = SMESH::eErase; break;
1444 case 301: anAction = SMESH::eDisplay; break;
1445 case 302: anAction = SMESH::eDisplayOnly; break;
1448 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1449 SALOME_ListIO sel_objects, to_process;
1451 aSel->selectedObjects( sel_objects );
1453 if( theCommandID==302 )
1454 startOperation( myEraseAll );
1456 extractContainers( sel_objects, to_process );
1459 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1463 SALOME_ListIteratorOfListIO It( to_process );
1464 for (; It.More(); It.Next()) {
1465 Handle(SALOME_InteractiveObject) IOS = It.Value();
1466 if (IOS->hasEntry()) {
1467 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1468 break; // PAL16774 (Crash after display of many groups)
1469 if (anAction == SMESH::eDisplayOnly)
1470 anAction = SMESH::eDisplay;
1475 // PAL13338 + PAL15161 -->
1476 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1477 SMESH::UpdateView();
1478 // PAL13338 + PAL15161 <--
1480 catch (...) { // PAL16774 (Crash after display of many groups)
1481 SMESH::OnVisuException();
1484 if (anAction == SMESH::eErase) {
1486 aSel->setSelectedObjects( l1 );
1489 aSel->setSelectedObjects( to_process );
1496 if(checkLock(aStudy)) break;
1499 EmitSignalDeactivateDialog();
1501 new SMESHGUI_NodesDlg(this);
1504 SUIT_MessageBox::warn1(desktop(),
1505 tr("SMESH_WRN_WARNING"),
1506 tr("SMESH_WRN_VIEWER_VTK"),
1507 tr("SMESH_BUT_OK"));
1512 case 2151: // FILTER
1516 EmitSignalDeactivateDialog();
1517 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1522 case 406: // MOVE NODE
1526 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1527 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1531 if(checkLock(aStudy)) break;
1532 new SMESHGUI_MoveNodesDlg(this);
1536 case 701: // COMPUTE MESH
1538 if (checkLock(aStudy)) break;
1540 startOperation( 701 );
1544 case 702: // Create mesh
1545 startOperation( 702 );
1547 case 703: // Create sub-mesh
1548 startOperation( 703 );
1550 case 704: // Edit mesh/sub-mesh
1551 startOperation( 704 );
1553 case 710: // Build compound mesh
1555 if (checkLock(aStudy)) break;
1556 EmitSignalDeactivateDialog();
1557 new SMESHGUI_BuildCompoundDlg( this );
1561 case 407: // DIAGONAL INVERSION
1562 case 408: // Delete diagonal
1566 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1567 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1571 if ( checkLock( aStudy ) )
1574 /*Standard_Boolean aRes;
1575 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1576 if ( aMesh->_is_nil() )
1578 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1579 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1583 EmitSignalDeactivateDialog();
1584 if ( theCommandID == 407 )
1585 new SMESHGUI_TrianglesInversionDlg(this);
1587 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1590 case 409: // Change orientation
1591 case 410: // Union of triangles
1592 case 411: // Cutting of quadrangles
1596 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1597 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1601 if ( checkLock( aStudy ) )
1604 EmitSignalDeactivateDialog();
1605 SMESHGUI_MultiEditDlg* aDlg = NULL;
1606 if ( theCommandID == 409 )
1607 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1608 else if ( theCommandID == 410 )
1609 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1611 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1616 case 412: // Smoothing
1618 if(checkLock(aStudy)) break;
1620 EmitSignalDeactivateDialog();
1621 new SMESHGUI_SmoothingDlg( this );
1624 SUIT_MessageBox::warn1(desktop(),
1625 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1626 tr("SMESH_BUT_OK"));
1630 case 413: // Extrusion
1632 if (checkLock(aStudy)) break;
1634 EmitSignalDeactivateDialog();
1635 new SMESHGUI_ExtrusionDlg ( this );
1637 SUIT_MessageBox::warn1(desktop(),
1638 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1639 tr("SMESH_BUT_OK"));
1643 case 414: // Revolution
1645 if(checkLock(aStudy)) break;
1647 EmitSignalDeactivateDialog();
1648 new SMESHGUI_RevolutionDlg( this );
1651 SUIT_MessageBox::warn1(desktop(),
1652 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1653 tr("SMESH_BUT_OK"));
1657 case 415: // Pattern mapping
1659 if ( checkLock( aStudy ) )
1663 EmitSignalDeactivateDialog();
1664 new SMESHGUI_MeshPatternDlg( this );
1667 SUIT_MessageBox::warn1(desktop(),
1668 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1669 tr("SMESH_BUT_OK"));
1673 case 416: // Extrusion along a path
1675 if (checkLock(aStudy)) break;
1677 EmitSignalDeactivateDialog();
1678 new SMESHGUI_ExtrusionAlongPathDlg( this );
1680 SUIT_MessageBox::warn1(desktop(),
1681 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1682 tr("SMESH_BUT_OK"));
1686 case 417: // Convert mesh to quadratic
1688 startOperation( 417 );
1689 /* if (checkLock(aStudy)) break;
1691 EmitSignalDeactivateDialog();
1692 new SMESHGUI_ConvToQuadDlg();
1694 SUIT_MessageBox::warn1(desktop(),
1695 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1696 tr("SMESH_BUT_OK"));
1700 case 801: // CREATE GROUP
1704 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1705 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1709 if(checkLock(aStudy)) break;
1710 EmitSignalDeactivateDialog();
1711 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1713 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1714 SALOME_ListIO selected;
1716 aSel->selectedObjects( selected );
1718 int nbSel = selected.Extent();
1720 // check if mesh is selected
1721 aMesh = SMESH::GetMeshByIO( selected.First() );
1723 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1728 case 802: // CONSTRUCT GROUP
1732 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1733 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1737 if(checkLock(aStudy)) break;
1738 EmitSignalDeactivateDialog();
1740 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1741 SALOME_ListIO selected;
1743 aSel->selectedObjects( selected );
1745 int nbSel = selected.Extent();
1747 // check if submesh is selected
1748 Handle(SALOME_InteractiveObject) IObject = selected.First();
1749 if (IObject->hasEntry()) {
1750 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1752 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1753 if (!aSubMesh->_is_nil()) {
1755 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1756 // get submesh elements list by types
1757 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1758 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1759 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1760 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1761 // create group for each type o elements
1762 QString aName = IObject->getName();
1763 if (aNodes->length() > 0) {
1764 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1765 aGroup->Add(aNodes.inout());
1767 if (aEdges->length() > 0) {
1768 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1769 aGroup->Add(aEdges.inout());
1771 if (aFaces->length() > 0) {
1772 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1773 aGroup->Add(aFaces.inout());
1775 if (aVolumes->length() > 0) {
1776 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1777 aGroup->Add(aVolumes.inout());
1782 catch(const SALOME::SALOME_Exception & S_ex){
1783 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1790 SUIT_MessageBox::warn1(desktop(),
1791 tr("SMESH_WRN_WARNING"),
1792 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1793 tr("SMESH_BUT_OK"));
1798 case 803: // EDIT GROUP
1802 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1803 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1807 if(checkLock(aStudy)) break;
1808 EmitSignalDeactivateDialog();
1810 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1811 SALOME_ListIO selected;
1813 aSel->selectedObjects( selected );
1815 SALOME_ListIteratorOfListIO It (selected);
1816 int nbSelectedGroups = 0;
1817 for ( ; It.More(); It.Next() )
1819 SMESH::SMESH_GroupBase_var aGroup =
1820 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1821 if (!aGroup->_is_nil()) {
1823 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1827 if (nbSelectedGroups == 0)
1829 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1835 case 804: // Add elements to group
1837 if(checkLock(aStudy)) break;
1838 if (myState == 800) {
1839 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1840 if (aDlg) aDlg->onAdd();
1845 case 805: // Remove elements from group
1847 if(checkLock(aStudy)) break;
1848 if (myState == 800) {
1849 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1850 if (aDlg) aDlg->onRemove();
1855 case 810: // Union Groups
1856 case 811: // Intersect groups
1857 case 812: // Cut groups
1861 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1862 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1866 if ( checkLock( aStudy ) )
1869 EmitSignalDeactivateDialog();
1872 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1873 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1874 else aMode = SMESHGUI_GroupOpDlg::CUT;
1876 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1880 case 813: // Delete groups with their contents
1884 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1885 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1889 if ( checkLock( aStudy ) )
1892 EmitSignalDeactivateDialog();
1894 new SMESHGUI_DeleteGroupDlg( this );
1898 case 900: // MESH INFOS
1900 EmitSignalDeactivateDialog();
1901 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1902 SALOME_ListIO selected;
1904 aSel->selectedObjects( selected );
1906 if ( selected.Extent() > 1 ) { // a dlg for each IO
1908 SALOME_ListIteratorOfListIO It (selected);
1909 for ( ; It.More(); It.Next() ) {
1910 IOs.Clear(); IOs.Append( It.Value() );
1911 aSel->setSelectedObjects( IOs );
1912 new SMESHGUI_MeshInfosDlg(this, "", false);
1914 // restore selection
1915 aSel->setSelectedObjects( selected );
1918 new SMESHGUI_MeshInfosDlg(this, "", false);
1922 case 902: // STANDARD MESH INFOS
1924 EmitSignalDeactivateDialog();
1925 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1926 SALOME_ListIO selected;
1928 aSel->selectedObjects( selected );
1930 if ( selected.Extent() > 1 ) { // a dlg for each IO
1932 SALOME_ListIteratorOfListIO It (selected);
1933 for ( ; It.More(); It.Next() ) {
1935 IOs.Append( It.Value() );
1936 aSel->setSelectedObjects( IOs );
1937 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1939 // restore selection
1940 aSel->setSelectedObjects( selected );
1943 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1947 case 903: // WHAT IS
1949 EmitSignalDeactivateDialog();
1950 new SMESHGUI_WhatIsDlg( this, "", false);
1954 case 1100: // EDIT HYPOTHESIS
1956 if(checkLock(aStudy)) break;
1958 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1959 SALOME_ListIO selected;
1961 aSel->selectedObjects( selected );
1963 int nbSel = selected.Extent();
1966 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1967 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1969 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1970 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1971 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1972 if ( !aHypothesis->_is_nil() )
1974 CORBA::String_var aHypType = aHypothesis->GetName();
1975 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1977 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1984 updateObjBrowser( true );
1988 case 1101: // RENAME
1990 if ( checkLock( aStudy ) )
1993 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1994 SALOME_ListIO selected;
1996 aSel->selectedObjects( selected );
1998 bool isAny = false; // iss there any appropriate object selected
2000 SALOME_ListIteratorOfListIO It( selected );
2001 for ( ; It.More(); It.Next() )
2003 Handle(SALOME_InteractiveObject) IObject = It.Value();
2004 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2005 _PTR(GenericAttribute) anAttr;
2006 _PTR(AttributeName) aName;
2009 if ( obj->FindAttribute(anAttr, "AttributeName") )
2012 QString newName = QString(aName->Value().c_str());
2014 // check type to prevent renaming of inappropriate objects
2015 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2016 if (aType == MESH || aType == GROUP ||
2017 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2018 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2019 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2020 aType == HYPOTHESIS || aType == ALGORITHM)
2023 newName = LightApp_NameDlg::getName(desktop(), newName);
2024 if ( !newName.isEmpty() )
2026 //old source: aStudy->renameIObject( IObject, newName );
2027 aName->SetValue( newName.latin1() );
2029 // if current object is group update group's name
2030 SMESH::SMESH_GroupBase_var aGroup =
2031 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2032 if (!aGroup->_is_nil() )
2033 aGroup->SetName( newName.latin1() );
2043 SUIT_MessageBox::warn1(desktop(),
2044 QObject::tr("SMESH_WRN_WARNING"),
2045 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2046 QObject::tr("SMESH_BUT_OK"));
2051 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2053 if(checkLock(aStudy)) break;
2054 SUIT_OverrideCursor wc;
2056 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2057 SALOME_ListIO selected;
2059 aSel->selectedObjects( selected, QString::null, false );
2061 SALOME_ListIteratorOfListIO It(selected);
2062 for (int i = 0; It.More(); It.Next(), i++) {
2063 Handle(SALOME_InteractiveObject) IObject = It.Value();
2064 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2067 aSel->setSelectedObjects( l1 );
2072 case 401: // GEOM::EDGE
2073 case 4021: // TRIANGLE
2075 case 4023: // POLYGON
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 SMDSAbs_ElementType type = SMDSAbs_Edge;
2084 switch (theCommandID) {
2085 case 4021: // TRIANGLE
2086 type = SMDSAbs_Face; nbNodes = 3; break;
2088 type = SMDSAbs_Face; nbNodes = 4; break;
2090 type = SMDSAbs_Volume; nbNodes = 4; break;
2091 case 4023: // POLYGON
2092 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2094 type = SMDSAbs_Volume; nbNodes = 8; break;
2095 case 4033: // POLYHEDRE
2096 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2099 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2102 SUIT_MessageBox::warn1(desktop(),
2103 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2104 tr("SMESH_BUT_OK"));
2108 case 4033: // POLYHEDRON
2110 if(checkLock(aStudy)) break;
2112 EmitSignalDeactivateDialog();
2113 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2116 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2117 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2118 tr("SMESH_BUT_OK"));
2122 case 4034: // QUADRATIC EDGE
2123 case 4035: // QUADRATIC TRIANGLE
2124 case 4036: // QUADRATIC QUADRANGLE
2125 case 4037: // QUADRATIC TETRAHEDRON
2126 case 4038: // QUADRATIC PYRAMID
2127 case 4039: // QUADRATIC PENTAHEDRON
2128 case 4040: // QUADRATIC HEXAHEDRON
2130 if(checkLock(aStudy)) break;
2132 EmitSignalDeactivateDialog();
2135 switch (theCommandID) {
2137 type = QUAD_EDGE; break;
2139 type = QUAD_TRIANGLE; break;
2141 type = QUAD_QUADRANGLE; break;
2143 type = QUAD_TETRAHEDRON; break;
2145 type = QUAD_PYRAMID; break;
2147 type = QUAD_PENTAHEDRON; break;
2149 type = QUAD_HEXAHEDRON;
2153 new SMESHGUI_AddQuadraticElementDlg( this, type );
2156 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2157 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2158 tr("SMESH_BUT_OK"));
2162 case 4041: // REMOVES NODES
2164 if(checkLock(aStudy)) break;
2166 EmitSignalDeactivateDialog();
2167 new SMESHGUI_RemoveNodesDlg(this);
2170 SUIT_MessageBox::warn1(desktop(),
2171 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2172 tr("SMESH_BUT_OK"));
2176 case 4042: // REMOVES ELEMENTS
2178 if(checkLock(aStudy)) break;
2180 EmitSignalDeactivateDialog();
2181 new SMESHGUI_RemoveElementsDlg(this);
2185 SUIT_MessageBox::warn1(desktop(),
2186 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2187 tr("SMESH_BUT_OK"));
2191 case 4043: { // CLEAR_MESH
2193 if(checkLock(aStudy)) break;
2195 SALOME_ListIO selected;
2196 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2197 aSel->selectedObjects( selected );
2199 SUIT_OverrideCursor wc;
2200 SALOME_ListIteratorOfListIO It (selected);
2201 for ( ; It.More(); It.Next() )
2203 Handle(SALOME_InteractiveObject) IOS = It.Value();
2204 SMESH::SMESH_Mesh_var aMesh =
2205 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2206 if ( aMesh->_is_nil()) continue;
2208 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2210 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2211 SMESH::ModifiedMesh( aMeshSObj, false, true);
2212 // hide groups and submeshes
2213 _PTR(ChildIterator) anIter =
2214 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2215 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2217 _PTR(SObject) so = anIter->Value();
2218 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2221 catch (const SALOME::SALOME_Exception& S_ex){
2223 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2227 SMESH::UpdateView();
2231 case 4051: // RENUMBERING NODES
2233 if(checkLock(aStudy)) break;
2235 EmitSignalDeactivateDialog();
2236 new SMESHGUI_RenumberingDlg( this, "", 0);
2240 SUIT_MessageBox::warn1(desktop(),
2241 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2242 tr("SMESH_BUT_OK"));
2246 case 4052: // RENUMBERING ELEMENTS
2248 if(checkLock(aStudy)) break;
2250 EmitSignalDeactivateDialog();
2251 new SMESHGUI_RenumberingDlg( this, "", 1);
2255 SUIT_MessageBox::warn1(desktop(),
2256 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2257 tr("SMESH_BUT_OK"));
2261 case 4061: // TRANSLATION
2263 if(checkLock(aStudy)) break;
2265 EmitSignalDeactivateDialog();
2266 new SMESHGUI_TranslationDlg( this );
2269 SUIT_MessageBox::warn1(desktop(),
2270 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2271 tr("SMESH_BUT_OK"));
2275 case 4062: // ROTATION
2277 if(checkLock(aStudy)) break;
2279 EmitSignalDeactivateDialog();
2280 new SMESHGUI_RotationDlg( this );
2283 SUIT_MessageBox::warn1(desktop(),
2284 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2285 tr("SMESH_BUT_OK"));
2289 case 4063: // SYMMETRY
2291 if(checkLock(aStudy)) break;
2293 EmitSignalDeactivateDialog();
2294 new SMESHGUI_SymmetryDlg( this );
2297 SUIT_MessageBox::warn1(desktop(),
2298 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2299 tr("SMESH_BUT_OK"));
2303 case 4064: // SEWING
2305 if(checkLock(aStudy)) break;
2307 EmitSignalDeactivateDialog();
2308 new SMESHGUI_SewingDlg( this );
2311 SUIT_MessageBox::warn1(desktop(),
2312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2313 tr("SMESH_BUT_OK"));
2317 case 4065: // MERGE NODES
2319 if(checkLock(aStudy)) break;
2321 EmitSignalDeactivateDialog();
2322 new SMESHGUI_EditMeshDlg( this, 0 );
2325 SUIT_MessageBox::warn1(desktop(),
2326 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2327 tr("SMESH_BUT_OK"));
2331 case 4066: // MERGE EQUAL ELEMENTS
2333 if (checkLock(aStudy)) break;
2335 EmitSignalDeactivateDialog();
2336 new SMESHGUI_EditMeshDlg( this, 1 );
2338 SUIT_MessageBox::warn1(desktop(),
2339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2340 tr("SMESH_BUT_OK"));
2345 case 4067: // MAKE MESH PASS THROUGH POINT
2346 startOperation( 4067 );
2349 case 5105: // Library of selection filters
2351 static QValueList<int> aTypes;
2352 if ( aTypes.isEmpty() )
2354 aTypes.append( SMESH::NODE );
2355 aTypes.append( SMESH::EDGE );
2356 aTypes.append( SMESH::FACE );
2357 aTypes.append( SMESH::VOLUME );
2359 if (!myFilterLibraryDlg)
2360 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2361 else if (myFilterLibraryDlg->isHidden())
2362 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2363 myFilterLibraryDlg->raise();
2367 case 6017: // CONTROLS
2383 LightApp_SelectionMgr* mgr = selectionMgr();
2384 SALOME_ListIO selected; mgr->selectedObjects( selected );
2386 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2387 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2389 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2390 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2391 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2392 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2393 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2394 ::Control( theCommandID );
2399 SUIT_MessageBox::warn1(desktop(),
2400 tr( "SMESH_WRN_WARNING" ),
2401 tr( "SMESH_BAD_SELECTION" ),
2402 tr( "SMESH_BUT_OK" ) );
2406 SUIT_MessageBox::warn1(desktop(),
2407 tr( "SMESH_WRN_WARNING" ),
2408 tr( "NOT_A_VTK_VIEWER" ),
2409 tr( "SMESH_BUT_OK" ) );
2414 LightApp_SelectionMgr* mgr = selectionMgr();
2415 SALOME_ListIO selected; mgr->selectedObjects( selected );
2417 SALOME_ListIteratorOfListIO it(selected);
2418 for(; it.More(); it.Next()) {
2419 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2420 if(anIObject->hasEntry()) {
2421 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2422 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2430 LightApp_SelectionMgr* mgr = selectionMgr();
2431 SALOME_ListIO selected; mgr->selectedObjects( selected );
2433 if (selected.Extent() == 1) {
2434 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2435 if(anIObject->hasEntry())
2436 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2437 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2444 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2445 //updateObjBrowser();
2449 //=============================================================================
2453 //=============================================================================
2454 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2459 //=============================================================================
2463 //=============================================================================
2464 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2469 //=============================================================================
2473 //=============================================================================
2474 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2479 //=============================================================================
2480 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2481 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2483 //=============================================================================
2484 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2485 SUIT_ViewWindow* wnd )
2487 if(theIO->hasEntry()){
2488 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2489 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2493 //=======================================================================
2494 // function : createSMESHAction
2496 //=======================================================================
2497 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2500 QWidget* parent = application()->desktop();
2501 SUIT_ResourceMgr* resMgr = resourceMgr();
2503 if ( icon_id.length() )
2504 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2506 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2507 if ( !pix.isNull() )
2508 icon = QIconSet( pix );
2510 QString tooltip = tr( QString( "TOP_" )+po_id ),
2511 menu = tr( QString( "MEN_" )+po_id ),
2512 status_bar = tr( QString( "STB_" )+po_id );
2514 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2517 //=======================================================================
2518 // function : createPopupItem
2520 //=======================================================================
2521 void SMESHGUI::createPopupItem( const int id,
2522 const QString& clients,
2523 const QString& types,
2524 const QString& theRule,
2529 parentId = popupMgr()->actionId( action( pId ) );
2531 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2532 popupMgr()->insert( action( id ), parentId, 0 );
2534 QChar lc = QtxPopupMgr::Selection::defEquality();
2535 QString rule = "(%1) and (%2) and (%3)";
2536 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2537 if( clients.isEmpty() )
2538 rule = rule.arg( QString( "true" ) );
2540 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2541 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2544 bool cont = myRules.contains( id );
2546 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2548 popupMgr()->setRule( action( id ), rule, true );
2549 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2552 //=======================================================================
2553 // function : initialize
2555 //=======================================================================
2556 void SMESHGUI::initialize( CAM_Application* app )
2558 SalomeApp_Module::initialize( app );
2560 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2562 /* Automatic Update flag */
2563 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2565 // ----- create actions --------------
2567 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2568 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2569 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2570 createSMESHAction( 114, "NUM" );
2571 createSMESHAction( 121, "DAT" );
2572 createSMESHAction( 122, "MED" );
2573 createSMESHAction( 123, "UNV" );
2574 createSMESHAction( 140, "STL" );
2575 createSMESHAction( 124, "EXPORT_DAT" );
2576 createSMESHAction( 125, "EXPORT_MED" );
2577 createSMESHAction( 126, "EXPORT_UNV" );
2578 createSMESHAction( 141, "EXPORT_STL" );
2579 createSMESHAction( 150, "FILE_INFO" );
2580 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2581 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2582 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2583 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2584 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2585 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2586 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2587 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2588 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2589 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2590 createSMESHAction( 804, "ADD" );
2591 createSMESHAction( 805, "REMOVE" );
2592 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2593 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2594 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2595 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2596 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2597 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2598 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2599 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2600 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2601 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2602 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2603 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2604 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2605 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2606 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2607 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2608 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2609 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2610 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2611 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2612 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2613 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2614 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2615 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2616 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2617 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2618 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2619 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2620 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2621 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2622 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2623 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2624 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2625 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2626 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2627 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2628 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2629 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2630 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2631 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2632 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2633 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2634 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2635 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2636 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2637 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2638 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2639 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2640 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2641 createSMESHAction( 415, "MAP", "ICON_MAP" );
2642 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2643 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2644 createSMESHAction( 200, "RESET" );
2645 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2646 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2647 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2648 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2649 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2650 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2651 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2652 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2653 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2654 createSMESHAction( 220, "ALL" );
2655 createSMESHAction( 1100, "EDIT_HYPO" );
2656 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2657 createSMESHAction( 1102, "UNASSIGN" );
2658 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2659 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2660 createSMESHAction( 1131, "DISPMODE" );
2661 createSMESHAction( 1132, "COLORS" );
2662 createSMESHAction( 1133, "TRANSP" );
2663 createSMESHAction( 1134, "CLIP" );
2664 createSMESHAction( 1135, "DISP_ENT" );
2665 createSMESHAction( 1136, "AUTO_COLOR" );
2666 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2667 createSMESHAction( 2000, "CTRL" );
2669 createSMESHAction( 300, "ERASE" );
2670 createSMESHAction( 301, "DISPLAY" );
2671 createSMESHAction( 302, "DISPLAY_ONLY" );
2672 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2673 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2674 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2675 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2676 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2677 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2678 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2679 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2681 // ----- create menu --------------
2682 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2683 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2684 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2685 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2686 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2687 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2688 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2690 createMenu( separator(), fileId );
2692 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2693 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2694 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2695 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2696 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2697 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2699 createMenu( 111, importId, -1 );
2700 createMenu( 112, importId, -1 );
2701 createMenu( 113, importId, -1 );
2703 createMenu( 121, exportId, -1 );
2704 createMenu( 122, exportId, -1 );
2705 createMenu( 123, exportId, -1 );
2706 createMenu( 140, exportId, -1 ); // export to stl STL
2708 createMenu( separator(), fileId, 10 );
2710 createMenu( 33, editId, -1 );
2712 createMenu( 5105, toolsId, -1 );
2714 createMenu( 702, meshId, -1 ); // "Mesh" menu
2715 createMenu( 703, meshId, -1 );
2716 createMenu( 704, meshId, -1 );
2717 createMenu( 710, meshId, -1 );
2718 createMenu( separator(), meshId, -1 );
2719 createMenu( 701, meshId, -1 );
2720 createMenu( separator(), meshId, -1 );
2721 createMenu( 801, meshId, -1 );
2722 createMenu( 802, meshId, -1 );
2723 createMenu( 803, meshId, -1 );
2724 createMenu( separator(), meshId, -1 );
2725 createMenu( 810, meshId, -1 );
2726 createMenu( 811, meshId, -1 );
2727 createMenu( 812, meshId, -1 );
2728 createMenu( separator(), meshId, -1 );
2729 createMenu( 813, meshId, -1 );
2730 createMenu( separator(), meshId, -1 );
2731 createMenu( 900, meshId, -1 );
2732 createMenu( 902, meshId, -1 );
2733 createMenu( 903, meshId, -1 );
2734 createMenu( separator(), meshId, -1 );
2736 createMenu( 6003, ctrlId, -1 );
2737 createMenu( 6001, ctrlId, -1 );
2738 createMenu( 6004, ctrlId, -1 );
2739 createMenu( separator(), ctrlId, -1 );
2740 createMenu( 6002, ctrlId, -1 );
2741 createMenu( 6018, ctrlId, -1 );
2742 createMenu( 6019, ctrlId, -1 );
2743 createMenu( 6011, ctrlId, -1 );
2744 createMenu( 6012, ctrlId, -1 );
2745 createMenu( 6013, ctrlId, -1 );
2746 createMenu( 6014, ctrlId, -1 );
2747 createMenu( 6015, ctrlId, -1 );
2748 createMenu( 6016, ctrlId, -1 );
2749 createMenu( separator(), ctrlId, -1 );
2750 createMenu( 6017, ctrlId, -1 );
2751 createMenu( 6009, ctrlId, -1 );
2752 createMenu( separator(), ctrlId, -1 );
2754 createMenu( 400, addId, -1 );
2755 createMenu( 401, addId, -1 );
2756 createMenu( 4021, addId, -1 );
2757 createMenu( 4022, addId, -1 );
2758 createMenu( 4023, addId, -1 );
2759 createMenu( 4031, addId, -1 );
2760 createMenu( 4032, addId, -1 );
2761 createMenu( 4033, addId, -1 );
2762 createMenu( separator(), addId, -1 );
2763 createMenu( 4034, addId, -1 );
2764 createMenu( 4035, addId, -1 );
2765 createMenu( 4036, addId, -1 );
2766 createMenu( 4037, addId, -1 );
2767 createMenu( 4038, addId, -1 );
2768 createMenu( 4039, addId, -1 );
2769 createMenu( 4040, addId, -1 );
2771 createMenu( 4041, removeId, -1 );
2772 createMenu( 4042, removeId, -1 );
2773 createMenu( 4043, removeId, -1 );
2775 createMenu( 4051, renumId, -1 );
2776 createMenu( 4052, renumId, -1 );
2778 createMenu( 4061, transfId, -1 );
2779 createMenu( 4062, transfId, -1 );
2780 createMenu( 4063, transfId, -1 );
2781 createMenu( 4064, transfId, -1 );
2782 createMenu( 4065, transfId, -1 );
2783 createMenu( 4066, transfId, -1 );
2785 createMenu( 406, modifyId, -1 );
2786 createMenu( 4067,modifyId, -1 );
2787 createMenu( 407, modifyId, -1 );
2788 createMenu( 408, modifyId, -1 );
2789 createMenu( 409, modifyId, -1 );
2790 createMenu( 410, modifyId, -1 );
2791 createMenu( 411, modifyId, -1 );
2792 createMenu( 412, modifyId, -1 );
2793 createMenu( 413, modifyId, -1 );
2794 createMenu( 416, modifyId, -1 );
2795 createMenu( 414, modifyId, -1 );
2796 createMenu( 415, modifyId, -1 );
2797 createMenu( 417, modifyId, -1 );
2799 createMenu( 214, viewId, -1 );
2801 // ----- create toolbars --------------
2802 int meshTb = createTool( tr( "TB_MESH" ) ),
2803 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2804 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2805 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2806 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2808 createTool( 702, meshTb );
2809 createTool( 703, meshTb );
2810 createTool( 704, meshTb );
2811 createTool( 710, meshTb );
2812 createTool( separator(), meshTb );
2813 createTool( 701, meshTb );
2814 createTool( separator(), meshTb );
2815 createTool( 801, meshTb );
2816 createTool( 802, meshTb );
2817 createTool( 803, meshTb );
2818 createTool( separator(), meshTb );
2819 createTool( 900, meshTb );
2820 createTool( 902, meshTb );
2821 createTool( 903, meshTb );
2822 createTool( separator(), meshTb );
2824 createTool( 6001, ctrlTb );
2825 createTool( 6003, ctrlTb );
2826 createTool( 6004, ctrlTb );
2827 createTool( separator(), ctrlTb );
2828 createTool( 6002, ctrlTb );
2829 createTool( 6018, ctrlTb );
2830 createTool( 6019, ctrlTb );
2831 createTool( 6011, ctrlTb );
2832 createTool( 6012, ctrlTb );
2833 createTool( 6013, ctrlTb );
2834 createTool( 6014, ctrlTb );
2835 createTool( 6015, ctrlTb );
2836 createTool( 6016, ctrlTb );
2837 createTool( separator(), ctrlTb );
2838 createTool( 6017, ctrlTb );
2839 createTool( 6009, ctrlTb );
2840 createTool( separator(), ctrlTb );
2842 createTool( 400, addRemTb );
2843 createTool( 401, addRemTb );
2844 createTool( 4021, addRemTb );
2845 createTool( 4022, addRemTb );
2846 createTool( 4023, addRemTb );
2847 createTool( 4031, addRemTb );
2848 createTool( 4032, addRemTb );
2849 createTool( 4033, addRemTb );
2850 createTool( separator(), addRemTb );
2851 createTool( 4034, addRemTb );
2852 createTool( 4035, addRemTb );
2853 createTool( 4036, addRemTb );
2854 createTool( 4037, addRemTb );
2855 createTool( 4038, addRemTb );
2856 createTool( 4039, addRemTb );
2857 createTool( 4040, addRemTb );
2858 createTool( separator(), addRemTb );
2859 createTool( 4041, addRemTb );
2860 createTool( 4042, addRemTb );
2861 createTool( 4043, addRemTb );
2862 createTool( separator(), addRemTb );
2863 createTool( 4051, addRemTb );
2864 createTool( 4052, addRemTb );
2865 createTool( separator(), addRemTb );
2866 createTool( 4061, addRemTb );
2867 createTool( 4062, addRemTb );
2868 createTool( 4063, addRemTb );
2869 createTool( 4064, addRemTb );
2870 createTool( 4065, addRemTb );
2871 createTool( 4066, addRemTb );
2872 createTool( separator(), addRemTb );
2874 createTool( 406, modifyTb );
2875 createTool( 4067,modifyTb );
2876 createTool( 407, modifyTb );
2877 createTool( 408, modifyTb );
2878 createTool( 409, modifyTb );
2879 createTool( 410, modifyTb );
2880 createTool( 411, modifyTb );
2881 createTool( 412, modifyTb );
2882 createTool( 413, modifyTb );
2883 createTool( 416, modifyTb );
2884 createTool( 414, modifyTb );
2885 createTool( 415, modifyTb );
2886 createTool( 417, modifyTb );
2888 createTool( 214, dispModeTb );
2892 QString OB = "'ObjectBrowser'",
2893 View = "'" + SVTK_Viewer::Type() + "'",
2895 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2896 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2897 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2898 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2899 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2900 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2901 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2902 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2903 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2904 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2905 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2907 mesh_group = mesh + " " + subMesh + " " + group,
2908 hyp_alg = hypo + " " + algo;
2910 // popup for object browser
2912 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2914 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2915 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2916 createPopupItem( 803, OB, group ); // EDIT_GROUP
2917 popupMgr()->insert( separator(), -1, 0 );
2918 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2919 createPopupItem( 214, OB, mesh_group ); // UPDATE
2920 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2921 createPopupItem( 902, OB, mesh ); // STD_INFO
2922 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2923 popupMgr()->insert( separator(), -1, 0 );
2924 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2925 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2926 popupMgr()->insert( separator(), -1, 0 );
2927 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2928 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2929 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2930 popupMgr()->insert( separator(), -1, 0 );
2931 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2932 popupMgr()->insert( separator(), -1, 0 );
2934 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2935 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2937 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2938 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2939 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2940 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2941 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2942 popupMgr()->insert( separator(), -1, 0 );
2945 createPopupItem( 803, View, group ); // EDIT_GROUP
2946 createPopupItem( 804, View, elems ); // ADD
2947 createPopupItem( 805, View, elems ); // REMOVE
2948 popupMgr()->insert( separator(), -1, 0 );
2949 createPopupItem( 214, View, mesh_group ); // UPDATE
2950 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2951 createPopupItem( 902, View, mesh ); // STD_INFO
2952 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2953 popupMgr()->insert( separator(), -1, 0 );
2955 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2956 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2957 popupMgr()->insert( separator(), -1, 0 );
2961 isInvisible("not( isVisible )"),
2962 isEmpty("numberOfNodes = 0"),
2963 isNotEmpty("numberOfNodes <> 0"),
2965 // has nodes, edges, etc in VISIBLE! actor
2966 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2967 hasElems("(count( elemTypes ) > 0)"),
2968 hasDifferentElems("(count( elemTypes ) > 1)"),
2969 hasEdges("({'Edge'} in elemTypes)"),
2970 hasFaces("({'Face'} in elemTypes)"),
2971 hasVolumes("({'Volume'} in elemTypes)");
2973 QString lc = QtxPopupMgr::Selection::defEquality();
2974 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2975 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2976 aType = aType.arg( mesh_group );
2977 QString aMeshInVTK = aClient + "&&" + aType;
2979 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2980 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2981 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2983 //-------------------------------------------------
2985 //-------------------------------------------------
2986 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2988 popupMgr()->insert( action( 9010 ), anId, -1 );
2989 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2990 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2992 popupMgr()->insert( action( 9011 ), anId, -1 );
2993 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2994 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2996 popupMgr()->insert( separator(), -1, -1 );
2998 //-------------------------------------------------
3000 //-------------------------------------------------
3001 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3003 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3004 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
3005 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
3007 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3008 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
3009 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
3011 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3012 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
3013 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
3015 popupMgr()->insert( separator(), anId, -1 );
3017 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3018 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
3019 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
3021 //-------------------------------------------------
3023 //-------------------------------------------------
3024 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3026 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3028 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3029 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3030 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3032 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3033 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3034 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3036 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3037 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3038 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3040 popupMgr()->insert( separator(), anId, -1 );
3042 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3043 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3045 //-------------------------------------------------
3047 //-------------------------------------------------
3048 popupMgr()->insert( action( 1132 ), -1, -1 );
3049 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3051 //-------------------------------------------------
3053 //-------------------------------------------------
3054 popupMgr()->insert( action( 1133 ), -1, -1 );
3055 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3057 //-------------------------------------------------
3059 //-------------------------------------------------
3060 popupMgr()->insert( action( 1134 ), -1, -1 );
3061 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3063 popupMgr()->insert( separator(), -1, -1 );
3065 //-------------------------------------------------
3067 //-------------------------------------------------
3069 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3070 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3071 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3073 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3075 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3076 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3078 popupMgr()->insert( separator(), anId, -1 );
3080 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3081 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3082 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3084 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3085 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3086 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3088 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3089 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3090 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3092 popupMgr()->insert( separator(), anId, -1 );
3094 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3095 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3096 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3098 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3099 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3100 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3102 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3103 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3104 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3106 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3107 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3108 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3110 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3111 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3112 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3114 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3115 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3116 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3118 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3119 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3120 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3122 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3123 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3124 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3126 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3127 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3128 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3130 popupMgr()->insert( separator(), anId, -1 );
3132 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3133 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3134 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3136 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3137 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3138 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3140 popupMgr()->insert( separator(), anId, -1 );
3142 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3143 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3145 popupMgr()->insert( separator(), -1, -1 );
3147 //-------------------------------------------------
3149 //-------------------------------------------------
3150 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3151 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3152 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3153 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3155 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3156 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3158 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3159 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3161 popupMgr()->insert( separator(), -1, -1 );
3163 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3164 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3167 //================================================================================
3169 * \brief Return true if SMESH or GEOM objects are selected.
3170 * Is called form LightApp_Module::activateModule() which clear selection if
3171 * not isSelectionCompatible()
3173 //================================================================================
3175 bool SMESHGUI::isSelectionCompatible()
3177 bool isCompatible = true;
3178 SALOME_ListIO selected;
3179 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3180 Sel->selectedObjects( selected );
3182 SALOME_ListIteratorOfListIO It( selected );
3183 for ( ; isCompatible && It.More(); It.Next())
3185 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3186 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3188 return isCompatible;
3191 bool SMESHGUI::activateModule( SUIT_Study* study )
3193 bool res = SalomeApp_Module::activateModule( study );
3195 setMenuShown( true );
3196 setToolShown( true );
3198 // Reset actions accelerator keys
3199 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3200 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3201 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3203 action( 33)->setEnabled(true); // Delete: Key_Delete
3204 action(1101)->setEnabled(true); // Rename: Key_F2
3209 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3211 setMenuShown( false );
3212 setToolShown( false );
3214 EmitSignalCloseAllDialogs();
3216 // Unset actions accelerator keys
3217 action(111)->setAccel(QKeySequence()); // Import DAT
3218 action(112)->setAccel(QKeySequence()); // Import UNV
3219 action(113)->setAccel(QKeySequence()); // Import MED
3221 action( 33)->setEnabled(false); // Delete: Key_Delete
3222 action(1101)->setEnabled(false); // Rename: Key_F2
3224 return SalomeApp_Module::deactivateModule( study );
3227 void SMESHGUI::studyClosed( SUIT_Study* s )
3229 SMESH::RemoveVisuData( s->id() );
3230 SalomeApp_Module::studyClosed( s );
3233 void SMESHGUI::OnGUIEvent()
3235 const QObject* obj = sender();
3236 if ( !obj || !obj->inherits( "QAction" ) )
3238 int id = actionId((QAction*)obj);
3243 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3245 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3246 if ( CORBA::is_nil( myComponentSMESH ) )
3248 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3250 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3251 return aGUI.myComponentSMESH;
3254 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3255 return myComponentSMESH;
3258 QString SMESHGUI::engineIOR() const
3260 CORBA::ORB_var anORB = getApp()->orb();
3261 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3262 return QString( anIOR.in() );
3265 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3267 SMESHGUI_Selection sel;
3268 sel.init( client, selectionMgr() );
3269 popupMgr()->updatePopup( menu, &sel );
3272 selectionMgr()->selectedObjects( lst );
3273 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3274 Handle(SALOME_InteractiveObject) io = lst.First();
3275 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3276 _PTR(Study) study = appStudy->studyDS();
3277 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3279 QString aName = QString( obj->GetName().c_str() );
3280 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3281 aName.remove( (aName.length() - 1), 1 );
3287 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3289 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3290 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3293 void SMESHGUI::viewManagers( QStringList& list ) const
3295 list.append( SVTK_Viewer::Type() );
3298 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3300 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3301 SMESH::UpdateSelectionProp( this );
3304 void SMESHGUI::createPreferences()
3306 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3308 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3309 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3311 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3312 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3313 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3315 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3316 setPreferenceProperty( precGroup, "columns", 1 );
3318 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3320 setPreferenceProperty( prec, "min", 0 );
3321 setPreferenceProperty( prec, "max", 16 );
3323 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3324 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3326 modes.append( "Wireframe" );
3327 modes.append( "Shading" );
3328 modes.append( "Nodes" );
3329 modes.append( "Shrink" );
3330 QValueList<QVariant> indices;
3331 indices.append( 0 );
3332 indices.append( 1 );
3333 indices.append( 2 );
3334 indices.append( 3 );
3335 setPreferenceProperty( dispmode, "strings", modes );
3336 setPreferenceProperty( dispmode, "indexes", indices );
3338 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3339 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3340 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3342 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3343 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3345 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3346 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3348 setPreferenceProperty( nodeSz, "min", 1 );
3349 setPreferenceProperty( nodeSz, "max", 5 );
3351 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3353 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3354 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3355 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3356 addPreference( "", elemGroup, LightApp_Preferences::Space );
3358 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3359 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3361 setPreferenceProperty( elemW, "min", 1 );
3362 setPreferenceProperty( elemW, "max", 5 );
3364 setPreferenceProperty( shrink, "min", 0 );
3365 setPreferenceProperty( shrink, "max", 100 );
3367 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3369 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3371 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3372 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3373 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3375 setPreferenceProperty( selW, "min", 1 );
3376 setPreferenceProperty( selW, "max", 5 );
3378 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3380 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3381 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3383 setPreferenceProperty( preW, "min", 1 );
3384 setPreferenceProperty( preW, "max", 5 );
3386 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3388 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3389 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3390 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3392 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3393 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3395 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3396 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3397 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3398 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3401 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3402 fam.append( tr( "SMESH_FONT_COURIER" ) );
3403 fam.append( tr( "SMESH_FONT_TIMES" ) );
3404 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3406 setPreferenceProperty( tfont, "families", fam );
3407 setPreferenceProperty( tfont, "system", false );
3408 setPreferenceProperty( tfont, "widget_flags", wflag );
3409 setPreferenceProperty( lfont, "families", fam );
3410 setPreferenceProperty( lfont, "system", false );
3411 setPreferenceProperty( lfont, "widget_flags", wflag );
3413 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3415 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3416 setPreferenceProperty( numcol, "min", 2 );
3417 setPreferenceProperty( numcol, "max", 256 );
3419 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3420 setPreferenceProperty( numlab, "min", 2 );
3421 setPreferenceProperty( numlab, "max", 65 );
3423 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3424 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3425 QStringList orients;
3426 orients.append( tr( "SMESH_VERTICAL" ) );
3427 orients.append( tr( "SMESH_HORIZONTAL" ) );
3428 indices.clear(); indices.append( 0 ); indices.append( 1 );
3429 setPreferenceProperty( orient, "strings", orients );
3430 setPreferenceProperty( orient, "indexes", indices );
3432 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3433 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3434 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3435 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3436 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3437 setPreferenceProperty( xv, "step", 0.1 );
3438 setPreferenceProperty( xv, "min", 0.0 );
3439 setPreferenceProperty( xv, "max", 1.0 );
3440 setPreferenceProperty( yv, "step", 0.1 );
3441 setPreferenceProperty( yv, "min", 0.0 );
3442 setPreferenceProperty( yv, "max", 1.0 );
3443 setPreferenceProperty( wv, "step", 0.1 );
3444 setPreferenceProperty( wv, "min", 0.0 );
3445 setPreferenceProperty( wv, "max", 1.0 );
3446 setPreferenceProperty( hv, "min", 0.0 );
3447 setPreferenceProperty( hv, "max", 1.0 );
3448 setPreferenceProperty( hv, "step", 0.1 );
3450 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3451 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3452 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3453 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3454 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3455 setPreferenceProperty( xv, "min", 0.0 );
3456 setPreferenceProperty( xv, "max", 1.0 );
3457 setPreferenceProperty( xv, "step", 0.1 );
3458 setPreferenceProperty( xh, "min", 0.0 );
3459 setPreferenceProperty( xh, "max", 1.0 );
3460 setPreferenceProperty( xh, "step", 0.1 );
3461 setPreferenceProperty( yh, "min", 0.0 );
3462 setPreferenceProperty( yh, "max", 1.0 );
3463 setPreferenceProperty( yh, "step", 0.1 );
3464 setPreferenceProperty( wh, "min", 0.0 );
3465 setPreferenceProperty( wh, "max", 1.0 );
3466 setPreferenceProperty( wh, "step", 0.1 );
3467 setPreferenceProperty( hh, "min", 0.0 );
3468 setPreferenceProperty( hh, "max", 1.0 );
3469 setPreferenceProperty( hh, "step", 0.1 );
3472 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3474 if( sect=="SMESH" ){
3475 float sbX1,sbY1,sbW,sbH;
3476 float aTol = 1.00000009999999;
3477 std::string aWarning;
3478 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3479 if( name=="selection_object_color" || name=="selection_element_color" ||
3480 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3481 name=="selection_precision_node" || name=="selection_precision_element" ||
3482 name=="selection_precision_object")
3483 SMESH::UpdateSelectionProp( this );
3484 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3485 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3486 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3487 if(sbX1+sbW > aTol){
3488 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3491 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3492 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3495 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3496 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3497 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3498 if(sbY1+sbH > aTol){
3499 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3500 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3501 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3504 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3505 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3506 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3507 if(sbX1+sbW > aTol){
3508 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3511 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3512 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3515 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3516 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3517 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3518 if(sbY1+sbH > aTol){
3519 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3522 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3523 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3527 if(aWarning.size() != 0){
3528 aWarning += "The default values are applied instead.";
3529 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3530 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3531 QObject::tr(aWarning.c_str()),
3532 QObject::tr("SMESH_BUT_OK"));
3537 //================================================================================
3539 * \brief Update something in accordance with update flags
3540 * \param theFlags - update flags
3542 * Update viewer or/and object browser etc. in accordance with update flags ( see
3543 * LightApp_UpdateFlags enumeration ).
3545 //================================================================================
3546 void SMESHGUI::update( const int flags )
3548 if ( flags & UF_Viewer | flags & UF_Forced )
3549 SMESH::UpdateView();
3551 SalomeApp_Module::update( flags );
3554 //================================================================================
3556 * \brief Set default selection mode
3558 * SLOT called when operation commited. Sets default selection mode
3560 //================================================================================
3561 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3563 SVTK_ViewWindow* vtkWnd =
3564 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3566 vtkWnd->SetSelectionMode( ActorSelection );
3569 //================================================================================
3571 * \brief Set default selection mode
3573 * SLOT called when operation aborted. Sets default selection mode
3575 //================================================================================
3576 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3578 SVTK_ViewWindow* vtkWnd =
3579 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3581 vtkWnd->SetSelectionMode( ActorSelection );
3584 //================================================================================
3586 * \brief Creates operation with given identifier
3587 * \param id - identifier of operation to be started
3588 * \return Pointer on created operation or NULL if operation is not created
3590 * Virtual method redefined from the base class creates operation with given id.
3591 * It is called called automatically from startOperation method of base class.
3593 //================================================================================
3594 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3596 LightApp_Operation* op = 0;
3597 // to do : create operation here
3600 case 701: // Compute mesh
3601 op = new SMESHGUI_ComputeOp();
3603 case 702: // Create mesh
3604 op = new SMESHGUI_MeshOp( true, true );
3606 case 703: // Create sub-mesh
3607 op = new SMESHGUI_MeshOp( true, false );
3609 case 704: // Edit mesh/sub-mesh
3610 op = new SMESHGUI_MeshOp( false );
3612 case 417: //convert to quadratic
3613 op = new SMESHGUI_ConvToQuadOp();
3615 case 4067: // make mesh pass through point
3616 op = new SMESHGUI_MakeNodeAtPointOp();
3623 op = SalomeApp_Module::createOperation( id );
3627 //================================================================================
3629 * \brief Stops current operations and starts a given one
3630 * \param id - The id of the operation to start
3632 //================================================================================
3634 void SMESHGUI::switchToOperation(int id)
3636 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3637 activeStudy()->abortAllOperations();
3638 startOperation( id );
3641 LightApp_Displayer* SMESHGUI::displayer()
3644 myDisplayer = new SMESHGUI_Displayer( getApp() );
3648 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3651 int aTolerance = 64;
3652 int anIterations = 0;
3658 if( anIterations % aPeriod == 0 )
3661 if( aTolerance < 1 )
3664 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3666 aHue = (int)( 360.0 * rand() / RAND_MAX );
3667 //cout << "Hue = " << aHue << endl;
3669 //cout << "Auto colors : ";
3671 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3672 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3673 for( ; it != itEnd; ++it )
3675 SALOMEDS::Color anAutoColor = *it;
3676 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3679 aQColor.getHsv( &h, &s, &v );
3681 if( abs( h - aHue ) < aTolerance )
3684 //cout << "break (diff = " << abs( h - aHue ) << ")";
3694 //cout << "Hue of the returned color = " << aHue << endl;
3696 aColor.setHsv( aHue, 255, 255 );
3698 SALOMEDS::Color aSColor;
3699 aSColor.R = (double)aColor.red() / 255.0;
3700 aSColor.G = (double)aColor.green() / 255.0;
3701 aSColor.B = (double)aColor.blue() / 255.0;