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_MeshOp.h"
66 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_Utils.h"
69 #include "SMESHGUI_GEOMGenUtils.h"
70 #include "SMESHGUI_MeshUtils.h"
71 #include "SMESHGUI_GroupUtils.h"
72 #include "SMESHGUI_FilterUtils.h"
73 #include "SMESHGUI_PatternUtils.h"
74 #include "SMESHGUI_VTKUtils.h"
75 #include "SMESHGUI_HypothesesUtils.h"
77 #include "SMESH_Actor.h"
78 #include "SMESH_Object.h"
79 #include "SMESH_TypeFilter.hxx"
81 #include "SalomeApp_Tools.h"
82 #include "SalomeApp_Study.h"
83 #include "SalomeApp_Application.h"
84 #include "SalomeApp_CheckFileDlg.h"
85 #include "SalomeApp_ImportOperation.h"
87 #include "LightApp_DataOwner.h"
88 #include "LightApp_Preferences.h"
89 #include "LightApp_VTKSelector.h"
90 #include "LightApp_Operation.h"
91 #include "LightApp_UpdateFlags.h"
92 #include "LightApp_NameDlg.h"
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_InteractorStyle.h>
97 #include <SVTK_RenderWindowInteractor.h>
98 #include <SVTK_ViewManager.h>
100 #include "OB_Browser.h"
102 #include "SUIT_Tools.h"
103 #include "SUIT_MessageBox.h"
104 #include "SUIT_ResourceMgr.h"
105 #include "SUIT_FileDlg.h"
106 #include "SUIT_Desktop.h"
107 #include "SUIT_OverrideCursor.h"
108 #include "SUIT_Study.h"
109 #include "SUIT_Session.h"
111 #include "QtxPopupMgr.h"
113 #include "SALOME_ListIO.hxx"
114 #include "SALOME_ListIteratorOfListIO.hxx"
115 #include "SALOME_InteractiveObject.hxx"
116 #include "SALOME_NamingService.hxx"
117 #include "SALOME_LifeCycleCORBA.hxx"
119 #include "SALOMEconfig.h"
120 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #define INCLUDE_MENUITEM_DEF
124 #include <qpopupmenu.h>
130 #include <boost/shared_ptr.hpp>
133 #include <vtkRenderer.h>
134 #include <vtkRenderWindow.h>
135 #include <vtkActorCollection.h>
136 #include <vtkScalarBarActor.h>
137 #include <vtkUnstructuredGrid.h>
139 #include "utilities.h"
141 #include "SALOMEDS_Study.hxx"
142 #include "SALOMEDSClient_StudyBuilder.hxx"
143 #include "SALOMEDSClient_SComponent.hxx"
149 //=============================================================
150 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
153 void ExportMeshToFile(int theCommandID);
155 void SetDisplayMode(int theCommandID);
157 void SetDisplayEntity(int theCommandID);
159 void Control( int theCommandID );
163 //=============================================================
164 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
170 if(theCommandID == 113){
171 filter.append(QObject::tr("MED files (*.med)"));
172 filter.append(QObject::tr("All files (*)"));
173 }else if (theCommandID == 112){
174 filter.append(QObject::tr("IDEAS files (*.unv)"));
175 }else if (theCommandID == 111){
176 filter.append(QObject::tr("DAT files (*.dat)"));
178 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
181 QObject::tr("Import mesh"),
183 if(!filename.isEmpty()) {
184 SUIT_OverrideCursor wc;
185 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
188 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
189 switch ( theCommandID ) {
192 aMeshes->length( 1 );
193 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
198 SMESH::DriverMED_ReadStatus res;
199 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
200 if ( res != SMESH::DRS_OK ) {
202 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
203 QObject::tr("SMESH_WRN_WARNING"),
204 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
205 QObject::tr("SMESH_BUT_OK"));
206 aMeshes->length( 0 );
213 bool isEmpty = false;
214 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
215 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
217 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
218 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
219 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
220 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
221 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
228 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
229 QObject::tr("SMESH_WRN_WARNING"),
230 QObject::tr("SMESH_DRS_EMPTY"),
231 QObject::tr("SMESH_BUT_OK"));
235 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
237 catch (const SALOME::SALOME_Exception& S_ex){
239 SalomeApp_Tools::QtCatchCorbaException(S_ex);
246 void ExportMeshToFile( int theCommandID )
248 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
249 SALOME_ListIO selected;
251 aSel->selectedObjects( selected );
253 if(selected.Extent()){
254 Handle(SALOME_InteractiveObject) anIObject = selected.First();
255 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
256 if ( !aMesh->_is_nil() ) {
257 QString aFilter, aTitle = QObject::tr("Export mesh");
258 QMap<QString, SMESH::MED_VERSION> aFilterMap;
259 switch ( theCommandID ) {
263 if (aMesh->HasDuplicatedGroupNamesMED()) {
264 int aRet = SUIT_MessageBox::warn2
265 (SMESHGUI::desktop(),
266 QObject::tr("SMESH_WRN_WARNING"),
267 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
268 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
274 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
275 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
280 aFilter = QObject::tr("DAT files (*.dat)");
285 if (aMesh->NbPyramids()) {
286 int aRet = SUIT_MessageBox::warn2
287 (SMESHGUI::desktop(),
288 QObject::tr("SMESH_WRN_WARNING"),
289 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
290 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
295 aFilter = QObject::tr("IDEAS files (*.unv)");
303 SMESH::MED_VERSION aFormat;
304 // Init the parameter with the default value
305 bool toCreateGroups = false;
306 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
308 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
310 if ( theCommandID != 122 && theCommandID != 125 )
311 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
314 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
315 for ( ; it != aFilterMap.end(); ++it )
316 filters.push_back( it.key() );
318 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
319 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
320 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
321 fd->setCaption( aTitle );
322 fd->setFilters( filters );
323 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
324 fd->SetChecked(toCreateGroups);
328 aFilename = fd->selectedFile();
329 aFormat = aFilterMap[fd->selectedFilter()];
331 if ( !aFilename.isEmpty()
332 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
333 && aFormat==SMESH::MED_V2_1) {
334 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
335 QObject::tr("SMESH_WRN_WARNING"),
336 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
337 QObject::tr("SMESH_BUT_YES"),
338 QObject::tr("SMESH_BUT_NO"),
345 toCreateGroups = fd->IsChecked();
348 if ( !aFilename.isEmpty() ) {
349 // Check whether the file already exists and delete it if yes
350 QFile aFile( aFilename );
351 if ( aFile.exists() )
353 SUIT_OverrideCursor wc;
354 switch ( theCommandID ) {
357 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
361 aMesh->ExportDAT( aFilename.latin1() );
365 aMesh->ExportUNV( aFilename.latin1() );
375 inline void InverseEntityMode(unsigned int& theOutputMode,
376 unsigned int theMode)
378 bool anIsNotPresent = ~theOutputMode & theMode;
380 theOutputMode |= theMode;
382 theOutputMode &= ~theMode;
385 void SetDisplayEntity(int theCommandID){
386 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
387 SALOME_ListIO selected;
389 aSel->selectedObjects( selected );
391 if(selected.Extent() >= 1){
392 SALOME_ListIteratorOfListIO It( selected );
393 for(; It.More(); It.Next()){
394 Handle(SALOME_InteractiveObject) IObject = It.Value();
395 if(IObject->hasEntry()){
396 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
397 unsigned int aMode = anActor->GetEntityMode();
398 switch(theCommandID){
400 InverseEntityMode(aMode,SMESH_Actor::eEdges);
403 InverseEntityMode(aMode,SMESH_Actor::eFaces);
406 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
409 aMode = SMESH_Actor::eAllEntity;
413 anActor->SetEntityMode(aMode);
420 void SetDisplayMode(int theCommandID){
421 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
422 SALOME_ListIO selected;
424 aSel->selectedObjects( selected );
426 if(selected.Extent() >= 1){
427 switch(theCommandID){
429 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
430 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
434 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
435 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
438 SALOME_ListIteratorOfListIO It( selected );
439 for(; It.More(); It.Next()){
440 Handle(SALOME_InteractiveObject) IObject = It.Value();
441 if(IObject->hasEntry()){
442 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
443 switch(theCommandID){
445 anActor->SetRepresentation(SMESH_Actor::eEdge);
448 anActor->SetRepresentation(SMESH_Actor::eSurface);
451 if(anActor->IsShrunk())
454 anActor->SetShrink();
457 anActor->SetRepresentation(SMESH_Actor::ePoint);
460 vtkFloatingPointType color[3];
461 anActor->GetSufaceColor(color[0], color[1], color[2]);
462 int c0 = int (color[0] * 255);
463 int c1 = int (color[1] * 255);
464 int c2 = int (color[2] * 255);
465 QColor c(c0, c1, c2);
467 vtkFloatingPointType edgecolor[3];
468 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
469 c0 = int (edgecolor[0] * 255);
470 c1 = int (edgecolor[1] * 255);
471 c2 = int (edgecolor[2] * 255);
472 QColor e(c0, c1, c2);
474 vtkFloatingPointType backfacecolor[3];
475 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
476 c0 = int (backfacecolor[0] * 255);
477 c1 = int (backfacecolor[1] * 255);
478 c2 = int (backfacecolor[2] * 255);
479 QColor b(c0, c1, c2);
481 vtkFloatingPointType nodecolor[3];
482 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
483 c0 = int (nodecolor[0] * 255);
484 c1 = int (nodecolor[1] * 255);
485 c2 = int (nodecolor[2] * 255);
486 QColor n(c0, c1, c2);
488 int Edgewidth = (int)anActor->GetLineWidth();
491 int intValue = int(anActor->GetNodeSize());
492 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
494 SMESHGUI_Preferences_ColorDlg *aDlg =
495 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
496 aDlg->SetColor(1, c);
497 aDlg->SetColor(2, e);
498 aDlg->SetColor(3, n);
499 aDlg->SetColor(4, b);
500 aDlg->SetIntValue(1, Edgewidth);
501 aDlg->SetIntValue(2, intValue);
502 aDlg->SetIntValue(3, int(Shrink*100.));
504 QColor color = aDlg->GetColor(1);
505 QColor edgecolor = aDlg->GetColor(2);
506 QColor nodecolor = aDlg->GetColor(3);
507 QColor backfacecolor = aDlg->GetColor(4);
508 /* actor color and backface color */
509 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
510 vtkFloatingPointType (color.green()) / 255.,
511 vtkFloatingPointType (color.blue()) / 255.);
512 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
513 vtkFloatingPointType (backfacecolor.green()) / 255.,
514 vtkFloatingPointType (backfacecolor.blue()) / 255.);
517 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
518 vtkFloatingPointType (edgecolor.green()) / 255.,
519 vtkFloatingPointType (edgecolor.blue()) / 255.);
521 /* Shrink factor and size edges */
522 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
523 anActor->SetLineWidth(aDlg->GetIntValue(1));
525 /* Nodes color and size */
526 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
527 vtkFloatingPointType (nodecolor.green()) / 255.,
528 vtkFloatingPointType (nodecolor.blue()) / 255.);
529 anActor->SetNodeSize(aDlg->GetIntValue(2));
538 SMESH::RepaintCurrentView();
542 void Control( int theCommandID )
544 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
545 SALOME_ListIO selected;
547 aSel->selectedObjects( selected );
549 if( !selected.IsEmpty() ){
550 Handle(SALOME_InteractiveObject) anIO = selected.First();
553 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
554 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
555 switch ( theCommandID ){
557 aTitle = QObject::tr( "LENGTH_EDGES" );
558 aControl = SMESH_Actor::eLength;
561 aTitle = QObject::tr( "LENGTH2D_EDGES" );
562 aControl = SMESH_Actor::eLength2D;
565 aTitle = QObject::tr( "FREE_EDGES" );
566 aControl = SMESH_Actor::eFreeEdges;
569 aTitle = QObject::tr( "FREE_BORDERS" );
570 aControl = SMESH_Actor::eFreeBorders;
573 aTitle = QObject::tr( "MULTI_BORDERS" );
574 aControl = SMESH_Actor::eMultiConnection;
577 aTitle = QObject::tr( "MULTI2D_BORDERS" );
578 aControl = SMESH_Actor::eMultiConnection2D;
581 aTitle = QObject::tr( "AREA_ELEMENTS" );
582 aControl = SMESH_Actor::eArea;
585 aTitle = QObject::tr( "TAPER_ELEMENTS" );
586 aControl = SMESH_Actor::eTaper;
589 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
590 aControl = SMESH_Actor::eAspectRatio;
593 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
594 aControl = SMESH_Actor::eAspectRatio3D;
597 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
598 aControl = SMESH_Actor::eMinimumAngle;
601 aTitle = QObject::tr( "WARP_ELEMENTS" );
602 aControl = SMESH_Actor::eWarping;
605 aTitle = QObject::tr( "SKEW_ELEMENTS" );
606 aControl = SMESH_Actor::eSkew;
609 aTitle = QObject::tr( "SMESH_VOLUME" );
610 aControl = SMESH_Actor::eVolume3D;
613 anActor->SetControlMode(aControl);
614 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
615 SMESH::RepaintCurrentView();
622 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
623 MeshObjectType theType,
624 const QString theInTypeName,
625 QString & theOutTypeName)
627 SMESH_TypeFilter aTypeFilter( theType );
629 if( !theIO.IsNull() )
631 entry = theIO->getEntry();
632 LightApp_DataOwner owner( entry );
633 if ( aTypeFilter.isOk( &owner )) {
634 theOutTypeName = theInTypeName;
642 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
644 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
645 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
647 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
648 CORBA::String_var anID = aSComp->GetID().c_str();
649 if (!strcmp(anID.in(),theIO->getEntry()))
655 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
656 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
657 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
658 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
659 CheckOIType ( theIO, GROUP, "Group", aTypeName )
667 QString CheckHomogeneousSelection()
669 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
670 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
671 SALOME_ListIO selected;
673 aSel->selectedObjects( selected );
675 QString RefType = CheckTypeObject(selected.First());
676 SALOME_ListIteratorOfListIO It(selected);
677 for (; It.More(); It.Next())
679 Handle(SALOME_InteractiveObject) IObject = It.Value();
680 QString Type = CheckTypeObject(IObject);
681 if (Type.compare(RefType) != 0)
682 return "Heterogeneous Selection";
689 void SMESHGUI::OnEditDelete()
691 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
692 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
693 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
695 QString aParentComponent = QString::null;
696 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
698 QString cur = anIt.Value()->getComponentDataType();
699 if( aParentComponent.isNull() )
700 aParentComponent = cur;
701 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
702 aParentComponent = "";
705 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
706 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
707 QObject::tr("ERR_ERROR"),
708 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
709 QObject::tr("BUT_OK") );
712 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
713 if (SUIT_MessageBox::warn2
714 (SMESHGUI::desktop(),
715 QObject::tr("SMESH_WRN_WARNING"),
716 QObject::tr("SMESH_REALLY_DELETE"),
717 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
720 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
721 SUIT_ViewManager* vm = anApp->activeViewManager();
722 int nbSf = vm->getViewsCount();
724 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
725 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
726 _PTR(GenericAttribute) anAttr;
727 _PTR(AttributeIOR) anIOR;
729 SALOME_ListIteratorOfListIO It(selected);
731 aStudyBuilder->NewCommand(); // There is a transaction
732 for(; It.More(); It.Next()){
733 Handle(SALOME_InteractiveObject) IObject = It.Value();
734 if(IObject->hasEntry()){
735 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
737 // disable removal of "SMESH" component object
738 if(SO->FindAttribute(anAttr, "AttributeIOR")){
740 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
744 /* Erase child graphical objects */
745 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
746 for(it->InitEx(true); it->More(); it->Next()){
747 _PTR(SObject) CSO = it->Value();
748 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
751 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
752 for(int i = 0; i < nbSf; i++){
753 SUIT_ViewWindow *sf = aViews[i];
754 CORBA::String_var anEntry = CSO->GetID().c_str();
755 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
756 SMESH::RemoveActor(sf,anActor);
762 /* Erase main graphical object */
763 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
764 for(int i = 0; i < nbSf; i++){
765 SUIT_ViewWindow *sf = aViews[i];
766 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
767 SMESH::RemoveActor(sf,anActor);
771 // Remove object(s) from data structures
772 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
774 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
775 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
776 QString objType = CheckTypeObject(IObject);
777 if ( !aGroup->_is_nil() ) { // DELETE GROUP
778 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
779 aMesh->RemoveGroup( aGroup );
781 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
782 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
783 aMesh->RemoveSubMesh( aSubMesh );
785 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
787 SMESH::ModifiedMesh(aMeshSO, false);
789 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
790 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
791 aStudyBuilder->RemoveObjectWithChildren( obj );
793 else {// default action: remove SObject from the study
794 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
795 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
797 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_nil();
799 _PTR(ChildIterator) it = aStudy->NewChildIterator(obj);
801 _PTR(SObject) CSO = it->Value();
802 aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( CSO ) );
803 if ( !aSubMesh->_is_nil() )
805 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
806 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
808 SMESH::ModifiedMesh(aMeshSO, false);
811 aStudyBuilder->RemoveObjectWithChildren( obj );
816 } /* IObject->hasEntry() */
818 aStudyBuilder->CommitCommand();
820 /* Clear any previous selection */
822 aSel->setSelectedObjects( l1 );
824 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
829 Standard_EXPORT CAM_Module* createModule()
831 return new SMESHGUI();
835 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
837 //=============================================================================
841 //=============================================================================
842 SMESHGUI::SMESHGUI() :
843 SalomeApp_Module( "SMESH" )
845 if ( CORBA::is_nil( myComponentSMESH ) )
847 CORBA::Boolean anIsEmbeddedMode;
848 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
851 myActiveDialogBox = 0;
852 myFilterLibraryDlg = 0;
856 SMESH::GetFilterManager();
859 /* load resources for all available meshers */
860 SMESH::InitAvailableHypotheses();
863 //=============================================================================
867 //=============================================================================
868 SMESHGUI::~SMESHGUI()
870 SMESH::GetFilterManager()->Destroy();
871 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
874 //=============================================================================
878 //=============================================================================
879 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
881 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
883 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
888 bool SMESHGUI::automaticUpdate()
890 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
894 return resMgr->booleanValue( "SMESH", "auto_update", false );
897 //=============================================================================
901 //=============================================================================
902 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
904 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
907 //=============================================================================
911 //=============================================================================
912 SMESHGUI* SMESHGUI::GetSMESHGUI()
914 SMESHGUI* smeshMod = 0;
915 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
918 CAM_Module* module = app->module( "Mesh" );
919 smeshMod = dynamic_cast<SMESHGUI*>( module );
922 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
924 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
927 _PTR(Study) aStudy = study->studyDS();
929 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
938 Standard_EXPORT SMESHGUI* GetComponentGUI()
940 return SMESHGUI::GetSMESHGUI();
944 //=============================================================================
948 //=============================================================================
949 void SMESHGUI::SetState(int aState)
954 //=============================================================================
958 //=============================================================================
959 void SMESHGUI::ResetState()
964 //=============================================================================
968 //=============================================================================
969 void SMESHGUI::EmitSignalDeactivateDialog()
971 emit SignalDeactivateActiveDialog();
974 //=============================================================================
978 //=============================================================================
979 void SMESHGUI::EmitSignalStudyFrameChanged()
981 emit SignalStudyFrameChanged();
984 //=============================================================================
988 //=============================================================================
989 void SMESHGUI::EmitSignalCloseAllDialogs()
991 emit SignalCloseAllDialogs();
994 //=============================================================================
998 //=============================================================================
999 QDialog *SMESHGUI::GetActiveDialogBox()
1001 return myActiveDialogBox;
1004 //=============================================================================
1008 //=============================================================================
1009 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1011 myActiveDialogBox = (QDialog *) aDlg;
1015 //=============================================================================
1019 //=============================================================================
1020 SUIT_Desktop* SMESHGUI::desktop()
1022 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1024 return app->desktop();
1029 //=============================================================================
1033 //=============================================================================
1034 SalomeApp_Study* SMESHGUI::activeStudy()
1036 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1038 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1043 //=============================================================================
1047 //=============================================================================
1048 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1050 /* Here the position is on the bottom right corner - 10 */
1051 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1053 SUIT_Desktop *PP = desktop();
1054 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1055 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1059 //=============================================================================
1063 //=============================================================================
1064 static int isStudyLocked(_PTR(Study) theStudy){
1065 return theStudy->GetProperties()->IsLocked();
1068 static bool checkLock(_PTR(Study) theStudy) {
1069 if (isStudyLocked(theStudy)) {
1070 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1071 QObject::tr("WRN_WARNING"),
1072 QObject::tr("WRN_STUDY_LOCKED"),
1073 QObject::tr("BUT_OK") );
1079 //=======================================================================
1080 //function : CheckActiveStudyLocked
1082 //=======================================================================
1084 bool SMESHGUI::isActiveStudyLocked()
1086 _PTR(Study) aStudy = activeStudy()->studyDS();
1087 return checkLock( aStudy );
1090 //=============================================================================
1094 //=============================================================================
1095 bool SMESHGUI::OnGUIEvent( int theCommandID )
1097 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1101 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1102 SUIT_ResourceMgr* mgr = resourceMgr();
1106 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1107 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1110 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1111 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1113 //QAction* act = action( theCommandID );
1115 switch (theCommandID) {
1117 if(checkLock(aStudy)) break;
1125 if(checkLock(aStudy)) break;
1126 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1130 case 122: // EXPORT MED
1137 ::ExportMeshToFile(theCommandID);
1141 case 200: // SCALAR BAR
1143 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1144 SALOME_ListIO selected;
1146 aSel->selectedObjects( selected );
1148 if( selected.Extent() ) {
1149 Handle(SALOME_InteractiveObject) anIO = selected.First();
1150 if( anIO->hasEntry() ) {
1151 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1152 anActor->SetControlMode( SMESH_Actor::eNone );
1160 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1164 case 1134: // Clipping
1165 case 1133: // Tranparency
1166 case 1132: // Colors / Size
1173 ::SetDisplayMode(theCommandID);
1179 case 219: // Volumes
1180 case 220: // All Entity
1181 ::SetDisplayEntity(theCommandID);
1186 if(checkLock(aStudy)) break;
1187 SMESH::UpdateView();
1190 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1191 aSel->selectedObjects( l );
1192 aSel->setSelectedObjects( l );
1197 case 301: // DISPLAY
1198 case 302: // DISPLAY ONLY
1200 SMESH::EDisplaing anAction;
1201 switch (theCommandID) {
1202 case 300: anAction = SMESH::eErase; break;
1203 case 301: anAction = SMESH::eDisplay; break;
1204 case 302: anAction = SMESH::eDisplayOnly; break;
1207 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1208 SALOME_ListIO sel_objects, to_process;
1210 aSel->selectedObjects( sel_objects );
1212 if( theCommandID==302 )
1213 startOperation( myEraseAll );
1215 extractContainers( sel_objects, to_process );
1218 SALOME_ListIteratorOfListIO It( to_process );
1219 for (; It.More(); It.Next()) {
1220 Handle(SALOME_InteractiveObject) IOS = It.Value();
1221 if (IOS->hasEntry()) {
1222 SMESH::UpdateView(anAction, IOS->getEntry());
1223 if (anAction == SMESH::eDisplayOnly)
1224 anAction = SMESH::eDisplay;
1229 if (anAction == SMESH::eErase) {
1231 aSel->setSelectedObjects( l1 );
1234 aSel->setSelectedObjects( to_process );
1240 if(checkLock(aStudy)) break;
1243 EmitSignalDeactivateDialog();
1245 new SMESHGUI_NodesDlg(this);
1248 SUIT_MessageBox::warn1(desktop(),
1249 tr("SMESH_WRN_WARNING"),
1250 tr("SMESH_WRN_VIEWER_VTK"),
1251 tr("SMESH_BUT_OK"));
1256 case 2151: // FILTER
1260 EmitSignalDeactivateDialog();
1261 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1266 case 406: // MOVE NODE
1270 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1271 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1275 if(checkLock(aStudy)) break;
1276 new SMESHGUI_MoveNodesDlg(this);
1280 case 701: // COMPUTE MESH
1282 if(checkLock(aStudy)) break;
1284 LightApp_SelectionMgr *Sel = selectionMgr();
1285 SALOME_ListIO selected; Sel->selectedObjects( selected );
1288 int nbSel = selected.Extent();
1293 SMESH::SMESH_Mesh_var aMesh;
1294 SMESH::SMESH_subMesh_var aSubMesh;
1295 Handle(SALOME_InteractiveObject) IObject = selected.First();
1296 if (IObject->hasEntry()) {
1297 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1298 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1299 if ( aShapeObject->_is_nil() ) {
1304 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1305 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1306 if ( !aSubMesh->_is_nil() )
1307 aMesh = aSubMesh->GetFather();
1309 if (!aMesh->_is_nil()) {
1310 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1311 // SUIT_MessageBox::warn1(desktop(),
1312 // tr("SMESH_WRN_WARNING"),
1313 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1314 // tr("SMESH_BUT_OK"));
1317 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1318 if ( errors->length() > 0 ) {
1319 SUIT_MessageBox::warn1(desktop(),
1320 tr("SMESH_WRN_WARNING"),
1321 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1322 tr("SMESH_BUT_OK"));
1326 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1327 SMESH::ModifiedMesh(aMeshSObj,true);
1329 SUIT_MessageBox::warn1(desktop(),
1330 tr("SMESH_WRN_WARNING"),
1331 tr("SMESH_WRN_COMPUTE_FAILED"),
1332 tr("SMESH_BUT_OK"));
1334 catch(const SALOME::SALOME_Exception & S_ex){
1335 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1340 CORBA::Long anId = aStudy->StudyId();
1341 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1342 if ( automaticUpdate() && aVisualObj){
1343 aVisualObj->Update();
1344 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1346 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1348 SMESH::DisplayActor(view,anActor); //apo
1352 SMESH::RepaintCurrentView();
1355 SUIT_MessageBox::warn1(desktop(),
1356 tr("SMESH_WRN_WARNING"),
1357 tr("SMESH_WRN_VIEWER_VTK"),
1358 tr("SMESH_BUT_OK"));
1361 Sel->setSelectedObjects( selected );
1365 case 702: // Create mesh
1366 startOperation( 702 );
1368 case 703: // Create sub-mesh
1369 startOperation( 703 );
1371 case 704: // Edit mesh/sub-mesh
1372 startOperation( 704 );
1374 case 407: // DIAGONAL INVERSION
1375 case 408: // Delete diagonal
1379 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1380 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1384 if ( checkLock( aStudy ) )
1387 /*Standard_Boolean aRes;
1388 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1389 if ( aMesh->_is_nil() )
1391 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1392 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1396 EmitSignalDeactivateDialog();
1397 if ( theCommandID == 407 )
1398 new SMESHGUI_TrianglesInversionDlg(this);
1400 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1403 case 409: // Change orientation
1404 case 410: // Union of triangles
1405 case 411: // Cutting of quadrangles
1409 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1410 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1414 if ( checkLock( aStudy ) )
1417 EmitSignalDeactivateDialog();
1418 SMESHGUI_MultiEditDlg* aDlg = NULL;
1419 if ( theCommandID == 409 )
1420 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1421 else if ( theCommandID == 410 )
1422 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1424 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1429 case 412: // Smoothing
1431 if(checkLock(aStudy)) break;
1433 EmitSignalDeactivateDialog();
1434 new SMESHGUI_SmoothingDlg( this );
1437 SUIT_MessageBox::warn1(desktop(),
1438 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1439 tr("SMESH_BUT_OK"));
1443 case 413: // Extrusion
1445 if (checkLock(aStudy)) break;
1447 EmitSignalDeactivateDialog();
1448 new SMESHGUI_ExtrusionDlg ( this );
1450 SUIT_MessageBox::warn1(desktop(),
1451 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1452 tr("SMESH_BUT_OK"));
1456 case 414: // Revolution
1458 if(checkLock(aStudy)) break;
1460 EmitSignalDeactivateDialog();
1461 new SMESHGUI_RevolutionDlg( this );
1464 SUIT_MessageBox::warn1(desktop(),
1465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1466 tr("SMESH_BUT_OK"));
1470 case 415: // Pattern mapping
1472 if ( checkLock( aStudy ) )
1476 EmitSignalDeactivateDialog();
1477 new SMESHGUI_MeshPatternDlg( this );
1480 SUIT_MessageBox::warn1(desktop(),
1481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1482 tr("SMESH_BUT_OK"));
1486 case 416: // Extrusion along a path
1488 if (checkLock(aStudy)) break;
1490 EmitSignalDeactivateDialog();
1491 new SMESHGUI_ExtrusionAlongPathDlg( this );
1493 SUIT_MessageBox::warn1(desktop(),
1494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1495 tr("SMESH_BUT_OK"));
1499 case 801: // CREATE GROUP
1503 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1504 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1508 if(checkLock(aStudy)) break;
1509 EmitSignalDeactivateDialog();
1510 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1512 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1513 SALOME_ListIO selected;
1515 aSel->selectedObjects( selected );
1517 int nbSel = selected.Extent();
1519 // check if mesh is selected
1520 aMesh = SMESH::GetMeshByIO( selected.First() );
1522 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1527 case 802: // CONSTRUCT GROUP
1531 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1532 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1536 if(checkLock(aStudy)) break;
1537 EmitSignalDeactivateDialog();
1539 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1540 SALOME_ListIO selected;
1542 aSel->selectedObjects( selected );
1544 int nbSel = selected.Extent();
1546 // check if submesh is selected
1547 Handle(SALOME_InteractiveObject) IObject = selected.First();
1548 if (IObject->hasEntry()) {
1549 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1551 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1552 if (!aSubMesh->_is_nil()) {
1554 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1555 // get submesh elements list by types
1556 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1557 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1558 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1559 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1560 // create group for each type o elements
1561 QString aName = IObject->getName();
1562 if (aNodes->length() > 0) {
1563 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1564 aGroup->Add(aNodes.inout());
1566 if (aEdges->length() > 0) {
1567 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1568 aGroup->Add(aEdges.inout());
1570 if (aFaces->length() > 0) {
1571 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1572 aGroup->Add(aFaces.inout());
1574 if (aVolumes->length() > 0) {
1575 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1576 aGroup->Add(aVolumes.inout());
1580 }catch(const SALOME::SALOME_Exception & S_ex){
1581 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1590 case 803: // EDIT GROUP
1594 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1595 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1599 if(checkLock(aStudy)) break;
1600 EmitSignalDeactivateDialog();
1602 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1603 SALOME_ListIO selected;
1605 aSel->selectedObjects( selected );
1607 SALOME_ListIteratorOfListIO It (selected);
1608 int nbSelectedGroups = 0;
1609 for ( ; It.More(); It.Next() )
1611 SMESH::SMESH_GroupBase_var aGroup =
1612 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1613 if (!aGroup->_is_nil()) {
1615 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1619 if (nbSelectedGroups == 0)
1621 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1627 case 804: // Add elements to group
1629 if(checkLock(aStudy)) break;
1630 if (myState == 800) {
1631 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1632 if (aDlg) aDlg->onAdd();
1637 case 805: // Remove elements from group
1639 if(checkLock(aStudy)) break;
1640 if (myState == 800) {
1641 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1642 if (aDlg) aDlg->onRemove();
1647 case 810: // Union Groups
1648 case 811: // Intersect groups
1649 case 812: // Cut groups
1653 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1654 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1658 if ( checkLock( aStudy ) )
1661 EmitSignalDeactivateDialog();
1664 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1665 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1666 else aMode = SMESHGUI_GroupOpDlg::CUT;
1668 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1672 case 813: // Delete groups with their contents
1676 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1677 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1681 if ( checkLock( aStudy ) )
1684 EmitSignalDeactivateDialog();
1686 new SMESHGUI_DeleteGroupDlg( this );
1690 case 900: // MESH INFOS
1692 EmitSignalDeactivateDialog();
1693 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1694 SALOME_ListIO selected;
1696 aSel->selectedObjects( selected );
1698 if ( selected.Extent() > 1 ) { // a dlg for each IO
1700 SALOME_ListIteratorOfListIO It (selected);
1701 for ( ; It.More(); It.Next() ) {
1702 IOs.Clear(); IOs.Append( It.Value() );
1703 aSel->setSelectedObjects( IOs );
1704 new SMESHGUI_MeshInfosDlg(this, "", false);
1706 // restore selection
1707 aSel->setSelectedObjects( selected );
1710 new SMESHGUI_MeshInfosDlg(this, "", false);
1714 case 902: // STANDARD MESH INFOS
1716 EmitSignalDeactivateDialog();
1717 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1718 SALOME_ListIO selected;
1720 aSel->selectedObjects( selected );
1722 if ( selected.Extent() > 1 ) { // a dlg for each IO
1724 SALOME_ListIteratorOfListIO It (selected);
1725 for ( ; It.More(); It.Next() ) {
1727 IOs.Append( It.Value() );
1728 aSel->setSelectedObjects( IOs );
1729 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1731 // restore selection
1732 aSel->setSelectedObjects( selected );
1735 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1739 case 1100: // EDIT HYPOTHESIS
1741 if(checkLock(aStudy)) break;
1743 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1744 SALOME_ListIO selected;
1746 aSel->selectedObjects( selected );
1748 int nbSel = selected.Extent();
1751 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1753 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1754 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1755 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1756 if ( !Hyp->_is_nil() )
1758 char* sName = Hyp->GetName();
1759 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1761 aCreator->edit( Hyp.in(), desktop() );
1768 updateObjBrowser( true );
1772 case 1101: // RENAME
1774 if ( checkLock( aStudy ) )
1777 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1778 SALOME_ListIO selected;
1780 aSel->selectedObjects( selected );
1782 SALOME_ListIteratorOfListIO It( selected );
1783 for ( ; It.More(); It.Next() )
1785 Handle(SALOME_InteractiveObject) IObject = It.Value();
1786 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1787 _PTR(GenericAttribute) anAttr;
1788 _PTR(AttributeName) aName;
1791 if ( obj->FindAttribute(anAttr, "AttributeName") )
1794 QString newName = QString(aName->Value().c_str());
1795 newName = LightApp_NameDlg::getName(desktop(), newName);
1796 if ( !newName.isEmpty() )
1798 //old source: aStudy->renameIObject( IObject, newName );
1799 aName->SetValue( newName.latin1() );
1801 // if current object is group update group's name
1802 SMESH::SMESH_GroupBase_var aGroup =
1803 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1804 if (!aGroup->_is_nil() )
1805 aGroup->SetName( newName.latin1() );
1815 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1817 if(checkLock(aStudy)) break;
1818 SUIT_OverrideCursor wc;
1820 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1821 SALOME_ListIO selected;
1823 aSel->selectedObjects( selected, QString::null, false );
1825 SALOME_ListIteratorOfListIO It(selected);
1826 for (int i = 0; It.More(); It.Next(), i++) {
1827 Handle(SALOME_InteractiveObject) IObject = It.Value();
1828 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1831 aSel->setSelectedObjects( l1 );
1836 case 401: // GEOM::EDGE
1837 case 4021: // TRIANGLE
1839 case 4023: // POLYGON
1843 if(checkLock(aStudy)) break;
1845 EmitSignalDeactivateDialog();
1846 SMDSAbs_ElementType type = SMDSAbs_Edge;
1848 switch (theCommandID) {
1849 case 4021: // TRIANGLE
1850 type = SMDSAbs_Face; nbNodes = 3; break;
1852 type = SMDSAbs_Face; nbNodes = 4; break;
1854 type = SMDSAbs_Volume; nbNodes = 4; break;
1855 case 4023: // POLYGON
1856 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1858 type = SMDSAbs_Volume; nbNodes = 8; break;
1859 case 4033: // POLYHEDRE
1860 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1863 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1866 SUIT_MessageBox::warn1(desktop(),
1867 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1868 tr("SMESH_BUT_OK"));
1872 case 4033: // POLYHEDRON
1874 if(checkLock(aStudy)) break;
1876 EmitSignalDeactivateDialog();
1877 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1880 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1881 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1882 tr("SMESH_BUT_OK"));
1886 case 4034: // QUADRATIC EDGE
1887 case 4035: // QUADRATIC TRIANGLE
1888 case 4036: // QUADRATIC QUADRANGLE
1889 case 4037: // QUADRATIC TETRAHEDRON
1890 case 4038: // QUADRATIC PYRAMID
1891 case 4039: // QUADRATIC PENTAHEDRON
1892 case 4040: // QUADRATIC HEXAHEDRON
1894 if(checkLock(aStudy)) break;
1896 EmitSignalDeactivateDialog();
1899 switch (theCommandID) {
1901 type = QUAD_EDGE; break;
1903 type = QUAD_TRIANGLE; break;
1905 type = QUAD_QUADRANGLE; break;
1907 type = QUAD_TETRAHEDRON; break;
1909 type = QUAD_PYRAMID; break;
1911 type = QUAD_PENTAHEDRON; break;
1913 type = QUAD_HEXAHEDRON;
1917 new SMESHGUI_AddQuadraticElementDlg( this, type );
1920 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1922 tr("SMESH_BUT_OK"));
1926 case 4041: // REMOVES NODES
1928 if(checkLock(aStudy)) break;
1930 EmitSignalDeactivateDialog();
1931 new SMESHGUI_RemoveNodesDlg(this);
1934 SUIT_MessageBox::warn1(desktop(),
1935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1936 tr("SMESH_BUT_OK"));
1940 case 4042: // REMOVES ELEMENTS
1942 if(checkLock(aStudy)) break;
1944 EmitSignalDeactivateDialog();
1945 new SMESHGUI_RemoveElementsDlg(this);
1949 SUIT_MessageBox::warn1(desktop(),
1950 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1951 tr("SMESH_BUT_OK"));
1955 case 4051: // RENUMBERING NODES
1957 if(checkLock(aStudy)) break;
1959 EmitSignalDeactivateDialog();
1960 new SMESHGUI_RenumberingDlg( this, "", 0);
1964 SUIT_MessageBox::warn1(desktop(),
1965 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1966 tr("SMESH_BUT_OK"));
1970 case 4052: // RENUMBERING ELEMENTS
1972 if(checkLock(aStudy)) break;
1974 EmitSignalDeactivateDialog();
1975 new SMESHGUI_RenumberingDlg( this, "", 1);
1979 SUIT_MessageBox::warn1(desktop(),
1980 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1981 tr("SMESH_BUT_OK"));
1985 case 4061: // TRANSLATION
1987 if(checkLock(aStudy)) break;
1989 EmitSignalDeactivateDialog();
1990 new SMESHGUI_TranslationDlg( this );
1993 SUIT_MessageBox::warn1(desktop(),
1994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1995 tr("SMESH_BUT_OK"));
1999 case 4062: // ROTATION
2001 if(checkLock(aStudy)) break;
2003 EmitSignalDeactivateDialog();
2004 new SMESHGUI_RotationDlg( this );
2007 SUIT_MessageBox::warn1(desktop(),
2008 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2009 tr("SMESH_BUT_OK"));
2013 case 4063: // SYMMETRY
2015 if(checkLock(aStudy)) break;
2017 EmitSignalDeactivateDialog();
2018 new SMESHGUI_SymmetryDlg( this );
2021 SUIT_MessageBox::warn1(desktop(),
2022 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2023 tr("SMESH_BUT_OK"));
2027 case 4064: // SEWING
2029 if(checkLock(aStudy)) break;
2031 EmitSignalDeactivateDialog();
2032 new SMESHGUI_SewingDlg( this );
2035 SUIT_MessageBox::warn1(desktop(),
2036 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2037 tr("SMESH_BUT_OK"));
2041 case 4065: // MERGE NODES
2043 if(checkLock(aStudy)) break;
2045 EmitSignalDeactivateDialog();
2046 new SMESHGUI_MergeNodesDlg( this );
2049 SUIT_MessageBox::warn1(desktop(),
2050 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2051 tr("SMESH_BUT_OK"));
2055 case 4066: // MERGE EQUAL ELEMENTS
2057 if (checkLock(aStudy)) break;
2059 EmitSignalDeactivateDialog();
2060 new SMESHGUI_EditMeshDlg(this,
2061 "SMESH_MERGE_ELEMENTS_TITLE",
2062 "ICON_DLG_MERGE_ELEMENTS",
2063 1); // MergeEqualElemets
2065 SUIT_MessageBox::warn1(desktop(),
2066 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2067 tr("SMESH_BUT_OK"));
2072 case 5105: // Library of selection filters
2074 static QValueList<int> aTypes;
2075 if ( aTypes.isEmpty() )
2077 aTypes.append( SMESH::NODE );
2078 aTypes.append( SMESH::EDGE );
2079 aTypes.append( SMESH::FACE );
2080 aTypes.append( SMESH::VOLUME );
2082 if (!myFilterLibraryDlg)
2083 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2084 else if (myFilterLibraryDlg->isHidden())
2085 myFilterLibraryDlg->show();
2086 myFilterLibraryDlg->raise();
2090 case 6017: // CONTROLS
2106 LightApp_SelectionMgr* mgr = selectionMgr();
2107 SALOME_ListIO selected; mgr->selectedObjects( selected );
2109 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2110 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2112 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2113 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2114 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2115 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2116 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2117 ::Control( theCommandID );
2122 SUIT_MessageBox::warn1(desktop(),
2123 tr( "SMESH_WRN_WARNING" ),
2124 tr( "SMESH_BAD_SELECTION" ),
2125 tr( "SMESH_BUT_OK" ) );
2129 SUIT_MessageBox::warn1(desktop(),
2130 tr( "SMESH_WRN_WARNING" ),
2131 tr( "NOT_A_VTK_VIEWER" ),
2132 tr( "SMESH_BUT_OK" ) );
2137 LightApp_SelectionMgr* mgr = selectionMgr();
2138 SALOME_ListIO selected; mgr->selectedObjects( selected );
2140 if (selected.Extent() == 1) {
2141 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2142 if(anIObject->hasEntry())
2143 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2144 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2151 LightApp_SelectionMgr* mgr = selectionMgr();
2152 SALOME_ListIO selected; mgr->selectedObjects( selected );
2154 if (selected.Extent() == 1) {
2155 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2156 if(anIObject->hasEntry())
2157 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2158 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2165 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2166 //updateObjBrowser();
2170 //=============================================================================
2174 //=============================================================================
2175 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2180 //=============================================================================
2184 //=============================================================================
2185 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2190 //=============================================================================
2194 //=============================================================================
2195 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2200 //=============================================================================
2201 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2202 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2204 //=============================================================================
2205 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2206 SUIT_ViewWindow* wnd )
2208 if(theIO->hasEntry()){
2209 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2210 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2214 //=======================================================================
2215 // function : createSMESHAction
2217 //=======================================================================
2218 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2221 QWidget* parent = application()->desktop();
2222 SUIT_ResourceMgr* resMgr = resourceMgr();
2224 if ( icon_id.length() )
2225 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2227 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2228 if ( !pix.isNull() )
2229 icon = QIconSet( pix );
2231 QString tooltip = tr( QString( "TOP_" )+po_id ),
2232 menu = tr( QString( "MEN_" )+po_id ),
2233 status_bar = tr( QString( "STB_" )+po_id );
2235 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2238 //=======================================================================
2239 // function : createPopupItem
2241 //=======================================================================
2242 void SMESHGUI::createPopupItem( const int id,
2243 const QString& clients,
2244 const QString& types,
2245 const QString& theRule,
2250 parentId = popupMgr()->actionId( action( pId ) );
2252 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2253 popupMgr()->insert( action( id ), parentId, 0 );
2255 QChar lc = QtxPopupMgr::Selection::defEquality();
2256 QString rule = "(%1) and (%2) and (%3)";
2257 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2258 if( clients.isEmpty() )
2259 rule = rule.arg( QString( "true" ) );
2261 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2262 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2265 bool cont = myRules.contains( id );
2267 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2269 popupMgr()->setRule( action( id ), rule, true );
2270 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2273 //=======================================================================
2274 // function : initialize
2276 //=======================================================================
2277 void SMESHGUI::initialize( CAM_Application* app )
2279 SalomeApp_Module::initialize( app );
2281 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2283 /* Automatic Update flag */
2284 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2286 // ----- create actions --------------
2288 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2289 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2290 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2291 createSMESHAction( 114, "NUM" );
2292 createSMESHAction( 121, "DAT" );
2293 createSMESHAction( 122, "MED" );
2294 createSMESHAction( 123, "UNV" );
2295 createSMESHAction( 124, "EXPORT_DAT" );
2296 createSMESHAction( 125, "EXPORT_MED" );
2297 createSMESHAction( 126, "EXPORT_UNV" );
2298 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2299 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2300 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2301 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2302 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2303 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2304 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2305 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2306 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2307 createSMESHAction( 804, "ADD" );
2308 createSMESHAction( 805, "REMOVE" );
2309 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2310 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2311 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2312 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2313 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2314 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2315 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2316 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2317 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2318 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2319 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2320 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2321 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2322 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2323 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2324 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2325 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2326 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2327 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2328 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2329 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2330 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2331 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2332 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2333 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2334 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2335 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2336 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2337 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2338 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2339 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2340 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2341 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2342 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2343 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2344 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2345 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2346 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2347 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2348 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2349 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2350 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2351 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2352 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2353 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2354 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2355 createSMESHAction( 415, "MAP", "ICON_MAP" );
2356 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2357 createSMESHAction( 200, "RESET" );
2358 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2359 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2360 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2361 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2362 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2363 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2364 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2365 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2366 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2367 createSMESHAction( 220, "ALL" );
2368 createSMESHAction( 1100, "EDIT_HYPO" );
2369 createSMESHAction( 1101, "RENAME" );
2370 createSMESHAction( 1102, "UNASSIGN" );
2371 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2372 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2373 createSMESHAction( 1131, "DISPMODE" );
2374 createSMESHAction( 1132, "COLORS" );
2375 createSMESHAction( 1133, "TRANSP" );
2376 createSMESHAction( 1134, "CLIP" );
2377 createSMESHAction( 1135, "DISP_ENT" );
2378 createSMESHAction( 2000, "CTRL" );
2380 createSMESHAction( 300, "ERASE" );
2381 createSMESHAction( 301, "DISPLAY" );
2382 createSMESHAction( 302, "DISPLAY_ONLY" );
2383 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2384 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2385 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2386 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2387 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2388 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2389 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2390 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2392 // ----- create menu --------------
2393 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2394 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2395 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2396 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2397 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2398 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2399 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2401 createMenu( separator(), fileId );
2403 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2404 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2405 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2406 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2407 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2408 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2410 createMenu( 111, importId, -1 );
2411 createMenu( 112, importId, -1 );
2412 createMenu( 113, importId, -1 );
2414 createMenu( 121, exportId, -1 );
2415 createMenu( 122, exportId, -1 );
2416 createMenu( 123, exportId, -1 );
2418 createMenu( separator(), fileId, 10 );
2420 createMenu( 33, editId, -1 );
2422 createMenu( 5105, toolsId, -1 );
2424 createMenu( 702, meshId, -1 );
2425 createMenu( 703, meshId, -1 );
2426 createMenu( 704, meshId, -1 );
2427 createMenu( separator(), meshId, -1 );
2428 createMenu( 701, meshId, -1 );
2429 createMenu( separator(), meshId, -1 );
2430 createMenu( 801, meshId, -1 );
2431 createMenu( 802, meshId, -1 );
2432 createMenu( 803, meshId, -1 );
2433 createMenu( separator(), meshId, -1 );
2434 createMenu( 810, meshId, -1 );
2435 createMenu( 811, meshId, -1 );
2436 createMenu( 812, meshId, -1 );
2437 createMenu( separator(), meshId, -1 );
2438 createMenu( 813, meshId, -1 );
2439 createMenu( separator(), meshId, -1 );
2440 createMenu( 900, meshId, -1 );
2441 createMenu( 902, meshId, -1 );
2442 createMenu( separator(), meshId, -1 );
2444 createMenu( 6003, ctrlId, -1 );
2445 createMenu( 6001, ctrlId, -1 );
2446 createMenu( 6004, ctrlId, -1 );
2447 createMenu( separator(), ctrlId, -1 );
2448 createMenu( 6002, ctrlId, -1 );
2449 createMenu( 6018, ctrlId, -1 );
2450 createMenu( 6019, ctrlId, -1 );
2451 createMenu( 6011, ctrlId, -1 );
2452 createMenu( 6012, ctrlId, -1 );
2453 createMenu( 6013, ctrlId, -1 );
2454 createMenu( 6014, ctrlId, -1 );
2455 createMenu( 6015, ctrlId, -1 );
2456 createMenu( 6016, ctrlId, -1 );
2457 createMenu( separator(), ctrlId, -1 );
2458 createMenu( 6017, ctrlId, -1 );
2459 createMenu( 6009, ctrlId, -1 );
2460 createMenu( separator(), ctrlId, -1 );
2462 createMenu( 400, addId, -1 );
2463 createMenu( 401, addId, -1 );
2464 createMenu( 4021, addId, -1 );
2465 createMenu( 4022, addId, -1 );
2466 createMenu( 4023, addId, -1 );
2467 createMenu( 4031, addId, -1 );
2468 createMenu( 4032, addId, -1 );
2469 createMenu( 4033, addId, -1 );
2470 createMenu( separator(), addId, -1 );
2471 createMenu( 4034, addId, -1 );
2472 createMenu( 4035, addId, -1 );
2473 createMenu( 4036, addId, -1 );
2474 createMenu( 4037, addId, -1 );
2475 createMenu( 4038, addId, -1 );
2476 createMenu( 4039, addId, -1 );
2477 createMenu( 4040, addId, -1 );
2479 createMenu( 4041, removeId, -1 );
2480 createMenu( 4042, removeId, -1 );
2482 createMenu( 4051, renumId, -1 );
2483 createMenu( 4052, renumId, -1 );
2485 createMenu( 4061, transfId, -1 );
2486 createMenu( 4062, transfId, -1 );
2487 createMenu( 4063, transfId, -1 );
2488 createMenu( 4064, transfId, -1 );
2489 createMenu( 4065, transfId, -1 );
2490 createMenu( 4066, transfId, -1 );
2492 createMenu( 406, modifyId, -1 );
2493 createMenu( 407, modifyId, -1 );
2494 createMenu( 408, modifyId, -1 );
2495 createMenu( 409, modifyId, -1 );
2496 createMenu( 410, modifyId, -1 );
2497 createMenu( 411, modifyId, -1 );
2498 createMenu( 412, modifyId, -1 );
2499 createMenu( 413, modifyId, -1 );
2500 createMenu( 416, modifyId, -1 );
2501 createMenu( 414, modifyId, -1 );
2502 createMenu( 415, modifyId, -1 );
2504 createMenu( 214, viewId, -1 );
2506 // ----- create toolbars --------------
2507 int meshTb = createTool( tr( "TB_MESH" ) ),
2508 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2509 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2510 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2511 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2513 createTool( 702, meshTb );
2514 createTool( 703, meshTb );
2515 createTool( 704, meshTb );
2516 createTool( separator(), meshTb );
2517 createTool( 701, meshTb );
2518 createTool( separator(), meshTb );
2519 createTool( 801, meshTb );
2520 createTool( 802, meshTb );
2521 createTool( 803, meshTb );
2522 createTool( separator(), meshTb );
2523 createTool( 900, meshTb );
2524 createTool( 902, meshTb );
2525 createTool( separator(), meshTb );
2527 createTool( 6001, ctrlTb );
2528 createTool( 6003, ctrlTb );
2529 createTool( 6004, ctrlTb );
2530 createTool( separator(), ctrlTb );
2531 createTool( 6002, ctrlTb );
2532 createTool( 6018, ctrlTb );
2533 createTool( 6019, ctrlTb );
2534 createTool( 6011, ctrlTb );
2535 createTool( 6012, ctrlTb );
2536 createTool( 6013, ctrlTb );
2537 createTool( 6014, ctrlTb );
2538 createTool( 6015, ctrlTb );
2539 createTool( 6016, ctrlTb );
2540 createTool( separator(), ctrlTb );
2541 createTool( 6017, ctrlTb );
2542 createTool( 6009, ctrlTb );
2543 createTool( separator(), ctrlTb );
2545 createTool( 400, addRemTb );
2546 createTool( 401, addRemTb );
2547 createTool( 4021, addRemTb );
2548 createTool( 4022, addRemTb );
2549 createTool( 4023, addRemTb );
2550 createTool( 4031, addRemTb );
2551 createTool( 4032, addRemTb );
2552 createTool( 4033, addRemTb );
2553 createTool( separator(), addRemTb );
2554 createTool( 4034, addRemTb );
2555 createTool( 4035, addRemTb );
2556 createTool( 4036, addRemTb );
2557 createTool( 4037, addRemTb );
2558 createTool( 4038, addRemTb );
2559 createTool( 4039, addRemTb );
2560 createTool( 4040, addRemTb );
2561 createTool( separator(), addRemTb );
2562 createTool( 4041, addRemTb );
2563 createTool( 4042, addRemTb );
2564 createTool( separator(), addRemTb );
2565 createTool( 4051, addRemTb );
2566 createTool( 4052, addRemTb );
2567 createTool( separator(), addRemTb );
2568 createTool( 4061, addRemTb );
2569 createTool( 4062, addRemTb );
2570 createTool( 4063, addRemTb );
2571 createTool( 4064, addRemTb );
2572 createTool( 4065, addRemTb );
2573 createTool( 4066, addRemTb );
2574 createTool( separator(), addRemTb );
2576 createTool( 406, modifyTb );
2577 createTool( 407, modifyTb );
2578 createTool( 408, modifyTb );
2579 createTool( 409, modifyTb );
2580 createTool( 410, modifyTb );
2581 createTool( 411, modifyTb );
2582 createTool( 412, modifyTb );
2583 createTool( 413, modifyTb );
2584 createTool( 416, modifyTb );
2585 createTool( 414, modifyTb );
2586 createTool( 415, modifyTb );
2588 createTool( 214, dispModeTb );
2592 QString OB = "'ObjectBrowser'",
2593 View = "'" + SVTK_Viewer::Type() + "'",
2595 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2596 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2597 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2598 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2599 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2600 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2601 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2602 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2603 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2604 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2605 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2607 mesh_group = mesh + " " + subMesh + " " + group,
2608 hyp_alg = hypo + " " + algo;
2610 // popup for object browser
2612 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2613 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2614 createPopupItem( 803, OB, group ); // EDIT_GROUP
2615 popupMgr()->insert( separator(), -1, 0 );
2616 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2617 createPopupItem( 214, OB, mesh_group ); // UPDATE
2618 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2619 createPopupItem( 902, OB, mesh ); // STD_INFO
2620 popupMgr()->insert( separator(), -1, 0 );
2621 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2622 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2623 popupMgr()->insert( separator(), -1, 0 );
2624 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2625 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2626 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2627 popupMgr()->insert( separator(), -1, 0 );
2629 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2630 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2631 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2632 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2633 popupMgr()->insert( separator(), -1, 0 );
2636 createPopupItem( 803, View, group ); // EDIT_GROUP
2637 createPopupItem( 804, View, elems ); // ADD
2638 createPopupItem( 805, View, elems ); // REMOVE
2639 popupMgr()->insert( separator(), -1, 0 );
2640 createPopupItem( 214, View, mesh_group ); // UPDATE
2641 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2642 createPopupItem( 902, View, mesh ); // STD_INFO
2643 popupMgr()->insert( separator(), -1, 0 );
2647 isInvisible("not( isVisible )"),
2648 isEmpty("numberOfNodes = 0"),
2649 isNotEmpty("numberOfNodes <> 0"),
2651 // has nodes, edges, etc in VISIBLE! actor
2652 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2653 hasElems("(count( elemTypes ) > 0)"),
2654 hasDifferentElems("(count( elemTypes ) > 1)"),
2655 hasEdges("({'Edge'} in elemTypes)"),
2656 hasFaces("({'Face'} in elemTypes)"),
2657 hasVolumes("({'Volume'} in elemTypes)");
2659 QString lc = QtxPopupMgr::Selection::defEquality();
2660 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2661 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2662 aType = aType.arg( mesh_group );
2663 QString aMeshInVTK = aClient + "&&" + aType;
2665 //-------------------------------------------------
2667 //-------------------------------------------------
2668 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2670 popupMgr()->insert( action( 9010 ), anId, -1 );
2671 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2672 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2674 popupMgr()->insert( action( 9011 ), anId, -1 );
2675 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2676 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2678 popupMgr()->insert( separator(), -1, -1 );
2680 //-------------------------------------------------
2682 //-------------------------------------------------
2683 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2685 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2686 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2687 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2689 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2690 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2691 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2693 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2694 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2695 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2697 popupMgr()->insert( separator(), anId, -1 );
2699 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2700 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2701 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2703 //-------------------------------------------------
2705 //-------------------------------------------------
2706 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2708 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2710 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2711 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2712 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2714 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2715 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2716 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2718 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2719 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2720 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2722 popupMgr()->insert( separator(), anId, -1 );
2724 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2725 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2727 //-------------------------------------------------
2729 //-------------------------------------------------
2730 popupMgr()->insert( action( 1132 ), -1, -1 );
2731 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2733 //-------------------------------------------------
2735 //-------------------------------------------------
2736 popupMgr()->insert( action( 1133 ), -1, -1 );
2737 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2739 //-------------------------------------------------
2741 //-------------------------------------------------
2742 popupMgr()->insert( action( 1134 ), -1, -1 );
2743 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2745 popupMgr()->insert( separator(), -1, -1 );
2747 //-------------------------------------------------
2749 //-------------------------------------------------
2751 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2752 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2753 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2755 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2757 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2758 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2760 popupMgr()->insert( separator(), anId, -1 );
2762 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2763 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2764 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2766 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2767 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2768 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2770 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2771 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2772 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2774 popupMgr()->insert( separator(), anId, -1 );
2776 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2777 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2778 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2780 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2781 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2782 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2784 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2785 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2786 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2788 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2789 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2790 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2792 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2793 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2794 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2796 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2797 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2798 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2800 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2801 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2802 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2804 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2805 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2806 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2808 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2809 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2810 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2812 popupMgr()->insert( separator(), anId, -1 );
2814 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2815 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2816 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2818 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2819 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2820 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2822 popupMgr()->insert( separator(), anId, -1 );
2824 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2825 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2827 popupMgr()->insert( separator(), -1, -1 );
2829 //-------------------------------------------------
2831 //-------------------------------------------------
2832 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2833 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2834 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2836 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2837 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2838 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2839 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2841 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2842 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2844 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2845 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2847 popupMgr()->insert( separator(), -1, -1 );
2849 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2850 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2853 bool SMESHGUI::activateModule( SUIT_Study* study )
2855 bool res = SalomeApp_Module::activateModule( study );
2857 setMenuShown( true );
2858 setToolShown( true );
2863 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2865 setMenuShown( false );
2866 setToolShown( false );
2868 EmitSignalCloseAllDialogs();
2870 return SalomeApp_Module::deactivateModule( study );
2873 void SMESHGUI::OnGUIEvent()
2875 const QObject* obj = sender();
2876 if ( !obj || !obj->inherits( "QAction" ) )
2878 int id = actionId((QAction*)obj);
2883 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2885 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2886 if ( CORBA::is_nil( myComponentSMESH ) )
2888 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2890 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2891 return aGUI.myComponentSMESH;
2894 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2895 return myComponentSMESH;
2898 QString SMESHGUI::engineIOR() const
2900 CORBA::ORB_var anORB = getApp()->orb();
2901 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2905 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2907 SMESHGUI_Selection sel;
2908 sel.init( client, selectionMgr() );
2909 popupMgr()->updatePopup( menu, &sel );
2912 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2914 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2915 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2918 void SMESHGUI::viewManagers( QStringList& list ) const
2920 list.append( SVTK_Viewer::Type() );
2923 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2925 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2926 SMESH::UpdateSelectionProp( this );
2929 void SMESHGUI::createPreferences()
2931 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2933 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2934 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2936 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2937 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2938 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2940 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2941 setPreferenceProperty( precGroup, "columns", 1 );
2943 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2945 setPreferenceProperty( prec, "min", 0 );
2946 setPreferenceProperty( prec, "max", 16 );
2948 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2949 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2951 modes.append( "Wireframe" );
2952 modes.append( "Shading" );
2953 modes.append( "Nodes" );
2954 modes.append( "Shrink" );
2955 QValueList<QVariant> indices;
2956 indices.append( 0 );
2957 indices.append( 1 );
2958 indices.append( 2 );
2959 indices.append( 3 );
2960 setPreferenceProperty( dispmode, "strings", modes );
2961 setPreferenceProperty( dispmode, "indexes", indices );
2963 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2964 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2966 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2967 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2969 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2970 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2972 setPreferenceProperty( nodeSz, "min", 1 );
2973 setPreferenceProperty( nodeSz, "max", 5 );
2975 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2977 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2978 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2979 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2980 addPreference( "", elemGroup, LightApp_Preferences::Space );
2982 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2983 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2985 setPreferenceProperty( elemW, "min", 1 );
2986 setPreferenceProperty( elemW, "max", 5 );
2988 setPreferenceProperty( shrink, "min", 0 );
2989 setPreferenceProperty( shrink, "max", 100 );
2991 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2993 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2995 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2996 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2997 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
2999 setPreferenceProperty( selW, "min", 1 );
3000 setPreferenceProperty( selW, "max", 5 );
3002 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3004 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3005 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3007 setPreferenceProperty( preW, "min", 1 );
3008 setPreferenceProperty( preW, "max", 5 );
3010 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3012 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3013 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3015 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3016 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3018 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3019 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3020 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3021 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3024 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3025 fam.append( tr( "SMESH_FONT_COURIER" ) );
3026 fam.append( tr( "SMESH_FONT_TIMES" ) );
3027 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3029 setPreferenceProperty( tfont, "families", fam );
3030 setPreferenceProperty( tfont, "system", false );
3031 setPreferenceProperty( tfont, "widget_flags", wflag );
3032 setPreferenceProperty( lfont, "families", fam );
3033 setPreferenceProperty( lfont, "system", false );
3034 setPreferenceProperty( lfont, "widget_flags", wflag );
3036 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3038 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3039 setPreferenceProperty( numcol, "min", 2 );
3040 setPreferenceProperty( numcol, "max", 256 );
3042 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3043 setPreferenceProperty( numlab, "min", 2 );
3044 setPreferenceProperty( numlab, "max", 65 );
3046 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3047 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3048 QStringList orients;
3049 orients.append( tr( "SMESH_VERTICAL" ) );
3050 orients.append( tr( "SMESH_HORIZONTAL" ) );
3051 indices.clear(); indices.append( 0 ); indices.append( 1 );
3052 setPreferenceProperty( orient, "strings", orients );
3053 setPreferenceProperty( orient, "indexes", indices );
3055 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3056 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3057 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3058 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3059 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3060 setPreferenceProperty( xv, "step", 0.1 );
3061 setPreferenceProperty( xv, "min", 0.0 );
3062 setPreferenceProperty( xv, "max", 1.0 );
3063 setPreferenceProperty( yv, "step", 0.1 );
3064 setPreferenceProperty( yv, "min", 0.0 );
3065 setPreferenceProperty( yv, "max", 1.0 );
3066 setPreferenceProperty( wv, "step", 0.1 );
3067 setPreferenceProperty( wv, "min", 0.0 );
3068 setPreferenceProperty( wv, "max", 1.0 );
3069 setPreferenceProperty( hv, "min", 0.0 );
3070 setPreferenceProperty( hv, "max", 1.0 );
3071 setPreferenceProperty( hv, "step", 0.1 );
3073 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3074 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3075 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3076 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3077 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3078 setPreferenceProperty( xv, "min", 0.0 );
3079 setPreferenceProperty( xv, "max", 1.0 );
3080 setPreferenceProperty( xv, "step", 0.1 );
3081 setPreferenceProperty( xh, "min", 0.0 );
3082 setPreferenceProperty( xh, "max", 1.0 );
3083 setPreferenceProperty( xh, "step", 0.1 );
3084 setPreferenceProperty( yh, "min", 0.0 );
3085 setPreferenceProperty( yh, "max", 1.0 );
3086 setPreferenceProperty( yh, "step", 0.1 );
3087 setPreferenceProperty( wh, "min", 0.0 );
3088 setPreferenceProperty( wh, "max", 1.0 );
3089 setPreferenceProperty( wh, "step", 0.1 );
3090 setPreferenceProperty( hh, "min", 0.0 );
3091 setPreferenceProperty( hh, "max", 1.0 );
3092 setPreferenceProperty( hh, "step", 0.1 );
3095 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3097 if( sect=="SMESH" ){
3098 float sbX1,sbY1,sbW,sbH;
3099 float aTol = 1.00000009999999;
3100 std::string aWarning;
3101 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3102 if( name=="selection_object_color" || name=="selection_element_color" ||
3103 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3104 name=="selection_precision_node" || name=="selection_precision_element" )
3105 SMESH::UpdateSelectionProp( this );
3106 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3107 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3108 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3109 if(sbX1+sbW > aTol){
3110 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3113 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3114 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3117 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3118 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3119 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3120 if(sbY1+sbH > aTol){
3121 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3124 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3125 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3128 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3129 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3130 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3131 if(sbX1+sbW > aTol){
3132 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3135 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3136 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3139 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3140 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3141 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3142 if(sbY1+sbH > aTol){
3143 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3146 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3147 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3151 if(aWarning.size() != 0){
3152 aWarning += "The default values are applied instead.";
3153 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3154 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3155 QObject::tr(aWarning.c_str()),
3156 QObject::tr("SMESH_BUT_OK"));
3161 //================================================================================
3163 * \brief Update something in accordance with update flags
3164 * \param theFlags - update flags
3166 * Update viewer or/and object browser etc. in accordance with update flags ( see
3167 * LightApp_UpdateFlags enumeration ).
3169 //================================================================================
3170 void SMESHGUI::update( const int flags )
3172 if ( flags & UF_Viewer | flags & UF_Forced )
3173 SMESH::UpdateView();
3175 SalomeApp_Module::update( flags );
3178 //================================================================================
3180 * \brief Set default selection mode
3182 * SLOT called when operation commited. Sets default selection mode
3184 //================================================================================
3185 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3187 SVTK_ViewWindow* vtkWnd =
3188 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3190 vtkWnd->SetSelectionMode( ActorSelection );
3193 //================================================================================
3195 * \brief Set default selection mode
3197 * SLOT called when operation aborted. Sets default selection mode
3199 //================================================================================
3200 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3202 SVTK_ViewWindow* vtkWnd =
3203 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3205 vtkWnd->SetSelectionMode( ActorSelection );
3208 //================================================================================
3210 * \brief Creates operation with given identifier
3211 * \param id - identifier of operation to be started
3212 * \return Pointer on created operation or NULL if operation is not created
3214 * Virtual method redefined from the base class creates operation with given id.
3215 * It is called called automatically from startOperation method of base class.
3217 //================================================================================
3218 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3220 LightApp_Operation* op = 0;
3221 // to do : create operation here
3224 case 702: // Create mesh
3225 op = new SMESHGUI_MeshOp( true, true );
3227 case 703: // Create sub-mesh
3228 op = new SMESHGUI_MeshOp( true, false );
3230 case 704: // Edit mesh/sub-mesh
3231 op = new SMESHGUI_MeshOp( false );
3238 op = SalomeApp_Module::createOperation( id );
3242 //================================================================================
3244 * \brief Stops current operations and starts a given one
3245 * \param id - The id of the operation to start
3247 //================================================================================
3249 void SMESHGUI::switchToOperation(int id)
3251 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3252 activeStudy()->abortAllOperations();
3253 startOperation( id );
3256 LightApp_Displayer* SMESHGUI::displayer()
3259 myDisplayer = new SMESHGUI_Displayer( getApp() );