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"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_GEOMGenUtils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include "SMESH_Actor.h"
79 #include "SMESH_Object.h"
80 #include "SMESH_TypeFilter.hxx"
82 #include "SalomeApp_Tools.h"
83 #include "SalomeApp_Study.h"
84 #include "SalomeApp_Application.h"
85 #include "SalomeApp_CheckFileDlg.h"
86 #include "SalomeApp_ImportOperation.h"
88 #include "LightApp_DataOwner.h"
89 #include "LightApp_Preferences.h"
90 #include "LightApp_VTKSelector.h"
91 #include "LightApp_Operation.h"
92 #include "LightApp_UpdateFlags.h"
93 #include "LightApp_NameDlg.h"
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_InteractorStyle.h>
98 #include <SVTK_RenderWindowInteractor.h>
99 #include <SVTK_ViewManager.h>
101 #include "OB_Browser.h"
103 #include "SUIT_Tools.h"
104 #include "SUIT_MessageBox.h"
105 #include "SUIT_ResourceMgr.h"
106 #include "SUIT_FileDlg.h"
107 #include "SUIT_Desktop.h"
108 #include "SUIT_OverrideCursor.h"
109 #include "SUIT_Study.h"
110 #include "SUIT_Session.h"
112 #include "QtxPopupMgr.h"
114 #include "SALOME_ListIO.hxx"
115 #include "SALOME_ListIteratorOfListIO.hxx"
116 #include "SALOME_InteractiveObject.hxx"
117 #include "SALOME_NamingService.hxx"
118 #include "SALOME_LifeCycleCORBA.hxx"
120 #include "SALOMEconfig.h"
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #define INCLUDE_MENUITEM_DEF
125 #include <qpopupmenu.h>
131 #include <boost/shared_ptr.hpp>
134 #include <vtkRenderer.h>
135 #include <vtkRenderWindow.h>
136 #include <vtkActorCollection.h>
137 #include <vtkScalarBarActor.h>
138 #include <vtkUnstructuredGrid.h>
140 #include "utilities.h"
142 #include "SALOMEDS_Study.hxx"
143 #include "SALOMEDSClient_StudyBuilder.hxx"
144 #include "SALOMEDSClient_SComponent.hxx"
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
171 if(theCommandID == 113){
172 filter.append(QObject::tr("MED files (*.med)"));
173 filter.append(QObject::tr("All files (*)"));
174 }else if (theCommandID == 112){
175 filter.append(QObject::tr("IDEAS files (*.unv)"));
176 }else if (theCommandID == 111){
177 filter.append(QObject::tr("DAT files (*.dat)"));
179 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
182 QObject::tr("Import mesh"),
184 if(!filename.isEmpty()) {
185 SUIT_OverrideCursor wc;
186 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
190 switch ( theCommandID ) {
193 aMeshes->length( 1 );
194 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
199 SMESH::DriverMED_ReadStatus res;
200 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
201 if ( res != SMESH::DRS_OK ) {
203 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
204 QObject::tr("SMESH_WRN_WARNING"),
205 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
206 QObject::tr("SMESH_BUT_OK"));
207 aMeshes->length( 0 );
214 bool isEmpty = false;
215 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
216 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
218 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
219 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
220 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
221 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
222 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
229 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
230 QObject::tr("SMESH_WRN_WARNING"),
231 QObject::tr("SMESH_DRS_EMPTY"),
232 QObject::tr("SMESH_BUT_OK"));
236 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
238 catch (const SALOME::SALOME_Exception& S_ex){
240 SalomeApp_Tools::QtCatchCorbaException(S_ex);
247 void ExportMeshToFile( int theCommandID )
249 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
250 SALOME_ListIO selected;
252 aSel->selectedObjects( selected );
254 if(selected.Extent()){
255 Handle(SALOME_InteractiveObject) anIObject = selected.First();
256 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
257 if ( !aMesh->_is_nil() ) {
258 QString aFilter, aTitle = QObject::tr("Export mesh");
259 QMap<QString, SMESH::MED_VERSION> aFilterMap;
260 switch ( theCommandID ) {
264 if (aMesh->HasDuplicatedGroupNamesMED()) {
265 int aRet = SUIT_MessageBox::warn2
266 (SMESHGUI::desktop(),
267 QObject::tr("SMESH_WRN_WARNING"),
268 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
269 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
275 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
276 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
281 aFilter = QObject::tr("DAT files (*.dat)");
286 if (aMesh->NbPyramids()) {
287 int aRet = SUIT_MessageBox::warn2
288 (SMESHGUI::desktop(),
289 QObject::tr("SMESH_WRN_WARNING"),
290 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
291 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
296 aFilter = QObject::tr("IDEAS files (*.unv)");
304 SMESH::MED_VERSION aFormat;
305 // Init the parameter with the default value
306 bool toCreateGroups = false;
307 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
309 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
311 if ( theCommandID != 122 && theCommandID != 125 )
312 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
315 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
316 for ( ; it != aFilterMap.end(); ++it )
317 filters.push_back( it.key() );
319 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
320 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
321 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
322 fd->setCaption( aTitle );
323 fd->setFilters( filters );
324 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
325 fd->SetChecked(toCreateGroups);
329 aFilename = fd->selectedFile();
330 aFormat = aFilterMap[fd->selectedFilter()];
332 if ( !aFilename.isEmpty()
333 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
334 && aFormat==SMESH::MED_V2_1) {
335 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
336 QObject::tr("SMESH_WRN_WARNING"),
337 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
338 QObject::tr("SMESH_BUT_YES"),
339 QObject::tr("SMESH_BUT_NO"),
346 toCreateGroups = fd->IsChecked();
349 if ( !aFilename.isEmpty() ) {
350 // Check whether the file already exists and delete it if yes
351 QFile aFile( aFilename );
352 if ( aFile.exists() )
354 SUIT_OverrideCursor wc;
357 bool Renumber = false ;
358 // PAL 14172 : Check of we have to renumber or not from the preferences before export
360 Renumber= resMgr->booleanValue("SMESH","renumbering");
362 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
363 aMeshEditor->RenumberNodes();
364 aMeshEditor->RenumberElements();
365 if ( SMESHGUI::automaticUpdate() )
368 switch ( theCommandID ) {
371 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
375 aMesh->ExportDAT( aFilename.latin1() );
379 aMesh->ExportUNV( aFilename.latin1() );
385 catch (const SALOME::SALOME_Exception& S_ex){
387 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
388 QObject::tr("SMESH_WRN_WARNING"),
389 QObject::tr("SMESH_EXPORT_FAILED"),
390 QObject::tr("SMESH_BUT_OK"));
398 inline void InverseEntityMode(unsigned int& theOutputMode,
399 unsigned int theMode)
401 bool anIsNotPresent = ~theOutputMode & theMode;
403 theOutputMode |= theMode;
405 theOutputMode &= ~theMode;
408 void SetDisplayEntity(int theCommandID){
409 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
410 SALOME_ListIO selected;
412 aSel->selectedObjects( selected );
414 if(selected.Extent() >= 1){
415 SALOME_ListIteratorOfListIO It( selected );
416 for(; It.More(); It.Next()){
417 Handle(SALOME_InteractiveObject) IObject = It.Value();
418 if(IObject->hasEntry()){
419 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
420 unsigned int aMode = anActor->GetEntityMode();
421 switch(theCommandID){
423 InverseEntityMode(aMode,SMESH_Actor::eEdges);
426 InverseEntityMode(aMode,SMESH_Actor::eFaces);
429 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
432 aMode = SMESH_Actor::eAllEntity;
436 anActor->SetEntityMode(aMode);
443 void SetDisplayMode(int theCommandID){
444 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
445 SALOME_ListIO selected;
447 aSel->selectedObjects( selected );
449 if(selected.Extent() >= 1){
450 switch(theCommandID){
452 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
453 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
457 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
458 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
461 SALOME_ListIteratorOfListIO It( selected );
462 for(; It.More(); It.Next()){
463 Handle(SALOME_InteractiveObject) IObject = It.Value();
464 if(IObject->hasEntry()){
465 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
466 switch(theCommandID){
468 anActor->SetRepresentation(SMESH_Actor::eEdge);
471 anActor->SetRepresentation(SMESH_Actor::eSurface);
474 if(anActor->IsShrunk())
477 anActor->SetShrink();
480 anActor->SetRepresentation(SMESH_Actor::ePoint);
483 vtkFloatingPointType color[3];
484 anActor->GetSufaceColor(color[0], color[1], color[2]);
485 int c0 = int (color[0] * 255);
486 int c1 = int (color[1] * 255);
487 int c2 = int (color[2] * 255);
488 QColor c(c0, c1, c2);
490 vtkFloatingPointType edgecolor[3];
491 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
492 c0 = int (edgecolor[0] * 255);
493 c1 = int (edgecolor[1] * 255);
494 c2 = int (edgecolor[2] * 255);
495 QColor e(c0, c1, c2);
497 vtkFloatingPointType backfacecolor[3];
498 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
499 c0 = int (backfacecolor[0] * 255);
500 c1 = int (backfacecolor[1] * 255);
501 c2 = int (backfacecolor[2] * 255);
502 QColor b(c0, c1, c2);
504 vtkFloatingPointType nodecolor[3];
505 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
506 c0 = int (nodecolor[0] * 255);
507 c1 = int (nodecolor[1] * 255);
508 c2 = int (nodecolor[2] * 255);
509 QColor n(c0, c1, c2);
511 int Edgewidth = (int)anActor->GetLineWidth();
514 int intValue = int(anActor->GetNodeSize());
515 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
517 SMESHGUI_Preferences_ColorDlg *aDlg =
518 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
519 aDlg->SetColor(1, c);
520 aDlg->SetColor(2, e);
521 aDlg->SetColor(3, n);
522 aDlg->SetColor(4, b);
523 aDlg->SetIntValue(1, Edgewidth);
524 aDlg->SetIntValue(2, intValue);
525 aDlg->SetIntValue(3, int(Shrink*100.));
527 QColor color = aDlg->GetColor(1);
528 QColor edgecolor = aDlg->GetColor(2);
529 QColor nodecolor = aDlg->GetColor(3);
530 QColor backfacecolor = aDlg->GetColor(4);
531 /* actor color and backface color */
532 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
533 vtkFloatingPointType (color.green()) / 255.,
534 vtkFloatingPointType (color.blue()) / 255.);
535 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
536 vtkFloatingPointType (backfacecolor.green()) / 255.,
537 vtkFloatingPointType (backfacecolor.blue()) / 255.);
540 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
541 vtkFloatingPointType (edgecolor.green()) / 255.,
542 vtkFloatingPointType (edgecolor.blue()) / 255.);
544 /* Shrink factor and size edges */
545 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
546 anActor->SetLineWidth(aDlg->GetIntValue(1));
548 /* Nodes color and size */
549 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
550 vtkFloatingPointType (nodecolor.green()) / 255.,
551 vtkFloatingPointType (nodecolor.blue()) / 255.);
552 anActor->SetNodeSize(aDlg->GetIntValue(2));
561 SMESH::RepaintCurrentView();
565 void Control( int theCommandID )
567 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
568 SALOME_ListIO selected;
570 aSel->selectedObjects( selected );
572 if( !selected.IsEmpty() ){
573 Handle(SALOME_InteractiveObject) anIO = selected.First();
576 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
577 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
578 switch ( theCommandID ){
580 aTitle = QObject::tr( "LENGTH_EDGES" );
581 aControl = SMESH_Actor::eLength;
584 aTitle = QObject::tr( "LENGTH2D_EDGES" );
585 aControl = SMESH_Actor::eLength2D;
588 aTitle = QObject::tr( "FREE_EDGES" );
589 aControl = SMESH_Actor::eFreeEdges;
592 aTitle = QObject::tr( "FREE_BORDERS" );
593 aControl = SMESH_Actor::eFreeBorders;
596 aTitle = QObject::tr( "MULTI_BORDERS" );
597 aControl = SMESH_Actor::eMultiConnection;
600 aTitle = QObject::tr( "MULTI2D_BORDERS" );
601 aControl = SMESH_Actor::eMultiConnection2D;
604 aTitle = QObject::tr( "AREA_ELEMENTS" );
605 aControl = SMESH_Actor::eArea;
608 aTitle = QObject::tr( "TAPER_ELEMENTS" );
609 aControl = SMESH_Actor::eTaper;
612 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
613 aControl = SMESH_Actor::eAspectRatio;
616 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
617 aControl = SMESH_Actor::eAspectRatio3D;
620 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
621 aControl = SMESH_Actor::eMinimumAngle;
624 aTitle = QObject::tr( "WARP_ELEMENTS" );
625 aControl = SMESH_Actor::eWarping;
628 aTitle = QObject::tr( "SKEW_ELEMENTS" );
629 aControl = SMESH_Actor::eSkew;
632 aTitle = QObject::tr( "SMESH_VOLUME" );
633 aControl = SMESH_Actor::eVolume3D;
636 anActor->SetControlMode(aControl);
637 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
638 SMESH::RepaintCurrentView();
645 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
646 MeshObjectType theType,
647 const QString theInTypeName,
648 QString & theOutTypeName)
650 SMESH_TypeFilter aTypeFilter( theType );
652 if( !theIO.IsNull() )
654 entry = theIO->getEntry();
655 LightApp_DataOwner owner( entry );
656 if ( aTypeFilter.isOk( &owner )) {
657 theOutTypeName = theInTypeName;
665 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
667 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
668 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
670 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
671 CORBA::String_var anID = aSComp->GetID().c_str();
672 if (!strcmp(anID.in(),theIO->getEntry()))
678 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
679 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
680 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
681 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
682 CheckOIType ( theIO, GROUP, "Group", aTypeName )
690 QString CheckHomogeneousSelection()
692 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
693 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
694 SALOME_ListIO selected;
696 aSel->selectedObjects( selected );
698 QString RefType = CheckTypeObject(selected.First());
699 SALOME_ListIteratorOfListIO It(selected);
700 for (; It.More(); It.Next())
702 Handle(SALOME_InteractiveObject) IObject = It.Value();
703 QString Type = CheckTypeObject(IObject);
704 if (Type.compare(RefType) != 0)
705 return "Heterogeneous Selection";
712 void SMESHGUI::OnEditDelete()
714 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
715 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
716 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
718 QString aParentComponent = QString::null;
719 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
721 QString cur = anIt.Value()->getComponentDataType();
722 if( aParentComponent.isNull() )
723 aParentComponent = cur;
724 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
725 aParentComponent = "";
728 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
729 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
730 QObject::tr("ERR_ERROR"),
731 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
732 QObject::tr("BUT_OK") );
735 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
736 if (SUIT_MessageBox::warn2
737 (SMESHGUI::desktop(),
738 QObject::tr("SMESH_WRN_WARNING"),
739 QObject::tr("SMESH_REALLY_DELETE"),
740 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
743 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
744 SUIT_ViewManager* vm = anApp->activeViewManager();
745 int nbSf = vm->getViewsCount();
747 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
748 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
749 _PTR(GenericAttribute) anAttr;
750 _PTR(AttributeIOR) anIOR;
752 SALOME_ListIteratorOfListIO It(selected);
754 aStudyBuilder->NewCommand(); // There is a transaction
755 for(; It.More(); It.Next()){ // loop on selected IO's
756 Handle(SALOME_InteractiveObject) IObject = It.Value();
757 if(IObject->hasEntry()) {
758 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
760 // disable removal of "SMESH" component object
761 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
763 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
767 // put the whole hierarchy of sub-objects of the selected SO into a list and
768 // then treat them all starting from the deepest objects (at list back)
770 list< _PTR(SObject) > listSO;
771 listSO.push_back( aSO );
772 list< _PTR(SObject) >::iterator itSO = listSO.begin();
773 for ( ; itSO != listSO.end(); ++itSO ) {
774 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
775 for (it->InitEx(false); it->More(); it->Next())
776 listSO.push_back( it->Value() );
779 // treat SO's in the list starting from the back
781 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
782 for ( ; ritSO != listSO.rend(); ++ritSO ) {
783 _PTR(SObject) SO = *ritSO;
785 string anEntry = SO->GetID();
787 /** Erase graphical object **/
788 if(SO->FindAttribute(anAttr, "AttributeIOR")){
789 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
790 for(int i = 0; i < nbSf; i++){
791 SUIT_ViewWindow *sf = aViews[i];
792 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
793 SMESH::RemoveActor(sf,anActor);
798 /** Remove an object from data structures **/
799 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
800 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
801 if ( !aGroup->_is_nil() ) { // DELETE GROUP
802 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
803 aMesh->RemoveGroup( aGroup );
805 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
806 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
807 aMesh->RemoveSubMesh( aSubMesh );
809 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
811 SMESH::ModifiedMesh(aMeshSO, false);
814 IObject = new SALOME_InteractiveObject
815 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
816 QString objType = CheckTypeObject(IObject);
817 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
818 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
819 aStudyBuilder->RemoveObjectWithChildren( SO );
821 else {// default action: remove SObject from the study
822 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
823 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
825 aStudyBuilder->RemoveObjectWithChildren( SO );
829 } /* listSO back loop */
830 } /* IObject->hasEntry() */
832 aStudyBuilder->CommitCommand();
834 /* Clear any previous selection */
836 aSel->setSelectedObjects( l1 );
838 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
843 Standard_EXPORT CAM_Module* createModule()
845 return new SMESHGUI();
849 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
851 //=============================================================================
855 //=============================================================================
856 SMESHGUI::SMESHGUI() :
857 SalomeApp_Module( "SMESH" )
859 if ( CORBA::is_nil( myComponentSMESH ) )
861 CORBA::Boolean anIsEmbeddedMode;
862 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
865 myActiveDialogBox = 0;
866 myFilterLibraryDlg = 0;
870 SMESH::GetFilterManager();
873 /* load resources for all available meshers */
874 SMESH::InitAvailableHypotheses();
877 //=============================================================================
881 //=============================================================================
882 SMESHGUI::~SMESHGUI()
884 SMESH::GetFilterManager()->Destroy();
885 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
888 //=============================================================================
892 //=============================================================================
893 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
895 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
897 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
902 bool SMESHGUI::automaticUpdate()
904 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
908 return resMgr->booleanValue( "SMESH", "auto_update", false );
911 //=============================================================================
915 //=============================================================================
916 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
918 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
921 //=============================================================================
925 //=============================================================================
926 SMESHGUI* SMESHGUI::GetSMESHGUI()
928 SMESHGUI* smeshMod = 0;
929 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
932 CAM_Module* module = app->module( "Mesh" );
933 smeshMod = dynamic_cast<SMESHGUI*>( module );
936 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
938 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
941 _PTR(Study) aStudy = study->studyDS();
943 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
952 Standard_EXPORT SMESHGUI* GetComponentGUI()
954 return SMESHGUI::GetSMESHGUI();
958 //=============================================================================
962 //=============================================================================
963 void SMESHGUI::SetState(int aState)
968 //=============================================================================
972 //=============================================================================
973 void SMESHGUI::ResetState()
978 //=============================================================================
982 //=============================================================================
983 void SMESHGUI::EmitSignalDeactivateDialog()
985 emit SignalDeactivateActiveDialog();
988 //=============================================================================
992 //=============================================================================
993 void SMESHGUI::EmitSignalStudyFrameChanged()
995 emit SignalStudyFrameChanged();
998 //=============================================================================
1002 //=============================================================================
1003 void SMESHGUI::EmitSignalCloseAllDialogs()
1005 emit SignalCloseAllDialogs();
1008 //=============================================================================
1012 //=============================================================================
1013 QDialog *SMESHGUI::GetActiveDialogBox()
1015 return myActiveDialogBox;
1018 //=============================================================================
1022 //=============================================================================
1023 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1025 myActiveDialogBox = (QDialog *) aDlg;
1029 //=============================================================================
1033 //=============================================================================
1034 SUIT_Desktop* SMESHGUI::desktop()
1036 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1038 return app->desktop();
1043 //=============================================================================
1047 //=============================================================================
1048 SalomeApp_Study* SMESHGUI::activeStudy()
1050 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1052 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1057 //=============================================================================
1061 //=============================================================================
1062 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1064 /* Here the position is on the bottom right corner - 10 */
1065 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1067 SUIT_Desktop *PP = desktop();
1068 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1069 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1073 //=============================================================================
1077 //=============================================================================
1078 static int isStudyLocked(_PTR(Study) theStudy){
1079 return theStudy->GetProperties()->IsLocked();
1082 static bool checkLock(_PTR(Study) theStudy) {
1083 if (isStudyLocked(theStudy)) {
1084 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1085 QObject::tr("WRN_WARNING"),
1086 QObject::tr("WRN_STUDY_LOCKED"),
1087 QObject::tr("BUT_OK") );
1093 //=======================================================================
1094 //function : CheckActiveStudyLocked
1096 //=======================================================================
1098 bool SMESHGUI::isActiveStudyLocked()
1100 _PTR(Study) aStudy = activeStudy()->studyDS();
1101 return checkLock( aStudy );
1104 //=============================================================================
1108 //=============================================================================
1109 bool SMESHGUI::OnGUIEvent( int theCommandID )
1111 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1115 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1116 SUIT_ResourceMgr* mgr = resourceMgr();
1120 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1121 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1124 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1125 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1127 //QAction* act = action( theCommandID );
1129 switch (theCommandID) {
1131 if(checkLock(aStudy)) break;
1139 if(checkLock(aStudy)) break;
1140 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1144 case 122: // EXPORT MED
1151 ::ExportMeshToFile(theCommandID);
1155 case 200: // SCALAR BAR
1157 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1158 SALOME_ListIO selected;
1160 aSel->selectedObjects( selected );
1162 if( selected.Extent() ) {
1163 Handle(SALOME_InteractiveObject) anIO = selected.First();
1164 if( anIO->hasEntry() ) {
1165 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1166 anActor->SetControlMode( SMESH_Actor::eNone );
1174 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1178 case 1134: // Clipping
1179 case 1133: // Tranparency
1180 case 1132: // Colors / Size
1187 ::SetDisplayMode(theCommandID);
1193 case 219: // Volumes
1194 case 220: // All Entity
1195 ::SetDisplayEntity(theCommandID);
1200 if(checkLock(aStudy)) break;
1201 SMESH::UpdateView();
1204 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1205 aSel->selectedObjects( l );
1206 aSel->setSelectedObjects( l );
1211 case 301: // DISPLAY
1212 case 302: // DISPLAY ONLY
1214 SMESH::EDisplaing anAction;
1215 switch (theCommandID) {
1216 case 300: anAction = SMESH::eErase; break;
1217 case 301: anAction = SMESH::eDisplay; break;
1218 case 302: anAction = SMESH::eDisplayOnly; break;
1221 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1222 SALOME_ListIO sel_objects, to_process;
1224 aSel->selectedObjects( sel_objects );
1226 if( theCommandID==302 )
1227 startOperation( myEraseAll );
1229 extractContainers( sel_objects, to_process );
1232 SALOME_ListIteratorOfListIO It( to_process );
1233 for (; It.More(); It.Next()) {
1234 Handle(SALOME_InteractiveObject) IOS = It.Value();
1235 if (IOS->hasEntry()) {
1236 SMESH::UpdateView(anAction, IOS->getEntry());
1237 if (anAction == SMESH::eDisplayOnly)
1238 anAction = SMESH::eDisplay;
1244 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) && !automaticUpdate() )
1245 SMESH::UpdateView();
1248 if (anAction == SMESH::eErase) {
1250 aSel->setSelectedObjects( l1 );
1253 aSel->setSelectedObjects( to_process );
1260 if(checkLock(aStudy)) break;
1263 EmitSignalDeactivateDialog();
1265 new SMESHGUI_NodesDlg(this);
1268 SUIT_MessageBox::warn1(desktop(),
1269 tr("SMESH_WRN_WARNING"),
1270 tr("SMESH_WRN_VIEWER_VTK"),
1271 tr("SMESH_BUT_OK"));
1276 case 2151: // FILTER
1280 EmitSignalDeactivateDialog();
1281 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1286 case 406: // MOVE NODE
1290 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1291 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1295 if(checkLock(aStudy)) break;
1296 new SMESHGUI_MoveNodesDlg(this);
1300 case 701: // COMPUTE MESH
1302 if(checkLock(aStudy)) break;
1304 LightApp_SelectionMgr *Sel = selectionMgr();
1305 SALOME_ListIO selected; Sel->selectedObjects( selected );
1308 int nbSel = selected.Extent();
1310 SUIT_MessageBox::warn1(desktop(),
1311 tr("SMESH_WRN_WARNING"),
1312 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1313 tr("SMESH_BUT_OK"));
1317 SMESH::SMESH_Mesh_var aMesh;
1318 SMESH::SMESH_subMesh_var aSubMesh;
1319 Handle(SALOME_InteractiveObject) IObject = selected.First();
1320 if (IObject->hasEntry()) {
1321 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1322 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1323 if ( aShapeObject->_is_nil() ) {
1328 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1329 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1330 if ( !aSubMesh->_is_nil() )
1331 aMesh = aSubMesh->GetFather();
1333 if (!aMesh->_is_nil()) {
1334 // if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1335 // SUIT_MessageBox::warn1(desktop(),
1336 // tr("SMESH_WRN_WARNING"),
1337 // tr("SMESH_WRN_MISSING_PARAMETERS"),
1338 // tr("SMESH_BUT_OK"));
1341 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1342 if ( errors->length() > 0 ) {
1343 SUIT_MessageBox::warn1(desktop(),
1344 tr("SMESH_WRN_WARNING"),
1345 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1346 tr("SMESH_BUT_OK"));
1350 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1351 SMESH::ModifiedMesh(aMeshSObj,true);
1353 SUIT_MessageBox::warn1(desktop(),
1354 tr("SMESH_WRN_WARNING"),
1355 tr("SMESH_WRN_COMPUTE_FAILED"),
1356 tr("SMESH_BUT_OK"));
1358 catch(const SALOME::SALOME_Exception & S_ex){
1359 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1364 CORBA::Long anId = aStudy->StudyId();
1365 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1366 if ( automaticUpdate() && aVisualObj){
1367 aVisualObj->Update();
1368 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1370 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1372 SMESH::DisplayActor(view,anActor); //apo
1376 SMESH::RepaintCurrentView();
1380 SUIT_MessageBox::warn1(desktop(),
1381 tr("SMESH_WRN_WARNING"),
1382 tr("SMESH_WRN_VIEWER_VTK"),
1383 tr("SMESH_BUT_OK"));
1386 Sel->setSelectedObjects( selected );
1390 case 702: // Create mesh
1391 startOperation( 702 );
1393 case 703: // Create sub-mesh
1394 startOperation( 703 );
1396 case 704: // Edit mesh/sub-mesh
1397 startOperation( 704 );
1399 case 407: // DIAGONAL INVERSION
1400 case 408: // Delete diagonal
1404 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1405 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1409 if ( checkLock( aStudy ) )
1412 /*Standard_Boolean aRes;
1413 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1414 if ( aMesh->_is_nil() )
1416 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1417 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1421 EmitSignalDeactivateDialog();
1422 if ( theCommandID == 407 )
1423 new SMESHGUI_TrianglesInversionDlg(this);
1425 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1428 case 409: // Change orientation
1429 case 410: // Union of triangles
1430 case 411: // Cutting of quadrangles
1434 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1435 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1439 if ( checkLock( aStudy ) )
1442 EmitSignalDeactivateDialog();
1443 SMESHGUI_MultiEditDlg* aDlg = NULL;
1444 if ( theCommandID == 409 )
1445 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1446 else if ( theCommandID == 410 )
1447 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1449 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1454 case 412: // Smoothing
1456 if(checkLock(aStudy)) break;
1458 EmitSignalDeactivateDialog();
1459 new SMESHGUI_SmoothingDlg( this );
1462 SUIT_MessageBox::warn1(desktop(),
1463 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1464 tr("SMESH_BUT_OK"));
1468 case 413: // Extrusion
1470 if (checkLock(aStudy)) break;
1472 EmitSignalDeactivateDialog();
1473 new SMESHGUI_ExtrusionDlg ( this );
1475 SUIT_MessageBox::warn1(desktop(),
1476 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1477 tr("SMESH_BUT_OK"));
1481 case 414: // Revolution
1483 if(checkLock(aStudy)) break;
1485 EmitSignalDeactivateDialog();
1486 new SMESHGUI_RevolutionDlg( this );
1489 SUIT_MessageBox::warn1(desktop(),
1490 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1491 tr("SMESH_BUT_OK"));
1495 case 415: // Pattern mapping
1497 if ( checkLock( aStudy ) )
1501 EmitSignalDeactivateDialog();
1502 new SMESHGUI_MeshPatternDlg( this );
1505 SUIT_MessageBox::warn1(desktop(),
1506 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1507 tr("SMESH_BUT_OK"));
1511 case 416: // Extrusion along a path
1513 if (checkLock(aStudy)) break;
1515 EmitSignalDeactivateDialog();
1516 new SMESHGUI_ExtrusionAlongPathDlg( this );
1518 SUIT_MessageBox::warn1(desktop(),
1519 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1520 tr("SMESH_BUT_OK"));
1524 case 417: // Convert mesh to quadratic
1526 startOperation( 417 );
1527 /* if (checkLock(aStudy)) break;
1529 EmitSignalDeactivateDialog();
1530 new SMESHGUI_ConvToQuadDlg();
1532 SUIT_MessageBox::warn1(desktop(),
1533 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1534 tr("SMESH_BUT_OK"));
1538 case 801: // CREATE GROUP
1542 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1543 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1547 if(checkLock(aStudy)) break;
1548 EmitSignalDeactivateDialog();
1549 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1551 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1552 SALOME_ListIO selected;
1554 aSel->selectedObjects( selected );
1556 int nbSel = selected.Extent();
1558 // check if mesh is selected
1559 aMesh = SMESH::GetMeshByIO( selected.First() );
1561 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1566 case 802: // CONSTRUCT GROUP
1570 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1571 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1575 if(checkLock(aStudy)) break;
1576 EmitSignalDeactivateDialog();
1578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1579 SALOME_ListIO selected;
1581 aSel->selectedObjects( selected );
1583 int nbSel = selected.Extent();
1585 // check if submesh is selected
1586 Handle(SALOME_InteractiveObject) IObject = selected.First();
1587 if (IObject->hasEntry()) {
1588 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1590 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1591 if (!aSubMesh->_is_nil()) {
1593 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1594 // get submesh elements list by types
1595 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1596 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1597 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1598 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1599 // create group for each type o elements
1600 QString aName = IObject->getName();
1601 if (aNodes->length() > 0) {
1602 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1603 aGroup->Add(aNodes.inout());
1605 if (aEdges->length() > 0) {
1606 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1607 aGroup->Add(aEdges.inout());
1609 if (aFaces->length() > 0) {
1610 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1611 aGroup->Add(aFaces.inout());
1613 if (aVolumes->length() > 0) {
1614 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1615 aGroup->Add(aVolumes.inout());
1620 catch(const SALOME::SALOME_Exception & S_ex){
1621 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1628 SUIT_MessageBox::warn1(desktop(),
1629 tr("SMESH_WRN_WARNING"),
1630 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1631 tr("SMESH_BUT_OK"));
1636 case 803: // EDIT GROUP
1640 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1641 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1645 if(checkLock(aStudy)) break;
1646 EmitSignalDeactivateDialog();
1648 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1649 SALOME_ListIO selected;
1651 aSel->selectedObjects( selected );
1653 SALOME_ListIteratorOfListIO It (selected);
1654 int nbSelectedGroups = 0;
1655 for ( ; It.More(); It.Next() )
1657 SMESH::SMESH_GroupBase_var aGroup =
1658 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1659 if (!aGroup->_is_nil()) {
1661 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1665 if (nbSelectedGroups == 0)
1667 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1673 case 804: // Add elements to group
1675 if(checkLock(aStudy)) break;
1676 if (myState == 800) {
1677 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1678 if (aDlg) aDlg->onAdd();
1683 case 805: // Remove elements from group
1685 if(checkLock(aStudy)) break;
1686 if (myState == 800) {
1687 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1688 if (aDlg) aDlg->onRemove();
1693 case 810: // Union Groups
1694 case 811: // Intersect groups
1695 case 812: // Cut groups
1699 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1700 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1704 if ( checkLock( aStudy ) )
1707 EmitSignalDeactivateDialog();
1710 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1711 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1712 else aMode = SMESHGUI_GroupOpDlg::CUT;
1714 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1718 case 813: // Delete groups with their contents
1722 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1723 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1727 if ( checkLock( aStudy ) )
1730 EmitSignalDeactivateDialog();
1732 new SMESHGUI_DeleteGroupDlg( this );
1736 case 900: // MESH INFOS
1738 EmitSignalDeactivateDialog();
1739 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1740 SALOME_ListIO selected;
1742 aSel->selectedObjects( selected );
1744 if ( selected.Extent() > 1 ) { // a dlg for each IO
1746 SALOME_ListIteratorOfListIO It (selected);
1747 for ( ; It.More(); It.Next() ) {
1748 IOs.Clear(); IOs.Append( It.Value() );
1749 aSel->setSelectedObjects( IOs );
1750 new SMESHGUI_MeshInfosDlg(this, "", false);
1752 // restore selection
1753 aSel->setSelectedObjects( selected );
1756 new SMESHGUI_MeshInfosDlg(this, "", false);
1760 case 902: // STANDARD MESH INFOS
1762 EmitSignalDeactivateDialog();
1763 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1764 SALOME_ListIO selected;
1766 aSel->selectedObjects( selected );
1768 if ( selected.Extent() > 1 ) { // a dlg for each IO
1770 SALOME_ListIteratorOfListIO It (selected);
1771 for ( ; It.More(); It.Next() ) {
1773 IOs.Append( It.Value() );
1774 aSel->setSelectedObjects( IOs );
1775 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1777 // restore selection
1778 aSel->setSelectedObjects( selected );
1781 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1785 case 1100: // EDIT HYPOTHESIS
1787 if(checkLock(aStudy)) break;
1789 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1790 SALOME_ListIO selected;
1792 aSel->selectedObjects( selected );
1794 int nbSel = selected.Extent();
1797 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1799 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1800 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1801 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1802 if ( !Hyp->_is_nil() )
1804 char* sName = Hyp->GetName();
1805 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1807 aCreator->edit( Hyp.in(), desktop() );
1814 updateObjBrowser( true );
1818 case 1101: // RENAME
1820 if ( checkLock( aStudy ) )
1823 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1824 SALOME_ListIO selected;
1826 aSel->selectedObjects( selected );
1828 SALOME_ListIteratorOfListIO It( selected );
1829 for ( ; It.More(); It.Next() )
1831 Handle(SALOME_InteractiveObject) IObject = It.Value();
1832 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1833 _PTR(GenericAttribute) anAttr;
1834 _PTR(AttributeName) aName;
1837 if ( obj->FindAttribute(anAttr, "AttributeName") )
1840 QString newName = QString(aName->Value().c_str());
1841 newName = LightApp_NameDlg::getName(desktop(), newName);
1842 if ( !newName.isEmpty() )
1844 //old source: aStudy->renameIObject( IObject, newName );
1845 aName->SetValue( newName.latin1() );
1847 // if current object is group update group's name
1848 SMESH::SMESH_GroupBase_var aGroup =
1849 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1850 if (!aGroup->_is_nil() )
1851 aGroup->SetName( newName.latin1() );
1861 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1863 if(checkLock(aStudy)) break;
1864 SUIT_OverrideCursor wc;
1866 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1867 SALOME_ListIO selected;
1869 aSel->selectedObjects( selected, QString::null, false );
1871 SALOME_ListIteratorOfListIO It(selected);
1872 for (int i = 0; It.More(); It.Next(), i++) {
1873 Handle(SALOME_InteractiveObject) IObject = It.Value();
1874 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1877 aSel->setSelectedObjects( l1 );
1882 case 401: // GEOM::EDGE
1883 case 4021: // TRIANGLE
1885 case 4023: // POLYGON
1889 if(checkLock(aStudy)) break;
1891 EmitSignalDeactivateDialog();
1892 SMDSAbs_ElementType type = SMDSAbs_Edge;
1894 switch (theCommandID) {
1895 case 4021: // TRIANGLE
1896 type = SMDSAbs_Face; nbNodes = 3; break;
1898 type = SMDSAbs_Face; nbNodes = 4; break;
1900 type = SMDSAbs_Volume; nbNodes = 4; break;
1901 case 4023: // POLYGON
1902 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1904 type = SMDSAbs_Volume; nbNodes = 8; break;
1905 case 4033: // POLYHEDRE
1906 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1909 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1912 SUIT_MessageBox::warn1(desktop(),
1913 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1914 tr("SMESH_BUT_OK"));
1918 case 4033: // POLYHEDRON
1920 if(checkLock(aStudy)) break;
1922 EmitSignalDeactivateDialog();
1923 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1926 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1927 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1928 tr("SMESH_BUT_OK"));
1932 case 4034: // QUADRATIC EDGE
1933 case 4035: // QUADRATIC TRIANGLE
1934 case 4036: // QUADRATIC QUADRANGLE
1935 case 4037: // QUADRATIC TETRAHEDRON
1936 case 4038: // QUADRATIC PYRAMID
1937 case 4039: // QUADRATIC PENTAHEDRON
1938 case 4040: // QUADRATIC HEXAHEDRON
1940 if(checkLock(aStudy)) break;
1942 EmitSignalDeactivateDialog();
1945 switch (theCommandID) {
1947 type = QUAD_EDGE; break;
1949 type = QUAD_TRIANGLE; break;
1951 type = QUAD_QUADRANGLE; break;
1953 type = QUAD_TETRAHEDRON; break;
1955 type = QUAD_PYRAMID; break;
1957 type = QUAD_PENTAHEDRON; break;
1959 type = QUAD_HEXAHEDRON;
1963 new SMESHGUI_AddQuadraticElementDlg( this, type );
1966 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1967 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1968 tr("SMESH_BUT_OK"));
1972 case 4041: // REMOVES NODES
1974 if(checkLock(aStudy)) break;
1976 EmitSignalDeactivateDialog();
1977 new SMESHGUI_RemoveNodesDlg(this);
1980 SUIT_MessageBox::warn1(desktop(),
1981 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1982 tr("SMESH_BUT_OK"));
1986 case 4042: // REMOVES ELEMENTS
1988 if(checkLock(aStudy)) break;
1990 EmitSignalDeactivateDialog();
1991 new SMESHGUI_RemoveElementsDlg(this);
1995 SUIT_MessageBox::warn1(desktop(),
1996 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1997 tr("SMESH_BUT_OK"));
2001 case 4051: // RENUMBERING NODES
2003 if(checkLock(aStudy)) break;
2005 EmitSignalDeactivateDialog();
2006 new SMESHGUI_RenumberingDlg( this, "", 0);
2010 SUIT_MessageBox::warn1(desktop(),
2011 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2012 tr("SMESH_BUT_OK"));
2016 case 4052: // RENUMBERING ELEMENTS
2018 if(checkLock(aStudy)) break;
2020 EmitSignalDeactivateDialog();
2021 new SMESHGUI_RenumberingDlg( this, "", 1);
2025 SUIT_MessageBox::warn1(desktop(),
2026 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2027 tr("SMESH_BUT_OK"));
2031 case 4061: // TRANSLATION
2033 if(checkLock(aStudy)) break;
2035 EmitSignalDeactivateDialog();
2036 new SMESHGUI_TranslationDlg( this );
2039 SUIT_MessageBox::warn1(desktop(),
2040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2041 tr("SMESH_BUT_OK"));
2045 case 4062: // ROTATION
2047 if(checkLock(aStudy)) break;
2049 EmitSignalDeactivateDialog();
2050 new SMESHGUI_RotationDlg( this );
2053 SUIT_MessageBox::warn1(desktop(),
2054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2055 tr("SMESH_BUT_OK"));
2059 case 4063: // SYMMETRY
2061 if(checkLock(aStudy)) break;
2063 EmitSignalDeactivateDialog();
2064 new SMESHGUI_SymmetryDlg( this );
2067 SUIT_MessageBox::warn1(desktop(),
2068 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2069 tr("SMESH_BUT_OK"));
2073 case 4064: // SEWING
2075 if(checkLock(aStudy)) break;
2077 EmitSignalDeactivateDialog();
2078 new SMESHGUI_SewingDlg( this );
2081 SUIT_MessageBox::warn1(desktop(),
2082 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2083 tr("SMESH_BUT_OK"));
2087 case 4065: // MERGE NODES
2089 if(checkLock(aStudy)) break;
2091 EmitSignalDeactivateDialog();
2092 new SMESHGUI_MergeNodesDlg( this );
2095 SUIT_MessageBox::warn1(desktop(),
2096 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2097 tr("SMESH_BUT_OK"));
2101 case 4066: // MERGE EQUAL ELEMENTS
2103 if (checkLock(aStudy)) break;
2105 EmitSignalDeactivateDialog();
2106 new SMESHGUI_EditMeshDlg(this,
2107 "SMESH_MERGE_ELEMENTS_TITLE",
2108 "ICON_DLG_MERGE_ELEMENTS",
2109 1); // MergeEqualElemets
2111 SUIT_MessageBox::warn1(desktop(),
2112 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2113 tr("SMESH_BUT_OK"));
2118 case 5105: // Library of selection filters
2120 static QValueList<int> aTypes;
2121 if ( aTypes.isEmpty() )
2123 aTypes.append( SMESH::NODE );
2124 aTypes.append( SMESH::EDGE );
2125 aTypes.append( SMESH::FACE );
2126 aTypes.append( SMESH::VOLUME );
2128 if (!myFilterLibraryDlg)
2129 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2130 else if (myFilterLibraryDlg->isHidden())
2131 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2132 myFilterLibraryDlg->raise();
2136 case 6017: // CONTROLS
2152 LightApp_SelectionMgr* mgr = selectionMgr();
2153 SALOME_ListIO selected; mgr->selectedObjects( selected );
2155 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2156 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2158 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2159 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2160 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2161 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2162 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2163 ::Control( theCommandID );
2168 SUIT_MessageBox::warn1(desktop(),
2169 tr( "SMESH_WRN_WARNING" ),
2170 tr( "SMESH_BAD_SELECTION" ),
2171 tr( "SMESH_BUT_OK" ) );
2175 SUIT_MessageBox::warn1(desktop(),
2176 tr( "SMESH_WRN_WARNING" ),
2177 tr( "NOT_A_VTK_VIEWER" ),
2178 tr( "SMESH_BUT_OK" ) );
2183 LightApp_SelectionMgr* mgr = selectionMgr();
2184 SALOME_ListIO selected; mgr->selectedObjects( selected );
2186 SALOME_ListIteratorOfListIO it(selected);
2187 for(; it.More(); it.Next()) {
2188 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2189 if(anIObject->hasEntry()) {
2190 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2191 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2199 LightApp_SelectionMgr* mgr = selectionMgr();
2200 SALOME_ListIO selected; mgr->selectedObjects( selected );
2202 if (selected.Extent() == 1) {
2203 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2204 if(anIObject->hasEntry())
2205 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2206 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2213 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2214 //updateObjBrowser();
2218 //=============================================================================
2222 //=============================================================================
2223 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2228 //=============================================================================
2232 //=============================================================================
2233 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2238 //=============================================================================
2242 //=============================================================================
2243 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2248 //=============================================================================
2249 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2250 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2252 //=============================================================================
2253 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2254 SUIT_ViewWindow* wnd )
2256 if(theIO->hasEntry()){
2257 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2258 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2262 //=======================================================================
2263 // function : createSMESHAction
2265 //=======================================================================
2266 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2269 QWidget* parent = application()->desktop();
2270 SUIT_ResourceMgr* resMgr = resourceMgr();
2272 if ( icon_id.length() )
2273 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2275 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2276 if ( !pix.isNull() )
2277 icon = QIconSet( pix );
2279 QString tooltip = tr( QString( "TOP_" )+po_id ),
2280 menu = tr( QString( "MEN_" )+po_id ),
2281 status_bar = tr( QString( "STB_" )+po_id );
2283 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2286 //=======================================================================
2287 // function : createPopupItem
2289 //=======================================================================
2290 void SMESHGUI::createPopupItem( const int id,
2291 const QString& clients,
2292 const QString& types,
2293 const QString& theRule,
2298 parentId = popupMgr()->actionId( action( pId ) );
2300 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2301 popupMgr()->insert( action( id ), parentId, 0 );
2303 QChar lc = QtxPopupMgr::Selection::defEquality();
2304 QString rule = "(%1) and (%2) and (%3)";
2305 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2306 if( clients.isEmpty() )
2307 rule = rule.arg( QString( "true" ) );
2309 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2310 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2313 bool cont = myRules.contains( id );
2315 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2317 popupMgr()->setRule( action( id ), rule, true );
2318 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2321 //=======================================================================
2322 // function : initialize
2324 //=======================================================================
2325 void SMESHGUI::initialize( CAM_Application* app )
2327 SalomeApp_Module::initialize( app );
2329 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2331 /* Automatic Update flag */
2332 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2334 // ----- create actions --------------
2336 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2337 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2338 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2339 createSMESHAction( 114, "NUM" );
2340 createSMESHAction( 121, "DAT" );
2341 createSMESHAction( 122, "MED" );
2342 createSMESHAction( 123, "UNV" );
2343 createSMESHAction( 124, "EXPORT_DAT" );
2344 createSMESHAction( 125, "EXPORT_MED" );
2345 createSMESHAction( 126, "EXPORT_UNV" );
2346 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2347 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2348 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2349 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2350 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2351 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2352 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2353 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2354 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2355 createSMESHAction( 804, "ADD" );
2356 createSMESHAction( 805, "REMOVE" );
2357 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2358 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2359 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2360 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2361 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2362 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2363 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2364 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2365 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2366 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2367 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2368 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2369 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2370 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2371 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2372 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2373 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2374 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2375 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2376 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2377 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2378 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2379 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2380 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2381 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2382 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2383 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2384 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2385 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2386 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2387 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2388 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2389 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2390 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2391 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2392 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2393 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
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( 407, modifyId, -1 );
2543 createMenu( 408, modifyId, -1 );
2544 createMenu( 409, modifyId, -1 );
2545 createMenu( 410, modifyId, -1 );
2546 createMenu( 411, modifyId, -1 );
2547 createMenu( 412, modifyId, -1 );
2548 createMenu( 413, modifyId, -1 );
2549 createMenu( 416, modifyId, -1 );
2550 createMenu( 414, modifyId, -1 );
2551 createMenu( 415, modifyId, -1 );
2552 createMenu( 417, modifyId, -1 );
2554 createMenu( 214, viewId, -1 );
2556 // ----- create toolbars --------------
2557 int meshTb = createTool( tr( "TB_MESH" ) ),
2558 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2559 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2560 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2561 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2563 createTool( 702, meshTb );
2564 createTool( 703, meshTb );
2565 createTool( 704, meshTb );
2566 createTool( separator(), meshTb );
2567 createTool( 701, meshTb );
2568 createTool( separator(), meshTb );
2569 createTool( 801, meshTb );
2570 createTool( 802, meshTb );
2571 createTool( 803, meshTb );
2572 createTool( separator(), meshTb );
2573 createTool( 900, meshTb );
2574 createTool( 902, meshTb );
2575 createTool( separator(), meshTb );
2577 createTool( 6001, ctrlTb );
2578 createTool( 6003, ctrlTb );
2579 createTool( 6004, ctrlTb );
2580 createTool( separator(), ctrlTb );
2581 createTool( 6002, ctrlTb );
2582 createTool( 6018, ctrlTb );
2583 createTool( 6019, ctrlTb );
2584 createTool( 6011, ctrlTb );
2585 createTool( 6012, ctrlTb );
2586 createTool( 6013, ctrlTb );
2587 createTool( 6014, ctrlTb );
2588 createTool( 6015, ctrlTb );
2589 createTool( 6016, ctrlTb );
2590 createTool( separator(), ctrlTb );
2591 createTool( 6017, ctrlTb );
2592 createTool( 6009, ctrlTb );
2593 createTool( separator(), ctrlTb );
2595 createTool( 400, addRemTb );
2596 createTool( 401, addRemTb );
2597 createTool( 4021, addRemTb );
2598 createTool( 4022, addRemTb );
2599 createTool( 4023, addRemTb );
2600 createTool( 4031, addRemTb );
2601 createTool( 4032, addRemTb );
2602 createTool( 4033, addRemTb );
2603 createTool( separator(), addRemTb );
2604 createTool( 4034, addRemTb );
2605 createTool( 4035, addRemTb );
2606 createTool( 4036, addRemTb );
2607 createTool( 4037, addRemTb );
2608 createTool( 4038, addRemTb );
2609 createTool( 4039, addRemTb );
2610 createTool( 4040, addRemTb );
2611 createTool( separator(), addRemTb );
2612 createTool( 4041, addRemTb );
2613 createTool( 4042, addRemTb );
2614 createTool( separator(), addRemTb );
2615 createTool( 4051, addRemTb );
2616 createTool( 4052, addRemTb );
2617 createTool( separator(), addRemTb );
2618 createTool( 4061, addRemTb );
2619 createTool( 4062, addRemTb );
2620 createTool( 4063, addRemTb );
2621 createTool( 4064, addRemTb );
2622 createTool( 4065, addRemTb );
2623 createTool( 4066, addRemTb );
2624 createTool( separator(), addRemTb );
2626 createTool( 406, modifyTb );
2627 createTool( 407, modifyTb );
2628 createTool( 408, modifyTb );
2629 createTool( 409, modifyTb );
2630 createTool( 410, modifyTb );
2631 createTool( 411, modifyTb );
2632 createTool( 412, modifyTb );
2633 createTool( 413, modifyTb );
2634 createTool( 416, modifyTb );
2635 createTool( 414, modifyTb );
2636 createTool( 415, modifyTb );
2637 createTool( 417, modifyTb );
2639 createTool( 214, dispModeTb );
2643 QString OB = "'ObjectBrowser'",
2644 View = "'" + SVTK_Viewer::Type() + "'",
2646 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2647 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2648 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2649 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2650 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2651 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2652 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2653 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2654 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2655 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2656 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2658 mesh_group = mesh + " " + subMesh + " " + group,
2659 hyp_alg = hypo + " " + algo;
2661 // popup for object browser
2663 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2664 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2665 createPopupItem( 803, OB, group ); // EDIT_GROUP
2666 popupMgr()->insert( separator(), -1, 0 );
2667 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2668 createPopupItem( 214, OB, mesh_group ); // UPDATE
2669 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2670 createPopupItem( 902, OB, mesh ); // STD_INFO
2671 popupMgr()->insert( separator(), -1, 0 );
2672 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2673 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2674 popupMgr()->insert( separator(), -1, 0 );
2675 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2676 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2677 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2678 popupMgr()->insert( separator(), -1, 0 );
2680 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2681 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2682 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2683 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2684 popupMgr()->insert( separator(), -1, 0 );
2687 createPopupItem( 803, View, group ); // EDIT_GROUP
2688 createPopupItem( 804, View, elems ); // ADD
2689 createPopupItem( 805, View, elems ); // REMOVE
2690 popupMgr()->insert( separator(), -1, 0 );
2691 createPopupItem( 214, View, mesh_group ); // UPDATE
2692 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2693 createPopupItem( 902, View, mesh ); // STD_INFO
2694 popupMgr()->insert( separator(), -1, 0 );
2698 isInvisible("not( isVisible )"),
2699 isEmpty("numberOfNodes = 0"),
2700 isNotEmpty("numberOfNodes <> 0"),
2702 // has nodes, edges, etc in VISIBLE! actor
2703 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2704 hasElems("(count( elemTypes ) > 0)"),
2705 hasDifferentElems("(count( elemTypes ) > 1)"),
2706 hasEdges("({'Edge'} in elemTypes)"),
2707 hasFaces("({'Face'} in elemTypes)"),
2708 hasVolumes("({'Volume'} in elemTypes)");
2710 QString lc = QtxPopupMgr::Selection::defEquality();
2711 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2712 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2713 aType = aType.arg( mesh_group );
2714 QString aMeshInVTK = aClient + "&&" + aType;
2716 //-------------------------------------------------
2718 //-------------------------------------------------
2719 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2721 popupMgr()->insert( action( 9010 ), anId, -1 );
2722 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2723 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2725 popupMgr()->insert( action( 9011 ), anId, -1 );
2726 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2727 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2729 popupMgr()->insert( separator(), -1, -1 );
2731 //-------------------------------------------------
2733 //-------------------------------------------------
2734 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2736 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2737 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2738 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2740 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2741 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2742 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2744 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2745 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2746 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2748 popupMgr()->insert( separator(), anId, -1 );
2750 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2751 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2752 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2754 //-------------------------------------------------
2756 //-------------------------------------------------
2757 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2759 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2761 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2762 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2763 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2765 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2766 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2767 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2769 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2770 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2771 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2773 popupMgr()->insert( separator(), anId, -1 );
2775 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2776 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2778 //-------------------------------------------------
2780 //-------------------------------------------------
2781 popupMgr()->insert( action( 1132 ), -1, -1 );
2782 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2784 //-------------------------------------------------
2786 //-------------------------------------------------
2787 popupMgr()->insert( action( 1133 ), -1, -1 );
2788 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2790 //-------------------------------------------------
2792 //-------------------------------------------------
2793 popupMgr()->insert( action( 1134 ), -1, -1 );
2794 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2796 popupMgr()->insert( separator(), -1, -1 );
2798 //-------------------------------------------------
2800 //-------------------------------------------------
2802 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2803 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2804 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2806 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2808 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2809 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2811 popupMgr()->insert( separator(), anId, -1 );
2813 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2814 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2815 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2817 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2818 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2819 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2821 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2822 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2823 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2825 popupMgr()->insert( separator(), anId, -1 );
2827 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2828 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2829 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2831 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2832 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2833 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2835 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2836 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2837 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2839 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2840 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2841 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2843 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2844 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2845 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2847 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2848 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2849 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2851 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2852 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2853 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2855 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2856 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2857 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2859 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2860 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2861 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2863 popupMgr()->insert( separator(), anId, -1 );
2865 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2866 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2867 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2869 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2870 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2871 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2873 popupMgr()->insert( separator(), anId, -1 );
2875 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2876 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2878 popupMgr()->insert( separator(), -1, -1 );
2880 //-------------------------------------------------
2882 //-------------------------------------------------
2883 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2884 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2885 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2887 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2888 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2889 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2890 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2892 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2893 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2895 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2896 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2898 popupMgr()->insert( separator(), -1, -1 );
2900 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2901 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2904 bool SMESHGUI::activateModule( SUIT_Study* study )
2906 bool res = SalomeApp_Module::activateModule( study );
2908 setMenuShown( true );
2909 setToolShown( true );
2911 // Reset actions accelerator keys
2912 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2913 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2914 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2919 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2921 setMenuShown( false );
2922 setToolShown( false );
2924 EmitSignalCloseAllDialogs();
2926 // Unset actions accelerator keys
2927 action(111)->setAccel(QKeySequence()); // Import DAT
2928 action(112)->setAccel(QKeySequence()); // Import UNV
2929 action(113)->setAccel(QKeySequence()); // Import MED
2931 return SalomeApp_Module::deactivateModule( study );
2934 void SMESHGUI::OnGUIEvent()
2936 const QObject* obj = sender();
2937 if ( !obj || !obj->inherits( "QAction" ) )
2939 int id = actionId((QAction*)obj);
2944 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2946 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2947 if ( CORBA::is_nil( myComponentSMESH ) )
2949 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2951 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2952 return aGUI.myComponentSMESH;
2955 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2956 return myComponentSMESH;
2959 QString SMESHGUI::engineIOR() const
2961 CORBA::ORB_var anORB = getApp()->orb();
2962 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2966 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2968 SMESHGUI_Selection sel;
2969 sel.init( client, selectionMgr() );
2970 popupMgr()->updatePopup( menu, &sel );
2973 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2975 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2976 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2979 void SMESHGUI::viewManagers( QStringList& list ) const
2981 list.append( SVTK_Viewer::Type() );
2984 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2986 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2987 SMESH::UpdateSelectionProp( this );
2990 void SMESHGUI::createPreferences()
2992 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2994 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2995 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2997 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2998 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2999 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3001 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3002 setPreferenceProperty( precGroup, "columns", 1 );
3004 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3006 setPreferenceProperty( prec, "min", 0 );
3007 setPreferenceProperty( prec, "max", 16 );
3009 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3010 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3012 modes.append( "Wireframe" );
3013 modes.append( "Shading" );
3014 modes.append( "Nodes" );
3015 modes.append( "Shrink" );
3016 QValueList<QVariant> indices;
3017 indices.append( 0 );
3018 indices.append( 1 );
3019 indices.append( 2 );
3020 indices.append( 3 );
3021 setPreferenceProperty( dispmode, "strings", modes );
3022 setPreferenceProperty( dispmode, "indexes", indices );
3024 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3025 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3026 int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3028 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3029 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3031 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3032 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3034 setPreferenceProperty( nodeSz, "min", 1 );
3035 setPreferenceProperty( nodeSz, "max", 5 );
3037 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3039 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3040 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3041 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3042 addPreference( "", elemGroup, LightApp_Preferences::Space );
3044 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3045 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3047 setPreferenceProperty( elemW, "min", 1 );
3048 setPreferenceProperty( elemW, "max", 5 );
3050 setPreferenceProperty( shrink, "min", 0 );
3051 setPreferenceProperty( shrink, "max", 100 );
3053 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3055 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3057 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3058 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3059 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3061 setPreferenceProperty( selW, "min", 1 );
3062 setPreferenceProperty( selW, "max", 5 );
3064 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3066 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3067 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3069 setPreferenceProperty( preW, "min", 1 );
3070 setPreferenceProperty( preW, "max", 5 );
3072 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3074 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3075 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3077 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3078 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3080 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3081 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3082 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3083 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3086 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3087 fam.append( tr( "SMESH_FONT_COURIER" ) );
3088 fam.append( tr( "SMESH_FONT_TIMES" ) );
3089 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3091 setPreferenceProperty( tfont, "families", fam );
3092 setPreferenceProperty( tfont, "system", false );
3093 setPreferenceProperty( tfont, "widget_flags", wflag );
3094 setPreferenceProperty( lfont, "families", fam );
3095 setPreferenceProperty( lfont, "system", false );
3096 setPreferenceProperty( lfont, "widget_flags", wflag );
3098 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3100 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3101 setPreferenceProperty( numcol, "min", 2 );
3102 setPreferenceProperty( numcol, "max", 256 );
3104 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3105 setPreferenceProperty( numlab, "min", 2 );
3106 setPreferenceProperty( numlab, "max", 65 );
3108 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3109 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3110 QStringList orients;
3111 orients.append( tr( "SMESH_VERTICAL" ) );
3112 orients.append( tr( "SMESH_HORIZONTAL" ) );
3113 indices.clear(); indices.append( 0 ); indices.append( 1 );
3114 setPreferenceProperty( orient, "strings", orients );
3115 setPreferenceProperty( orient, "indexes", indices );
3117 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3118 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3119 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3120 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3121 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3122 setPreferenceProperty( xv, "step", 0.1 );
3123 setPreferenceProperty( xv, "min", 0.0 );
3124 setPreferenceProperty( xv, "max", 1.0 );
3125 setPreferenceProperty( yv, "step", 0.1 );
3126 setPreferenceProperty( yv, "min", 0.0 );
3127 setPreferenceProperty( yv, "max", 1.0 );
3128 setPreferenceProperty( wv, "step", 0.1 );
3129 setPreferenceProperty( wv, "min", 0.0 );
3130 setPreferenceProperty( wv, "max", 1.0 );
3131 setPreferenceProperty( hv, "min", 0.0 );
3132 setPreferenceProperty( hv, "max", 1.0 );
3133 setPreferenceProperty( hv, "step", 0.1 );
3135 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3136 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3137 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3138 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3139 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3140 setPreferenceProperty( xv, "min", 0.0 );
3141 setPreferenceProperty( xv, "max", 1.0 );
3142 setPreferenceProperty( xv, "step", 0.1 );
3143 setPreferenceProperty( xh, "min", 0.0 );
3144 setPreferenceProperty( xh, "max", 1.0 );
3145 setPreferenceProperty( xh, "step", 0.1 );
3146 setPreferenceProperty( yh, "min", 0.0 );
3147 setPreferenceProperty( yh, "max", 1.0 );
3148 setPreferenceProperty( yh, "step", 0.1 );
3149 setPreferenceProperty( wh, "min", 0.0 );
3150 setPreferenceProperty( wh, "max", 1.0 );
3151 setPreferenceProperty( wh, "step", 0.1 );
3152 setPreferenceProperty( hh, "min", 0.0 );
3153 setPreferenceProperty( hh, "max", 1.0 );
3154 setPreferenceProperty( hh, "step", 0.1 );
3157 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3159 if( sect=="SMESH" ){
3160 float sbX1,sbY1,sbW,sbH;
3161 float aTol = 1.00000009999999;
3162 std::string aWarning;
3163 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3164 if( name=="selection_object_color" || name=="selection_element_color" ||
3165 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3166 name=="selection_precision_node" || name=="selection_precision_element" )
3167 SMESH::UpdateSelectionProp( this );
3168 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3169 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3170 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3171 if(sbX1+sbW > aTol){
3172 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3175 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3176 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3179 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3180 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3181 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3182 if(sbY1+sbH > aTol){
3183 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3186 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3187 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3190 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3191 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3192 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3193 if(sbX1+sbW > aTol){
3194 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3197 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3198 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3201 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3202 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3203 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3204 if(sbY1+sbH > aTol){
3205 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3208 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3209 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3213 if(aWarning.size() != 0){
3214 aWarning += "The default values are applied instead.";
3215 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3216 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3217 QObject::tr(aWarning.c_str()),
3218 QObject::tr("SMESH_BUT_OK"));
3223 //================================================================================
3225 * \brief Update something in accordance with update flags
3226 * \param theFlags - update flags
3228 * Update viewer or/and object browser etc. in accordance with update flags ( see
3229 * LightApp_UpdateFlags enumeration ).
3231 //================================================================================
3232 void SMESHGUI::update( const int flags )
3234 if ( flags & UF_Viewer | flags & UF_Forced )
3235 SMESH::UpdateView();
3237 SalomeApp_Module::update( flags );
3240 //================================================================================
3242 * \brief Set default selection mode
3244 * SLOT called when operation commited. Sets default selection mode
3246 //================================================================================
3247 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3249 SVTK_ViewWindow* vtkWnd =
3250 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3252 vtkWnd->SetSelectionMode( ActorSelection );
3255 //================================================================================
3257 * \brief Set default selection mode
3259 * SLOT called when operation aborted. Sets default selection mode
3261 //================================================================================
3262 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3264 SVTK_ViewWindow* vtkWnd =
3265 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3267 vtkWnd->SetSelectionMode( ActorSelection );
3270 //================================================================================
3272 * \brief Creates operation with given identifier
3273 * \param id - identifier of operation to be started
3274 * \return Pointer on created operation or NULL if operation is not created
3276 * Virtual method redefined from the base class creates operation with given id.
3277 * It is called called automatically from startOperation method of base class.
3279 //================================================================================
3280 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3282 LightApp_Operation* op = 0;
3283 // to do : create operation here
3286 case 702: // Create mesh
3287 op = new SMESHGUI_MeshOp( true, true );
3289 case 703: // Create sub-mesh
3290 op = new SMESHGUI_MeshOp( true, false );
3292 case 704: // Edit mesh/sub-mesh
3293 op = new SMESHGUI_MeshOp( false );
3295 case 417: //convert to quadratic
3296 op = new SMESHGUI_ConvToQuadOp();
3303 op = SalomeApp_Module::createOperation( id );
3307 //================================================================================
3309 * \brief Stops current operations and starts a given one
3310 * \param id - The id of the operation to start
3312 //================================================================================
3314 void SMESHGUI::switchToOperation(int id)
3316 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3317 activeStudy()->abortAllOperations();
3318 startOperation( id );
3321 LightApp_Displayer* SMESHGUI::displayer()
3324 myDisplayer = new SMESHGUI_Displayer( getApp() );