1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_GEOMGenUtils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
79 #include "SMESH_Actor.h"
80 #include "SMESH_Object.h"
81 #include "SMESH_TypeFilter.hxx"
83 #include "SalomeApp_Tools.h"
84 #include "SalomeApp_Study.h"
85 #include "SalomeApp_Application.h"
86 #include "SalomeApp_CheckFileDlg.h"
87 #include "SalomeApp_ImportOperation.h"
89 #include "LightApp_DataOwner.h"
90 #include "LightApp_Preferences.h"
91 #include "LightApp_VTKSelector.h"
92 #include "LightApp_Operation.h"
93 #include "LightApp_UpdateFlags.h"
94 #include "LightApp_NameDlg.h"
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_InteractorStyle.h>
99 #include <SVTK_RenderWindowInteractor.h>
100 #include <SVTK_ViewManager.h>
102 #include "OB_Browser.h"
104 #include "SUIT_Tools.h"
105 #include "SUIT_MessageBox.h"
106 #include "SUIT_ResourceMgr.h"
107 #include "SUIT_FileDlg.h"
108 #include "SUIT_Desktop.h"
109 #include "SUIT_OverrideCursor.h"
110 #include "SUIT_Study.h"
111 #include "SUIT_Session.h"
113 #include "QtxPopupMgr.h"
115 #include "SALOME_ListIO.hxx"
116 #include "SALOME_ListIteratorOfListIO.hxx"
117 #include "SALOME_InteractiveObject.hxx"
118 #include "SALOME_NamingService.hxx"
119 #include "SALOME_LifeCycleCORBA.hxx"
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
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;
359 bool Renumber = false ;
360 // PAL 14172 : Check of we have to renumber or not from the preferences before export
362 Renumber= resMgr->booleanValue("SMESH","renumbering");
364 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
365 aMeshEditor->RenumberNodes();
366 aMeshEditor->RenumberElements();
367 if ( SMESHGUI::automaticUpdate() )
370 switch ( theCommandID ) {
373 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
377 aMesh->ExportDAT( aFilename.latin1() );
381 aMesh->ExportUNV( aFilename.latin1() );
387 catch (const SALOME::SALOME_Exception& S_ex){
389 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
390 QObject::tr("SMESH_WRN_WARNING"),
391 QObject::tr("SMESH_EXPORT_FAILED"),
392 QObject::tr("SMESH_BUT_OK"));
400 inline void InverseEntityMode(unsigned int& theOutputMode,
401 unsigned int theMode)
403 bool anIsNotPresent = ~theOutputMode & theMode;
405 theOutputMode |= theMode;
407 theOutputMode &= ~theMode;
410 void SetDisplayEntity(int theCommandID){
411 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
412 SALOME_ListIO selected;
414 aSel->selectedObjects( selected );
416 if(selected.Extent() >= 1){
417 SALOME_ListIteratorOfListIO It( selected );
418 for(; It.More(); It.Next()){
419 Handle(SALOME_InteractiveObject) IObject = It.Value();
420 if(IObject->hasEntry()){
421 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
422 unsigned int aMode = anActor->GetEntityMode();
423 switch(theCommandID){
425 InverseEntityMode(aMode,SMESH_Actor::eEdges);
428 InverseEntityMode(aMode,SMESH_Actor::eFaces);
431 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
434 aMode = SMESH_Actor::eAllEntity;
438 anActor->SetEntityMode(aMode);
445 void SetDisplayMode(int theCommandID){
446 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
447 SALOME_ListIO selected;
449 aSel->selectedObjects( selected );
451 if(selected.Extent() >= 1){
452 switch(theCommandID){
454 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
455 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
459 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
460 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
463 SALOME_ListIteratorOfListIO It( selected );
464 for(; It.More(); It.Next()){
465 Handle(SALOME_InteractiveObject) IObject = It.Value();
466 if(IObject->hasEntry()){
467 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
468 switch(theCommandID){
470 anActor->SetRepresentation(SMESH_Actor::eEdge);
473 anActor->SetRepresentation(SMESH_Actor::eSurface);
476 if(anActor->IsShrunk())
479 anActor->SetShrink();
482 anActor->SetRepresentation(SMESH_Actor::ePoint);
485 vtkFloatingPointType color[3];
486 anActor->GetSufaceColor(color[0], color[1], color[2]);
487 int c0 = int (color[0] * 255);
488 int c1 = int (color[1] * 255);
489 int c2 = int (color[2] * 255);
490 QColor c(c0, c1, c2);
492 vtkFloatingPointType edgecolor[3];
493 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
494 c0 = int (edgecolor[0] * 255);
495 c1 = int (edgecolor[1] * 255);
496 c2 = int (edgecolor[2] * 255);
497 QColor e(c0, c1, c2);
499 vtkFloatingPointType backfacecolor[3];
500 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
501 c0 = int (backfacecolor[0] * 255);
502 c1 = int (backfacecolor[1] * 255);
503 c2 = int (backfacecolor[2] * 255);
504 QColor b(c0, c1, c2);
506 vtkFloatingPointType nodecolor[3];
507 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
508 c0 = int (nodecolor[0] * 255);
509 c1 = int (nodecolor[1] * 255);
510 c2 = int (nodecolor[2] * 255);
511 QColor n(c0, c1, c2);
513 int Edgewidth = (int)anActor->GetLineWidth();
516 int intValue = int(anActor->GetNodeSize());
517 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
519 SMESHGUI_Preferences_ColorDlg *aDlg =
520 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
521 aDlg->SetColor(1, c);
522 aDlg->SetColor(2, e);
523 aDlg->SetColor(3, n);
524 aDlg->SetColor(4, b);
525 aDlg->SetIntValue(1, Edgewidth);
526 aDlg->SetIntValue(2, intValue);
527 aDlg->SetIntValue(3, int(Shrink*100.));
529 QColor color = aDlg->GetColor(1);
530 QColor edgecolor = aDlg->GetColor(2);
531 QColor nodecolor = aDlg->GetColor(3);
532 QColor backfacecolor = aDlg->GetColor(4);
533 /* actor color and backface color */
534 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
535 vtkFloatingPointType (color.green()) / 255.,
536 vtkFloatingPointType (color.blue()) / 255.);
537 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
538 vtkFloatingPointType (backfacecolor.green()) / 255.,
539 vtkFloatingPointType (backfacecolor.blue()) / 255.);
542 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
543 vtkFloatingPointType (edgecolor.green()) / 255.,
544 vtkFloatingPointType (edgecolor.blue()) / 255.);
546 /* Shrink factor and size edges */
547 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
548 anActor->SetLineWidth(aDlg->GetIntValue(1));
550 /* Nodes color and size */
551 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
552 vtkFloatingPointType (nodecolor.green()) / 255.,
553 vtkFloatingPointType (nodecolor.blue()) / 255.);
554 anActor->SetNodeSize(aDlg->GetIntValue(2));
563 SMESH::RepaintCurrentView();
567 void Control( int theCommandID )
569 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
570 SALOME_ListIO selected;
572 aSel->selectedObjects( selected );
574 if( !selected.IsEmpty() ){
575 Handle(SALOME_InteractiveObject) anIO = selected.First();
578 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
579 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
580 switch ( theCommandID ){
582 aTitle = QObject::tr( "LENGTH_EDGES" );
583 aControl = SMESH_Actor::eLength;
586 aTitle = QObject::tr( "LENGTH2D_EDGES" );
587 aControl = SMESH_Actor::eLength2D;
590 aTitle = QObject::tr( "FREE_EDGES" );
591 aControl = SMESH_Actor::eFreeEdges;
594 aTitle = QObject::tr( "FREE_BORDERS" );
595 aControl = SMESH_Actor::eFreeBorders;
598 aTitle = QObject::tr( "MULTI_BORDERS" );
599 aControl = SMESH_Actor::eMultiConnection;
602 aTitle = QObject::tr( "MULTI2D_BORDERS" );
603 aControl = SMESH_Actor::eMultiConnection2D;
606 aTitle = QObject::tr( "AREA_ELEMENTS" );
607 aControl = SMESH_Actor::eArea;
610 aTitle = QObject::tr( "TAPER_ELEMENTS" );
611 aControl = SMESH_Actor::eTaper;
614 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
615 aControl = SMESH_Actor::eAspectRatio;
618 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
619 aControl = SMESH_Actor::eAspectRatio3D;
622 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
623 aControl = SMESH_Actor::eMinimumAngle;
626 aTitle = QObject::tr( "WARP_ELEMENTS" );
627 aControl = SMESH_Actor::eWarping;
630 aTitle = QObject::tr( "SKEW_ELEMENTS" );
631 aControl = SMESH_Actor::eSkew;
634 aTitle = QObject::tr( "SMESH_VOLUME" );
635 aControl = SMESH_Actor::eVolume3D;
638 anActor->SetControlMode(aControl);
639 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
640 SMESH::RepaintCurrentView();
647 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
648 MeshObjectType theType,
649 const QString theInTypeName,
650 QString & theOutTypeName)
652 SMESH_TypeFilter aTypeFilter( theType );
654 if( !theIO.IsNull() )
656 entry = theIO->getEntry();
657 LightApp_DataOwner owner( entry );
658 if ( aTypeFilter.isOk( &owner )) {
659 theOutTypeName = theInTypeName;
667 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
669 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
670 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
672 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
673 CORBA::String_var anID = aSComp->GetID().c_str();
674 if (!strcmp(anID.in(),theIO->getEntry()))
680 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
681 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
682 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
683 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
684 CheckOIType ( theIO, GROUP, "Group", aTypeName )
692 QString CheckHomogeneousSelection()
694 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
695 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
696 SALOME_ListIO selected;
698 aSel->selectedObjects( selected );
700 QString RefType = CheckTypeObject(selected.First());
701 SALOME_ListIteratorOfListIO It(selected);
702 for (; It.More(); It.Next())
704 Handle(SALOME_InteractiveObject) IObject = It.Value();
705 QString Type = CheckTypeObject(IObject);
706 if (Type.compare(RefType) != 0)
707 return "Heterogeneous Selection";
714 void SMESHGUI::OnEditDelete()
716 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
717 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
718 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
720 QString aParentComponent = QString::null;
721 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
723 QString cur = anIt.Value()->getComponentDataType();
724 if( aParentComponent.isNull() )
725 aParentComponent = cur;
726 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
727 aParentComponent = "";
730 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
731 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
732 QObject::tr("ERR_ERROR"),
733 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
734 QObject::tr("BUT_OK") );
737 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
738 if (SUIT_MessageBox::warn2
739 (SMESHGUI::desktop(),
740 QObject::tr("SMESH_WRN_WARNING"),
741 QObject::tr("SMESH_REALLY_DELETE"),
742 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
745 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
746 SUIT_ViewManager* vm = anApp->activeViewManager();
747 int nbSf = vm->getViewsCount();
749 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
750 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
751 _PTR(GenericAttribute) anAttr;
752 _PTR(AttributeIOR) anIOR;
754 SALOME_ListIteratorOfListIO It(selected);
756 aStudyBuilder->NewCommand(); // There is a transaction
757 for(; It.More(); It.Next()){ // loop on selected IO's
758 Handle(SALOME_InteractiveObject) IObject = It.Value();
759 if(IObject->hasEntry()) {
760 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
762 // disable removal of "SMESH" component object
763 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
765 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
769 // put the whole hierarchy of sub-objects of the selected SO into a list and
770 // then treat them all starting from the deepest objects (at list back)
772 list< _PTR(SObject) > listSO;
773 listSO.push_back( aSO );
774 list< _PTR(SObject) >::iterator itSO = listSO.begin();
775 for ( ; itSO != listSO.end(); ++itSO ) {
776 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
777 for (it->InitEx(false); it->More(); it->Next())
778 listSO.push_back( it->Value() );
781 // treat SO's in the list starting from the back
783 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
784 for ( ; ritSO != listSO.rend(); ++ritSO ) {
785 _PTR(SObject) SO = *ritSO;
787 string anEntry = SO->GetID();
789 /** Erase graphical object **/
790 if(SO->FindAttribute(anAttr, "AttributeIOR")){
791 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
792 for(int i = 0; i < nbSf; i++){
793 SUIT_ViewWindow *sf = aViews[i];
794 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
795 SMESH::RemoveActor(sf,anActor);
800 /** Remove an object from data structures **/
801 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
802 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
803 if ( !aGroup->_is_nil() ) { // DELETE GROUP
804 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
805 aMesh->RemoveGroup( aGroup );
807 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
808 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
809 aMesh->RemoveSubMesh( aSubMesh );
811 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
813 SMESH::ModifiedMesh(aMeshSO, false);
816 IObject = new SALOME_InteractiveObject
817 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
818 QString objType = CheckTypeObject(IObject);
819 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
820 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
821 aStudyBuilder->RemoveObjectWithChildren( SO );
823 else {// default action: remove SObject from the study
824 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
825 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
827 aStudyBuilder->RemoveObjectWithChildren( SO );
831 } /* listSO back loop */
832 } /* IObject->hasEntry() */
834 aStudyBuilder->CommitCommand();
836 /* Clear any previous selection */
838 aSel->setSelectedObjects( l1 );
840 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
845 Standard_EXPORT CAM_Module* createModule()
847 return new SMESHGUI();
851 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
853 //=============================================================================
857 //=============================================================================
858 SMESHGUI::SMESHGUI() :
859 SalomeApp_Module( "SMESH" )
861 if ( CORBA::is_nil( myComponentSMESH ) )
863 CORBA::Boolean anIsEmbeddedMode;
864 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
867 myActiveDialogBox = 0;
868 myFilterLibraryDlg = 0;
872 SMESH::GetFilterManager();
875 /* load resources for all available meshers */
876 SMESH::InitAvailableHypotheses();
879 //=============================================================================
883 //=============================================================================
884 SMESHGUI::~SMESHGUI()
886 SMESH::GetFilterManager()->Destroy();
887 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
890 //=============================================================================
894 //=============================================================================
895 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
897 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
899 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
904 bool SMESHGUI::automaticUpdate()
906 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
910 return resMgr->booleanValue( "SMESH", "auto_update", false );
913 //=============================================================================
917 //=============================================================================
918 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
920 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
923 //=============================================================================
927 //=============================================================================
928 SMESHGUI* SMESHGUI::GetSMESHGUI()
930 SMESHGUI* smeshMod = 0;
931 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
934 CAM_Module* module = app->module( "Mesh" );
935 smeshMod = dynamic_cast<SMESHGUI*>( module );
938 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
940 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
943 _PTR(Study) aStudy = study->studyDS();
945 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
954 Standard_EXPORT SMESHGUI* GetComponentGUI()
956 return SMESHGUI::GetSMESHGUI();
960 //=============================================================================
964 //=============================================================================
965 void SMESHGUI::SetState(int aState)
970 //=============================================================================
974 //=============================================================================
975 void SMESHGUI::ResetState()
980 //=============================================================================
984 //=============================================================================
985 void SMESHGUI::EmitSignalDeactivateDialog()
987 emit SignalDeactivateActiveDialog();
990 //=============================================================================
994 //=============================================================================
995 void SMESHGUI::EmitSignalStudyFrameChanged()
997 emit SignalStudyFrameChanged();
1000 //=============================================================================
1004 //=============================================================================
1005 void SMESHGUI::EmitSignalCloseAllDialogs()
1007 emit SignalCloseAllDialogs();
1010 //=============================================================================
1014 //=============================================================================
1015 QDialog *SMESHGUI::GetActiveDialogBox()
1017 return myActiveDialogBox;
1020 //=============================================================================
1024 //=============================================================================
1025 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1027 myActiveDialogBox = (QDialog *) aDlg;
1031 //=============================================================================
1035 //=============================================================================
1036 SUIT_Desktop* SMESHGUI::desktop()
1038 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1040 return app->desktop();
1045 //=============================================================================
1049 //=============================================================================
1050 SalomeApp_Study* SMESHGUI::activeStudy()
1052 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1054 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1059 //=============================================================================
1063 //=============================================================================
1064 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1066 /* Here the position is on the bottom right corner - 10 */
1067 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1069 SUIT_Desktop *PP = desktop();
1070 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1071 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1075 //=============================================================================
1079 //=============================================================================
1080 static int isStudyLocked(_PTR(Study) theStudy){
1081 return theStudy->GetProperties()->IsLocked();
1084 static bool checkLock(_PTR(Study) theStudy) {
1085 if (isStudyLocked(theStudy)) {
1086 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1087 QObject::tr("WRN_WARNING"),
1088 QObject::tr("WRN_STUDY_LOCKED"),
1089 QObject::tr("BUT_OK") );
1095 //=======================================================================
1096 //function : CheckActiveStudyLocked
1098 //=======================================================================
1100 bool SMESHGUI::isActiveStudyLocked()
1102 _PTR(Study) aStudy = activeStudy()->studyDS();
1103 return checkLock( aStudy );
1106 //=============================================================================
1110 //=============================================================================
1111 bool SMESHGUI::OnGUIEvent( int theCommandID )
1113 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1117 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1118 SUIT_ResourceMgr* mgr = resourceMgr();
1122 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1123 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1126 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1127 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1129 //QAction* act = action( theCommandID );
1131 switch (theCommandID) {
1133 if(checkLock(aStudy)) break;
1141 if(checkLock(aStudy)) break;
1142 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1146 case 122: // EXPORT MED
1153 ::ExportMeshToFile(theCommandID);
1157 case 200: // SCALAR BAR
1159 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1160 SALOME_ListIO selected;
1162 aSel->selectedObjects( selected );
1164 if( selected.Extent() ) {
1165 Handle(SALOME_InteractiveObject) anIO = selected.First();
1166 if( anIO->hasEntry() ) {
1167 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1168 anActor->SetControlMode( SMESH_Actor::eNone );
1176 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1180 case 1134: // Clipping
1181 case 1133: // Tranparency
1182 case 1132: // Colors / Size
1189 ::SetDisplayMode(theCommandID);
1195 case 219: // Volumes
1196 case 220: // All Entity
1197 ::SetDisplayEntity(theCommandID);
1202 if(checkLock(aStudy)) break;
1203 SMESH::UpdateView();
1206 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1207 aSel->selectedObjects( l );
1208 aSel->setSelectedObjects( l );
1213 case 301: // DISPLAY
1214 case 302: // DISPLAY ONLY
1216 SMESH::EDisplaing anAction;
1217 switch (theCommandID) {
1218 case 300: anAction = SMESH::eErase; break;
1219 case 301: anAction = SMESH::eDisplay; break;
1220 case 302: anAction = SMESH::eDisplayOnly; break;
1223 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1224 SALOME_ListIO sel_objects, to_process;
1226 aSel->selectedObjects( sel_objects );
1228 if( theCommandID==302 )
1229 startOperation( myEraseAll );
1231 extractContainers( sel_objects, to_process );
1234 SALOME_ListIteratorOfListIO It( to_process );
1235 for (; It.More(); It.Next()) {
1236 Handle(SALOME_InteractiveObject) IOS = It.Value();
1237 if (IOS->hasEntry()) {
1238 SMESH::UpdateView(anAction, IOS->getEntry());
1239 if (anAction == SMESH::eDisplayOnly)
1240 anAction = SMESH::eDisplay;
1246 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) && !automaticUpdate() )
1247 SMESH::UpdateView();
1250 if (anAction == SMESH::eErase) {
1252 aSel->setSelectedObjects( l1 );
1255 aSel->setSelectedObjects( to_process );
1262 if(checkLock(aStudy)) break;
1265 EmitSignalDeactivateDialog();
1267 new SMESHGUI_NodesDlg(this);
1270 SUIT_MessageBox::warn1(desktop(),
1271 tr("SMESH_WRN_WARNING"),
1272 tr("SMESH_WRN_VIEWER_VTK"),
1273 tr("SMESH_BUT_OK"));
1278 case 2151: // FILTER
1282 EmitSignalDeactivateDialog();
1283 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1288 case 406: // MOVE NODE
1292 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1293 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1297 if(checkLock(aStudy)) break;
1298 new SMESHGUI_MoveNodesDlg(this);
1302 case 701: // COMPUTE MESH
1304 if (checkLock(aStudy)) break;
1306 LightApp_SelectionMgr *Sel = selectionMgr();
1307 SALOME_ListIO selected; Sel->selectedObjects( selected );
1309 int nbSel = selected.Extent();
1311 SUIT_MessageBox::warn1(desktop(),
1312 tr("SMESH_WRN_WARNING"),
1313 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1314 tr("SMESH_BUT_OK"));
1318 SMESH::SMESH_Mesh_var aMesh;
1319 SMESH::SMESH_subMesh_var aSubMesh;
1320 Handle(SALOME_InteractiveObject) IObject = selected.First();
1321 if (IObject->hasEntry()) {
1322 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1323 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1324 if ( aShapeObject->_is_nil() ) {
1329 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1330 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1331 if ( !aSubMesh->_is_nil() )
1332 aMesh = aSubMesh->GetFather();
1334 if (!aMesh->_is_nil()) {
1335 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1336 if ( errors->length() > 0 ) {
1337 SUIT_MessageBox::warn1(desktop(),
1338 tr("SMESH_WRN_WARNING"),
1339 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1340 tr("SMESH_BUT_OK"));
1345 if (GetSMESHGen()->Compute(aMesh, aShapeObject))
1346 SMESH::ModifiedMesh(aMeshSObj, true);
1348 SUIT_MessageBox::warn1(desktop(),
1349 tr("SMESH_WRN_WARNING"),
1350 tr("SMESH_WRN_COMPUTE_FAILED"),
1351 tr("SMESH_BUT_OK"));
1353 catch(const SALOME::SALOME_Exception & S_ex){
1354 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1359 if (automaticUpdate()) {
1360 SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
1362 CORBA::Long anId = aStudy->StudyId();
1363 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
1365 aVisualObj->Update();
1366 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1368 anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
1370 SMESH::DisplayActor(aVTKView, anActor); //apo
1374 SMESH::RepaintCurrentView();
1375 Sel->setSelectedObjects( selected );
1385 case 702: // Create mesh
1386 startOperation( 702 );
1388 case 703: // Create sub-mesh
1389 startOperation( 703 );
1391 case 704: // Edit mesh/sub-mesh
1392 startOperation( 704 );
1394 case 407: // DIAGONAL INVERSION
1395 case 408: // Delete diagonal
1399 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1400 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1404 if ( checkLock( aStudy ) )
1407 /*Standard_Boolean aRes;
1408 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1409 if ( aMesh->_is_nil() )
1411 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1412 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1416 EmitSignalDeactivateDialog();
1417 if ( theCommandID == 407 )
1418 new SMESHGUI_TrianglesInversionDlg(this);
1420 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1423 case 409: // Change orientation
1424 case 410: // Union of triangles
1425 case 411: // Cutting of quadrangles
1429 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1430 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1434 if ( checkLock( aStudy ) )
1437 EmitSignalDeactivateDialog();
1438 SMESHGUI_MultiEditDlg* aDlg = NULL;
1439 if ( theCommandID == 409 )
1440 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1441 else if ( theCommandID == 410 )
1442 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1444 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1449 case 412: // Smoothing
1451 if(checkLock(aStudy)) break;
1453 EmitSignalDeactivateDialog();
1454 new SMESHGUI_SmoothingDlg( this );
1457 SUIT_MessageBox::warn1(desktop(),
1458 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1459 tr("SMESH_BUT_OK"));
1463 case 413: // Extrusion
1465 if (checkLock(aStudy)) break;
1467 EmitSignalDeactivateDialog();
1468 new SMESHGUI_ExtrusionDlg ( this );
1470 SUIT_MessageBox::warn1(desktop(),
1471 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1472 tr("SMESH_BUT_OK"));
1476 case 414: // Revolution
1478 if(checkLock(aStudy)) break;
1480 EmitSignalDeactivateDialog();
1481 new SMESHGUI_RevolutionDlg( this );
1484 SUIT_MessageBox::warn1(desktop(),
1485 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1486 tr("SMESH_BUT_OK"));
1490 case 415: // Pattern mapping
1492 if ( checkLock( aStudy ) )
1496 EmitSignalDeactivateDialog();
1497 new SMESHGUI_MeshPatternDlg( this );
1500 SUIT_MessageBox::warn1(desktop(),
1501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1502 tr("SMESH_BUT_OK"));
1506 case 416: // Extrusion along a path
1508 if (checkLock(aStudy)) break;
1510 EmitSignalDeactivateDialog();
1511 new SMESHGUI_ExtrusionAlongPathDlg( this );
1513 SUIT_MessageBox::warn1(desktop(),
1514 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1515 tr("SMESH_BUT_OK"));
1519 case 417: // Convert mesh to quadratic
1521 startOperation( 417 );
1522 /* if (checkLock(aStudy)) break;
1524 EmitSignalDeactivateDialog();
1525 new SMESHGUI_ConvToQuadDlg();
1527 SUIT_MessageBox::warn1(desktop(),
1528 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1529 tr("SMESH_BUT_OK"));
1533 case 801: // CREATE GROUP
1537 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1538 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1542 if(checkLock(aStudy)) break;
1543 EmitSignalDeactivateDialog();
1544 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1546 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1547 SALOME_ListIO selected;
1549 aSel->selectedObjects( selected );
1551 int nbSel = selected.Extent();
1553 // check if mesh is selected
1554 aMesh = SMESH::GetMeshByIO( selected.First() );
1556 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1561 case 802: // CONSTRUCT GROUP
1565 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1566 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1570 if(checkLock(aStudy)) break;
1571 EmitSignalDeactivateDialog();
1573 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1574 SALOME_ListIO selected;
1576 aSel->selectedObjects( selected );
1578 int nbSel = selected.Extent();
1580 // check if submesh is selected
1581 Handle(SALOME_InteractiveObject) IObject = selected.First();
1582 if (IObject->hasEntry()) {
1583 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1585 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1586 if (!aSubMesh->_is_nil()) {
1588 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1589 // get submesh elements list by types
1590 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1591 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1592 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1593 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1594 // create group for each type o elements
1595 QString aName = IObject->getName();
1596 if (aNodes->length() > 0) {
1597 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1598 aGroup->Add(aNodes.inout());
1600 if (aEdges->length() > 0) {
1601 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1602 aGroup->Add(aEdges.inout());
1604 if (aFaces->length() > 0) {
1605 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1606 aGroup->Add(aFaces.inout());
1608 if (aVolumes->length() > 0) {
1609 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1610 aGroup->Add(aVolumes.inout());
1615 catch(const SALOME::SALOME_Exception & S_ex){
1616 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1623 SUIT_MessageBox::warn1(desktop(),
1624 tr("SMESH_WRN_WARNING"),
1625 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1626 tr("SMESH_BUT_OK"));
1631 case 803: // EDIT GROUP
1635 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1636 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1640 if(checkLock(aStudy)) break;
1641 EmitSignalDeactivateDialog();
1643 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1644 SALOME_ListIO selected;
1646 aSel->selectedObjects( selected );
1648 SALOME_ListIteratorOfListIO It (selected);
1649 int nbSelectedGroups = 0;
1650 for ( ; It.More(); It.Next() )
1652 SMESH::SMESH_GroupBase_var aGroup =
1653 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1654 if (!aGroup->_is_nil()) {
1656 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1660 if (nbSelectedGroups == 0)
1662 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1668 case 804: // Add elements to group
1670 if(checkLock(aStudy)) break;
1671 if (myState == 800) {
1672 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1673 if (aDlg) aDlg->onAdd();
1678 case 805: // Remove elements from group
1680 if(checkLock(aStudy)) break;
1681 if (myState == 800) {
1682 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1683 if (aDlg) aDlg->onRemove();
1688 case 810: // Union Groups
1689 case 811: // Intersect groups
1690 case 812: // Cut groups
1694 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1695 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1699 if ( checkLock( aStudy ) )
1702 EmitSignalDeactivateDialog();
1705 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1706 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1707 else aMode = SMESHGUI_GroupOpDlg::CUT;
1709 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1713 case 813: // Delete groups with their contents
1717 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1718 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1722 if ( checkLock( aStudy ) )
1725 EmitSignalDeactivateDialog();
1727 new SMESHGUI_DeleteGroupDlg( this );
1731 case 900: // MESH INFOS
1733 EmitSignalDeactivateDialog();
1734 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1735 SALOME_ListIO selected;
1737 aSel->selectedObjects( selected );
1739 if ( selected.Extent() > 1 ) { // a dlg for each IO
1741 SALOME_ListIteratorOfListIO It (selected);
1742 for ( ; It.More(); It.Next() ) {
1743 IOs.Clear(); IOs.Append( It.Value() );
1744 aSel->setSelectedObjects( IOs );
1745 new SMESHGUI_MeshInfosDlg(this, "", false);
1747 // restore selection
1748 aSel->setSelectedObjects( selected );
1751 new SMESHGUI_MeshInfosDlg(this, "", false);
1755 case 902: // STANDARD MESH INFOS
1757 EmitSignalDeactivateDialog();
1758 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1759 SALOME_ListIO selected;
1761 aSel->selectedObjects( selected );
1763 if ( selected.Extent() > 1 ) { // a dlg for each IO
1765 SALOME_ListIteratorOfListIO It (selected);
1766 for ( ; It.More(); It.Next() ) {
1768 IOs.Append( It.Value() );
1769 aSel->setSelectedObjects( IOs );
1770 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1772 // restore selection
1773 aSel->setSelectedObjects( selected );
1776 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1780 case 1100: // EDIT HYPOTHESIS
1782 if(checkLock(aStudy)) break;
1784 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1785 SALOME_ListIO selected;
1787 aSel->selectedObjects( selected );
1789 int nbSel = selected.Extent();
1792 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1794 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1795 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1796 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1797 if ( !Hyp->_is_nil() )
1799 char* sName = Hyp->GetName();
1800 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1802 aCreator->edit( Hyp.in(), desktop() );
1809 updateObjBrowser( true );
1813 case 1101: // RENAME
1815 if ( checkLock( aStudy ) )
1818 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1819 SALOME_ListIO selected;
1821 aSel->selectedObjects( selected );
1823 SALOME_ListIteratorOfListIO It( selected );
1824 for ( ; It.More(); It.Next() )
1826 Handle(SALOME_InteractiveObject) IObject = It.Value();
1827 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1828 _PTR(GenericAttribute) anAttr;
1829 _PTR(AttributeName) aName;
1832 if ( obj->FindAttribute(anAttr, "AttributeName") )
1835 QString newName = QString(aName->Value().c_str());
1836 newName = LightApp_NameDlg::getName(desktop(), newName);
1837 if ( !newName.isEmpty() )
1839 //old source: aStudy->renameIObject( IObject, newName );
1840 aName->SetValue( newName.latin1() );
1842 // if current object is group update group's name
1843 SMESH::SMESH_GroupBase_var aGroup =
1844 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1845 if (!aGroup->_is_nil() )
1846 aGroup->SetName( newName.latin1() );
1856 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1858 if(checkLock(aStudy)) break;
1859 SUIT_OverrideCursor wc;
1861 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1862 SALOME_ListIO selected;
1864 aSel->selectedObjects( selected, QString::null, false );
1866 SALOME_ListIteratorOfListIO It(selected);
1867 for (int i = 0; It.More(); It.Next(), i++) {
1868 Handle(SALOME_InteractiveObject) IObject = It.Value();
1869 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1872 aSel->setSelectedObjects( l1 );
1877 case 401: // GEOM::EDGE
1878 case 4021: // TRIANGLE
1880 case 4023: // POLYGON
1884 if(checkLock(aStudy)) break;
1886 EmitSignalDeactivateDialog();
1887 SMDSAbs_ElementType type = SMDSAbs_Edge;
1889 switch (theCommandID) {
1890 case 4021: // TRIANGLE
1891 type = SMDSAbs_Face; nbNodes = 3; break;
1893 type = SMDSAbs_Face; nbNodes = 4; break;
1895 type = SMDSAbs_Volume; nbNodes = 4; break;
1896 case 4023: // POLYGON
1897 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1899 type = SMDSAbs_Volume; nbNodes = 8; break;
1900 case 4033: // POLYHEDRE
1901 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1904 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1907 SUIT_MessageBox::warn1(desktop(),
1908 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1909 tr("SMESH_BUT_OK"));
1913 case 4033: // POLYHEDRON
1915 if(checkLock(aStudy)) break;
1917 EmitSignalDeactivateDialog();
1918 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1921 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1923 tr("SMESH_BUT_OK"));
1927 case 4034: // QUADRATIC EDGE
1928 case 4035: // QUADRATIC TRIANGLE
1929 case 4036: // QUADRATIC QUADRANGLE
1930 case 4037: // QUADRATIC TETRAHEDRON
1931 case 4038: // QUADRATIC PYRAMID
1932 case 4039: // QUADRATIC PENTAHEDRON
1933 case 4040: // QUADRATIC HEXAHEDRON
1935 if(checkLock(aStudy)) break;
1937 EmitSignalDeactivateDialog();
1940 switch (theCommandID) {
1942 type = QUAD_EDGE; break;
1944 type = QUAD_TRIANGLE; break;
1946 type = QUAD_QUADRANGLE; break;
1948 type = QUAD_TETRAHEDRON; break;
1950 type = QUAD_PYRAMID; break;
1952 type = QUAD_PENTAHEDRON; break;
1954 type = QUAD_HEXAHEDRON;
1958 new SMESHGUI_AddQuadraticElementDlg( this, type );
1961 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1962 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963 tr("SMESH_BUT_OK"));
1967 case 4041: // REMOVES NODES
1969 if(checkLock(aStudy)) break;
1971 EmitSignalDeactivateDialog();
1972 new SMESHGUI_RemoveNodesDlg(this);
1975 SUIT_MessageBox::warn1(desktop(),
1976 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1977 tr("SMESH_BUT_OK"));
1981 case 4042: // REMOVES ELEMENTS
1983 if(checkLock(aStudy)) break;
1985 EmitSignalDeactivateDialog();
1986 new SMESHGUI_RemoveElementsDlg(this);
1990 SUIT_MessageBox::warn1(desktop(),
1991 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1992 tr("SMESH_BUT_OK"));
1996 case 4051: // RENUMBERING NODES
1998 if(checkLock(aStudy)) break;
2000 EmitSignalDeactivateDialog();
2001 new SMESHGUI_RenumberingDlg( this, "", 0);
2005 SUIT_MessageBox::warn1(desktop(),
2006 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2007 tr("SMESH_BUT_OK"));
2011 case 4052: // RENUMBERING ELEMENTS
2013 if(checkLock(aStudy)) break;
2015 EmitSignalDeactivateDialog();
2016 new SMESHGUI_RenumberingDlg( this, "", 1);
2020 SUIT_MessageBox::warn1(desktop(),
2021 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2022 tr("SMESH_BUT_OK"));
2026 case 4061: // TRANSLATION
2028 if(checkLock(aStudy)) break;
2030 EmitSignalDeactivateDialog();
2031 new SMESHGUI_TranslationDlg( this );
2034 SUIT_MessageBox::warn1(desktop(),
2035 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2036 tr("SMESH_BUT_OK"));
2040 case 4062: // ROTATION
2042 if(checkLock(aStudy)) break;
2044 EmitSignalDeactivateDialog();
2045 new SMESHGUI_RotationDlg( this );
2048 SUIT_MessageBox::warn1(desktop(),
2049 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2050 tr("SMESH_BUT_OK"));
2054 case 4063: // SYMMETRY
2056 if(checkLock(aStudy)) break;
2058 EmitSignalDeactivateDialog();
2059 new SMESHGUI_SymmetryDlg( this );
2062 SUIT_MessageBox::warn1(desktop(),
2063 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2064 tr("SMESH_BUT_OK"));
2068 case 4064: // SEWING
2070 if(checkLock(aStudy)) break;
2072 EmitSignalDeactivateDialog();
2073 new SMESHGUI_SewingDlg( this );
2076 SUIT_MessageBox::warn1(desktop(),
2077 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2078 tr("SMESH_BUT_OK"));
2082 case 4065: // MERGE NODES
2084 if(checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 new SMESHGUI_MergeNodesDlg( this );
2090 SUIT_MessageBox::warn1(desktop(),
2091 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2092 tr("SMESH_BUT_OK"));
2096 case 4066: // MERGE EQUAL ELEMENTS
2098 if (checkLock(aStudy)) break;
2100 EmitSignalDeactivateDialog();
2101 new SMESHGUI_EditMeshDlg(this,
2102 "SMESH_MERGE_ELEMENTS_TITLE",
2103 "ICON_DLG_MERGE_ELEMENTS",
2104 1); // MergeEqualElemets
2106 SUIT_MessageBox::warn1(desktop(),
2107 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2108 tr("SMESH_BUT_OK"));
2113 case 4067: // MAKE MESH PASS THROUGH POINT
2114 startOperation( 4067 );
2117 case 5105: // Library of selection filters
2119 static QValueList<int> aTypes;
2120 if ( aTypes.isEmpty() )
2122 aTypes.append( SMESH::NODE );
2123 aTypes.append( SMESH::EDGE );
2124 aTypes.append( SMESH::FACE );
2125 aTypes.append( SMESH::VOLUME );
2127 if (!myFilterLibraryDlg)
2128 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2129 else if (myFilterLibraryDlg->isHidden())
2130 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2131 myFilterLibraryDlg->raise();
2135 case 6017: // CONTROLS
2151 LightApp_SelectionMgr* mgr = selectionMgr();
2152 SALOME_ListIO selected; mgr->selectedObjects( selected );
2154 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2155 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2157 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2158 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2159 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2160 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2161 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2162 ::Control( theCommandID );
2167 SUIT_MessageBox::warn1(desktop(),
2168 tr( "SMESH_WRN_WARNING" ),
2169 tr( "SMESH_BAD_SELECTION" ),
2170 tr( "SMESH_BUT_OK" ) );
2174 SUIT_MessageBox::warn1(desktop(),
2175 tr( "SMESH_WRN_WARNING" ),
2176 tr( "NOT_A_VTK_VIEWER" ),
2177 tr( "SMESH_BUT_OK" ) );
2182 LightApp_SelectionMgr* mgr = selectionMgr();
2183 SALOME_ListIO selected; mgr->selectedObjects( selected );
2185 SALOME_ListIteratorOfListIO it(selected);
2186 for(; it.More(); it.Next()) {
2187 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2188 if(anIObject->hasEntry()) {
2189 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2190 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2198 LightApp_SelectionMgr* mgr = selectionMgr();
2199 SALOME_ListIO selected; mgr->selectedObjects( selected );
2201 if (selected.Extent() == 1) {
2202 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2203 if(anIObject->hasEntry())
2204 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2205 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2212 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2213 //updateObjBrowser();
2217 //=============================================================================
2221 //=============================================================================
2222 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2227 //=============================================================================
2231 //=============================================================================
2232 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2237 //=============================================================================
2241 //=============================================================================
2242 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2247 //=============================================================================
2248 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2249 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2251 //=============================================================================
2252 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2253 SUIT_ViewWindow* wnd )
2255 if(theIO->hasEntry()){
2256 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2257 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2261 //=======================================================================
2262 // function : createSMESHAction
2264 //=======================================================================
2265 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2268 QWidget* parent = application()->desktop();
2269 SUIT_ResourceMgr* resMgr = resourceMgr();
2271 if ( icon_id.length() )
2272 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2274 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2275 if ( !pix.isNull() )
2276 icon = QIconSet( pix );
2278 QString tooltip = tr( QString( "TOP_" )+po_id ),
2279 menu = tr( QString( "MEN_" )+po_id ),
2280 status_bar = tr( QString( "STB_" )+po_id );
2282 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2285 //=======================================================================
2286 // function : createPopupItem
2288 //=======================================================================
2289 void SMESHGUI::createPopupItem( const int id,
2290 const QString& clients,
2291 const QString& types,
2292 const QString& theRule,
2297 parentId = popupMgr()->actionId( action( pId ) );
2299 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2300 popupMgr()->insert( action( id ), parentId, 0 );
2302 QChar lc = QtxPopupMgr::Selection::defEquality();
2303 QString rule = "(%1) and (%2) and (%3)";
2304 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2305 if( clients.isEmpty() )
2306 rule = rule.arg( QString( "true" ) );
2308 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2309 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2312 bool cont = myRules.contains( id );
2314 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2316 popupMgr()->setRule( action( id ), rule, true );
2317 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2320 //=======================================================================
2321 // function : initialize
2323 //=======================================================================
2324 void SMESHGUI::initialize( CAM_Application* app )
2326 SalomeApp_Module::initialize( app );
2328 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2330 /* Automatic Update flag */
2331 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2333 // ----- create actions --------------
2335 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2336 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2337 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2338 createSMESHAction( 114, "NUM" );
2339 createSMESHAction( 121, "DAT" );
2340 createSMESHAction( 122, "MED" );
2341 createSMESHAction( 123, "UNV" );
2342 createSMESHAction( 124, "EXPORT_DAT" );
2343 createSMESHAction( 125, "EXPORT_MED" );
2344 createSMESHAction( 126, "EXPORT_UNV" );
2345 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2346 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2347 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2348 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2349 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2350 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2351 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2352 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2353 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2354 createSMESHAction( 804, "ADD" );
2355 createSMESHAction( 805, "REMOVE" );
2356 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2357 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2358 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2359 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2360 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2361 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2362 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2363 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2364 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2365 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2366 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2367 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2368 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2369 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2370 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2371 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2372 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2373 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2374 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2375 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2376 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2377 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2378 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2379 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2380 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2381 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2382 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2383 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2384 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2385 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2386 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2387 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2388 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2389 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2390 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2391 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2392 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2393 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2394 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2395 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2396 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2397 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2398 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2399 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2400 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2401 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2402 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2403 createSMESHAction( 415, "MAP", "ICON_MAP" );
2404 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2405 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2406 createSMESHAction( 200, "RESET" );
2407 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2408 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2409 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2410 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2411 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2412 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2413 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2414 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2415 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2416 createSMESHAction( 220, "ALL" );
2417 createSMESHAction( 1100, "EDIT_HYPO" );
2418 createSMESHAction( 1101, "RENAME" );
2419 createSMESHAction( 1102, "UNASSIGN" );
2420 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2421 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2422 createSMESHAction( 1131, "DISPMODE" );
2423 createSMESHAction( 1132, "COLORS" );
2424 createSMESHAction( 1133, "TRANSP" );
2425 createSMESHAction( 1134, "CLIP" );
2426 createSMESHAction( 1135, "DISP_ENT" );
2427 createSMESHAction( 2000, "CTRL" );
2429 createSMESHAction( 300, "ERASE" );
2430 createSMESHAction( 301, "DISPLAY" );
2431 createSMESHAction( 302, "DISPLAY_ONLY" );
2432 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2433 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2434 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2435 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2436 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2437 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2438 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2439 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2441 // ----- create menu --------------
2442 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2443 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2444 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2445 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2446 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2447 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2448 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2450 createMenu( separator(), fileId );
2452 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2453 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2454 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2455 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2456 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2457 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2459 createMenu( 111, importId, -1 );
2460 createMenu( 112, importId, -1 );
2461 createMenu( 113, importId, -1 );
2463 createMenu( 121, exportId, -1 );
2464 createMenu( 122, exportId, -1 );
2465 createMenu( 123, exportId, -1 );
2467 createMenu( separator(), fileId, 10 );
2469 createMenu( 33, editId, -1 );
2471 createMenu( 5105, toolsId, -1 );
2473 createMenu( 702, meshId, -1 );
2474 createMenu( 703, meshId, -1 );
2475 createMenu( 704, meshId, -1 );
2476 createMenu( separator(), meshId, -1 );
2477 createMenu( 701, meshId, -1 );
2478 createMenu( separator(), meshId, -1 );
2479 createMenu( 801, meshId, -1 );
2480 createMenu( 802, meshId, -1 );
2481 createMenu( 803, meshId, -1 );
2482 createMenu( separator(), meshId, -1 );
2483 createMenu( 810, meshId, -1 );
2484 createMenu( 811, meshId, -1 );
2485 createMenu( 812, meshId, -1 );
2486 createMenu( separator(), meshId, -1 );
2487 createMenu( 813, meshId, -1 );
2488 createMenu( separator(), meshId, -1 );
2489 createMenu( 900, meshId, -1 );
2490 createMenu( 902, meshId, -1 );
2491 createMenu( separator(), meshId, -1 );
2493 createMenu( 6003, ctrlId, -1 );
2494 createMenu( 6001, ctrlId, -1 );
2495 createMenu( 6004, ctrlId, -1 );
2496 createMenu( separator(), ctrlId, -1 );
2497 createMenu( 6002, ctrlId, -1 );
2498 createMenu( 6018, ctrlId, -1 );
2499 createMenu( 6019, ctrlId, -1 );
2500 createMenu( 6011, ctrlId, -1 );
2501 createMenu( 6012, ctrlId, -1 );
2502 createMenu( 6013, ctrlId, -1 );
2503 createMenu( 6014, ctrlId, -1 );
2504 createMenu( 6015, ctrlId, -1 );
2505 createMenu( 6016, ctrlId, -1 );
2506 createMenu( separator(), ctrlId, -1 );
2507 createMenu( 6017, ctrlId, -1 );
2508 createMenu( 6009, ctrlId, -1 );
2509 createMenu( separator(), ctrlId, -1 );
2511 createMenu( 400, addId, -1 );
2512 createMenu( 401, addId, -1 );
2513 createMenu( 4021, addId, -1 );
2514 createMenu( 4022, addId, -1 );
2515 createMenu( 4023, addId, -1 );
2516 createMenu( 4031, addId, -1 );
2517 createMenu( 4032, addId, -1 );
2518 createMenu( 4033, addId, -1 );
2519 createMenu( separator(), addId, -1 );
2520 createMenu( 4034, addId, -1 );
2521 createMenu( 4035, addId, -1 );
2522 createMenu( 4036, addId, -1 );
2523 createMenu( 4037, addId, -1 );
2524 createMenu( 4038, addId, -1 );
2525 createMenu( 4039, addId, -1 );
2526 createMenu( 4040, addId, -1 );
2528 createMenu( 4041, removeId, -1 );
2529 createMenu( 4042, removeId, -1 );
2531 createMenu( 4051, renumId, -1 );
2532 createMenu( 4052, renumId, -1 );
2534 createMenu( 4061, transfId, -1 );
2535 createMenu( 4062, transfId, -1 );
2536 createMenu( 4063, transfId, -1 );
2537 createMenu( 4064, transfId, -1 );
2538 createMenu( 4065, transfId, -1 );
2539 createMenu( 4066, transfId, -1 );
2541 createMenu( 406, modifyId, -1 );
2542 createMenu( 4067,modifyId, -1 );
2543 createMenu( 407, modifyId, -1 );
2544 createMenu( 408, modifyId, -1 );
2545 createMenu( 409, modifyId, -1 );
2546 createMenu( 410, modifyId, -1 );
2547 createMenu( 411, modifyId, -1 );
2548 createMenu( 412, modifyId, -1 );
2549 createMenu( 413, modifyId, -1 );
2550 createMenu( 416, modifyId, -1 );
2551 createMenu( 414, modifyId, -1 );
2552 createMenu( 415, modifyId, -1 );
2553 createMenu( 417, modifyId, -1 );
2555 createMenu( 214, viewId, -1 );
2557 // ----- create toolbars --------------
2558 int meshTb = createTool( tr( "TB_MESH" ) ),
2559 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2560 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2561 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2562 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2564 createTool( 702, meshTb );
2565 createTool( 703, meshTb );
2566 createTool( 704, meshTb );
2567 createTool( separator(), meshTb );
2568 createTool( 701, meshTb );
2569 createTool( separator(), meshTb );
2570 createTool( 801, meshTb );
2571 createTool( 802, meshTb );
2572 createTool( 803, meshTb );
2573 createTool( separator(), meshTb );
2574 createTool( 900, meshTb );
2575 createTool( 902, meshTb );
2576 createTool( separator(), meshTb );
2578 createTool( 6001, ctrlTb );
2579 createTool( 6003, ctrlTb );
2580 createTool( 6004, ctrlTb );
2581 createTool( separator(), ctrlTb );
2582 createTool( 6002, ctrlTb );
2583 createTool( 6018, ctrlTb );
2584 createTool( 6019, ctrlTb );
2585 createTool( 6011, ctrlTb );
2586 createTool( 6012, ctrlTb );
2587 createTool( 6013, ctrlTb );
2588 createTool( 6014, ctrlTb );
2589 createTool( 6015, ctrlTb );
2590 createTool( 6016, ctrlTb );
2591 createTool( separator(), ctrlTb );
2592 createTool( 6017, ctrlTb );
2593 createTool( 6009, ctrlTb );
2594 createTool( separator(), ctrlTb );
2596 createTool( 400, addRemTb );
2597 createTool( 401, addRemTb );
2598 createTool( 4021, addRemTb );
2599 createTool( 4022, addRemTb );
2600 createTool( 4023, addRemTb );
2601 createTool( 4031, addRemTb );
2602 createTool( 4032, addRemTb );
2603 createTool( 4033, addRemTb );
2604 createTool( separator(), addRemTb );
2605 createTool( 4034, addRemTb );
2606 createTool( 4035, addRemTb );
2607 createTool( 4036, addRemTb );
2608 createTool( 4037, addRemTb );
2609 createTool( 4038, addRemTb );
2610 createTool( 4039, addRemTb );
2611 createTool( 4040, addRemTb );
2612 createTool( separator(), addRemTb );
2613 createTool( 4041, addRemTb );
2614 createTool( 4042, addRemTb );
2615 createTool( separator(), addRemTb );
2616 createTool( 4051, addRemTb );
2617 createTool( 4052, addRemTb );
2618 createTool( separator(), addRemTb );
2619 createTool( 4061, addRemTb );
2620 createTool( 4062, addRemTb );
2621 createTool( 4063, addRemTb );
2622 createTool( 4064, addRemTb );
2623 createTool( 4065, addRemTb );
2624 createTool( 4066, addRemTb );
2625 createTool( separator(), addRemTb );
2627 createTool( 406, modifyTb );
2628 createTool( 4067,modifyTb );
2629 createTool( 407, modifyTb );
2630 createTool( 408, modifyTb );
2631 createTool( 409, modifyTb );
2632 createTool( 410, modifyTb );
2633 createTool( 411, modifyTb );
2634 createTool( 412, modifyTb );
2635 createTool( 413, modifyTb );
2636 createTool( 416, modifyTb );
2637 createTool( 414, modifyTb );
2638 createTool( 415, modifyTb );
2639 createTool( 417, modifyTb );
2641 createTool( 214, dispModeTb );
2645 QString OB = "'ObjectBrowser'",
2646 View = "'" + SVTK_Viewer::Type() + "'",
2648 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2649 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2650 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2651 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2652 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2653 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2654 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2655 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2656 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2657 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2658 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2660 mesh_group = mesh + " " + subMesh + " " + group,
2661 hyp_alg = hypo + " " + algo;
2663 // popup for object browser
2665 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2666 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2667 createPopupItem( 803, OB, group ); // EDIT_GROUP
2668 popupMgr()->insert( separator(), -1, 0 );
2669 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2670 createPopupItem( 214, OB, mesh_group ); // UPDATE
2671 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2672 createPopupItem( 902, OB, mesh ); // STD_INFO
2673 popupMgr()->insert( separator(), -1, 0 );
2674 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2675 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2676 popupMgr()->insert( separator(), -1, 0 );
2677 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2678 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2679 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2680 popupMgr()->insert( separator(), -1, 0 );
2682 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2683 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2684 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2685 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2686 popupMgr()->insert( separator(), -1, 0 );
2689 createPopupItem( 803, View, group ); // EDIT_GROUP
2690 createPopupItem( 804, View, elems ); // ADD
2691 createPopupItem( 805, View, elems ); // REMOVE
2692 popupMgr()->insert( separator(), -1, 0 );
2693 createPopupItem( 214, View, mesh_group ); // UPDATE
2694 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2695 createPopupItem( 902, View, mesh ); // STD_INFO
2696 popupMgr()->insert( separator(), -1, 0 );
2700 isInvisible("not( isVisible )"),
2701 isEmpty("numberOfNodes = 0"),
2702 isNotEmpty("numberOfNodes <> 0"),
2704 // has nodes, edges, etc in VISIBLE! actor
2705 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2706 hasElems("(count( elemTypes ) > 0)"),
2707 hasDifferentElems("(count( elemTypes ) > 1)"),
2708 hasEdges("({'Edge'} in elemTypes)"),
2709 hasFaces("({'Face'} in elemTypes)"),
2710 hasVolumes("({'Volume'} in elemTypes)");
2712 QString lc = QtxPopupMgr::Selection::defEquality();
2713 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2714 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2715 aType = aType.arg( mesh_group );
2716 QString aMeshInVTK = aClient + "&&" + aType;
2718 //-------------------------------------------------
2720 //-------------------------------------------------
2721 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2723 popupMgr()->insert( action( 9010 ), anId, -1 );
2724 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2725 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2727 popupMgr()->insert( action( 9011 ), anId, -1 );
2728 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2729 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2731 popupMgr()->insert( separator(), -1, -1 );
2733 //-------------------------------------------------
2735 //-------------------------------------------------
2736 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2738 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2739 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2740 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2742 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2743 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2744 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2746 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2747 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2748 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2750 popupMgr()->insert( separator(), anId, -1 );
2752 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2753 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2754 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2756 //-------------------------------------------------
2758 //-------------------------------------------------
2759 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2761 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2763 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2764 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2765 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2767 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2768 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2769 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2771 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2772 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2773 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2775 popupMgr()->insert( separator(), anId, -1 );
2777 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2778 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2780 //-------------------------------------------------
2782 //-------------------------------------------------
2783 popupMgr()->insert( action( 1132 ), -1, -1 );
2784 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2786 //-------------------------------------------------
2788 //-------------------------------------------------
2789 popupMgr()->insert( action( 1133 ), -1, -1 );
2790 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2792 //-------------------------------------------------
2794 //-------------------------------------------------
2795 popupMgr()->insert( action( 1134 ), -1, -1 );
2796 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2798 popupMgr()->insert( separator(), -1, -1 );
2800 //-------------------------------------------------
2802 //-------------------------------------------------
2804 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2805 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2806 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2808 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2810 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2811 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2813 popupMgr()->insert( separator(), anId, -1 );
2815 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2816 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2817 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2819 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2820 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2821 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2823 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2824 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2825 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2827 popupMgr()->insert( separator(), anId, -1 );
2829 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2830 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2831 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2833 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2834 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2835 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2837 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2838 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2839 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2841 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2842 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2843 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2845 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2846 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2847 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2849 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2850 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2851 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2853 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2854 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2855 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2857 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2858 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2859 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2861 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2862 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2863 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2865 popupMgr()->insert( separator(), anId, -1 );
2867 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2868 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2869 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2871 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2872 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2873 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2875 popupMgr()->insert( separator(), anId, -1 );
2877 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2878 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2880 popupMgr()->insert( separator(), -1, -1 );
2882 //-------------------------------------------------
2884 //-------------------------------------------------
2885 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2886 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2887 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2889 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2890 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2891 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2892 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2894 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2895 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2897 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2898 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2900 popupMgr()->insert( separator(), -1, -1 );
2902 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2903 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2906 bool SMESHGUI::activateModule( SUIT_Study* study )
2908 bool res = SalomeApp_Module::activateModule( study );
2910 setMenuShown( true );
2911 setToolShown( true );
2913 // Reset actions accelerator keys
2914 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2915 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2916 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2921 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2923 setMenuShown( false );
2924 setToolShown( false );
2926 EmitSignalCloseAllDialogs();
2928 // Unset actions accelerator keys
2929 action(111)->setAccel(QKeySequence()); // Import DAT
2930 action(112)->setAccel(QKeySequence()); // Import UNV
2931 action(113)->setAccel(QKeySequence()); // Import MED
2933 return SalomeApp_Module::deactivateModule( study );
2936 void SMESHGUI::OnGUIEvent()
2938 const QObject* obj = sender();
2939 if ( !obj || !obj->inherits( "QAction" ) )
2941 int id = actionId((QAction*)obj);
2946 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2948 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2949 if ( CORBA::is_nil( myComponentSMESH ) )
2951 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2953 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2954 return aGUI.myComponentSMESH;
2957 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2958 return myComponentSMESH;
2961 QString SMESHGUI::engineIOR() const
2963 CORBA::ORB_var anORB = getApp()->orb();
2964 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2968 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2970 SMESHGUI_Selection sel;
2971 sel.init( client, selectionMgr() );
2972 popupMgr()->updatePopup( menu, &sel );
2975 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2977 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2978 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2981 void SMESHGUI::viewManagers( QStringList& list ) const
2983 list.append( SVTK_Viewer::Type() );
2986 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2988 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2989 SMESH::UpdateSelectionProp( this );
2992 void SMESHGUI::createPreferences()
2994 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2996 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2997 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2999 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3000 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3001 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3003 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3004 setPreferenceProperty( precGroup, "columns", 1 );
3006 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3008 setPreferenceProperty( prec, "min", 0 );
3009 setPreferenceProperty( prec, "max", 16 );
3011 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3012 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3014 modes.append( "Wireframe" );
3015 modes.append( "Shading" );
3016 modes.append( "Nodes" );
3017 modes.append( "Shrink" );
3018 QValueList<QVariant> indices;
3019 indices.append( 0 );
3020 indices.append( 1 );
3021 indices.append( 2 );
3022 indices.append( 3 );
3023 setPreferenceProperty( dispmode, "strings", modes );
3024 setPreferenceProperty( dispmode, "indexes", indices );
3026 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3027 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3028 int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3030 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3031 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3033 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3034 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3036 setPreferenceProperty( nodeSz, "min", 1 );
3037 setPreferenceProperty( nodeSz, "max", 5 );
3039 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3041 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3042 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3043 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3044 addPreference( "", elemGroup, LightApp_Preferences::Space );
3046 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3047 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3049 setPreferenceProperty( elemW, "min", 1 );
3050 setPreferenceProperty( elemW, "max", 5 );
3052 setPreferenceProperty( shrink, "min", 0 );
3053 setPreferenceProperty( shrink, "max", 100 );
3055 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3057 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3059 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3060 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3061 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3063 setPreferenceProperty( selW, "min", 1 );
3064 setPreferenceProperty( selW, "max", 5 );
3066 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3068 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3069 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3071 setPreferenceProperty( preW, "min", 1 );
3072 setPreferenceProperty( preW, "max", 5 );
3074 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3076 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3077 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3079 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3080 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3082 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3083 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3084 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3085 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3088 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3089 fam.append( tr( "SMESH_FONT_COURIER" ) );
3090 fam.append( tr( "SMESH_FONT_TIMES" ) );
3091 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3093 setPreferenceProperty( tfont, "families", fam );
3094 setPreferenceProperty( tfont, "system", false );
3095 setPreferenceProperty( tfont, "widget_flags", wflag );
3096 setPreferenceProperty( lfont, "families", fam );
3097 setPreferenceProperty( lfont, "system", false );
3098 setPreferenceProperty( lfont, "widget_flags", wflag );
3100 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3102 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3103 setPreferenceProperty( numcol, "min", 2 );
3104 setPreferenceProperty( numcol, "max", 256 );
3106 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3107 setPreferenceProperty( numlab, "min", 2 );
3108 setPreferenceProperty( numlab, "max", 65 );
3110 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3111 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3112 QStringList orients;
3113 orients.append( tr( "SMESH_VERTICAL" ) );
3114 orients.append( tr( "SMESH_HORIZONTAL" ) );
3115 indices.clear(); indices.append( 0 ); indices.append( 1 );
3116 setPreferenceProperty( orient, "strings", orients );
3117 setPreferenceProperty( orient, "indexes", indices );
3119 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3120 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3121 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3122 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3123 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3124 setPreferenceProperty( xv, "step", 0.1 );
3125 setPreferenceProperty( xv, "min", 0.0 );
3126 setPreferenceProperty( xv, "max", 1.0 );
3127 setPreferenceProperty( yv, "step", 0.1 );
3128 setPreferenceProperty( yv, "min", 0.0 );
3129 setPreferenceProperty( yv, "max", 1.0 );
3130 setPreferenceProperty( wv, "step", 0.1 );
3131 setPreferenceProperty( wv, "min", 0.0 );
3132 setPreferenceProperty( wv, "max", 1.0 );
3133 setPreferenceProperty( hv, "min", 0.0 );
3134 setPreferenceProperty( hv, "max", 1.0 );
3135 setPreferenceProperty( hv, "step", 0.1 );
3137 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3138 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3139 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3140 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3141 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3142 setPreferenceProperty( xv, "min", 0.0 );
3143 setPreferenceProperty( xv, "max", 1.0 );
3144 setPreferenceProperty( xv, "step", 0.1 );
3145 setPreferenceProperty( xh, "min", 0.0 );
3146 setPreferenceProperty( xh, "max", 1.0 );
3147 setPreferenceProperty( xh, "step", 0.1 );
3148 setPreferenceProperty( yh, "min", 0.0 );
3149 setPreferenceProperty( yh, "max", 1.0 );
3150 setPreferenceProperty( yh, "step", 0.1 );
3151 setPreferenceProperty( wh, "min", 0.0 );
3152 setPreferenceProperty( wh, "max", 1.0 );
3153 setPreferenceProperty( wh, "step", 0.1 );
3154 setPreferenceProperty( hh, "min", 0.0 );
3155 setPreferenceProperty( hh, "max", 1.0 );
3156 setPreferenceProperty( hh, "step", 0.1 );
3159 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3161 if( sect=="SMESH" ){
3162 float sbX1,sbY1,sbW,sbH;
3163 float aTol = 1.00000009999999;
3164 std::string aWarning;
3165 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3166 if( name=="selection_object_color" || name=="selection_element_color" ||
3167 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3168 name=="selection_precision_node" || name=="selection_precision_element" )
3169 SMESH::UpdateSelectionProp( this );
3170 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3171 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3172 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3173 if(sbX1+sbW > aTol){
3174 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3177 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3178 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3181 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3182 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3183 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3184 if(sbY1+sbH > aTol){
3185 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3188 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3189 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3192 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3193 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3194 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3195 if(sbX1+sbW > aTol){
3196 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3199 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3200 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3203 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3204 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3205 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3206 if(sbY1+sbH > aTol){
3207 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3210 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3211 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3215 if(aWarning.size() != 0){
3216 aWarning += "The default values are applied instead.";
3217 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3218 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3219 QObject::tr(aWarning.c_str()),
3220 QObject::tr("SMESH_BUT_OK"));
3225 //================================================================================
3227 * \brief Update something in accordance with update flags
3228 * \param theFlags - update flags
3230 * Update viewer or/and object browser etc. in accordance with update flags ( see
3231 * LightApp_UpdateFlags enumeration ).
3233 //================================================================================
3234 void SMESHGUI::update( const int flags )
3236 if ( flags & UF_Viewer | flags & UF_Forced )
3237 SMESH::UpdateView();
3239 SalomeApp_Module::update( flags );
3242 //================================================================================
3244 * \brief Set default selection mode
3246 * SLOT called when operation commited. Sets default selection mode
3248 //================================================================================
3249 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3251 SVTK_ViewWindow* vtkWnd =
3252 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3254 vtkWnd->SetSelectionMode( ActorSelection );
3257 //================================================================================
3259 * \brief Set default selection mode
3261 * SLOT called when operation aborted. Sets default selection mode
3263 //================================================================================
3264 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3266 SVTK_ViewWindow* vtkWnd =
3267 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3269 vtkWnd->SetSelectionMode( ActorSelection );
3272 //================================================================================
3274 * \brief Creates operation with given identifier
3275 * \param id - identifier of operation to be started
3276 * \return Pointer on created operation or NULL if operation is not created
3278 * Virtual method redefined from the base class creates operation with given id.
3279 * It is called called automatically from startOperation method of base class.
3281 //================================================================================
3282 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3284 LightApp_Operation* op = 0;
3285 // to do : create operation here
3288 case 702: // Create mesh
3289 op = new SMESHGUI_MeshOp( true, true );
3291 case 703: // Create sub-mesh
3292 op = new SMESHGUI_MeshOp( true, false );
3294 case 704: // Edit mesh/sub-mesh
3295 op = new SMESHGUI_MeshOp( false );
3297 case 417: //convert to quadratic
3298 op = new SMESHGUI_ConvToQuadOp();
3300 case 4067: // make mesh pass through point
3301 op = new SMESHGUI_MakeNodeAtPointOp();
3308 op = SalomeApp_Module::createOperation( id );
3312 //================================================================================
3314 * \brief Stops current operations and starts a given one
3315 * \param id - The id of the operation to start
3317 //================================================================================
3319 void SMESHGUI::switchToOperation(int id)
3321 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3322 activeStudy()->abortAllOperations();
3323 startOperation( id );
3326 LightApp_Displayer* SMESHGUI::displayer()
3329 myDisplayer = new SMESHGUI_Displayer( getApp() );