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_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_EditMeshDlg.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_PrecisionDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
68 #include "SMESHGUI_MeshOp.h"
69 #include "SMESHGUI_Displayer.h"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_GEOMGenUtils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include "SMESH_Actor.h"
81 #include "SMESH_Object.h"
82 #include "SMESH_TypeFilter.hxx"
84 #include "SalomeApp_Tools.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_CheckFileDlg.h"
88 #include "SalomeApp_ImportOperation.h"
90 #include "LightApp_DataOwner.h"
91 #include "LightApp_Preferences.h"
92 #include "LightApp_VTKSelector.h"
93 #include "LightApp_Operation.h"
94 #include "LightApp_UpdateFlags.h"
95 #include "LightApp_NameDlg.h"
97 #include <SVTK_ViewWindow.h>
98 #include <SVTK_ViewModel.h>
99 #include <SVTK_InteractorStyle.h>
100 #include <SVTK_RenderWindowInteractor.h>
101 #include <SVTK_ViewManager.h>
103 #include "OB_Browser.h"
105 #include "SUIT_Tools.h"
106 #include "SUIT_MessageBox.h"
107 #include "SUIT_ResourceMgr.h"
108 #include "SUIT_FileDlg.h"
109 #include "SUIT_Desktop.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
126 #define INCLUDE_MENUITEM_DEF
127 #include <qpopupmenu.h>
133 #include <boost/shared_ptr.hpp>
136 #include <vtkRenderer.h>
137 #include <vtkRenderWindow.h>
138 #include <vtkActorCollection.h>
139 #include <vtkScalarBarActor.h>
140 #include <vtkUnstructuredGrid.h>
142 #include "utilities.h"
144 #include "SALOMEDS_Study.hxx"
145 #include "SALOMEDSClient_StudyBuilder.hxx"
146 #include "SALOMEDSClient_SComponent.hxx"
152 //=============================================================
153 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
156 void ExportMeshToFile(int theCommandID);
158 void SetDisplayMode(int theCommandID);
160 void SetDisplayEntity(int theCommandID);
162 void Control( int theCommandID );
166 //=============================================================
167 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
173 if(theCommandID == 113){
174 filter.append(QObject::tr("MED files (*.med)"));
175 filter.append(QObject::tr("All files (*)"));
176 }else if (theCommandID == 112){
177 filter.append(QObject::tr("IDEAS files (*.unv)"));
178 }else if (theCommandID == 111){
179 filter.append(QObject::tr("DAT files (*.dat)"));
181 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
184 QObject::tr("Import mesh"),
186 if(!filename.isEmpty()) {
187 SUIT_OverrideCursor wc;
188 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
191 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
192 switch ( theCommandID ) {
195 aMeshes->length( 1 );
196 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
201 SMESH::DriverMED_ReadStatus res;
202 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
203 if ( res != SMESH::DRS_OK ) {
205 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
206 QObject::tr("SMESH_WRN_WARNING"),
207 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
208 QObject::tr("SMESH_BUT_OK"));
209 aMeshes->length( 0 );
216 bool isEmpty = false;
217 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
218 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
220 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
221 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
222 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
223 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
224 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
231 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
232 QObject::tr("SMESH_WRN_WARNING"),
233 QObject::tr("SMESH_DRS_EMPTY"),
234 QObject::tr("SMESH_BUT_OK"));
238 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
240 catch (const SALOME::SALOME_Exception& S_ex){
242 SalomeApp_Tools::QtCatchCorbaException(S_ex);
249 void ExportMeshToFile( int theCommandID )
251 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
252 SALOME_ListIO selected;
254 aSel->selectedObjects( selected );
256 if(selected.Extent()){
257 Handle(SALOME_InteractiveObject) anIObject = selected.First();
258 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
259 if ( !aMesh->_is_nil() ) {
260 QString aFilter, aTitle = QObject::tr("Export mesh");
261 QMap<QString, SMESH::MED_VERSION> aFilterMap;
262 switch ( theCommandID ) {
266 if (aMesh->HasDuplicatedGroupNamesMED()) {
267 int aRet = SUIT_MessageBox::warn2
268 (SMESHGUI::desktop(),
269 QObject::tr("SMESH_WRN_WARNING"),
270 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
271 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
277 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
278 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
283 aFilter = QObject::tr("DAT files (*.dat)");
288 if (aMesh->NbPyramids()) {
289 int aRet = SUIT_MessageBox::warn2
290 (SMESHGUI::desktop(),
291 QObject::tr("SMESH_WRN_WARNING"),
292 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
293 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
298 aFilter = QObject::tr("IDEAS files (*.unv)");
306 SMESH::MED_VERSION aFormat;
307 // Init the parameter with the default value
308 bool toCreateGroups = false;
309 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
311 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
313 if ( theCommandID != 122 && theCommandID != 125 )
314 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
317 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
318 for ( ; it != aFilterMap.end(); ++it )
319 filters.push_back( it.key() );
321 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
322 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
323 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
324 fd->setCaption( aTitle );
325 fd->setFilters( filters );
326 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
327 fd->SetChecked(toCreateGroups);
331 aFilename = fd->selectedFile();
332 aFormat = aFilterMap[fd->selectedFilter()];
334 if ( !aFilename.isEmpty()
335 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
336 && aFormat==SMESH::MED_V2_1) {
337 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
338 QObject::tr("SMESH_WRN_WARNING"),
339 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
340 QObject::tr("SMESH_BUT_YES"),
341 QObject::tr("SMESH_BUT_NO"),
348 toCreateGroups = fd->IsChecked();
351 if ( !aFilename.isEmpty() ) {
352 // Check whether the file already exists and delete it if yes
353 QFile aFile( aFilename );
354 if ( aFile.exists() )
356 SUIT_OverrideCursor wc;
357 switch ( theCommandID ) {
360 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
364 aMesh->ExportDAT( aFilename.latin1() );
368 aMesh->ExportUNV( aFilename.latin1() );
378 inline void InverseEntityMode(unsigned int& theOutputMode,
379 unsigned int theMode)
381 bool anIsNotPresent = ~theOutputMode & theMode;
383 theOutputMode |= theMode;
385 theOutputMode &= ~theMode;
388 void SetDisplayEntity(int theCommandID){
389 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
390 SALOME_ListIO selected;
392 aSel->selectedObjects( selected );
394 if(selected.Extent() >= 1){
395 SALOME_ListIteratorOfListIO It( selected );
396 for(; It.More(); It.Next()){
397 Handle(SALOME_InteractiveObject) IObject = It.Value();
398 if(IObject->hasEntry()){
399 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
400 unsigned int aMode = anActor->GetEntityMode();
401 switch(theCommandID){
403 InverseEntityMode(aMode,SMESH_Actor::eEdges);
406 InverseEntityMode(aMode,SMESH_Actor::eFaces);
409 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
412 aMode = SMESH_Actor::eAllEntity;
416 anActor->SetEntityMode(aMode);
423 void SetDisplayMode(int theCommandID){
424 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
425 SALOME_ListIO selected;
427 aSel->selectedObjects( selected );
429 if(selected.Extent() >= 1){
430 switch(theCommandID){
432 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
433 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
437 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
438 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
441 SALOME_ListIteratorOfListIO It( selected );
442 for(; It.More(); It.Next()){
443 Handle(SALOME_InteractiveObject) IObject = It.Value();
444 if(IObject->hasEntry()){
445 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
446 switch(theCommandID){
448 anActor->SetRepresentation(SMESH_Actor::eEdge);
451 anActor->SetRepresentation(SMESH_Actor::eSurface);
454 if(anActor->IsShrunk())
457 anActor->SetShrink();
460 anActor->SetRepresentation(SMESH_Actor::ePoint);
464 anActor->GetSufaceColor(color[0], color[1], color[2]);
465 int c0 = int (color[0] * 255);
466 int c1 = int (color[1] * 255);
467 int c2 = int (color[2] * 255);
468 QColor c(c0, c1, c2);
471 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
472 c0 = int (edgecolor[0] * 255);
473 c1 = int (edgecolor[1] * 255);
474 c2 = int (edgecolor[2] * 255);
475 QColor e(c0, c1, c2);
477 float backfacecolor[3];
478 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
479 c0 = int (backfacecolor[0] * 255);
480 c1 = int (backfacecolor[1] * 255);
481 c2 = int (backfacecolor[2] * 255);
482 QColor b(c0, c1, c2);
485 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
486 c0 = int (nodecolor[0] * 255);
487 c1 = int (nodecolor[1] * 255);
488 c2 = int (nodecolor[2] * 255);
489 QColor n(c0, c1, c2);
491 int Edgewidth = (int)anActor->GetLineWidth();
494 int intValue = int(anActor->GetNodeSize());
495 float Shrink = anActor->GetShrinkFactor();
497 SMESHGUI_Preferences_ColorDlg *aDlg =
498 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
499 aDlg->SetColor(1, c);
500 aDlg->SetColor(2, e);
501 aDlg->SetColor(3, n);
502 aDlg->SetColor(4, b);
503 aDlg->SetIntValue(1, Edgewidth);
504 aDlg->SetIntValue(2, intValue);
505 aDlg->SetIntValue(3, int(Shrink*100.));
507 QColor color = aDlg->GetColor(1);
508 QColor edgecolor = aDlg->GetColor(2);
509 QColor nodecolor = aDlg->GetColor(3);
510 QColor backfacecolor = aDlg->GetColor(4);
511 /* actor color and backface color */
512 anActor->SetSufaceColor(float (color.red()) / 255.,
513 float (color.green()) / 255.,
514 float (color.blue()) / 255.);
515 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
516 float (backfacecolor.green()) / 255.,
517 float (backfacecolor.blue()) / 255.);
520 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
521 float (edgecolor.green()) / 255.,
522 float (edgecolor.blue()) / 255.);
524 /* Shrink factor and size edges */
525 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
526 anActor->SetLineWidth(aDlg->GetIntValue(1));
528 /* Nodes color and size */
529 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
530 float (nodecolor.green()) / 255.,
531 float (nodecolor.blue()) / 255.);
532 anActor->SetNodeSize(aDlg->GetIntValue(2));
541 SMESH::RepaintCurrentView();
545 void Control( int theCommandID )
547 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
548 SALOME_ListIO selected;
550 aSel->selectedObjects( selected );
552 if( !selected.IsEmpty() ){
553 Handle(SALOME_InteractiveObject) anIO = selected.First();
556 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
557 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
558 switch ( theCommandID ){
560 aTitle = QObject::tr( "LENGTH_EDGES" );
561 aControl = SMESH_Actor::eLength;
564 aTitle = QObject::tr( "LENGTH2D_EDGES" );
565 aControl = SMESH_Actor::eLength2D;
568 aTitle = QObject::tr( "FREE_EDGES" );
569 aControl = SMESH_Actor::eFreeEdges;
572 aTitle = QObject::tr( "FREE_BORDERS" );
573 aControl = SMESH_Actor::eFreeBorders;
576 aTitle = QObject::tr( "MULTI_BORDERS" );
577 aControl = SMESH_Actor::eMultiConnection;
580 aTitle = QObject::tr( "MULTI2D_BORDERS" );
581 aControl = SMESH_Actor::eMultiConnection2D;
584 aTitle = QObject::tr( "AREA_ELEMENTS" );
585 aControl = SMESH_Actor::eArea;
588 aTitle = QObject::tr( "TAPER_ELEMENTS" );
589 aControl = SMESH_Actor::eTaper;
592 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
593 aControl = SMESH_Actor::eAspectRatio;
596 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
597 aControl = SMESH_Actor::eAspectRatio3D;
600 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
601 aControl = SMESH_Actor::eMinimumAngle;
604 aTitle = QObject::tr( "WARP_ELEMENTS" );
605 aControl = SMESH_Actor::eWarping;
608 aTitle = QObject::tr( "SKEW_ELEMENTS" );
609 aControl = SMESH_Actor::eSkew;
612 aTitle = QObject::tr( "SMESH_VOLUME" );
613 aControl = SMESH_Actor::eVolume3D;
616 anActor->SetControlMode(aControl);
617 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
618 SMESH::RepaintCurrentView();
625 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
626 MeshObjectType theType,
627 const QString theInTypeName,
628 QString & theOutTypeName)
630 SMESH_TypeFilter aTypeFilter( theType );
632 if( !theIO.IsNull() )
634 entry = theIO->getEntry();
635 LightApp_DataOwner owner( entry );
636 if ( aTypeFilter.isOk( &owner )) {
637 theOutTypeName = theInTypeName;
645 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
647 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
648 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
650 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
651 CORBA::String_var anID = aSComp->GetID().c_str();
652 if (!strcmp(anID.in(),theIO->getEntry()))
658 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
659 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
660 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
661 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
662 CheckOIType ( theIO, GROUP, "Group", aTypeName )
670 QString CheckHomogeneousSelection()
672 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
673 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
674 SALOME_ListIO selected;
676 aSel->selectedObjects( selected );
678 QString RefType = CheckTypeObject(selected.First());
679 SALOME_ListIteratorOfListIO It(selected);
680 for (; It.More(); It.Next())
682 Handle(SALOME_InteractiveObject) IObject = It.Value();
683 QString Type = CheckTypeObject(IObject);
684 if (Type.compare(RefType) != 0)
685 return "Heterogeneous Selection";
692 void SMESHGUI::OnEditDelete()
694 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
695 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
696 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
698 QString aParentComponent = QString::null;
699 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
701 QString cur = anIt.Value()->getComponentDataType();
702 if( aParentComponent.isNull() )
703 aParentComponent = cur;
704 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
705 aParentComponent = "";
708 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
709 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
710 QObject::tr("ERR_ERROR"),
711 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
712 QObject::tr("BUT_OK") );
715 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
716 if (SUIT_MessageBox::warn2
717 (SMESHGUI::desktop(),
718 QObject::tr("SMESH_WRN_WARNING"),
719 QObject::tr("SMESH_REALLY_DELETE"),
720 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
723 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
724 SUIT_ViewManager* vm = anApp->activeViewManager();
725 int nbSf = vm->getViewsCount();
727 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
728 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
729 _PTR(GenericAttribute) anAttr;
730 _PTR(AttributeIOR) anIOR;
732 SALOME_ListIteratorOfListIO It(selected);
734 aStudyBuilder->NewCommand(); // There is a transaction
735 for(; It.More(); It.Next()){
736 Handle(SALOME_InteractiveObject) IObject = It.Value();
737 if(IObject->hasEntry()){
738 _PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
740 // disable removal of "SMESH" component object
741 if(SO->FindAttribute(anAttr, "AttributeIOR")){
743 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
747 /* Erase child graphical objects */
748 _PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
749 for(it->InitEx(true); it->More(); it->Next()){
750 _PTR(SObject) CSO = it->Value();
751 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
754 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
755 for(int i = 0; i < nbSf; i++){
756 SUIT_ViewWindow *sf = aViews[i];
757 CORBA::String_var anEntry = CSO->GetID().c_str();
758 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
759 SMESH::RemoveActor(sf,anActor);
765 /* Erase main graphical object */
766 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
767 for(int i = 0; i < nbSf; i++){
768 SUIT_ViewWindow *sf = aViews[i];
769 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
770 SMESH::RemoveActor(sf,anActor);
774 // Remove object(s) from data structures
775 _PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
777 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
778 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
779 QString objType = CheckTypeObject(IObject);
780 if ( !aGroup->_is_nil() ) { // DELETE GROUP
781 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
782 aMesh->RemoveGroup( aGroup );
784 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
785 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
786 aMesh->RemoveSubMesh( aSubMesh );
788 else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
789 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
790 aStudyBuilder->RemoveObjectWithChildren( obj );
792 else {// default action: remove SObject from the study
793 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
794 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
796 aStudyBuilder->RemoveObjectWithChildren( obj );
801 } /* IObject->hasEntry() */
803 aStudyBuilder->CommitCommand();
805 /* Clear any previous selection */
807 aSel->setSelectedObjects( l1 );
809 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
814 Standard_EXPORT CAM_Module* createModule()
816 return new SMESHGUI();
820 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
822 //=============================================================================
826 //=============================================================================
827 SMESHGUI::SMESHGUI() :
828 SalomeApp_Module( "SMESH" )
830 if ( CORBA::is_nil( myComponentSMESH ) )
832 CORBA::Boolean anIsEmbeddedMode;
833 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
836 myActiveDialogBox = 0;
840 SMESH::GetFilterManager();
843 /* load resources for all available meshers */
844 SMESH::InitAvailableHypotheses();
847 //=============================================================================
851 //=============================================================================
852 SMESHGUI::~SMESHGUI()
854 SMESH::GetFilterManager()->Destroy();
855 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
858 //=============================================================================
862 //=============================================================================
863 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
865 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
867 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
872 bool SMESHGUI::automaticUpdate()
874 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
878 return resMgr->booleanValue( "SMESH", "auto_update", false );
881 //=============================================================================
885 //=============================================================================
886 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
888 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
891 //=============================================================================
895 //=============================================================================
896 SMESHGUI* SMESHGUI::GetSMESHGUI()
898 SMESHGUI* smeshMod = 0;
899 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
902 CAM_Module* module = app->module( "Mesh" );
903 smeshMod = dynamic_cast<SMESHGUI*>( module );
906 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
908 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
911 _PTR(Study) aStudy = study->studyDS();
913 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
922 Standard_EXPORT SMESHGUI* GetComponentGUI()
924 return SMESHGUI::GetSMESHGUI();
928 //=============================================================================
932 //=============================================================================
933 void SMESHGUI::SetState(int aState)
938 //=============================================================================
942 //=============================================================================
943 void SMESHGUI::ResetState()
948 //=============================================================================
952 //=============================================================================
953 void SMESHGUI::EmitSignalDeactivateDialog()
955 emit SignalDeactivateActiveDialog();
958 //=============================================================================
962 //=============================================================================
963 void SMESHGUI::EmitSignalStudyFrameChanged()
965 emit SignalStudyFrameChanged();
968 //=============================================================================
972 //=============================================================================
973 void SMESHGUI::EmitSignalCloseAllDialogs()
975 emit SignalCloseAllDialogs();
978 //=============================================================================
982 //=============================================================================
983 QDialog *SMESHGUI::GetActiveDialogBox()
985 return myActiveDialogBox;
988 //=============================================================================
992 //=============================================================================
993 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
995 myActiveDialogBox = (QDialog *) aDlg;
999 //=============================================================================
1003 //=============================================================================
1004 SUIT_Desktop* SMESHGUI::desktop()
1006 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1008 return app->desktop();
1013 //=============================================================================
1017 //=============================================================================
1018 SalomeApp_Study* SMESHGUI::activeStudy()
1020 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1022 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1027 //=============================================================================
1031 //=============================================================================
1032 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1034 /* Here the position is on the bottom right corner - 10 */
1035 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1037 SUIT_Desktop *PP = desktop();
1038 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1039 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1043 //=============================================================================
1047 //=============================================================================
1048 static int isStudyLocked(_PTR(Study) theStudy){
1049 return theStudy->GetProperties()->IsLocked();
1052 static bool checkLock(_PTR(Study) theStudy) {
1053 if (isStudyLocked(theStudy)) {
1054 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1055 QObject::tr("WRN_WARNING"),
1056 QObject::tr("WRN_STUDY_LOCKED"),
1057 QObject::tr("BUT_OK") );
1063 //=======================================================================
1064 //function : CheckActiveStudyLocked
1066 //=======================================================================
1068 bool SMESHGUI::isActiveStudyLocked()
1070 _PTR(Study) aStudy = activeStudy()->studyDS();
1071 return checkLock( aStudy );
1074 //=============================================================================
1078 //=============================================================================
1079 bool SMESHGUI::OnGUIEvent( int theCommandID )
1081 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1085 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1086 SUIT_ResourceMgr* mgr = resourceMgr();
1090 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1091 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1094 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1095 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1097 //QAction* act = action( theCommandID );
1099 switch (theCommandID) {
1101 if(checkLock(aStudy)) break;
1109 if(checkLock(aStudy)) break;
1110 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1114 case 122: // EXPORT MED
1121 ::ExportMeshToFile(theCommandID);
1125 case 200: // SCALAR BAR
1127 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1128 SALOME_ListIO selected;
1130 aSel->selectedObjects( selected );
1132 if( selected.Extent() ) {
1133 Handle(SALOME_InteractiveObject) anIO = selected.First();
1134 if( anIO->hasEntry() ) {
1135 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1136 anActor->SetControlMode( SMESH_Actor::eNone );
1144 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1148 case 1134: // Clipping
1149 case 1133: // Tranparency
1150 case 1132: // Colors / Size
1157 ::SetDisplayMode(theCommandID);
1163 case 219: // Volumes
1164 case 220: // All Entity
1165 ::SetDisplayEntity(theCommandID);
1170 if(checkLock(aStudy)) break;
1171 SMESH::UpdateView();
1174 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1175 aSel->selectedObjects( l );
1176 aSel->setSelectedObjects( l );
1181 case 301: // DISPLAY
1182 case 302: // DISPLAY ONLY
1184 SMESH::EDisplaing anAction;
1185 switch (theCommandID) {
1186 case 300: anAction = SMESH::eErase; break;
1187 case 301: anAction = SMESH::eDisplay; break;
1188 case 302: anAction = SMESH::eDisplayOnly; break;
1191 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1192 SALOME_ListIO sel_objects, to_process;
1194 aSel->selectedObjects( sel_objects );
1196 if( theCommandID==302 )
1197 startOperation( myEraseAll );
1199 extractContainers( sel_objects, to_process );
1202 SALOME_ListIteratorOfListIO It( to_process );
1203 for (; It.More(); It.Next()) {
1204 Handle(SALOME_InteractiveObject) IOS = It.Value();
1205 if (IOS->hasEntry()) {
1206 SMESH::UpdateView(anAction, IOS->getEntry());
1207 if (anAction == SMESH::eDisplayOnly)
1208 anAction = SMESH::eDisplay;
1213 if (anAction == SMESH::eErase) {
1215 aSel->setSelectedObjects( l1 );
1218 aSel->setSelectedObjects( to_process );
1224 if(checkLock(aStudy)) break;
1227 EmitSignalDeactivateDialog();
1229 new SMESHGUI_NodesDlg(this);
1232 SUIT_MessageBox::warn1(desktop(),
1233 tr("SMESH_WRN_WARNING"),
1234 tr("SMESH_WRN_VIEWER_VTK"),
1235 tr("SMESH_BUT_OK"));
1240 case 2151: // FILTER
1244 EmitSignalDeactivateDialog();
1245 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1250 case 406: // MOVE NODE
1254 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1255 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1259 if(checkLock(aStudy)) break;
1260 new SMESHGUI_MoveNodesDlg(this);
1264 case 701: // COMPUTE MESH
1266 if(checkLock(aStudy)) break;
1268 LightApp_SelectionMgr *Sel = selectionMgr();
1269 SALOME_ListIO selected; Sel->selectedObjects( selected );
1272 int nbSel = selected.Extent();
1277 SMESH::SMESH_Mesh_var aMesh;
1278 SMESH::SMESH_subMesh_var aSubMesh;
1279 Handle(SALOME_InteractiveObject) IObject = selected.First();
1280 if (IObject->hasEntry()) {
1281 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1282 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1283 if ( aShapeObject->_is_nil() ) {
1288 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1289 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1290 if ( !aSubMesh->_is_nil() )
1291 aMesh = aSubMesh->GetFather();
1293 if (!aMesh->_is_nil()) {
1294 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1295 // SUIT_MessageBox::warn1(desktop(),
1296 // tr("SMESH_WRN_WARNING"),
1297 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1298 // tr("SMESH_BUT_OK"));
1301 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1302 if ( errors->length() > 0 ) {
1303 SUIT_MessageBox::warn1(desktop(),
1304 tr("SMESH_WRN_WARNING"),
1305 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1306 tr("SMESH_BUT_OK"));
1310 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1311 SMESH::ModifiedMesh(aMeshSObj,true);
1313 SUIT_MessageBox::warn1(desktop(),
1314 tr("SMESH_WRN_WARNING"),
1315 tr("SMESH_WRN_COMPUTE_FAILED"),
1316 tr("SMESH_BUT_OK"));
1318 catch(const SALOME::SALOME_Exception & S_ex){
1319 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1324 CORBA::Long anId = aStudy->StudyId();
1325 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1326 if ( automaticUpdate() && aVisualObj){
1327 aVisualObj->Update();
1328 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1330 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1332 SMESH::DisplayActor(view,anActor); //apo
1336 SMESH::RepaintCurrentView();
1339 SUIT_MessageBox::warn1(desktop(),
1340 tr("SMESH_WRN_WARNING"),
1341 tr("SMESH_WRN_VIEWER_VTK"),
1342 tr("SMESH_BUT_OK"));
1345 Sel->setSelectedObjects( selected );
1349 case 702: // Create mesh
1350 startOperation( 702 );
1352 case 703: // Create sub-mesh
1353 startOperation( 703 );
1355 case 704: // Edit mesh/sub-mesh
1356 startOperation( 704 );
1358 case 407: // DIAGONAL INVERSION
1359 case 408: // Delete diagonal
1363 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1364 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1368 if ( checkLock( aStudy ) )
1371 /*Standard_Boolean aRes;
1372 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1373 if ( aMesh->_is_nil() )
1375 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1376 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1380 EmitSignalDeactivateDialog();
1381 if ( theCommandID == 407 )
1382 new SMESHGUI_TrianglesInversionDlg(this);
1384 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1387 case 409: // Change orientation
1388 case 410: // Union of triangles
1389 case 411: // Cutting of quadrangles
1393 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1394 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1398 if ( checkLock( aStudy ) )
1401 EmitSignalDeactivateDialog();
1402 SMESHGUI_MultiEditDlg* aDlg = NULL;
1403 if ( theCommandID == 409 )
1404 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1405 else if ( theCommandID == 410 )
1406 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1408 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1413 case 412: // Smoothing
1415 if(checkLock(aStudy)) break;
1417 EmitSignalDeactivateDialog();
1418 new SMESHGUI_SmoothingDlg( this );
1421 SUIT_MessageBox::warn1(desktop(),
1422 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1423 tr("SMESH_BUT_OK"));
1427 case 413: // Extrusion
1429 if (checkLock(aStudy)) break;
1431 EmitSignalDeactivateDialog();
1432 new SMESHGUI_ExtrusionDlg ( this );
1434 SUIT_MessageBox::warn1(desktop(),
1435 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1436 tr("SMESH_BUT_OK"));
1440 case 414: // Revolution
1442 if(checkLock(aStudy)) break;
1444 EmitSignalDeactivateDialog();
1445 new SMESHGUI_RevolutionDlg( this );
1448 SUIT_MessageBox::warn1(desktop(),
1449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1450 tr("SMESH_BUT_OK"));
1454 case 415: // Pattern mapping
1456 if ( checkLock( aStudy ) )
1460 EmitSignalDeactivateDialog();
1461 new SMESHGUI_MeshPatternDlg( this );
1464 SUIT_MessageBox::warn1(desktop(),
1465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1466 tr("SMESH_BUT_OK"));
1470 case 416: // Extrusion along a path
1472 if (checkLock(aStudy)) break;
1474 EmitSignalDeactivateDialog();
1475 new SMESHGUI_ExtrusionAlongPathDlg( this );
1477 SUIT_MessageBox::warn1(desktop(),
1478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1479 tr("SMESH_BUT_OK"));
1483 case 801: // CREATE GROUP
1487 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1488 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1492 if(checkLock(aStudy)) break;
1493 EmitSignalDeactivateDialog();
1494 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1496 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1497 SALOME_ListIO selected;
1499 aSel->selectedObjects( selected );
1501 int nbSel = selected.Extent();
1503 // check if mesh is selected
1504 aMesh = SMESH::GetMeshByIO( selected.First() );
1506 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1511 case 802: // CONSTRUCT GROUP
1515 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1516 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1520 if(checkLock(aStudy)) break;
1521 EmitSignalDeactivateDialog();
1523 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1524 SALOME_ListIO selected;
1526 aSel->selectedObjects( selected );
1528 int nbSel = selected.Extent();
1530 // check if submesh is selected
1531 Handle(SALOME_InteractiveObject) IObject = selected.First();
1532 if (IObject->hasEntry()) {
1533 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1535 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1536 if (!aSubMesh->_is_nil()) {
1538 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1539 // get submesh elements list by types
1540 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1541 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1542 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1543 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1544 // create group for each type o elements
1545 QString aName = IObject->getName();
1546 if (aNodes->length() > 0) {
1547 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1548 aGroup->Add(aNodes.inout());
1550 if (aEdges->length() > 0) {
1551 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1552 aGroup->Add(aEdges.inout());
1554 if (aFaces->length() > 0) {
1555 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1556 aGroup->Add(aFaces.inout());
1558 if (aVolumes->length() > 0) {
1559 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1560 aGroup->Add(aVolumes.inout());
1564 }catch(const SALOME::SALOME_Exception & S_ex){
1565 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1574 case 803: // EDIT GROUP
1578 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1579 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1583 if(checkLock(aStudy)) break;
1584 EmitSignalDeactivateDialog();
1586 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1587 SALOME_ListIO selected;
1589 aSel->selectedObjects( selected );
1591 SALOME_ListIteratorOfListIO It (selected);
1592 int nbSelectedGroups = 0;
1593 for ( ; It.More(); It.Next() )
1595 SMESH::SMESH_GroupBase_var aGroup =
1596 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1597 if (!aGroup->_is_nil()) {
1599 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1603 if (nbSelectedGroups == 0)
1605 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1611 case 804: // Add elements to group
1613 if(checkLock(aStudy)) break;
1614 if (myState == 800) {
1615 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1616 if (aDlg) aDlg->onAdd();
1621 case 805: // Remove elements from group
1623 if(checkLock(aStudy)) break;
1624 if (myState == 800) {
1625 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1626 if (aDlg) aDlg->onRemove();
1631 case 810: // Union Groups
1632 case 811: // Intersect groups
1633 case 812: // Cut groups
1637 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1638 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1642 if ( checkLock( aStudy ) )
1645 EmitSignalDeactivateDialog();
1648 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1649 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1650 else aMode = SMESHGUI_GroupOpDlg::CUT;
1652 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1656 case 813: // Delete groups with their contents
1660 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1661 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1665 if ( checkLock( aStudy ) )
1668 EmitSignalDeactivateDialog();
1670 new SMESHGUI_DeleteGroupDlg( this );
1674 case 900: // MESH INFOS
1676 EmitSignalDeactivateDialog();
1677 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1678 SALOME_ListIO selected;
1680 aSel->selectedObjects( selected );
1682 if ( selected.Extent() > 1 ) { // a dlg for each IO
1684 SALOME_ListIteratorOfListIO It (selected);
1685 for ( ; It.More(); It.Next() ) {
1686 IOs.Clear(); IOs.Append( It.Value() );
1687 aSel->setSelectedObjects( IOs );
1688 new SMESHGUI_MeshInfosDlg(this, "", false);
1690 // restore selection
1691 aSel->setSelectedObjects( selected );
1694 new SMESHGUI_MeshInfosDlg(this, "", false);
1698 case 902: // STANDARD MESH INFOS
1700 EmitSignalDeactivateDialog();
1701 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1702 SALOME_ListIO selected;
1704 aSel->selectedObjects( selected );
1706 if ( selected.Extent() > 1 ) { // a dlg for each IO
1708 SALOME_ListIteratorOfListIO It (selected);
1709 for ( ; It.More(); It.Next() ) {
1711 IOs.Append( It.Value() );
1712 aSel->setSelectedObjects( IOs );
1713 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1715 // restore selection
1716 aSel->setSelectedObjects( selected );
1719 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1723 case 1100: // EDIT HYPOTHESIS
1725 if(checkLock(aStudy)) break;
1727 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1728 SALOME_ListIO selected;
1730 aSel->selectedObjects( selected );
1732 int nbSel = selected.Extent();
1735 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1737 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1738 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1739 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1740 if ( !Hyp->_is_nil() )
1742 char* sName = Hyp->GetName();
1743 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1745 aCreator->edit( Hyp.in(), desktop() );
1752 updateObjBrowser( true );
1756 case 1101: // RENAME
1758 if ( checkLock( aStudy ) )
1761 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1762 SALOME_ListIO selected;
1764 aSel->selectedObjects( selected );
1766 SALOME_ListIteratorOfListIO It( selected );
1767 for ( ; It.More(); It.Next() )
1769 Handle(SALOME_InteractiveObject) IObject = It.Value();
1770 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1771 _PTR(GenericAttribute) anAttr;
1772 _PTR(AttributeName) aName;
1775 if ( obj->FindAttribute(anAttr, "AttributeName") )
1778 QString newName = QString(aName->Value().c_str());
1779 newName = LightApp_NameDlg::getName(desktop(), newName);
1780 if ( !newName.isEmpty() )
1782 //old source: aStudy->renameIObject( IObject, newName );
1783 aName->SetValue( newName.latin1() );
1785 // if current object is group update group's name
1786 SMESH::SMESH_GroupBase_var aGroup =
1787 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1788 if (!aGroup->_is_nil() )
1789 aGroup->SetName( newName.latin1() );
1799 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1801 if(checkLock(aStudy)) break;
1802 SUIT_OverrideCursor wc;
1804 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1805 SALOME_ListIO selected;
1807 aSel->selectedObjects( selected, QString::null, false );
1809 SALOME_ListIteratorOfListIO It(selected);
1810 for (int i = 0; It.More(); It.Next(), i++) {
1811 Handle(SALOME_InteractiveObject) IObject = It.Value();
1812 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1815 aSel->setSelectedObjects( l1 );
1820 case 401: // GEOM::EDGE
1821 case 4021: // TRIANGLE
1823 case 4023: // POLYGON
1827 if(checkLock(aStudy)) break;
1829 EmitSignalDeactivateDialog();
1830 SMDSAbs_ElementType type = SMDSAbs_Edge;
1832 switch (theCommandID) {
1833 case 4021: // TRIANGLE
1834 type = SMDSAbs_Face; nbNodes = 3; break;
1836 type = SMDSAbs_Face; nbNodes = 4; break;
1838 type = SMDSAbs_Volume; nbNodes = 4; break;
1839 case 4023: // POLYGON
1840 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1842 type = SMDSAbs_Volume; nbNodes = 8; break;
1843 case 4033: // POLYHEDRE
1844 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1847 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1850 SUIT_MessageBox::warn1(desktop(),
1851 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1852 tr("SMESH_BUT_OK"));
1856 case 4033: // POLYHEDRON
1858 if(checkLock(aStudy)) break;
1860 EmitSignalDeactivateDialog();
1861 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1864 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1865 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1866 tr("SMESH_BUT_OK"));
1870 case 4034: // QUADRATIC EDGE
1871 case 4035: // QUADRATIC TRIANGLE
1872 case 4036: // QUADRATIC QUADRANGLE
1873 case 4037: // QUADRATIC TETRAHEDRON
1874 case 4038: // QUADRATIC PYRAMID
1875 case 4039: // QUADRATIC PENTAHEDRON
1876 case 4040: // QUADRATIC HEXAHEDRON
1878 if(checkLock(aStudy)) break;
1880 EmitSignalDeactivateDialog();
1883 switch (theCommandID) {
1885 type = QUAD_EDGE; break;
1887 type = QUAD_TRIANGLE; break;
1889 type = QUAD_QUADRANGLE; break;
1891 type = QUAD_TETRAHEDRON; break;
1893 type = QUAD_PYRAMID; break;
1895 type = QUAD_PENTAHEDRON; break;
1897 type = QUAD_HEXAHEDRON;
1901 new SMESHGUI_AddQuadraticElementDlg( this, type );
1904 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1905 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1906 tr("SMESH_BUT_OK"));
1910 case 4041: // REMOVES NODES
1912 if(checkLock(aStudy)) break;
1914 EmitSignalDeactivateDialog();
1915 new SMESHGUI_RemoveNodesDlg(this);
1918 SUIT_MessageBox::warn1(desktop(),
1919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1920 tr("SMESH_BUT_OK"));
1924 case 4042: // REMOVES ELEMENTS
1926 if(checkLock(aStudy)) break;
1928 EmitSignalDeactivateDialog();
1929 new SMESHGUI_RemoveElementsDlg(this);
1933 SUIT_MessageBox::warn1(desktop(),
1934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1935 tr("SMESH_BUT_OK"));
1939 case 4051: // RENUMBERING NODES
1941 if(checkLock(aStudy)) break;
1943 EmitSignalDeactivateDialog();
1944 new SMESHGUI_RenumberingDlg( this, "", 0);
1948 SUIT_MessageBox::warn1(desktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4052: // RENUMBERING ELEMENTS
1956 if(checkLock(aStudy)) break;
1958 EmitSignalDeactivateDialog();
1959 new SMESHGUI_RenumberingDlg( this, "", 1);
1963 SUIT_MessageBox::warn1(desktop(),
1964 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1965 tr("SMESH_BUT_OK"));
1969 case 4061: // TRANSLATION
1971 if(checkLock(aStudy)) break;
1973 EmitSignalDeactivateDialog();
1974 new SMESHGUI_TranslationDlg( this );
1977 SUIT_MessageBox::warn1(desktop(),
1978 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1979 tr("SMESH_BUT_OK"));
1983 case 4062: // ROTATION
1985 if(checkLock(aStudy)) break;
1987 EmitSignalDeactivateDialog();
1988 new SMESHGUI_RotationDlg( this );
1991 SUIT_MessageBox::warn1(desktop(),
1992 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1993 tr("SMESH_BUT_OK"));
1997 case 4063: // SYMMETRY
1999 if(checkLock(aStudy)) break;
2001 EmitSignalDeactivateDialog();
2002 new SMESHGUI_SymmetryDlg( this );
2005 SUIT_MessageBox::warn1(desktop(),
2006 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2007 tr("SMESH_BUT_OK"));
2011 case 4064: // SEWING
2013 if(checkLock(aStudy)) break;
2015 EmitSignalDeactivateDialog();
2016 new SMESHGUI_SewingDlg( this );
2019 SUIT_MessageBox::warn1(desktop(),
2020 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2021 tr("SMESH_BUT_OK"));
2025 case 4065: // MERGE NODES
2027 if(checkLock(aStudy)) break;
2029 EmitSignalDeactivateDialog();
2030 new SMESHGUI_MergeNodesDlg( this );
2033 SUIT_MessageBox::warn1(desktop(),
2034 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2035 tr("SMESH_BUT_OK"));
2039 case 4066: // MERGE EQUAL ELEMENTS
2041 if (checkLock(aStudy)) break;
2043 EmitSignalDeactivateDialog();
2044 new SMESHGUI_EditMeshDlg(this,
2045 "SMESH_MERGE_ELEMENTS_TITLE",
2046 "ICON_DLG_MERGE_ELEMENTS",
2047 1); // MergeEqualElemets
2049 SUIT_MessageBox::warn1(desktop(),
2050 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2051 tr("SMESH_BUT_OK"));
2056 case 5105: // Library of selection filters
2058 static QValueList<int> aTypes;
2059 if ( aTypes.isEmpty() )
2061 aTypes.append( SMESH::NODE );
2062 aTypes.append( SMESH::EDGE );
2063 aTypes.append( SMESH::FACE );
2064 aTypes.append( SMESH::VOLUME );
2066 new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2070 case 6017: // CONTROLS
2086 LightApp_SelectionMgr* mgr = selectionMgr();
2087 SALOME_ListIO selected; mgr->selectedObjects( selected );
2089 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2090 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2092 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2093 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2094 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2095 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2096 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2097 ::Control( theCommandID );
2102 SUIT_MessageBox::warn1(desktop(),
2103 tr( "SMESH_WRN_WARNING" ),
2104 tr( "SMESH_BAD_SELECTION" ),
2105 tr( "SMESH_BUT_OK" ) );
2109 SUIT_MessageBox::warn1(desktop(),
2110 tr( "SMESH_WRN_WARNING" ),
2111 tr( "NOT_A_VTK_VIEWER" ),
2112 tr( "SMESH_BUT_OK" ) );
2117 LightApp_SelectionMgr* mgr = selectionMgr();
2118 SALOME_ListIO selected; mgr->selectedObjects( selected );
2120 if (selected.Extent() == 1) {
2121 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2122 if(anIObject->hasEntry())
2123 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2124 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2131 LightApp_SelectionMgr* mgr = selectionMgr();
2132 SALOME_ListIO selected; mgr->selectedObjects( selected );
2134 if (selected.Extent() == 1) {
2135 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2136 if(anIObject->hasEntry())
2137 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2138 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2145 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2146 //updateObjBrowser();
2150 //=============================================================================
2154 //=============================================================================
2155 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2160 //=============================================================================
2164 //=============================================================================
2165 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2170 //=============================================================================
2174 //=============================================================================
2175 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2180 //=============================================================================
2181 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2182 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2184 //=============================================================================
2185 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2186 SUIT_ViewWindow* wnd )
2188 if(theIO->hasEntry()){
2189 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2190 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2194 //=======================================================================
2195 // function : createSMESHAction
2197 //=======================================================================
2198 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2201 QWidget* parent = application()->desktop();
2202 SUIT_ResourceMgr* resMgr = resourceMgr();
2204 if ( icon_id.length() )
2205 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2207 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2208 if ( !pix.isNull() )
2209 icon = QIconSet( pix );
2211 QString tooltip = tr( QString( "TOP_" )+po_id ),
2212 menu = tr( QString( "MEN_" )+po_id ),
2213 status_bar = tr( QString( "STB_" )+po_id );
2215 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2218 //=======================================================================
2219 // function : createPopupItem
2221 //=======================================================================
2222 void SMESHGUI::createPopupItem( const int id,
2223 const QString& clients,
2224 const QString& types,
2225 const QString& theRule,
2230 parentId = popupMgr()->actionId( action( pId ) );
2232 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2233 popupMgr()->insert( action( id ), parentId, 0 );
2235 QChar lc = QtxPopupMgr::Selection::defEquality();
2236 QString rule = "(%1) and (%2) and (%3)";
2237 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2238 if( clients.isEmpty() )
2239 rule = rule.arg( QString( "true" ) );
2241 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2242 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2245 bool cont = myRules.contains( id );
2247 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2249 popupMgr()->setRule( action( id ), rule, true );
2250 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2253 //=======================================================================
2254 // function : initialize
2256 //=======================================================================
2257 void SMESHGUI::initialize( CAM_Application* app )
2259 SalomeApp_Module::initialize( app );
2261 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2263 /* Automatic Update flag */
2264 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2266 // ----- create actions --------------
2268 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2269 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2270 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2271 createSMESHAction( 114, "NUM" );
2272 createSMESHAction( 121, "DAT" );
2273 createSMESHAction( 122, "MED" );
2274 createSMESHAction( 123, "UNV" );
2275 createSMESHAction( 124, "EXPORT_DAT" );
2276 createSMESHAction( 125, "EXPORT_MED" );
2277 createSMESHAction( 126, "EXPORT_UNV" );
2278 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2279 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2280 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2281 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2282 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2283 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2284 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2285 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2286 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2287 createSMESHAction( 804, "ADD" );
2288 createSMESHAction( 805, "REMOVE" );
2289 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2290 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2291 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2292 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2293 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2294 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2295 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2296 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2297 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2298 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2299 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2300 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2301 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2302 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2303 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2304 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2305 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2306 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2307 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2308 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2309 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2310 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2311 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2312 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2313 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2314 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2315 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2316 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2317 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2318 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2319 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2320 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2321 createSMESHAction( 4062, "ROT", "ICON_DLG_ROTATION" );
2322 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2323 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2324 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2325 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2326 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2327 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2328 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2329 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2330 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2331 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2332 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2333 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2334 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2335 createSMESHAction( 415, "MAP", "ICON_MAP" );
2336 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2337 createSMESHAction( 200, "RESET" );
2338 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2339 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2340 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2341 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2342 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2343 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2344 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2345 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2346 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2347 createSMESHAction( 220, "ALL" );
2348 createSMESHAction( 1100, "EDIT_HYPO" );
2349 createSMESHAction( 1101, "RENAME" );
2350 createSMESHAction( 1102, "UNASSIGN" );
2351 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2352 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2353 createSMESHAction( 1131, "DISPMODE" );
2354 createSMESHAction( 1132, "COLORS" );
2355 createSMESHAction( 1133, "TRANSP" );
2356 createSMESHAction( 1134, "CLIP" );
2357 createSMESHAction( 1135, "DISP_ENT" );
2358 createSMESHAction( 2000, "CTRL" );
2360 createSMESHAction( 300, "ERASE" );
2361 createSMESHAction( 301, "DISPLAY" );
2362 createSMESHAction( 302, "DISPLAY_ONLY" );
2363 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2364 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2365 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2366 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2367 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2368 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2369 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2370 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2372 // ----- create menu --------------
2373 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2374 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2375 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2376 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2377 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2378 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2379 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2381 createMenu( separator(), fileId );
2383 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2384 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2385 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2386 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2387 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2388 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2390 createMenu( 111, importId, -1 );
2391 createMenu( 112, importId, -1 );
2392 createMenu( 113, importId, -1 );
2394 createMenu( 121, exportId, -1 );
2395 createMenu( 122, exportId, -1 );
2396 createMenu( 123, exportId, -1 );
2398 createMenu( separator(), fileId, 10 );
2400 createMenu( 33, editId, -1 );
2402 createMenu( 5105, toolsId, -1 );
2404 createMenu( 702, meshId, -1 );
2405 createMenu( 703, meshId, -1 );
2406 createMenu( 704, meshId, -1 );
2407 createMenu( separator(), meshId, -1 );
2408 createMenu( 701, meshId, -1 );
2409 createMenu( separator(), meshId, -1 );
2410 createMenu( 801, meshId, -1 );
2411 createMenu( 802, meshId, -1 );
2412 createMenu( 803, meshId, -1 );
2413 createMenu( separator(), meshId, -1 );
2414 createMenu( 810, meshId, -1 );
2415 createMenu( 811, meshId, -1 );
2416 createMenu( 812, meshId, -1 );
2417 createMenu( separator(), meshId, -1 );
2418 createMenu( 813, meshId, -1 );
2419 createMenu( separator(), meshId, -1 );
2420 createMenu( 900, meshId, -1 );
2421 createMenu( 902, meshId, -1 );
2422 createMenu( separator(), meshId, -1 );
2424 createMenu( 6003, ctrlId, -1 );
2425 createMenu( 6001, ctrlId, -1 );
2426 createMenu( 6004, ctrlId, -1 );
2427 createMenu( separator(), ctrlId, -1 );
2428 createMenu( 6002, ctrlId, -1 );
2429 createMenu( 6018, ctrlId, -1 );
2430 createMenu( 6019, ctrlId, -1 );
2431 createMenu( 6011, ctrlId, -1 );
2432 createMenu( 6012, ctrlId, -1 );
2433 createMenu( 6013, ctrlId, -1 );
2434 createMenu( 6014, ctrlId, -1 );
2435 createMenu( 6015, ctrlId, -1 );
2436 createMenu( 6016, ctrlId, -1 );
2437 createMenu( separator(), ctrlId, -1 );
2438 createMenu( 6017, ctrlId, -1 );
2439 createMenu( 6009, ctrlId, -1 );
2440 createMenu( separator(), ctrlId, -1 );
2442 createMenu( 400, addId, -1 );
2443 createMenu( 401, addId, -1 );
2444 createMenu( 4021, addId, -1 );
2445 createMenu( 4022, addId, -1 );
2446 createMenu( 4023, addId, -1 );
2447 createMenu( 4031, addId, -1 );
2448 createMenu( 4032, addId, -1 );
2449 createMenu( 4033, addId, -1 );
2450 createMenu( separator(), addId, -1 );
2451 createMenu( 4034, addId, -1 );
2452 createMenu( 4035, addId, -1 );
2453 createMenu( 4036, addId, -1 );
2454 createMenu( 4037, addId, -1 );
2455 createMenu( 4038, addId, -1 );
2456 createMenu( 4039, addId, -1 );
2457 createMenu( 4040, addId, -1 );
2459 createMenu( 4041, removeId, -1 );
2460 createMenu( 4042, removeId, -1 );
2462 createMenu( 4051, renumId, -1 );
2463 createMenu( 4052, renumId, -1 );
2465 createMenu( 4061, transfId, -1 );
2466 createMenu( 4062, transfId, -1 );
2467 createMenu( 4063, transfId, -1 );
2468 createMenu( 4064, transfId, -1 );
2469 createMenu( 4065, transfId, -1 );
2470 createMenu( 4066, transfId, -1 );
2472 createMenu( 406, modifyId, -1 );
2473 createMenu( 407, modifyId, -1 );
2474 createMenu( 408, modifyId, -1 );
2475 createMenu( 409, modifyId, -1 );
2476 createMenu( 410, modifyId, -1 );
2477 createMenu( 411, modifyId, -1 );
2478 createMenu( 412, modifyId, -1 );
2479 createMenu( 413, modifyId, -1 );
2480 createMenu( 416, modifyId, -1 );
2481 createMenu( 414, modifyId, -1 );
2482 createMenu( 415, modifyId, -1 );
2484 createMenu( 214, viewId, -1 );
2486 // ----- create toolbars --------------
2487 int meshTb = createTool( tr( "TB_MESH" ) ),
2488 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2489 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2490 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2491 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2493 createTool( 702, meshTb );
2494 createTool( 703, meshTb );
2495 createTool( 704, meshTb );
2496 createTool( separator(), meshTb );
2497 createTool( 701, meshTb );
2498 createTool( separator(), meshTb );
2499 createTool( 801, meshTb );
2500 createTool( 802, meshTb );
2501 createTool( 803, meshTb );
2502 createTool( separator(), meshTb );
2503 createTool( 900, meshTb );
2504 createTool( 902, meshTb );
2505 createTool( separator(), meshTb );
2507 createTool( 6001, ctrlTb );
2508 createTool( 6003, ctrlTb );
2509 createTool( 6004, ctrlTb );
2510 createTool( separator(), ctrlTb );
2511 createTool( 6002, ctrlTb );
2512 createTool( 6018, ctrlTb );
2513 createTool( 6019, ctrlTb );
2514 createTool( 6011, ctrlTb );
2515 createTool( 6012, ctrlTb );
2516 createTool( 6013, ctrlTb );
2517 createTool( 6014, ctrlTb );
2518 createTool( 6015, ctrlTb );
2519 createTool( 6016, ctrlTb );
2520 createTool( separator(), ctrlTb );
2521 createTool( 6017, ctrlTb );
2522 createTool( 6009, ctrlTb );
2523 createTool( separator(), ctrlTb );
2525 createTool( 400, addRemTb );
2526 createTool( 401, addRemTb );
2527 createTool( 4021, addRemTb );
2528 createTool( 4022, addRemTb );
2529 createTool( 4023, addRemTb );
2530 createTool( 4031, addRemTb );
2531 createTool( 4032, addRemTb );
2532 createTool( 4033, addRemTb );
2533 createTool( separator(), addRemTb );
2534 createTool( 4034, addRemTb );
2535 createTool( 4035, addRemTb );
2536 createTool( 4036, addRemTb );
2537 createTool( 4037, addRemTb );
2538 createTool( 4038, addRemTb );
2539 createTool( 4039, addRemTb );
2540 createTool( 4040, addRemTb );
2541 createTool( separator(), addRemTb );
2542 createTool( 4041, addRemTb );
2543 createTool( 4042, addRemTb );
2544 createTool( separator(), addRemTb );
2545 createTool( 4051, addRemTb );
2546 createTool( 4052, addRemTb );
2547 createTool( separator(), addRemTb );
2548 createTool( 4061, addRemTb );
2549 createTool( 4062, addRemTb );
2550 createTool( 4063, addRemTb );
2551 createTool( 4064, addRemTb );
2552 createTool( 4065, addRemTb );
2553 createTool( 4066, addRemTb );
2554 createTool( separator(), addRemTb );
2556 createTool( 406, modifyTb );
2557 createTool( 407, modifyTb );
2558 createTool( 408, modifyTb );
2559 createTool( 409, modifyTb );
2560 createTool( 410, modifyTb );
2561 createTool( 411, modifyTb );
2562 createTool( 412, modifyTb );
2563 createTool( 413, modifyTb );
2564 createTool( 416, modifyTb );
2565 createTool( 414, modifyTb );
2566 createTool( 415, modifyTb );
2568 createTool( 214, dispModeTb );
2572 QString OB = "'ObjectBrowser'",
2573 View = "'" + SVTK_Viewer::Type() + "'",
2575 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2576 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2577 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2578 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2579 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2580 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2581 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2582 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2583 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2584 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2585 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2587 mesh_group = mesh + " " + subMesh + " " + group,
2588 hyp_alg = hypo + " " + algo;
2590 // popup for object browser
2592 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2593 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2594 createPopupItem( 803, OB, group ); // EDIT_GROUP
2595 popupMgr()->insert( separator(), -1, 0 );
2596 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2597 createPopupItem( 214, OB, mesh_group ); // UPDATE
2598 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2599 createPopupItem( 902, OB, mesh ); // STD_INFO
2600 popupMgr()->insert( separator(), -1, 0 );
2601 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2602 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2603 popupMgr()->insert( separator(), -1, 0 );
2604 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2605 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2606 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2607 popupMgr()->insert( separator(), -1, 0 );
2609 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2610 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2611 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2612 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2613 popupMgr()->insert( separator(), -1, 0 );
2616 createPopupItem( 803, View, group ); // EDIT_GROUP
2617 createPopupItem( 804, View, elems ); // ADD
2618 createPopupItem( 805, View, elems ); // REMOVE
2619 popupMgr()->insert( separator(), -1, 0 );
2620 createPopupItem( 214, View, mesh_group ); // UPDATE
2621 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2622 createPopupItem( 902, View, mesh ); // STD_INFO
2623 popupMgr()->insert( separator(), -1, 0 );
2627 isInvisible("not( isVisible )"),
2628 isEmpty("numberOfNodes = 0"),
2629 isNotEmpty("numberOfNodes <> 0"),
2631 // has nodes, edges, etc in VISIBLE! actor
2632 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2633 hasElems("(count( elemTypes ) > 0)"),
2634 hasDifferentElems("(count( elemTypes ) > 1)"),
2635 hasEdges("({'Edge'} in elemTypes)"),
2636 hasFaces("({'Face'} in elemTypes)"),
2637 hasVolumes("({'Volume'} in elemTypes)");
2639 QString lc = QtxPopupMgr::Selection::defEquality();
2640 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2641 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2642 aType = aType.arg( mesh_group );
2643 QString aMeshInVTK = aClient + "&&" + aType;
2645 //-------------------------------------------------
2647 //-------------------------------------------------
2648 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2650 popupMgr()->insert( action( 9010 ), anId, -1 );
2651 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2652 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2654 popupMgr()->insert( action( 9011 ), anId, -1 );
2655 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2656 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2658 popupMgr()->insert( separator(), -1, -1 );
2660 //-------------------------------------------------
2662 //-------------------------------------------------
2663 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2665 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2666 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2667 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2669 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2670 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2671 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2673 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2674 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2675 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2677 popupMgr()->insert( separator(), anId, -1 );
2679 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2680 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2681 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2683 //-------------------------------------------------
2685 //-------------------------------------------------
2686 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2688 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2690 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2691 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2692 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2694 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2695 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2696 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2698 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2699 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2700 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2702 popupMgr()->insert( separator(), anId, -1 );
2704 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2705 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2707 //-------------------------------------------------
2709 //-------------------------------------------------
2710 popupMgr()->insert( action( 1132 ), -1, -1 );
2711 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2713 //-------------------------------------------------
2715 //-------------------------------------------------
2716 popupMgr()->insert( action( 1133 ), -1, -1 );
2717 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2719 //-------------------------------------------------
2721 //-------------------------------------------------
2722 popupMgr()->insert( action( 1134 ), -1, -1 );
2723 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2725 popupMgr()->insert( separator(), -1, -1 );
2727 //-------------------------------------------------
2729 //-------------------------------------------------
2731 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2732 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2733 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2735 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2737 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2738 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2740 popupMgr()->insert( separator(), anId, -1 );
2742 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2743 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2744 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeEdges'", false );
2746 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2747 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2748 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2750 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2751 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2752 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2754 popupMgr()->insert( separator(), anId, -1 );
2756 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2757 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2758 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeBorders'", false );
2760 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2761 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2762 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2764 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2765 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2766 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2768 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2769 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2770 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2772 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2773 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2774 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2776 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2777 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2778 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2780 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2781 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2782 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2784 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2785 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2786 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2788 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2789 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2790 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2792 popupMgr()->insert( separator(), anId, -1 );
2794 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2795 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2796 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2798 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2799 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2800 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2802 popupMgr()->insert( separator(), anId, -1 );
2804 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2805 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2807 popupMgr()->insert( separator(), -1, -1 );
2809 //-------------------------------------------------
2811 //-------------------------------------------------
2812 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2813 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2814 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2816 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2817 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2818 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2819 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2821 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2822 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2824 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2825 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2827 popupMgr()->insert( separator(), -1, -1 );
2829 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2830 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2833 bool SMESHGUI::activateModule( SUIT_Study* study )
2835 bool res = SalomeApp_Module::activateModule( study );
2837 setMenuShown( true );
2838 setToolShown( true );
2843 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2845 setMenuShown( false );
2846 setToolShown( false );
2848 EmitSignalCloseAllDialogs();
2850 return SalomeApp_Module::deactivateModule( study );
2853 void SMESHGUI::OnGUIEvent()
2855 const QObject* obj = sender();
2856 if ( !obj || !obj->inherits( "QAction" ) )
2858 int id = actionId((QAction*)obj);
2863 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2865 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2866 if ( CORBA::is_nil( myComponentSMESH ) )
2868 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2870 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2871 return aGUI.myComponentSMESH;
2874 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2875 return myComponentSMESH;
2878 QString SMESHGUI::engineIOR() const
2880 CORBA::ORB_var anORB = getApp()->orb();
2881 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2885 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2887 SMESHGUI_Selection sel;
2888 sel.init( client, selectionMgr() );
2889 popupMgr()->updatePopup( menu, &sel );
2892 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2894 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2895 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2898 void SMESHGUI::viewManagers( QStringList& list ) const
2900 list.append( SVTK_Viewer::Type() );
2903 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2905 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2906 SMESH::UpdateSelectionProp( this );
2909 void SMESHGUI::createPreferences()
2911 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2913 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2914 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2916 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2917 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2918 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2920 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2921 setPreferenceProperty( precGroup, "columns", 1 );
2923 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2925 setPreferenceProperty( prec, "min", 0 );
2926 setPreferenceProperty( prec, "max", 16 );
2928 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2929 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2931 modes.append( "Wireframe" );
2932 modes.append( "Shading" );
2933 modes.append( "Nodes" );
2934 modes.append( "Shrink" );
2935 QValueList<QVariant> indices;
2936 indices.append( 0 );
2937 indices.append( 1 );
2938 indices.append( 2 );
2939 indices.append( 3 );
2940 setPreferenceProperty( dispmode, "strings", modes );
2941 setPreferenceProperty( dispmode, "indexes", indices );
2943 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2944 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2946 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2947 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2949 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2950 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2952 setPreferenceProperty( nodeSz, "min", 1 );
2953 setPreferenceProperty( nodeSz, "max", 5 );
2955 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2957 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2958 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2959 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2960 addPreference( "", elemGroup, LightApp_Preferences::Space );
2962 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2963 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2965 setPreferenceProperty( elemW, "min", 1 );
2966 setPreferenceProperty( elemW, "max", 5 );
2968 setPreferenceProperty( shrink, "min", 0 );
2969 setPreferenceProperty( shrink, "max", 100 );
2971 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
2973 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
2975 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
2976 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
2977 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
2979 setPreferenceProperty( selW, "min", 1 );
2980 setPreferenceProperty( selW, "max", 5 );
2982 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
2984 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
2985 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
2987 setPreferenceProperty( preW, "min", 1 );
2988 setPreferenceProperty( preW, "max", 5 );
2990 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
2992 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
2993 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
2995 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
2996 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
2998 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
2999 addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3000 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3001 addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3004 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3005 fam.append( tr( "SMESH_FONT_COURIER" ) );
3006 fam.append( tr( "SMESH_FONT_TIMES" ) );
3007 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3009 setPreferenceProperty( tfont, "families", fam );
3010 setPreferenceProperty( tfont, "system", false );
3011 setPreferenceProperty( tfont, "widget_flags", wflag );
3012 setPreferenceProperty( lfont, "families", fam );
3013 setPreferenceProperty( lfont, "system", false );
3014 setPreferenceProperty( lfont, "widget_flags", wflag );
3016 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3018 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3019 setPreferenceProperty( numcol, "min", 2 );
3020 setPreferenceProperty( numcol, "max", 256 );
3022 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3023 setPreferenceProperty( numlab, "min", 2 );
3024 setPreferenceProperty( numlab, "max", 65 );
3026 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3027 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3028 QStringList orients;
3029 orients.append( tr( "SMESH_VERTICAL" ) );
3030 orients.append( tr( "SMESH_HORIZONTAL" ) );
3031 indices.clear(); indices.append( 0 ); indices.append( 1 );
3032 setPreferenceProperty( orient, "strings", orients );
3033 setPreferenceProperty( orient, "indexes", indices );
3035 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3036 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3037 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3038 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3039 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3040 setPreferenceProperty( xv, "step", 0.1 );
3041 setPreferenceProperty( xv, "min", 0.0 );
3042 setPreferenceProperty( xv, "max", 1.0 );
3043 setPreferenceProperty( yv, "step", 0.1 );
3044 setPreferenceProperty( yv, "min", 0.0 );
3045 setPreferenceProperty( yv, "max", 1.0 );
3046 setPreferenceProperty( wv, "step", 0.1 );
3047 setPreferenceProperty( wv, "min", 0.0 );
3048 setPreferenceProperty( wv, "max", 1.0 );
3049 setPreferenceProperty( hv, "min", 0.0 );
3050 setPreferenceProperty( hv, "max", 1.0 );
3051 setPreferenceProperty( hv, "step", 0.1 );
3053 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3054 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3055 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3056 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3057 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3058 setPreferenceProperty( xv, "min", 0.0 );
3059 setPreferenceProperty( xv, "max", 1.0 );
3060 setPreferenceProperty( xv, "step", 0.1 );
3061 setPreferenceProperty( xh, "min", 0.0 );
3062 setPreferenceProperty( xh, "max", 1.0 );
3063 setPreferenceProperty( xh, "step", 0.1 );
3064 setPreferenceProperty( yh, "min", 0.0 );
3065 setPreferenceProperty( yh, "max", 1.0 );
3066 setPreferenceProperty( yh, "step", 0.1 );
3067 setPreferenceProperty( wh, "min", 0.0 );
3068 setPreferenceProperty( wh, "max", 1.0 );
3069 setPreferenceProperty( wh, "step", 0.1 );
3070 setPreferenceProperty( hh, "min", 0.0 );
3071 setPreferenceProperty( hh, "max", 1.0 );
3072 setPreferenceProperty( hh, "step", 0.1 );
3075 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3077 if( sect=="SMESH" ){
3078 float sbX1,sbY1,sbW,sbH;
3079 float aTol = 1.00000009999999;
3080 std::string aWarning;
3081 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3082 if( name=="selection_object_color" || name=="selection_element_color" ||
3083 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3084 name=="selection_precision_node" || name=="selection_precision_element" )
3085 SMESH::UpdateSelectionProp( this );
3086 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3087 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3088 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3089 if(sbX1+sbW > aTol){
3090 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3093 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3094 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3097 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3098 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3099 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3100 if(sbY1+sbH > aTol){
3101 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3104 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3105 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3108 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3109 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3110 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3111 if(sbX1+sbW > aTol){
3112 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3115 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3116 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3119 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3120 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3121 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3122 if(sbY1+sbH > aTol){
3123 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3126 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3127 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3131 if(aWarning.size() != 0){
3132 aWarning += "The default values are applied instead.";
3133 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3134 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3135 QObject::tr(aWarning.c_str()),
3136 QObject::tr("SMESH_BUT_OK"));
3141 //================================================================================
3143 * \brief Update something in accordance with update flags
3144 * \param theFlags - update flags
3146 * Update viewer or/and object browser etc. in accordance with update flags ( see
3147 * LightApp_UpdateFlags enumeration ).
3149 //================================================================================
3150 void SMESHGUI::update( const int flags )
3152 if ( flags & UF_Viewer | flags & UF_Forced )
3153 SMESH::UpdateView();
3155 SalomeApp_Module::update( flags );
3158 //================================================================================
3160 * \brief Set default selection mode
3162 * SLOT called when operation commited. Sets default selection mode
3164 //================================================================================
3165 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3167 SVTK_ViewWindow* vtkWnd =
3168 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3170 vtkWnd->SetSelectionMode( ActorSelection );
3173 //================================================================================
3175 * \brief Set default selection mode
3177 * SLOT called when operation aborted. Sets default selection mode
3179 //================================================================================
3180 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3182 SVTK_ViewWindow* vtkWnd =
3183 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3185 vtkWnd->SetSelectionMode( ActorSelection );
3188 //================================================================================
3190 * \brief Creates operation with given identifier
3191 * \param id - identifier of operation to be started
3192 * \return Pointer on created operation or NULL if operation is not created
3194 * Virtual method redefined from the base class creates operation with given id.
3195 * It is called called automatically from startOperation method of base class.
3197 //================================================================================
3198 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3200 LightApp_Operation* op = 0;
3201 // to do : create operation here
3204 case 702: // Create mesh
3205 op = new SMESHGUI_MeshOp( true, true );
3207 case 703: // Create sub-mesh
3208 op = new SMESHGUI_MeshOp( true, false );
3210 case 704: // Edit mesh/sub-mesh
3211 op = new SMESHGUI_MeshOp( false );
3218 op = SalomeApp_Module::createOperation( id );
3222 //================================================================================
3224 * \brief Stops current operations and starts a given one
3225 * \param id - The id of the operation to start
3227 //================================================================================
3229 void SMESHGUI::switchToOperation(int id)
3231 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3232 activeStudy()->abortAllOperations();
3233 startOperation( id );
3236 LightApp_Displayer* SMESHGUI::displayer()
3239 myDisplayer = new SMESHGUI_Displayer( getApp() );