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 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
359 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
361 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
363 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
364 for ( ; it != aFilterMapSTL.end(); ++it )
365 filters.push_back( it.key() );
367 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
368 fd->setCaption( aTitle );
369 fd->setFilters( filters );
370 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
374 aFilename = fd->selectedFile();
375 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
380 else { // Export to MED
382 QString aDefaultFilter;
383 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
384 for ( ; it != aFilterMap.end(); ++it ) {
385 filters.push_back( it.key() );
386 if (it.data() == SMESH::MED_V2_2)
387 aDefaultFilter = it.key();
390 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
391 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
392 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
393 fd->setCaption( aTitle );
394 fd->setFilters( filters );
395 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
396 fd->setSelectedFilter(aDefaultFilter);
397 fd->SetChecked(toCreateGroups);
401 aFilename = fd->selectedFile();
402 aFormat = aFilterMap[fd->selectedFilter()];
404 if ( !aFilename.isEmpty()
405 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
406 && aFormat==SMESH::MED_V2_1) {
407 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
408 QObject::tr("SMESH_WRN_WARNING"),
409 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
410 QObject::tr("SMESH_BUT_YES"),
411 QObject::tr("SMESH_BUT_NO"),
418 toCreateGroups = fd->IsChecked();
421 if ( !aFilename.isEmpty() ) {
422 // Check whether the file already exists and delete it if yes
423 QFile aFile( aFilename );
424 if ( aFile.exists() )
426 SUIT_OverrideCursor wc;
429 bool Renumber = false ;
430 // PAL 14172 : Check of we have to renumber or not from the preferences before export
432 Renumber= resMgr->booleanValue("SMESH","renumbering");
434 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
435 aMeshEditor->RenumberNodes();
436 aMeshEditor->RenumberElements();
437 if ( SMESHGUI::automaticUpdate() )
440 switch ( theCommandID ) {
443 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
447 aMesh->ExportDAT( aFilename.latin1() );
451 aMesh->ExportUNV( aFilename.latin1() );
455 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
461 catch (const SALOME::SALOME_Exception& S_ex){
463 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
464 QObject::tr("SMESH_WRN_WARNING"),
465 QObject::tr("SMESH_EXPORT_FAILED"),
466 QObject::tr("SMESH_BUT_OK"));
474 inline void InverseEntityMode(unsigned int& theOutputMode,
475 unsigned int theMode)
477 bool anIsNotPresent = ~theOutputMode & theMode;
479 theOutputMode |= theMode;
481 theOutputMode &= ~theMode;
484 void SetDisplayEntity(int theCommandID){
485 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
486 SALOME_ListIO selected;
488 aSel->selectedObjects( selected );
490 if(selected.Extent() >= 1){
491 SALOME_ListIteratorOfListIO It( selected );
492 for(; It.More(); It.Next()){
493 Handle(SALOME_InteractiveObject) IObject = It.Value();
494 if(IObject->hasEntry()){
495 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
496 unsigned int aMode = anActor->GetEntityMode();
497 switch(theCommandID){
499 InverseEntityMode(aMode,SMESH_Actor::eEdges);
502 InverseEntityMode(aMode,SMESH_Actor::eFaces);
505 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
508 aMode = SMESH_Actor::eAllEntity;
512 anActor->SetEntityMode(aMode);
520 SALOME_ListIO selected;
521 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
525 LightApp_SelectionMgr* aSel = app->selectionMgr();
526 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
527 if( !aSel || !appStudy )
530 aSel->selectedObjects( selected );
531 if( selected.IsEmpty() )
534 Handle(SALOME_InteractiveObject) anIObject = selected.First();
536 _PTR(Study) aStudy = appStudy->studyDS();
537 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
538 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
539 if( aMainObject->_is_nil() )
542 aMainObject->SetAutoColor( true );
544 QValueList<SALOMEDS::Color> aReservedColors;
546 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
547 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
549 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
550 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
552 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
553 aGroupObject->SetColor( aColor );
554 aReservedColors.append( aColor );
556 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
557 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
559 if( aGroupObject->GetType() == SMESH::NODE )
560 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
561 else if( aGroupObject->GetType() == SMESH::EDGE )
562 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
564 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
568 SMESH::RepaintCurrentView();
571 void DisableAutoColor(){
572 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
573 SALOME_ListIO selected;
575 aSel->selectedObjects( selected );
577 if(selected.Extent()){
578 Handle(SALOME_InteractiveObject) anIObject = selected.First();
579 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
580 if ( !aMesh->_is_nil() ) {
581 aMesh->SetAutoColor( false );
586 void SetDisplayMode(int theCommandID){
587 SALOME_ListIO selected;
588 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
592 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
593 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
594 if( !aSel || !appStudy )
597 _PTR(Study) aStudy = appStudy->studyDS();
599 aSel->selectedObjects( selected );
601 if(selected.Extent() >= 1){
602 switch(theCommandID){
604 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
605 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
609 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
610 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
613 SALOME_ListIteratorOfListIO It( selected );
614 for(; It.More(); It.Next()){
615 Handle(SALOME_InteractiveObject) IObject = It.Value();
616 if(IObject->hasEntry()){
617 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
618 switch(theCommandID){
620 anActor->SetRepresentation(SMESH_Actor::eEdge);
623 anActor->SetRepresentation(SMESH_Actor::eSurface);
626 if(anActor->IsShrunk())
629 anActor->SetShrink();
632 anActor->SetRepresentation(SMESH_Actor::ePoint);
635 vtkFloatingPointType color[3];
636 anActor->GetSufaceColor(color[0], color[1], color[2]);
637 int c0 = int (color[0] * 255);
638 int c1 = int (color[1] * 255);
639 int c2 = int (color[2] * 255);
640 QColor c(c0, c1, c2);
642 vtkFloatingPointType edgecolor[3];
643 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
644 c0 = int (edgecolor[0] * 255);
645 c1 = int (edgecolor[1] * 255);
646 c2 = int (edgecolor[2] * 255);
647 QColor e(c0, c1, c2);
649 vtkFloatingPointType backfacecolor[3];
650 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
651 c0 = int (backfacecolor[0] * 255);
652 c1 = int (backfacecolor[1] * 255);
653 c2 = int (backfacecolor[2] * 255);
654 QColor b(c0, c1, c2);
656 vtkFloatingPointType nodecolor[3];
657 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
658 c0 = int (nodecolor[0] * 255);
659 c1 = int (nodecolor[1] * 255);
660 c2 = int (nodecolor[2] * 255);
661 QColor n(c0, c1, c2);
663 int Edgewidth = (int)anActor->GetLineWidth();
666 int intValue = int(anActor->GetNodeSize());
667 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
669 SMESHGUI_Preferences_ColorDlg *aDlg =
670 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
671 aDlg->SetColor(1, c);
672 aDlg->SetColor(2, e);
673 aDlg->SetColor(3, n);
674 aDlg->SetColor(4, b);
675 aDlg->SetIntValue(1, Edgewidth);
676 aDlg->SetIntValue(2, intValue);
677 aDlg->SetIntValue(3, int(Shrink*100.));
679 QColor color = aDlg->GetColor(1);
680 QColor edgecolor = aDlg->GetColor(2);
681 QColor nodecolor = aDlg->GetColor(3);
682 QColor backfacecolor = aDlg->GetColor(4);
683 /* actor color and backface color */
684 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
685 vtkFloatingPointType (color.green()) / 255.,
686 vtkFloatingPointType (color.blue()) / 255.);
687 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
688 vtkFloatingPointType (backfacecolor.green()) / 255.,
689 vtkFloatingPointType (backfacecolor.blue()) / 255.);
692 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
693 vtkFloatingPointType (edgecolor.green()) / 255.,
694 vtkFloatingPointType (edgecolor.blue()) / 255.);
696 /* Shrink factor and size edges */
697 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
698 anActor->SetLineWidth(aDlg->GetIntValue(1));
700 /* Nodes color and size */
701 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
702 vtkFloatingPointType (nodecolor.green()) / 255.,
703 vtkFloatingPointType (nodecolor.blue()) / 255.);
704 anActor->SetNodeSize(aDlg->GetIntValue(2));
706 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
707 if( !aGroupObject->_is_nil() )
709 SALOMEDS::Color aColor;
710 aColor.R = (float)color.red() / 255.0;
711 aColor.G = (float)color.green() / 255.0;
712 aColor.B = (float)color.blue() / 255.0;
713 aGroupObject->SetColor( aColor );
723 SMESH::RepaintCurrentView();
727 void Control( int theCommandID )
729 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
730 SALOME_ListIO selected;
732 aSel->selectedObjects( selected );
734 if( !selected.IsEmpty() ){
735 Handle(SALOME_InteractiveObject) anIO = selected.First();
738 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
739 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
740 switch ( theCommandID ){
742 aTitle = QObject::tr( "LENGTH_EDGES" );
743 aControl = SMESH_Actor::eLength;
746 aTitle = QObject::tr( "LENGTH2D_EDGES" );
747 aControl = SMESH_Actor::eLength2D;
750 aTitle = QObject::tr( "FREE_EDGES" );
751 aControl = SMESH_Actor::eFreeEdges;
754 aTitle = QObject::tr( "FREE_BORDERS" );
755 aControl = SMESH_Actor::eFreeBorders;
758 aTitle = QObject::tr( "MULTI_BORDERS" );
759 aControl = SMESH_Actor::eMultiConnection;
762 aTitle = QObject::tr( "MULTI2D_BORDERS" );
763 aControl = SMESH_Actor::eMultiConnection2D;
766 aTitle = QObject::tr( "AREA_ELEMENTS" );
767 aControl = SMESH_Actor::eArea;
770 aTitle = QObject::tr( "TAPER_ELEMENTS" );
771 aControl = SMESH_Actor::eTaper;
774 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
775 aControl = SMESH_Actor::eAspectRatio;
778 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
779 aControl = SMESH_Actor::eAspectRatio3D;
782 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
783 aControl = SMESH_Actor::eMinimumAngle;
786 aTitle = QObject::tr( "WARP_ELEMENTS" );
787 aControl = SMESH_Actor::eWarping;
790 aTitle = QObject::tr( "SKEW_ELEMENTS" );
791 aControl = SMESH_Actor::eSkew;
794 aTitle = QObject::tr( "SMESH_VOLUME" );
795 aControl = SMESH_Actor::eVolume3D;
798 anActor->SetControlMode(aControl);
799 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
800 SMESH::RepaintCurrentView();
807 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
808 MeshObjectType theType,
809 const QString theInTypeName,
810 QString & theOutTypeName)
812 SMESH_TypeFilter aTypeFilter( theType );
814 if( !theIO.IsNull() )
816 entry = theIO->getEntry();
817 LightApp_DataOwner owner( entry );
818 if ( aTypeFilter.isOk( &owner )) {
819 theOutTypeName = theInTypeName;
827 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
829 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
830 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
832 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
833 CORBA::String_var anID = aSComp->GetID().c_str();
834 if (!strcmp(anID.in(),theIO->getEntry()))
840 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
841 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
842 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
843 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
844 CheckOIType ( theIO, GROUP, "Group", aTypeName )
852 QString CheckHomogeneousSelection()
854 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
855 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
856 SALOME_ListIO selected;
858 aSel->selectedObjects( selected );
860 QString RefType = CheckTypeObject(selected.First());
861 SALOME_ListIteratorOfListIO It(selected);
862 for (; It.More(); It.Next())
864 Handle(SALOME_InteractiveObject) IObject = It.Value();
865 QString Type = CheckTypeObject(IObject);
866 if (Type.compare(RefType) != 0)
867 return "Heterogeneous Selection";
874 void SMESHGUI::OnEditDelete()
876 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
877 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
878 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
880 QString aParentComponent = QString::null;
881 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
883 QString cur = anIt.Value()->getComponentDataType();
884 if( aParentComponent.isNull() )
885 aParentComponent = cur;
886 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
887 aParentComponent = "";
890 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
891 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
892 QObject::tr("ERR_ERROR"),
893 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
894 QObject::tr("BUT_OK") );
897 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
898 if (SUIT_MessageBox::warn2
899 (SMESHGUI::desktop(),
900 QObject::tr("SMESH_WRN_WARNING"),
901 QObject::tr("SMESH_REALLY_DELETE"),
902 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
905 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
906 SUIT_ViewManager* vm = anApp->activeViewManager();
907 int nbSf = vm->getViewsCount();
909 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
910 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
911 _PTR(GenericAttribute) anAttr;
912 _PTR(AttributeIOR) anIOR;
914 SALOME_ListIteratorOfListIO It(selected);
916 aStudyBuilder->NewCommand(); // There is a transaction
917 for(; It.More(); It.Next()){ // loop on selected IO's
918 Handle(SALOME_InteractiveObject) IObject = It.Value();
919 if(IObject->hasEntry()) {
920 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
922 // disable removal of "SMESH" component object
923 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
925 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
929 // put the whole hierarchy of sub-objects of the selected SO into a list and
930 // then treat them all starting from the deepest objects (at list back)
932 list< _PTR(SObject) > listSO;
933 listSO.push_back( aSO );
934 list< _PTR(SObject) >::iterator itSO = listSO.begin();
935 for ( ; itSO != listSO.end(); ++itSO ) {
936 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
937 for (it->InitEx(false); it->More(); it->Next())
938 listSO.push_back( it->Value() );
941 // treat SO's in the list starting from the back
943 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
944 for ( ; ritSO != listSO.rend(); ++ritSO ) {
945 _PTR(SObject) SO = *ritSO;
947 string anEntry = SO->GetID();
949 /** Erase graphical object **/
950 if(SO->FindAttribute(anAttr, "AttributeIOR")){
951 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
952 for(int i = 0; i < nbSf; i++){
953 SUIT_ViewWindow *sf = aViews[i];
954 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
955 SMESH::RemoveActor(sf,anActor);
960 /** Remove an object from data structures **/
961 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
962 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
963 if ( !aGroup->_is_nil() ) { // DELETE GROUP
964 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
965 aMesh->RemoveGroup( aGroup );
967 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
968 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
969 aMesh->RemoveSubMesh( aSubMesh );
971 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
973 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
976 IObject = new SALOME_InteractiveObject
977 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
978 QString objType = CheckTypeObject(IObject);
979 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
980 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
981 aStudyBuilder->RemoveObjectWithChildren( SO );
983 else {// default action: remove SObject from the study
984 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
985 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
987 aStudyBuilder->RemoveObjectWithChildren( SO );
991 } /* listSO back loop */
992 } /* IObject->hasEntry() */
994 aStudyBuilder->CommitCommand();
996 /* Clear any previous selection */
998 aSel->setSelectedObjects( l1 );
1000 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1005 SMESHGUI_EXPORT CAM_Module* createModule()
1007 return new SMESHGUI();
1011 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1013 //=============================================================================
1017 //=============================================================================
1018 SMESHGUI::SMESHGUI() :
1019 SalomeApp_Module( "SMESH" )
1021 if ( CORBA::is_nil( myComponentSMESH ) )
1023 CORBA::Boolean anIsEmbeddedMode;
1024 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1027 myActiveDialogBox = 0;
1028 myFilterLibraryDlg = 0;
1032 SMESH::GetFilterManager();
1033 SMESH::GetPattern();
1035 /* load resources for all available meshers */
1036 SMESH::InitAvailableHypotheses();
1039 //=============================================================================
1043 //=============================================================================
1044 SMESHGUI::~SMESHGUI()
1046 SMESH::GetFilterManager()->Destroy();
1047 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1050 //=============================================================================
1054 //=============================================================================
1055 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1057 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1059 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1064 bool SMESHGUI::automaticUpdate()
1066 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1070 return resMgr->booleanValue( "SMESH", "auto_update", false );
1073 //=============================================================================
1077 //=============================================================================
1078 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1080 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1083 //=============================================================================
1087 //=============================================================================
1088 SMESHGUI* SMESHGUI::GetSMESHGUI()
1090 SMESHGUI* smeshMod = 0;
1091 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1094 CAM_Module* module = app->module( "Mesh" );
1095 smeshMod = dynamic_cast<SMESHGUI*>( module );
1098 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1100 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1103 _PTR(Study) aStudy = study->studyDS();
1105 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1114 Standard_EXPORT SMESHGUI* GetComponentGUI()
1116 return SMESHGUI::GetSMESHGUI();
1120 //=============================================================================
1124 //=============================================================================
1125 void SMESHGUI::SetState(int aState)
1130 //=============================================================================
1134 //=============================================================================
1135 void SMESHGUI::ResetState()
1140 //=============================================================================
1144 //=============================================================================
1145 void SMESHGUI::EmitSignalDeactivateDialog()
1147 emit SignalDeactivateActiveDialog();
1150 //=============================================================================
1154 //=============================================================================
1155 void SMESHGUI::EmitSignalStudyFrameChanged()
1157 emit SignalStudyFrameChanged();
1160 //=============================================================================
1164 //=============================================================================
1165 void SMESHGUI::EmitSignalCloseAllDialogs()
1167 emit SignalCloseAllDialogs();
1170 //=============================================================================
1174 //=============================================================================
1175 QDialog *SMESHGUI::GetActiveDialogBox()
1177 return myActiveDialogBox;
1180 //=============================================================================
1184 //=============================================================================
1185 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1187 myActiveDialogBox = (QDialog *) aDlg;
1191 //=============================================================================
1195 //=============================================================================
1196 SUIT_Desktop* SMESHGUI::desktop()
1198 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1200 return app->desktop();
1205 //=============================================================================
1209 //=============================================================================
1210 SalomeApp_Study* SMESHGUI::activeStudy()
1212 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1214 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1219 //=============================================================================
1223 //=============================================================================
1224 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1226 /* Here the position is on the bottom right corner - 10 */
1227 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1229 SUIT_Desktop *PP = desktop();
1230 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1231 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1235 //=============================================================================
1239 //=============================================================================
1240 static int isStudyLocked(_PTR(Study) theStudy){
1241 return theStudy->GetProperties()->IsLocked();
1244 static bool checkLock(_PTR(Study) theStudy) {
1245 if (isStudyLocked(theStudy)) {
1246 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1247 QObject::tr("WRN_WARNING"),
1248 QObject::tr("WRN_STUDY_LOCKED"),
1249 QObject::tr("BUT_OK") );
1255 //=======================================================================
1256 //function : CheckActiveStudyLocked
1258 //=======================================================================
1260 bool SMESHGUI::isActiveStudyLocked()
1262 _PTR(Study) aStudy = activeStudy()->studyDS();
1263 return checkLock( aStudy );
1266 //=============================================================================
1270 //=============================================================================
1271 bool SMESHGUI::OnGUIEvent( int theCommandID )
1273 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1277 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1278 SUIT_ResourceMgr* mgr = resourceMgr();
1282 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1283 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1286 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1287 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1289 //QAction* act = action( theCommandID );
1291 switch (theCommandID) {
1293 if(checkLock(aStudy)) break;
1301 if(checkLock(aStudy)) break;
1302 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1306 case 150: //MED FILE INFORMATION
1308 SALOME_ListIO selected;
1309 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1311 aSel->selectedObjects( selected );
1312 if( selected.Extent() )
1314 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1315 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1316 if ( !aMesh->_is_nil() )
1318 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1324 case 122: // EXPORT MED
1333 ::ExportMeshToFile(theCommandID);
1337 case 200: // SCALAR BAR
1339 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1340 SALOME_ListIO selected;
1342 aSel->selectedObjects( selected );
1344 if( selected.Extent() ) {
1345 Handle(SALOME_InteractiveObject) anIO = selected.First();
1346 if( anIO->hasEntry() ) {
1347 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1348 anActor->SetControlMode( SMESH_Actor::eNone );
1356 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1366 ::DisableAutoColor();
1369 case 1134: // Clipping
1370 case 1133: // Tranparency
1371 case 1132: // Colors / Size
1378 ::SetDisplayMode(theCommandID);
1384 case 219: // Volumes
1385 case 220: // All Entity
1386 ::SetDisplayEntity(theCommandID);
1391 if(checkLock(aStudy)) break;
1393 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1396 SMESH::UpdateView();
1398 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1399 SMESH::OnVisuException();
1401 catch (...) { // PAL16774 (Crash after display of many groups)
1402 SMESH::OnVisuException();
1406 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1407 aSel->selectedObjects( l );
1408 aSel->setSelectedObjects( l );
1413 case 301: // DISPLAY
1414 case 302: // DISPLAY ONLY
1416 SMESH::EDisplaing anAction;
1417 switch (theCommandID) {
1418 case 300: anAction = SMESH::eErase; break;
1419 case 301: anAction = SMESH::eDisplay; break;
1420 case 302: anAction = SMESH::eDisplayOnly; break;
1423 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1424 SALOME_ListIO sel_objects, to_process;
1426 aSel->selectedObjects( sel_objects );
1428 if( theCommandID==302 )
1429 startOperation( myEraseAll );
1431 extractContainers( sel_objects, to_process );
1434 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1438 SALOME_ListIteratorOfListIO It( to_process );
1439 for (; It.More(); It.Next()) {
1440 Handle(SALOME_InteractiveObject) IOS = It.Value();
1441 if (IOS->hasEntry()) {
1442 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1443 break; // PAL16774 (Crash after display of many groups)
1444 if (anAction == SMESH::eDisplayOnly)
1445 anAction = SMESH::eDisplay;
1450 // PAL13338 + PAL15161 -->
1451 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1452 SMESH::UpdateView();
1453 // PAL13338 + PAL15161 <--
1455 catch (...) { // PAL16774 (Crash after display of many groups)
1456 SMESH::OnVisuException();
1459 if (anAction == SMESH::eErase) {
1461 aSel->setSelectedObjects( l1 );
1464 aSel->setSelectedObjects( to_process );
1471 if(checkLock(aStudy)) break;
1474 EmitSignalDeactivateDialog();
1476 new SMESHGUI_NodesDlg(this);
1479 SUIT_MessageBox::warn1(desktop(),
1480 tr("SMESH_WRN_WARNING"),
1481 tr("SMESH_WRN_VIEWER_VTK"),
1482 tr("SMESH_BUT_OK"));
1487 case 2151: // FILTER
1491 EmitSignalDeactivateDialog();
1492 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1497 case 406: // MOVE NODE
1501 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1502 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1506 if(checkLock(aStudy)) break;
1507 new SMESHGUI_MoveNodesDlg(this);
1511 case 701: // COMPUTE MESH
1513 if (checkLock(aStudy)) break;
1515 startOperation( 701 );
1519 case 702: // Create mesh
1520 startOperation( 702 );
1522 case 703: // Create sub-mesh
1523 startOperation( 703 );
1525 case 704: // Edit mesh/sub-mesh
1526 startOperation( 704 );
1528 case 710: // Build compound mesh
1530 if (checkLock(aStudy)) break;
1531 EmitSignalDeactivateDialog();
1532 new SMESHGUI_BuildCompoundDlg( this );
1536 case 407: // DIAGONAL INVERSION
1537 case 408: // Delete diagonal
1541 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1542 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1546 if ( checkLock( aStudy ) )
1549 /*Standard_Boolean aRes;
1550 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1551 if ( aMesh->_is_nil() )
1553 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1554 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1558 EmitSignalDeactivateDialog();
1559 if ( theCommandID == 407 )
1560 new SMESHGUI_TrianglesInversionDlg(this);
1562 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1565 case 409: // Change orientation
1566 case 410: // Union of triangles
1567 case 411: // Cutting of quadrangles
1571 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1572 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1576 if ( checkLock( aStudy ) )
1579 EmitSignalDeactivateDialog();
1580 SMESHGUI_MultiEditDlg* aDlg = NULL;
1581 if ( theCommandID == 409 )
1582 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1583 else if ( theCommandID == 410 )
1584 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1586 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1591 case 412: // Smoothing
1593 if(checkLock(aStudy)) break;
1595 EmitSignalDeactivateDialog();
1596 new SMESHGUI_SmoothingDlg( this );
1599 SUIT_MessageBox::warn1(desktop(),
1600 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1601 tr("SMESH_BUT_OK"));
1605 case 413: // Extrusion
1607 if (checkLock(aStudy)) break;
1609 EmitSignalDeactivateDialog();
1610 new SMESHGUI_ExtrusionDlg ( this );
1612 SUIT_MessageBox::warn1(desktop(),
1613 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1614 tr("SMESH_BUT_OK"));
1618 case 414: // Revolution
1620 if(checkLock(aStudy)) break;
1622 EmitSignalDeactivateDialog();
1623 new SMESHGUI_RevolutionDlg( this );
1626 SUIT_MessageBox::warn1(desktop(),
1627 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1628 tr("SMESH_BUT_OK"));
1632 case 415: // Pattern mapping
1634 if ( checkLock( aStudy ) )
1638 EmitSignalDeactivateDialog();
1639 new SMESHGUI_MeshPatternDlg( this );
1642 SUIT_MessageBox::warn1(desktop(),
1643 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1644 tr("SMESH_BUT_OK"));
1648 case 416: // Extrusion along a path
1650 if (checkLock(aStudy)) break;
1652 EmitSignalDeactivateDialog();
1653 new SMESHGUI_ExtrusionAlongPathDlg( this );
1655 SUIT_MessageBox::warn1(desktop(),
1656 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1657 tr("SMESH_BUT_OK"));
1661 case 417: // Convert mesh to quadratic
1663 startOperation( 417 );
1664 /* if (checkLock(aStudy)) break;
1666 EmitSignalDeactivateDialog();
1667 new SMESHGUI_ConvToQuadDlg();
1669 SUIT_MessageBox::warn1(desktop(),
1670 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1671 tr("SMESH_BUT_OK"));
1675 case 801: // CREATE GROUP
1679 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1680 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1684 if(checkLock(aStudy)) break;
1685 EmitSignalDeactivateDialog();
1686 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1688 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1689 SALOME_ListIO selected;
1691 aSel->selectedObjects( selected );
1693 int nbSel = selected.Extent();
1695 // check if mesh is selected
1696 aMesh = SMESH::GetMeshByIO( selected.First() );
1698 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1703 case 802: // CONSTRUCT GROUP
1707 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1708 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1712 if(checkLock(aStudy)) break;
1713 EmitSignalDeactivateDialog();
1715 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1716 SALOME_ListIO selected;
1718 aSel->selectedObjects( selected );
1720 int nbSel = selected.Extent();
1722 // check if submesh is selected
1723 Handle(SALOME_InteractiveObject) IObject = selected.First();
1724 if (IObject->hasEntry()) {
1725 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1727 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1728 if (!aSubMesh->_is_nil()) {
1730 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1731 // get submesh elements list by types
1732 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1733 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1734 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1735 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1736 // create group for each type o elements
1737 QString aName = IObject->getName();
1738 if (aNodes->length() > 0) {
1739 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1740 aGroup->Add(aNodes.inout());
1742 if (aEdges->length() > 0) {
1743 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1744 aGroup->Add(aEdges.inout());
1746 if (aFaces->length() > 0) {
1747 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1748 aGroup->Add(aFaces.inout());
1750 if (aVolumes->length() > 0) {
1751 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1752 aGroup->Add(aVolumes.inout());
1757 catch(const SALOME::SALOME_Exception & S_ex){
1758 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1765 SUIT_MessageBox::warn1(desktop(),
1766 tr("SMESH_WRN_WARNING"),
1767 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1768 tr("SMESH_BUT_OK"));
1773 case 803: // EDIT GROUP
1777 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1778 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1782 if(checkLock(aStudy)) break;
1783 EmitSignalDeactivateDialog();
1785 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1786 SALOME_ListIO selected;
1788 aSel->selectedObjects( selected );
1790 SALOME_ListIteratorOfListIO It (selected);
1791 int nbSelectedGroups = 0;
1792 for ( ; It.More(); It.Next() )
1794 SMESH::SMESH_GroupBase_var aGroup =
1795 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1796 if (!aGroup->_is_nil()) {
1798 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1802 if (nbSelectedGroups == 0)
1804 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1810 case 804: // Add elements to group
1812 if(checkLock(aStudy)) break;
1813 if (myState == 800) {
1814 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1815 if (aDlg) aDlg->onAdd();
1820 case 805: // Remove elements from group
1822 if(checkLock(aStudy)) break;
1823 if (myState == 800) {
1824 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1825 if (aDlg) aDlg->onRemove();
1830 case 810: // Union Groups
1831 case 811: // Intersect groups
1832 case 812: // Cut groups
1836 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1837 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1841 if ( checkLock( aStudy ) )
1844 EmitSignalDeactivateDialog();
1847 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1848 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1849 else aMode = SMESHGUI_GroupOpDlg::CUT;
1851 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1855 case 813: // Delete groups with their contents
1859 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1860 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1864 if ( checkLock( aStudy ) )
1867 EmitSignalDeactivateDialog();
1869 new SMESHGUI_DeleteGroupDlg( this );
1873 case 900: // MESH INFOS
1875 EmitSignalDeactivateDialog();
1876 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1877 SALOME_ListIO selected;
1879 aSel->selectedObjects( selected );
1881 if ( selected.Extent() > 1 ) { // a dlg for each IO
1883 SALOME_ListIteratorOfListIO It (selected);
1884 for ( ; It.More(); It.Next() ) {
1885 IOs.Clear(); IOs.Append( It.Value() );
1886 aSel->setSelectedObjects( IOs );
1887 new SMESHGUI_MeshInfosDlg(this, "", false);
1889 // restore selection
1890 aSel->setSelectedObjects( selected );
1893 new SMESHGUI_MeshInfosDlg(this, "", false);
1897 case 902: // STANDARD MESH INFOS
1899 EmitSignalDeactivateDialog();
1900 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1901 SALOME_ListIO selected;
1903 aSel->selectedObjects( selected );
1905 if ( selected.Extent() > 1 ) { // a dlg for each IO
1907 SALOME_ListIteratorOfListIO It (selected);
1908 for ( ; It.More(); It.Next() ) {
1910 IOs.Append( It.Value() );
1911 aSel->setSelectedObjects( IOs );
1912 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1914 // restore selection
1915 aSel->setSelectedObjects( selected );
1918 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1922 case 903: // WHAT IS
1924 EmitSignalDeactivateDialog();
1925 new SMESHGUI_WhatIsDlg( this, "", false);
1929 case 1100: // EDIT HYPOTHESIS
1931 if(checkLock(aStudy)) break;
1933 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1934 SALOME_ListIO selected;
1936 aSel->selectedObjects( selected );
1938 int nbSel = selected.Extent();
1941 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1942 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1944 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1945 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1946 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1947 if ( !aHypothesis->_is_nil() )
1949 CORBA::String_var aHypType = aHypothesis->GetName();
1950 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1952 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1959 updateObjBrowser( true );
1963 case 1101: // RENAME
1965 if ( checkLock( aStudy ) )
1968 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1969 SALOME_ListIO selected;
1971 aSel->selectedObjects( selected );
1973 bool isAny = false; // iss there any appropriate object selected
1975 SALOME_ListIteratorOfListIO It( selected );
1976 for ( ; It.More(); It.Next() )
1978 Handle(SALOME_InteractiveObject) IObject = It.Value();
1979 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1980 _PTR(GenericAttribute) anAttr;
1981 _PTR(AttributeName) aName;
1984 if ( obj->FindAttribute(anAttr, "AttributeName") )
1987 QString newName = QString(aName->Value().c_str());
1989 // check type to prevent renaming of inappropriate objects
1990 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
1991 if (aType == MESH || aType == GROUP ||
1992 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
1993 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
1994 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
1995 aType == HYPOTHESIS || aType == ALGORITHM)
1998 newName = LightApp_NameDlg::getName(desktop(), newName);
1999 if ( !newName.isEmpty() )
2001 //old source: aStudy->renameIObject( IObject, newName );
2002 aName->SetValue( newName.latin1() );
2004 // if current object is group update group's name
2005 SMESH::SMESH_GroupBase_var aGroup =
2006 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2007 if (!aGroup->_is_nil() )
2008 aGroup->SetName( newName.latin1() );
2018 SUIT_MessageBox::warn1(desktop(),
2019 QObject::tr("SMESH_WRN_WARNING"),
2020 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"),
2021 QObject::tr("SMESH_BUT_OK"));
2026 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2028 if(checkLock(aStudy)) break;
2029 SUIT_OverrideCursor wc;
2031 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2032 SALOME_ListIO selected;
2034 aSel->selectedObjects( selected, QString::null, false );
2036 SALOME_ListIteratorOfListIO It(selected);
2037 for (int i = 0; It.More(); It.Next(), i++) {
2038 Handle(SALOME_InteractiveObject) IObject = It.Value();
2039 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2042 aSel->setSelectedObjects( l1 );
2047 case 401: // GEOM::EDGE
2048 case 4021: // TRIANGLE
2050 case 4023: // POLYGON
2054 if(checkLock(aStudy)) break;
2056 EmitSignalDeactivateDialog();
2057 SMDSAbs_ElementType type = SMDSAbs_Edge;
2059 switch (theCommandID) {
2060 case 4021: // TRIANGLE
2061 type = SMDSAbs_Face; nbNodes = 3; break;
2063 type = SMDSAbs_Face; nbNodes = 4; break;
2065 type = SMDSAbs_Volume; nbNodes = 4; break;
2066 case 4023: // POLYGON
2067 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2069 type = SMDSAbs_Volume; nbNodes = 8; break;
2070 case 4033: // POLYHEDRE
2071 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2074 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2077 SUIT_MessageBox::warn1(desktop(),
2078 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2079 tr("SMESH_BUT_OK"));
2083 case 4033: // POLYHEDRON
2085 if(checkLock(aStudy)) break;
2087 EmitSignalDeactivateDialog();
2088 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2091 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2092 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2093 tr("SMESH_BUT_OK"));
2097 case 4034: // QUADRATIC EDGE
2098 case 4035: // QUADRATIC TRIANGLE
2099 case 4036: // QUADRATIC QUADRANGLE
2100 case 4037: // QUADRATIC TETRAHEDRON
2101 case 4038: // QUADRATIC PYRAMID
2102 case 4039: // QUADRATIC PENTAHEDRON
2103 case 4040: // QUADRATIC HEXAHEDRON
2105 if(checkLock(aStudy)) break;
2107 EmitSignalDeactivateDialog();
2110 switch (theCommandID) {
2112 type = QUAD_EDGE; break;
2114 type = QUAD_TRIANGLE; break;
2116 type = QUAD_QUADRANGLE; break;
2118 type = QUAD_TETRAHEDRON; break;
2120 type = QUAD_PYRAMID; break;
2122 type = QUAD_PENTAHEDRON; break;
2124 type = QUAD_HEXAHEDRON;
2128 new SMESHGUI_AddQuadraticElementDlg( this, type );
2131 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2132 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2133 tr("SMESH_BUT_OK"));
2137 case 4041: // REMOVES NODES
2139 if(checkLock(aStudy)) break;
2141 EmitSignalDeactivateDialog();
2142 new SMESHGUI_RemoveNodesDlg(this);
2145 SUIT_MessageBox::warn1(desktop(),
2146 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2147 tr("SMESH_BUT_OK"));
2151 case 4042: // REMOVES ELEMENTS
2153 if(checkLock(aStudy)) break;
2155 EmitSignalDeactivateDialog();
2156 new SMESHGUI_RemoveElementsDlg(this);
2160 SUIT_MessageBox::warn1(desktop(),
2161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2162 tr("SMESH_BUT_OK"));
2166 case 4043: { // CLEAR_MESH
2168 if(checkLock(aStudy)) break;
2170 SALOME_ListIO selected;
2171 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2172 aSel->selectedObjects( selected );
2174 SUIT_OverrideCursor wc;
2175 SALOME_ListIteratorOfListIO It (selected);
2176 for ( ; It.More(); It.Next() )
2178 Handle(SALOME_InteractiveObject) IOS = It.Value();
2179 SMESH::SMESH_Mesh_var aMesh =
2180 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2181 if ( aMesh->_is_nil()) continue;
2183 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2185 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2186 SMESH::ModifiedMesh( aMeshSObj, false, true);
2187 // hide groups and submeshes
2188 _PTR(ChildIterator) anIter =
2189 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2190 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2192 _PTR(SObject) so = anIter->Value();
2193 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2196 catch (const SALOME::SALOME_Exception& S_ex){
2198 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2202 SMESH::UpdateView();
2206 case 4051: // RENUMBERING NODES
2208 if(checkLock(aStudy)) break;
2210 EmitSignalDeactivateDialog();
2211 new SMESHGUI_RenumberingDlg( this, "", 0);
2215 SUIT_MessageBox::warn1(desktop(),
2216 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2217 tr("SMESH_BUT_OK"));
2221 case 4052: // RENUMBERING ELEMENTS
2223 if(checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 new SMESHGUI_RenumberingDlg( this, "", 1);
2230 SUIT_MessageBox::warn1(desktop(),
2231 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2232 tr("SMESH_BUT_OK"));
2236 case 4061: // TRANSLATION
2238 if(checkLock(aStudy)) break;
2240 EmitSignalDeactivateDialog();
2241 new SMESHGUI_TranslationDlg( this );
2244 SUIT_MessageBox::warn1(desktop(),
2245 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2246 tr("SMESH_BUT_OK"));
2250 case 4062: // ROTATION
2252 if(checkLock(aStudy)) break;
2254 EmitSignalDeactivateDialog();
2255 new SMESHGUI_RotationDlg( this );
2258 SUIT_MessageBox::warn1(desktop(),
2259 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2260 tr("SMESH_BUT_OK"));
2264 case 4063: // SYMMETRY
2266 if(checkLock(aStudy)) break;
2268 EmitSignalDeactivateDialog();
2269 new SMESHGUI_SymmetryDlg( this );
2272 SUIT_MessageBox::warn1(desktop(),
2273 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2274 tr("SMESH_BUT_OK"));
2278 case 4064: // SEWING
2280 if(checkLock(aStudy)) break;
2282 EmitSignalDeactivateDialog();
2283 new SMESHGUI_SewingDlg( this );
2286 SUIT_MessageBox::warn1(desktop(),
2287 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2288 tr("SMESH_BUT_OK"));
2292 case 4065: // MERGE NODES
2294 if(checkLock(aStudy)) break;
2296 EmitSignalDeactivateDialog();
2297 new SMESHGUI_EditMeshDlg( this, 0 );
2300 SUIT_MessageBox::warn1(desktop(),
2301 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2302 tr("SMESH_BUT_OK"));
2306 case 4066: // MERGE EQUAL ELEMENTS
2308 if (checkLock(aStudy)) break;
2310 EmitSignalDeactivateDialog();
2311 new SMESHGUI_EditMeshDlg( this, 1 );
2313 SUIT_MessageBox::warn1(desktop(),
2314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2315 tr("SMESH_BUT_OK"));
2320 case 4067: // MAKE MESH PASS THROUGH POINT
2321 startOperation( 4067 );
2324 case 5105: // Library of selection filters
2326 static QValueList<int> aTypes;
2327 if ( aTypes.isEmpty() )
2329 aTypes.append( SMESH::NODE );
2330 aTypes.append( SMESH::EDGE );
2331 aTypes.append( SMESH::FACE );
2332 aTypes.append( SMESH::VOLUME );
2334 if (!myFilterLibraryDlg)
2335 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2336 else if (myFilterLibraryDlg->isHidden())
2337 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2338 myFilterLibraryDlg->raise();
2342 case 6017: // CONTROLS
2358 LightApp_SelectionMgr* mgr = selectionMgr();
2359 SALOME_ListIO selected; mgr->selectedObjects( selected );
2361 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2362 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2364 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2365 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2366 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2367 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2368 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2369 ::Control( theCommandID );
2374 SUIT_MessageBox::warn1(desktop(),
2375 tr( "SMESH_WRN_WARNING" ),
2376 tr( "SMESH_BAD_SELECTION" ),
2377 tr( "SMESH_BUT_OK" ) );
2381 SUIT_MessageBox::warn1(desktop(),
2382 tr( "SMESH_WRN_WARNING" ),
2383 tr( "NOT_A_VTK_VIEWER" ),
2384 tr( "SMESH_BUT_OK" ) );
2389 LightApp_SelectionMgr* mgr = selectionMgr();
2390 SALOME_ListIO selected; mgr->selectedObjects( selected );
2392 SALOME_ListIteratorOfListIO it(selected);
2393 for(; it.More(); it.Next()) {
2394 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2395 if(anIObject->hasEntry()) {
2396 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2397 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2405 LightApp_SelectionMgr* mgr = selectionMgr();
2406 SALOME_ListIO selected; mgr->selectedObjects( selected );
2408 if (selected.Extent() == 1) {
2409 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2410 if(anIObject->hasEntry())
2411 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2412 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2419 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2420 //updateObjBrowser();
2424 //=============================================================================
2428 //=============================================================================
2429 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2434 //=============================================================================
2438 //=============================================================================
2439 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2444 //=============================================================================
2448 //=============================================================================
2449 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2454 //=============================================================================
2455 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2456 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2458 //=============================================================================
2459 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2460 SUIT_ViewWindow* wnd )
2462 if(theIO->hasEntry()){
2463 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2464 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2468 //=======================================================================
2469 // function : createSMESHAction
2471 //=======================================================================
2472 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2475 QWidget* parent = application()->desktop();
2476 SUIT_ResourceMgr* resMgr = resourceMgr();
2478 if ( icon_id.length() )
2479 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2481 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2482 if ( !pix.isNull() )
2483 icon = QIconSet( pix );
2485 QString tooltip = tr( QString( "TOP_" )+po_id ),
2486 menu = tr( QString( "MEN_" )+po_id ),
2487 status_bar = tr( QString( "STB_" )+po_id );
2489 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2492 //=======================================================================
2493 // function : createPopupItem
2495 //=======================================================================
2496 void SMESHGUI::createPopupItem( const int id,
2497 const QString& clients,
2498 const QString& types,
2499 const QString& theRule,
2504 parentId = popupMgr()->actionId( action( pId ) );
2506 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2507 popupMgr()->insert( action( id ), parentId, 0 );
2509 QChar lc = QtxPopupMgr::Selection::defEquality();
2510 QString rule = "(%1) and (%2) and (%3)";
2511 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2512 if( clients.isEmpty() )
2513 rule = rule.arg( QString( "true" ) );
2515 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2516 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2519 bool cont = myRules.contains( id );
2521 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2523 popupMgr()->setRule( action( id ), rule, true );
2524 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2527 //=======================================================================
2528 // function : initialize
2530 //=======================================================================
2531 void SMESHGUI::initialize( CAM_Application* app )
2533 SalomeApp_Module::initialize( app );
2535 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2537 /* Automatic Update flag */
2538 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2540 // ----- create actions --------------
2542 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2543 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2544 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2545 createSMESHAction( 114, "NUM" );
2546 createSMESHAction( 121, "DAT" );
2547 createSMESHAction( 122, "MED" );
2548 createSMESHAction( 123, "UNV" );
2549 createSMESHAction( 140, "STL" );
2550 createSMESHAction( 124, "EXPORT_DAT" );
2551 createSMESHAction( 125, "EXPORT_MED" );
2552 createSMESHAction( 126, "EXPORT_UNV" );
2553 createSMESHAction( 141, "EXPORT_STL" );
2554 createSMESHAction( 150, "FILE_INFO" );
2555 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2556 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2557 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2558 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2559 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2560 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2561 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2562 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2563 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2564 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2565 createSMESHAction( 804, "ADD" );
2566 createSMESHAction( 805, "REMOVE" );
2567 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2568 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2569 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2570 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2571 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2572 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2573 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2574 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2575 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2576 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2577 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2578 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2579 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2580 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2581 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2582 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2583 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2584 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2585 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2586 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2587 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2588 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2589 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2590 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2591 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2592 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2593 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2594 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2595 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2596 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2597 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2598 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2599 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2600 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2601 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2602 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2603 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2604 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2605 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2606 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2607 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2608 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2609 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2610 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2611 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2612 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2613 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2614 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2615 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2616 createSMESHAction( 415, "MAP", "ICON_MAP" );
2617 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2618 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2619 createSMESHAction( 200, "RESET" );
2620 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2621 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2622 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2623 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2624 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2625 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2626 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2627 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2628 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2629 createSMESHAction( 220, "ALL" );
2630 createSMESHAction( 1100, "EDIT_HYPO" );
2631 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2632 createSMESHAction( 1102, "UNASSIGN" );
2633 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2634 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2635 createSMESHAction( 1131, "DISPMODE" );
2636 createSMESHAction( 1132, "COLORS" );
2637 createSMESHAction( 1133, "TRANSP" );
2638 createSMESHAction( 1134, "CLIP" );
2639 createSMESHAction( 1135, "DISP_ENT" );
2640 createSMESHAction( 1136, "AUTO_COLOR" );
2641 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2642 createSMESHAction( 2000, "CTRL" );
2644 createSMESHAction( 300, "ERASE" );
2645 createSMESHAction( 301, "DISPLAY" );
2646 createSMESHAction( 302, "DISPLAY_ONLY" );
2647 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2648 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2649 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2650 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2651 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2652 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2653 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2654 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2656 // ----- create menu --------------
2657 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2658 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2659 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2660 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2661 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2662 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2663 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2665 createMenu( separator(), fileId );
2667 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2668 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2669 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2670 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2671 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2672 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2674 createMenu( 111, importId, -1 );
2675 createMenu( 112, importId, -1 );
2676 createMenu( 113, importId, -1 );
2678 createMenu( 121, exportId, -1 );
2679 createMenu( 122, exportId, -1 );
2680 createMenu( 123, exportId, -1 );
2681 createMenu( 140, exportId, -1 ); // export to stl STL
2683 createMenu( separator(), fileId, 10 );
2685 createMenu( 33, editId, -1 );
2687 createMenu( 5105, toolsId, -1 );
2689 createMenu( 702, meshId, -1 ); // "Mesh" menu
2690 createMenu( 703, meshId, -1 );
2691 createMenu( 704, meshId, -1 );
2692 createMenu( 710, meshId, -1 );
2693 createMenu( separator(), meshId, -1 );
2694 createMenu( 701, meshId, -1 );
2695 createMenu( separator(), meshId, -1 );
2696 createMenu( 801, meshId, -1 );
2697 createMenu( 802, meshId, -1 );
2698 createMenu( 803, meshId, -1 );
2699 createMenu( separator(), meshId, -1 );
2700 createMenu( 810, meshId, -1 );
2701 createMenu( 811, meshId, -1 );
2702 createMenu( 812, meshId, -1 );
2703 createMenu( separator(), meshId, -1 );
2704 createMenu( 813, meshId, -1 );
2705 createMenu( separator(), meshId, -1 );
2706 createMenu( 900, meshId, -1 );
2707 createMenu( 902, meshId, -1 );
2708 createMenu( 903, meshId, -1 );
2709 createMenu( separator(), meshId, -1 );
2711 createMenu( 6003, ctrlId, -1 );
2712 createMenu( 6001, ctrlId, -1 );
2713 createMenu( 6004, ctrlId, -1 );
2714 createMenu( separator(), ctrlId, -1 );
2715 createMenu( 6002, ctrlId, -1 );
2716 createMenu( 6018, ctrlId, -1 );
2717 createMenu( 6019, ctrlId, -1 );
2718 createMenu( 6011, ctrlId, -1 );
2719 createMenu( 6012, ctrlId, -1 );
2720 createMenu( 6013, ctrlId, -1 );
2721 createMenu( 6014, ctrlId, -1 );
2722 createMenu( 6015, ctrlId, -1 );
2723 createMenu( 6016, ctrlId, -1 );
2724 createMenu( separator(), ctrlId, -1 );
2725 createMenu( 6017, ctrlId, -1 );
2726 createMenu( 6009, ctrlId, -1 );
2727 createMenu( separator(), ctrlId, -1 );
2729 createMenu( 400, addId, -1 );
2730 createMenu( 401, addId, -1 );
2731 createMenu( 4021, addId, -1 );
2732 createMenu( 4022, addId, -1 );
2733 createMenu( 4023, addId, -1 );
2734 createMenu( 4031, addId, -1 );
2735 createMenu( 4032, addId, -1 );
2736 createMenu( 4033, addId, -1 );
2737 createMenu( separator(), addId, -1 );
2738 createMenu( 4034, addId, -1 );
2739 createMenu( 4035, addId, -1 );
2740 createMenu( 4036, addId, -1 );
2741 createMenu( 4037, addId, -1 );
2742 createMenu( 4038, addId, -1 );
2743 createMenu( 4039, addId, -1 );
2744 createMenu( 4040, addId, -1 );
2746 createMenu( 4041, removeId, -1 );
2747 createMenu( 4042, removeId, -1 );
2748 createMenu( 4043, removeId, -1 );
2750 createMenu( 4051, renumId, -1 );
2751 createMenu( 4052, renumId, -1 );
2753 createMenu( 4061, transfId, -1 );
2754 createMenu( 4062, transfId, -1 );
2755 createMenu( 4063, transfId, -1 );
2756 createMenu( 4064, transfId, -1 );
2757 createMenu( 4065, transfId, -1 );
2758 createMenu( 4066, transfId, -1 );
2760 createMenu( 406, modifyId, -1 );
2761 createMenu( 4067,modifyId, -1 );
2762 createMenu( 407, modifyId, -1 );
2763 createMenu( 408, modifyId, -1 );
2764 createMenu( 409, modifyId, -1 );
2765 createMenu( 410, modifyId, -1 );
2766 createMenu( 411, modifyId, -1 );
2767 createMenu( 412, modifyId, -1 );
2768 createMenu( 413, modifyId, -1 );
2769 createMenu( 416, modifyId, -1 );
2770 createMenu( 414, modifyId, -1 );
2771 createMenu( 415, modifyId, -1 );
2772 createMenu( 417, modifyId, -1 );
2774 createMenu( 214, viewId, -1 );
2776 // ----- create toolbars --------------
2777 int meshTb = createTool( tr( "TB_MESH" ) ),
2778 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2779 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2780 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2781 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2783 createTool( 702, meshTb );
2784 createTool( 703, meshTb );
2785 createTool( 704, meshTb );
2786 createTool( 710, meshTb );
2787 createTool( separator(), meshTb );
2788 createTool( 701, meshTb );
2789 createTool( separator(), meshTb );
2790 createTool( 801, meshTb );
2791 createTool( 802, meshTb );
2792 createTool( 803, meshTb );
2793 createTool( separator(), meshTb );
2794 createTool( 900, meshTb );
2795 createTool( 902, meshTb );
2796 createTool( 903, meshTb );
2797 createTool( separator(), meshTb );
2799 createTool( 6001, ctrlTb );
2800 createTool( 6003, ctrlTb );
2801 createTool( 6004, ctrlTb );
2802 createTool( separator(), ctrlTb );
2803 createTool( 6002, ctrlTb );
2804 createTool( 6018, ctrlTb );
2805 createTool( 6019, ctrlTb );
2806 createTool( 6011, ctrlTb );
2807 createTool( 6012, ctrlTb );
2808 createTool( 6013, ctrlTb );
2809 createTool( 6014, ctrlTb );
2810 createTool( 6015, ctrlTb );
2811 createTool( 6016, ctrlTb );
2812 createTool( separator(), ctrlTb );
2813 createTool( 6017, ctrlTb );
2814 createTool( 6009, ctrlTb );
2815 createTool( separator(), ctrlTb );
2817 createTool( 400, addRemTb );
2818 createTool( 401, addRemTb );
2819 createTool( 4021, addRemTb );
2820 createTool( 4022, addRemTb );
2821 createTool( 4023, addRemTb );
2822 createTool( 4031, addRemTb );
2823 createTool( 4032, addRemTb );
2824 createTool( 4033, addRemTb );
2825 createTool( separator(), addRemTb );
2826 createTool( 4034, addRemTb );
2827 createTool( 4035, addRemTb );
2828 createTool( 4036, addRemTb );
2829 createTool( 4037, addRemTb );
2830 createTool( 4038, addRemTb );
2831 createTool( 4039, addRemTb );
2832 createTool( 4040, addRemTb );
2833 createTool( separator(), addRemTb );
2834 createTool( 4041, addRemTb );
2835 createTool( 4042, addRemTb );
2836 createTool( 4043, addRemTb );
2837 createTool( separator(), addRemTb );
2838 createTool( 4051, addRemTb );
2839 createTool( 4052, addRemTb );
2840 createTool( separator(), addRemTb );
2841 createTool( 4061, addRemTb );
2842 createTool( 4062, addRemTb );
2843 createTool( 4063, addRemTb );
2844 createTool( 4064, addRemTb );
2845 createTool( 4065, addRemTb );
2846 createTool( 4066, addRemTb );
2847 createTool( separator(), addRemTb );
2849 createTool( 406, modifyTb );
2850 createTool( 4067,modifyTb );
2851 createTool( 407, modifyTb );
2852 createTool( 408, modifyTb );
2853 createTool( 409, modifyTb );
2854 createTool( 410, modifyTb );
2855 createTool( 411, modifyTb );
2856 createTool( 412, modifyTb );
2857 createTool( 413, modifyTb );
2858 createTool( 416, modifyTb );
2859 createTool( 414, modifyTb );
2860 createTool( 415, modifyTb );
2861 createTool( 417, modifyTb );
2863 createTool( 214, dispModeTb );
2867 QString OB = "'ObjectBrowser'",
2868 View = "'" + SVTK_Viewer::Type() + "'",
2870 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2871 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2872 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2873 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2874 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2875 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2876 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2877 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2878 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2879 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2880 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2882 mesh_group = mesh + " " + subMesh + " " + group,
2883 hyp_alg = hypo + " " + algo;
2885 // popup for object browser
2887 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2889 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2890 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2891 createPopupItem( 803, OB, group ); // EDIT_GROUP
2892 popupMgr()->insert( separator(), -1, 0 );
2893 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2894 createPopupItem( 214, OB, mesh_group ); // UPDATE
2895 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2896 createPopupItem( 902, OB, mesh ); // STD_INFO
2897 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2898 popupMgr()->insert( separator(), -1, 0 );
2899 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2900 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2901 popupMgr()->insert( separator(), -1, 0 );
2902 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2903 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2904 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2905 popupMgr()->insert( separator(), -1, 0 );
2906 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2907 popupMgr()->insert( separator(), -1, 0 );
2909 QString nbSelected = QtxPopupMgr::Selection::defSelCountParam();
2910 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( nbSelected );
2912 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2913 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2914 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2915 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2916 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2917 popupMgr()->insert( separator(), -1, 0 );
2920 createPopupItem( 803, View, group ); // EDIT_GROUP
2921 createPopupItem( 804, View, elems ); // ADD
2922 createPopupItem( 805, View, elems ); // REMOVE
2923 popupMgr()->insert( separator(), -1, 0 );
2924 createPopupItem( 214, View, mesh_group ); // UPDATE
2925 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2926 createPopupItem( 902, View, mesh ); // STD_INFO
2927 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2928 popupMgr()->insert( separator(), -1, 0 );
2930 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2931 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2932 popupMgr()->insert( separator(), -1, 0 );
2936 isInvisible("not( isVisible )"),
2937 isEmpty("numberOfNodes = 0"),
2938 isNotEmpty("numberOfNodes <> 0"),
2940 // has nodes, edges, etc in VISIBLE! actor
2941 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2942 hasElems("(count( elemTypes ) > 0)"),
2943 hasDifferentElems("(count( elemTypes ) > 1)"),
2944 hasEdges("({'Edge'} in elemTypes)"),
2945 hasFaces("({'Face'} in elemTypes)"),
2946 hasVolumes("({'Volume'} in elemTypes)");
2948 QString lc = QtxPopupMgr::Selection::defEquality();
2949 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2950 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2951 aType = aType.arg( mesh_group );
2952 QString aMeshInVTK = aClient + "&&" + aType;
2954 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2955 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2956 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2958 //-------------------------------------------------
2960 //-------------------------------------------------
2961 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2963 popupMgr()->insert( action( 9010 ), anId, -1 );
2964 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2965 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2967 popupMgr()->insert( action( 9011 ), anId, -1 );
2968 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2969 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2971 popupMgr()->insert( separator(), -1, -1 );
2973 //-------------------------------------------------
2975 //-------------------------------------------------
2976 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2978 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2979 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2980 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2982 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2983 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2984 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2986 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2987 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2988 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2990 popupMgr()->insert( separator(), anId, -1 );
2992 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2993 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2994 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2996 //-------------------------------------------------
2998 //-------------------------------------------------
2999 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3001 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3003 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3004 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
3005 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
3007 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3008 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
3009 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
3011 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3012 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
3013 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
3015 popupMgr()->insert( separator(), anId, -1 );
3017 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3018 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
3020 //-------------------------------------------------
3022 //-------------------------------------------------
3023 popupMgr()->insert( action( 1132 ), -1, -1 );
3024 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
3026 //-------------------------------------------------
3028 //-------------------------------------------------
3029 popupMgr()->insert( action( 1133 ), -1, -1 );
3030 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
3032 //-------------------------------------------------
3034 //-------------------------------------------------
3035 popupMgr()->insert( action( 1134 ), -1, -1 );
3036 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
3038 popupMgr()->insert( separator(), -1, -1 );
3040 //-------------------------------------------------
3042 //-------------------------------------------------
3044 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3045 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3046 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3048 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3050 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3051 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3053 popupMgr()->insert( separator(), anId, -1 );
3055 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3056 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
3057 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
3059 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3060 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
3061 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
3063 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3064 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
3065 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
3067 popupMgr()->insert( separator(), anId, -1 );
3069 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3070 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
3071 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
3073 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3074 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
3075 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
3077 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3078 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3079 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3081 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3082 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3083 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3085 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3086 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3087 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3089 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3090 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3091 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3093 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3094 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3095 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3097 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3098 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3099 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3101 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3102 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3103 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3105 popupMgr()->insert( separator(), anId, -1 );
3107 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3108 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3109 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3111 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3112 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3113 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3115 popupMgr()->insert( separator(), anId, -1 );
3117 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3118 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3120 popupMgr()->insert( separator(), -1, -1 );
3122 //-------------------------------------------------
3124 //-------------------------------------------------
3125 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3126 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3127 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3128 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3130 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3131 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3133 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3134 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3136 popupMgr()->insert( separator(), -1, -1 );
3138 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3139 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3142 //================================================================================
3144 * \brief Return true if SMESH or GEOM objects are selected.
3145 * Is called form LightApp_Module::activateModule() which clear selection if
3146 * not isSelectionCompatible()
3148 //================================================================================
3150 bool SMESHGUI::isSelectionCompatible()
3152 bool isCompatible = true;
3153 SALOME_ListIO selected;
3154 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3155 Sel->selectedObjects( selected );
3157 SALOME_ListIteratorOfListIO It( selected );
3158 for ( ; isCompatible && It.More(); It.Next())
3160 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3161 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3163 return isCompatible;
3166 bool SMESHGUI::activateModule( SUIT_Study* study )
3168 bool res = SalomeApp_Module::activateModule( study );
3170 setMenuShown( true );
3171 setToolShown( true );
3173 // Reset actions accelerator keys
3174 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3175 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3176 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3178 action( 33)->setEnabled(true); // Delete: Key_Delete
3179 action(1101)->setEnabled(true); // Rename: Key_F2
3184 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3186 setMenuShown( false );
3187 setToolShown( false );
3189 EmitSignalCloseAllDialogs();
3191 // Unset actions accelerator keys
3192 action(111)->setAccel(QKeySequence()); // Import DAT
3193 action(112)->setAccel(QKeySequence()); // Import UNV
3194 action(113)->setAccel(QKeySequence()); // Import MED
3196 action( 33)->setEnabled(false); // Delete: Key_Delete
3197 action(1101)->setEnabled(false); // Rename: Key_F2
3199 return SalomeApp_Module::deactivateModule( study );
3202 void SMESHGUI::studyClosed( SUIT_Study* s )
3204 SMESH::RemoveVisuData( s->id() );
3205 SalomeApp_Module::studyClosed( s );
3208 void SMESHGUI::OnGUIEvent()
3210 const QObject* obj = sender();
3211 if ( !obj || !obj->inherits( "QAction" ) )
3213 int id = actionId((QAction*)obj);
3218 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3220 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3221 if ( CORBA::is_nil( myComponentSMESH ) )
3223 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3225 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3226 return aGUI.myComponentSMESH;
3229 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3230 return myComponentSMESH;
3233 QString SMESHGUI::engineIOR() const
3235 CORBA::ORB_var anORB = getApp()->orb();
3236 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3237 return QString( anIOR.in() );
3240 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
3242 SMESHGUI_Selection sel;
3243 sel.init( client, selectionMgr() );
3244 popupMgr()->updatePopup( menu, &sel );
3247 selectionMgr()->selectedObjects( lst );
3248 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3249 Handle(SALOME_InteractiveObject) io = lst.First();
3250 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3251 _PTR(Study) study = appStudy->studyDS();
3252 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3254 QString aName = QString( obj->GetName().c_str() );
3255 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3256 aName.remove( (aName.length() - 1), 1 );
3262 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3264 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3265 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3268 void SMESHGUI::viewManagers( QStringList& list ) const
3270 list.append( SVTK_Viewer::Type() );
3273 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3275 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3276 SMESH::UpdateSelectionProp( this );
3279 void SMESHGUI::createPreferences()
3281 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3283 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3284 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3286 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3287 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3288 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3290 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3291 setPreferenceProperty( precGroup, "columns", 1 );
3293 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3295 setPreferenceProperty( prec, "min", 0 );
3296 setPreferenceProperty( prec, "max", 16 );
3298 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3299 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3301 modes.append( "Wireframe" );
3302 modes.append( "Shading" );
3303 modes.append( "Nodes" );
3304 modes.append( "Shrink" );
3305 QValueList<QVariant> indices;
3306 indices.append( 0 );
3307 indices.append( 1 );
3308 indices.append( 2 );
3309 indices.append( 3 );
3310 setPreferenceProperty( dispmode, "strings", modes );
3311 setPreferenceProperty( dispmode, "indexes", indices );
3313 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3314 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3315 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3317 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3318 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3320 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3321 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3323 setPreferenceProperty( nodeSz, "min", 1 );
3324 setPreferenceProperty( nodeSz, "max", 5 );
3326 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3328 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3329 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3330 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3331 addPreference( "", elemGroup, LightApp_Preferences::Space );
3333 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3334 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3336 setPreferenceProperty( elemW, "min", 1 );
3337 setPreferenceProperty( elemW, "max", 5 );
3339 setPreferenceProperty( shrink, "min", 0 );
3340 setPreferenceProperty( shrink, "max", 100 );
3342 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3344 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3346 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3347 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3348 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3350 setPreferenceProperty( selW, "min", 1 );
3351 setPreferenceProperty( selW, "max", 5 );
3353 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3355 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3356 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3358 setPreferenceProperty( preW, "min", 1 );
3359 setPreferenceProperty( preW, "max", 5 );
3361 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3363 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3364 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3365 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3367 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3368 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3370 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3371 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3372 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3373 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3376 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3377 fam.append( tr( "SMESH_FONT_COURIER" ) );
3378 fam.append( tr( "SMESH_FONT_TIMES" ) );
3379 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3381 setPreferenceProperty( tfont, "families", fam );
3382 setPreferenceProperty( tfont, "system", false );
3383 setPreferenceProperty( tfont, "widget_flags", wflag );
3384 setPreferenceProperty( lfont, "families", fam );
3385 setPreferenceProperty( lfont, "system", false );
3386 setPreferenceProperty( lfont, "widget_flags", wflag );
3388 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3390 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3391 setPreferenceProperty( numcol, "min", 2 );
3392 setPreferenceProperty( numcol, "max", 256 );
3394 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3395 setPreferenceProperty( numlab, "min", 2 );
3396 setPreferenceProperty( numlab, "max", 65 );
3398 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3399 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3400 QStringList orients;
3401 orients.append( tr( "SMESH_VERTICAL" ) );
3402 orients.append( tr( "SMESH_HORIZONTAL" ) );
3403 indices.clear(); indices.append( 0 ); indices.append( 1 );
3404 setPreferenceProperty( orient, "strings", orients );
3405 setPreferenceProperty( orient, "indexes", indices );
3407 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3408 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3409 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3410 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3411 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3412 setPreferenceProperty( xv, "step", 0.1 );
3413 setPreferenceProperty( xv, "min", 0.0 );
3414 setPreferenceProperty( xv, "max", 1.0 );
3415 setPreferenceProperty( yv, "step", 0.1 );
3416 setPreferenceProperty( yv, "min", 0.0 );
3417 setPreferenceProperty( yv, "max", 1.0 );
3418 setPreferenceProperty( wv, "step", 0.1 );
3419 setPreferenceProperty( wv, "min", 0.0 );
3420 setPreferenceProperty( wv, "max", 1.0 );
3421 setPreferenceProperty( hv, "min", 0.0 );
3422 setPreferenceProperty( hv, "max", 1.0 );
3423 setPreferenceProperty( hv, "step", 0.1 );
3425 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3426 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3427 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3428 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3429 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3430 setPreferenceProperty( xv, "min", 0.0 );
3431 setPreferenceProperty( xv, "max", 1.0 );
3432 setPreferenceProperty( xv, "step", 0.1 );
3433 setPreferenceProperty( xh, "min", 0.0 );
3434 setPreferenceProperty( xh, "max", 1.0 );
3435 setPreferenceProperty( xh, "step", 0.1 );
3436 setPreferenceProperty( yh, "min", 0.0 );
3437 setPreferenceProperty( yh, "max", 1.0 );
3438 setPreferenceProperty( yh, "step", 0.1 );
3439 setPreferenceProperty( wh, "min", 0.0 );
3440 setPreferenceProperty( wh, "max", 1.0 );
3441 setPreferenceProperty( wh, "step", 0.1 );
3442 setPreferenceProperty( hh, "min", 0.0 );
3443 setPreferenceProperty( hh, "max", 1.0 );
3444 setPreferenceProperty( hh, "step", 0.1 );
3447 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3449 if( sect=="SMESH" ){
3450 float sbX1,sbY1,sbW,sbH;
3451 float aTol = 1.00000009999999;
3452 std::string aWarning;
3453 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3454 if( name=="selection_object_color" || name=="selection_element_color" ||
3455 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3456 name=="selection_precision_node" || name=="selection_precision_element" ||
3457 name=="selection_precision_object")
3458 SMESH::UpdateSelectionProp( this );
3459 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3460 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3461 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3462 if(sbX1+sbW > aTol){
3463 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3466 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3467 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3470 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3471 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3472 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3473 if(sbY1+sbH > aTol){
3474 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3475 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3476 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3479 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3480 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3481 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3482 if(sbX1+sbW > aTol){
3483 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3486 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3487 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3490 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3491 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3492 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3493 if(sbY1+sbH > aTol){
3494 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3497 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3498 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3502 if(aWarning.size() != 0){
3503 aWarning += "The default values are applied instead.";
3504 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3505 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3506 QObject::tr(aWarning.c_str()),
3507 QObject::tr("SMESH_BUT_OK"));
3512 //================================================================================
3514 * \brief Update something in accordance with update flags
3515 * \param theFlags - update flags
3517 * Update viewer or/and object browser etc. in accordance with update flags ( see
3518 * LightApp_UpdateFlags enumeration ).
3520 //================================================================================
3521 void SMESHGUI::update( const int flags )
3523 if ( flags & UF_Viewer | flags & UF_Forced )
3524 SMESH::UpdateView();
3526 SalomeApp_Module::update( flags );
3529 //================================================================================
3531 * \brief Set default selection mode
3533 * SLOT called when operation commited. Sets default selection mode
3535 //================================================================================
3536 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3538 SVTK_ViewWindow* vtkWnd =
3539 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3541 vtkWnd->SetSelectionMode( ActorSelection );
3544 //================================================================================
3546 * \brief Set default selection mode
3548 * SLOT called when operation aborted. Sets default selection mode
3550 //================================================================================
3551 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3553 SVTK_ViewWindow* vtkWnd =
3554 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3556 vtkWnd->SetSelectionMode( ActorSelection );
3559 //================================================================================
3561 * \brief Creates operation with given identifier
3562 * \param id - identifier of operation to be started
3563 * \return Pointer on created operation or NULL if operation is not created
3565 * Virtual method redefined from the base class creates operation with given id.
3566 * It is called called automatically from startOperation method of base class.
3568 //================================================================================
3569 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3571 LightApp_Operation* op = 0;
3572 // to do : create operation here
3575 case 701: // Compute mesh
3576 op = new SMESHGUI_ComputeOp();
3578 case 702: // Create mesh
3579 op = new SMESHGUI_MeshOp( true, true );
3581 case 703: // Create sub-mesh
3582 op = new SMESHGUI_MeshOp( true, false );
3584 case 704: // Edit mesh/sub-mesh
3585 op = new SMESHGUI_MeshOp( false );
3587 case 417: //convert to quadratic
3588 op = new SMESHGUI_ConvToQuadOp();
3590 case 4067: // make mesh pass through point
3591 op = new SMESHGUI_MakeNodeAtPointOp();
3598 op = SalomeApp_Module::createOperation( id );
3602 //================================================================================
3604 * \brief Stops current operations and starts a given one
3605 * \param id - The id of the operation to start
3607 //================================================================================
3609 void SMESHGUI::switchToOperation(int id)
3611 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3612 activeStudy()->abortAllOperations();
3613 startOperation( id );
3616 LightApp_Displayer* SMESHGUI::displayer()
3619 myDisplayer = new SMESHGUI_Displayer( getApp() );
3623 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3626 int aTolerance = 64;
3627 int anIterations = 0;
3633 if( anIterations % aPeriod == 0 )
3636 if( aTolerance < 1 )
3639 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3641 aHue = (int)( 360.0 * rand() / RAND_MAX );
3642 //cout << "Hue = " << aHue << endl;
3644 //cout << "Auto colors : ";
3646 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3647 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3648 for( ; it != itEnd; ++it )
3650 SALOMEDS::Color anAutoColor = *it;
3651 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3654 aQColor.getHsv( &h, &s, &v );
3656 if( abs( h - aHue ) < aTolerance )
3659 //cout << "break (diff = " << abs( h - aHue ) << ")";
3669 //cout << "Hue of the returned color = " << aHue << endl;
3671 aColor.setHsv( aHue, 255, 255 );
3673 SALOMEDS::Color aSColor;
3674 aSColor.R = (double)aColor.red() / 255.0;
3675 aSColor.G = (double)aColor.green() / 255.0;
3676 aSColor.B = (double)aColor.blue() / 255.0;