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)"));
186 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
189 QObject::tr("Import mesh"),
191 if(!filename.isEmpty()) {
192 SUIT_OverrideCursor wc;
193 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
196 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
197 switch ( theCommandID ) {
200 aMeshes->length( 1 );
201 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
206 SMESH::DriverMED_ReadStatus res;
207 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
208 if ( res != SMESH::DRS_OK ) {
210 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
211 QObject::tr("SMESH_WRN_WARNING"),
212 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
213 QObject::tr("SMESH_BUT_OK"));
214 aMeshes->length( 0 );
221 bool isEmpty = false;
222 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
223 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
225 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
226 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
227 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
228 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
229 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
236 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
237 QObject::tr("SMESH_WRN_WARNING"),
238 QObject::tr("SMESH_DRS_EMPTY"),
239 QObject::tr("SMESH_BUT_OK"));
243 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
245 catch (const SALOME::SALOME_Exception& S_ex){
247 SalomeApp_Tools::QtCatchCorbaException(S_ex);
254 void ExportMeshToFile( int theCommandID )
256 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
257 SALOME_ListIO selected;
259 aSel->selectedObjects( selected );
261 if(selected.Extent()){
262 Handle(SALOME_InteractiveObject) anIObject = selected.First();
263 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
264 if ( !aMesh->_is_nil() ) {
265 QString aFilter, aTitle = QObject::tr("Export mesh");
266 QMap<QString, SMESH::MED_VERSION> aFilterMap;
267 QMap<QString, int> aFilterMapSTL;
268 switch ( theCommandID ) {
272 if (aMesh->HasDuplicatedGroupNamesMED()) {
273 int aRet = SUIT_MessageBox::warn2
274 (SMESHGUI::desktop(),
275 QObject::tr("SMESH_WRN_WARNING"),
276 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
277 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
283 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
284 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
285 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
286 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
291 aFilter = QObject::tr("DAT files (*.dat)");
296 if (aMesh->NbPyramids()) {
297 int aRet = SUIT_MessageBox::warn2
298 (SMESHGUI::desktop(),
299 QObject::tr("SMESH_WRN_WARNING"),
300 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
301 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
306 aFilter = QObject::tr("IDEAS files (*.unv)");
314 there must be check on others mesh elements not equal triangles
316 if (aMesh->NbTriangles() < 1) {
317 SUIT_MessageBox::warn1
318 (SMESHGUI::desktop(),
319 QObject::tr("SMESH_WRN_WARNING"),
320 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
321 QObject::tr("SMESH_BUT_OK"));
324 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
325 int aRet = SUIT_MessageBox::warn2
326 (SMESHGUI::desktop(),
327 QObject::tr("SMESH_WRN_WARNING"),
328 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
329 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
335 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
336 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
344 SMESH::MED_VERSION aFormat;
345 // Init the parameter with the default value
346 bool aIsASCII_STL = true;
347 bool toCreateGroups = false;
348 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
350 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
352 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
354 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
356 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
358 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
359 for ( ; it != aFilterMapSTL.end(); ++it )
360 filters.push_back( it.key() );
362 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
363 fd->setCaption( aTitle );
364 fd->setFilters( filters );
365 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
369 aFilename = fd->selectedFile();
370 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
377 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
378 for ( ; it != aFilterMap.end(); ++it )
379 filters.push_back( it.key() );
381 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
382 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
383 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
384 fd->setCaption( aTitle );
385 fd->setFilters( filters );
386 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
387 fd->SetChecked(toCreateGroups);
391 aFilename = fd->selectedFile();
392 aFormat = aFilterMap[fd->selectedFilter()];
394 if ( !aFilename.isEmpty()
395 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
396 && aFormat==SMESH::MED_V2_1) {
397 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
398 QObject::tr("SMESH_WRN_WARNING"),
399 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
400 QObject::tr("SMESH_BUT_YES"),
401 QObject::tr("SMESH_BUT_NO"),
408 toCreateGroups = fd->IsChecked();
411 if ( !aFilename.isEmpty() ) {
412 // Check whether the file already exists and delete it if yes
413 QFile aFile( aFilename );
414 if ( aFile.exists() )
416 SUIT_OverrideCursor wc;
419 bool Renumber = false ;
420 // PAL 14172 : Check of we have to renumber or not from the preferences before export
422 Renumber= resMgr->booleanValue("SMESH","renumbering");
424 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
425 aMeshEditor->RenumberNodes();
426 aMeshEditor->RenumberElements();
427 if ( SMESHGUI::automaticUpdate() )
430 switch ( theCommandID ) {
433 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
437 aMesh->ExportDAT( aFilename.latin1() );
441 aMesh->ExportUNV( aFilename.latin1() );
445 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
451 catch (const SALOME::SALOME_Exception& S_ex){
453 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
454 QObject::tr("SMESH_WRN_WARNING"),
455 QObject::tr("SMESH_EXPORT_FAILED"),
456 QObject::tr("SMESH_BUT_OK"));
464 inline void InverseEntityMode(unsigned int& theOutputMode,
465 unsigned int theMode)
467 bool anIsNotPresent = ~theOutputMode & theMode;
469 theOutputMode |= theMode;
471 theOutputMode &= ~theMode;
474 void SetDisplayEntity(int theCommandID){
475 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
476 SALOME_ListIO selected;
478 aSel->selectedObjects( selected );
480 if(selected.Extent() >= 1){
481 SALOME_ListIteratorOfListIO It( selected );
482 for(; It.More(); It.Next()){
483 Handle(SALOME_InteractiveObject) IObject = It.Value();
484 if(IObject->hasEntry()){
485 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
486 unsigned int aMode = anActor->GetEntityMode();
487 switch(theCommandID){
489 InverseEntityMode(aMode,SMESH_Actor::eEdges);
492 InverseEntityMode(aMode,SMESH_Actor::eFaces);
495 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
498 aMode = SMESH_Actor::eAllEntity;
502 anActor->SetEntityMode(aMode);
510 SALOME_ListIO selected;
511 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
515 LightApp_SelectionMgr* aSel = app->selectionMgr();
516 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
517 if( !aSel || !appStudy )
520 aSel->selectedObjects( selected );
521 if( selected.IsEmpty() )
524 Handle(SALOME_InteractiveObject) anIObject = selected.First();
526 _PTR(Study) aStudy = appStudy->studyDS();
527 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
528 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
529 if( aMainObject->_is_nil() )
532 aMainObject->SetAutoColor( true );
534 QValueList<SALOMEDS::Color> aReservedColors;
536 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
537 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
539 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
540 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
542 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
543 aGroupObject->SetColor( aColor );
544 aReservedColors.append( aColor );
546 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
547 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
549 if( aGroupObject->GetType() == SMESH::NODE )
550 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
551 else if( aGroupObject->GetType() == SMESH::EDGE )
552 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
554 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
558 SMESH::RepaintCurrentView();
561 void DisableAutoColor(){
562 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
563 SALOME_ListIO selected;
565 aSel->selectedObjects( selected );
567 if(selected.Extent()){
568 Handle(SALOME_InteractiveObject) anIObject = selected.First();
569 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
570 if ( !aMesh->_is_nil() ) {
571 aMesh->SetAutoColor( false );
576 void SetDisplayMode(int theCommandID){
577 SALOME_ListIO selected;
578 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
582 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
583 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
584 if( !aSel || !appStudy )
587 _PTR(Study) aStudy = appStudy->studyDS();
589 aSel->selectedObjects( selected );
591 if(selected.Extent() >= 1){
592 switch(theCommandID){
594 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
595 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
599 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
600 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
603 SALOME_ListIteratorOfListIO It( selected );
604 for(; It.More(); It.Next()){
605 Handle(SALOME_InteractiveObject) IObject = It.Value();
606 if(IObject->hasEntry()){
607 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
608 switch(theCommandID){
610 anActor->SetRepresentation(SMESH_Actor::eEdge);
613 anActor->SetRepresentation(SMESH_Actor::eSurface);
616 if(anActor->IsShrunk())
619 anActor->SetShrink();
622 anActor->SetRepresentation(SMESH_Actor::ePoint);
625 vtkFloatingPointType color[3];
626 anActor->GetSufaceColor(color[0], color[1], color[2]);
627 int c0 = int (color[0] * 255);
628 int c1 = int (color[1] * 255);
629 int c2 = int (color[2] * 255);
630 QColor c(c0, c1, c2);
632 vtkFloatingPointType edgecolor[3];
633 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
634 c0 = int (edgecolor[0] * 255);
635 c1 = int (edgecolor[1] * 255);
636 c2 = int (edgecolor[2] * 255);
637 QColor e(c0, c1, c2);
639 vtkFloatingPointType backfacecolor[3];
640 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
641 c0 = int (backfacecolor[0] * 255);
642 c1 = int (backfacecolor[1] * 255);
643 c2 = int (backfacecolor[2] * 255);
644 QColor b(c0, c1, c2);
646 vtkFloatingPointType nodecolor[3];
647 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
648 c0 = int (nodecolor[0] * 255);
649 c1 = int (nodecolor[1] * 255);
650 c2 = int (nodecolor[2] * 255);
651 QColor n(c0, c1, c2);
653 int Edgewidth = (int)anActor->GetLineWidth();
656 int intValue = int(anActor->GetNodeSize());
657 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
659 SMESHGUI_Preferences_ColorDlg *aDlg =
660 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
661 aDlg->SetColor(1, c);
662 aDlg->SetColor(2, e);
663 aDlg->SetColor(3, n);
664 aDlg->SetColor(4, b);
665 aDlg->SetIntValue(1, Edgewidth);
666 aDlg->SetIntValue(2, intValue);
667 aDlg->SetIntValue(3, int(Shrink*100.));
669 QColor color = aDlg->GetColor(1);
670 QColor edgecolor = aDlg->GetColor(2);
671 QColor nodecolor = aDlg->GetColor(3);
672 QColor backfacecolor = aDlg->GetColor(4);
673 /* actor color and backface color */
674 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
675 vtkFloatingPointType (color.green()) / 255.,
676 vtkFloatingPointType (color.blue()) / 255.);
677 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
678 vtkFloatingPointType (backfacecolor.green()) / 255.,
679 vtkFloatingPointType (backfacecolor.blue()) / 255.);
682 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
683 vtkFloatingPointType (edgecolor.green()) / 255.,
684 vtkFloatingPointType (edgecolor.blue()) / 255.);
686 /* Shrink factor and size edges */
687 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
688 anActor->SetLineWidth(aDlg->GetIntValue(1));
690 /* Nodes color and size */
691 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
692 vtkFloatingPointType (nodecolor.green()) / 255.,
693 vtkFloatingPointType (nodecolor.blue()) / 255.);
694 anActor->SetNodeSize(aDlg->GetIntValue(2));
696 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
697 if( !aGroupObject->_is_nil() )
699 SALOMEDS::Color aColor;
700 aColor.R = (float)color.red() / 255.0;
701 aColor.G = (float)color.green() / 255.0;
702 aColor.B = (float)color.blue() / 255.0;
703 aGroupObject->SetColor( aColor );
713 SMESH::RepaintCurrentView();
717 void Control( int theCommandID )
719 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
720 SALOME_ListIO selected;
722 aSel->selectedObjects( selected );
724 if( !selected.IsEmpty() ){
725 Handle(SALOME_InteractiveObject) anIO = selected.First();
728 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
729 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
730 switch ( theCommandID ){
732 aTitle = QObject::tr( "LENGTH_EDGES" );
733 aControl = SMESH_Actor::eLength;
736 aTitle = QObject::tr( "LENGTH2D_EDGES" );
737 aControl = SMESH_Actor::eLength2D;
740 aTitle = QObject::tr( "FREE_EDGES" );
741 aControl = SMESH_Actor::eFreeEdges;
744 aTitle = QObject::tr( "FREE_BORDERS" );
745 aControl = SMESH_Actor::eFreeBorders;
748 aTitle = QObject::tr( "MULTI_BORDERS" );
749 aControl = SMESH_Actor::eMultiConnection;
752 aTitle = QObject::tr( "MULTI2D_BORDERS" );
753 aControl = SMESH_Actor::eMultiConnection2D;
756 aTitle = QObject::tr( "AREA_ELEMENTS" );
757 aControl = SMESH_Actor::eArea;
760 aTitle = QObject::tr( "TAPER_ELEMENTS" );
761 aControl = SMESH_Actor::eTaper;
764 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
765 aControl = SMESH_Actor::eAspectRatio;
768 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
769 aControl = SMESH_Actor::eAspectRatio3D;
772 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
773 aControl = SMESH_Actor::eMinimumAngle;
776 aTitle = QObject::tr( "WARP_ELEMENTS" );
777 aControl = SMESH_Actor::eWarping;
780 aTitle = QObject::tr( "SKEW_ELEMENTS" );
781 aControl = SMESH_Actor::eSkew;
784 aTitle = QObject::tr( "SMESH_VOLUME" );
785 aControl = SMESH_Actor::eVolume3D;
788 anActor->SetControlMode(aControl);
789 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
790 SMESH::RepaintCurrentView();
797 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
798 MeshObjectType theType,
799 const QString theInTypeName,
800 QString & theOutTypeName)
802 SMESH_TypeFilter aTypeFilter( theType );
804 if( !theIO.IsNull() )
806 entry = theIO->getEntry();
807 LightApp_DataOwner owner( entry );
808 if ( aTypeFilter.isOk( &owner )) {
809 theOutTypeName = theInTypeName;
817 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
819 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
820 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
822 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
823 CORBA::String_var anID = aSComp->GetID().c_str();
824 if (!strcmp(anID.in(),theIO->getEntry()))
830 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
831 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
832 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
833 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
834 CheckOIType ( theIO, GROUP, "Group", aTypeName )
842 QString CheckHomogeneousSelection()
844 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
845 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
846 SALOME_ListIO selected;
848 aSel->selectedObjects( selected );
850 QString RefType = CheckTypeObject(selected.First());
851 SALOME_ListIteratorOfListIO It(selected);
852 for (; It.More(); It.Next())
854 Handle(SALOME_InteractiveObject) IObject = It.Value();
855 QString Type = CheckTypeObject(IObject);
856 if (Type.compare(RefType) != 0)
857 return "Heterogeneous Selection";
864 void SMESHGUI::OnEditDelete()
866 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
867 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
868 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
870 QString aParentComponent = QString::null;
871 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
873 QString cur = anIt.Value()->getComponentDataType();
874 if( aParentComponent.isNull() )
875 aParentComponent = cur;
876 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
877 aParentComponent = "";
880 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
881 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
882 QObject::tr("ERR_ERROR"),
883 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
884 QObject::tr("BUT_OK") );
887 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
888 if (SUIT_MessageBox::warn2
889 (SMESHGUI::desktop(),
890 QObject::tr("SMESH_WRN_WARNING"),
891 QObject::tr("SMESH_REALLY_DELETE"),
892 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
895 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
896 SUIT_ViewManager* vm = anApp->activeViewManager();
897 int nbSf = vm->getViewsCount();
899 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
900 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
901 _PTR(GenericAttribute) anAttr;
902 _PTR(AttributeIOR) anIOR;
904 SALOME_ListIteratorOfListIO It(selected);
906 aStudyBuilder->NewCommand(); // There is a transaction
907 for(; It.More(); It.Next()){ // loop on selected IO's
908 Handle(SALOME_InteractiveObject) IObject = It.Value();
909 if(IObject->hasEntry()) {
910 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
912 // disable removal of "SMESH" component object
913 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
915 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
919 // put the whole hierarchy of sub-objects of the selected SO into a list and
920 // then treat them all starting from the deepest objects (at list back)
922 list< _PTR(SObject) > listSO;
923 listSO.push_back( aSO );
924 list< _PTR(SObject) >::iterator itSO = listSO.begin();
925 for ( ; itSO != listSO.end(); ++itSO ) {
926 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
927 for (it->InitEx(false); it->More(); it->Next())
928 listSO.push_back( it->Value() );
931 // treat SO's in the list starting from the back
933 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
934 for ( ; ritSO != listSO.rend(); ++ritSO ) {
935 _PTR(SObject) SO = *ritSO;
937 string anEntry = SO->GetID();
939 /** Erase graphical object **/
940 if(SO->FindAttribute(anAttr, "AttributeIOR")){
941 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
942 for(int i = 0; i < nbSf; i++){
943 SUIT_ViewWindow *sf = aViews[i];
944 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
945 SMESH::RemoveActor(sf,anActor);
950 /** Remove an object from data structures **/
951 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
952 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
953 if ( !aGroup->_is_nil() ) { // DELETE GROUP
954 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
955 aMesh->RemoveGroup( aGroup );
957 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
958 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
959 aMesh->RemoveSubMesh( aSubMesh );
961 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
963 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
966 IObject = new SALOME_InteractiveObject
967 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
968 QString objType = CheckTypeObject(IObject);
969 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
970 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
971 aStudyBuilder->RemoveObjectWithChildren( SO );
973 else {// default action: remove SObject from the study
974 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
975 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
977 aStudyBuilder->RemoveObjectWithChildren( SO );
981 } /* listSO back loop */
982 } /* IObject->hasEntry() */
984 aStudyBuilder->CommitCommand();
986 /* Clear any previous selection */
988 aSel->setSelectedObjects( l1 );
990 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
995 SMESHGUI_EXPORT CAM_Module* createModule()
997 return new SMESHGUI();
1001 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1003 //=============================================================================
1007 //=============================================================================
1008 SMESHGUI::SMESHGUI() :
1009 SalomeApp_Module( "SMESH" )
1011 if ( CORBA::is_nil( myComponentSMESH ) )
1013 CORBA::Boolean anIsEmbeddedMode;
1014 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1017 myActiveDialogBox = 0;
1018 myFilterLibraryDlg = 0;
1022 SMESH::GetFilterManager();
1023 SMESH::GetPattern();
1025 /* load resources for all available meshers */
1026 SMESH::InitAvailableHypotheses();
1029 //=============================================================================
1033 //=============================================================================
1034 SMESHGUI::~SMESHGUI()
1036 SMESH::GetFilterManager()->Destroy();
1037 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1040 //=============================================================================
1044 //=============================================================================
1045 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1047 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1049 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1054 bool SMESHGUI::automaticUpdate()
1056 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1060 return resMgr->booleanValue( "SMESH", "auto_update", false );
1063 //=============================================================================
1067 //=============================================================================
1068 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1070 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1073 //=============================================================================
1077 //=============================================================================
1078 SMESHGUI* SMESHGUI::GetSMESHGUI()
1080 SMESHGUI* smeshMod = 0;
1081 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1084 CAM_Module* module = app->module( "Mesh" );
1085 smeshMod = dynamic_cast<SMESHGUI*>( module );
1088 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1090 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1093 _PTR(Study) aStudy = study->studyDS();
1095 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1104 Standard_EXPORT SMESHGUI* GetComponentGUI()
1106 return SMESHGUI::GetSMESHGUI();
1110 //=============================================================================
1114 //=============================================================================
1115 void SMESHGUI::SetState(int aState)
1120 //=============================================================================
1124 //=============================================================================
1125 void SMESHGUI::ResetState()
1130 //=============================================================================
1134 //=============================================================================
1135 void SMESHGUI::EmitSignalDeactivateDialog()
1137 emit SignalDeactivateActiveDialog();
1140 //=============================================================================
1144 //=============================================================================
1145 void SMESHGUI::EmitSignalStudyFrameChanged()
1147 emit SignalStudyFrameChanged();
1150 //=============================================================================
1154 //=============================================================================
1155 void SMESHGUI::EmitSignalCloseAllDialogs()
1157 emit SignalCloseAllDialogs();
1160 //=============================================================================
1164 //=============================================================================
1165 QDialog *SMESHGUI::GetActiveDialogBox()
1167 return myActiveDialogBox;
1170 //=============================================================================
1174 //=============================================================================
1175 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1177 myActiveDialogBox = (QDialog *) aDlg;
1181 //=============================================================================
1185 //=============================================================================
1186 SUIT_Desktop* SMESHGUI::desktop()
1188 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1190 return app->desktop();
1195 //=============================================================================
1199 //=============================================================================
1200 SalomeApp_Study* SMESHGUI::activeStudy()
1202 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1204 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1209 //=============================================================================
1213 //=============================================================================
1214 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1216 /* Here the position is on the bottom right corner - 10 */
1217 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1219 SUIT_Desktop *PP = desktop();
1220 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1221 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1225 //=============================================================================
1229 //=============================================================================
1230 static int isStudyLocked(_PTR(Study) theStudy){
1231 return theStudy->GetProperties()->IsLocked();
1234 static bool checkLock(_PTR(Study) theStudy) {
1235 if (isStudyLocked(theStudy)) {
1236 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1237 QObject::tr("WRN_WARNING"),
1238 QObject::tr("WRN_STUDY_LOCKED"),
1239 QObject::tr("BUT_OK") );
1245 //=======================================================================
1246 //function : CheckActiveStudyLocked
1248 //=======================================================================
1250 bool SMESHGUI::isActiveStudyLocked()
1252 _PTR(Study) aStudy = activeStudy()->studyDS();
1253 return checkLock( aStudy );
1256 //=============================================================================
1260 //=============================================================================
1261 bool SMESHGUI::OnGUIEvent( int theCommandID )
1263 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1267 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1268 SUIT_ResourceMgr* mgr = resourceMgr();
1272 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1273 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1276 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1277 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1279 //QAction* act = action( theCommandID );
1281 switch (theCommandID) {
1283 if(checkLock(aStudy)) break;
1291 if(checkLock(aStudy)) break;
1292 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1296 case 150: //MED FILE INFORMATION
1298 SALOME_ListIO selected;
1299 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1301 aSel->selectedObjects( selected );
1302 if( selected.Extent() )
1304 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1305 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1306 if ( !aMesh->_is_nil() )
1308 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1314 case 122: // EXPORT MED
1323 ::ExportMeshToFile(theCommandID);
1327 case 200: // SCALAR BAR
1329 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1330 SALOME_ListIO selected;
1332 aSel->selectedObjects( selected );
1334 if( selected.Extent() ) {
1335 Handle(SALOME_InteractiveObject) anIO = selected.First();
1336 if( anIO->hasEntry() ) {
1337 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1338 anActor->SetControlMode( SMESH_Actor::eNone );
1346 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1356 ::DisableAutoColor();
1359 case 1134: // Clipping
1360 case 1133: // Tranparency
1361 case 1132: // Colors / Size
1368 ::SetDisplayMode(theCommandID);
1374 case 219: // Volumes
1375 case 220: // All Entity
1376 ::SetDisplayEntity(theCommandID);
1381 if(checkLock(aStudy)) break;
1383 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1386 SMESH::UpdateView();
1388 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1389 SMESH::OnVisuException();
1391 catch (...) { // PAL16774 (Crash after display of many groups)
1392 SMESH::OnVisuException();
1396 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1397 aSel->selectedObjects( l );
1398 aSel->setSelectedObjects( l );
1403 case 301: // DISPLAY
1404 case 302: // DISPLAY ONLY
1406 SMESH::EDisplaing anAction;
1407 switch (theCommandID) {
1408 case 300: anAction = SMESH::eErase; break;
1409 case 301: anAction = SMESH::eDisplay; break;
1410 case 302: anAction = SMESH::eDisplayOnly; break;
1413 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1414 SALOME_ListIO sel_objects, to_process;
1416 aSel->selectedObjects( sel_objects );
1418 if( theCommandID==302 )
1419 startOperation( myEraseAll );
1421 extractContainers( sel_objects, to_process );
1424 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1428 SALOME_ListIteratorOfListIO It( to_process );
1429 for (; It.More(); It.Next()) {
1430 Handle(SALOME_InteractiveObject) IOS = It.Value();
1431 if (IOS->hasEntry()) {
1432 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1433 break; // PAL16774 (Crash after display of many groups)
1434 if (anAction == SMESH::eDisplayOnly)
1435 anAction = SMESH::eDisplay;
1440 // PAL13338 + PAL15161 -->
1441 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1442 SMESH::UpdateView();
1443 // PAL13338 + PAL15161 <--
1445 catch (...) { // PAL16774 (Crash after display of many groups)
1446 SMESH::OnVisuException();
1449 if (anAction == SMESH::eErase) {
1451 aSel->setSelectedObjects( l1 );
1454 aSel->setSelectedObjects( to_process );
1461 if(checkLock(aStudy)) break;
1464 EmitSignalDeactivateDialog();
1466 new SMESHGUI_NodesDlg(this);
1469 SUIT_MessageBox::warn1(desktop(),
1470 tr("SMESH_WRN_WARNING"),
1471 tr("SMESH_WRN_VIEWER_VTK"),
1472 tr("SMESH_BUT_OK"));
1477 case 2151: // FILTER
1481 EmitSignalDeactivateDialog();
1482 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1487 case 406: // MOVE NODE
1491 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1492 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1496 if(checkLock(aStudy)) break;
1497 new SMESHGUI_MoveNodesDlg(this);
1501 case 701: // COMPUTE MESH
1503 if (checkLock(aStudy)) break;
1505 startOperation( 701 );
1509 case 702: // Create mesh
1510 startOperation( 702 );
1512 case 703: // Create sub-mesh
1513 startOperation( 703 );
1515 case 704: // Edit mesh/sub-mesh
1516 startOperation( 704 );
1518 case 710: // Build compound mesh
1520 if (checkLock(aStudy)) break;
1521 EmitSignalDeactivateDialog();
1522 new SMESHGUI_BuildCompoundDlg( this );
1525 case 407: // DIAGONAL INVERSION
1526 case 408: // Delete diagonal
1530 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1531 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1535 if ( checkLock( aStudy ) )
1538 /*Standard_Boolean aRes;
1539 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1540 if ( aMesh->_is_nil() )
1542 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1543 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1547 EmitSignalDeactivateDialog();
1548 if ( theCommandID == 407 )
1549 new SMESHGUI_TrianglesInversionDlg(this);
1551 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1554 case 409: // Change orientation
1555 case 410: // Union of triangles
1556 case 411: // Cutting of quadrangles
1560 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1561 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1565 if ( checkLock( aStudy ) )
1568 EmitSignalDeactivateDialog();
1569 SMESHGUI_MultiEditDlg* aDlg = NULL;
1570 if ( theCommandID == 409 )
1571 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1572 else if ( theCommandID == 410 )
1573 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1575 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1580 case 412: // Smoothing
1582 if(checkLock(aStudy)) break;
1584 EmitSignalDeactivateDialog();
1585 new SMESHGUI_SmoothingDlg( this );
1588 SUIT_MessageBox::warn1(desktop(),
1589 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1590 tr("SMESH_BUT_OK"));
1594 case 413: // Extrusion
1596 if (checkLock(aStudy)) break;
1598 EmitSignalDeactivateDialog();
1599 new SMESHGUI_ExtrusionDlg ( this );
1601 SUIT_MessageBox::warn1(desktop(),
1602 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1603 tr("SMESH_BUT_OK"));
1607 case 414: // Revolution
1609 if(checkLock(aStudy)) break;
1611 EmitSignalDeactivateDialog();
1612 new SMESHGUI_RevolutionDlg( this );
1615 SUIT_MessageBox::warn1(desktop(),
1616 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1617 tr("SMESH_BUT_OK"));
1621 case 415: // Pattern mapping
1623 if ( checkLock( aStudy ) )
1627 EmitSignalDeactivateDialog();
1628 new SMESHGUI_MeshPatternDlg( this );
1631 SUIT_MessageBox::warn1(desktop(),
1632 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1633 tr("SMESH_BUT_OK"));
1637 case 416: // Extrusion along a path
1639 if (checkLock(aStudy)) break;
1641 EmitSignalDeactivateDialog();
1642 new SMESHGUI_ExtrusionAlongPathDlg( this );
1644 SUIT_MessageBox::warn1(desktop(),
1645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1646 tr("SMESH_BUT_OK"));
1650 case 417: // Convert mesh to quadratic
1652 startOperation( 417 );
1653 /* if (checkLock(aStudy)) break;
1655 EmitSignalDeactivateDialog();
1656 new SMESHGUI_ConvToQuadDlg();
1658 SUIT_MessageBox::warn1(desktop(),
1659 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1660 tr("SMESH_BUT_OK"));
1664 case 801: // CREATE GROUP
1668 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1669 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1673 if(checkLock(aStudy)) break;
1674 EmitSignalDeactivateDialog();
1675 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1677 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1678 SALOME_ListIO selected;
1680 aSel->selectedObjects( selected );
1682 int nbSel = selected.Extent();
1684 // check if mesh is selected
1685 aMesh = SMESH::GetMeshByIO( selected.First() );
1687 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1692 case 802: // CONSTRUCT GROUP
1696 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1697 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1701 if(checkLock(aStudy)) break;
1702 EmitSignalDeactivateDialog();
1704 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1705 SALOME_ListIO selected;
1707 aSel->selectedObjects( selected );
1709 int nbSel = selected.Extent();
1711 // check if submesh is selected
1712 Handle(SALOME_InteractiveObject) IObject = selected.First();
1713 if (IObject->hasEntry()) {
1714 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1716 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1717 if (!aSubMesh->_is_nil()) {
1719 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1720 // get submesh elements list by types
1721 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1722 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1723 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1724 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1725 // create group for each type o elements
1726 QString aName = IObject->getName();
1727 if (aNodes->length() > 0) {
1728 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1729 aGroup->Add(aNodes.inout());
1731 if (aEdges->length() > 0) {
1732 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1733 aGroup->Add(aEdges.inout());
1735 if (aFaces->length() > 0) {
1736 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1737 aGroup->Add(aFaces.inout());
1739 if (aVolumes->length() > 0) {
1740 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1741 aGroup->Add(aVolumes.inout());
1746 catch(const SALOME::SALOME_Exception & S_ex){
1747 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1754 SUIT_MessageBox::warn1(desktop(),
1755 tr("SMESH_WRN_WARNING"),
1756 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1757 tr("SMESH_BUT_OK"));
1762 case 803: // EDIT GROUP
1766 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1767 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1771 if(checkLock(aStudy)) break;
1772 EmitSignalDeactivateDialog();
1774 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1775 SALOME_ListIO selected;
1777 aSel->selectedObjects( selected );
1779 SALOME_ListIteratorOfListIO It (selected);
1780 int nbSelectedGroups = 0;
1781 for ( ; It.More(); It.Next() )
1783 SMESH::SMESH_GroupBase_var aGroup =
1784 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1785 if (!aGroup->_is_nil()) {
1787 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1791 if (nbSelectedGroups == 0)
1793 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1799 case 804: // Add elements to group
1801 if(checkLock(aStudy)) break;
1802 if (myState == 800) {
1803 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1804 if (aDlg) aDlg->onAdd();
1809 case 805: // Remove elements from group
1811 if(checkLock(aStudy)) break;
1812 if (myState == 800) {
1813 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1814 if (aDlg) aDlg->onRemove();
1819 case 810: // Union Groups
1820 case 811: // Intersect groups
1821 case 812: // Cut groups
1825 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1826 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1830 if ( checkLock( aStudy ) )
1833 EmitSignalDeactivateDialog();
1836 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1837 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1838 else aMode = SMESHGUI_GroupOpDlg::CUT;
1840 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1844 case 813: // Delete groups with their contents
1848 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1849 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1853 if ( checkLock( aStudy ) )
1856 EmitSignalDeactivateDialog();
1858 new SMESHGUI_DeleteGroupDlg( this );
1862 case 900: // MESH INFOS
1864 EmitSignalDeactivateDialog();
1865 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1866 SALOME_ListIO selected;
1868 aSel->selectedObjects( selected );
1870 if ( selected.Extent() > 1 ) { // a dlg for each IO
1872 SALOME_ListIteratorOfListIO It (selected);
1873 for ( ; It.More(); It.Next() ) {
1874 IOs.Clear(); IOs.Append( It.Value() );
1875 aSel->setSelectedObjects( IOs );
1876 new SMESHGUI_MeshInfosDlg(this, "", false);
1878 // restore selection
1879 aSel->setSelectedObjects( selected );
1882 new SMESHGUI_MeshInfosDlg(this, "", false);
1886 case 902: // STANDARD MESH INFOS
1888 EmitSignalDeactivateDialog();
1889 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1890 SALOME_ListIO selected;
1892 aSel->selectedObjects( selected );
1894 if ( selected.Extent() > 1 ) { // a dlg for each IO
1896 SALOME_ListIteratorOfListIO It (selected);
1897 for ( ; It.More(); It.Next() ) {
1899 IOs.Append( It.Value() );
1900 aSel->setSelectedObjects( IOs );
1901 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1903 // restore selection
1904 aSel->setSelectedObjects( selected );
1907 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1911 case 903: // WHAT IS
1913 EmitSignalDeactivateDialog();
1914 new SMESHGUI_WhatIsDlg( this, "", false);
1918 case 1100: // EDIT HYPOTHESIS
1920 if(checkLock(aStudy)) break;
1922 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1923 SALOME_ListIO selected;
1925 aSel->selectedObjects( selected );
1927 int nbSel = selected.Extent();
1930 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1931 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1933 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1934 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1935 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1936 if ( !aHypothesis->_is_nil() )
1938 CORBA::String_var aHypType = aHypothesis->GetName();
1939 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1941 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1948 updateObjBrowser( true );
1952 case 1101: // RENAME
1954 if ( checkLock( aStudy ) )
1957 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1958 SALOME_ListIO selected;
1960 aSel->selectedObjects( selected );
1962 SALOME_ListIteratorOfListIO It( selected );
1963 for ( ; It.More(); It.Next() )
1965 Handle(SALOME_InteractiveObject) IObject = It.Value();
1966 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1967 _PTR(GenericAttribute) anAttr;
1968 _PTR(AttributeName) aName;
1971 if ( obj->FindAttribute(anAttr, "AttributeName") )
1974 QString newName = QString(aName->Value().c_str());
1975 newName = LightApp_NameDlg::getName(desktop(), newName);
1976 if ( !newName.isEmpty() )
1978 //old source: aStudy->renameIObject( IObject, newName );
1979 aName->SetValue( newName.latin1() );
1981 // if current object is group update group's name
1982 SMESH::SMESH_GroupBase_var aGroup =
1983 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1984 if (!aGroup->_is_nil() )
1985 aGroup->SetName( newName.latin1() );
1995 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1997 if(checkLock(aStudy)) break;
1998 SUIT_OverrideCursor wc;
2000 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2001 SALOME_ListIO selected;
2003 aSel->selectedObjects( selected, QString::null, false );
2005 SALOME_ListIteratorOfListIO It(selected);
2006 for (int i = 0; It.More(); It.Next(), i++) {
2007 Handle(SALOME_InteractiveObject) IObject = It.Value();
2008 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2011 aSel->setSelectedObjects( l1 );
2016 case 401: // GEOM::EDGE
2017 case 4021: // TRIANGLE
2019 case 4023: // POLYGON
2023 if(checkLock(aStudy)) break;
2025 EmitSignalDeactivateDialog();
2026 SMDSAbs_ElementType type = SMDSAbs_Edge;
2028 switch (theCommandID) {
2029 case 4021: // TRIANGLE
2030 type = SMDSAbs_Face; nbNodes = 3; break;
2032 type = SMDSAbs_Face; nbNodes = 4; break;
2034 type = SMDSAbs_Volume; nbNodes = 4; break;
2035 case 4023: // POLYGON
2036 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2038 type = SMDSAbs_Volume; nbNodes = 8; break;
2039 case 4033: // POLYHEDRE
2040 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2043 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2046 SUIT_MessageBox::warn1(desktop(),
2047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2048 tr("SMESH_BUT_OK"));
2052 case 4033: // POLYHEDRON
2054 if(checkLock(aStudy)) break;
2056 EmitSignalDeactivateDialog();
2057 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2060 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2061 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2062 tr("SMESH_BUT_OK"));
2066 case 4034: // QUADRATIC EDGE
2067 case 4035: // QUADRATIC TRIANGLE
2068 case 4036: // QUADRATIC QUADRANGLE
2069 case 4037: // QUADRATIC TETRAHEDRON
2070 case 4038: // QUADRATIC PYRAMID
2071 case 4039: // QUADRATIC PENTAHEDRON
2072 case 4040: // QUADRATIC HEXAHEDRON
2074 if(checkLock(aStudy)) break;
2076 EmitSignalDeactivateDialog();
2079 switch (theCommandID) {
2081 type = QUAD_EDGE; break;
2083 type = QUAD_TRIANGLE; break;
2085 type = QUAD_QUADRANGLE; break;
2087 type = QUAD_TETRAHEDRON; break;
2089 type = QUAD_PYRAMID; break;
2091 type = QUAD_PENTAHEDRON; break;
2093 type = QUAD_HEXAHEDRON;
2097 new SMESHGUI_AddQuadraticElementDlg( this, type );
2100 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2102 tr("SMESH_BUT_OK"));
2106 case 4041: // REMOVES NODES
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 new SMESHGUI_RemoveNodesDlg(this);
2114 SUIT_MessageBox::warn1(desktop(),
2115 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2116 tr("SMESH_BUT_OK"));
2120 case 4042: // REMOVES ELEMENTS
2122 if(checkLock(aStudy)) break;
2124 EmitSignalDeactivateDialog();
2125 new SMESHGUI_RemoveElementsDlg(this);
2129 SUIT_MessageBox::warn1(desktop(),
2130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2131 tr("SMESH_BUT_OK"));
2135 case 4051: // RENUMBERING NODES
2137 if(checkLock(aStudy)) break;
2139 EmitSignalDeactivateDialog();
2140 new SMESHGUI_RenumberingDlg( this, "", 0);
2144 SUIT_MessageBox::warn1(desktop(),
2145 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2146 tr("SMESH_BUT_OK"));
2150 case 4052: // RENUMBERING ELEMENTS
2152 if(checkLock(aStudy)) break;
2154 EmitSignalDeactivateDialog();
2155 new SMESHGUI_RenumberingDlg( this, "", 1);
2159 SUIT_MessageBox::warn1(desktop(),
2160 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2161 tr("SMESH_BUT_OK"));
2165 case 4061: // TRANSLATION
2167 if(checkLock(aStudy)) break;
2169 EmitSignalDeactivateDialog();
2170 new SMESHGUI_TranslationDlg( this );
2173 SUIT_MessageBox::warn1(desktop(),
2174 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2175 tr("SMESH_BUT_OK"));
2179 case 4062: // ROTATION
2181 if(checkLock(aStudy)) break;
2183 EmitSignalDeactivateDialog();
2184 new SMESHGUI_RotationDlg( this );
2187 SUIT_MessageBox::warn1(desktop(),
2188 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2189 tr("SMESH_BUT_OK"));
2193 case 4063: // SYMMETRY
2195 if(checkLock(aStudy)) break;
2197 EmitSignalDeactivateDialog();
2198 new SMESHGUI_SymmetryDlg( this );
2201 SUIT_MessageBox::warn1(desktop(),
2202 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2203 tr("SMESH_BUT_OK"));
2207 case 4064: // SEWING
2209 if(checkLock(aStudy)) break;
2211 EmitSignalDeactivateDialog();
2212 new SMESHGUI_SewingDlg( this );
2215 SUIT_MessageBox::warn1(desktop(),
2216 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2217 tr("SMESH_BUT_OK"));
2221 case 4065: // MERGE NODES
2223 if(checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 new SMESHGUI_EditMeshDlg( this, 0 );
2229 SUIT_MessageBox::warn1(desktop(),
2230 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2231 tr("SMESH_BUT_OK"));
2235 case 4066: // MERGE EQUAL ELEMENTS
2237 if (checkLock(aStudy)) break;
2239 EmitSignalDeactivateDialog();
2240 new SMESHGUI_EditMeshDlg( this, 1 );
2242 SUIT_MessageBox::warn1(desktop(),
2243 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2244 tr("SMESH_BUT_OK"));
2249 case 4067: // MAKE MESH PASS THROUGH POINT
2250 startOperation( 4067 );
2253 case 5105: // Library of selection filters
2255 static QValueList<int> aTypes;
2256 if ( aTypes.isEmpty() )
2258 aTypes.append( SMESH::NODE );
2259 aTypes.append( SMESH::EDGE );
2260 aTypes.append( SMESH::FACE );
2261 aTypes.append( SMESH::VOLUME );
2263 if (!myFilterLibraryDlg)
2264 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2265 else if (myFilterLibraryDlg->isHidden())
2266 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2267 myFilterLibraryDlg->raise();
2271 case 6017: // CONTROLS
2287 LightApp_SelectionMgr* mgr = selectionMgr();
2288 SALOME_ListIO selected; mgr->selectedObjects( selected );
2290 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2291 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2293 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2294 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2295 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2296 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2297 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2298 ::Control( theCommandID );
2303 SUIT_MessageBox::warn1(desktop(),
2304 tr( "SMESH_WRN_WARNING" ),
2305 tr( "SMESH_BAD_SELECTION" ),
2306 tr( "SMESH_BUT_OK" ) );
2310 SUIT_MessageBox::warn1(desktop(),
2311 tr( "SMESH_WRN_WARNING" ),
2312 tr( "NOT_A_VTK_VIEWER" ),
2313 tr( "SMESH_BUT_OK" ) );
2318 LightApp_SelectionMgr* mgr = selectionMgr();
2319 SALOME_ListIO selected; mgr->selectedObjects( selected );
2321 SALOME_ListIteratorOfListIO it(selected);
2322 for(; it.More(); it.Next()) {
2323 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2324 if(anIObject->hasEntry()) {
2325 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2326 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2334 LightApp_SelectionMgr* mgr = selectionMgr();
2335 SALOME_ListIO selected; mgr->selectedObjects( selected );
2337 if (selected.Extent() == 1) {
2338 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2339 if(anIObject->hasEntry())
2340 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2341 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2348 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2349 //updateObjBrowser();
2353 //=============================================================================
2357 //=============================================================================
2358 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2363 //=============================================================================
2367 //=============================================================================
2368 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2373 //=============================================================================
2377 //=============================================================================
2378 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2383 //=============================================================================
2384 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2385 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2387 //=============================================================================
2388 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2389 SUIT_ViewWindow* wnd )
2391 if(theIO->hasEntry()){
2392 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2393 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2397 //=======================================================================
2398 // function : createSMESHAction
2400 //=======================================================================
2401 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2404 QWidget* parent = application()->desktop();
2405 SUIT_ResourceMgr* resMgr = resourceMgr();
2407 if ( icon_id.length() )
2408 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2410 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2411 if ( !pix.isNull() )
2412 icon = QIconSet( pix );
2414 QString tooltip = tr( QString( "TOP_" )+po_id ),
2415 menu = tr( QString( "MEN_" )+po_id ),
2416 status_bar = tr( QString( "STB_" )+po_id );
2418 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2421 //=======================================================================
2422 // function : createPopupItem
2424 //=======================================================================
2425 void SMESHGUI::createPopupItem( const int id,
2426 const QString& clients,
2427 const QString& types,
2428 const QString& theRule,
2433 parentId = popupMgr()->actionId( action( pId ) );
2435 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2436 popupMgr()->insert( action( id ), parentId, 0 );
2438 QChar lc = QtxPopupMgr::Selection::defEquality();
2439 QString rule = "(%1) and (%2) and (%3)";
2440 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2441 if( clients.isEmpty() )
2442 rule = rule.arg( QString( "true" ) );
2444 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2445 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2448 bool cont = myRules.contains( id );
2450 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2452 popupMgr()->setRule( action( id ), rule, true );
2453 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2456 //=======================================================================
2457 // function : initialize
2459 //=======================================================================
2460 void SMESHGUI::initialize( CAM_Application* app )
2462 SalomeApp_Module::initialize( app );
2464 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2466 /* Automatic Update flag */
2467 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2469 // ----- create actions --------------
2471 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2472 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2473 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2474 createSMESHAction( 114, "NUM" );
2475 createSMESHAction( 121, "DAT" );
2476 createSMESHAction( 122, "MED" );
2477 createSMESHAction( 123, "UNV" );
2478 createSMESHAction( 140, "STL" );
2479 createSMESHAction( 124, "EXPORT_DAT" );
2480 createSMESHAction( 125, "EXPORT_MED" );
2481 createSMESHAction( 126, "EXPORT_UNV" );
2482 createSMESHAction( 141, "EXPORT_STL" );
2483 createSMESHAction( 150, "FILE_INFO" );
2484 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2485 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2486 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2487 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2488 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2489 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2490 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2491 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2492 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2493 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2494 createSMESHAction( 804, "ADD" );
2495 createSMESHAction( 805, "REMOVE" );
2496 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2497 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2498 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2499 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2500 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2501 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2502 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2503 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2504 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2505 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2506 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2507 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2508 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2509 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2510 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2511 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2512 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2513 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2514 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2515 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2516 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2517 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2518 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2519 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2520 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2521 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2522 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2523 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2524 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2525 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2526 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2527 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2528 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2529 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2530 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2531 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2532 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2533 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2534 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2535 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2536 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2537 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2538 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2539 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2540 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2541 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2542 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2543 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2544 createSMESHAction( 415, "MAP", "ICON_MAP" );
2545 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2546 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2547 createSMESHAction( 200, "RESET" );
2548 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2549 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2550 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2551 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2552 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2553 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2554 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2555 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2556 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2557 createSMESHAction( 220, "ALL" );
2558 createSMESHAction( 1100, "EDIT_HYPO" );
2559 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2560 createSMESHAction( 1102, "UNASSIGN" );
2561 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2562 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2563 createSMESHAction( 1131, "DISPMODE" );
2564 createSMESHAction( 1132, "COLORS" );
2565 createSMESHAction( 1133, "TRANSP" );
2566 createSMESHAction( 1134, "CLIP" );
2567 createSMESHAction( 1135, "DISP_ENT" );
2568 createSMESHAction( 1136, "AUTO_COLOR" );
2569 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2570 createSMESHAction( 2000, "CTRL" );
2572 createSMESHAction( 300, "ERASE" );
2573 createSMESHAction( 301, "DISPLAY" );
2574 createSMESHAction( 302, "DISPLAY_ONLY" );
2575 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2576 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2577 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2578 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2579 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2580 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2581 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2582 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2584 // ----- create menu --------------
2585 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2586 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2587 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2588 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2589 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2590 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2591 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2593 createMenu( separator(), fileId );
2595 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2596 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2597 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2598 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2599 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2600 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2602 createMenu( 111, importId, -1 );
2603 createMenu( 112, importId, -1 );
2604 createMenu( 113, importId, -1 );
2606 createMenu( 121, exportId, -1 );
2607 createMenu( 122, exportId, -1 );
2608 createMenu( 123, exportId, -1 );
2609 createMenu( 140, exportId, -1 ); // export to stl STL
2611 createMenu( separator(), fileId, 10 );
2613 createMenu( 33, editId, -1 );
2615 createMenu( 5105, toolsId, -1 );
2617 createMenu( 702, meshId, -1 );
2618 createMenu( 703, meshId, -1 );
2619 createMenu( 704, meshId, -1 );
2620 createMenu( 710, meshId, -1 );
2621 createMenu( separator(), meshId, -1 );
2622 createMenu( 701, meshId, -1 );
2623 createMenu( separator(), meshId, -1 );
2624 createMenu( 801, meshId, -1 );
2625 createMenu( 802, meshId, -1 );
2626 createMenu( 803, meshId, -1 );
2627 createMenu( separator(), meshId, -1 );
2628 createMenu( 810, meshId, -1 );
2629 createMenu( 811, meshId, -1 );
2630 createMenu( 812, meshId, -1 );
2631 createMenu( separator(), meshId, -1 );
2632 createMenu( 813, meshId, -1 );
2633 createMenu( separator(), meshId, -1 );
2634 createMenu( 900, meshId, -1 );
2635 createMenu( 902, meshId, -1 );
2636 createMenu( 903, meshId, -1 );
2637 createMenu( separator(), meshId, -1 );
2639 createMenu( 6003, ctrlId, -1 );
2640 createMenu( 6001, ctrlId, -1 );
2641 createMenu( 6004, ctrlId, -1 );
2642 createMenu( separator(), ctrlId, -1 );
2643 createMenu( 6002, ctrlId, -1 );
2644 createMenu( 6018, ctrlId, -1 );
2645 createMenu( 6019, ctrlId, -1 );
2646 createMenu( 6011, ctrlId, -1 );
2647 createMenu( 6012, ctrlId, -1 );
2648 createMenu( 6013, ctrlId, -1 );
2649 createMenu( 6014, ctrlId, -1 );
2650 createMenu( 6015, ctrlId, -1 );
2651 createMenu( 6016, ctrlId, -1 );
2652 createMenu( separator(), ctrlId, -1 );
2653 createMenu( 6017, ctrlId, -1 );
2654 createMenu( 6009, ctrlId, -1 );
2655 createMenu( separator(), ctrlId, -1 );
2657 createMenu( 400, addId, -1 );
2658 createMenu( 401, addId, -1 );
2659 createMenu( 4021, addId, -1 );
2660 createMenu( 4022, addId, -1 );
2661 createMenu( 4023, addId, -1 );
2662 createMenu( 4031, addId, -1 );
2663 createMenu( 4032, addId, -1 );
2664 createMenu( 4033, addId, -1 );
2665 createMenu( separator(), addId, -1 );
2666 createMenu( 4034, addId, -1 );
2667 createMenu( 4035, addId, -1 );
2668 createMenu( 4036, addId, -1 );
2669 createMenu( 4037, addId, -1 );
2670 createMenu( 4038, addId, -1 );
2671 createMenu( 4039, addId, -1 );
2672 createMenu( 4040, addId, -1 );
2674 createMenu( 4041, removeId, -1 );
2675 createMenu( 4042, removeId, -1 );
2677 createMenu( 4051, renumId, -1 );
2678 createMenu( 4052, renumId, -1 );
2680 createMenu( 4061, transfId, -1 );
2681 createMenu( 4062, transfId, -1 );
2682 createMenu( 4063, transfId, -1 );
2683 createMenu( 4064, transfId, -1 );
2684 createMenu( 4065, transfId, -1 );
2685 createMenu( 4066, transfId, -1 );
2687 createMenu( 406, modifyId, -1 );
2688 createMenu( 4067,modifyId, -1 );
2689 createMenu( 407, modifyId, -1 );
2690 createMenu( 408, modifyId, -1 );
2691 createMenu( 409, modifyId, -1 );
2692 createMenu( 410, modifyId, -1 );
2693 createMenu( 411, modifyId, -1 );
2694 createMenu( 412, modifyId, -1 );
2695 createMenu( 413, modifyId, -1 );
2696 createMenu( 416, modifyId, -1 );
2697 createMenu( 414, modifyId, -1 );
2698 createMenu( 415, modifyId, -1 );
2699 createMenu( 417, modifyId, -1 );
2701 createMenu( 214, viewId, -1 );
2703 // ----- create toolbars --------------
2704 int meshTb = createTool( tr( "TB_MESH" ) ),
2705 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2706 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2707 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2708 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2710 createTool( 702, meshTb );
2711 createTool( 703, meshTb );
2712 createTool( 704, meshTb );
2713 createTool( 710, meshTb );
2714 createTool( separator(), meshTb );
2715 createTool( 701, meshTb );
2716 createTool( separator(), meshTb );
2717 createTool( 801, meshTb );
2718 createTool( 802, meshTb );
2719 createTool( 803, meshTb );
2720 createTool( separator(), meshTb );
2721 createTool( 900, meshTb );
2722 createTool( 902, meshTb );
2723 createTool( 903, meshTb );
2724 createTool( separator(), meshTb );
2726 createTool( 6001, ctrlTb );
2727 createTool( 6003, ctrlTb );
2728 createTool( 6004, ctrlTb );
2729 createTool( separator(), ctrlTb );
2730 createTool( 6002, ctrlTb );
2731 createTool( 6018, ctrlTb );
2732 createTool( 6019, ctrlTb );
2733 createTool( 6011, ctrlTb );
2734 createTool( 6012, ctrlTb );
2735 createTool( 6013, ctrlTb );
2736 createTool( 6014, ctrlTb );
2737 createTool( 6015, ctrlTb );
2738 createTool( 6016, ctrlTb );
2739 createTool( separator(), ctrlTb );
2740 createTool( 6017, ctrlTb );
2741 createTool( 6009, ctrlTb );
2742 createTool( separator(), ctrlTb );
2744 createTool( 400, addRemTb );
2745 createTool( 401, addRemTb );
2746 createTool( 4021, addRemTb );
2747 createTool( 4022, addRemTb );
2748 createTool( 4023, addRemTb );
2749 createTool( 4031, addRemTb );
2750 createTool( 4032, addRemTb );
2751 createTool( 4033, addRemTb );
2752 createTool( separator(), addRemTb );
2753 createTool( 4034, addRemTb );
2754 createTool( 4035, addRemTb );
2755 createTool( 4036, addRemTb );
2756 createTool( 4037, addRemTb );
2757 createTool( 4038, addRemTb );
2758 createTool( 4039, addRemTb );
2759 createTool( 4040, addRemTb );
2760 createTool( separator(), addRemTb );
2761 createTool( 4041, addRemTb );
2762 createTool( 4042, addRemTb );
2763 createTool( separator(), addRemTb );
2764 createTool( 4051, addRemTb );
2765 createTool( 4052, addRemTb );
2766 createTool( separator(), addRemTb );
2767 createTool( 4061, addRemTb );
2768 createTool( 4062, addRemTb );
2769 createTool( 4063, addRemTb );
2770 createTool( 4064, addRemTb );
2771 createTool( 4065, addRemTb );
2772 createTool( 4066, addRemTb );
2773 createTool( separator(), addRemTb );
2775 createTool( 406, modifyTb );
2776 createTool( 4067,modifyTb );
2777 createTool( 407, modifyTb );
2778 createTool( 408, modifyTb );
2779 createTool( 409, modifyTb );
2780 createTool( 410, modifyTb );
2781 createTool( 411, modifyTb );
2782 createTool( 412, modifyTb );
2783 createTool( 413, modifyTb );
2784 createTool( 416, modifyTb );
2785 createTool( 414, modifyTb );
2786 createTool( 415, modifyTb );
2787 createTool( 417, modifyTb );
2789 createTool( 214, dispModeTb );
2793 QString OB = "'ObjectBrowser'",
2794 View = "'" + SVTK_Viewer::Type() + "'",
2796 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2797 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2798 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2799 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2800 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2801 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2802 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2803 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2804 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2805 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2806 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2808 mesh_group = mesh + " " + subMesh + " " + group,
2809 hyp_alg = hypo + " " + algo;
2811 // popup for object browser
2813 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2815 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2816 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2817 createPopupItem( 803, OB, group ); // EDIT_GROUP
2818 popupMgr()->insert( separator(), -1, 0 );
2819 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2820 createPopupItem( 214, OB, mesh_group ); // UPDATE
2821 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2822 createPopupItem( 902, OB, mesh ); // STD_INFO
2823 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2824 popupMgr()->insert( separator(), -1, 0 );
2825 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2826 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2827 popupMgr()->insert( separator(), -1, 0 );
2828 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2829 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2830 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2831 popupMgr()->insert( separator(), -1, 0 );
2833 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2834 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2835 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2836 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2837 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2838 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2839 popupMgr()->insert( separator(), -1, 0 );
2842 createPopupItem( 803, View, group ); // EDIT_GROUP
2843 createPopupItem( 804, View, elems ); // ADD
2844 createPopupItem( 805, View, elems ); // REMOVE
2845 popupMgr()->insert( separator(), -1, 0 );
2846 createPopupItem( 214, View, mesh_group ); // UPDATE
2847 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2848 createPopupItem( 902, View, mesh ); // STD_INFO
2849 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2850 popupMgr()->insert( separator(), -1, 0 );
2852 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2853 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2854 popupMgr()->insert( separator(), -1, 0 );
2858 isInvisible("not( isVisible )"),
2859 isEmpty("numberOfNodes = 0"),
2860 isNotEmpty("numberOfNodes <> 0"),
2862 // has nodes, edges, etc in VISIBLE! actor
2863 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2864 hasElems("(count( elemTypes ) > 0)"),
2865 hasDifferentElems("(count( elemTypes ) > 1)"),
2866 hasEdges("({'Edge'} in elemTypes)"),
2867 hasFaces("({'Face'} in elemTypes)"),
2868 hasVolumes("({'Volume'} in elemTypes)");
2870 QString lc = QtxPopupMgr::Selection::defEquality();
2871 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2872 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2873 aType = aType.arg( mesh_group );
2874 QString aMeshInVTK = aClient + "&&" + aType;
2876 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2877 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2878 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2880 //-------------------------------------------------
2882 //-------------------------------------------------
2883 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2885 popupMgr()->insert( action( 9010 ), anId, -1 );
2886 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2887 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2889 popupMgr()->insert( action( 9011 ), anId, -1 );
2890 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2891 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2893 popupMgr()->insert( separator(), -1, -1 );
2895 //-------------------------------------------------
2897 //-------------------------------------------------
2898 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2900 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2901 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2902 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2904 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2905 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2906 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2908 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2909 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2910 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2912 popupMgr()->insert( separator(), anId, -1 );
2914 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2915 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2916 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2918 //-------------------------------------------------
2920 //-------------------------------------------------
2921 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2923 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2925 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2926 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2927 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2929 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2930 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2931 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2933 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2934 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2935 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2937 popupMgr()->insert( separator(), anId, -1 );
2939 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2940 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2942 //-------------------------------------------------
2944 //-------------------------------------------------
2945 popupMgr()->insert( action( 1132 ), -1, -1 );
2946 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2948 //-------------------------------------------------
2950 //-------------------------------------------------
2951 popupMgr()->insert( action( 1133 ), -1, -1 );
2952 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2954 //-------------------------------------------------
2956 //-------------------------------------------------
2957 popupMgr()->insert( action( 1134 ), -1, -1 );
2958 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2960 popupMgr()->insert( separator(), -1, -1 );
2962 //-------------------------------------------------
2964 //-------------------------------------------------
2966 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2967 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2968 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2970 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2972 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2973 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2975 popupMgr()->insert( separator(), anId, -1 );
2977 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2978 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2979 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2981 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2982 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2983 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2985 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2986 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2987 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2989 popupMgr()->insert( separator(), anId, -1 );
2991 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2992 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2993 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2995 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2996 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2997 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2999 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3000 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
3001 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
3003 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3004 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
3005 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
3007 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3008 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
3009 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
3011 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3012 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
3013 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
3015 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3016 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
3017 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
3019 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3020 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
3021 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
3023 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3024 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
3025 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
3027 popupMgr()->insert( separator(), anId, -1 );
3029 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3030 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
3031 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
3033 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3034 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
3035 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3037 popupMgr()->insert( separator(), anId, -1 );
3039 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3040 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3042 popupMgr()->insert( separator(), -1, -1 );
3044 //-------------------------------------------------
3046 //-------------------------------------------------
3047 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3048 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3049 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3050 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3052 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3053 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3055 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3056 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3058 popupMgr()->insert( separator(), -1, -1 );
3060 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3061 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3064 bool SMESHGUI::activateModule( SUIT_Study* study )
3066 bool res = SalomeApp_Module::activateModule( study );
3068 setMenuShown( true );
3069 setToolShown( true );
3071 // Reset actions accelerator keys
3072 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3073 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3074 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3079 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3081 setMenuShown( false );
3082 setToolShown( false );
3084 EmitSignalCloseAllDialogs();
3086 // Unset actions accelerator keys
3087 action(111)->setAccel(QKeySequence()); // Import DAT
3088 action(112)->setAccel(QKeySequence()); // Import UNV
3089 action(113)->setAccel(QKeySequence()); // Import MED
3091 return SalomeApp_Module::deactivateModule( study );
3094 void SMESHGUI::studyClosed( SUIT_Study* s )
3096 SMESH::RemoveVisuData( s->id() );
3097 SalomeApp_Module::studyClosed( s );
3100 void SMESHGUI::OnGUIEvent()
3102 const QObject* obj = sender();
3103 if ( !obj || !obj->inherits( "QAction" ) )
3105 int id = actionId((QAction*)obj);
3110 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3112 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3113 if ( CORBA::is_nil( myComponentSMESH ) )
3115 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3117 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3118 return aGUI.myComponentSMESH;
3121 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3122 return myComponentSMESH;
3125 QString SMESHGUI::engineIOR() const
3127 CORBA::ORB_var anORB = getApp()->orb();
3128 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3129 return QString( anIOR.in() );
3132 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3134 SMESHGUI_Selection sel;
3135 sel.init( client, selectionMgr() );
3136 popupMgr()->updatePopup( menu, &sel );
3139 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3141 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3142 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3145 void SMESHGUI::viewManagers( QStringList& list ) const
3147 list.append( SVTK_Viewer::Type() );
3150 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3152 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3153 SMESH::UpdateSelectionProp( this );
3156 void SMESHGUI::createPreferences()
3158 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3160 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3161 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3163 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3164 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3165 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3167 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3168 setPreferenceProperty( precGroup, "columns", 1 );
3170 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3172 setPreferenceProperty( prec, "min", 0 );
3173 setPreferenceProperty( prec, "max", 16 );
3175 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3176 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3178 modes.append( "Wireframe" );
3179 modes.append( "Shading" );
3180 modes.append( "Nodes" );
3181 modes.append( "Shrink" );
3182 QValueList<QVariant> indices;
3183 indices.append( 0 );
3184 indices.append( 1 );
3185 indices.append( 2 );
3186 indices.append( 3 );
3187 setPreferenceProperty( dispmode, "strings", modes );
3188 setPreferenceProperty( dispmode, "indexes", indices );
3190 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3191 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3192 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3194 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3195 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3197 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3198 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3200 setPreferenceProperty( nodeSz, "min", 1 );
3201 setPreferenceProperty( nodeSz, "max", 5 );
3203 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3205 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3206 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3207 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3208 addPreference( "", elemGroup, LightApp_Preferences::Space );
3210 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3211 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3213 setPreferenceProperty( elemW, "min", 1 );
3214 setPreferenceProperty( elemW, "max", 5 );
3216 setPreferenceProperty( shrink, "min", 0 );
3217 setPreferenceProperty( shrink, "max", 100 );
3219 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3221 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3223 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3224 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3225 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3227 setPreferenceProperty( selW, "min", 1 );
3228 setPreferenceProperty( selW, "max", 5 );
3230 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3232 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3233 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3235 setPreferenceProperty( preW, "min", 1 );
3236 setPreferenceProperty( preW, "max", 5 );
3238 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3240 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3241 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3242 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3244 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3245 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3247 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3248 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3249 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3250 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3253 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3254 fam.append( tr( "SMESH_FONT_COURIER" ) );
3255 fam.append( tr( "SMESH_FONT_TIMES" ) );
3256 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3258 setPreferenceProperty( tfont, "families", fam );
3259 setPreferenceProperty( tfont, "system", false );
3260 setPreferenceProperty( tfont, "widget_flags", wflag );
3261 setPreferenceProperty( lfont, "families", fam );
3262 setPreferenceProperty( lfont, "system", false );
3263 setPreferenceProperty( lfont, "widget_flags", wflag );
3265 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3267 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3268 setPreferenceProperty( numcol, "min", 2 );
3269 setPreferenceProperty( numcol, "max", 256 );
3271 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3272 setPreferenceProperty( numlab, "min", 2 );
3273 setPreferenceProperty( numlab, "max", 65 );
3275 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3276 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3277 QStringList orients;
3278 orients.append( tr( "SMESH_VERTICAL" ) );
3279 orients.append( tr( "SMESH_HORIZONTAL" ) );
3280 indices.clear(); indices.append( 0 ); indices.append( 1 );
3281 setPreferenceProperty( orient, "strings", orients );
3282 setPreferenceProperty( orient, "indexes", indices );
3284 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3285 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3286 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3287 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3288 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3289 setPreferenceProperty( xv, "step", 0.1 );
3290 setPreferenceProperty( xv, "min", 0.0 );
3291 setPreferenceProperty( xv, "max", 1.0 );
3292 setPreferenceProperty( yv, "step", 0.1 );
3293 setPreferenceProperty( yv, "min", 0.0 );
3294 setPreferenceProperty( yv, "max", 1.0 );
3295 setPreferenceProperty( wv, "step", 0.1 );
3296 setPreferenceProperty( wv, "min", 0.0 );
3297 setPreferenceProperty( wv, "max", 1.0 );
3298 setPreferenceProperty( hv, "min", 0.0 );
3299 setPreferenceProperty( hv, "max", 1.0 );
3300 setPreferenceProperty( hv, "step", 0.1 );
3302 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3303 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3304 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3305 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3306 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3307 setPreferenceProperty( xv, "min", 0.0 );
3308 setPreferenceProperty( xv, "max", 1.0 );
3309 setPreferenceProperty( xv, "step", 0.1 );
3310 setPreferenceProperty( xh, "min", 0.0 );
3311 setPreferenceProperty( xh, "max", 1.0 );
3312 setPreferenceProperty( xh, "step", 0.1 );
3313 setPreferenceProperty( yh, "min", 0.0 );
3314 setPreferenceProperty( yh, "max", 1.0 );
3315 setPreferenceProperty( yh, "step", 0.1 );
3316 setPreferenceProperty( wh, "min", 0.0 );
3317 setPreferenceProperty( wh, "max", 1.0 );
3318 setPreferenceProperty( wh, "step", 0.1 );
3319 setPreferenceProperty( hh, "min", 0.0 );
3320 setPreferenceProperty( hh, "max", 1.0 );
3321 setPreferenceProperty( hh, "step", 0.1 );
3324 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3326 if( sect=="SMESH" ){
3327 float sbX1,sbY1,sbW,sbH;
3328 float aTol = 1.00000009999999;
3329 std::string aWarning;
3330 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3331 if( name=="selection_object_color" || name=="selection_element_color" ||
3332 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3333 name=="selection_precision_node" || name=="selection_precision_element" ||
3334 name=="selection_precision_object")
3335 SMESH::UpdateSelectionProp( this );
3336 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3337 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3338 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3339 if(sbX1+sbW > aTol){
3340 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3343 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3344 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3347 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3348 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3349 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3350 if(sbY1+sbH > aTol){
3351 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3352 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3353 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3356 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3357 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3358 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3359 if(sbX1+sbW > aTol){
3360 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3363 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3364 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3367 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3368 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3369 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3370 if(sbY1+sbH > aTol){
3371 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3374 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3375 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3379 if(aWarning.size() != 0){
3380 aWarning += "The default values are applied instead.";
3381 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3382 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3383 QObject::tr(aWarning.c_str()),
3384 QObject::tr("SMESH_BUT_OK"));
3389 //================================================================================
3391 * \brief Update something in accordance with update flags
3392 * \param theFlags - update flags
3394 * Update viewer or/and object browser etc. in accordance with update flags ( see
3395 * LightApp_UpdateFlags enumeration ).
3397 //================================================================================
3398 void SMESHGUI::update( const int flags )
3400 if ( flags & UF_Viewer | flags & UF_Forced )
3401 SMESH::UpdateView();
3403 SalomeApp_Module::update( flags );
3406 //================================================================================
3408 * \brief Set default selection mode
3410 * SLOT called when operation commited. Sets default selection mode
3412 //================================================================================
3413 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3415 SVTK_ViewWindow* vtkWnd =
3416 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3418 vtkWnd->SetSelectionMode( ActorSelection );
3421 //================================================================================
3423 * \brief Set default selection mode
3425 * SLOT called when operation aborted. Sets default selection mode
3427 //================================================================================
3428 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3430 SVTK_ViewWindow* vtkWnd =
3431 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3433 vtkWnd->SetSelectionMode( ActorSelection );
3436 //================================================================================
3438 * \brief Creates operation with given identifier
3439 * \param id - identifier of operation to be started
3440 * \return Pointer on created operation or NULL if operation is not created
3442 * Virtual method redefined from the base class creates operation with given id.
3443 * It is called called automatically from startOperation method of base class.
3445 //================================================================================
3446 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3448 LightApp_Operation* op = 0;
3449 // to do : create operation here
3452 case 701: // Compute mesh
3453 op = new SMESHGUI_ComputeOp();
3455 case 702: // Create mesh
3456 op = new SMESHGUI_MeshOp( true, true );
3458 case 703: // Create sub-mesh
3459 op = new SMESHGUI_MeshOp( true, false );
3461 case 704: // Edit mesh/sub-mesh
3462 op = new SMESHGUI_MeshOp( false );
3464 case 417: //convert to quadratic
3465 op = new SMESHGUI_ConvToQuadOp();
3467 case 4067: // make mesh pass through point
3468 op = new SMESHGUI_MakeNodeAtPointOp();
3475 op = SalomeApp_Module::createOperation( id );
3479 //================================================================================
3481 * \brief Stops current operations and starts a given one
3482 * \param id - The id of the operation to start
3484 //================================================================================
3486 void SMESHGUI::switchToOperation(int id)
3488 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3489 activeStudy()->abortAllOperations();
3490 startOperation( id );
3493 LightApp_Displayer* SMESHGUI::displayer()
3496 myDisplayer = new SMESHGUI_Displayer( getApp() );
3500 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3503 int aTolerance = 64;
3504 int anIterations = 0;
3510 if( anIterations % aPeriod == 0 )
3513 if( aTolerance < 1 )
3516 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3518 aHue = (int)( 360.0 * rand() / RAND_MAX );
3519 //cout << "Hue = " << aHue << endl;
3521 //cout << "Auto colors : ";
3523 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3524 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3525 for( ; it != itEnd; ++it )
3527 SALOMEDS::Color anAutoColor = *it;
3528 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3531 aQColor.getHsv( &h, &s, &v );
3533 if( abs( h - aHue ) < aTolerance )
3536 //cout << "break (diff = " << abs( h - aHue ) << ")";
3546 //cout << "Hue of the returned color = " << aHue << endl;
3548 aColor.setHsv( aHue, 255, 255 );
3550 SALOMEDS::Color aSColor;
3551 aSColor.R = (double)aColor.red() / 255.0;
3552 aSColor.G = (double)aColor.green() / 255.0;
3553 aSColor.B = (double)aColor.blue() / 255.0;