1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.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"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_GEOMGenUtils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include "SMESH_Actor.h"
81 #include "SMESH_Object.h"
82 #include "SMESH_TypeFilter.hxx"
84 #include "SalomeApp_Tools.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_CheckFileDlg.h"
88 #include "SalomeApp_ImportOperation.h"
90 #include "LightApp_DataOwner.h"
91 #include "LightApp_Preferences.h"
92 #include "LightApp_VTKSelector.h"
93 #include "LightApp_Operation.h"
94 #include "LightApp_UpdateFlags.h"
95 #include "LightApp_NameDlg.h"
97 #include <SVTK_ViewWindow.h>
98 #include <SVTK_ViewModel.h>
99 #include <SVTK_InteractorStyle.h>
100 #include <SVTK_RenderWindowInteractor.h>
101 #include <SVTK_ViewManager.h>
103 #include "OB_Browser.h"
105 #include "SUIT_Tools.h"
106 #include "SUIT_MessageBox.h"
107 #include "SUIT_ResourceMgr.h"
108 #include "SUIT_FileDlg.h"
109 #include "SUIT_Desktop.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
127 #define INCLUDE_MENUITEM_DEF
128 #include <qpopupmenu.h>
134 #include <boost/shared_ptr.hpp>
137 #include <vtkRenderer.h>
138 #include <vtkRenderWindow.h>
139 #include <vtkActorCollection.h>
140 #include <vtkScalarBarActor.h>
141 #include <vtkUnstructuredGrid.h>
143 #include "utilities.h"
145 #include "SALOMEDS_Study.hxx"
146 #include "SALOMEDSClient_StudyBuilder.hxx"
147 #include "SALOMEDSClient_SComponent.hxx"
153 //=============================================================
154 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
157 void ExportMeshToFile(int theCommandID);
159 void SetDisplayMode(int theCommandID);
161 void SetDisplayEntity(int theCommandID);
163 void Control( int theCommandID );
167 //=============================================================
168 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
174 if(theCommandID == 113){
175 filter.append(QObject::tr("MED files (*.med)"));
176 filter.append(QObject::tr("All files (*)"));
177 }else if (theCommandID == 112){
178 filter.append(QObject::tr("IDEAS files (*.unv)"));
179 }else if (theCommandID == 111){
180 filter.append(QObject::tr("DAT files (*.dat)"));
182 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
185 QObject::tr("Import mesh"),
187 if(!filename.isEmpty()) {
188 SUIT_OverrideCursor wc;
189 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
192 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 aMeshes->length( 1 );
197 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
202 SMESH::DriverMED_ReadStatus res;
203 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
204 if ( res != SMESH::DRS_OK ) {
206 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
207 QObject::tr("SMESH_WRN_WARNING"),
208 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
209 QObject::tr("SMESH_BUT_OK"));
210 aMeshes->length( 0 );
217 bool isEmpty = false;
218 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
219 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
221 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
222 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
223 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
224 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
225 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
232 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
233 QObject::tr("SMESH_WRN_WARNING"),
234 QObject::tr("SMESH_DRS_EMPTY"),
235 QObject::tr("SMESH_BUT_OK"));
239 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
241 catch (const SALOME::SALOME_Exception& S_ex){
243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
250 void ExportMeshToFile( int theCommandID )
252 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
253 SALOME_ListIO selected;
255 aSel->selectedObjects( selected );
257 if(selected.Extent()){
258 Handle(SALOME_InteractiveObject) anIObject = selected.First();
259 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
260 if ( !aMesh->_is_nil() ) {
261 QString aFilter, aTitle = QObject::tr("Export mesh");
262 QMap<QString, SMESH::MED_VERSION> aFilterMap;
263 switch ( theCommandID ) {
267 if (aMesh->HasDuplicatedGroupNamesMED()) {
268 int aRet = SUIT_MessageBox::warn2
269 (SMESHGUI::desktop(),
270 QObject::tr("SMESH_WRN_WARNING"),
271 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
272 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
278 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
279 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
284 aFilter = QObject::tr("DAT files (*.dat)");
289 if (aMesh->NbPyramids()) {
290 int aRet = SUIT_MessageBox::warn2
291 (SMESHGUI::desktop(),
292 QObject::tr("SMESH_WRN_WARNING"),
293 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
294 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
299 aFilter = QObject::tr("IDEAS files (*.unv)");
307 SMESH::MED_VERSION aFormat;
308 // Init the parameter with the default value
309 bool toCreateGroups = false;
310 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
312 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
314 if ( theCommandID != 122 && theCommandID != 125 )
315 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
318 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
319 for ( ; it != aFilterMap.end(); ++it )
320 filters.push_back( it.key() );
322 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
323 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
324 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
325 fd->setCaption( aTitle );
326 fd->setFilters( filters );
327 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
328 fd->SetChecked(toCreateGroups);
332 aFilename = fd->selectedFile();
333 aFormat = aFilterMap[fd->selectedFilter()];
335 if ( !aFilename.isEmpty()
336 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
337 && aFormat==SMESH::MED_V2_1) {
338 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
339 QObject::tr("SMESH_WRN_WARNING"),
340 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
341 QObject::tr("SMESH_BUT_YES"),
342 QObject::tr("SMESH_BUT_NO"),
349 toCreateGroups = fd->IsChecked();
352 if ( !aFilename.isEmpty() ) {
353 // Check whether the file already exists and delete it if yes
354 QFile aFile( aFilename );
355 if ( aFile.exists() )
357 SUIT_OverrideCursor wc;
360 bool Renumber = false ;
361 // PAL 14172 : Check of we have to renumber or not from the preferences before export
363 Renumber= resMgr->booleanValue("SMESH","renumbering");
365 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
366 aMeshEditor->RenumberNodes();
367 aMeshEditor->RenumberElements();
368 if ( SMESHGUI::automaticUpdate() )
371 switch ( theCommandID ) {
374 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
378 aMesh->ExportDAT( aFilename.latin1() );
382 aMesh->ExportUNV( aFilename.latin1() );
388 catch (const SALOME::SALOME_Exception& S_ex){
390 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
391 QObject::tr("SMESH_WRN_WARNING"),
392 QObject::tr("SMESH_EXPORT_FAILED"),
393 QObject::tr("SMESH_BUT_OK"));
401 inline void InverseEntityMode(unsigned int& theOutputMode,
402 unsigned int theMode)
404 bool anIsNotPresent = ~theOutputMode & theMode;
406 theOutputMode |= theMode;
408 theOutputMode &= ~theMode;
411 void SetDisplayEntity(int theCommandID){
412 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
413 SALOME_ListIO selected;
415 aSel->selectedObjects( selected );
417 if(selected.Extent() >= 1){
418 SALOME_ListIteratorOfListIO It( selected );
419 for(; It.More(); It.Next()){
420 Handle(SALOME_InteractiveObject) IObject = It.Value();
421 if(IObject->hasEntry()){
422 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
423 unsigned int aMode = anActor->GetEntityMode();
424 switch(theCommandID){
426 InverseEntityMode(aMode,SMESH_Actor::eEdges);
429 InverseEntityMode(aMode,SMESH_Actor::eFaces);
432 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
435 aMode = SMESH_Actor::eAllEntity;
439 anActor->SetEntityMode(aMode);
446 void SetDisplayMode(int theCommandID){
447 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
448 SALOME_ListIO selected;
450 aSel->selectedObjects( selected );
452 if(selected.Extent() >= 1){
453 switch(theCommandID){
455 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
456 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
460 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
461 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
464 SALOME_ListIteratorOfListIO It( selected );
465 for(; It.More(); It.Next()){
466 Handle(SALOME_InteractiveObject) IObject = It.Value();
467 if(IObject->hasEntry()){
468 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
469 switch(theCommandID){
471 anActor->SetRepresentation(SMESH_Actor::eEdge);
474 anActor->SetRepresentation(SMESH_Actor::eSurface);
477 if(anActor->IsShrunk())
480 anActor->SetShrink();
483 anActor->SetRepresentation(SMESH_Actor::ePoint);
486 vtkFloatingPointType color[3];
487 anActor->GetSufaceColor(color[0], color[1], color[2]);
488 int c0 = int (color[0] * 255);
489 int c1 = int (color[1] * 255);
490 int c2 = int (color[2] * 255);
491 QColor c(c0, c1, c2);
493 vtkFloatingPointType edgecolor[3];
494 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
495 c0 = int (edgecolor[0] * 255);
496 c1 = int (edgecolor[1] * 255);
497 c2 = int (edgecolor[2] * 255);
498 QColor e(c0, c1, c2);
500 vtkFloatingPointType backfacecolor[3];
501 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
502 c0 = int (backfacecolor[0] * 255);
503 c1 = int (backfacecolor[1] * 255);
504 c2 = int (backfacecolor[2] * 255);
505 QColor b(c0, c1, c2);
507 vtkFloatingPointType nodecolor[3];
508 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
509 c0 = int (nodecolor[0] * 255);
510 c1 = int (nodecolor[1] * 255);
511 c2 = int (nodecolor[2] * 255);
512 QColor n(c0, c1, c2);
514 int Edgewidth = (int)anActor->GetLineWidth();
517 int intValue = int(anActor->GetNodeSize());
518 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
520 SMESHGUI_Preferences_ColorDlg *aDlg =
521 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
522 aDlg->SetColor(1, c);
523 aDlg->SetColor(2, e);
524 aDlg->SetColor(3, n);
525 aDlg->SetColor(4, b);
526 aDlg->SetIntValue(1, Edgewidth);
527 aDlg->SetIntValue(2, intValue);
528 aDlg->SetIntValue(3, int(Shrink*100.));
530 QColor color = aDlg->GetColor(1);
531 QColor edgecolor = aDlg->GetColor(2);
532 QColor nodecolor = aDlg->GetColor(3);
533 QColor backfacecolor = aDlg->GetColor(4);
534 /* actor color and backface color */
535 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
536 vtkFloatingPointType (color.green()) / 255.,
537 vtkFloatingPointType (color.blue()) / 255.);
538 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
539 vtkFloatingPointType (backfacecolor.green()) / 255.,
540 vtkFloatingPointType (backfacecolor.blue()) / 255.);
543 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
544 vtkFloatingPointType (edgecolor.green()) / 255.,
545 vtkFloatingPointType (edgecolor.blue()) / 255.);
547 /* Shrink factor and size edges */
548 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
549 anActor->SetLineWidth(aDlg->GetIntValue(1));
551 /* Nodes color and size */
552 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
553 vtkFloatingPointType (nodecolor.green()) / 255.,
554 vtkFloatingPointType (nodecolor.blue()) / 255.);
555 anActor->SetNodeSize(aDlg->GetIntValue(2));
564 SMESH::RepaintCurrentView();
568 void Control( int theCommandID )
570 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
571 SALOME_ListIO selected;
573 aSel->selectedObjects( selected );
575 if( !selected.IsEmpty() ){
576 Handle(SALOME_InteractiveObject) anIO = selected.First();
579 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
580 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
581 switch ( theCommandID ){
583 aTitle = QObject::tr( "LENGTH_EDGES" );
584 aControl = SMESH_Actor::eLength;
587 aTitle = QObject::tr( "LENGTH2D_EDGES" );
588 aControl = SMESH_Actor::eLength2D;
591 aTitle = QObject::tr( "FREE_EDGES" );
592 aControl = SMESH_Actor::eFreeEdges;
595 aTitle = QObject::tr( "FREE_BORDERS" );
596 aControl = SMESH_Actor::eFreeBorders;
599 aTitle = QObject::tr( "MULTI_BORDERS" );
600 aControl = SMESH_Actor::eMultiConnection;
603 aTitle = QObject::tr( "MULTI2D_BORDERS" );
604 aControl = SMESH_Actor::eMultiConnection2D;
607 aTitle = QObject::tr( "AREA_ELEMENTS" );
608 aControl = SMESH_Actor::eArea;
611 aTitle = QObject::tr( "TAPER_ELEMENTS" );
612 aControl = SMESH_Actor::eTaper;
615 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
616 aControl = SMESH_Actor::eAspectRatio;
619 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
620 aControl = SMESH_Actor::eAspectRatio3D;
623 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
624 aControl = SMESH_Actor::eMinimumAngle;
627 aTitle = QObject::tr( "WARP_ELEMENTS" );
628 aControl = SMESH_Actor::eWarping;
631 aTitle = QObject::tr( "SKEW_ELEMENTS" );
632 aControl = SMESH_Actor::eSkew;
635 aTitle = QObject::tr( "SMESH_VOLUME" );
636 aControl = SMESH_Actor::eVolume3D;
639 anActor->SetControlMode(aControl);
640 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
641 SMESH::RepaintCurrentView();
648 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
649 MeshObjectType theType,
650 const QString theInTypeName,
651 QString & theOutTypeName)
653 SMESH_TypeFilter aTypeFilter( theType );
655 if( !theIO.IsNull() )
657 entry = theIO->getEntry();
658 LightApp_DataOwner owner( entry );
659 if ( aTypeFilter.isOk( &owner )) {
660 theOutTypeName = theInTypeName;
668 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
670 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
671 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
673 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
674 CORBA::String_var anID = aSComp->GetID().c_str();
675 if (!strcmp(anID.in(),theIO->getEntry()))
681 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
682 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
683 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
684 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
685 CheckOIType ( theIO, GROUP, "Group", aTypeName )
693 QString CheckHomogeneousSelection()
695 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
696 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
697 SALOME_ListIO selected;
699 aSel->selectedObjects( selected );
701 QString RefType = CheckTypeObject(selected.First());
702 SALOME_ListIteratorOfListIO It(selected);
703 for (; It.More(); It.Next())
705 Handle(SALOME_InteractiveObject) IObject = It.Value();
706 QString Type = CheckTypeObject(IObject);
707 if (Type.compare(RefType) != 0)
708 return "Heterogeneous Selection";
715 void SMESHGUI::OnEditDelete()
717 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
718 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
719 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
721 QString aParentComponent = QString::null;
722 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
724 QString cur = anIt.Value()->getComponentDataType();
725 if( aParentComponent.isNull() )
726 aParentComponent = cur;
727 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
728 aParentComponent = "";
731 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
732 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
733 QObject::tr("ERR_ERROR"),
734 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
735 QObject::tr("BUT_OK") );
738 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
739 if (SUIT_MessageBox::warn2
740 (SMESHGUI::desktop(),
741 QObject::tr("SMESH_WRN_WARNING"),
742 QObject::tr("SMESH_REALLY_DELETE"),
743 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
746 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
747 SUIT_ViewManager* vm = anApp->activeViewManager();
748 int nbSf = vm->getViewsCount();
750 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
751 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
752 _PTR(GenericAttribute) anAttr;
753 _PTR(AttributeIOR) anIOR;
755 SALOME_ListIteratorOfListIO It(selected);
757 aStudyBuilder->NewCommand(); // There is a transaction
758 for(; It.More(); It.Next()){ // loop on selected IO's
759 Handle(SALOME_InteractiveObject) IObject = It.Value();
760 if(IObject->hasEntry()) {
761 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
763 // disable removal of "SMESH" component object
764 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
766 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
770 // put the whole hierarchy of sub-objects of the selected SO into a list and
771 // then treat them all starting from the deepest objects (at list back)
773 list< _PTR(SObject) > listSO;
774 listSO.push_back( aSO );
775 list< _PTR(SObject) >::iterator itSO = listSO.begin();
776 for ( ; itSO != listSO.end(); ++itSO ) {
777 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
778 for (it->InitEx(false); it->More(); it->Next())
779 listSO.push_back( it->Value() );
782 // treat SO's in the list starting from the back
784 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
785 for ( ; ritSO != listSO.rend(); ++ritSO ) {
786 _PTR(SObject) SO = *ritSO;
788 string anEntry = SO->GetID();
790 /** Erase graphical object **/
791 if(SO->FindAttribute(anAttr, "AttributeIOR")){
792 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
793 for(int i = 0; i < nbSf; i++){
794 SUIT_ViewWindow *sf = aViews[i];
795 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
796 SMESH::RemoveActor(sf,anActor);
801 /** Remove an object from data structures **/
802 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
803 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
804 if ( !aGroup->_is_nil() ) { // DELETE GROUP
805 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
806 aMesh->RemoveGroup( aGroup );
808 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
809 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
810 aMesh->RemoveSubMesh( aSubMesh );
812 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
814 SMESH::ModifiedMesh(aMeshSO, false);
817 IObject = new SALOME_InteractiveObject
818 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
819 QString objType = CheckTypeObject(IObject);
820 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
821 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
822 aStudyBuilder->RemoveObjectWithChildren( SO );
824 else {// default action: remove SObject from the study
825 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
826 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
828 aStudyBuilder->RemoveObjectWithChildren( SO );
832 } /* listSO back loop */
833 } /* IObject->hasEntry() */
835 aStudyBuilder->CommitCommand();
837 /* Clear any previous selection */
839 aSel->setSelectedObjects( l1 );
841 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
846 Standard_EXPORT CAM_Module* createModule()
848 return new SMESHGUI();
852 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
854 //=============================================================================
858 //=============================================================================
859 SMESHGUI::SMESHGUI() :
860 SalomeApp_Module( "SMESH" )
862 if ( CORBA::is_nil( myComponentSMESH ) )
864 CORBA::Boolean anIsEmbeddedMode;
865 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
868 myActiveDialogBox = 0;
869 myFilterLibraryDlg = 0;
873 SMESH::GetFilterManager();
876 /* load resources for all available meshers */
877 SMESH::InitAvailableHypotheses();
880 //=============================================================================
884 //=============================================================================
885 SMESHGUI::~SMESHGUI()
887 SMESH::GetFilterManager()->Destroy();
888 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
891 //=============================================================================
895 //=============================================================================
896 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
898 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
900 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
905 bool SMESHGUI::automaticUpdate()
907 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
911 return resMgr->booleanValue( "SMESH", "auto_update", false );
914 //=============================================================================
918 //=============================================================================
919 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
921 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
924 //=============================================================================
928 //=============================================================================
929 SMESHGUI* SMESHGUI::GetSMESHGUI()
931 SMESHGUI* smeshMod = 0;
932 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
935 CAM_Module* module = app->module( "Mesh" );
936 smeshMod = dynamic_cast<SMESHGUI*>( module );
939 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
941 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
944 _PTR(Study) aStudy = study->studyDS();
946 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
955 Standard_EXPORT SMESHGUI* GetComponentGUI()
957 return SMESHGUI::GetSMESHGUI();
961 //=============================================================================
965 //=============================================================================
966 void SMESHGUI::SetState(int aState)
971 //=============================================================================
975 //=============================================================================
976 void SMESHGUI::ResetState()
981 //=============================================================================
985 //=============================================================================
986 void SMESHGUI::EmitSignalDeactivateDialog()
988 emit SignalDeactivateActiveDialog();
991 //=============================================================================
995 //=============================================================================
996 void SMESHGUI::EmitSignalStudyFrameChanged()
998 emit SignalStudyFrameChanged();
1001 //=============================================================================
1005 //=============================================================================
1006 void SMESHGUI::EmitSignalCloseAllDialogs()
1008 emit SignalCloseAllDialogs();
1011 //=============================================================================
1015 //=============================================================================
1016 QDialog *SMESHGUI::GetActiveDialogBox()
1018 return myActiveDialogBox;
1021 //=============================================================================
1025 //=============================================================================
1026 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1028 myActiveDialogBox = (QDialog *) aDlg;
1032 //=============================================================================
1036 //=============================================================================
1037 SUIT_Desktop* SMESHGUI::desktop()
1039 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1041 return app->desktop();
1046 //=============================================================================
1050 //=============================================================================
1051 SalomeApp_Study* SMESHGUI::activeStudy()
1053 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1055 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1060 //=============================================================================
1064 //=============================================================================
1065 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1067 /* Here the position is on the bottom right corner - 10 */
1068 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1070 SUIT_Desktop *PP = desktop();
1071 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1072 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1076 //=============================================================================
1080 //=============================================================================
1081 static int isStudyLocked(_PTR(Study) theStudy){
1082 return theStudy->GetProperties()->IsLocked();
1085 static bool checkLock(_PTR(Study) theStudy) {
1086 if (isStudyLocked(theStudy)) {
1087 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1088 QObject::tr("WRN_WARNING"),
1089 QObject::tr("WRN_STUDY_LOCKED"),
1090 QObject::tr("BUT_OK") );
1096 //=======================================================================
1097 //function : CheckActiveStudyLocked
1099 //=======================================================================
1101 bool SMESHGUI::isActiveStudyLocked()
1103 _PTR(Study) aStudy = activeStudy()->studyDS();
1104 return checkLock( aStudy );
1107 //=============================================================================
1111 //=============================================================================
1112 bool SMESHGUI::OnGUIEvent( int theCommandID )
1114 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1118 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1119 SUIT_ResourceMgr* mgr = resourceMgr();
1123 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1124 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1127 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1128 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1130 //QAction* act = action( theCommandID );
1132 switch (theCommandID) {
1134 if(checkLock(aStudy)) break;
1142 if(checkLock(aStudy)) break;
1143 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1147 case 122: // EXPORT MED
1154 ::ExportMeshToFile(theCommandID);
1158 case 200: // SCALAR BAR
1160 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1161 SALOME_ListIO selected;
1163 aSel->selectedObjects( selected );
1165 if( selected.Extent() ) {
1166 Handle(SALOME_InteractiveObject) anIO = selected.First();
1167 if( anIO->hasEntry() ) {
1168 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1169 anActor->SetControlMode( SMESH_Actor::eNone );
1177 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1181 case 1134: // Clipping
1182 case 1133: // Tranparency
1183 case 1132: // Colors / Size
1190 ::SetDisplayMode(theCommandID);
1196 case 219: // Volumes
1197 case 220: // All Entity
1198 ::SetDisplayEntity(theCommandID);
1203 if(checkLock(aStudy)) break;
1204 SMESH::UpdateView();
1207 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1208 aSel->selectedObjects( l );
1209 aSel->setSelectedObjects( l );
1214 case 301: // DISPLAY
1215 case 302: // DISPLAY ONLY
1217 SMESH::EDisplaing anAction;
1218 switch (theCommandID) {
1219 case 300: anAction = SMESH::eErase; break;
1220 case 301: anAction = SMESH::eDisplay; break;
1221 case 302: anAction = SMESH::eDisplayOnly; break;
1224 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1225 SALOME_ListIO sel_objects, to_process;
1227 aSel->selectedObjects( sel_objects );
1229 if( theCommandID==302 )
1230 startOperation( myEraseAll );
1232 extractContainers( sel_objects, to_process );
1235 SALOME_ListIteratorOfListIO It( to_process );
1236 for (; It.More(); It.Next()) {
1237 Handle(SALOME_InteractiveObject) IOS = It.Value();
1238 if (IOS->hasEntry()) {
1239 SMESH::UpdateView(anAction, IOS->getEntry());
1240 if (anAction == SMESH::eDisplayOnly)
1241 anAction = SMESH::eDisplay;
1247 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) && !automaticUpdate() )
1248 SMESH::UpdateView();
1251 if (anAction == SMESH::eErase) {
1253 aSel->setSelectedObjects( l1 );
1256 aSel->setSelectedObjects( to_process );
1263 if(checkLock(aStudy)) break;
1266 EmitSignalDeactivateDialog();
1268 new SMESHGUI_NodesDlg(this);
1271 SUIT_MessageBox::warn1(desktop(),
1272 tr("SMESH_WRN_WARNING"),
1273 tr("SMESH_WRN_VIEWER_VTK"),
1274 tr("SMESH_BUT_OK"));
1279 case 2151: // FILTER
1283 EmitSignalDeactivateDialog();
1284 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1289 case 406: // MOVE NODE
1293 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1294 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1298 if(checkLock(aStudy)) break;
1299 new SMESHGUI_MoveNodesDlg(this);
1303 case 701: // COMPUTE MESH
1305 if (checkLock(aStudy)) break;
1307 LightApp_SelectionMgr *Sel = selectionMgr();
1308 SALOME_ListIO selected; Sel->selectedObjects( selected );
1310 int nbSel = selected.Extent();
1312 SUIT_MessageBox::warn1(desktop(),
1313 tr("SMESH_WRN_WARNING"),
1314 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1315 tr("SMESH_BUT_OK"));
1319 SMESH::SMESH_Mesh_var aMesh;
1320 SMESH::SMESH_subMesh_var aSubMesh;
1321 Handle(SALOME_InteractiveObject) IObject = selected.First();
1322 if (IObject->hasEntry()) {
1323 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1324 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1325 if ( aShapeObject->_is_nil() ) {
1330 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1331 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1332 if ( !aSubMesh->_is_nil() )
1333 aMesh = aSubMesh->GetFather();
1335 if (!aMesh->_is_nil()) {
1336 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1337 if ( errors->length() > 0 ) {
1338 SUIT_MessageBox::warn1(desktop(),
1339 tr("SMESH_WRN_WARNING"),
1340 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1341 tr("SMESH_BUT_OK"));
1346 if (GetSMESHGen()->Compute(aMesh, aShapeObject))
1347 SMESH::ModifiedMesh(aMeshSObj, true);
1349 SUIT_MessageBox::warn1(desktop(),
1350 tr("SMESH_WRN_WARNING"),
1351 tr("SMESH_WRN_COMPUTE_FAILED"),
1352 tr("SMESH_BUT_OK"));
1354 catch(const SALOME::SALOME_Exception & S_ex){
1355 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1360 if (automaticUpdate()) {
1361 SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
1363 CORBA::Long anId = aStudy->StudyId();
1364 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
1366 aVisualObj->Update();
1367 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1369 anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
1371 SMESH::DisplayActor(aVTKView, anActor); //apo
1375 SMESH::RepaintCurrentView();
1376 Sel->setSelectedObjects( selected );
1386 case 702: // Create mesh
1387 startOperation( 702 );
1389 case 703: // Create sub-mesh
1390 startOperation( 703 );
1392 case 704: // Edit mesh/sub-mesh
1393 startOperation( 704 );
1395 case 710: // Build compound mesh
1397 if (checkLock(aStudy)) break;
1398 EmitSignalDeactivateDialog();
1399 new SMESHGUI_BuildCompoundDlg( this,
1400 tr("SMESH_BUILD_COMPOUND_TITLE"),
1401 tr("ICON_DLG_BUILD_COMPOUND"),
1405 case 407: // DIAGONAL INVERSION
1406 case 408: // Delete diagonal
1410 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1411 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1415 if ( checkLock( aStudy ) )
1418 /*Standard_Boolean aRes;
1419 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1420 if ( aMesh->_is_nil() )
1422 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1423 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1427 EmitSignalDeactivateDialog();
1428 if ( theCommandID == 407 )
1429 new SMESHGUI_TrianglesInversionDlg(this);
1431 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1434 case 409: // Change orientation
1435 case 410: // Union of triangles
1436 case 411: // Cutting of quadrangles
1440 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1441 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1445 if ( checkLock( aStudy ) )
1448 EmitSignalDeactivateDialog();
1449 SMESHGUI_MultiEditDlg* aDlg = NULL;
1450 if ( theCommandID == 409 )
1451 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1452 else if ( theCommandID == 410 )
1453 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1455 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1460 case 412: // Smoothing
1462 if(checkLock(aStudy)) break;
1464 EmitSignalDeactivateDialog();
1465 new SMESHGUI_SmoothingDlg( this );
1468 SUIT_MessageBox::warn1(desktop(),
1469 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1470 tr("SMESH_BUT_OK"));
1474 case 413: // Extrusion
1476 if (checkLock(aStudy)) break;
1478 EmitSignalDeactivateDialog();
1479 new SMESHGUI_ExtrusionDlg ( this );
1481 SUIT_MessageBox::warn1(desktop(),
1482 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1483 tr("SMESH_BUT_OK"));
1487 case 414: // Revolution
1489 if(checkLock(aStudy)) break;
1491 EmitSignalDeactivateDialog();
1492 new SMESHGUI_RevolutionDlg( this );
1495 SUIT_MessageBox::warn1(desktop(),
1496 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1497 tr("SMESH_BUT_OK"));
1501 case 415: // Pattern mapping
1503 if ( checkLock( aStudy ) )
1507 EmitSignalDeactivateDialog();
1508 new SMESHGUI_MeshPatternDlg( this );
1511 SUIT_MessageBox::warn1(desktop(),
1512 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1513 tr("SMESH_BUT_OK"));
1517 case 416: // Extrusion along a path
1519 if (checkLock(aStudy)) break;
1521 EmitSignalDeactivateDialog();
1522 new SMESHGUI_ExtrusionAlongPathDlg( this );
1524 SUIT_MessageBox::warn1(desktop(),
1525 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1526 tr("SMESH_BUT_OK"));
1530 case 417: // Convert mesh to quadratic
1532 startOperation( 417 );
1533 /* if (checkLock(aStudy)) break;
1535 EmitSignalDeactivateDialog();
1536 new SMESHGUI_ConvToQuadDlg();
1538 SUIT_MessageBox::warn1(desktop(),
1539 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1540 tr("SMESH_BUT_OK"));
1544 case 801: // CREATE GROUP
1548 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1549 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1553 if(checkLock(aStudy)) break;
1554 EmitSignalDeactivateDialog();
1555 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1557 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1558 SALOME_ListIO selected;
1560 aSel->selectedObjects( selected );
1562 int nbSel = selected.Extent();
1564 // check if mesh is selected
1565 aMesh = SMESH::GetMeshByIO( selected.First() );
1567 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1572 case 802: // CONSTRUCT GROUP
1576 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1577 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1581 if(checkLock(aStudy)) break;
1582 EmitSignalDeactivateDialog();
1584 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1585 SALOME_ListIO selected;
1587 aSel->selectedObjects( selected );
1589 int nbSel = selected.Extent();
1591 // check if submesh is selected
1592 Handle(SALOME_InteractiveObject) IObject = selected.First();
1593 if (IObject->hasEntry()) {
1594 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1596 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1597 if (!aSubMesh->_is_nil()) {
1599 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1600 // get submesh elements list by types
1601 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1602 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1603 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1604 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1605 // create group for each type o elements
1606 QString aName = IObject->getName();
1607 if (aNodes->length() > 0) {
1608 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1609 aGroup->Add(aNodes.inout());
1611 if (aEdges->length() > 0) {
1612 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1613 aGroup->Add(aEdges.inout());
1615 if (aFaces->length() > 0) {
1616 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1617 aGroup->Add(aFaces.inout());
1619 if (aVolumes->length() > 0) {
1620 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1621 aGroup->Add(aVolumes.inout());
1626 catch(const SALOME::SALOME_Exception & S_ex){
1627 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1634 SUIT_MessageBox::warn1(desktop(),
1635 tr("SMESH_WRN_WARNING"),
1636 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1637 tr("SMESH_BUT_OK"));
1642 case 803: // EDIT GROUP
1646 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1647 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1651 if(checkLock(aStudy)) break;
1652 EmitSignalDeactivateDialog();
1654 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1655 SALOME_ListIO selected;
1657 aSel->selectedObjects( selected );
1659 SALOME_ListIteratorOfListIO It (selected);
1660 int nbSelectedGroups = 0;
1661 for ( ; It.More(); It.Next() )
1663 SMESH::SMESH_GroupBase_var aGroup =
1664 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1665 if (!aGroup->_is_nil()) {
1667 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1671 if (nbSelectedGroups == 0)
1673 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1679 case 804: // Add elements to group
1681 if(checkLock(aStudy)) break;
1682 if (myState == 800) {
1683 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1684 if (aDlg) aDlg->onAdd();
1689 case 805: // Remove elements from group
1691 if(checkLock(aStudy)) break;
1692 if (myState == 800) {
1693 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1694 if (aDlg) aDlg->onRemove();
1699 case 810: // Union Groups
1700 case 811: // Intersect groups
1701 case 812: // Cut groups
1705 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1706 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1710 if ( checkLock( aStudy ) )
1713 EmitSignalDeactivateDialog();
1716 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1717 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1718 else aMode = SMESHGUI_GroupOpDlg::CUT;
1720 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1724 case 813: // Delete groups with their contents
1728 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1729 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1733 if ( checkLock( aStudy ) )
1736 EmitSignalDeactivateDialog();
1738 new SMESHGUI_DeleteGroupDlg( this );
1742 case 900: // MESH INFOS
1744 EmitSignalDeactivateDialog();
1745 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1746 SALOME_ListIO selected;
1748 aSel->selectedObjects( selected );
1750 if ( selected.Extent() > 1 ) { // a dlg for each IO
1752 SALOME_ListIteratorOfListIO It (selected);
1753 for ( ; It.More(); It.Next() ) {
1754 IOs.Clear(); IOs.Append( It.Value() );
1755 aSel->setSelectedObjects( IOs );
1756 new SMESHGUI_MeshInfosDlg(this, "", false);
1758 // restore selection
1759 aSel->setSelectedObjects( selected );
1762 new SMESHGUI_MeshInfosDlg(this, "", false);
1766 case 902: // STANDARD MESH INFOS
1768 EmitSignalDeactivateDialog();
1769 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1770 SALOME_ListIO selected;
1772 aSel->selectedObjects( selected );
1774 if ( selected.Extent() > 1 ) { // a dlg for each IO
1776 SALOME_ListIteratorOfListIO It (selected);
1777 for ( ; It.More(); It.Next() ) {
1779 IOs.Append( It.Value() );
1780 aSel->setSelectedObjects( IOs );
1781 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1783 // restore selection
1784 aSel->setSelectedObjects( selected );
1787 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1791 case 1100: // EDIT HYPOTHESIS
1793 if(checkLock(aStudy)) break;
1795 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1796 SALOME_ListIO selected;
1798 aSel->selectedObjects( selected );
1800 int nbSel = selected.Extent();
1803 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1805 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1806 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1807 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1808 if ( !Hyp->_is_nil() )
1810 char* sName = Hyp->GetName();
1811 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1813 aCreator->edit( Hyp.in(), desktop() );
1820 updateObjBrowser( true );
1824 case 1101: // RENAME
1826 if ( checkLock( aStudy ) )
1829 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1830 SALOME_ListIO selected;
1832 aSel->selectedObjects( selected );
1834 SALOME_ListIteratorOfListIO It( selected );
1835 for ( ; It.More(); It.Next() )
1837 Handle(SALOME_InteractiveObject) IObject = It.Value();
1838 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1839 _PTR(GenericAttribute) anAttr;
1840 _PTR(AttributeName) aName;
1843 if ( obj->FindAttribute(anAttr, "AttributeName") )
1846 QString newName = QString(aName->Value().c_str());
1847 newName = LightApp_NameDlg::getName(desktop(), newName);
1848 if ( !newName.isEmpty() )
1850 //old source: aStudy->renameIObject( IObject, newName );
1851 aName->SetValue( newName.latin1() );
1853 // if current object is group update group's name
1854 SMESH::SMESH_GroupBase_var aGroup =
1855 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1856 if (!aGroup->_is_nil() )
1857 aGroup->SetName( newName.latin1() );
1867 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1869 if(checkLock(aStudy)) break;
1870 SUIT_OverrideCursor wc;
1872 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1873 SALOME_ListIO selected;
1875 aSel->selectedObjects( selected, QString::null, false );
1877 SALOME_ListIteratorOfListIO It(selected);
1878 for (int i = 0; It.More(); It.Next(), i++) {
1879 Handle(SALOME_InteractiveObject) IObject = It.Value();
1880 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1883 aSel->setSelectedObjects( l1 );
1888 case 401: // GEOM::EDGE
1889 case 4021: // TRIANGLE
1891 case 4023: // POLYGON
1895 if(checkLock(aStudy)) break;
1897 EmitSignalDeactivateDialog();
1898 SMDSAbs_ElementType type = SMDSAbs_Edge;
1900 switch (theCommandID) {
1901 case 4021: // TRIANGLE
1902 type = SMDSAbs_Face; nbNodes = 3; break;
1904 type = SMDSAbs_Face; nbNodes = 4; break;
1906 type = SMDSAbs_Volume; nbNodes = 4; break;
1907 case 4023: // POLYGON
1908 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1910 type = SMDSAbs_Volume; nbNodes = 8; break;
1911 case 4033: // POLYHEDRE
1912 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1915 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1918 SUIT_MessageBox::warn1(desktop(),
1919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1920 tr("SMESH_BUT_OK"));
1924 case 4033: // POLYHEDRON
1926 if(checkLock(aStudy)) break;
1928 EmitSignalDeactivateDialog();
1929 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1932 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1934 tr("SMESH_BUT_OK"));
1938 case 4034: // QUADRATIC EDGE
1939 case 4035: // QUADRATIC TRIANGLE
1940 case 4036: // QUADRATIC QUADRANGLE
1941 case 4037: // QUADRATIC TETRAHEDRON
1942 case 4038: // QUADRATIC PYRAMID
1943 case 4039: // QUADRATIC PENTAHEDRON
1944 case 4040: // QUADRATIC HEXAHEDRON
1946 if(checkLock(aStudy)) break;
1948 EmitSignalDeactivateDialog();
1951 switch (theCommandID) {
1953 type = QUAD_EDGE; break;
1955 type = QUAD_TRIANGLE; break;
1957 type = QUAD_QUADRANGLE; break;
1959 type = QUAD_TETRAHEDRON; break;
1961 type = QUAD_PYRAMID; break;
1963 type = QUAD_PENTAHEDRON; break;
1965 type = QUAD_HEXAHEDRON;
1969 new SMESHGUI_AddQuadraticElementDlg( this, type );
1972 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1973 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1974 tr("SMESH_BUT_OK"));
1978 case 4041: // REMOVES NODES
1980 if(checkLock(aStudy)) break;
1982 EmitSignalDeactivateDialog();
1983 new SMESHGUI_RemoveNodesDlg(this);
1986 SUIT_MessageBox::warn1(desktop(),
1987 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1988 tr("SMESH_BUT_OK"));
1992 case 4042: // REMOVES ELEMENTS
1994 if(checkLock(aStudy)) break;
1996 EmitSignalDeactivateDialog();
1997 new SMESHGUI_RemoveElementsDlg(this);
2001 SUIT_MessageBox::warn1(desktop(),
2002 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2003 tr("SMESH_BUT_OK"));
2007 case 4051: // RENUMBERING NODES
2009 if(checkLock(aStudy)) break;
2011 EmitSignalDeactivateDialog();
2012 new SMESHGUI_RenumberingDlg( this, "", 0);
2016 SUIT_MessageBox::warn1(desktop(),
2017 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2018 tr("SMESH_BUT_OK"));
2022 case 4052: // RENUMBERING ELEMENTS
2024 if(checkLock(aStudy)) break;
2026 EmitSignalDeactivateDialog();
2027 new SMESHGUI_RenumberingDlg( this, "", 1);
2031 SUIT_MessageBox::warn1(desktop(),
2032 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2033 tr("SMESH_BUT_OK"));
2037 case 4061: // TRANSLATION
2039 if(checkLock(aStudy)) break;
2041 EmitSignalDeactivateDialog();
2042 new SMESHGUI_TranslationDlg( this );
2045 SUIT_MessageBox::warn1(desktop(),
2046 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2047 tr("SMESH_BUT_OK"));
2051 case 4062: // ROTATION
2053 if(checkLock(aStudy)) break;
2055 EmitSignalDeactivateDialog();
2056 new SMESHGUI_RotationDlg( this );
2059 SUIT_MessageBox::warn1(desktop(),
2060 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2061 tr("SMESH_BUT_OK"));
2065 case 4063: // SYMMETRY
2067 if(checkLock(aStudy)) break;
2069 EmitSignalDeactivateDialog();
2070 new SMESHGUI_SymmetryDlg( this );
2073 SUIT_MessageBox::warn1(desktop(),
2074 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2075 tr("SMESH_BUT_OK"));
2079 case 4064: // SEWING
2081 if(checkLock(aStudy)) break;
2083 EmitSignalDeactivateDialog();
2084 new SMESHGUI_SewingDlg( this );
2087 SUIT_MessageBox::warn1(desktop(),
2088 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2089 tr("SMESH_BUT_OK"));
2093 case 4065: // MERGE NODES
2095 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 new SMESHGUI_MergeNodesDlg( this );
2101 SUIT_MessageBox::warn1(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2103 tr("SMESH_BUT_OK"));
2107 case 4066: // MERGE EQUAL ELEMENTS
2109 if (checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 new SMESHGUI_EditMeshDlg(this,
2113 "SMESH_MERGE_ELEMENTS_TITLE",
2114 "ICON_DLG_MERGE_ELEMENTS",
2115 1); // MergeEqualElemets
2117 SUIT_MessageBox::warn1(desktop(),
2118 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2119 tr("SMESH_BUT_OK"));
2124 case 4067: // MAKE MESH PASS THROUGH POINT
2125 startOperation( 4067 );
2128 case 5105: // Library of selection filters
2130 static QValueList<int> aTypes;
2131 if ( aTypes.isEmpty() )
2133 aTypes.append( SMESH::NODE );
2134 aTypes.append( SMESH::EDGE );
2135 aTypes.append( SMESH::FACE );
2136 aTypes.append( SMESH::VOLUME );
2138 if (!myFilterLibraryDlg)
2139 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2140 else if (myFilterLibraryDlg->isHidden())
2141 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2142 myFilterLibraryDlg->raise();
2146 case 6017: // CONTROLS
2162 LightApp_SelectionMgr* mgr = selectionMgr();
2163 SALOME_ListIO selected; mgr->selectedObjects( selected );
2165 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2166 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2168 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2169 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2170 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2171 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2172 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2173 ::Control( theCommandID );
2178 SUIT_MessageBox::warn1(desktop(),
2179 tr( "SMESH_WRN_WARNING" ),
2180 tr( "SMESH_BAD_SELECTION" ),
2181 tr( "SMESH_BUT_OK" ) );
2185 SUIT_MessageBox::warn1(desktop(),
2186 tr( "SMESH_WRN_WARNING" ),
2187 tr( "NOT_A_VTK_VIEWER" ),
2188 tr( "SMESH_BUT_OK" ) );
2193 LightApp_SelectionMgr* mgr = selectionMgr();
2194 SALOME_ListIO selected; mgr->selectedObjects( selected );
2196 SALOME_ListIteratorOfListIO it(selected);
2197 for(; it.More(); it.Next()) {
2198 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2199 if(anIObject->hasEntry()) {
2200 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2201 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2209 LightApp_SelectionMgr* mgr = selectionMgr();
2210 SALOME_ListIO selected; mgr->selectedObjects( selected );
2212 if (selected.Extent() == 1) {
2213 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2214 if(anIObject->hasEntry())
2215 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2216 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2223 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2224 //updateObjBrowser();
2228 //=============================================================================
2232 //=============================================================================
2233 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2238 //=============================================================================
2242 //=============================================================================
2243 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2248 //=============================================================================
2252 //=============================================================================
2253 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2258 //=============================================================================
2259 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2260 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2262 //=============================================================================
2263 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2264 SUIT_ViewWindow* wnd )
2266 if(theIO->hasEntry()){
2267 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2268 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2272 //=======================================================================
2273 // function : createSMESHAction
2275 //=======================================================================
2276 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2279 QWidget* parent = application()->desktop();
2280 SUIT_ResourceMgr* resMgr = resourceMgr();
2282 if ( icon_id.length() )
2283 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2285 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2286 if ( !pix.isNull() )
2287 icon = QIconSet( pix );
2289 QString tooltip = tr( QString( "TOP_" )+po_id ),
2290 menu = tr( QString( "MEN_" )+po_id ),
2291 status_bar = tr( QString( "STB_" )+po_id );
2293 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2296 //=======================================================================
2297 // function : createPopupItem
2299 //=======================================================================
2300 void SMESHGUI::createPopupItem( const int id,
2301 const QString& clients,
2302 const QString& types,
2303 const QString& theRule,
2308 parentId = popupMgr()->actionId( action( pId ) );
2310 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2311 popupMgr()->insert( action( id ), parentId, 0 );
2313 QChar lc = QtxPopupMgr::Selection::defEquality();
2314 QString rule = "(%1) and (%2) and (%3)";
2315 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2316 if( clients.isEmpty() )
2317 rule = rule.arg( QString( "true" ) );
2319 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2320 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2323 bool cont = myRules.contains( id );
2325 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2327 popupMgr()->setRule( action( id ), rule, true );
2328 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2331 //=======================================================================
2332 // function : initialize
2334 //=======================================================================
2335 void SMESHGUI::initialize( CAM_Application* app )
2337 SalomeApp_Module::initialize( app );
2339 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2341 /* Automatic Update flag */
2342 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2344 // ----- create actions --------------
2346 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2347 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2348 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2349 createSMESHAction( 114, "NUM" );
2350 createSMESHAction( 121, "DAT" );
2351 createSMESHAction( 122, "MED" );
2352 createSMESHAction( 123, "UNV" );
2353 createSMESHAction( 124, "EXPORT_DAT" );
2354 createSMESHAction( 125, "EXPORT_MED" );
2355 createSMESHAction( 126, "EXPORT_UNV" );
2356 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2357 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2358 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2359 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2360 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2361 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2362 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2363 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2364 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2365 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2366 createSMESHAction( 804, "ADD" );
2367 createSMESHAction( 805, "REMOVE" );
2368 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2369 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2370 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2371 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2372 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2373 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2374 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2375 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2376 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2377 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2378 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2379 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2380 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2381 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2382 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2383 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2384 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2385 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2386 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2387 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2388 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2389 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2390 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2391 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2392 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2393 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2394 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2395 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2396 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2397 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2398 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2399 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2400 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2401 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2402 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2403 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2404 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2405 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2406 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2407 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2408 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2409 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2410 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2411 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2412 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2413 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2414 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2415 createSMESHAction( 415, "MAP", "ICON_MAP" );
2416 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2417 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2418 createSMESHAction( 200, "RESET" );
2419 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2420 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2421 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2422 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2423 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2424 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2425 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2426 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2427 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2428 createSMESHAction( 220, "ALL" );
2429 createSMESHAction( 1100, "EDIT_HYPO" );
2430 createSMESHAction( 1101, "RENAME" );
2431 createSMESHAction( 1102, "UNASSIGN" );
2432 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2433 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2434 createSMESHAction( 1131, "DISPMODE" );
2435 createSMESHAction( 1132, "COLORS" );
2436 createSMESHAction( 1133, "TRANSP" );
2437 createSMESHAction( 1134, "CLIP" );
2438 createSMESHAction( 1135, "DISP_ENT" );
2439 createSMESHAction( 2000, "CTRL" );
2441 createSMESHAction( 300, "ERASE" );
2442 createSMESHAction( 301, "DISPLAY" );
2443 createSMESHAction( 302, "DISPLAY_ONLY" );
2444 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2445 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2446 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2447 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2448 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2449 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2450 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2451 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2453 // ----- create menu --------------
2454 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2455 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2456 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2457 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2458 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2459 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2460 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2462 createMenu( separator(), fileId );
2464 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2465 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2466 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2467 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2468 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2469 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2471 createMenu( 111, importId, -1 );
2472 createMenu( 112, importId, -1 );
2473 createMenu( 113, importId, -1 );
2475 createMenu( 121, exportId, -1 );
2476 createMenu( 122, exportId, -1 );
2477 createMenu( 123, exportId, -1 );
2479 createMenu( separator(), fileId, 10 );
2481 createMenu( 33, editId, -1 );
2483 createMenu( 5105, toolsId, -1 );
2485 createMenu( 702, meshId, -1 );
2486 createMenu( 703, meshId, -1 );
2487 createMenu( 704, meshId, -1 );
2488 createMenu( separator(), meshId, -1 );
2489 createMenu( 701, meshId, -1 );
2490 createMenu( separator(), meshId, -1 );
2491 createMenu( 710, meshId, -1 );
2492 createMenu( separator(), meshId, -1 );
2493 createMenu( 801, meshId, -1 );
2494 createMenu( 802, meshId, -1 );
2495 createMenu( 803, meshId, -1 );
2496 createMenu( separator(), meshId, -1 );
2497 createMenu( 810, meshId, -1 );
2498 createMenu( 811, meshId, -1 );
2499 createMenu( 812, meshId, -1 );
2500 createMenu( separator(), meshId, -1 );
2501 createMenu( 813, meshId, -1 );
2502 createMenu( separator(), meshId, -1 );
2503 createMenu( 900, meshId, -1 );
2504 createMenu( 902, meshId, -1 );
2505 createMenu( separator(), meshId, -1 );
2507 createMenu( 6003, ctrlId, -1 );
2508 createMenu( 6001, ctrlId, -1 );
2509 createMenu( 6004, ctrlId, -1 );
2510 createMenu( separator(), ctrlId, -1 );
2511 createMenu( 6002, ctrlId, -1 );
2512 createMenu( 6018, ctrlId, -1 );
2513 createMenu( 6019, ctrlId, -1 );
2514 createMenu( 6011, ctrlId, -1 );
2515 createMenu( 6012, ctrlId, -1 );
2516 createMenu( 6013, ctrlId, -1 );
2517 createMenu( 6014, ctrlId, -1 );
2518 createMenu( 6015, ctrlId, -1 );
2519 createMenu( 6016, ctrlId, -1 );
2520 createMenu( separator(), ctrlId, -1 );
2521 createMenu( 6017, ctrlId, -1 );
2522 createMenu( 6009, ctrlId, -1 );
2523 createMenu( separator(), ctrlId, -1 );
2525 createMenu( 400, addId, -1 );
2526 createMenu( 401, addId, -1 );
2527 createMenu( 4021, addId, -1 );
2528 createMenu( 4022, addId, -1 );
2529 createMenu( 4023, addId, -1 );
2530 createMenu( 4031, addId, -1 );
2531 createMenu( 4032, addId, -1 );
2532 createMenu( 4033, addId, -1 );
2533 createMenu( separator(), addId, -1 );
2534 createMenu( 4034, addId, -1 );
2535 createMenu( 4035, addId, -1 );
2536 createMenu( 4036, addId, -1 );
2537 createMenu( 4037, addId, -1 );
2538 createMenu( 4038, addId, -1 );
2539 createMenu( 4039, addId, -1 );
2540 createMenu( 4040, addId, -1 );
2542 createMenu( 4041, removeId, -1 );
2543 createMenu( 4042, removeId, -1 );
2545 createMenu( 4051, renumId, -1 );
2546 createMenu( 4052, renumId, -1 );
2548 createMenu( 4061, transfId, -1 );
2549 createMenu( 4062, transfId, -1 );
2550 createMenu( 4063, transfId, -1 );
2551 createMenu( 4064, transfId, -1 );
2552 createMenu( 4065, transfId, -1 );
2553 createMenu( 4066, transfId, -1 );
2555 createMenu( 406, modifyId, -1 );
2556 createMenu( 4067,modifyId, -1 );
2557 createMenu( 407, modifyId, -1 );
2558 createMenu( 408, modifyId, -1 );
2559 createMenu( 409, modifyId, -1 );
2560 createMenu( 410, modifyId, -1 );
2561 createMenu( 411, modifyId, -1 );
2562 createMenu( 412, modifyId, -1 );
2563 createMenu( 413, modifyId, -1 );
2564 createMenu( 416, modifyId, -1 );
2565 createMenu( 414, modifyId, -1 );
2566 createMenu( 415, modifyId, -1 );
2567 createMenu( 417, modifyId, -1 );
2569 createMenu( 214, viewId, -1 );
2571 // ----- create toolbars --------------
2572 int meshTb = createTool( tr( "TB_MESH" ) ),
2573 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2574 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2575 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2576 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2578 createTool( 702, meshTb );
2579 createTool( 703, meshTb );
2580 createTool( 704, meshTb );
2581 createTool( separator(), meshTb );
2582 createTool( 701, meshTb );
2583 createTool( separator(), meshTb );
2584 createTool( 710, meshTb );
2585 createTool( separator(), meshTb );
2586 createTool( 801, meshTb );
2587 createTool( 802, meshTb );
2588 createTool( 803, meshTb );
2589 createTool( separator(), meshTb );
2590 createTool( 900, meshTb );
2591 createTool( 902, meshTb );
2592 createTool( separator(), meshTb );
2594 createTool( 6001, ctrlTb );
2595 createTool( 6003, ctrlTb );
2596 createTool( 6004, ctrlTb );
2597 createTool( separator(), ctrlTb );
2598 createTool( 6002, ctrlTb );
2599 createTool( 6018, ctrlTb );
2600 createTool( 6019, ctrlTb );
2601 createTool( 6011, ctrlTb );
2602 createTool( 6012, ctrlTb );
2603 createTool( 6013, ctrlTb );
2604 createTool( 6014, ctrlTb );
2605 createTool( 6015, ctrlTb );
2606 createTool( 6016, ctrlTb );
2607 createTool( separator(), ctrlTb );
2608 createTool( 6017, ctrlTb );
2609 createTool( 6009, ctrlTb );
2610 createTool( separator(), ctrlTb );
2612 createTool( 400, addRemTb );
2613 createTool( 401, addRemTb );
2614 createTool( 4021, addRemTb );
2615 createTool( 4022, addRemTb );
2616 createTool( 4023, addRemTb );
2617 createTool( 4031, addRemTb );
2618 createTool( 4032, addRemTb );
2619 createTool( 4033, addRemTb );
2620 createTool( separator(), addRemTb );
2621 createTool( 4034, addRemTb );
2622 createTool( 4035, addRemTb );
2623 createTool( 4036, addRemTb );
2624 createTool( 4037, addRemTb );
2625 createTool( 4038, addRemTb );
2626 createTool( 4039, addRemTb );
2627 createTool( 4040, addRemTb );
2628 createTool( separator(), addRemTb );
2629 createTool( 4041, addRemTb );
2630 createTool( 4042, addRemTb );
2631 createTool( separator(), addRemTb );
2632 createTool( 4051, addRemTb );
2633 createTool( 4052, addRemTb );
2634 createTool( separator(), addRemTb );
2635 createTool( 4061, addRemTb );
2636 createTool( 4062, addRemTb );
2637 createTool( 4063, addRemTb );
2638 createTool( 4064, addRemTb );
2639 createTool( 4065, addRemTb );
2640 createTool( 4066, addRemTb );
2641 createTool( separator(), addRemTb );
2643 createTool( 406, modifyTb );
2644 createTool( 4067,modifyTb );
2645 createTool( 407, modifyTb );
2646 createTool( 408, modifyTb );
2647 createTool( 409, modifyTb );
2648 createTool( 410, modifyTb );
2649 createTool( 411, modifyTb );
2650 createTool( 412, modifyTb );
2651 createTool( 413, modifyTb );
2652 createTool( 416, modifyTb );
2653 createTool( 414, modifyTb );
2654 createTool( 415, modifyTb );
2655 createTool( 417, modifyTb );
2657 createTool( 214, dispModeTb );
2661 QString OB = "'ObjectBrowser'",
2662 View = "'" + SVTK_Viewer::Type() + "'",
2664 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2665 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2666 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2667 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2668 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2669 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2670 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2671 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2672 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2673 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2674 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2676 mesh_group = mesh + " " + subMesh + " " + group,
2677 hyp_alg = hypo + " " + algo;
2679 // popup for object browser
2681 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2682 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2683 createPopupItem( 803, OB, group ); // EDIT_GROUP
2684 popupMgr()->insert( separator(), -1, 0 );
2685 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2686 createPopupItem( 214, OB, mesh_group ); // UPDATE
2687 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2688 createPopupItem( 902, OB, mesh ); // STD_INFO
2689 popupMgr()->insert( separator(), -1, 0 );
2690 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2691 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2692 popupMgr()->insert( separator(), -1, 0 );
2693 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2694 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2695 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2696 popupMgr()->insert( separator(), -1, 0 );
2698 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2699 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2700 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2701 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2702 popupMgr()->insert( separator(), -1, 0 );
2705 createPopupItem( 803, View, group ); // EDIT_GROUP
2706 createPopupItem( 804, View, elems ); // ADD
2707 createPopupItem( 805, View, elems ); // REMOVE
2708 popupMgr()->insert( separator(), -1, 0 );
2709 createPopupItem( 214, View, mesh_group ); // UPDATE
2710 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2711 createPopupItem( 902, View, mesh ); // STD_INFO
2712 popupMgr()->insert( separator(), -1, 0 );
2716 isInvisible("not( isVisible )"),
2717 isEmpty("numberOfNodes = 0"),
2718 isNotEmpty("numberOfNodes <> 0"),
2720 // has nodes, edges, etc in VISIBLE! actor
2721 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2722 hasElems("(count( elemTypes ) > 0)"),
2723 hasDifferentElems("(count( elemTypes ) > 1)"),
2724 hasEdges("({'Edge'} in elemTypes)"),
2725 hasFaces("({'Face'} in elemTypes)"),
2726 hasVolumes("({'Volume'} in elemTypes)");
2728 QString lc = QtxPopupMgr::Selection::defEquality();
2729 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2730 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2731 aType = aType.arg( mesh_group );
2732 QString aMeshInVTK = aClient + "&&" + aType;
2734 //-------------------------------------------------
2736 //-------------------------------------------------
2737 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2739 popupMgr()->insert( action( 9010 ), anId, -1 );
2740 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2741 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2743 popupMgr()->insert( action( 9011 ), anId, -1 );
2744 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2745 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2747 popupMgr()->insert( separator(), -1, -1 );
2749 //-------------------------------------------------
2751 //-------------------------------------------------
2752 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2754 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2755 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2756 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2758 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2759 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2760 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2762 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2763 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2764 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2766 popupMgr()->insert( separator(), anId, -1 );
2768 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2769 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2770 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2772 //-------------------------------------------------
2774 //-------------------------------------------------
2775 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2777 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2779 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2780 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2781 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2783 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2784 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2785 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2787 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2788 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2789 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2791 popupMgr()->insert( separator(), anId, -1 );
2793 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2794 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2796 //-------------------------------------------------
2798 //-------------------------------------------------
2799 popupMgr()->insert( action( 1132 ), -1, -1 );
2800 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2802 //-------------------------------------------------
2804 //-------------------------------------------------
2805 popupMgr()->insert( action( 1133 ), -1, -1 );
2806 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2808 //-------------------------------------------------
2810 //-------------------------------------------------
2811 popupMgr()->insert( action( 1134 ), -1, -1 );
2812 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2814 popupMgr()->insert( separator(), -1, -1 );
2816 //-------------------------------------------------
2818 //-------------------------------------------------
2820 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2821 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2822 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2824 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2826 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2827 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2829 popupMgr()->insert( separator(), anId, -1 );
2831 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2832 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2833 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2835 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2836 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2837 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2839 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2840 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2841 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2843 popupMgr()->insert( separator(), anId, -1 );
2845 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2846 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2847 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2849 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2850 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2851 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2853 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2854 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2855 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2857 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2858 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2859 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2861 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2862 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2863 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2865 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2866 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2867 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2869 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2870 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2871 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2873 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2874 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2875 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2877 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2878 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2879 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2881 popupMgr()->insert( separator(), anId, -1 );
2883 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2884 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2885 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2887 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2888 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2889 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2891 popupMgr()->insert( separator(), anId, -1 );
2893 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2894 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2896 popupMgr()->insert( separator(), -1, -1 );
2898 //-------------------------------------------------
2900 //-------------------------------------------------
2901 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2902 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2903 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2905 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2906 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2907 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2908 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2910 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2911 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2913 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2914 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2916 popupMgr()->insert( separator(), -1, -1 );
2918 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2919 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2922 bool SMESHGUI::activateModule( SUIT_Study* study )
2924 bool res = SalomeApp_Module::activateModule( study );
2926 setMenuShown( true );
2927 setToolShown( true );
2929 // Reset actions accelerator keys
2930 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2931 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2932 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2937 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2939 setMenuShown( false );
2940 setToolShown( false );
2942 EmitSignalCloseAllDialogs();
2944 // Unset actions accelerator keys
2945 action(111)->setAccel(QKeySequence()); // Import DAT
2946 action(112)->setAccel(QKeySequence()); // Import UNV
2947 action(113)->setAccel(QKeySequence()); // Import MED
2949 return SalomeApp_Module::deactivateModule( study );
2952 void SMESHGUI::OnGUIEvent()
2954 const QObject* obj = sender();
2955 if ( !obj || !obj->inherits( "QAction" ) )
2957 int id = actionId((QAction*)obj);
2962 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2964 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2965 if ( CORBA::is_nil( myComponentSMESH ) )
2967 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2969 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2970 return aGUI.myComponentSMESH;
2973 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2974 return myComponentSMESH;
2977 QString SMESHGUI::engineIOR() const
2979 CORBA::ORB_var anORB = getApp()->orb();
2980 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2984 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2986 SMESHGUI_Selection sel;
2987 sel.init( client, selectionMgr() );
2988 popupMgr()->updatePopup( menu, &sel );
2991 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2993 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2994 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2997 void SMESHGUI::viewManagers( QStringList& list ) const
2999 list.append( SVTK_Viewer::Type() );
3002 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3004 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3005 SMESH::UpdateSelectionProp( this );
3008 void SMESHGUI::createPreferences()
3010 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3012 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3013 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3015 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3016 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3017 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3019 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3020 setPreferenceProperty( precGroup, "columns", 1 );
3022 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3024 setPreferenceProperty( prec, "min", 0 );
3025 setPreferenceProperty( prec, "max", 16 );
3027 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3028 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3030 modes.append( "Wireframe" );
3031 modes.append( "Shading" );
3032 modes.append( "Nodes" );
3033 modes.append( "Shrink" );
3034 QValueList<QVariant> indices;
3035 indices.append( 0 );
3036 indices.append( 1 );
3037 indices.append( 2 );
3038 indices.append( 3 );
3039 setPreferenceProperty( dispmode, "strings", modes );
3040 setPreferenceProperty( dispmode, "indexes", indices );
3042 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3043 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3044 int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3046 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3047 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3049 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3050 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3052 setPreferenceProperty( nodeSz, "min", 1 );
3053 setPreferenceProperty( nodeSz, "max", 5 );
3055 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3057 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3058 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3059 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3060 addPreference( "", elemGroup, LightApp_Preferences::Space );
3062 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3063 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3065 setPreferenceProperty( elemW, "min", 1 );
3066 setPreferenceProperty( elemW, "max", 5 );
3068 setPreferenceProperty( shrink, "min", 0 );
3069 setPreferenceProperty( shrink, "max", 100 );
3071 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3073 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3075 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3076 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3077 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3079 setPreferenceProperty( selW, "min", 1 );
3080 setPreferenceProperty( selW, "max", 5 );
3082 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3084 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3085 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3087 setPreferenceProperty( preW, "min", 1 );
3088 setPreferenceProperty( preW, "max", 5 );
3090 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3092 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3093 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3095 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3096 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3098 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3099 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3100 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3101 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3104 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3105 fam.append( tr( "SMESH_FONT_COURIER" ) );
3106 fam.append( tr( "SMESH_FONT_TIMES" ) );
3107 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3109 setPreferenceProperty( tfont, "families", fam );
3110 setPreferenceProperty( tfont, "system", false );
3111 setPreferenceProperty( tfont, "widget_flags", wflag );
3112 setPreferenceProperty( lfont, "families", fam );
3113 setPreferenceProperty( lfont, "system", false );
3114 setPreferenceProperty( lfont, "widget_flags", wflag );
3116 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3118 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3119 setPreferenceProperty( numcol, "min", 2 );
3120 setPreferenceProperty( numcol, "max", 256 );
3122 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3123 setPreferenceProperty( numlab, "min", 2 );
3124 setPreferenceProperty( numlab, "max", 65 );
3126 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3127 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3128 QStringList orients;
3129 orients.append( tr( "SMESH_VERTICAL" ) );
3130 orients.append( tr( "SMESH_HORIZONTAL" ) );
3131 indices.clear(); indices.append( 0 ); indices.append( 1 );
3132 setPreferenceProperty( orient, "strings", orients );
3133 setPreferenceProperty( orient, "indexes", indices );
3135 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3136 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3137 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3138 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3139 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3140 setPreferenceProperty( xv, "step", 0.1 );
3141 setPreferenceProperty( xv, "min", 0.0 );
3142 setPreferenceProperty( xv, "max", 1.0 );
3143 setPreferenceProperty( yv, "step", 0.1 );
3144 setPreferenceProperty( yv, "min", 0.0 );
3145 setPreferenceProperty( yv, "max", 1.0 );
3146 setPreferenceProperty( wv, "step", 0.1 );
3147 setPreferenceProperty( wv, "min", 0.0 );
3148 setPreferenceProperty( wv, "max", 1.0 );
3149 setPreferenceProperty( hv, "min", 0.0 );
3150 setPreferenceProperty( hv, "max", 1.0 );
3151 setPreferenceProperty( hv, "step", 0.1 );
3153 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3154 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3155 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3156 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3157 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3158 setPreferenceProperty( xv, "min", 0.0 );
3159 setPreferenceProperty( xv, "max", 1.0 );
3160 setPreferenceProperty( xv, "step", 0.1 );
3161 setPreferenceProperty( xh, "min", 0.0 );
3162 setPreferenceProperty( xh, "max", 1.0 );
3163 setPreferenceProperty( xh, "step", 0.1 );
3164 setPreferenceProperty( yh, "min", 0.0 );
3165 setPreferenceProperty( yh, "max", 1.0 );
3166 setPreferenceProperty( yh, "step", 0.1 );
3167 setPreferenceProperty( wh, "min", 0.0 );
3168 setPreferenceProperty( wh, "max", 1.0 );
3169 setPreferenceProperty( wh, "step", 0.1 );
3170 setPreferenceProperty( hh, "min", 0.0 );
3171 setPreferenceProperty( hh, "max", 1.0 );
3172 setPreferenceProperty( hh, "step", 0.1 );
3175 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3177 if( sect=="SMESH" ){
3178 float sbX1,sbY1,sbW,sbH;
3179 float aTol = 1.00000009999999;
3180 std::string aWarning;
3181 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3182 if( name=="selection_object_color" || name=="selection_element_color" ||
3183 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3184 name=="selection_precision_node" || name=="selection_precision_element" )
3185 SMESH::UpdateSelectionProp( this );
3186 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3187 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3188 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3189 if(sbX1+sbW > aTol){
3190 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3193 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3194 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3197 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3198 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3199 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3200 if(sbY1+sbH > aTol){
3201 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3204 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3205 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3208 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3209 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3210 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3211 if(sbX1+sbW > aTol){
3212 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3215 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3216 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3219 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3220 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3221 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3222 if(sbY1+sbH > aTol){
3223 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3226 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3227 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3231 if(aWarning.size() != 0){
3232 aWarning += "The default values are applied instead.";
3233 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3234 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3235 QObject::tr(aWarning.c_str()),
3236 QObject::tr("SMESH_BUT_OK"));
3241 //================================================================================
3243 * \brief Update something in accordance with update flags
3244 * \param theFlags - update flags
3246 * Update viewer or/and object browser etc. in accordance with update flags ( see
3247 * LightApp_UpdateFlags enumeration ).
3249 //================================================================================
3250 void SMESHGUI::update( const int flags )
3252 if ( flags & UF_Viewer | flags & UF_Forced )
3253 SMESH::UpdateView();
3255 SalomeApp_Module::update( flags );
3258 //================================================================================
3260 * \brief Set default selection mode
3262 * SLOT called when operation commited. Sets default selection mode
3264 //================================================================================
3265 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3267 SVTK_ViewWindow* vtkWnd =
3268 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3270 vtkWnd->SetSelectionMode( ActorSelection );
3273 //================================================================================
3275 * \brief Set default selection mode
3277 * SLOT called when operation aborted. Sets default selection mode
3279 //================================================================================
3280 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3282 SVTK_ViewWindow* vtkWnd =
3283 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3285 vtkWnd->SetSelectionMode( ActorSelection );
3288 //================================================================================
3290 * \brief Creates operation with given identifier
3291 * \param id - identifier of operation to be started
3292 * \return Pointer on created operation or NULL if operation is not created
3294 * Virtual method redefined from the base class creates operation with given id.
3295 * It is called called automatically from startOperation method of base class.
3297 //================================================================================
3298 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3300 LightApp_Operation* op = 0;
3301 // to do : create operation here
3304 case 702: // Create mesh
3305 op = new SMESHGUI_MeshOp( true, true );
3307 case 703: // Create sub-mesh
3308 op = new SMESHGUI_MeshOp( true, false );
3310 case 704: // Edit mesh/sub-mesh
3311 op = new SMESHGUI_MeshOp( false );
3313 case 417: //convert to quadratic
3314 op = new SMESHGUI_ConvToQuadOp();
3316 case 4067: // make mesh pass through point
3317 op = new SMESHGUI_MakeNodeAtPointOp();
3324 op = SalomeApp_Module::createOperation( id );
3328 //================================================================================
3330 * \brief Stops current operations and starts a given one
3331 * \param id - The id of the operation to start
3333 //================================================================================
3335 void SMESHGUI::switchToOperation(int id)
3337 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3338 activeStudy()->abortAllOperations();
3339 startOperation( id );
3342 LightApp_Displayer* SMESHGUI::displayer()
3345 myDisplayer = new SMESHGUI_Displayer( getApp() );