1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_WhatIsDlg.h"
39 #include "SMESHGUI_Preferences_ColorDlg.h"
40 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
41 #include "SMESHGUI_Preferences_SelectionDlg.h"
42 #include "SMESHGUI_Hypotheses.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_AddQuadraticElementDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.h"
55 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_ComputeDlg.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_GEOMGenUtils.h"
74 #include "SMESHGUI_MeshUtils.h"
75 #include "SMESHGUI_GroupUtils.h"
76 #include "SMESHGUI_FilterUtils.h"
77 #include "SMESHGUI_PatternUtils.h"
78 #include "SMESHGUI_VTKUtils.h"
79 #include "SMESHGUI_HypothesesUtils.h"
81 #include "SMESH_Actor.h"
82 #include "SMESH_Object.h"
83 #include "SMESH_TypeFilter.hxx"
85 #include "SalomeApp_Tools.h"
86 #include "SalomeApp_Study.h"
87 #include "SalomeApp_Application.h"
88 #include "SalomeApp_CheckFileDlg.h"
89 #include "SalomeApp_ImportOperation.h"
91 #include "LightApp_DataOwner.h"
92 #include "LightApp_Preferences.h"
93 #include "LightApp_VTKSelector.h"
94 #include "LightApp_Operation.h"
95 #include "LightApp_UpdateFlags.h"
96 #include "LightApp_NameDlg.h"
98 #include <SVTK_ViewWindow.h>
99 #include <SVTK_ViewModel.h>
100 #include <SVTK_InteractorStyle.h>
101 #include <SVTK_RenderWindowInteractor.h>
102 #include <SVTK_ViewManager.h>
104 #include "OB_Browser.h"
106 #include "SUIT_Tools.h"
107 #include "SUIT_MessageBox.h"
108 #include "SUIT_ResourceMgr.h"
109 #include "SUIT_FileDlg.h"
110 #include "SUIT_Desktop.h"
111 #include "SUIT_OverrideCursor.h"
112 #include "SUIT_Study.h"
113 #include "SUIT_Session.h"
115 #include "QtxPopupMgr.h"
117 #include "SALOME_ListIO.hxx"
118 #include "SALOME_ListIteratorOfListIO.hxx"
119 #include "SALOME_InteractiveObject.hxx"
120 #include "SALOME_NamingService.hxx"
121 #include "SALOME_LifeCycleCORBA.hxx"
123 #include "SALOMEconfig.h"
124 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
125 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
128 #define INCLUDE_MENUITEM_DEF
129 #include <qpopupmenu.h>
135 #include <boost/shared_ptr.hpp>
138 #include <vtkRenderer.h>
139 #include <vtkRenderWindow.h>
140 #include <vtkActorCollection.h>
141 #include <vtkScalarBarActor.h>
142 #include <vtkUnstructuredGrid.h>
144 #include "utilities.h"
146 #include "SALOMEDS_Study.hxx"
147 #include "SALOMEDSClient_StudyBuilder.hxx"
148 #include "SALOMEDSClient_SComponent.hxx"
150 #include <Standard_ErrorHandler.hxx>
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
170 //=============================================================
171 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 if(theCommandID == 113){
178 filter.append(QObject::tr("MED files (*.med)"));
179 filter.append(QObject::tr("All files (*)"));
180 }else if (theCommandID == 112){
181 filter.append(QObject::tr("IDEAS files (*.unv)"));
182 }else if (theCommandID == 111){
183 filter.append(QObject::tr("DAT files (*.dat)"));
185 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
188 QObject::tr("Import mesh"),
190 if(!filename.isEmpty()) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 aMeshes->length( 1 );
200 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
205 SMESH::DriverMED_ReadStatus res;
206 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
207 if ( res != SMESH::DRS_OK ) {
209 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
210 QObject::tr("SMESH_WRN_WARNING"),
211 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
212 QObject::tr("SMESH_BUT_OK"));
213 aMeshes->length( 0 );
220 bool isEmpty = false;
221 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
222 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
224 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
225 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
226 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
227 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
228 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
235 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
236 QObject::tr("SMESH_WRN_WARNING"),
237 QObject::tr("SMESH_DRS_EMPTY"),
238 QObject::tr("SMESH_BUT_OK"));
242 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
244 catch (const SALOME::SALOME_Exception& S_ex){
246 SalomeApp_Tools::QtCatchCorbaException(S_ex);
253 void ExportMeshToFile( int theCommandID )
255 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
256 SALOME_ListIO selected;
258 aSel->selectedObjects( selected );
260 if(selected.Extent()){
261 Handle(SALOME_InteractiveObject) anIObject = selected.First();
262 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
263 if ( !aMesh->_is_nil() ) {
264 QString aFilter, aTitle = QObject::tr("Export mesh");
265 QMap<QString, SMESH::MED_VERSION> aFilterMap;
266 QMap<QString, int> aFilterMapSTL;
267 switch ( theCommandID ) {
271 if (aMesh->HasDuplicatedGroupNamesMED()) {
272 int aRet = SUIT_MessageBox::warn2
273 (SMESHGUI::desktop(),
274 QObject::tr("SMESH_WRN_WARNING"),
275 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
276 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
282 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
283 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
288 aFilter = QObject::tr("DAT files (*.dat)");
293 if (aMesh->NbPyramids()) {
294 int aRet = SUIT_MessageBox::warn2
295 (SMESHGUI::desktop(),
296 QObject::tr("SMESH_WRN_WARNING"),
297 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
298 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
303 aFilter = QObject::tr("IDEAS files (*.unv)");
311 there must be check on others mesh elements not equal triangles
313 if (aMesh->NbTriangles() < 1) {
314 SUIT_MessageBox::warn1
315 (SMESHGUI::desktop(),
316 QObject::tr("SMESH_WRN_WARNING"),
317 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
318 QObject::tr("SMESH_BUT_OK"));
321 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
322 int aRet = SUIT_MessageBox::warn2
323 (SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
326 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
332 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
333 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
341 SMESH::MED_VERSION aFormat;
342 // Init the parameter with the default value
343 bool aIsASCII_STL = true;
344 bool toCreateGroups = false;
345 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
347 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
349 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
351 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
353 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
355 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
356 for ( ; it != aFilterMapSTL.end(); ++it )
357 filters.push_back( it.key() );
359 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
360 fd->setCaption( aTitle );
361 fd->setFilters( filters );
362 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
366 aFilename = fd->selectedFile();
367 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
374 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
375 for ( ; it != aFilterMap.end(); ++it )
376 filters.push_back( it.key() );
378 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
379 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
380 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
381 fd->setCaption( aTitle );
382 fd->setFilters( filters );
383 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
384 fd->SetChecked(toCreateGroups);
388 aFilename = fd->selectedFile();
389 aFormat = aFilterMap[fd->selectedFilter()];
391 if ( !aFilename.isEmpty()
392 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
393 && aFormat==SMESH::MED_V2_1) {
394 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
395 QObject::tr("SMESH_WRN_WARNING"),
396 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
397 QObject::tr("SMESH_BUT_YES"),
398 QObject::tr("SMESH_BUT_NO"),
405 toCreateGroups = fd->IsChecked();
408 if ( !aFilename.isEmpty() ) {
409 // Check whether the file already exists and delete it if yes
410 QFile aFile( aFilename );
411 if ( aFile.exists() )
413 SUIT_OverrideCursor wc;
416 bool Renumber = false ;
417 // PAL 14172 : Check of we have to renumber or not from the preferences before export
419 Renumber= resMgr->booleanValue("SMESH","renumbering");
421 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
422 aMeshEditor->RenumberNodes();
423 aMeshEditor->RenumberElements();
424 if ( SMESHGUI::automaticUpdate() )
427 switch ( theCommandID ) {
430 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
434 aMesh->ExportDAT( aFilename.latin1() );
438 aMesh->ExportUNV( aFilename.latin1() );
442 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
448 catch (const SALOME::SALOME_Exception& S_ex){
450 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
451 QObject::tr("SMESH_WRN_WARNING"),
452 QObject::tr("SMESH_EXPORT_FAILED"),
453 QObject::tr("SMESH_BUT_OK"));
461 inline void InverseEntityMode(unsigned int& theOutputMode,
462 unsigned int theMode)
464 bool anIsNotPresent = ~theOutputMode & theMode;
466 theOutputMode |= theMode;
468 theOutputMode &= ~theMode;
471 void SetDisplayEntity(int theCommandID){
472 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
473 SALOME_ListIO selected;
475 aSel->selectedObjects( selected );
477 if(selected.Extent() >= 1){
478 SALOME_ListIteratorOfListIO It( selected );
479 for(; It.More(); It.Next()){
480 Handle(SALOME_InteractiveObject) IObject = It.Value();
481 if(IObject->hasEntry()){
482 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
483 unsigned int aMode = anActor->GetEntityMode();
484 switch(theCommandID){
486 InverseEntityMode(aMode,SMESH_Actor::eEdges);
489 InverseEntityMode(aMode,SMESH_Actor::eFaces);
492 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
495 aMode = SMESH_Actor::eAllEntity;
499 anActor->SetEntityMode(aMode);
506 void SetDisplayMode(int theCommandID){
507 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
508 SALOME_ListIO selected;
510 aSel->selectedObjects( selected );
512 if(selected.Extent() >= 1){
513 switch(theCommandID){
515 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
516 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
520 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
521 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
524 SALOME_ListIteratorOfListIO It( selected );
525 for(; It.More(); It.Next()){
526 Handle(SALOME_InteractiveObject) IObject = It.Value();
527 if(IObject->hasEntry()){
528 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
529 switch(theCommandID){
531 anActor->SetRepresentation(SMESH_Actor::eEdge);
534 anActor->SetRepresentation(SMESH_Actor::eSurface);
537 if(anActor->IsShrunk())
540 anActor->SetShrink();
543 anActor->SetRepresentation(SMESH_Actor::ePoint);
546 vtkFloatingPointType color[3];
547 anActor->GetSufaceColor(color[0], color[1], color[2]);
548 int c0 = int (color[0] * 255);
549 int c1 = int (color[1] * 255);
550 int c2 = int (color[2] * 255);
551 QColor c(c0, c1, c2);
553 vtkFloatingPointType edgecolor[3];
554 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
555 c0 = int (edgecolor[0] * 255);
556 c1 = int (edgecolor[1] * 255);
557 c2 = int (edgecolor[2] * 255);
558 QColor e(c0, c1, c2);
560 vtkFloatingPointType backfacecolor[3];
561 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
562 c0 = int (backfacecolor[0] * 255);
563 c1 = int (backfacecolor[1] * 255);
564 c2 = int (backfacecolor[2] * 255);
565 QColor b(c0, c1, c2);
567 vtkFloatingPointType nodecolor[3];
568 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
569 c0 = int (nodecolor[0] * 255);
570 c1 = int (nodecolor[1] * 255);
571 c2 = int (nodecolor[2] * 255);
572 QColor n(c0, c1, c2);
574 int Edgewidth = (int)anActor->GetLineWidth();
577 int intValue = int(anActor->GetNodeSize());
578 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
580 SMESHGUI_Preferences_ColorDlg *aDlg =
581 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
582 aDlg->SetColor(1, c);
583 aDlg->SetColor(2, e);
584 aDlg->SetColor(3, n);
585 aDlg->SetColor(4, b);
586 aDlg->SetIntValue(1, Edgewidth);
587 aDlg->SetIntValue(2, intValue);
588 aDlg->SetIntValue(3, int(Shrink*100.));
590 QColor color = aDlg->GetColor(1);
591 QColor edgecolor = aDlg->GetColor(2);
592 QColor nodecolor = aDlg->GetColor(3);
593 QColor backfacecolor = aDlg->GetColor(4);
594 /* actor color and backface color */
595 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
596 vtkFloatingPointType (color.green()) / 255.,
597 vtkFloatingPointType (color.blue()) / 255.);
598 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
599 vtkFloatingPointType (backfacecolor.green()) / 255.,
600 vtkFloatingPointType (backfacecolor.blue()) / 255.);
603 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
604 vtkFloatingPointType (edgecolor.green()) / 255.,
605 vtkFloatingPointType (edgecolor.blue()) / 255.);
607 /* Shrink factor and size edges */
608 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
609 anActor->SetLineWidth(aDlg->GetIntValue(1));
611 /* Nodes color and size */
612 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
613 vtkFloatingPointType (nodecolor.green()) / 255.,
614 vtkFloatingPointType (nodecolor.blue()) / 255.);
615 anActor->SetNodeSize(aDlg->GetIntValue(2));
624 SMESH::RepaintCurrentView();
628 void Control( int theCommandID )
630 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
631 SALOME_ListIO selected;
633 aSel->selectedObjects( selected );
635 if( !selected.IsEmpty() ){
636 Handle(SALOME_InteractiveObject) anIO = selected.First();
639 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
640 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
641 switch ( theCommandID ){
643 aTitle = QObject::tr( "LENGTH_EDGES" );
644 aControl = SMESH_Actor::eLength;
647 aTitle = QObject::tr( "LENGTH2D_EDGES" );
648 aControl = SMESH_Actor::eLength2D;
651 aTitle = QObject::tr( "FREE_EDGES" );
652 aControl = SMESH_Actor::eFreeEdges;
655 aTitle = QObject::tr( "FREE_BORDERS" );
656 aControl = SMESH_Actor::eFreeBorders;
659 aTitle = QObject::tr( "MULTI_BORDERS" );
660 aControl = SMESH_Actor::eMultiConnection;
663 aTitle = QObject::tr( "MULTI2D_BORDERS" );
664 aControl = SMESH_Actor::eMultiConnection2D;
667 aTitle = QObject::tr( "AREA_ELEMENTS" );
668 aControl = SMESH_Actor::eArea;
671 aTitle = QObject::tr( "TAPER_ELEMENTS" );
672 aControl = SMESH_Actor::eTaper;
675 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
676 aControl = SMESH_Actor::eAspectRatio;
679 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
680 aControl = SMESH_Actor::eAspectRatio3D;
683 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
684 aControl = SMESH_Actor::eMinimumAngle;
687 aTitle = QObject::tr( "WARP_ELEMENTS" );
688 aControl = SMESH_Actor::eWarping;
691 aTitle = QObject::tr( "SKEW_ELEMENTS" );
692 aControl = SMESH_Actor::eSkew;
695 aTitle = QObject::tr( "SMESH_VOLUME" );
696 aControl = SMESH_Actor::eVolume3D;
699 anActor->SetControlMode(aControl);
700 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
701 SMESH::RepaintCurrentView();
708 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
709 MeshObjectType theType,
710 const QString theInTypeName,
711 QString & theOutTypeName)
713 SMESH_TypeFilter aTypeFilter( theType );
715 if( !theIO.IsNull() )
717 entry = theIO->getEntry();
718 LightApp_DataOwner owner( entry );
719 if ( aTypeFilter.isOk( &owner )) {
720 theOutTypeName = theInTypeName;
728 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
730 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
731 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
733 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
734 CORBA::String_var anID = aSComp->GetID().c_str();
735 if (!strcmp(anID.in(),theIO->getEntry()))
741 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
742 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
743 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
744 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
745 CheckOIType ( theIO, GROUP, "Group", aTypeName )
753 QString CheckHomogeneousSelection()
755 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
756 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
757 SALOME_ListIO selected;
759 aSel->selectedObjects( selected );
761 QString RefType = CheckTypeObject(selected.First());
762 SALOME_ListIteratorOfListIO It(selected);
763 for (; It.More(); It.Next())
765 Handle(SALOME_InteractiveObject) IObject = It.Value();
766 QString Type = CheckTypeObject(IObject);
767 if (Type.compare(RefType) != 0)
768 return "Heterogeneous Selection";
775 void SMESHGUI::OnEditDelete()
777 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
778 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
779 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
781 QString aParentComponent = QString::null;
782 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
784 QString cur = anIt.Value()->getComponentDataType();
785 if( aParentComponent.isNull() )
786 aParentComponent = cur;
787 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
788 aParentComponent = "";
791 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
792 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
793 QObject::tr("ERR_ERROR"),
794 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
795 QObject::tr("BUT_OK") );
798 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
799 if (SUIT_MessageBox::warn2
800 (SMESHGUI::desktop(),
801 QObject::tr("SMESH_WRN_WARNING"),
802 QObject::tr("SMESH_REALLY_DELETE"),
803 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
806 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
807 SUIT_ViewManager* vm = anApp->activeViewManager();
808 int nbSf = vm->getViewsCount();
810 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
811 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
812 _PTR(GenericAttribute) anAttr;
813 _PTR(AttributeIOR) anIOR;
815 SALOME_ListIteratorOfListIO It(selected);
817 aStudyBuilder->NewCommand(); // There is a transaction
818 for(; It.More(); It.Next()){ // loop on selected IO's
819 Handle(SALOME_InteractiveObject) IObject = It.Value();
820 if(IObject->hasEntry()) {
821 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
823 // disable removal of "SMESH" component object
824 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
826 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
830 // put the whole hierarchy of sub-objects of the selected SO into a list and
831 // then treat them all starting from the deepest objects (at list back)
833 list< _PTR(SObject) > listSO;
834 listSO.push_back( aSO );
835 list< _PTR(SObject) >::iterator itSO = listSO.begin();
836 for ( ; itSO != listSO.end(); ++itSO ) {
837 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
838 for (it->InitEx(false); it->More(); it->Next())
839 listSO.push_back( it->Value() );
842 // treat SO's in the list starting from the back
844 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
845 for ( ; ritSO != listSO.rend(); ++ritSO ) {
846 _PTR(SObject) SO = *ritSO;
848 string anEntry = SO->GetID();
850 /** Erase graphical object **/
851 if(SO->FindAttribute(anAttr, "AttributeIOR")){
852 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
853 for(int i = 0; i < nbSf; i++){
854 SUIT_ViewWindow *sf = aViews[i];
855 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
856 SMESH::RemoveActor(sf,anActor);
861 /** Remove an object from data structures **/
862 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
863 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
864 if ( !aGroup->_is_nil() ) { // DELETE GROUP
865 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
866 aMesh->RemoveGroup( aGroup );
868 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
869 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
870 aMesh->RemoveSubMesh( aSubMesh );
872 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
874 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
877 IObject = new SALOME_InteractiveObject
878 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
879 QString objType = CheckTypeObject(IObject);
880 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
881 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
882 aStudyBuilder->RemoveObjectWithChildren( SO );
884 else {// default action: remove SObject from the study
885 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
886 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
888 aStudyBuilder->RemoveObjectWithChildren( SO );
892 } /* listSO back loop */
893 } /* IObject->hasEntry() */
895 aStudyBuilder->CommitCommand();
897 /* Clear any previous selection */
899 aSel->setSelectedObjects( l1 );
901 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
906 Standard_EXPORT CAM_Module* createModule()
908 return new SMESHGUI();
912 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
914 //=============================================================================
918 //=============================================================================
919 SMESHGUI::SMESHGUI() :
920 SalomeApp_Module( "SMESH" )
922 if ( CORBA::is_nil( myComponentSMESH ) )
924 CORBA::Boolean anIsEmbeddedMode;
925 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
928 myActiveDialogBox = 0;
929 myFilterLibraryDlg = 0;
933 SMESH::GetFilterManager();
936 /* load resources for all available meshers */
937 SMESH::InitAvailableHypotheses();
940 //=============================================================================
944 //=============================================================================
945 SMESHGUI::~SMESHGUI()
947 SMESH::GetFilterManager()->Destroy();
948 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
951 //=============================================================================
955 //=============================================================================
956 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
958 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
960 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
965 bool SMESHGUI::automaticUpdate()
967 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
971 return resMgr->booleanValue( "SMESH", "auto_update", false );
974 //=============================================================================
978 //=============================================================================
979 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
981 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
984 //=============================================================================
988 //=============================================================================
989 SMESHGUI* SMESHGUI::GetSMESHGUI()
991 SMESHGUI* smeshMod = 0;
992 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
995 CAM_Module* module = app->module( "Mesh" );
996 smeshMod = dynamic_cast<SMESHGUI*>( module );
999 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1001 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1004 _PTR(Study) aStudy = study->studyDS();
1006 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1015 Standard_EXPORT SMESHGUI* GetComponentGUI()
1017 return SMESHGUI::GetSMESHGUI();
1021 //=============================================================================
1025 //=============================================================================
1026 void SMESHGUI::SetState(int aState)
1031 //=============================================================================
1035 //=============================================================================
1036 void SMESHGUI::ResetState()
1041 //=============================================================================
1045 //=============================================================================
1046 void SMESHGUI::EmitSignalDeactivateDialog()
1048 emit SignalDeactivateActiveDialog();
1051 //=============================================================================
1055 //=============================================================================
1056 void SMESHGUI::EmitSignalStudyFrameChanged()
1058 emit SignalStudyFrameChanged();
1061 //=============================================================================
1065 //=============================================================================
1066 void SMESHGUI::EmitSignalCloseAllDialogs()
1068 emit SignalCloseAllDialogs();
1071 //=============================================================================
1075 //=============================================================================
1076 QDialog *SMESHGUI::GetActiveDialogBox()
1078 return myActiveDialogBox;
1081 //=============================================================================
1085 //=============================================================================
1086 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1088 myActiveDialogBox = (QDialog *) aDlg;
1092 //=============================================================================
1096 //=============================================================================
1097 SUIT_Desktop* SMESHGUI::desktop()
1099 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1101 return app->desktop();
1106 //=============================================================================
1110 //=============================================================================
1111 SalomeApp_Study* SMESHGUI::activeStudy()
1113 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1115 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1120 //=============================================================================
1124 //=============================================================================
1125 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1127 /* Here the position is on the bottom right corner - 10 */
1128 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1130 SUIT_Desktop *PP = desktop();
1131 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1132 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1136 //=============================================================================
1140 //=============================================================================
1141 static int isStudyLocked(_PTR(Study) theStudy){
1142 return theStudy->GetProperties()->IsLocked();
1145 static bool checkLock(_PTR(Study) theStudy) {
1146 if (isStudyLocked(theStudy)) {
1147 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1148 QObject::tr("WRN_WARNING"),
1149 QObject::tr("WRN_STUDY_LOCKED"),
1150 QObject::tr("BUT_OK") );
1156 //=======================================================================
1157 //function : CheckActiveStudyLocked
1159 //=======================================================================
1161 bool SMESHGUI::isActiveStudyLocked()
1163 _PTR(Study) aStudy = activeStudy()->studyDS();
1164 return checkLock( aStudy );
1167 //=============================================================================
1171 //=============================================================================
1172 bool SMESHGUI::OnGUIEvent( int theCommandID )
1174 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1178 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1179 SUIT_ResourceMgr* mgr = resourceMgr();
1183 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1184 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1187 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1188 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1190 //QAction* act = action( theCommandID );
1192 switch (theCommandID) {
1194 if(checkLock(aStudy)) break;
1202 if(checkLock(aStudy)) break;
1203 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1207 case 122: // EXPORT MED
1216 ::ExportMeshToFile(theCommandID);
1220 case 200: // SCALAR BAR
1222 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1223 SALOME_ListIO selected;
1225 aSel->selectedObjects( selected );
1227 if( selected.Extent() ) {
1228 Handle(SALOME_InteractiveObject) anIO = selected.First();
1229 if( anIO->hasEntry() ) {
1230 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1231 anActor->SetControlMode( SMESH_Actor::eNone );
1239 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1243 case 1134: // Clipping
1244 case 1133: // Tranparency
1245 case 1132: // Colors / Size
1252 ::SetDisplayMode(theCommandID);
1258 case 219: // Volumes
1259 case 220: // All Entity
1260 ::SetDisplayEntity(theCommandID);
1265 if(checkLock(aStudy)) break;
1267 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1270 SMESH::UpdateView();
1272 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1273 SMESH::OnVisuException();
1275 catch (...) { // PAL16774 (Crash after display of many groups)
1276 SMESH::OnVisuException();
1280 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1281 aSel->selectedObjects( l );
1282 aSel->setSelectedObjects( l );
1287 case 301: // DISPLAY
1288 case 302: // DISPLAY ONLY
1290 SMESH::EDisplaing anAction;
1291 switch (theCommandID) {
1292 case 300: anAction = SMESH::eErase; break;
1293 case 301: anAction = SMESH::eDisplay; break;
1294 case 302: anAction = SMESH::eDisplayOnly; break;
1297 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1298 SALOME_ListIO sel_objects, to_process;
1300 aSel->selectedObjects( sel_objects );
1302 if( theCommandID==302 )
1303 startOperation( myEraseAll );
1305 extractContainers( sel_objects, to_process );
1308 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1312 SALOME_ListIteratorOfListIO It( to_process );
1313 for (; It.More(); It.Next()) {
1314 Handle(SALOME_InteractiveObject) IOS = It.Value();
1315 if (IOS->hasEntry()) {
1316 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1317 break; // PAL16774 (Crash after display of many groups)
1318 if (anAction == SMESH::eDisplayOnly)
1319 anAction = SMESH::eDisplay;
1324 // PAL13338 + PAL15161 -->
1325 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1326 SMESH::UpdateView();
1327 // PAL13338 + PAL15161 <--
1329 catch (...) { // PAL16774 (Crash after display of many groups)
1330 SMESH::OnVisuException();
1333 if (anAction == SMESH::eErase) {
1335 aSel->setSelectedObjects( l1 );
1338 aSel->setSelectedObjects( to_process );
1345 if(checkLock(aStudy)) break;
1348 EmitSignalDeactivateDialog();
1350 new SMESHGUI_NodesDlg(this);
1353 SUIT_MessageBox::warn1(desktop(),
1354 tr("SMESH_WRN_WARNING"),
1355 tr("SMESH_WRN_VIEWER_VTK"),
1356 tr("SMESH_BUT_OK"));
1361 case 2151: // FILTER
1365 EmitSignalDeactivateDialog();
1366 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1371 case 406: // MOVE NODE
1375 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1376 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1380 if(checkLock(aStudy)) break;
1381 new SMESHGUI_MoveNodesDlg(this);
1385 case 701: // COMPUTE MESH
1387 if (checkLock(aStudy)) break;
1389 startOperation( 701 );
1393 case 702: // Create mesh
1394 startOperation( 702 );
1396 case 703: // Create sub-mesh
1397 startOperation( 703 );
1399 case 704: // Edit mesh/sub-mesh
1400 startOperation( 704 );
1402 case 710: // Build compound mesh
1404 if (checkLock(aStudy)) break;
1405 EmitSignalDeactivateDialog();
1406 new SMESHGUI_BuildCompoundDlg( this );
1409 case 407: // DIAGONAL INVERSION
1410 case 408: // Delete diagonal
1414 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1415 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1419 if ( checkLock( aStudy ) )
1422 /*Standard_Boolean aRes;
1423 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1424 if ( aMesh->_is_nil() )
1426 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1427 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1431 EmitSignalDeactivateDialog();
1432 if ( theCommandID == 407 )
1433 new SMESHGUI_TrianglesInversionDlg(this);
1435 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1438 case 409: // Change orientation
1439 case 410: // Union of triangles
1440 case 411: // Cutting of quadrangles
1444 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1445 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1449 if ( checkLock( aStudy ) )
1452 EmitSignalDeactivateDialog();
1453 SMESHGUI_MultiEditDlg* aDlg = NULL;
1454 if ( theCommandID == 409 )
1455 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1456 else if ( theCommandID == 410 )
1457 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1459 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1464 case 412: // Smoothing
1466 if(checkLock(aStudy)) break;
1468 EmitSignalDeactivateDialog();
1469 new SMESHGUI_SmoothingDlg( this );
1472 SUIT_MessageBox::warn1(desktop(),
1473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1474 tr("SMESH_BUT_OK"));
1478 case 413: // Extrusion
1480 if (checkLock(aStudy)) break;
1482 EmitSignalDeactivateDialog();
1483 new SMESHGUI_ExtrusionDlg ( this );
1485 SUIT_MessageBox::warn1(desktop(),
1486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487 tr("SMESH_BUT_OK"));
1491 case 414: // Revolution
1493 if(checkLock(aStudy)) break;
1495 EmitSignalDeactivateDialog();
1496 new SMESHGUI_RevolutionDlg( this );
1499 SUIT_MessageBox::warn1(desktop(),
1500 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1501 tr("SMESH_BUT_OK"));
1505 case 415: // Pattern mapping
1507 if ( checkLock( aStudy ) )
1511 EmitSignalDeactivateDialog();
1512 new SMESHGUI_MeshPatternDlg( this );
1515 SUIT_MessageBox::warn1(desktop(),
1516 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1517 tr("SMESH_BUT_OK"));
1521 case 416: // Extrusion along a path
1523 if (checkLock(aStudy)) break;
1525 EmitSignalDeactivateDialog();
1526 new SMESHGUI_ExtrusionAlongPathDlg( this );
1528 SUIT_MessageBox::warn1(desktop(),
1529 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1530 tr("SMESH_BUT_OK"));
1534 case 417: // Convert mesh to quadratic
1536 startOperation( 417 );
1537 /* if (checkLock(aStudy)) break;
1539 EmitSignalDeactivateDialog();
1540 new SMESHGUI_ConvToQuadDlg();
1542 SUIT_MessageBox::warn1(desktop(),
1543 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1544 tr("SMESH_BUT_OK"));
1548 case 801: // CREATE GROUP
1552 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1553 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1557 if(checkLock(aStudy)) break;
1558 EmitSignalDeactivateDialog();
1559 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1561 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1562 SALOME_ListIO selected;
1564 aSel->selectedObjects( selected );
1566 int nbSel = selected.Extent();
1568 // check if mesh is selected
1569 aMesh = SMESH::GetMeshByIO( selected.First() );
1571 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1576 case 802: // CONSTRUCT GROUP
1580 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1581 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1585 if(checkLock(aStudy)) break;
1586 EmitSignalDeactivateDialog();
1588 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1589 SALOME_ListIO selected;
1591 aSel->selectedObjects( selected );
1593 int nbSel = selected.Extent();
1595 // check if submesh is selected
1596 Handle(SALOME_InteractiveObject) IObject = selected.First();
1597 if (IObject->hasEntry()) {
1598 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1600 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1601 if (!aSubMesh->_is_nil()) {
1603 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1604 // get submesh elements list by types
1605 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1606 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1607 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1608 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1609 // create group for each type o elements
1610 QString aName = IObject->getName();
1611 if (aNodes->length() > 0) {
1612 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1613 aGroup->Add(aNodes.inout());
1615 if (aEdges->length() > 0) {
1616 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1617 aGroup->Add(aEdges.inout());
1619 if (aFaces->length() > 0) {
1620 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1621 aGroup->Add(aFaces.inout());
1623 if (aVolumes->length() > 0) {
1624 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1625 aGroup->Add(aVolumes.inout());
1630 catch(const SALOME::SALOME_Exception & S_ex){
1631 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1638 SUIT_MessageBox::warn1(desktop(),
1639 tr("SMESH_WRN_WARNING"),
1640 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1641 tr("SMESH_BUT_OK"));
1646 case 803: // EDIT GROUP
1650 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1651 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1655 if(checkLock(aStudy)) break;
1656 EmitSignalDeactivateDialog();
1658 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1659 SALOME_ListIO selected;
1661 aSel->selectedObjects( selected );
1663 SALOME_ListIteratorOfListIO It (selected);
1664 int nbSelectedGroups = 0;
1665 for ( ; It.More(); It.Next() )
1667 SMESH::SMESH_GroupBase_var aGroup =
1668 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1669 if (!aGroup->_is_nil()) {
1671 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1675 if (nbSelectedGroups == 0)
1677 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1683 case 804: // Add elements to group
1685 if(checkLock(aStudy)) break;
1686 if (myState == 800) {
1687 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1688 if (aDlg) aDlg->onAdd();
1693 case 805: // Remove elements from group
1695 if(checkLock(aStudy)) break;
1696 if (myState == 800) {
1697 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1698 if (aDlg) aDlg->onRemove();
1703 case 810: // Union Groups
1704 case 811: // Intersect groups
1705 case 812: // Cut groups
1709 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1710 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1714 if ( checkLock( aStudy ) )
1717 EmitSignalDeactivateDialog();
1720 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1721 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1722 else aMode = SMESHGUI_GroupOpDlg::CUT;
1724 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1728 case 813: // Delete groups with their contents
1732 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1733 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1737 if ( checkLock( aStudy ) )
1740 EmitSignalDeactivateDialog();
1742 new SMESHGUI_DeleteGroupDlg( this );
1746 case 900: // MESH INFOS
1748 EmitSignalDeactivateDialog();
1749 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1750 SALOME_ListIO selected;
1752 aSel->selectedObjects( selected );
1754 if ( selected.Extent() > 1 ) { // a dlg for each IO
1756 SALOME_ListIteratorOfListIO It (selected);
1757 for ( ; It.More(); It.Next() ) {
1758 IOs.Clear(); IOs.Append( It.Value() );
1759 aSel->setSelectedObjects( IOs );
1760 new SMESHGUI_MeshInfosDlg(this, "", false);
1762 // restore selection
1763 aSel->setSelectedObjects( selected );
1766 new SMESHGUI_MeshInfosDlg(this, "", false);
1770 case 902: // STANDARD MESH INFOS
1772 EmitSignalDeactivateDialog();
1773 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1774 SALOME_ListIO selected;
1776 aSel->selectedObjects( selected );
1778 if ( selected.Extent() > 1 ) { // a dlg for each IO
1780 SALOME_ListIteratorOfListIO It (selected);
1781 for ( ; It.More(); It.Next() ) {
1783 IOs.Append( It.Value() );
1784 aSel->setSelectedObjects( IOs );
1785 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1787 // restore selection
1788 aSel->setSelectedObjects( selected );
1791 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1795 case 903: // WHAT IS
1797 EmitSignalDeactivateDialog();
1798 new SMESHGUI_WhatIsDlg( this, "", false);
1802 case 1100: // EDIT HYPOTHESIS
1804 if(checkLock(aStudy)) break;
1806 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1807 SALOME_ListIO selected;
1809 aSel->selectedObjects( selected );
1811 int nbSel = selected.Extent();
1814 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1815 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1817 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1818 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1819 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1820 if ( !aHypothesis->_is_nil() )
1822 CORBA::String_var aHypType = aHypothesis->GetName();
1823 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1825 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1832 updateObjBrowser( true );
1836 case 1101: // RENAME
1838 if ( checkLock( aStudy ) )
1841 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1842 SALOME_ListIO selected;
1844 aSel->selectedObjects( selected );
1846 SALOME_ListIteratorOfListIO It( selected );
1847 for ( ; It.More(); It.Next() )
1849 Handle(SALOME_InteractiveObject) IObject = It.Value();
1850 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1851 _PTR(GenericAttribute) anAttr;
1852 _PTR(AttributeName) aName;
1855 if ( obj->FindAttribute(anAttr, "AttributeName") )
1858 QString newName = QString(aName->Value().c_str());
1859 newName = LightApp_NameDlg::getName(desktop(), newName);
1860 if ( !newName.isEmpty() )
1862 //old source: aStudy->renameIObject( IObject, newName );
1863 aName->SetValue( newName.latin1() );
1865 // if current object is group update group's name
1866 SMESH::SMESH_GroupBase_var aGroup =
1867 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1868 if (!aGroup->_is_nil() )
1869 aGroup->SetName( newName.latin1() );
1879 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1881 if(checkLock(aStudy)) break;
1882 SUIT_OverrideCursor wc;
1884 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1885 SALOME_ListIO selected;
1887 aSel->selectedObjects( selected, QString::null, false );
1889 SALOME_ListIteratorOfListIO It(selected);
1890 for (int i = 0; It.More(); It.Next(), i++) {
1891 Handle(SALOME_InteractiveObject) IObject = It.Value();
1892 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1895 aSel->setSelectedObjects( l1 );
1900 case 401: // GEOM::EDGE
1901 case 4021: // TRIANGLE
1903 case 4023: // POLYGON
1907 if(checkLock(aStudy)) break;
1909 EmitSignalDeactivateDialog();
1910 SMDSAbs_ElementType type = SMDSAbs_Edge;
1912 switch (theCommandID) {
1913 case 4021: // TRIANGLE
1914 type = SMDSAbs_Face; nbNodes = 3; break;
1916 type = SMDSAbs_Face; nbNodes = 4; break;
1918 type = SMDSAbs_Volume; nbNodes = 4; break;
1919 case 4023: // POLYGON
1920 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1922 type = SMDSAbs_Volume; nbNodes = 8; break;
1923 case 4033: // POLYHEDRE
1924 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1927 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1930 SUIT_MessageBox::warn1(desktop(),
1931 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1932 tr("SMESH_BUT_OK"));
1936 case 4033: // POLYHEDRON
1938 if(checkLock(aStudy)) break;
1940 EmitSignalDeactivateDialog();
1941 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1944 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1945 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1946 tr("SMESH_BUT_OK"));
1950 case 4034: // QUADRATIC EDGE
1951 case 4035: // QUADRATIC TRIANGLE
1952 case 4036: // QUADRATIC QUADRANGLE
1953 case 4037: // QUADRATIC TETRAHEDRON
1954 case 4038: // QUADRATIC PYRAMID
1955 case 4039: // QUADRATIC PENTAHEDRON
1956 case 4040: // QUADRATIC HEXAHEDRON
1958 if(checkLock(aStudy)) break;
1960 EmitSignalDeactivateDialog();
1963 switch (theCommandID) {
1965 type = QUAD_EDGE; break;
1967 type = QUAD_TRIANGLE; break;
1969 type = QUAD_QUADRANGLE; break;
1971 type = QUAD_TETRAHEDRON; break;
1973 type = QUAD_PYRAMID; break;
1975 type = QUAD_PENTAHEDRON; break;
1977 type = QUAD_HEXAHEDRON;
1981 new SMESHGUI_AddQuadraticElementDlg( this, type );
1984 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1985 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1986 tr("SMESH_BUT_OK"));
1990 case 4041: // REMOVES NODES
1992 if(checkLock(aStudy)) break;
1994 EmitSignalDeactivateDialog();
1995 new SMESHGUI_RemoveNodesDlg(this);
1998 SUIT_MessageBox::warn1(desktop(),
1999 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2000 tr("SMESH_BUT_OK"));
2004 case 4042: // REMOVES ELEMENTS
2006 if(checkLock(aStudy)) break;
2008 EmitSignalDeactivateDialog();
2009 new SMESHGUI_RemoveElementsDlg(this);
2013 SUIT_MessageBox::warn1(desktop(),
2014 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2015 tr("SMESH_BUT_OK"));
2019 case 4051: // RENUMBERING NODES
2021 if(checkLock(aStudy)) break;
2023 EmitSignalDeactivateDialog();
2024 new SMESHGUI_RenumberingDlg( this, "", 0);
2028 SUIT_MessageBox::warn1(desktop(),
2029 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2030 tr("SMESH_BUT_OK"));
2034 case 4052: // RENUMBERING ELEMENTS
2036 if(checkLock(aStudy)) break;
2038 EmitSignalDeactivateDialog();
2039 new SMESHGUI_RenumberingDlg( this, "", 1);
2043 SUIT_MessageBox::warn1(desktop(),
2044 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2045 tr("SMESH_BUT_OK"));
2049 case 4061: // TRANSLATION
2051 if(checkLock(aStudy)) break;
2053 EmitSignalDeactivateDialog();
2054 new SMESHGUI_TranslationDlg( this );
2057 SUIT_MessageBox::warn1(desktop(),
2058 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2059 tr("SMESH_BUT_OK"));
2063 case 4062: // ROTATION
2065 if(checkLock(aStudy)) break;
2067 EmitSignalDeactivateDialog();
2068 new SMESHGUI_RotationDlg( this );
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4063: // SYMMETRY
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 new SMESHGUI_SymmetryDlg( this );
2085 SUIT_MessageBox::warn1(desktop(),
2086 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2087 tr("SMESH_BUT_OK"));
2091 case 4064: // SEWING
2093 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2096 new SMESHGUI_SewingDlg( this );
2099 SUIT_MessageBox::warn1(desktop(),
2100 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2101 tr("SMESH_BUT_OK"));
2105 case 4065: // MERGE NODES
2107 if(checkLock(aStudy)) break;
2109 EmitSignalDeactivateDialog();
2110 new SMESHGUI_EditMeshDlg( this, 0 );
2113 SUIT_MessageBox::warn1(desktop(),
2114 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2115 tr("SMESH_BUT_OK"));
2119 case 4066: // MERGE EQUAL ELEMENTS
2121 if (checkLock(aStudy)) break;
2123 EmitSignalDeactivateDialog();
2124 new SMESHGUI_EditMeshDlg( this, 1 );
2126 SUIT_MessageBox::warn1(desktop(),
2127 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2128 tr("SMESH_BUT_OK"));
2133 case 4067: // MAKE MESH PASS THROUGH POINT
2134 startOperation( 4067 );
2137 case 5105: // Library of selection filters
2139 static QValueList<int> aTypes;
2140 if ( aTypes.isEmpty() )
2142 aTypes.append( SMESH::NODE );
2143 aTypes.append( SMESH::EDGE );
2144 aTypes.append( SMESH::FACE );
2145 aTypes.append( SMESH::VOLUME );
2147 if (!myFilterLibraryDlg)
2148 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2149 else if (myFilterLibraryDlg->isHidden())
2150 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2151 myFilterLibraryDlg->raise();
2155 case 6017: // CONTROLS
2171 LightApp_SelectionMgr* mgr = selectionMgr();
2172 SALOME_ListIO selected; mgr->selectedObjects( selected );
2174 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2175 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2177 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2178 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2179 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2180 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2181 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2182 ::Control( theCommandID );
2187 SUIT_MessageBox::warn1(desktop(),
2188 tr( "SMESH_WRN_WARNING" ),
2189 tr( "SMESH_BAD_SELECTION" ),
2190 tr( "SMESH_BUT_OK" ) );
2194 SUIT_MessageBox::warn1(desktop(),
2195 tr( "SMESH_WRN_WARNING" ),
2196 tr( "NOT_A_VTK_VIEWER" ),
2197 tr( "SMESH_BUT_OK" ) );
2202 LightApp_SelectionMgr* mgr = selectionMgr();
2203 SALOME_ListIO selected; mgr->selectedObjects( selected );
2205 SALOME_ListIteratorOfListIO it(selected);
2206 for(; it.More(); it.Next()) {
2207 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2208 if(anIObject->hasEntry()) {
2209 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2210 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2218 LightApp_SelectionMgr* mgr = selectionMgr();
2219 SALOME_ListIO selected; mgr->selectedObjects( selected );
2221 if (selected.Extent() == 1) {
2222 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2223 if(anIObject->hasEntry())
2224 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2225 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2232 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2233 //updateObjBrowser();
2237 //=============================================================================
2241 //=============================================================================
2242 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2247 //=============================================================================
2251 //=============================================================================
2252 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2257 //=============================================================================
2261 //=============================================================================
2262 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2267 //=============================================================================
2268 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2269 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2271 //=============================================================================
2272 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2273 SUIT_ViewWindow* wnd )
2275 if(theIO->hasEntry()){
2276 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2277 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2281 //=======================================================================
2282 // function : createSMESHAction
2284 //=======================================================================
2285 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2288 QWidget* parent = application()->desktop();
2289 SUIT_ResourceMgr* resMgr = resourceMgr();
2291 if ( icon_id.length() )
2292 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2294 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2295 if ( !pix.isNull() )
2296 icon = QIconSet( pix );
2298 QString tooltip = tr( QString( "TOP_" )+po_id ),
2299 menu = tr( QString( "MEN_" )+po_id ),
2300 status_bar = tr( QString( "STB_" )+po_id );
2302 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2305 //=======================================================================
2306 // function : createPopupItem
2308 //=======================================================================
2309 void SMESHGUI::createPopupItem( const int id,
2310 const QString& clients,
2311 const QString& types,
2312 const QString& theRule,
2317 parentId = popupMgr()->actionId( action( pId ) );
2319 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2320 popupMgr()->insert( action( id ), parentId, 0 );
2322 QChar lc = QtxPopupMgr::Selection::defEquality();
2323 QString rule = "(%1) and (%2) and (%3)";
2324 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2325 if( clients.isEmpty() )
2326 rule = rule.arg( QString( "true" ) );
2328 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2329 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2332 bool cont = myRules.contains( id );
2334 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2336 popupMgr()->setRule( action( id ), rule, true );
2337 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2340 //=======================================================================
2341 // function : initialize
2343 //=======================================================================
2344 void SMESHGUI::initialize( CAM_Application* app )
2346 SalomeApp_Module::initialize( app );
2348 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2350 /* Automatic Update flag */
2351 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2353 // ----- create actions --------------
2355 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2356 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2357 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2358 createSMESHAction( 114, "NUM" );
2359 createSMESHAction( 121, "DAT" );
2360 createSMESHAction( 122, "MED" );
2361 createSMESHAction( 123, "UNV" );
2362 createSMESHAction( 140, "STL" );
2363 createSMESHAction( 124, "EXPORT_DAT" );
2364 createSMESHAction( 125, "EXPORT_MED" );
2365 createSMESHAction( 126, "EXPORT_UNV" );
2366 createSMESHAction( 141, "EXPORT_STL" );
2367 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2368 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2369 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2370 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2371 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2372 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2373 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2374 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2375 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2376 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2377 createSMESHAction( 804, "ADD" );
2378 createSMESHAction( 805, "REMOVE" );
2379 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2380 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2381 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2382 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2383 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2384 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2385 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2386 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2387 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2388 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2389 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2390 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2391 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2392 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2393 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2394 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2395 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2396 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2397 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2398 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2399 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2400 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2401 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2402 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2403 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2404 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2405 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2406 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2407 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2408 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2409 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2410 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2411 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2412 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2413 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2414 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2415 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2416 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2417 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2418 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2419 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2420 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2421 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2422 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2423 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2424 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2425 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2426 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2427 createSMESHAction( 415, "MAP", "ICON_MAP" );
2428 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2429 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2430 createSMESHAction( 200, "RESET" );
2431 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2432 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2433 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2434 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2435 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2436 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2437 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2438 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2439 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2440 createSMESHAction( 220, "ALL" );
2441 createSMESHAction( 1100, "EDIT_HYPO" );
2442 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2443 createSMESHAction( 1102, "UNASSIGN" );
2444 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2445 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2446 createSMESHAction( 1131, "DISPMODE" );
2447 createSMESHAction( 1132, "COLORS" );
2448 createSMESHAction( 1133, "TRANSP" );
2449 createSMESHAction( 1134, "CLIP" );
2450 createSMESHAction( 1135, "DISP_ENT" );
2451 createSMESHAction( 2000, "CTRL" );
2453 createSMESHAction( 300, "ERASE" );
2454 createSMESHAction( 301, "DISPLAY" );
2455 createSMESHAction( 302, "DISPLAY_ONLY" );
2456 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2457 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2458 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2459 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2460 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2461 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2462 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2463 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2465 // ----- create menu --------------
2466 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2467 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2468 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2469 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2470 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2471 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2472 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2474 createMenu( separator(), fileId );
2476 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2477 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2478 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2479 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2480 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2481 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2483 createMenu( 111, importId, -1 );
2484 createMenu( 112, importId, -1 );
2485 createMenu( 113, importId, -1 );
2487 createMenu( 121, exportId, -1 );
2488 createMenu( 122, exportId, -1 );
2489 createMenu( 123, exportId, -1 );
2490 createMenu( 140, exportId, -1 ); // export to stl STL
2492 createMenu( separator(), fileId, 10 );
2494 createMenu( 33, editId, -1 );
2496 createMenu( 5105, toolsId, -1 );
2498 createMenu( 702, meshId, -1 );
2499 createMenu( 703, meshId, -1 );
2500 createMenu( 704, meshId, -1 );
2501 createMenu( 710, meshId, -1 );
2502 createMenu( separator(), meshId, -1 );
2503 createMenu( 701, meshId, -1 );
2504 createMenu( separator(), meshId, -1 );
2505 createMenu( 801, meshId, -1 );
2506 createMenu( 802, meshId, -1 );
2507 createMenu( 803, meshId, -1 );
2508 createMenu( separator(), meshId, -1 );
2509 createMenu( 810, meshId, -1 );
2510 createMenu( 811, meshId, -1 );
2511 createMenu( 812, meshId, -1 );
2512 createMenu( separator(), meshId, -1 );
2513 createMenu( 813, meshId, -1 );
2514 createMenu( separator(), meshId, -1 );
2515 createMenu( 900, meshId, -1 );
2516 createMenu( 902, meshId, -1 );
2517 createMenu( 903, meshId, -1 );
2518 createMenu( separator(), meshId, -1 );
2520 createMenu( 6003, ctrlId, -1 );
2521 createMenu( 6001, ctrlId, -1 );
2522 createMenu( 6004, ctrlId, -1 );
2523 createMenu( separator(), ctrlId, -1 );
2524 createMenu( 6002, ctrlId, -1 );
2525 createMenu( 6018, ctrlId, -1 );
2526 createMenu( 6019, ctrlId, -1 );
2527 createMenu( 6011, ctrlId, -1 );
2528 createMenu( 6012, ctrlId, -1 );
2529 createMenu( 6013, ctrlId, -1 );
2530 createMenu( 6014, ctrlId, -1 );
2531 createMenu( 6015, ctrlId, -1 );
2532 createMenu( 6016, ctrlId, -1 );
2533 createMenu( separator(), ctrlId, -1 );
2534 createMenu( 6017, ctrlId, -1 );
2535 createMenu( 6009, ctrlId, -1 );
2536 createMenu( separator(), ctrlId, -1 );
2538 createMenu( 400, addId, -1 );
2539 createMenu( 401, addId, -1 );
2540 createMenu( 4021, addId, -1 );
2541 createMenu( 4022, addId, -1 );
2542 createMenu( 4023, addId, -1 );
2543 createMenu( 4031, addId, -1 );
2544 createMenu( 4032, addId, -1 );
2545 createMenu( 4033, addId, -1 );
2546 createMenu( separator(), addId, -1 );
2547 createMenu( 4034, addId, -1 );
2548 createMenu( 4035, addId, -1 );
2549 createMenu( 4036, addId, -1 );
2550 createMenu( 4037, addId, -1 );
2551 createMenu( 4038, addId, -1 );
2552 createMenu( 4039, addId, -1 );
2553 createMenu( 4040, addId, -1 );
2555 createMenu( 4041, removeId, -1 );
2556 createMenu( 4042, removeId, -1 );
2558 createMenu( 4051, renumId, -1 );
2559 createMenu( 4052, renumId, -1 );
2561 createMenu( 4061, transfId, -1 );
2562 createMenu( 4062, transfId, -1 );
2563 createMenu( 4063, transfId, -1 );
2564 createMenu( 4064, transfId, -1 );
2565 createMenu( 4065, transfId, -1 );
2566 createMenu( 4066, transfId, -1 );
2568 createMenu( 406, modifyId, -1 );
2569 createMenu( 4067,modifyId, -1 );
2570 createMenu( 407, modifyId, -1 );
2571 createMenu( 408, modifyId, -1 );
2572 createMenu( 409, modifyId, -1 );
2573 createMenu( 410, modifyId, -1 );
2574 createMenu( 411, modifyId, -1 );
2575 createMenu( 412, modifyId, -1 );
2576 createMenu( 413, modifyId, -1 );
2577 createMenu( 416, modifyId, -1 );
2578 createMenu( 414, modifyId, -1 );
2579 createMenu( 415, modifyId, -1 );
2580 createMenu( 417, modifyId, -1 );
2582 createMenu( 214, viewId, -1 );
2584 // ----- create toolbars --------------
2585 int meshTb = createTool( tr( "TB_MESH" ) ),
2586 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2587 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2588 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2589 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2591 createTool( 702, meshTb );
2592 createTool( 703, meshTb );
2593 createTool( 704, meshTb );
2594 createTool( 710, meshTb );
2595 createTool( separator(), meshTb );
2596 createTool( 701, meshTb );
2597 createTool( separator(), meshTb );
2598 createTool( 801, meshTb );
2599 createTool( 802, meshTb );
2600 createTool( 803, meshTb );
2601 createTool( separator(), meshTb );
2602 createTool( 900, meshTb );
2603 createTool( 902, meshTb );
2604 createTool( 903, meshTb );
2605 createTool( separator(), meshTb );
2607 createTool( 6001, ctrlTb );
2608 createTool( 6003, ctrlTb );
2609 createTool( 6004, ctrlTb );
2610 createTool( separator(), ctrlTb );
2611 createTool( 6002, ctrlTb );
2612 createTool( 6018, ctrlTb );
2613 createTool( 6019, ctrlTb );
2614 createTool( 6011, ctrlTb );
2615 createTool( 6012, ctrlTb );
2616 createTool( 6013, ctrlTb );
2617 createTool( 6014, ctrlTb );
2618 createTool( 6015, ctrlTb );
2619 createTool( 6016, ctrlTb );
2620 createTool( separator(), ctrlTb );
2621 createTool( 6017, ctrlTb );
2622 createTool( 6009, ctrlTb );
2623 createTool( separator(), ctrlTb );
2625 createTool( 400, addRemTb );
2626 createTool( 401, addRemTb );
2627 createTool( 4021, addRemTb );
2628 createTool( 4022, addRemTb );
2629 createTool( 4023, addRemTb );
2630 createTool( 4031, addRemTb );
2631 createTool( 4032, addRemTb );
2632 createTool( 4033, addRemTb );
2633 createTool( separator(), addRemTb );
2634 createTool( 4034, addRemTb );
2635 createTool( 4035, addRemTb );
2636 createTool( 4036, addRemTb );
2637 createTool( 4037, addRemTb );
2638 createTool( 4038, addRemTb );
2639 createTool( 4039, addRemTb );
2640 createTool( 4040, addRemTb );
2641 createTool( separator(), addRemTb );
2642 createTool( 4041, addRemTb );
2643 createTool( 4042, addRemTb );
2644 createTool( separator(), addRemTb );
2645 createTool( 4051, addRemTb );
2646 createTool( 4052, addRemTb );
2647 createTool( separator(), addRemTb );
2648 createTool( 4061, addRemTb );
2649 createTool( 4062, addRemTb );
2650 createTool( 4063, addRemTb );
2651 createTool( 4064, addRemTb );
2652 createTool( 4065, addRemTb );
2653 createTool( 4066, addRemTb );
2654 createTool( separator(), addRemTb );
2656 createTool( 406, modifyTb );
2657 createTool( 4067,modifyTb );
2658 createTool( 407, modifyTb );
2659 createTool( 408, modifyTb );
2660 createTool( 409, modifyTb );
2661 createTool( 410, modifyTb );
2662 createTool( 411, modifyTb );
2663 createTool( 412, modifyTb );
2664 createTool( 413, modifyTb );
2665 createTool( 416, modifyTb );
2666 createTool( 414, modifyTb );
2667 createTool( 415, modifyTb );
2668 createTool( 417, modifyTb );
2670 createTool( 214, dispModeTb );
2674 QString OB = "'ObjectBrowser'",
2675 View = "'" + SVTK_Viewer::Type() + "'",
2677 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2678 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2679 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2680 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2681 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2682 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2683 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2684 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2685 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2686 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2687 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2689 mesh_group = mesh + " " + subMesh + " " + group,
2690 hyp_alg = hypo + " " + algo;
2692 // popup for object browser
2694 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2695 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2696 createPopupItem( 803, OB, group ); // EDIT_GROUP
2697 popupMgr()->insert( separator(), -1, 0 );
2698 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2699 createPopupItem( 214, OB, mesh_group ); // UPDATE
2700 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2701 createPopupItem( 902, OB, mesh ); // STD_INFO
2702 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2703 popupMgr()->insert( separator(), -1, 0 );
2704 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2705 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2706 popupMgr()->insert( separator(), -1, 0 );
2707 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2708 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2709 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2710 popupMgr()->insert( separator(), -1, 0 );
2712 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2713 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2714 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2715 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2716 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2717 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2718 popupMgr()->insert( separator(), -1, 0 );
2721 createPopupItem( 803, View, group ); // EDIT_GROUP
2722 createPopupItem( 804, View, elems ); // ADD
2723 createPopupItem( 805, View, elems ); // REMOVE
2724 popupMgr()->insert( separator(), -1, 0 );
2725 createPopupItem( 214, View, mesh_group ); // UPDATE
2726 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2727 createPopupItem( 902, View, mesh ); // STD_INFO
2728 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2729 popupMgr()->insert( separator(), -1, 0 );
2733 isInvisible("not( isVisible )"),
2734 isEmpty("numberOfNodes = 0"),
2735 isNotEmpty("numberOfNodes <> 0"),
2737 // has nodes, edges, etc in VISIBLE! actor
2738 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2739 hasElems("(count( elemTypes ) > 0)"),
2740 hasDifferentElems("(count( elemTypes ) > 1)"),
2741 hasEdges("({'Edge'} in elemTypes)"),
2742 hasFaces("({'Face'} in elemTypes)"),
2743 hasVolumes("({'Volume'} in elemTypes)");
2745 QString lc = QtxPopupMgr::Selection::defEquality();
2746 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2747 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2748 aType = aType.arg( mesh_group );
2749 QString aMeshInVTK = aClient + "&&" + aType;
2751 //-------------------------------------------------
2753 //-------------------------------------------------
2754 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2756 popupMgr()->insert( action( 9010 ), anId, -1 );
2757 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2758 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2760 popupMgr()->insert( action( 9011 ), anId, -1 );
2761 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2762 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2764 popupMgr()->insert( separator(), -1, -1 );
2766 //-------------------------------------------------
2768 //-------------------------------------------------
2769 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2771 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2772 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2773 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2775 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2776 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2777 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2779 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2780 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2781 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2783 popupMgr()->insert( separator(), anId, -1 );
2785 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2786 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2787 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2789 //-------------------------------------------------
2791 //-------------------------------------------------
2792 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2794 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2796 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2797 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2798 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2800 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2801 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2802 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2804 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2805 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2806 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2808 popupMgr()->insert( separator(), anId, -1 );
2810 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2811 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2813 //-------------------------------------------------
2815 //-------------------------------------------------
2816 popupMgr()->insert( action( 1132 ), -1, -1 );
2817 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2819 //-------------------------------------------------
2821 //-------------------------------------------------
2822 popupMgr()->insert( action( 1133 ), -1, -1 );
2823 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2825 //-------------------------------------------------
2827 //-------------------------------------------------
2828 popupMgr()->insert( action( 1134 ), -1, -1 );
2829 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2831 popupMgr()->insert( separator(), -1, -1 );
2833 //-------------------------------------------------
2835 //-------------------------------------------------
2837 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2838 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2839 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2841 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2843 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2844 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2846 popupMgr()->insert( separator(), anId, -1 );
2848 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2849 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2850 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2852 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2853 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2854 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2856 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2857 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2858 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2860 popupMgr()->insert( separator(), anId, -1 );
2862 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2863 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2864 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2866 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2867 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2868 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2870 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2871 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2872 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2874 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2875 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2876 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2878 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2879 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2880 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2882 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2883 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2884 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2886 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2887 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2888 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2890 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2891 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2892 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2894 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2895 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2896 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2898 popupMgr()->insert( separator(), anId, -1 );
2900 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2901 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2902 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2904 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2905 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2906 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2908 popupMgr()->insert( separator(), anId, -1 );
2910 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2911 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2913 popupMgr()->insert( separator(), -1, -1 );
2915 //-------------------------------------------------
2917 //-------------------------------------------------
2918 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2919 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2920 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2922 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2923 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2924 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2925 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2927 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2928 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2930 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2931 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2933 popupMgr()->insert( separator(), -1, -1 );
2935 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2936 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2939 bool SMESHGUI::activateModule( SUIT_Study* study )
2941 bool res = SalomeApp_Module::activateModule( study );
2943 setMenuShown( true );
2944 setToolShown( true );
2946 // Reset actions accelerator keys
2947 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2948 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2949 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2954 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2956 setMenuShown( false );
2957 setToolShown( false );
2959 EmitSignalCloseAllDialogs();
2961 // Unset actions accelerator keys
2962 action(111)->setAccel(QKeySequence()); // Import DAT
2963 action(112)->setAccel(QKeySequence()); // Import UNV
2964 action(113)->setAccel(QKeySequence()); // Import MED
2966 return SalomeApp_Module::deactivateModule( study );
2969 void SMESHGUI::studyClosed( SUIT_Study* s )
2971 SMESH::RemoveVisuData( s->id() );
2972 SalomeApp_Module::studyClosed( s );
2975 void SMESHGUI::OnGUIEvent()
2977 const QObject* obj = sender();
2978 if ( !obj || !obj->inherits( "QAction" ) )
2980 int id = actionId((QAction*)obj);
2985 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2987 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2988 if ( CORBA::is_nil( myComponentSMESH ) )
2990 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2992 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2993 return aGUI.myComponentSMESH;
2996 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2997 return myComponentSMESH;
3000 QString SMESHGUI::engineIOR() const
3002 CORBA::ORB_var anORB = getApp()->orb();
3003 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3007 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3009 SMESHGUI_Selection sel;
3010 sel.init( client, selectionMgr() );
3011 popupMgr()->updatePopup( menu, &sel );
3014 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3016 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3017 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3020 void SMESHGUI::viewManagers( QStringList& list ) const
3022 list.append( SVTK_Viewer::Type() );
3025 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3027 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3028 SMESH::UpdateSelectionProp( this );
3031 void SMESHGUI::createPreferences()
3033 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3035 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3036 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3038 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3039 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3040 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3042 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3043 setPreferenceProperty( precGroup, "columns", 1 );
3045 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3047 setPreferenceProperty( prec, "min", 0 );
3048 setPreferenceProperty( prec, "max", 16 );
3050 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3051 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3053 modes.append( "Wireframe" );
3054 modes.append( "Shading" );
3055 modes.append( "Nodes" );
3056 modes.append( "Shrink" );
3057 QValueList<QVariant> indices;
3058 indices.append( 0 );
3059 indices.append( 1 );
3060 indices.append( 2 );
3061 indices.append( 3 );
3062 setPreferenceProperty( dispmode, "strings", modes );
3063 setPreferenceProperty( dispmode, "indexes", indices );
3065 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3066 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3067 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3069 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3070 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3072 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3073 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3075 setPreferenceProperty( nodeSz, "min", 1 );
3076 setPreferenceProperty( nodeSz, "max", 5 );
3078 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3080 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3081 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3082 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3083 addPreference( "", elemGroup, LightApp_Preferences::Space );
3085 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3086 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3088 setPreferenceProperty( elemW, "min", 1 );
3089 setPreferenceProperty( elemW, "max", 5 );
3091 setPreferenceProperty( shrink, "min", 0 );
3092 setPreferenceProperty( shrink, "max", 100 );
3094 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3096 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3098 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3099 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3100 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3102 setPreferenceProperty( selW, "min", 1 );
3103 setPreferenceProperty( selW, "max", 5 );
3105 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3107 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3108 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3110 setPreferenceProperty( preW, "min", 1 );
3111 setPreferenceProperty( preW, "max", 5 );
3113 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3115 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3116 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3117 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3119 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3120 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3122 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3123 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3124 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3125 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3128 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3129 fam.append( tr( "SMESH_FONT_COURIER" ) );
3130 fam.append( tr( "SMESH_FONT_TIMES" ) );
3131 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3133 setPreferenceProperty( tfont, "families", fam );
3134 setPreferenceProperty( tfont, "system", false );
3135 setPreferenceProperty( tfont, "widget_flags", wflag );
3136 setPreferenceProperty( lfont, "families", fam );
3137 setPreferenceProperty( lfont, "system", false );
3138 setPreferenceProperty( lfont, "widget_flags", wflag );
3140 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3142 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3143 setPreferenceProperty( numcol, "min", 2 );
3144 setPreferenceProperty( numcol, "max", 256 );
3146 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3147 setPreferenceProperty( numlab, "min", 2 );
3148 setPreferenceProperty( numlab, "max", 65 );
3150 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3151 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3152 QStringList orients;
3153 orients.append( tr( "SMESH_VERTICAL" ) );
3154 orients.append( tr( "SMESH_HORIZONTAL" ) );
3155 indices.clear(); indices.append( 0 ); indices.append( 1 );
3156 setPreferenceProperty( orient, "strings", orients );
3157 setPreferenceProperty( orient, "indexes", indices );
3159 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3160 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3161 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3162 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3163 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3164 setPreferenceProperty( xv, "step", 0.1 );
3165 setPreferenceProperty( xv, "min", 0.0 );
3166 setPreferenceProperty( xv, "max", 1.0 );
3167 setPreferenceProperty( yv, "step", 0.1 );
3168 setPreferenceProperty( yv, "min", 0.0 );
3169 setPreferenceProperty( yv, "max", 1.0 );
3170 setPreferenceProperty( wv, "step", 0.1 );
3171 setPreferenceProperty( wv, "min", 0.0 );
3172 setPreferenceProperty( wv, "max", 1.0 );
3173 setPreferenceProperty( hv, "min", 0.0 );
3174 setPreferenceProperty( hv, "max", 1.0 );
3175 setPreferenceProperty( hv, "step", 0.1 );
3177 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3178 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3179 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3180 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3181 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3182 setPreferenceProperty( xv, "min", 0.0 );
3183 setPreferenceProperty( xv, "max", 1.0 );
3184 setPreferenceProperty( xv, "step", 0.1 );
3185 setPreferenceProperty( xh, "min", 0.0 );
3186 setPreferenceProperty( xh, "max", 1.0 );
3187 setPreferenceProperty( xh, "step", 0.1 );
3188 setPreferenceProperty( yh, "min", 0.0 );
3189 setPreferenceProperty( yh, "max", 1.0 );
3190 setPreferenceProperty( yh, "step", 0.1 );
3191 setPreferenceProperty( wh, "min", 0.0 );
3192 setPreferenceProperty( wh, "max", 1.0 );
3193 setPreferenceProperty( wh, "step", 0.1 );
3194 setPreferenceProperty( hh, "min", 0.0 );
3195 setPreferenceProperty( hh, "max", 1.0 );
3196 setPreferenceProperty( hh, "step", 0.1 );
3199 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3201 if( sect=="SMESH" ){
3202 float sbX1,sbY1,sbW,sbH;
3203 float aTol = 1.00000009999999;
3204 std::string aWarning;
3205 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3206 if( name=="selection_object_color" || name=="selection_element_color" ||
3207 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3208 name=="selection_precision_node" || name=="selection_precision_element" ||
3209 name=="selection_precision_object")
3210 SMESH::UpdateSelectionProp( this );
3211 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3212 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3213 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3214 if(sbX1+sbW > aTol){
3215 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3218 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3219 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3222 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3223 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3224 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3225 if(sbY1+sbH > aTol){
3226 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3229 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3230 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3233 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3234 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3235 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3236 if(sbX1+sbW > aTol){
3237 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3240 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3241 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3244 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3245 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3246 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3247 if(sbY1+sbH > aTol){
3248 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3251 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3252 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3256 if(aWarning.size() != 0){
3257 aWarning += "The default values are applied instead.";
3258 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3259 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3260 QObject::tr(aWarning.c_str()),
3261 QObject::tr("SMESH_BUT_OK"));
3266 //================================================================================
3268 * \brief Update something in accordance with update flags
3269 * \param theFlags - update flags
3271 * Update viewer or/and object browser etc. in accordance with update flags ( see
3272 * LightApp_UpdateFlags enumeration ).
3274 //================================================================================
3275 void SMESHGUI::update( const int flags )
3277 if ( flags & UF_Viewer | flags & UF_Forced )
3278 SMESH::UpdateView();
3280 SalomeApp_Module::update( flags );
3283 //================================================================================
3285 * \brief Set default selection mode
3287 * SLOT called when operation commited. Sets default selection mode
3289 //================================================================================
3290 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3292 SVTK_ViewWindow* vtkWnd =
3293 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3295 vtkWnd->SetSelectionMode( ActorSelection );
3298 //================================================================================
3300 * \brief Set default selection mode
3302 * SLOT called when operation aborted. Sets default selection mode
3304 //================================================================================
3305 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3307 SVTK_ViewWindow* vtkWnd =
3308 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3310 vtkWnd->SetSelectionMode( ActorSelection );
3313 //================================================================================
3315 * \brief Creates operation with given identifier
3316 * \param id - identifier of operation to be started
3317 * \return Pointer on created operation or NULL if operation is not created
3319 * Virtual method redefined from the base class creates operation with given id.
3320 * It is called called automatically from startOperation method of base class.
3322 //================================================================================
3323 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3325 LightApp_Operation* op = 0;
3326 // to do : create operation here
3329 case 701: // Compute mesh
3330 op = new SMESHGUI_ComputeOp();
3332 case 702: // Create mesh
3333 op = new SMESHGUI_MeshOp( true, true );
3335 case 703: // Create sub-mesh
3336 op = new SMESHGUI_MeshOp( true, false );
3338 case 704: // Edit mesh/sub-mesh
3339 op = new SMESHGUI_MeshOp( false );
3341 case 417: //convert to quadratic
3342 op = new SMESHGUI_ConvToQuadOp();
3344 case 4067: // make mesh pass through point
3345 op = new SMESHGUI_MakeNodeAtPointOp();
3352 op = SalomeApp_Module::createOperation( id );
3356 //================================================================================
3358 * \brief Stops current operations and starts a given one
3359 * \param id - The id of the operation to start
3361 //================================================================================
3363 void SMESHGUI::switchToOperation(int id)
3365 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3366 activeStudy()->abortAllOperations();
3367 startOperation( id );
3370 LightApp_Displayer* SMESHGUI::displayer()
3373 myDisplayer = new SMESHGUI_Displayer( getApp() );