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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_GEOMGenUtils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include "SMESH_Actor.h"
79 #include "SMESH_Object.h"
80 #include "SMESH_TypeFilter.hxx"
82 #include "SalomeApp_Tools.h"
83 #include "SalomeApp_Study.h"
84 #include "SalomeApp_Application.h"
85 #include "SalomeApp_CheckFileDlg.h"
86 #include "SalomeApp_ImportOperation.h"
88 #include "LightApp_DataOwner.h"
89 #include "LightApp_Preferences.h"
90 #include "LightApp_VTKSelector.h"
91 #include "LightApp_Operation.h"
92 #include "LightApp_UpdateFlags.h"
93 #include "LightApp_NameDlg.h"
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_InteractorStyle.h>
98 #include <SVTK_RenderWindowInteractor.h>
99 #include <SVTK_ViewManager.h>
101 #include "OB_Browser.h"
103 #include "SUIT_Tools.h"
104 #include "SUIT_MessageBox.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_FileDlg.h"
107 #include "SUIT_Desktop.h"
108 #include "SUIT_OverrideCursor.h"
109 #include "SUIT_Study.h"
110 #include "SUIT_Session.h"
112 #include "QtxPopupMgr.h"
114 #include "SALOME_ListIO.hxx"
115 #include "SALOME_ListIteratorOfListIO.hxx"
116 #include "SALOME_InteractiveObject.hxx"
117 #include "SALOME_NamingService.hxx"
118 #include "SALOME_LifeCycleCORBA.hxx"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qpopupmenu.h>
131 #include <boost/shared_ptr.hpp>
134 #include <vtkRenderer.h>
135 #include <vtkRenderWindow.h>
136 #include <vtkActorCollection.h>
137 #include <vtkScalarBarActor.h>
138 #include <vtkUnstructuredGrid.h>
140 #include "utilities.h"
142 #include "SALOMEDS_Study.hxx"
143 #include "SALOMEDSClient_StudyBuilder.hxx"
144 #include "SALOMEDSClient_SComponent.hxx"
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
171 if(theCommandID == 113){
172 filter.append(QObject::tr("MED files (*.med)"));
173 filter.append(QObject::tr("All files (*)"));
174 }else if (theCommandID == 112){
175 filter.append(QObject::tr("IDEAS files (*.unv)"));
176 }else if (theCommandID == 111){
177 filter.append(QObject::tr("DAT files (*.dat)"));
179 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
182 QObject::tr("Import mesh"),
184 if(!filename.isEmpty()) {
185 SUIT_OverrideCursor wc;
186 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
190 switch ( theCommandID ) {
193 aMeshes->length( 1 );
194 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
199 SMESH::DriverMED_ReadStatus res;
200 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
201 if ( res != SMESH::DRS_OK ) {
203 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
204 QObject::tr("SMESH_WRN_WARNING"),
205 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
206 QObject::tr("SMESH_BUT_OK"));
207 aMeshes->length( 0 );
214 bool isEmpty = false;
215 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
216 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
218 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
219 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
220 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
221 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
222 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
229 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
230 QObject::tr("SMESH_WRN_WARNING"),
231 QObject::tr("SMESH_DRS_EMPTY"),
232 QObject::tr("SMESH_BUT_OK"));
236 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
238 catch (const SALOME::SALOME_Exception& S_ex){
240 SalomeApp_Tools::QtCatchCorbaException(S_ex);
247 void ExportMeshToFile( int theCommandID )
249 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
250 SALOME_ListIO selected;
252 aSel->selectedObjects( selected );
254 if(selected.Extent()){
255 Handle(SALOME_InteractiveObject) anIObject = selected.First();
256 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
257 if ( !aMesh->_is_nil() ) {
258 QString aFilter, aTitle = QObject::tr("Export mesh");
259 QMap<QString, SMESH::MED_VERSION> aFilterMap;
260 switch ( theCommandID ) {
264 if (aMesh->HasDuplicatedGroupNamesMED()) {
265 int aRet = SUIT_MessageBox::warn2
266 (SMESHGUI::desktop(),
267 QObject::tr("SMESH_WRN_WARNING"),
268 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
269 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
275 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
276 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
281 aFilter = QObject::tr("DAT files (*.dat)");
286 if (aMesh->NbPyramids()) {
287 int aRet = SUIT_MessageBox::warn2
288 (SMESHGUI::desktop(),
289 QObject::tr("SMESH_WRN_WARNING"),
290 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
291 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
296 aFilter = QObject::tr("IDEAS files (*.unv)");
304 SMESH::MED_VERSION aFormat;
305 // Init the parameter with the default value
306 bool toCreateGroups = false;
307 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
309 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
311 if ( theCommandID != 122 && theCommandID != 125 )
312 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
315 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
316 for ( ; it != aFilterMap.end(); ++it )
317 filters.push_back( it.key() );
319 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
320 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
321 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
322 fd->setCaption( aTitle );
323 fd->setFilters( filters );
324 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
325 fd->SetChecked(toCreateGroups);
329 aFilename = fd->selectedFile();
330 aFormat = aFilterMap[fd->selectedFilter()];
332 if ( !aFilename.isEmpty()
333 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
334 && aFormat==SMESH::MED_V2_1) {
335 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
336 QObject::tr("SMESH_WRN_WARNING"),
337 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
338 QObject::tr("SMESH_BUT_YES"),
339 QObject::tr("SMESH_BUT_NO"),
346 toCreateGroups = fd->IsChecked();
349 if ( !aFilename.isEmpty() ) {
350 // Check whether the file already exists and delete it if yes
351 QFile aFile( aFilename );
352 if ( aFile.exists() )
354 SUIT_OverrideCursor wc;
355 switch ( theCommandID ) {
358 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
362 aMesh->ExportDAT( aFilename.latin1() );
366 aMesh->ExportUNV( aFilename.latin1() );
376 inline void InverseEntityMode(unsigned int& theOutputMode,
377 unsigned int theMode)
379 bool anIsNotPresent = ~theOutputMode & theMode;
381 theOutputMode |= theMode;
383 theOutputMode &= ~theMode;
386 void SetDisplayEntity(int theCommandID){
387 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
388 SALOME_ListIO selected;
390 aSel->selectedObjects( selected );
392 if(selected.Extent() >= 1){
393 SALOME_ListIteratorOfListIO It( selected );
394 for(; It.More(); It.Next()){
395 Handle(SALOME_InteractiveObject) IObject = It.Value();
396 if(IObject->hasEntry()){
397 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
398 unsigned int aMode = anActor->GetEntityMode();
399 switch(theCommandID){
401 InverseEntityMode(aMode,SMESH_Actor::eEdges);
404 InverseEntityMode(aMode,SMESH_Actor::eFaces);
407 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
410 aMode = SMESH_Actor::eAllEntity;
414 anActor->SetEntityMode(aMode);
421 void SetDisplayMode(int theCommandID){
422 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
423 SALOME_ListIO selected;
425 aSel->selectedObjects( selected );
427 if(selected.Extent() >= 1){
428 switch(theCommandID){
430 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
431 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
435 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
436 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
439 SALOME_ListIteratorOfListIO It( selected );
440 for(; It.More(); It.Next()){
441 Handle(SALOME_InteractiveObject) IObject = It.Value();
442 if(IObject->hasEntry()){
443 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
444 switch(theCommandID){
446 anActor->SetRepresentation(SMESH_Actor::eEdge);
449 anActor->SetRepresentation(SMESH_Actor::eSurface);
452 if(anActor->IsShrunk())
455 anActor->SetShrink();
458 anActor->SetRepresentation(SMESH_Actor::ePoint);
461 vtkFloatingPointType color[3];
462 anActor->GetSufaceColor(color[0], color[1], color[2]);
463 int c0 = int (color[0] * 255);
464 int c1 = int (color[1] * 255);
465 int c2 = int (color[2] * 255);
466 QColor c(c0, c1, c2);
468 vtkFloatingPointType edgecolor[3];
469 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
470 c0 = int (edgecolor[0] * 255);
471 c1 = int (edgecolor[1] * 255);
472 c2 = int (edgecolor[2] * 255);
473 QColor e(c0, c1, c2);
475 vtkFloatingPointType backfacecolor[3];
476 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
477 c0 = int (backfacecolor[0] * 255);
478 c1 = int (backfacecolor[1] * 255);
479 c2 = int (backfacecolor[2] * 255);
480 QColor b(c0, c1, c2);
482 vtkFloatingPointType nodecolor[3];
483 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
484 c0 = int (nodecolor[0] * 255);
485 c1 = int (nodecolor[1] * 255);
486 c2 = int (nodecolor[2] * 255);
487 QColor n(c0, c1, c2);
489 int Edgewidth = (int)anActor->GetLineWidth();
492 int intValue = int(anActor->GetNodeSize());
493 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
495 SMESHGUI_Preferences_ColorDlg *aDlg =
496 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
497 aDlg->SetColor(1, c);
498 aDlg->SetColor(2, e);
499 aDlg->SetColor(3, n);
500 aDlg->SetColor(4, b);
501 aDlg->SetIntValue(1, Edgewidth);
502 aDlg->SetIntValue(2, intValue);
503 aDlg->SetIntValue(3, int(Shrink*100.));
505 QColor color = aDlg->GetColor(1);
506 QColor edgecolor = aDlg->GetColor(2);
507 QColor nodecolor = aDlg->GetColor(3);
508 QColor backfacecolor = aDlg->GetColor(4);
509 /* actor color and backface color */
510 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
511 vtkFloatingPointType (color.green()) / 255.,
512 vtkFloatingPointType (color.blue()) / 255.);
513 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
514 vtkFloatingPointType (backfacecolor.green()) / 255.,
515 vtkFloatingPointType (backfacecolor.blue()) / 255.);
518 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
519 vtkFloatingPointType (edgecolor.green()) / 255.,
520 vtkFloatingPointType (edgecolor.blue()) / 255.);
522 /* Shrink factor and size edges */
523 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
524 anActor->SetLineWidth(aDlg->GetIntValue(1));
526 /* Nodes color and size */
527 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
528 vtkFloatingPointType (nodecolor.green()) / 255.,
529 vtkFloatingPointType (nodecolor.blue()) / 255.);
530 anActor->SetNodeSize(aDlg->GetIntValue(2));
539 SMESH::RepaintCurrentView();
543 void Control( int theCommandID )
545 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
546 SALOME_ListIO selected;
548 aSel->selectedObjects( selected );
550 if( !selected.IsEmpty() ){
551 Handle(SALOME_InteractiveObject) anIO = selected.First();
554 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
555 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
556 switch ( theCommandID ){
558 aTitle = QObject::tr( "LENGTH_EDGES" );
559 aControl = SMESH_Actor::eLength;
562 aTitle = QObject::tr( "LENGTH2D_EDGES" );
563 aControl = SMESH_Actor::eLength2D;
566 aTitle = QObject::tr( "FREE_EDGES" );
567 aControl = SMESH_Actor::eFreeEdges;
570 aTitle = QObject::tr( "FREE_BORDERS" );
571 aControl = SMESH_Actor::eFreeBorders;
574 aTitle = QObject::tr( "MULTI_BORDERS" );
575 aControl = SMESH_Actor::eMultiConnection;
578 aTitle = QObject::tr( "MULTI2D_BORDERS" );
579 aControl = SMESH_Actor::eMultiConnection2D;
582 aTitle = QObject::tr( "AREA_ELEMENTS" );
583 aControl = SMESH_Actor::eArea;
586 aTitle = QObject::tr( "TAPER_ELEMENTS" );
587 aControl = SMESH_Actor::eTaper;
590 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
591 aControl = SMESH_Actor::eAspectRatio;
594 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
595 aControl = SMESH_Actor::eAspectRatio3D;
598 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
599 aControl = SMESH_Actor::eMinimumAngle;
602 aTitle = QObject::tr( "WARP_ELEMENTS" );
603 aControl = SMESH_Actor::eWarping;
606 aTitle = QObject::tr( "SKEW_ELEMENTS" );
607 aControl = SMESH_Actor::eSkew;
610 aTitle = QObject::tr( "SMESH_VOLUME" );
611 aControl = SMESH_Actor::eVolume3D;
614 anActor->SetControlMode(aControl);
615 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
616 SMESH::RepaintCurrentView();
623 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
624 MeshObjectType theType,
625 const QString theInTypeName,
626 QString & theOutTypeName)
628 SMESH_TypeFilter aTypeFilter( theType );
630 if( !theIO.IsNull() )
632 entry = theIO->getEntry();
633 LightApp_DataOwner owner( entry );
634 if ( aTypeFilter.isOk( &owner )) {
635 theOutTypeName = theInTypeName;
643 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
645 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
646 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
648 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
649 CORBA::String_var anID = aSComp->GetID().c_str();
650 if (!strcmp(anID.in(),theIO->getEntry()))
656 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
657 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
658 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
659 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
660 CheckOIType ( theIO, GROUP, "Group", aTypeName )
668 QString CheckHomogeneousSelection()
670 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
671 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
672 SALOME_ListIO selected;
674 aSel->selectedObjects( selected );
676 QString RefType = CheckTypeObject(selected.First());
677 SALOME_ListIteratorOfListIO It(selected);
678 for (; It.More(); It.Next())
680 Handle(SALOME_InteractiveObject) IObject = It.Value();
681 QString Type = CheckTypeObject(IObject);
682 if (Type.compare(RefType) != 0)
683 return "Heterogeneous Selection";
690 void SMESHGUI::OnEditDelete()
692 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
693 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
694 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
696 QString aParentComponent = QString::null;
697 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
699 QString cur = anIt.Value()->getComponentDataType();
700 if( aParentComponent.isNull() )
701 aParentComponent = cur;
702 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
703 aParentComponent = "";
706 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
707 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
708 QObject::tr("ERR_ERROR"),
709 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
710 QObject::tr("BUT_OK") );
713 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
714 if (SUIT_MessageBox::warn2
715 (SMESHGUI::desktop(),
716 QObject::tr("SMESH_WRN_WARNING"),
717 QObject::tr("SMESH_REALLY_DELETE"),
718 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
721 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
722 SUIT_ViewManager* vm = anApp->activeViewManager();
723 int nbSf = vm->getViewsCount();
725 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
726 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
727 _PTR(GenericAttribute) anAttr;
728 _PTR(AttributeIOR) anIOR;
730 SALOME_ListIteratorOfListIO It(selected);
732 aStudyBuilder->NewCommand(); // There is a transaction
733 for(; It.More(); It.Next()){ // loop on selected IO's
734 Handle(SALOME_InteractiveObject) IObject = It.Value();
735 if(IObject->hasEntry()) {
736 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
738 // disable removal of "SMESH" component object
739 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
741 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
745 // put the whole hierarchy of sub-objects of the selected SO into a list and
746 // then treat them all starting from the deepest objects (at list back)
748 list< _PTR(SObject) > listSO;
749 listSO.push_back( aSO );
750 list< _PTR(SObject) >::iterator itSO = listSO.begin();
751 for ( ; itSO != listSO.end(); ++itSO ) {
752 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
753 for (it->InitEx(false); it->More(); it->Next())
754 listSO.push_back( it->Value() );
757 // treat SO's in the list starting from the back
759 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
760 for ( ; ritSO != listSO.rend(); ++ritSO ) {
761 _PTR(SObject) SO = *ritSO;
763 string anEntry = SO->GetID();
765 /** Erase graphical object **/
766 if(SO->FindAttribute(anAttr, "AttributeIOR")){
767 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
768 for(int i = 0; i < nbSf; i++){
769 SUIT_ViewWindow *sf = aViews[i];
770 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
771 SMESH::RemoveActor(sf,anActor);
776 /** Remove an object from data structures **/
777 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
778 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
779 if ( !aGroup->_is_nil() ) { // DELETE GROUP
780 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
781 aMesh->RemoveGroup( aGroup );
783 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
784 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
785 aMesh->RemoveSubMesh( aSubMesh );
787 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
789 SMESH::ModifiedMesh(aMeshSO, false);
792 IObject = new SALOME_InteractiveObject
793 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
794 QString objType = CheckTypeObject(IObject);
795 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
796 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
797 aStudyBuilder->RemoveObjectWithChildren( SO );
799 else {// default action: remove SObject from the study
800 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
801 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
803 aStudyBuilder->RemoveObjectWithChildren( SO );
807 } /* listSO back loop */
808 } /* IObject->hasEntry() */
810 aStudyBuilder->CommitCommand();
812 /* Clear any previous selection */
814 aSel->setSelectedObjects( l1 );
816 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
821 Standard_EXPORT CAM_Module* createModule()
823 return new SMESHGUI();
827 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
829 //=============================================================================
833 //=============================================================================
834 SMESHGUI::SMESHGUI() :
835 SalomeApp_Module( "SMESH" )
837 if ( CORBA::is_nil( myComponentSMESH ) )
839 CORBA::Boolean anIsEmbeddedMode;
840 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
843 myActiveDialogBox = 0;
844 myFilterLibraryDlg = 0;
848 SMESH::GetFilterManager();
851 /* load resources for all available meshers */
852 SMESH::InitAvailableHypotheses();
855 //=============================================================================
859 //=============================================================================
860 SMESHGUI::~SMESHGUI()
862 SMESH::GetFilterManager()->Destroy();
863 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
866 //=============================================================================
870 //=============================================================================
871 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
873 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
875 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
880 bool SMESHGUI::automaticUpdate()
882 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
886 return resMgr->booleanValue( "SMESH", "auto_update", false );
889 //=============================================================================
893 //=============================================================================
894 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
896 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
899 //=============================================================================
903 //=============================================================================
904 SMESHGUI* SMESHGUI::GetSMESHGUI()
906 SMESHGUI* smeshMod = 0;
907 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
910 CAM_Module* module = app->module( "Mesh" );
911 smeshMod = dynamic_cast<SMESHGUI*>( module );
914 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
916 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
919 _PTR(Study) aStudy = study->studyDS();
921 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
930 Standard_EXPORT SMESHGUI* GetComponentGUI()
932 return SMESHGUI::GetSMESHGUI();
936 //=============================================================================
940 //=============================================================================
941 void SMESHGUI::SetState(int aState)
946 //=============================================================================
950 //=============================================================================
951 void SMESHGUI::ResetState()
956 //=============================================================================
960 //=============================================================================
961 void SMESHGUI::EmitSignalDeactivateDialog()
963 emit SignalDeactivateActiveDialog();
966 //=============================================================================
970 //=============================================================================
971 void SMESHGUI::EmitSignalStudyFrameChanged()
973 emit SignalStudyFrameChanged();
976 //=============================================================================
980 //=============================================================================
981 void SMESHGUI::EmitSignalCloseAllDialogs()
983 emit SignalCloseAllDialogs();
986 //=============================================================================
990 //=============================================================================
991 QDialog *SMESHGUI::GetActiveDialogBox()
993 return myActiveDialogBox;
996 //=============================================================================
1000 //=============================================================================
1001 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1003 myActiveDialogBox = (QDialog *) aDlg;
1007 //=============================================================================
1011 //=============================================================================
1012 SUIT_Desktop* SMESHGUI::desktop()
1014 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1016 return app->desktop();
1021 //=============================================================================
1025 //=============================================================================
1026 SalomeApp_Study* SMESHGUI::activeStudy()
1028 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1030 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1035 //=============================================================================
1039 //=============================================================================
1040 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1042 /* Here the position is on the bottom right corner - 10 */
1043 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1045 SUIT_Desktop *PP = desktop();
1046 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1047 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1051 //=============================================================================
1055 //=============================================================================
1056 static int isStudyLocked(_PTR(Study) theStudy){
1057 return theStudy->GetProperties()->IsLocked();
1060 static bool checkLock(_PTR(Study) theStudy) {
1061 if (isStudyLocked(theStudy)) {
1062 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1063 QObject::tr("WRN_WARNING"),
1064 QObject::tr("WRN_STUDY_LOCKED"),
1065 QObject::tr("BUT_OK") );
1071 //=======================================================================
1072 //function : CheckActiveStudyLocked
1074 //=======================================================================
1076 bool SMESHGUI::isActiveStudyLocked()
1078 _PTR(Study) aStudy = activeStudy()->studyDS();
1079 return checkLock( aStudy );
1082 //=============================================================================
1086 //=============================================================================
1087 bool SMESHGUI::OnGUIEvent( int theCommandID )
1089 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1093 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1094 SUIT_ResourceMgr* mgr = resourceMgr();
1098 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1099 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1102 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1103 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1105 //QAction* act = action( theCommandID );
1107 switch (theCommandID) {
1109 if(checkLock(aStudy)) break;
1117 if(checkLock(aStudy)) break;
1118 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1122 case 122: // EXPORT MED
1129 ::ExportMeshToFile(theCommandID);
1133 case 200: // SCALAR BAR
1135 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1136 SALOME_ListIO selected;
1138 aSel->selectedObjects( selected );
1140 if( selected.Extent() ) {
1141 Handle(SALOME_InteractiveObject) anIO = selected.First();
1142 if( anIO->hasEntry() ) {
1143 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1144 anActor->SetControlMode( SMESH_Actor::eNone );
1152 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1156 case 1134: // Clipping
1157 case 1133: // Tranparency
1158 case 1132: // Colors / Size
1165 ::SetDisplayMode(theCommandID);
1171 case 219: // Volumes
1172 case 220: // All Entity
1173 ::SetDisplayEntity(theCommandID);
1178 if(checkLock(aStudy)) break;
1179 SMESH::UpdateView();
1182 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1183 aSel->selectedObjects( l );
1184 aSel->setSelectedObjects( l );
1189 case 301: // DISPLAY
1190 case 302: // DISPLAY ONLY
1192 SMESH::EDisplaing anAction;
1193 switch (theCommandID) {
1194 case 300: anAction = SMESH::eErase; break;
1195 case 301: anAction = SMESH::eDisplay; break;
1196 case 302: anAction = SMESH::eDisplayOnly; break;
1199 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1200 SALOME_ListIO sel_objects, to_process;
1202 aSel->selectedObjects( sel_objects );
1204 if( theCommandID==302 )
1205 startOperation( myEraseAll );
1207 extractContainers( sel_objects, to_process );
1210 SALOME_ListIteratorOfListIO It( to_process );
1211 for (; It.More(); It.Next()) {
1212 Handle(SALOME_InteractiveObject) IOS = It.Value();
1213 if (IOS->hasEntry()) {
1214 SMESH::UpdateView(anAction, IOS->getEntry());
1215 if (anAction == SMESH::eDisplayOnly)
1216 anAction = SMESH::eDisplay;
1221 if (anAction == SMESH::eErase) {
1223 aSel->setSelectedObjects( l1 );
1226 aSel->setSelectedObjects( to_process );
1232 if(checkLock(aStudy)) break;
1235 EmitSignalDeactivateDialog();
1237 new SMESHGUI_NodesDlg(this);
1240 SUIT_MessageBox::warn1(desktop(),
1241 tr("SMESH_WRN_WARNING"),
1242 tr("SMESH_WRN_VIEWER_VTK"),
1243 tr("SMESH_BUT_OK"));
1248 case 2151: // FILTER
1252 EmitSignalDeactivateDialog();
1253 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1258 case 406: // MOVE NODE
1262 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1263 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1267 if(checkLock(aStudy)) break;
1268 new SMESHGUI_MoveNodesDlg(this);
1272 case 701: // COMPUTE MESH
1274 if(checkLock(aStudy)) break;
1276 LightApp_SelectionMgr *Sel = selectionMgr();
1277 SALOME_ListIO selected; Sel->selectedObjects( selected );
1280 int nbSel = selected.Extent();
1285 SMESH::SMESH_Mesh_var aMesh;
1286 SMESH::SMESH_subMesh_var aSubMesh;
1287 Handle(SALOME_InteractiveObject) IObject = selected.First();
1288 if (IObject->hasEntry()) {
1289 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1290 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1291 if ( aShapeObject->_is_nil() ) {
1296 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1297 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1298 if ( !aSubMesh->_is_nil() )
1299 aMesh = aSubMesh->GetFather();
1301 if (!aMesh->_is_nil()) {
1302 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1303 // SUIT_MessageBox::warn1(desktop(),
1304 // tr("SMESH_WRN_WARNING"),
1305 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1306 // tr("SMESH_BUT_OK"));
1309 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1310 if ( errors->length() > 0 ) {
1311 SUIT_MessageBox::warn1(desktop(),
1312 tr("SMESH_WRN_WARNING"),
1313 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1314 tr("SMESH_BUT_OK"));
1318 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1319 SMESH::ModifiedMesh(aMeshSObj,true);
1321 SUIT_MessageBox::warn1(desktop(),
1322 tr("SMESH_WRN_WARNING"),
1323 tr("SMESH_WRN_COMPUTE_FAILED"),
1324 tr("SMESH_BUT_OK"));
1326 catch(const SALOME::SALOME_Exception & S_ex){
1327 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1332 CORBA::Long anId = aStudy->StudyId();
1333 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1334 if ( automaticUpdate() && aVisualObj){
1335 aVisualObj->Update();
1336 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1338 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1340 SMESH::DisplayActor(view,anActor); //apo
1344 SMESH::RepaintCurrentView();
1347 SUIT_MessageBox::warn1(desktop(),
1348 tr("SMESH_WRN_WARNING"),
1349 tr("SMESH_WRN_VIEWER_VTK"),
1350 tr("SMESH_BUT_OK"));
1353 Sel->setSelectedObjects( selected );
1357 case 702: // Create mesh
1358 startOperation( 702 );
1360 case 703: // Create sub-mesh
1361 startOperation( 703 );
1363 case 704: // Edit mesh/sub-mesh
1364 startOperation( 704 );
1366 case 407: // DIAGONAL INVERSION
1367 case 408: // Delete diagonal
1371 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1372 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1376 if ( checkLock( aStudy ) )
1379 /*Standard_Boolean aRes;
1380 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1381 if ( aMesh->_is_nil() )
1383 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1384 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1388 EmitSignalDeactivateDialog();
1389 if ( theCommandID == 407 )
1390 new SMESHGUI_TrianglesInversionDlg(this);
1392 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1395 case 409: // Change orientation
1396 case 410: // Union of triangles
1397 case 411: // Cutting of quadrangles
1401 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1402 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1406 if ( checkLock( aStudy ) )
1409 EmitSignalDeactivateDialog();
1410 SMESHGUI_MultiEditDlg* aDlg = NULL;
1411 if ( theCommandID == 409 )
1412 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1413 else if ( theCommandID == 410 )
1414 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1416 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1421 case 412: // Smoothing
1423 if(checkLock(aStudy)) break;
1425 EmitSignalDeactivateDialog();
1426 new SMESHGUI_SmoothingDlg( this );
1429 SUIT_MessageBox::warn1(desktop(),
1430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1431 tr("SMESH_BUT_OK"));
1435 case 413: // Extrusion
1437 if (checkLock(aStudy)) break;
1439 EmitSignalDeactivateDialog();
1440 new SMESHGUI_ExtrusionDlg ( this );
1442 SUIT_MessageBox::warn1(desktop(),
1443 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1444 tr("SMESH_BUT_OK"));
1448 case 414: // Revolution
1450 if(checkLock(aStudy)) break;
1452 EmitSignalDeactivateDialog();
1453 new SMESHGUI_RevolutionDlg( this );
1456 SUIT_MessageBox::warn1(desktop(),
1457 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1458 tr("SMESH_BUT_OK"));
1462 case 415: // Pattern mapping
1464 if ( checkLock( aStudy ) )
1468 EmitSignalDeactivateDialog();
1469 new SMESHGUI_MeshPatternDlg( this );
1472 SUIT_MessageBox::warn1(desktop(),
1473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1474 tr("SMESH_BUT_OK"));
1478 case 416: // Extrusion along a path
1480 if (checkLock(aStudy)) break;
1482 EmitSignalDeactivateDialog();
1483 new SMESHGUI_ExtrusionAlongPathDlg( this );
1485 SUIT_MessageBox::warn1(desktop(),
1486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487 tr("SMESH_BUT_OK"));
1491 case 417: // Convert mesh to quadratic
1493 startOperation( 417 );
1494 /* if (checkLock(aStudy)) break;
1496 EmitSignalDeactivateDialog();
1497 new SMESHGUI_ConvToQuadDlg();
1499 SUIT_MessageBox::warn1(desktop(),
1500 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1501 tr("SMESH_BUT_OK"));
1505 case 801: // CREATE GROUP
1509 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1510 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1514 if(checkLock(aStudy)) break;
1515 EmitSignalDeactivateDialog();
1516 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1518 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1519 SALOME_ListIO selected;
1521 aSel->selectedObjects( selected );
1523 int nbSel = selected.Extent();
1525 // check if mesh is selected
1526 aMesh = SMESH::GetMeshByIO( selected.First() );
1528 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1533 case 802: // CONSTRUCT GROUP
1537 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1538 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1542 if(checkLock(aStudy)) break;
1543 EmitSignalDeactivateDialog();
1545 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1546 SALOME_ListIO selected;
1548 aSel->selectedObjects( selected );
1550 int nbSel = selected.Extent();
1552 // check if submesh is selected
1553 Handle(SALOME_InteractiveObject) IObject = selected.First();
1554 if (IObject->hasEntry()) {
1555 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1557 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1558 if (!aSubMesh->_is_nil()) {
1560 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1561 // get submesh elements list by types
1562 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1563 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1564 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1565 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1566 // create group for each type o elements
1567 QString aName = IObject->getName();
1568 if (aNodes->length() > 0) {
1569 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1570 aGroup->Add(aNodes.inout());
1572 if (aEdges->length() > 0) {
1573 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1574 aGroup->Add(aEdges.inout());
1576 if (aFaces->length() > 0) {
1577 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1578 aGroup->Add(aFaces.inout());
1580 if (aVolumes->length() > 0) {
1581 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1582 aGroup->Add(aVolumes.inout());
1586 }catch(const SALOME::SALOME_Exception & S_ex){
1587 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1596 case 803: // EDIT GROUP
1600 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1601 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1605 if(checkLock(aStudy)) break;
1606 EmitSignalDeactivateDialog();
1608 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1609 SALOME_ListIO selected;
1611 aSel->selectedObjects( selected );
1613 SALOME_ListIteratorOfListIO It (selected);
1614 int nbSelectedGroups = 0;
1615 for ( ; It.More(); It.Next() )
1617 SMESH::SMESH_GroupBase_var aGroup =
1618 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1619 if (!aGroup->_is_nil()) {
1621 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1625 if (nbSelectedGroups == 0)
1627 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1633 case 804: // Add elements to group
1635 if(checkLock(aStudy)) break;
1636 if (myState == 800) {
1637 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1638 if (aDlg) aDlg->onAdd();
1643 case 805: // Remove elements from group
1645 if(checkLock(aStudy)) break;
1646 if (myState == 800) {
1647 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1648 if (aDlg) aDlg->onRemove();
1653 case 810: // Union Groups
1654 case 811: // Intersect groups
1655 case 812: // Cut groups
1659 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1660 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1664 if ( checkLock( aStudy ) )
1667 EmitSignalDeactivateDialog();
1670 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1671 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1672 else aMode = SMESHGUI_GroupOpDlg::CUT;
1674 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1678 case 813: // Delete groups with their contents
1682 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1683 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1687 if ( checkLock( aStudy ) )
1690 EmitSignalDeactivateDialog();
1692 new SMESHGUI_DeleteGroupDlg( this );
1696 case 900: // MESH INFOS
1698 EmitSignalDeactivateDialog();
1699 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1700 SALOME_ListIO selected;
1702 aSel->selectedObjects( selected );
1704 if ( selected.Extent() > 1 ) { // a dlg for each IO
1706 SALOME_ListIteratorOfListIO It (selected);
1707 for ( ; It.More(); It.Next() ) {
1708 IOs.Clear(); IOs.Append( It.Value() );
1709 aSel->setSelectedObjects( IOs );
1710 new SMESHGUI_MeshInfosDlg(this, "", false);
1712 // restore selection
1713 aSel->setSelectedObjects( selected );
1716 new SMESHGUI_MeshInfosDlg(this, "", false);
1720 case 902: // STANDARD MESH INFOS
1722 EmitSignalDeactivateDialog();
1723 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1724 SALOME_ListIO selected;
1726 aSel->selectedObjects( selected );
1728 if ( selected.Extent() > 1 ) { // a dlg for each IO
1730 SALOME_ListIteratorOfListIO It (selected);
1731 for ( ; It.More(); It.Next() ) {
1733 IOs.Append( It.Value() );
1734 aSel->setSelectedObjects( IOs );
1735 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1737 // restore selection
1738 aSel->setSelectedObjects( selected );
1741 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1745 case 1100: // EDIT HYPOTHESIS
1747 if(checkLock(aStudy)) break;
1749 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1750 SALOME_ListIO selected;
1752 aSel->selectedObjects( selected );
1754 int nbSel = selected.Extent();
1757 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1759 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1760 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1761 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1762 if ( !Hyp->_is_nil() )
1764 char* sName = Hyp->GetName();
1765 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1767 aCreator->edit( Hyp.in(), desktop() );
1774 updateObjBrowser( true );
1778 case 1101: // RENAME
1780 if ( checkLock( aStudy ) )
1783 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1784 SALOME_ListIO selected;
1786 aSel->selectedObjects( selected );
1788 SALOME_ListIteratorOfListIO It( selected );
1789 for ( ; It.More(); It.Next() )
1791 Handle(SALOME_InteractiveObject) IObject = It.Value();
1792 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1793 _PTR(GenericAttribute) anAttr;
1794 _PTR(AttributeName) aName;
1797 if ( obj->FindAttribute(anAttr, "AttributeName") )
1800 QString newName = QString(aName->Value().c_str());
1801 newName = LightApp_NameDlg::getName(desktop(), newName);
1802 if ( !newName.isEmpty() )
1804 //old source: aStudy->renameIObject( IObject, newName );
1805 aName->SetValue( newName.latin1() );
1807 // if current object is group update group's name
1808 SMESH::SMESH_GroupBase_var aGroup =
1809 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1810 if (!aGroup->_is_nil() )
1811 aGroup->SetName( newName.latin1() );
1821 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1823 if(checkLock(aStudy)) break;
1824 SUIT_OverrideCursor wc;
1826 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1827 SALOME_ListIO selected;
1829 aSel->selectedObjects( selected, QString::null, false );
1831 SALOME_ListIteratorOfListIO It(selected);
1832 for (int i = 0; It.More(); It.Next(), i++) {
1833 Handle(SALOME_InteractiveObject) IObject = It.Value();
1834 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1837 aSel->setSelectedObjects( l1 );
1842 case 401: // GEOM::EDGE
1843 case 4021: // TRIANGLE
1845 case 4023: // POLYGON
1849 if(checkLock(aStudy)) break;
1851 EmitSignalDeactivateDialog();
1852 SMDSAbs_ElementType type = SMDSAbs_Edge;
1854 switch (theCommandID) {
1855 case 4021: // TRIANGLE
1856 type = SMDSAbs_Face; nbNodes = 3; break;
1858 type = SMDSAbs_Face; nbNodes = 4; break;
1860 type = SMDSAbs_Volume; nbNodes = 4; break;
1861 case 4023: // POLYGON
1862 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1864 type = SMDSAbs_Volume; nbNodes = 8; break;
1865 case 4033: // POLYHEDRE
1866 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1869 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1872 SUIT_MessageBox::warn1(desktop(),
1873 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1874 tr("SMESH_BUT_OK"));
1878 case 4033: // POLYHEDRON
1880 if(checkLock(aStudy)) break;
1882 EmitSignalDeactivateDialog();
1883 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1886 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1887 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1888 tr("SMESH_BUT_OK"));
1892 case 4034: // QUADRATIC EDGE
1893 case 4035: // QUADRATIC TRIANGLE
1894 case 4036: // QUADRATIC QUADRANGLE
1895 case 4037: // QUADRATIC TETRAHEDRON
1896 case 4038: // QUADRATIC PYRAMID
1897 case 4039: // QUADRATIC PENTAHEDRON
1898 case 4040: // QUADRATIC HEXAHEDRON
1900 if(checkLock(aStudy)) break;
1902 EmitSignalDeactivateDialog();
1905 switch (theCommandID) {
1907 type = QUAD_EDGE; break;
1909 type = QUAD_TRIANGLE; break;
1911 type = QUAD_QUADRANGLE; break;
1913 type = QUAD_TETRAHEDRON; break;
1915 type = QUAD_PYRAMID; break;
1917 type = QUAD_PENTAHEDRON; break;
1919 type = QUAD_HEXAHEDRON;
1923 new SMESHGUI_AddQuadraticElementDlg( this, type );
1926 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1927 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1928 tr("SMESH_BUT_OK"));
1932 case 4041: // REMOVES NODES
1934 if(checkLock(aStudy)) break;
1936 EmitSignalDeactivateDialog();
1937 new SMESHGUI_RemoveNodesDlg(this);
1940 SUIT_MessageBox::warn1(desktop(),
1941 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1942 tr("SMESH_BUT_OK"));
1946 case 4042: // REMOVES ELEMENTS
1948 if(checkLock(aStudy)) break;
1950 EmitSignalDeactivateDialog();
1951 new SMESHGUI_RemoveElementsDlg(this);
1955 SUIT_MessageBox::warn1(desktop(),
1956 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1957 tr("SMESH_BUT_OK"));
1961 case 4051: // RENUMBERING NODES
1963 if(checkLock(aStudy)) break;
1965 EmitSignalDeactivateDialog();
1966 new SMESHGUI_RenumberingDlg( this, "", 0);
1970 SUIT_MessageBox::warn1(desktop(),
1971 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1972 tr("SMESH_BUT_OK"));
1976 case 4052: // RENUMBERING ELEMENTS
1978 if(checkLock(aStudy)) break;
1980 EmitSignalDeactivateDialog();
1981 new SMESHGUI_RenumberingDlg( this, "", 1);
1985 SUIT_MessageBox::warn1(desktop(),
1986 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1987 tr("SMESH_BUT_OK"));
1991 case 4061: // TRANSLATION
1993 if(checkLock(aStudy)) break;
1995 EmitSignalDeactivateDialog();
1996 new SMESHGUI_TranslationDlg( this );
1999 SUIT_MessageBox::warn1(desktop(),
2000 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2001 tr("SMESH_BUT_OK"));
2005 case 4062: // ROTATION
2007 if(checkLock(aStudy)) break;
2009 EmitSignalDeactivateDialog();
2010 new SMESHGUI_RotationDlg( this );
2013 SUIT_MessageBox::warn1(desktop(),
2014 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2015 tr("SMESH_BUT_OK"));
2019 case 4063: // SYMMETRY
2021 if(checkLock(aStudy)) break;
2023 EmitSignalDeactivateDialog();
2024 new SMESHGUI_SymmetryDlg( this );
2027 SUIT_MessageBox::warn1(desktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2033 case 4064: // SEWING
2035 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2038 new SMESHGUI_SewingDlg( this );
2041 SUIT_MessageBox::warn1(desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4065: // MERGE NODES
2049 if(checkLock(aStudy)) break;
2051 EmitSignalDeactivateDialog();
2052 new SMESHGUI_MergeNodesDlg( this );
2055 SUIT_MessageBox::warn1(desktop(),
2056 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2057 tr("SMESH_BUT_OK"));
2061 case 4066: // MERGE EQUAL ELEMENTS
2063 if (checkLock(aStudy)) break;
2065 EmitSignalDeactivateDialog();
2066 new SMESHGUI_EditMeshDlg(this,
2067 "SMESH_MERGE_ELEMENTS_TITLE",
2068 "ICON_DLG_MERGE_ELEMENTS",
2069 1); // MergeEqualElemets
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2078 case 5105: // Library of selection filters
2080 static QValueList<int> aTypes;
2081 if ( aTypes.isEmpty() )
2083 aTypes.append( SMESH::NODE );
2084 aTypes.append( SMESH::EDGE );
2085 aTypes.append( SMESH::FACE );
2086 aTypes.append( SMESH::VOLUME );
2088 if (!myFilterLibraryDlg)
2089 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2090 else if (myFilterLibraryDlg->isHidden())
2091 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2092 myFilterLibraryDlg->raise();
2096 case 6017: // CONTROLS
2112 LightApp_SelectionMgr* mgr = selectionMgr();
2113 SALOME_ListIO selected; mgr->selectedObjects( selected );
2115 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2116 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2118 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2119 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2120 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2121 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2122 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2123 ::Control( theCommandID );
2128 SUIT_MessageBox::warn1(desktop(),
2129 tr( "SMESH_WRN_WARNING" ),
2130 tr( "SMESH_BAD_SELECTION" ),
2131 tr( "SMESH_BUT_OK" ) );
2135 SUIT_MessageBox::warn1(desktop(),
2136 tr( "SMESH_WRN_WARNING" ),
2137 tr( "NOT_A_VTK_VIEWER" ),
2138 tr( "SMESH_BUT_OK" ) );
2143 LightApp_SelectionMgr* mgr = selectionMgr();
2144 SALOME_ListIO selected; mgr->selectedObjects( selected );
2146 if (selected.Extent() == 1) {
2147 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2148 if(anIObject->hasEntry())
2149 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2150 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2157 LightApp_SelectionMgr* mgr = selectionMgr();
2158 SALOME_ListIO selected; mgr->selectedObjects( selected );
2160 if (selected.Extent() == 1) {
2161 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2162 if(anIObject->hasEntry())
2163 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2164 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2171 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2172 //updateObjBrowser();
2176 //=============================================================================
2180 //=============================================================================
2181 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2186 //=============================================================================
2190 //=============================================================================
2191 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2196 //=============================================================================
2200 //=============================================================================
2201 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2206 //=============================================================================
2207 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2208 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2210 //=============================================================================
2211 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2212 SUIT_ViewWindow* wnd )
2214 if(theIO->hasEntry()){
2215 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2216 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2220 //=======================================================================
2221 // function : createSMESHAction
2223 //=======================================================================
2224 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2227 QWidget* parent = application()->desktop();
2228 SUIT_ResourceMgr* resMgr = resourceMgr();
2230 if ( icon_id.length() )
2231 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2233 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2234 if ( !pix.isNull() )
2235 icon = QIconSet( pix );
2237 QString tooltip = tr( QString( "TOP_" )+po_id ),
2238 menu = tr( QString( "MEN_" )+po_id ),
2239 status_bar = tr( QString( "STB_" )+po_id );
2241 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2244 //=======================================================================
2245 // function : createPopupItem
2247 //=======================================================================
2248 void SMESHGUI::createPopupItem( const int id,
2249 const QString& clients,
2250 const QString& types,
2251 const QString& theRule,
2256 parentId = popupMgr()->actionId( action( pId ) );
2258 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2259 popupMgr()->insert( action( id ), parentId, 0 );
2261 QChar lc = QtxPopupMgr::Selection::defEquality();
2262 QString rule = "(%1) and (%2) and (%3)";
2263 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2264 if( clients.isEmpty() )
2265 rule = rule.arg( QString( "true" ) );
2267 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2268 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2271 bool cont = myRules.contains( id );
2273 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2275 popupMgr()->setRule( action( id ), rule, true );
2276 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2279 //=======================================================================
2280 // function : initialize
2282 //=======================================================================
2283 void SMESHGUI::initialize( CAM_Application* app )
2285 SalomeApp_Module::initialize( app );
2287 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2289 /* Automatic Update flag */
2290 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2292 // ----- create actions --------------
2294 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2295 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2296 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2297 createSMESHAction( 114, "NUM" );
2298 createSMESHAction( 121, "DAT" );
2299 createSMESHAction( 122, "MED" );
2300 createSMESHAction( 123, "UNV" );
2301 createSMESHAction( 124, "EXPORT_DAT" );
2302 createSMESHAction( 125, "EXPORT_MED" );
2303 createSMESHAction( 126, "EXPORT_UNV" );
2304 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2305 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2306 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2307 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2308 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2309 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2310 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2311 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2312 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2313 createSMESHAction( 804, "ADD" );
2314 createSMESHAction( 805, "REMOVE" );
2315 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2316 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2317 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2318 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2319 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2320 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2321 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2322 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2323 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2324 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2325 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2326 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2327 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2328 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2329 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2330 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2331 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2332 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2333 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2334 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2335 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2336 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2337 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2338 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2339 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2340 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2341 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2342 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2343 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2344 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2345 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2346 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2347 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2348 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2349 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2350 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2351 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2352 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2353 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2354 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2355 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2356 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2357 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2358 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2359 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2360 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2361 createSMESHAction( 415, "MAP", "ICON_MAP" );
2362 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2363 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2364 createSMESHAction( 200, "RESET" );
2365 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2366 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2367 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2368 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2369 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2370 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2371 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2372 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2373 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2374 createSMESHAction( 220, "ALL" );
2375 createSMESHAction( 1100, "EDIT_HYPO" );
2376 createSMESHAction( 1101, "RENAME" );
2377 createSMESHAction( 1102, "UNASSIGN" );
2378 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2379 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2380 createSMESHAction( 1131, "DISPMODE" );
2381 createSMESHAction( 1132, "COLORS" );
2382 createSMESHAction( 1133, "TRANSP" );
2383 createSMESHAction( 1134, "CLIP" );
2384 createSMESHAction( 1135, "DISP_ENT" );
2385 createSMESHAction( 2000, "CTRL" );
2387 createSMESHAction( 300, "ERASE" );
2388 createSMESHAction( 301, "DISPLAY" );
2389 createSMESHAction( 302, "DISPLAY_ONLY" );
2390 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2391 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2392 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2393 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2394 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2395 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2396 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2397 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2399 // ----- create menu --------------
2400 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2401 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2402 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2403 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2404 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2405 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2406 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2408 createMenu( separator(), fileId );
2410 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2411 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2412 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2413 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2414 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2415 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2417 createMenu( 111, importId, -1 );
2418 createMenu( 112, importId, -1 );
2419 createMenu( 113, importId, -1 );
2421 createMenu( 121, exportId, -1 );
2422 createMenu( 122, exportId, -1 );
2423 createMenu( 123, exportId, -1 );
2425 createMenu( separator(), fileId, 10 );
2427 createMenu( 33, editId, -1 );
2429 createMenu( 5105, toolsId, -1 );
2431 createMenu( 702, meshId, -1 );
2432 createMenu( 703, meshId, -1 );
2433 createMenu( 704, meshId, -1 );
2434 createMenu( separator(), meshId, -1 );
2435 createMenu( 701, meshId, -1 );
2436 createMenu( separator(), meshId, -1 );
2437 createMenu( 801, meshId, -1 );
2438 createMenu( 802, meshId, -1 );
2439 createMenu( 803, meshId, -1 );
2440 createMenu( separator(), meshId, -1 );
2441 createMenu( 810, meshId, -1 );
2442 createMenu( 811, meshId, -1 );
2443 createMenu( 812, meshId, -1 );
2444 createMenu( separator(), meshId, -1 );
2445 createMenu( 813, meshId, -1 );
2446 createMenu( separator(), meshId, -1 );
2447 createMenu( 900, meshId, -1 );
2448 createMenu( 902, meshId, -1 );
2449 createMenu( separator(), meshId, -1 );
2451 createMenu( 6003, ctrlId, -1 );
2452 createMenu( 6001, ctrlId, -1 );
2453 createMenu( 6004, ctrlId, -1 );
2454 createMenu( separator(), ctrlId, -1 );
2455 createMenu( 6002, ctrlId, -1 );
2456 createMenu( 6018, ctrlId, -1 );
2457 createMenu( 6019, ctrlId, -1 );
2458 createMenu( 6011, ctrlId, -1 );
2459 createMenu( 6012, ctrlId, -1 );
2460 createMenu( 6013, ctrlId, -1 );
2461 createMenu( 6014, ctrlId, -1 );
2462 createMenu( 6015, ctrlId, -1 );
2463 createMenu( 6016, ctrlId, -1 );
2464 createMenu( separator(), ctrlId, -1 );
2465 createMenu( 6017, ctrlId, -1 );
2466 createMenu( 6009, ctrlId, -1 );
2467 createMenu( separator(), ctrlId, -1 );
2469 createMenu( 400, addId, -1 );
2470 createMenu( 401, addId, -1 );
2471 createMenu( 4021, addId, -1 );
2472 createMenu( 4022, addId, -1 );
2473 createMenu( 4023, addId, -1 );
2474 createMenu( 4031, addId, -1 );
2475 createMenu( 4032, addId, -1 );
2476 createMenu( 4033, addId, -1 );
2477 createMenu( separator(), addId, -1 );
2478 createMenu( 4034, addId, -1 );
2479 createMenu( 4035, addId, -1 );
2480 createMenu( 4036, addId, -1 );
2481 createMenu( 4037, addId, -1 );
2482 createMenu( 4038, addId, -1 );
2483 createMenu( 4039, addId, -1 );
2484 createMenu( 4040, addId, -1 );
2486 createMenu( 4041, removeId, -1 );
2487 createMenu( 4042, removeId, -1 );
2489 createMenu( 4051, renumId, -1 );
2490 createMenu( 4052, renumId, -1 );
2492 createMenu( 4061, transfId, -1 );
2493 createMenu( 4062, transfId, -1 );
2494 createMenu( 4063, transfId, -1 );
2495 createMenu( 4064, transfId, -1 );
2496 createMenu( 4065, transfId, -1 );
2497 createMenu( 4066, transfId, -1 );
2499 createMenu( 406, modifyId, -1 );
2500 createMenu( 407, modifyId, -1 );
2501 createMenu( 408, modifyId, -1 );
2502 createMenu( 409, modifyId, -1 );
2503 createMenu( 410, modifyId, -1 );
2504 createMenu( 411, modifyId, -1 );
2505 createMenu( 412, modifyId, -1 );
2506 createMenu( 413, modifyId, -1 );
2507 createMenu( 416, modifyId, -1 );
2508 createMenu( 414, modifyId, -1 );
2509 createMenu( 415, modifyId, -1 );
2510 createMenu( 417, modifyId, -1 );
2512 createMenu( 214, viewId, -1 );
2514 // ----- create toolbars --------------
2515 int meshTb = createTool( tr( "TB_MESH" ) ),
2516 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2517 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2518 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2519 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2521 createTool( 702, meshTb );
2522 createTool( 703, meshTb );
2523 createTool( 704, meshTb );
2524 createTool( separator(), meshTb );
2525 createTool( 701, meshTb );
2526 createTool( separator(), meshTb );
2527 createTool( 801, meshTb );
2528 createTool( 802, meshTb );
2529 createTool( 803, meshTb );
2530 createTool( separator(), meshTb );
2531 createTool( 900, meshTb );
2532 createTool( 902, meshTb );
2533 createTool( separator(), meshTb );
2535 createTool( 6001, ctrlTb );
2536 createTool( 6003, ctrlTb );
2537 createTool( 6004, ctrlTb );
2538 createTool( separator(), ctrlTb );
2539 createTool( 6002, ctrlTb );
2540 createTool( 6018, ctrlTb );
2541 createTool( 6019, ctrlTb );
2542 createTool( 6011, ctrlTb );
2543 createTool( 6012, ctrlTb );
2544 createTool( 6013, ctrlTb );
2545 createTool( 6014, ctrlTb );
2546 createTool( 6015, ctrlTb );
2547 createTool( 6016, ctrlTb );
2548 createTool( separator(), ctrlTb );
2549 createTool( 6017, ctrlTb );
2550 createTool( 6009, ctrlTb );
2551 createTool( separator(), ctrlTb );
2553 createTool( 400, addRemTb );
2554 createTool( 401, addRemTb );
2555 createTool( 4021, addRemTb );
2556 createTool( 4022, addRemTb );
2557 createTool( 4023, addRemTb );
2558 createTool( 4031, addRemTb );
2559 createTool( 4032, addRemTb );
2560 createTool( 4033, addRemTb );
2561 createTool( separator(), addRemTb );
2562 createTool( 4034, addRemTb );
2563 createTool( 4035, addRemTb );
2564 createTool( 4036, addRemTb );
2565 createTool( 4037, addRemTb );
2566 createTool( 4038, addRemTb );
2567 createTool( 4039, addRemTb );
2568 createTool( 4040, addRemTb );
2569 createTool( separator(), addRemTb );
2570 createTool( 4041, addRemTb );
2571 createTool( 4042, addRemTb );
2572 createTool( separator(), addRemTb );
2573 createTool( 4051, addRemTb );
2574 createTool( 4052, addRemTb );
2575 createTool( separator(), addRemTb );
2576 createTool( 4061, addRemTb );
2577 createTool( 4062, addRemTb );
2578 createTool( 4063, addRemTb );
2579 createTool( 4064, addRemTb );
2580 createTool( 4065, addRemTb );
2581 createTool( 4066, addRemTb );
2582 createTool( separator(), addRemTb );
2584 createTool( 406, modifyTb );
2585 createTool( 407, modifyTb );
2586 createTool( 408, modifyTb );
2587 createTool( 409, modifyTb );
2588 createTool( 410, modifyTb );
2589 createTool( 411, modifyTb );
2590 createTool( 412, modifyTb );
2591 createTool( 413, modifyTb );
2592 createTool( 416, modifyTb );
2593 createTool( 414, modifyTb );
2594 createTool( 415, modifyTb );
2595 createTool( 417, modifyTb );
2597 createTool( 214, dispModeTb );
2601 QString OB = "'ObjectBrowser'",
2602 View = "'" + SVTK_Viewer::Type() + "'",
2604 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2605 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2606 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2607 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2608 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2609 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2610 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2611 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2612 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2613 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2614 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2616 mesh_group = mesh + " " + subMesh + " " + group,
2617 hyp_alg = hypo + " " + algo;
2619 // popup for object browser
2621 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2622 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2623 createPopupItem( 803, OB, group ); // EDIT_GROUP
2624 popupMgr()->insert( separator(), -1, 0 );
2625 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2626 createPopupItem( 214, OB, mesh_group ); // UPDATE
2627 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2628 createPopupItem( 902, OB, mesh ); // STD_INFO
2629 popupMgr()->insert( separator(), -1, 0 );
2630 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2631 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2632 popupMgr()->insert( separator(), -1, 0 );
2633 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2634 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2635 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2636 popupMgr()->insert( separator(), -1, 0 );
2638 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2639 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2640 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2641 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2642 popupMgr()->insert( separator(), -1, 0 );
2645 createPopupItem( 803, View, group ); // EDIT_GROUP
2646 createPopupItem( 804, View, elems ); // ADD
2647 createPopupItem( 805, View, elems ); // REMOVE
2648 popupMgr()->insert( separator(), -1, 0 );
2649 createPopupItem( 214, View, mesh_group ); // UPDATE
2650 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2651 createPopupItem( 902, View, mesh ); // STD_INFO
2652 popupMgr()->insert( separator(), -1, 0 );
2656 isInvisible("not( isVisible )"),
2657 isEmpty("numberOfNodes = 0"),
2658 isNotEmpty("numberOfNodes <> 0"),
2660 // has nodes, edges, etc in VISIBLE! actor
2661 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2662 hasElems("(count( elemTypes ) > 0)"),
2663 hasDifferentElems("(count( elemTypes ) > 1)"),
2664 hasEdges("({'Edge'} in elemTypes)"),
2665 hasFaces("({'Face'} in elemTypes)"),
2666 hasVolumes("({'Volume'} in elemTypes)");
2668 QString lc = QtxPopupMgr::Selection::defEquality();
2669 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2670 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2671 aType = aType.arg( mesh_group );
2672 QString aMeshInVTK = aClient + "&&" + aType;
2674 //-------------------------------------------------
2676 //-------------------------------------------------
2677 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2679 popupMgr()->insert( action( 9010 ), anId, -1 );
2680 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2681 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2683 popupMgr()->insert( action( 9011 ), anId, -1 );
2684 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2685 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2687 popupMgr()->insert( separator(), -1, -1 );
2689 //-------------------------------------------------
2691 //-------------------------------------------------
2692 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2694 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2695 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2696 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2698 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2699 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2700 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2702 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2703 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2704 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2706 popupMgr()->insert( separator(), anId, -1 );
2708 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2709 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2710 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2712 //-------------------------------------------------
2714 //-------------------------------------------------
2715 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2717 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2719 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2720 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2721 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2723 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2724 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2725 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2727 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2728 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2729 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2731 popupMgr()->insert( separator(), anId, -1 );
2733 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2734 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2736 //-------------------------------------------------
2738 //-------------------------------------------------
2739 popupMgr()->insert( action( 1132 ), -1, -1 );
2740 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2742 //-------------------------------------------------
2744 //-------------------------------------------------
2745 popupMgr()->insert( action( 1133 ), -1, -1 );
2746 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2748 //-------------------------------------------------
2750 //-------------------------------------------------
2751 popupMgr()->insert( action( 1134 ), -1, -1 );
2752 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2754 popupMgr()->insert( separator(), -1, -1 );
2756 //-------------------------------------------------
2758 //-------------------------------------------------
2760 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2761 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2762 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2764 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2766 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2767 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2769 popupMgr()->insert( separator(), anId, -1 );
2771 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2772 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2773 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2775 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2776 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2777 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2779 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2780 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2781 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2783 popupMgr()->insert( separator(), anId, -1 );
2785 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2786 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2787 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2789 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2790 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2791 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2793 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2794 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2795 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2797 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2798 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2799 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2801 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2802 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2803 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2805 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2806 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2807 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2809 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2810 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2811 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2813 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2814 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2815 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2817 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2818 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2819 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2821 popupMgr()->insert( separator(), anId, -1 );
2823 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2824 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2825 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2827 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2828 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2829 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2831 popupMgr()->insert( separator(), anId, -1 );
2833 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2834 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2836 popupMgr()->insert( separator(), -1, -1 );
2838 //-------------------------------------------------
2840 //-------------------------------------------------
2841 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2842 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2843 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2845 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2846 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2847 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2848 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2850 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2851 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2853 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2854 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2856 popupMgr()->insert( separator(), -1, -1 );
2858 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2859 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2862 bool SMESHGUI::activateModule( SUIT_Study* study )
2864 bool res = SalomeApp_Module::activateModule( study );
2866 setMenuShown( true );
2867 setToolShown( true );
2872 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2874 setMenuShown( false );
2875 setToolShown( false );
2877 EmitSignalCloseAllDialogs();
2879 return SalomeApp_Module::deactivateModule( study );
2882 void SMESHGUI::OnGUIEvent()
2884 const QObject* obj = sender();
2885 if ( !obj || !obj->inherits( "QAction" ) )
2887 int id = actionId((QAction*)obj);
2892 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2894 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2895 if ( CORBA::is_nil( myComponentSMESH ) )
2897 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2899 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2900 return aGUI.myComponentSMESH;
2903 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2904 return myComponentSMESH;
2907 QString SMESHGUI::engineIOR() const
2909 CORBA::ORB_var anORB = getApp()->orb();
2910 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2914 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2916 SMESHGUI_Selection sel;
2917 sel.init( client, selectionMgr() );
2918 popupMgr()->updatePopup( menu, &sel );
2921 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2923 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2924 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2927 void SMESHGUI::viewManagers( QStringList& list ) const
2929 list.append( SVTK_Viewer::Type() );
2932 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2934 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2935 SMESH::UpdateSelectionProp( this );
2938 void SMESHGUI::createPreferences()
2940 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2942 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2943 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2945 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2946 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2947 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2949 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2950 setPreferenceProperty( precGroup, "columns", 1 );
2952 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2954 setPreferenceProperty( prec, "min", 0 );
2955 setPreferenceProperty( prec, "max", 16 );
2957 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2958 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2960 modes.append( "Wireframe" );
2961 modes.append( "Shading" );
2962 modes.append( "Nodes" );
2963 modes.append( "Shrink" );
2964 QValueList<QVariant> indices;
2965 indices.append( 0 );
2966 indices.append( 1 );
2967 indices.append( 2 );
2968 indices.append( 3 );
2969 setPreferenceProperty( dispmode, "strings", modes );
2970 setPreferenceProperty( dispmode, "indexes", indices );
2972 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2973 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2975 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2976 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2978 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2979 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2981 setPreferenceProperty( nodeSz, "min", 1 );
2982 setPreferenceProperty( nodeSz, "max", 5 );
2984 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2986 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2987 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2988 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2989 addPreference( "", elemGroup, LightApp_Preferences::Space );
2991 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2992 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2994 setPreferenceProperty( elemW, "min", 1 );
2995 setPreferenceProperty( elemW, "max", 5 );
2997 setPreferenceProperty( shrink, "min", 0 );
2998 setPreferenceProperty( shrink, "max", 100 );
3000 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3002 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3004 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3005 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3006 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3008 setPreferenceProperty( selW, "min", 1 );
3009 setPreferenceProperty( selW, "max", 5 );
3011 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3013 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3014 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3016 setPreferenceProperty( preW, "min", 1 );
3017 setPreferenceProperty( preW, "max", 5 );
3019 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3021 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3022 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3024 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3025 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3027 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3028 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3029 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3030 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3033 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3034 fam.append( tr( "SMESH_FONT_COURIER" ) );
3035 fam.append( tr( "SMESH_FONT_TIMES" ) );
3036 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3038 setPreferenceProperty( tfont, "families", fam );
3039 setPreferenceProperty( tfont, "system", false );
3040 setPreferenceProperty( tfont, "widget_flags", wflag );
3041 setPreferenceProperty( lfont, "families", fam );
3042 setPreferenceProperty( lfont, "system", false );
3043 setPreferenceProperty( lfont, "widget_flags", wflag );
3045 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3047 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3048 setPreferenceProperty( numcol, "min", 2 );
3049 setPreferenceProperty( numcol, "max", 256 );
3051 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3052 setPreferenceProperty( numlab, "min", 2 );
3053 setPreferenceProperty( numlab, "max", 65 );
3055 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3056 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3057 QStringList orients;
3058 orients.append( tr( "SMESH_VERTICAL" ) );
3059 orients.append( tr( "SMESH_HORIZONTAL" ) );
3060 indices.clear(); indices.append( 0 ); indices.append( 1 );
3061 setPreferenceProperty( orient, "strings", orients );
3062 setPreferenceProperty( orient, "indexes", indices );
3064 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3065 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3066 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3067 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3068 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3069 setPreferenceProperty( xv, "step", 0.1 );
3070 setPreferenceProperty( xv, "min", 0.0 );
3071 setPreferenceProperty( xv, "max", 1.0 );
3072 setPreferenceProperty( yv, "step", 0.1 );
3073 setPreferenceProperty( yv, "min", 0.0 );
3074 setPreferenceProperty( yv, "max", 1.0 );
3075 setPreferenceProperty( wv, "step", 0.1 );
3076 setPreferenceProperty( wv, "min", 0.0 );
3077 setPreferenceProperty( wv, "max", 1.0 );
3078 setPreferenceProperty( hv, "min", 0.0 );
3079 setPreferenceProperty( hv, "max", 1.0 );
3080 setPreferenceProperty( hv, "step", 0.1 );
3082 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3083 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3084 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3085 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3086 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3087 setPreferenceProperty( xv, "min", 0.0 );
3088 setPreferenceProperty( xv, "max", 1.0 );
3089 setPreferenceProperty( xv, "step", 0.1 );
3090 setPreferenceProperty( xh, "min", 0.0 );
3091 setPreferenceProperty( xh, "max", 1.0 );
3092 setPreferenceProperty( xh, "step", 0.1 );
3093 setPreferenceProperty( yh, "min", 0.0 );
3094 setPreferenceProperty( yh, "max", 1.0 );
3095 setPreferenceProperty( yh, "step", 0.1 );
3096 setPreferenceProperty( wh, "min", 0.0 );
3097 setPreferenceProperty( wh, "max", 1.0 );
3098 setPreferenceProperty( wh, "step", 0.1 );
3099 setPreferenceProperty( hh, "min", 0.0 );
3100 setPreferenceProperty( hh, "max", 1.0 );
3101 setPreferenceProperty( hh, "step", 0.1 );
3104 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3106 if( sect=="SMESH" ){
3107 float sbX1,sbY1,sbW,sbH;
3108 float aTol = 1.00000009999999;
3109 std::string aWarning;
3110 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3111 if( name=="selection_object_color" || name=="selection_element_color" ||
3112 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3113 name=="selection_precision_node" || name=="selection_precision_element" )
3114 SMESH::UpdateSelectionProp( this );
3115 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3116 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3117 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3118 if(sbX1+sbW > aTol){
3119 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3122 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3123 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3126 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3127 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3128 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3129 if(sbY1+sbH > aTol){
3130 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3133 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3134 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3137 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3138 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3139 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3140 if(sbX1+sbW > aTol){
3141 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3144 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3145 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3148 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3149 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3150 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3151 if(sbY1+sbH > aTol){
3152 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3155 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3156 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3160 if(aWarning.size() != 0){
3161 aWarning += "The default values are applied instead.";
3162 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3163 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3164 QObject::tr(aWarning.c_str()),
3165 QObject::tr("SMESH_BUT_OK"));
3170 //================================================================================
3172 * \brief Update something in accordance with update flags
3173 * \param theFlags - update flags
3175 * Update viewer or/and object browser etc. in accordance with update flags ( see
3176 * LightApp_UpdateFlags enumeration ).
3178 //================================================================================
3179 void SMESHGUI::update( const int flags )
3181 if ( flags & UF_Viewer | flags & UF_Forced )
3182 SMESH::UpdateView();
3184 SalomeApp_Module::update( flags );
3187 //================================================================================
3189 * \brief Set default selection mode
3191 * SLOT called when operation commited. Sets default selection mode
3193 //================================================================================
3194 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3196 SVTK_ViewWindow* vtkWnd =
3197 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3199 vtkWnd->SetSelectionMode( ActorSelection );
3202 //================================================================================
3204 * \brief Set default selection mode
3206 * SLOT called when operation aborted. Sets default selection mode
3208 //================================================================================
3209 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3211 SVTK_ViewWindow* vtkWnd =
3212 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3214 vtkWnd->SetSelectionMode( ActorSelection );
3217 //================================================================================
3219 * \brief Creates operation with given identifier
3220 * \param id - identifier of operation to be started
3221 * \return Pointer on created operation or NULL if operation is not created
3223 * Virtual method redefined from the base class creates operation with given id.
3224 * It is called called automatically from startOperation method of base class.
3226 //================================================================================
3227 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3229 LightApp_Operation* op = 0;
3230 // to do : create operation here
3233 case 702: // Create mesh
3234 op = new SMESHGUI_MeshOp( true, true );
3236 case 703: // Create sub-mesh
3237 op = new SMESHGUI_MeshOp( true, false );
3239 case 704: // Edit mesh/sub-mesh
3240 op = new SMESHGUI_MeshOp( false );
3242 case 417: //convert to quadratic
3243 op = new SMESHGUI_ConvToQuadOp();
3250 op = SalomeApp_Module::createOperation( id );
3254 //================================================================================
3256 * \brief Stops current operations and starts a given one
3257 * \param id - The id of the operation to start
3259 //================================================================================
3261 void SMESHGUI::switchToOperation(int id)
3263 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3264 activeStudy()->abortAllOperations();
3265 startOperation( id );
3268 LightApp_Displayer* SMESHGUI::displayer()
3271 myDisplayer = new SMESHGUI_Displayer( getApp() );