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_EditMeshDlg.h"
61 #include "SMESHGUI_MeshPatternDlg.h"
62 #include "SMESHGUI_Selection.h"
63 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
64 #include "SMESHGUI_ConvToQuadOp.h"
65 #include "SMESHGUI_MeshOp.h"
66 #include "SMESHGUI_Displayer.h"
67 #include "SMESHGUI_MakeNodeAtPointDlg.h"
68 #include "SMESHGUI_BuildCompoundDlg.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_GEOMGenUtils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
79 #include "SMESH_Actor.h"
80 #include "SMESH_Object.h"
81 #include "SMESH_TypeFilter.hxx"
83 #include "SalomeApp_Tools.h"
84 #include "SalomeApp_Study.h"
85 #include "SalomeApp_Application.h"
86 #include "SalomeApp_CheckFileDlg.h"
87 #include "SalomeApp_ImportOperation.h"
89 #include "LightApp_DataOwner.h"
90 #include "LightApp_Preferences.h"
91 #include "LightApp_VTKSelector.h"
92 #include "LightApp_Operation.h"
93 #include "LightApp_UpdateFlags.h"
94 #include "LightApp_NameDlg.h"
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_InteractorStyle.h>
99 #include <SVTK_RenderWindowInteractor.h>
100 #include <SVTK_ViewManager.h>
102 #include "OB_Browser.h"
104 #include "SUIT_Tools.h"
105 #include "SUIT_MessageBox.h"
106 #include "SUIT_ResourceMgr.h"
107 #include "SUIT_FileDlg.h"
108 #include "SUIT_Desktop.h"
109 #include "SUIT_OverrideCursor.h"
110 #include "SUIT_Study.h"
111 #include "SUIT_Session.h"
113 #include "QtxPopupMgr.h"
115 #include "SALOME_ListIO.hxx"
116 #include "SALOME_ListIteratorOfListIO.hxx"
117 #include "SALOME_InteractiveObject.hxx"
118 #include "SALOME_NamingService.hxx"
119 #include "SALOME_LifeCycleCORBA.hxx"
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
126 #define INCLUDE_MENUITEM_DEF
127 #include <qpopupmenu.h>
133 #include <boost/shared_ptr.hpp>
136 #include <vtkRenderer.h>
137 #include <vtkRenderWindow.h>
138 #include <vtkActorCollection.h>
139 #include <vtkScalarBarActor.h>
140 #include <vtkUnstructuredGrid.h>
142 #include "utilities.h"
144 #include "SALOMEDS_Study.hxx"
145 #include "SALOMEDSClient_StudyBuilder.hxx"
146 #include "SALOMEDSClient_SComponent.hxx"
152 //=============================================================
153 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
156 void ExportMeshToFile(int theCommandID);
158 void SetDisplayMode(int theCommandID);
160 void SetDisplayEntity(int theCommandID);
162 void Control( int theCommandID );
166 //=============================================================
167 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
173 if(theCommandID == 113){
174 filter.append(QObject::tr("MED files (*.med)"));
175 filter.append(QObject::tr("All files (*)"));
176 }else if (theCommandID == 112){
177 filter.append(QObject::tr("IDEAS files (*.unv)"));
178 }else if (theCommandID == 111){
179 filter.append(QObject::tr("DAT files (*.dat)"));
181 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
184 QObject::tr("Import mesh"),
186 if(!filename.isEmpty()) {
187 SUIT_OverrideCursor wc;
188 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
191 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
192 switch ( theCommandID ) {
195 aMeshes->length( 1 );
196 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
201 SMESH::DriverMED_ReadStatus res;
202 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
203 if ( res != SMESH::DRS_OK ) {
205 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
206 QObject::tr("SMESH_WRN_WARNING"),
207 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
208 QObject::tr("SMESH_BUT_OK"));
209 aMeshes->length( 0 );
216 bool isEmpty = false;
217 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
218 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
220 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
221 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
222 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
223 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
224 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
231 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
232 QObject::tr("SMESH_WRN_WARNING"),
233 QObject::tr("SMESH_DRS_EMPTY"),
234 QObject::tr("SMESH_BUT_OK"));
238 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
240 catch (const SALOME::SALOME_Exception& S_ex){
242 SalomeApp_Tools::QtCatchCorbaException(S_ex);
249 void ExportMeshToFile( int theCommandID )
251 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
252 SALOME_ListIO selected;
254 aSel->selectedObjects( selected );
256 if(selected.Extent()){
257 Handle(SALOME_InteractiveObject) anIObject = selected.First();
258 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
259 if ( !aMesh->_is_nil() ) {
260 QString aFilter, aTitle = QObject::tr("Export mesh");
261 QMap<QString, SMESH::MED_VERSION> aFilterMap;
262 QMap<QString, int> aFilterMapSTL;
263 switch ( theCommandID ) {
267 if (aMesh->HasDuplicatedGroupNamesMED()) {
268 int aRet = SUIT_MessageBox::warn2
269 (SMESHGUI::desktop(),
270 QObject::tr("SMESH_WRN_WARNING"),
271 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
272 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
278 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
279 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
284 aFilter = QObject::tr("DAT files (*.dat)");
289 if (aMesh->NbPyramids()) {
290 int aRet = SUIT_MessageBox::warn2
291 (SMESHGUI::desktop(),
292 QObject::tr("SMESH_WRN_WARNING"),
293 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
294 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
299 aFilter = QObject::tr("IDEAS files (*.unv)");
307 there must be check on others mesh elements not equal triangles
309 if (aMesh->NbTriangles() < 1) {
310 int aRet = SUIT_MessageBox::warn1
311 (SMESHGUI::desktop(),
312 QObject::tr("SMESH_WRN_WARNING"),
313 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
314 QObject::tr("SMESH_BUT_OK"));
317 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
318 int aRet = SUIT_MessageBox::warn2
319 (SMESHGUI::desktop(),
320 QObject::tr("SMESH_WRN_WARNING"),
321 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
322 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
328 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
329 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
337 SMESH::MED_VERSION aFormat;
338 // Init the parameter with the default value
339 bool aIsASCII_STL = true;
340 bool toCreateGroups = false;
341 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
343 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
345 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
347 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
349 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
351 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
352 for ( ; it != aFilterMapSTL.end(); ++it )
353 filters.push_back( it.key() );
355 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
356 fd->setCaption( aTitle );
357 fd->setFilters( filters );
358 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
362 aFilename = fd->selectedFile();
363 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
370 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
371 for ( ; it != aFilterMap.end(); ++it )
372 filters.push_back( it.key() );
374 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
375 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
376 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
377 fd->setCaption( aTitle );
378 fd->setFilters( filters );
379 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
380 fd->SetChecked(toCreateGroups);
384 aFilename = fd->selectedFile();
385 aFormat = aFilterMap[fd->selectedFilter()];
387 if ( !aFilename.isEmpty()
388 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
389 && aFormat==SMESH::MED_V2_1) {
390 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
391 QObject::tr("SMESH_WRN_WARNING"),
392 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
393 QObject::tr("SMESH_BUT_YES"),
394 QObject::tr("SMESH_BUT_NO"),
401 toCreateGroups = fd->IsChecked();
404 if ( !aFilename.isEmpty() ) {
405 // Check whether the file already exists and delete it if yes
406 QFile aFile( aFilename );
407 if ( aFile.exists() )
409 SUIT_OverrideCursor wc;
412 bool Renumber = false ;
413 // PAL 14172 : Check of we have to renumber or not from the preferences before export
415 Renumber= resMgr->booleanValue("SMESH","renumbering");
417 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
418 aMeshEditor->RenumberNodes();
419 aMeshEditor->RenumberElements();
420 if ( SMESHGUI::automaticUpdate() )
423 switch ( theCommandID ) {
426 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
430 aMesh->ExportDAT( aFilename.latin1() );
434 aMesh->ExportUNV( aFilename.latin1() );
438 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
444 catch (const SALOME::SALOME_Exception& S_ex){
446 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
447 QObject::tr("SMESH_WRN_WARNING"),
448 QObject::tr("SMESH_EXPORT_FAILED"),
449 QObject::tr("SMESH_BUT_OK"));
457 inline void InverseEntityMode(unsigned int& theOutputMode,
458 unsigned int theMode)
460 bool anIsNotPresent = ~theOutputMode & theMode;
462 theOutputMode |= theMode;
464 theOutputMode &= ~theMode;
467 void SetDisplayEntity(int theCommandID){
468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
469 SALOME_ListIO selected;
471 aSel->selectedObjects( selected );
473 if(selected.Extent() >= 1){
474 SALOME_ListIteratorOfListIO It( selected );
475 for(; It.More(); It.Next()){
476 Handle(SALOME_InteractiveObject) IObject = It.Value();
477 if(IObject->hasEntry()){
478 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
479 unsigned int aMode = anActor->GetEntityMode();
480 switch(theCommandID){
482 InverseEntityMode(aMode,SMESH_Actor::eEdges);
485 InverseEntityMode(aMode,SMESH_Actor::eFaces);
488 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
491 aMode = SMESH_Actor::eAllEntity;
495 anActor->SetEntityMode(aMode);
502 void SetDisplayMode(int theCommandID){
503 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
504 SALOME_ListIO selected;
506 aSel->selectedObjects( selected );
508 if(selected.Extent() >= 1){
509 switch(theCommandID){
511 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
512 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
516 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
517 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
520 SALOME_ListIteratorOfListIO It( selected );
521 for(; It.More(); It.Next()){
522 Handle(SALOME_InteractiveObject) IObject = It.Value();
523 if(IObject->hasEntry()){
524 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
525 switch(theCommandID){
527 anActor->SetRepresentation(SMESH_Actor::eEdge);
530 anActor->SetRepresentation(SMESH_Actor::eSurface);
533 if(anActor->IsShrunk())
536 anActor->SetShrink();
539 anActor->SetRepresentation(SMESH_Actor::ePoint);
542 vtkFloatingPointType color[3];
543 anActor->GetSufaceColor(color[0], color[1], color[2]);
544 int c0 = int (color[0] * 255);
545 int c1 = int (color[1] * 255);
546 int c2 = int (color[2] * 255);
547 QColor c(c0, c1, c2);
549 vtkFloatingPointType edgecolor[3];
550 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
551 c0 = int (edgecolor[0] * 255);
552 c1 = int (edgecolor[1] * 255);
553 c2 = int (edgecolor[2] * 255);
554 QColor e(c0, c1, c2);
556 vtkFloatingPointType backfacecolor[3];
557 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
558 c0 = int (backfacecolor[0] * 255);
559 c1 = int (backfacecolor[1] * 255);
560 c2 = int (backfacecolor[2] * 255);
561 QColor b(c0, c1, c2);
563 vtkFloatingPointType nodecolor[3];
564 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
565 c0 = int (nodecolor[0] * 255);
566 c1 = int (nodecolor[1] * 255);
567 c2 = int (nodecolor[2] * 255);
568 QColor n(c0, c1, c2);
570 int Edgewidth = (int)anActor->GetLineWidth();
573 int intValue = int(anActor->GetNodeSize());
574 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
576 SMESHGUI_Preferences_ColorDlg *aDlg =
577 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
578 aDlg->SetColor(1, c);
579 aDlg->SetColor(2, e);
580 aDlg->SetColor(3, n);
581 aDlg->SetColor(4, b);
582 aDlg->SetIntValue(1, Edgewidth);
583 aDlg->SetIntValue(2, intValue);
584 aDlg->SetIntValue(3, int(Shrink*100.));
586 QColor color = aDlg->GetColor(1);
587 QColor edgecolor = aDlg->GetColor(2);
588 QColor nodecolor = aDlg->GetColor(3);
589 QColor backfacecolor = aDlg->GetColor(4);
590 /* actor color and backface color */
591 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
592 vtkFloatingPointType (color.green()) / 255.,
593 vtkFloatingPointType (color.blue()) / 255.);
594 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
595 vtkFloatingPointType (backfacecolor.green()) / 255.,
596 vtkFloatingPointType (backfacecolor.blue()) / 255.);
599 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
600 vtkFloatingPointType (edgecolor.green()) / 255.,
601 vtkFloatingPointType (edgecolor.blue()) / 255.);
603 /* Shrink factor and size edges */
604 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
605 anActor->SetLineWidth(aDlg->GetIntValue(1));
607 /* Nodes color and size */
608 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
609 vtkFloatingPointType (nodecolor.green()) / 255.,
610 vtkFloatingPointType (nodecolor.blue()) / 255.);
611 anActor->SetNodeSize(aDlg->GetIntValue(2));
620 SMESH::RepaintCurrentView();
624 void Control( int theCommandID )
626 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
627 SALOME_ListIO selected;
629 aSel->selectedObjects( selected );
631 if( !selected.IsEmpty() ){
632 Handle(SALOME_InteractiveObject) anIO = selected.First();
635 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
636 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
637 switch ( theCommandID ){
639 aTitle = QObject::tr( "LENGTH_EDGES" );
640 aControl = SMESH_Actor::eLength;
643 aTitle = QObject::tr( "LENGTH2D_EDGES" );
644 aControl = SMESH_Actor::eLength2D;
647 aTitle = QObject::tr( "FREE_EDGES" );
648 aControl = SMESH_Actor::eFreeEdges;
651 aTitle = QObject::tr( "FREE_BORDERS" );
652 aControl = SMESH_Actor::eFreeBorders;
655 aTitle = QObject::tr( "MULTI_BORDERS" );
656 aControl = SMESH_Actor::eMultiConnection;
659 aTitle = QObject::tr( "MULTI2D_BORDERS" );
660 aControl = SMESH_Actor::eMultiConnection2D;
663 aTitle = QObject::tr( "AREA_ELEMENTS" );
664 aControl = SMESH_Actor::eArea;
667 aTitle = QObject::tr( "TAPER_ELEMENTS" );
668 aControl = SMESH_Actor::eTaper;
671 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
672 aControl = SMESH_Actor::eAspectRatio;
675 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
676 aControl = SMESH_Actor::eAspectRatio3D;
679 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
680 aControl = SMESH_Actor::eMinimumAngle;
683 aTitle = QObject::tr( "WARP_ELEMENTS" );
684 aControl = SMESH_Actor::eWarping;
687 aTitle = QObject::tr( "SKEW_ELEMENTS" );
688 aControl = SMESH_Actor::eSkew;
691 aTitle = QObject::tr( "SMESH_VOLUME" );
692 aControl = SMESH_Actor::eVolume3D;
695 anActor->SetControlMode(aControl);
696 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
697 SMESH::RepaintCurrentView();
704 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
705 MeshObjectType theType,
706 const QString theInTypeName,
707 QString & theOutTypeName)
709 SMESH_TypeFilter aTypeFilter( theType );
711 if( !theIO.IsNull() )
713 entry = theIO->getEntry();
714 LightApp_DataOwner owner( entry );
715 if ( aTypeFilter.isOk( &owner )) {
716 theOutTypeName = theInTypeName;
724 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
726 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
727 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
729 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
730 CORBA::String_var anID = aSComp->GetID().c_str();
731 if (!strcmp(anID.in(),theIO->getEntry()))
737 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
738 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
739 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
740 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
741 CheckOIType ( theIO, GROUP, "Group", aTypeName )
749 QString CheckHomogeneousSelection()
751 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
752 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
753 SALOME_ListIO selected;
755 aSel->selectedObjects( selected );
757 QString RefType = CheckTypeObject(selected.First());
758 SALOME_ListIteratorOfListIO It(selected);
759 for (; It.More(); It.Next())
761 Handle(SALOME_InteractiveObject) IObject = It.Value();
762 QString Type = CheckTypeObject(IObject);
763 if (Type.compare(RefType) != 0)
764 return "Heterogeneous Selection";
771 void SMESHGUI::OnEditDelete()
773 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
774 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
775 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
777 QString aParentComponent = QString::null;
778 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
780 QString cur = anIt.Value()->getComponentDataType();
781 if( aParentComponent.isNull() )
782 aParentComponent = cur;
783 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
784 aParentComponent = "";
787 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
788 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
789 QObject::tr("ERR_ERROR"),
790 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
791 QObject::tr("BUT_OK") );
794 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
795 if (SUIT_MessageBox::warn2
796 (SMESHGUI::desktop(),
797 QObject::tr("SMESH_WRN_WARNING"),
798 QObject::tr("SMESH_REALLY_DELETE"),
799 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
802 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
803 SUIT_ViewManager* vm = anApp->activeViewManager();
804 int nbSf = vm->getViewsCount();
806 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
807 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
808 _PTR(GenericAttribute) anAttr;
809 _PTR(AttributeIOR) anIOR;
811 SALOME_ListIteratorOfListIO It(selected);
813 aStudyBuilder->NewCommand(); // There is a transaction
814 for(; It.More(); It.Next()){ // loop on selected IO's
815 Handle(SALOME_InteractiveObject) IObject = It.Value();
816 if(IObject->hasEntry()) {
817 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
819 // disable removal of "SMESH" component object
820 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
822 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
826 // put the whole hierarchy of sub-objects of the selected SO into a list and
827 // then treat them all starting from the deepest objects (at list back)
829 list< _PTR(SObject) > listSO;
830 listSO.push_back( aSO );
831 list< _PTR(SObject) >::iterator itSO = listSO.begin();
832 for ( ; itSO != listSO.end(); ++itSO ) {
833 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
834 for (it->InitEx(false); it->More(); it->Next())
835 listSO.push_back( it->Value() );
838 // treat SO's in the list starting from the back
840 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
841 for ( ; ritSO != listSO.rend(); ++ritSO ) {
842 _PTR(SObject) SO = *ritSO;
844 string anEntry = SO->GetID();
846 /** Erase graphical object **/
847 if(SO->FindAttribute(anAttr, "AttributeIOR")){
848 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
849 for(int i = 0; i < nbSf; i++){
850 SUIT_ViewWindow *sf = aViews[i];
851 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
852 SMESH::RemoveActor(sf,anActor);
857 /** Remove an object from data structures **/
858 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
859 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
860 if ( !aGroup->_is_nil() ) { // DELETE GROUP
861 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
862 aMesh->RemoveGroup( aGroup );
864 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
865 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
866 aMesh->RemoveSubMesh( aSubMesh );
868 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
870 SMESH::ModifiedMesh(aMeshSO, false);
873 IObject = new SALOME_InteractiveObject
874 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
875 QString objType = CheckTypeObject(IObject);
876 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
877 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
878 aStudyBuilder->RemoveObjectWithChildren( SO );
880 else {// default action: remove SObject from the study
881 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
882 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
884 aStudyBuilder->RemoveObjectWithChildren( SO );
888 } /* listSO back loop */
889 } /* IObject->hasEntry() */
891 aStudyBuilder->CommitCommand();
893 /* Clear any previous selection */
895 aSel->setSelectedObjects( l1 );
897 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
902 Standard_EXPORT CAM_Module* createModule()
904 return new SMESHGUI();
908 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
910 //=============================================================================
914 //=============================================================================
915 SMESHGUI::SMESHGUI() :
916 SalomeApp_Module( "SMESH" )
918 if ( CORBA::is_nil( myComponentSMESH ) )
920 CORBA::Boolean anIsEmbeddedMode;
921 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
924 myActiveDialogBox = 0;
925 myFilterLibraryDlg = 0;
929 SMESH::GetFilterManager();
932 /* load resources for all available meshers */
933 SMESH::InitAvailableHypotheses();
936 //=============================================================================
940 //=============================================================================
941 SMESHGUI::~SMESHGUI()
943 SMESH::GetFilterManager()->Destroy();
944 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
947 //=============================================================================
951 //=============================================================================
952 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
954 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
956 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
961 bool SMESHGUI::automaticUpdate()
963 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
967 return resMgr->booleanValue( "SMESH", "auto_update", false );
970 //=============================================================================
974 //=============================================================================
975 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
977 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
980 //=============================================================================
984 //=============================================================================
985 SMESHGUI* SMESHGUI::GetSMESHGUI()
987 SMESHGUI* smeshMod = 0;
988 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
991 CAM_Module* module = app->module( "Mesh" );
992 smeshMod = dynamic_cast<SMESHGUI*>( module );
995 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
997 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1000 _PTR(Study) aStudy = study->studyDS();
1002 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1011 Standard_EXPORT SMESHGUI* GetComponentGUI()
1013 return SMESHGUI::GetSMESHGUI();
1017 //=============================================================================
1021 //=============================================================================
1022 void SMESHGUI::SetState(int aState)
1027 //=============================================================================
1031 //=============================================================================
1032 void SMESHGUI::ResetState()
1037 //=============================================================================
1041 //=============================================================================
1042 void SMESHGUI::EmitSignalDeactivateDialog()
1044 emit SignalDeactivateActiveDialog();
1047 //=============================================================================
1051 //=============================================================================
1052 void SMESHGUI::EmitSignalStudyFrameChanged()
1054 emit SignalStudyFrameChanged();
1057 //=============================================================================
1061 //=============================================================================
1062 void SMESHGUI::EmitSignalCloseAllDialogs()
1064 emit SignalCloseAllDialogs();
1067 //=============================================================================
1071 //=============================================================================
1072 QDialog *SMESHGUI::GetActiveDialogBox()
1074 return myActiveDialogBox;
1077 //=============================================================================
1081 //=============================================================================
1082 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1084 myActiveDialogBox = (QDialog *) aDlg;
1088 //=============================================================================
1092 //=============================================================================
1093 SUIT_Desktop* SMESHGUI::desktop()
1095 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1097 return app->desktop();
1102 //=============================================================================
1106 //=============================================================================
1107 SalomeApp_Study* SMESHGUI::activeStudy()
1109 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1111 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1116 //=============================================================================
1120 //=============================================================================
1121 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1123 /* Here the position is on the bottom right corner - 10 */
1124 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1126 SUIT_Desktop *PP = desktop();
1127 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1128 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1132 //=============================================================================
1136 //=============================================================================
1137 static int isStudyLocked(_PTR(Study) theStudy){
1138 return theStudy->GetProperties()->IsLocked();
1141 static bool checkLock(_PTR(Study) theStudy) {
1142 if (isStudyLocked(theStudy)) {
1143 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1144 QObject::tr("WRN_WARNING"),
1145 QObject::tr("WRN_STUDY_LOCKED"),
1146 QObject::tr("BUT_OK") );
1152 //=======================================================================
1153 //function : CheckActiveStudyLocked
1155 //=======================================================================
1157 bool SMESHGUI::isActiveStudyLocked()
1159 _PTR(Study) aStudy = activeStudy()->studyDS();
1160 return checkLock( aStudy );
1163 //=============================================================================
1167 //=============================================================================
1168 bool SMESHGUI::OnGUIEvent( int theCommandID )
1170 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1174 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1175 SUIT_ResourceMgr* mgr = resourceMgr();
1179 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1180 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1183 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1184 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1186 //QAction* act = action( theCommandID );
1188 switch (theCommandID) {
1190 if(checkLock(aStudy)) break;
1198 if(checkLock(aStudy)) break;
1199 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1203 case 122: // EXPORT MED
1212 ::ExportMeshToFile(theCommandID);
1216 case 200: // SCALAR BAR
1218 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1219 SALOME_ListIO selected;
1221 aSel->selectedObjects( selected );
1223 if( selected.Extent() ) {
1224 Handle(SALOME_InteractiveObject) anIO = selected.First();
1225 if( anIO->hasEntry() ) {
1226 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1227 anActor->SetControlMode( SMESH_Actor::eNone );
1235 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1239 case 1134: // Clipping
1240 case 1133: // Tranparency
1241 case 1132: // Colors / Size
1248 ::SetDisplayMode(theCommandID);
1254 case 219: // Volumes
1255 case 220: // All Entity
1256 ::SetDisplayEntity(theCommandID);
1261 if(checkLock(aStudy)) break;
1262 SMESH::UpdateView();
1265 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1266 aSel->selectedObjects( l );
1267 aSel->setSelectedObjects( l );
1272 case 301: // DISPLAY
1273 case 302: // DISPLAY ONLY
1275 SMESH::EDisplaing anAction;
1276 switch (theCommandID) {
1277 case 300: anAction = SMESH::eErase; break;
1278 case 301: anAction = SMESH::eDisplay; break;
1279 case 302: anAction = SMESH::eDisplayOnly; break;
1282 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1283 SALOME_ListIO sel_objects, to_process;
1285 aSel->selectedObjects( sel_objects );
1287 if( theCommandID==302 )
1288 startOperation( myEraseAll );
1290 extractContainers( sel_objects, to_process );
1293 SALOME_ListIteratorOfListIO It( to_process );
1294 for (; It.More(); It.Next()) {
1295 Handle(SALOME_InteractiveObject) IOS = It.Value();
1296 if (IOS->hasEntry()) {
1297 SMESH::UpdateView(anAction, IOS->getEntry());
1298 if (anAction == SMESH::eDisplayOnly)
1299 anAction = SMESH::eDisplay;
1304 // PAL13338 + PAL15161 -->
1305 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) /*&& !automaticUpdate()*/ )
1306 SMESH::UpdateView();
1307 // PAL13338 + PAL15161 <--
1309 if (anAction == SMESH::eErase) {
1311 aSel->setSelectedObjects( l1 );
1314 aSel->setSelectedObjects( to_process );
1321 if(checkLock(aStudy)) break;
1324 EmitSignalDeactivateDialog();
1326 new SMESHGUI_NodesDlg(this);
1329 SUIT_MessageBox::warn1(desktop(),
1330 tr("SMESH_WRN_WARNING"),
1331 tr("SMESH_WRN_VIEWER_VTK"),
1332 tr("SMESH_BUT_OK"));
1337 case 2151: // FILTER
1341 EmitSignalDeactivateDialog();
1342 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1347 case 406: // MOVE NODE
1351 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1352 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1356 if(checkLock(aStudy)) break;
1357 new SMESHGUI_MoveNodesDlg(this);
1361 case 701: // COMPUTE MESH
1363 if (checkLock(aStudy)) break;
1365 LightApp_SelectionMgr *Sel = selectionMgr();
1366 SALOME_ListIO selected; Sel->selectedObjects( selected );
1368 int nbSel = selected.Extent();
1370 SUIT_MessageBox::warn1(desktop(),
1371 tr("SMESH_WRN_WARNING"),
1372 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1373 tr("SMESH_BUT_OK"));
1377 SMESH::SMESH_Mesh_var aMesh;
1378 SMESH::SMESH_subMesh_var aSubMesh;
1379 Handle(SALOME_InteractiveObject) IObject = selected.First();
1380 if (IObject->hasEntry()) {
1381 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1382 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1383 if ( aShapeObject->_is_nil() ) {
1388 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1389 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1390 if ( !aSubMesh->_is_nil() )
1391 aMesh = aSubMesh->GetFather();
1393 if (!aMesh->_is_nil()) {
1394 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1395 if ( errors->length() > 0 ) {
1396 SUIT_MessageBox::warn1(desktop(),
1397 tr("SMESH_WRN_WARNING"),
1398 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1399 tr("SMESH_BUT_OK"));
1404 if (GetSMESHGen()->Compute(aMesh, aShapeObject))
1405 SMESH::ModifiedMesh(aMeshSObj, true);
1407 SUIT_MessageBox::warn1(desktop(),
1408 tr("SMESH_WRN_WARNING"),
1409 tr("SMESH_WRN_COMPUTE_FAILED"),
1410 tr("SMESH_BUT_OK"));
1412 catch(const SALOME::SALOME_Exception & S_ex){
1413 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1418 if (automaticUpdate()) {
1419 SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
1421 CORBA::Long anId = aStudy->StudyId();
1422 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
1424 aVisualObj->Update();
1425 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1427 anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
1429 SMESH::DisplayActor(aVTKView, anActor); //apo
1433 SMESH::RepaintCurrentView();
1434 Sel->setSelectedObjects( selected );
1444 case 702: // Create mesh
1445 startOperation( 702 );
1447 case 703: // Create sub-mesh
1448 startOperation( 703 );
1450 case 704: // Edit mesh/sub-mesh
1451 startOperation( 704 );
1453 case 710: // Build compound mesh
1455 if (checkLock(aStudy)) break;
1456 EmitSignalDeactivateDialog();
1457 new SMESHGUI_BuildCompoundDlg( this );
1460 case 407: // DIAGONAL INVERSION
1461 case 408: // Delete diagonal
1465 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1466 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1470 if ( checkLock( aStudy ) )
1473 /*Standard_Boolean aRes;
1474 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1475 if ( aMesh->_is_nil() )
1477 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1478 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1482 EmitSignalDeactivateDialog();
1483 if ( theCommandID == 407 )
1484 new SMESHGUI_TrianglesInversionDlg(this);
1486 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1489 case 409: // Change orientation
1490 case 410: // Union of triangles
1491 case 411: // Cutting of quadrangles
1495 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1496 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1500 if ( checkLock( aStudy ) )
1503 EmitSignalDeactivateDialog();
1504 SMESHGUI_MultiEditDlg* aDlg = NULL;
1505 if ( theCommandID == 409 )
1506 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1507 else if ( theCommandID == 410 )
1508 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1510 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1515 case 412: // Smoothing
1517 if(checkLock(aStudy)) break;
1519 EmitSignalDeactivateDialog();
1520 new SMESHGUI_SmoothingDlg( this );
1523 SUIT_MessageBox::warn1(desktop(),
1524 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1525 tr("SMESH_BUT_OK"));
1529 case 413: // Extrusion
1531 if (checkLock(aStudy)) break;
1533 EmitSignalDeactivateDialog();
1534 new SMESHGUI_ExtrusionDlg ( this );
1536 SUIT_MessageBox::warn1(desktop(),
1537 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1538 tr("SMESH_BUT_OK"));
1542 case 414: // Revolution
1544 if(checkLock(aStudy)) break;
1546 EmitSignalDeactivateDialog();
1547 new SMESHGUI_RevolutionDlg( this );
1550 SUIT_MessageBox::warn1(desktop(),
1551 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1552 tr("SMESH_BUT_OK"));
1556 case 415: // Pattern mapping
1558 if ( checkLock( aStudy ) )
1562 EmitSignalDeactivateDialog();
1563 new SMESHGUI_MeshPatternDlg( this );
1566 SUIT_MessageBox::warn1(desktop(),
1567 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1568 tr("SMESH_BUT_OK"));
1572 case 416: // Extrusion along a path
1574 if (checkLock(aStudy)) break;
1576 EmitSignalDeactivateDialog();
1577 new SMESHGUI_ExtrusionAlongPathDlg( this );
1579 SUIT_MessageBox::warn1(desktop(),
1580 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1581 tr("SMESH_BUT_OK"));
1585 case 417: // Convert mesh to quadratic
1587 startOperation( 417 );
1588 /* if (checkLock(aStudy)) break;
1590 EmitSignalDeactivateDialog();
1591 new SMESHGUI_ConvToQuadDlg();
1593 SUIT_MessageBox::warn1(desktop(),
1594 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1595 tr("SMESH_BUT_OK"));
1599 case 801: // CREATE GROUP
1603 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1604 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1608 if(checkLock(aStudy)) break;
1609 EmitSignalDeactivateDialog();
1610 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1612 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1613 SALOME_ListIO selected;
1615 aSel->selectedObjects( selected );
1617 int nbSel = selected.Extent();
1619 // check if mesh is selected
1620 aMesh = SMESH::GetMeshByIO( selected.First() );
1622 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1627 case 802: // CONSTRUCT GROUP
1631 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1632 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1636 if(checkLock(aStudy)) break;
1637 EmitSignalDeactivateDialog();
1639 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1640 SALOME_ListIO selected;
1642 aSel->selectedObjects( selected );
1644 int nbSel = selected.Extent();
1646 // check if submesh is selected
1647 Handle(SALOME_InteractiveObject) IObject = selected.First();
1648 if (IObject->hasEntry()) {
1649 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1651 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1652 if (!aSubMesh->_is_nil()) {
1654 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1655 // get submesh elements list by types
1656 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1657 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1658 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1659 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1660 // create group for each type o elements
1661 QString aName = IObject->getName();
1662 if (aNodes->length() > 0) {
1663 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1664 aGroup->Add(aNodes.inout());
1666 if (aEdges->length() > 0) {
1667 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1668 aGroup->Add(aEdges.inout());
1670 if (aFaces->length() > 0) {
1671 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1672 aGroup->Add(aFaces.inout());
1674 if (aVolumes->length() > 0) {
1675 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1676 aGroup->Add(aVolumes.inout());
1681 catch(const SALOME::SALOME_Exception & S_ex){
1682 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1689 SUIT_MessageBox::warn1(desktop(),
1690 tr("SMESH_WRN_WARNING"),
1691 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1692 tr("SMESH_BUT_OK"));
1697 case 803: // EDIT GROUP
1701 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1702 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1706 if(checkLock(aStudy)) break;
1707 EmitSignalDeactivateDialog();
1709 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1710 SALOME_ListIO selected;
1712 aSel->selectedObjects( selected );
1714 SALOME_ListIteratorOfListIO It (selected);
1715 int nbSelectedGroups = 0;
1716 for ( ; It.More(); It.Next() )
1718 SMESH::SMESH_GroupBase_var aGroup =
1719 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1720 if (!aGroup->_is_nil()) {
1722 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1726 if (nbSelectedGroups == 0)
1728 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1734 case 804: // Add elements to group
1736 if(checkLock(aStudy)) break;
1737 if (myState == 800) {
1738 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1739 if (aDlg) aDlg->onAdd();
1744 case 805: // Remove elements from group
1746 if(checkLock(aStudy)) break;
1747 if (myState == 800) {
1748 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1749 if (aDlg) aDlg->onRemove();
1754 case 810: // Union Groups
1755 case 811: // Intersect groups
1756 case 812: // Cut groups
1760 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1761 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1765 if ( checkLock( aStudy ) )
1768 EmitSignalDeactivateDialog();
1771 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1772 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1773 else aMode = SMESHGUI_GroupOpDlg::CUT;
1775 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1779 case 813: // Delete groups with their contents
1783 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1784 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1788 if ( checkLock( aStudy ) )
1791 EmitSignalDeactivateDialog();
1793 new SMESHGUI_DeleteGroupDlg( this );
1797 case 900: // MESH INFOS
1799 EmitSignalDeactivateDialog();
1800 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1801 SALOME_ListIO selected;
1803 aSel->selectedObjects( selected );
1805 if ( selected.Extent() > 1 ) { // a dlg for each IO
1807 SALOME_ListIteratorOfListIO It (selected);
1808 for ( ; It.More(); It.Next() ) {
1809 IOs.Clear(); IOs.Append( It.Value() );
1810 aSel->setSelectedObjects( IOs );
1811 new SMESHGUI_MeshInfosDlg(this, "", false);
1813 // restore selection
1814 aSel->setSelectedObjects( selected );
1817 new SMESHGUI_MeshInfosDlg(this, "", false);
1821 case 902: // STANDARD MESH INFOS
1823 EmitSignalDeactivateDialog();
1824 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1825 SALOME_ListIO selected;
1827 aSel->selectedObjects( selected );
1829 if ( selected.Extent() > 1 ) { // a dlg for each IO
1831 SALOME_ListIteratorOfListIO It (selected);
1832 for ( ; It.More(); It.Next() ) {
1834 IOs.Append( It.Value() );
1835 aSel->setSelectedObjects( IOs );
1836 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1838 // restore selection
1839 aSel->setSelectedObjects( selected );
1842 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1846 case 1100: // EDIT HYPOTHESIS
1848 if(checkLock(aStudy)) break;
1850 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1851 SALOME_ListIO selected;
1853 aSel->selectedObjects( selected );
1855 int nbSel = selected.Extent();
1858 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1860 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1861 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1862 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1863 if ( !Hyp->_is_nil() )
1865 char* sName = Hyp->GetName();
1866 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1868 aCreator->edit( Hyp.in(), desktop() );
1875 updateObjBrowser( true );
1879 case 1101: // RENAME
1881 if ( checkLock( aStudy ) )
1884 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1885 SALOME_ListIO selected;
1887 aSel->selectedObjects( selected );
1889 SALOME_ListIteratorOfListIO It( selected );
1890 for ( ; It.More(); It.Next() )
1892 Handle(SALOME_InteractiveObject) IObject = It.Value();
1893 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1894 _PTR(GenericAttribute) anAttr;
1895 _PTR(AttributeName) aName;
1898 if ( obj->FindAttribute(anAttr, "AttributeName") )
1901 QString newName = QString(aName->Value().c_str());
1902 newName = LightApp_NameDlg::getName(desktop(), newName);
1903 if ( !newName.isEmpty() )
1905 //old source: aStudy->renameIObject( IObject, newName );
1906 aName->SetValue( newName.latin1() );
1908 // if current object is group update group's name
1909 SMESH::SMESH_GroupBase_var aGroup =
1910 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1911 if (!aGroup->_is_nil() )
1912 aGroup->SetName( newName.latin1() );
1922 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1924 if(checkLock(aStudy)) break;
1925 SUIT_OverrideCursor wc;
1927 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1928 SALOME_ListIO selected;
1930 aSel->selectedObjects( selected, QString::null, false );
1932 SALOME_ListIteratorOfListIO It(selected);
1933 for (int i = 0; It.More(); It.Next(), i++) {
1934 Handle(SALOME_InteractiveObject) IObject = It.Value();
1935 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1938 aSel->setSelectedObjects( l1 );
1943 case 401: // GEOM::EDGE
1944 case 4021: // TRIANGLE
1946 case 4023: // POLYGON
1950 if(checkLock(aStudy)) break;
1952 EmitSignalDeactivateDialog();
1953 SMDSAbs_ElementType type = SMDSAbs_Edge;
1955 switch (theCommandID) {
1956 case 4021: // TRIANGLE
1957 type = SMDSAbs_Face; nbNodes = 3; break;
1959 type = SMDSAbs_Face; nbNodes = 4; break;
1961 type = SMDSAbs_Volume; nbNodes = 4; break;
1962 case 4023: // POLYGON
1963 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1965 type = SMDSAbs_Volume; nbNodes = 8; break;
1966 case 4033: // POLYHEDRE
1967 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1970 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1973 SUIT_MessageBox::warn1(desktop(),
1974 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1975 tr("SMESH_BUT_OK"));
1979 case 4033: // POLYHEDRON
1981 if(checkLock(aStudy)) break;
1983 EmitSignalDeactivateDialog();
1984 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1987 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1988 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1989 tr("SMESH_BUT_OK"));
1993 case 4034: // QUADRATIC EDGE
1994 case 4035: // QUADRATIC TRIANGLE
1995 case 4036: // QUADRATIC QUADRANGLE
1996 case 4037: // QUADRATIC TETRAHEDRON
1997 case 4038: // QUADRATIC PYRAMID
1998 case 4039: // QUADRATIC PENTAHEDRON
1999 case 4040: // QUADRATIC HEXAHEDRON
2001 if(checkLock(aStudy)) break;
2003 EmitSignalDeactivateDialog();
2006 switch (theCommandID) {
2008 type = QUAD_EDGE; break;
2010 type = QUAD_TRIANGLE; break;
2012 type = QUAD_QUADRANGLE; break;
2014 type = QUAD_TETRAHEDRON; break;
2016 type = QUAD_PYRAMID; break;
2018 type = QUAD_PENTAHEDRON; break;
2020 type = QUAD_HEXAHEDRON;
2024 new SMESHGUI_AddQuadraticElementDlg( this, type );
2027 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2033 case 4041: // REMOVES NODES
2035 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2038 new SMESHGUI_RemoveNodesDlg(this);
2041 SUIT_MessageBox::warn1(desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4042: // REMOVES ELEMENTS
2049 if(checkLock(aStudy)) break;
2051 EmitSignalDeactivateDialog();
2052 new SMESHGUI_RemoveElementsDlg(this);
2056 SUIT_MessageBox::warn1(desktop(),
2057 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2058 tr("SMESH_BUT_OK"));
2062 case 4051: // RENUMBERING NODES
2064 if(checkLock(aStudy)) break;
2066 EmitSignalDeactivateDialog();
2067 new SMESHGUI_RenumberingDlg( this, "", 0);
2071 SUIT_MessageBox::warn1(desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4052: // RENUMBERING ELEMENTS
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 new SMESHGUI_RenumberingDlg( this, "", 1);
2086 SUIT_MessageBox::warn1(desktop(),
2087 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2088 tr("SMESH_BUT_OK"));
2092 case 4061: // TRANSLATION
2094 if(checkLock(aStudy)) break;
2096 EmitSignalDeactivateDialog();
2097 new SMESHGUI_TranslationDlg( this );
2100 SUIT_MessageBox::warn1(desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2102 tr("SMESH_BUT_OK"));
2106 case 4062: // ROTATION
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 new SMESHGUI_RotationDlg( this );
2114 SUIT_MessageBox::warn1(desktop(),
2115 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2116 tr("SMESH_BUT_OK"));
2120 case 4063: // SYMMETRY
2122 if(checkLock(aStudy)) break;
2124 EmitSignalDeactivateDialog();
2125 new SMESHGUI_SymmetryDlg( this );
2128 SUIT_MessageBox::warn1(desktop(),
2129 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2130 tr("SMESH_BUT_OK"));
2134 case 4064: // SEWING
2136 if(checkLock(aStudy)) break;
2138 EmitSignalDeactivateDialog();
2139 new SMESHGUI_SewingDlg( this );
2142 SUIT_MessageBox::warn1(desktop(),
2143 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2144 tr("SMESH_BUT_OK"));
2148 case 4065: // MERGE NODES
2150 if(checkLock(aStudy)) break;
2152 EmitSignalDeactivateDialog();
2153 new SMESHGUI_EditMeshDlg( this, 0 );
2156 SUIT_MessageBox::warn1(desktop(),
2157 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2158 tr("SMESH_BUT_OK"));
2162 case 4066: // MERGE EQUAL ELEMENTS
2164 if (checkLock(aStudy)) break;
2166 EmitSignalDeactivateDialog();
2167 new SMESHGUI_EditMeshDlg( this, 1 );
2169 SUIT_MessageBox::warn1(desktop(),
2170 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2171 tr("SMESH_BUT_OK"));
2176 case 4067: // MAKE MESH PASS THROUGH POINT
2177 startOperation( 4067 );
2180 case 5105: // Library of selection filters
2182 static QValueList<int> aTypes;
2183 if ( aTypes.isEmpty() )
2185 aTypes.append( SMESH::NODE );
2186 aTypes.append( SMESH::EDGE );
2187 aTypes.append( SMESH::FACE );
2188 aTypes.append( SMESH::VOLUME );
2190 if (!myFilterLibraryDlg)
2191 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2192 else if (myFilterLibraryDlg->isHidden())
2193 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2194 myFilterLibraryDlg->raise();
2198 case 6017: // CONTROLS
2214 LightApp_SelectionMgr* mgr = selectionMgr();
2215 SALOME_ListIO selected; mgr->selectedObjects( selected );
2217 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2218 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2220 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2221 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2222 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2223 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2224 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2225 ::Control( theCommandID );
2230 SUIT_MessageBox::warn1(desktop(),
2231 tr( "SMESH_WRN_WARNING" ),
2232 tr( "SMESH_BAD_SELECTION" ),
2233 tr( "SMESH_BUT_OK" ) );
2237 SUIT_MessageBox::warn1(desktop(),
2238 tr( "SMESH_WRN_WARNING" ),
2239 tr( "NOT_A_VTK_VIEWER" ),
2240 tr( "SMESH_BUT_OK" ) );
2245 LightApp_SelectionMgr* mgr = selectionMgr();
2246 SALOME_ListIO selected; mgr->selectedObjects( selected );
2248 SALOME_ListIteratorOfListIO it(selected);
2249 for(; it.More(); it.Next()) {
2250 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2251 if(anIObject->hasEntry()) {
2252 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2253 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2261 LightApp_SelectionMgr* mgr = selectionMgr();
2262 SALOME_ListIO selected; mgr->selectedObjects( selected );
2264 if (selected.Extent() == 1) {
2265 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2266 if(anIObject->hasEntry())
2267 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2268 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2275 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2276 //updateObjBrowser();
2280 //=============================================================================
2284 //=============================================================================
2285 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2290 //=============================================================================
2294 //=============================================================================
2295 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2300 //=============================================================================
2304 //=============================================================================
2305 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2310 //=============================================================================
2311 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2312 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2314 //=============================================================================
2315 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2316 SUIT_ViewWindow* wnd )
2318 if(theIO->hasEntry()){
2319 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2320 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2324 //=======================================================================
2325 // function : createSMESHAction
2327 //=======================================================================
2328 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2331 QWidget* parent = application()->desktop();
2332 SUIT_ResourceMgr* resMgr = resourceMgr();
2334 if ( icon_id.length() )
2335 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2337 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2338 if ( !pix.isNull() )
2339 icon = QIconSet( pix );
2341 QString tooltip = tr( QString( "TOP_" )+po_id ),
2342 menu = tr( QString( "MEN_" )+po_id ),
2343 status_bar = tr( QString( "STB_" )+po_id );
2345 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2348 //=======================================================================
2349 // function : createPopupItem
2351 //=======================================================================
2352 void SMESHGUI::createPopupItem( const int id,
2353 const QString& clients,
2354 const QString& types,
2355 const QString& theRule,
2360 parentId = popupMgr()->actionId( action( pId ) );
2362 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2363 popupMgr()->insert( action( id ), parentId, 0 );
2365 QChar lc = QtxPopupMgr::Selection::defEquality();
2366 QString rule = "(%1) and (%2) and (%3)";
2367 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2368 if( clients.isEmpty() )
2369 rule = rule.arg( QString( "true" ) );
2371 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2372 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2375 bool cont = myRules.contains( id );
2377 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2379 popupMgr()->setRule( action( id ), rule, true );
2380 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2383 //=======================================================================
2384 // function : initialize
2386 //=======================================================================
2387 void SMESHGUI::initialize( CAM_Application* app )
2389 SalomeApp_Module::initialize( app );
2391 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2393 /* Automatic Update flag */
2394 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2396 // ----- create actions --------------
2398 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2399 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2400 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2401 createSMESHAction( 114, "NUM" );
2402 createSMESHAction( 121, "DAT" );
2403 createSMESHAction( 122, "MED" );
2404 createSMESHAction( 123, "UNV" );
2405 createSMESHAction( 140, "STL" );
2406 createSMESHAction( 124, "EXPORT_DAT" );
2407 createSMESHAction( 125, "EXPORT_MED" );
2408 createSMESHAction( 126, "EXPORT_UNV" );
2409 createSMESHAction( 141, "EXPORT_STL" );
2410 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2411 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2412 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2413 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2414 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2415 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2416 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2417 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2418 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2419 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2420 createSMESHAction( 804, "ADD" );
2421 createSMESHAction( 805, "REMOVE" );
2422 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2423 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2424 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2425 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2426 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2427 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2428 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2429 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2430 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2431 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2432 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2433 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2434 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2435 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2436 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2437 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2438 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2439 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2440 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2441 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2442 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2443 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2444 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2445 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2446 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2447 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2448 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2449 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2450 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2451 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2452 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2453 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2454 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2455 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2456 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2457 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2458 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2459 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2460 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2461 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2462 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2463 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2464 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2465 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2466 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2467 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2468 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2469 createSMESHAction( 415, "MAP", "ICON_MAP" );
2470 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2471 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2472 createSMESHAction( 200, "RESET" );
2473 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2474 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2475 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2476 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2477 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2478 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2479 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2480 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2481 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2482 createSMESHAction( 220, "ALL" );
2483 createSMESHAction( 1100, "EDIT_HYPO" );
2484 createSMESHAction( 1101, "RENAME" );
2485 createSMESHAction( 1102, "UNASSIGN" );
2486 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2487 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2488 createSMESHAction( 1131, "DISPMODE" );
2489 createSMESHAction( 1132, "COLORS" );
2490 createSMESHAction( 1133, "TRANSP" );
2491 createSMESHAction( 1134, "CLIP" );
2492 createSMESHAction( 1135, "DISP_ENT" );
2493 createSMESHAction( 2000, "CTRL" );
2495 createSMESHAction( 300, "ERASE" );
2496 createSMESHAction( 301, "DISPLAY" );
2497 createSMESHAction( 302, "DISPLAY_ONLY" );
2498 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2499 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2500 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2501 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2502 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2503 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2504 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2505 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2507 // ----- create menu --------------
2508 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2509 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2510 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2511 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2512 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2513 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2514 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2516 createMenu( separator(), fileId );
2518 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2519 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2520 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2521 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2522 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2523 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2525 createMenu( 111, importId, -1 );
2526 createMenu( 112, importId, -1 );
2527 createMenu( 113, importId, -1 );
2529 createMenu( 121, exportId, -1 );
2530 createMenu( 122, exportId, -1 );
2531 createMenu( 123, exportId, -1 );
2532 createMenu( 140, exportId, -1 ); // export to stl STL
2534 createMenu( separator(), fileId, 10 );
2536 createMenu( 33, editId, -1 );
2538 createMenu( 5105, toolsId, -1 );
2540 createMenu( 702, meshId, -1 );
2541 createMenu( 703, meshId, -1 );
2542 createMenu( 704, meshId, -1 );
2543 createMenu( 710, meshId, -1 );
2544 createMenu( separator(), meshId, -1 );
2545 createMenu( 701, meshId, -1 );
2546 createMenu( separator(), meshId, -1 );
2547 createMenu( 801, meshId, -1 );
2548 createMenu( 802, meshId, -1 );
2549 createMenu( 803, meshId, -1 );
2550 createMenu( separator(), meshId, -1 );
2551 createMenu( 810, meshId, -1 );
2552 createMenu( 811, meshId, -1 );
2553 createMenu( 812, meshId, -1 );
2554 createMenu( separator(), meshId, -1 );
2555 createMenu( 813, meshId, -1 );
2556 createMenu( separator(), meshId, -1 );
2557 createMenu( 900, meshId, -1 );
2558 createMenu( 902, meshId, -1 );
2559 createMenu( separator(), meshId, -1 );
2561 createMenu( 6003, ctrlId, -1 );
2562 createMenu( 6001, ctrlId, -1 );
2563 createMenu( 6004, ctrlId, -1 );
2564 createMenu( separator(), ctrlId, -1 );
2565 createMenu( 6002, ctrlId, -1 );
2566 createMenu( 6018, ctrlId, -1 );
2567 createMenu( 6019, ctrlId, -1 );
2568 createMenu( 6011, ctrlId, -1 );
2569 createMenu( 6012, ctrlId, -1 );
2570 createMenu( 6013, ctrlId, -1 );
2571 createMenu( 6014, ctrlId, -1 );
2572 createMenu( 6015, ctrlId, -1 );
2573 createMenu( 6016, ctrlId, -1 );
2574 createMenu( separator(), ctrlId, -1 );
2575 createMenu( 6017, ctrlId, -1 );
2576 createMenu( 6009, ctrlId, -1 );
2577 createMenu( separator(), ctrlId, -1 );
2579 createMenu( 400, addId, -1 );
2580 createMenu( 401, addId, -1 );
2581 createMenu( 4021, addId, -1 );
2582 createMenu( 4022, addId, -1 );
2583 createMenu( 4023, addId, -1 );
2584 createMenu( 4031, addId, -1 );
2585 createMenu( 4032, addId, -1 );
2586 createMenu( 4033, addId, -1 );
2587 createMenu( separator(), addId, -1 );
2588 createMenu( 4034, addId, -1 );
2589 createMenu( 4035, addId, -1 );
2590 createMenu( 4036, addId, -1 );
2591 createMenu( 4037, addId, -1 );
2592 createMenu( 4038, addId, -1 );
2593 createMenu( 4039, addId, -1 );
2594 createMenu( 4040, addId, -1 );
2596 createMenu( 4041, removeId, -1 );
2597 createMenu( 4042, removeId, -1 );
2599 createMenu( 4051, renumId, -1 );
2600 createMenu( 4052, renumId, -1 );
2602 createMenu( 4061, transfId, -1 );
2603 createMenu( 4062, transfId, -1 );
2604 createMenu( 4063, transfId, -1 );
2605 createMenu( 4064, transfId, -1 );
2606 createMenu( 4065, transfId, -1 );
2607 createMenu( 4066, transfId, -1 );
2609 createMenu( 406, modifyId, -1 );
2610 createMenu( 4067,modifyId, -1 );
2611 createMenu( 407, modifyId, -1 );
2612 createMenu( 408, modifyId, -1 );
2613 createMenu( 409, modifyId, -1 );
2614 createMenu( 410, modifyId, -1 );
2615 createMenu( 411, modifyId, -1 );
2616 createMenu( 412, modifyId, -1 );
2617 createMenu( 413, modifyId, -1 );
2618 createMenu( 416, modifyId, -1 );
2619 createMenu( 414, modifyId, -1 );
2620 createMenu( 415, modifyId, -1 );
2621 createMenu( 417, modifyId, -1 );
2623 createMenu( 214, viewId, -1 );
2625 // ----- create toolbars --------------
2626 int meshTb = createTool( tr( "TB_MESH" ) ),
2627 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2628 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2629 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2630 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2632 createTool( 702, meshTb );
2633 createTool( 703, meshTb );
2634 createTool( 704, meshTb );
2635 createTool( 710, meshTb );
2636 createTool( separator(), meshTb );
2637 createTool( 701, meshTb );
2638 createTool( separator(), meshTb );
2639 createTool( 801, meshTb );
2640 createTool( 802, meshTb );
2641 createTool( 803, meshTb );
2642 createTool( separator(), meshTb );
2643 createTool( 900, meshTb );
2644 createTool( 902, meshTb );
2645 createTool( separator(), meshTb );
2647 createTool( 6001, ctrlTb );
2648 createTool( 6003, ctrlTb );
2649 createTool( 6004, ctrlTb );
2650 createTool( separator(), ctrlTb );
2651 createTool( 6002, ctrlTb );
2652 createTool( 6018, ctrlTb );
2653 createTool( 6019, ctrlTb );
2654 createTool( 6011, ctrlTb );
2655 createTool( 6012, ctrlTb );
2656 createTool( 6013, ctrlTb );
2657 createTool( 6014, ctrlTb );
2658 createTool( 6015, ctrlTb );
2659 createTool( 6016, ctrlTb );
2660 createTool( separator(), ctrlTb );
2661 createTool( 6017, ctrlTb );
2662 createTool( 6009, ctrlTb );
2663 createTool( separator(), ctrlTb );
2665 createTool( 400, addRemTb );
2666 createTool( 401, addRemTb );
2667 createTool( 4021, addRemTb );
2668 createTool( 4022, addRemTb );
2669 createTool( 4023, addRemTb );
2670 createTool( 4031, addRemTb );
2671 createTool( 4032, addRemTb );
2672 createTool( 4033, addRemTb );
2673 createTool( separator(), addRemTb );
2674 createTool( 4034, addRemTb );
2675 createTool( 4035, addRemTb );
2676 createTool( 4036, addRemTb );
2677 createTool( 4037, addRemTb );
2678 createTool( 4038, addRemTb );
2679 createTool( 4039, addRemTb );
2680 createTool( 4040, addRemTb );
2681 createTool( separator(), addRemTb );
2682 createTool( 4041, addRemTb );
2683 createTool( 4042, addRemTb );
2684 createTool( separator(), addRemTb );
2685 createTool( 4051, addRemTb );
2686 createTool( 4052, addRemTb );
2687 createTool( separator(), addRemTb );
2688 createTool( 4061, addRemTb );
2689 createTool( 4062, addRemTb );
2690 createTool( 4063, addRemTb );
2691 createTool( 4064, addRemTb );
2692 createTool( 4065, addRemTb );
2693 createTool( 4066, addRemTb );
2694 createTool( separator(), addRemTb );
2696 createTool( 406, modifyTb );
2697 createTool( 4067,modifyTb );
2698 createTool( 407, modifyTb );
2699 createTool( 408, modifyTb );
2700 createTool( 409, modifyTb );
2701 createTool( 410, modifyTb );
2702 createTool( 411, modifyTb );
2703 createTool( 412, modifyTb );
2704 createTool( 413, modifyTb );
2705 createTool( 416, modifyTb );
2706 createTool( 414, modifyTb );
2707 createTool( 415, modifyTb );
2708 createTool( 417, modifyTb );
2710 createTool( 214, dispModeTb );
2714 QString OB = "'ObjectBrowser'",
2715 View = "'" + SVTK_Viewer::Type() + "'",
2717 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2718 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2719 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2720 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2721 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2722 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2723 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2724 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2725 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2726 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2727 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2729 mesh_group = mesh + " " + subMesh + " " + group,
2730 hyp_alg = hypo + " " + algo;
2732 // popup for object browser
2734 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2735 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2736 createPopupItem( 803, OB, group ); // EDIT_GROUP
2737 popupMgr()->insert( separator(), -1, 0 );
2738 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2739 createPopupItem( 214, OB, mesh_group ); // UPDATE
2740 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2741 createPopupItem( 902, OB, mesh ); // STD_INFO
2742 popupMgr()->insert( separator(), -1, 0 );
2743 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2744 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2745 popupMgr()->insert( separator(), -1, 0 );
2746 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2747 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2748 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2749 popupMgr()->insert( separator(), -1, 0 );
2751 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2752 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2753 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2754 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2755 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2756 popupMgr()->insert( separator(), -1, 0 );
2759 createPopupItem( 803, View, group ); // EDIT_GROUP
2760 createPopupItem( 804, View, elems ); // ADD
2761 createPopupItem( 805, View, elems ); // REMOVE
2762 popupMgr()->insert( separator(), -1, 0 );
2763 createPopupItem( 214, View, mesh_group ); // UPDATE
2764 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2765 createPopupItem( 902, View, mesh ); // STD_INFO
2766 popupMgr()->insert( separator(), -1, 0 );
2770 isInvisible("not( isVisible )"),
2771 isEmpty("numberOfNodes = 0"),
2772 isNotEmpty("numberOfNodes <> 0"),
2774 // has nodes, edges, etc in VISIBLE! actor
2775 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2776 hasElems("(count( elemTypes ) > 0)"),
2777 hasDifferentElems("(count( elemTypes ) > 1)"),
2778 hasEdges("({'Edge'} in elemTypes)"),
2779 hasFaces("({'Face'} in elemTypes)"),
2780 hasVolumes("({'Volume'} in elemTypes)");
2782 QString lc = QtxPopupMgr::Selection::defEquality();
2783 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2784 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2785 aType = aType.arg( mesh_group );
2786 QString aMeshInVTK = aClient + "&&" + aType;
2788 //-------------------------------------------------
2790 //-------------------------------------------------
2791 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2793 popupMgr()->insert( action( 9010 ), anId, -1 );
2794 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2795 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2797 popupMgr()->insert( action( 9011 ), anId, -1 );
2798 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2799 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2801 popupMgr()->insert( separator(), -1, -1 );
2803 //-------------------------------------------------
2805 //-------------------------------------------------
2806 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2808 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2809 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2810 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2812 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2813 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2814 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2816 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2817 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2818 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2820 popupMgr()->insert( separator(), anId, -1 );
2822 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2823 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2824 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2826 //-------------------------------------------------
2828 //-------------------------------------------------
2829 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2831 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2833 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2834 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2835 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2837 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2838 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2839 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2841 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2842 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2843 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2845 popupMgr()->insert( separator(), anId, -1 );
2847 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2848 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2850 //-------------------------------------------------
2852 //-------------------------------------------------
2853 popupMgr()->insert( action( 1132 ), -1, -1 );
2854 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2856 //-------------------------------------------------
2858 //-------------------------------------------------
2859 popupMgr()->insert( action( 1133 ), -1, -1 );
2860 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2862 //-------------------------------------------------
2864 //-------------------------------------------------
2865 popupMgr()->insert( action( 1134 ), -1, -1 );
2866 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2868 popupMgr()->insert( separator(), -1, -1 );
2870 //-------------------------------------------------
2872 //-------------------------------------------------
2874 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2875 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2876 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2878 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2880 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2881 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2883 popupMgr()->insert( separator(), anId, -1 );
2885 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2886 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2887 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2889 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2890 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2891 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2893 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2894 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2895 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2897 popupMgr()->insert( separator(), anId, -1 );
2899 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2900 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2901 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2903 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2904 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2905 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2907 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2908 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2909 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2911 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2912 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2913 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2915 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2916 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2917 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2919 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2920 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2921 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2923 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2924 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2925 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2927 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2928 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2929 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2931 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2932 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2933 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2935 popupMgr()->insert( separator(), anId, -1 );
2937 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2938 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2939 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2941 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2942 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2943 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2945 popupMgr()->insert( separator(), anId, -1 );
2947 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2948 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2950 popupMgr()->insert( separator(), -1, -1 );
2952 //-------------------------------------------------
2954 //-------------------------------------------------
2955 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2956 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2957 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2959 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2960 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2961 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2962 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2964 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2965 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2967 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2968 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2970 popupMgr()->insert( separator(), -1, -1 );
2972 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2973 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2976 bool SMESHGUI::activateModule( SUIT_Study* study )
2978 bool res = SalomeApp_Module::activateModule( study );
2980 setMenuShown( true );
2981 setToolShown( true );
2983 // Reset actions accelerator keys
2984 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2985 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2986 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2991 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2993 setMenuShown( false );
2994 setToolShown( false );
2996 EmitSignalCloseAllDialogs();
2998 // Unset actions accelerator keys
2999 action(111)->setAccel(QKeySequence()); // Import DAT
3000 action(112)->setAccel(QKeySequence()); // Import UNV
3001 action(113)->setAccel(QKeySequence()); // Import MED
3003 return SalomeApp_Module::deactivateModule( study );
3006 void SMESHGUI::OnGUIEvent()
3008 const QObject* obj = sender();
3009 if ( !obj || !obj->inherits( "QAction" ) )
3011 int id = actionId((QAction*)obj);
3016 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3018 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3019 if ( CORBA::is_nil( myComponentSMESH ) )
3021 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3023 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3024 return aGUI.myComponentSMESH;
3027 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3028 return myComponentSMESH;
3031 QString SMESHGUI::engineIOR() const
3033 CORBA::ORB_var anORB = getApp()->orb();
3034 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3038 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3040 SMESHGUI_Selection sel;
3041 sel.init( client, selectionMgr() );
3042 popupMgr()->updatePopup( menu, &sel );
3045 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3047 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3048 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3051 void SMESHGUI::viewManagers( QStringList& list ) const
3053 list.append( SVTK_Viewer::Type() );
3056 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3058 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3059 SMESH::UpdateSelectionProp( this );
3062 void SMESHGUI::createPreferences()
3064 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3066 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3067 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3069 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3070 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3071 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3073 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3074 setPreferenceProperty( precGroup, "columns", 1 );
3076 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3078 setPreferenceProperty( prec, "min", 0 );
3079 setPreferenceProperty( prec, "max", 16 );
3081 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3082 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3084 modes.append( "Wireframe" );
3085 modes.append( "Shading" );
3086 modes.append( "Nodes" );
3087 modes.append( "Shrink" );
3088 QValueList<QVariant> indices;
3089 indices.append( 0 );
3090 indices.append( 1 );
3091 indices.append( 2 );
3092 indices.append( 3 );
3093 setPreferenceProperty( dispmode, "strings", modes );
3094 setPreferenceProperty( dispmode, "indexes", indices );
3096 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3097 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3098 int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3100 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3101 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3103 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3104 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3106 setPreferenceProperty( nodeSz, "min", 1 );
3107 setPreferenceProperty( nodeSz, "max", 5 );
3109 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3111 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3112 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3113 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3114 addPreference( "", elemGroup, LightApp_Preferences::Space );
3116 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3117 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3119 setPreferenceProperty( elemW, "min", 1 );
3120 setPreferenceProperty( elemW, "max", 5 );
3122 setPreferenceProperty( shrink, "min", 0 );
3123 setPreferenceProperty( shrink, "max", 100 );
3125 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3127 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3129 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3130 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3131 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3133 setPreferenceProperty( selW, "min", 1 );
3134 setPreferenceProperty( selW, "max", 5 );
3136 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3138 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3139 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3141 setPreferenceProperty( preW, "min", 1 );
3142 setPreferenceProperty( preW, "max", 5 );
3144 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3146 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3147 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3149 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3150 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3152 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3153 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3154 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3155 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3158 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3159 fam.append( tr( "SMESH_FONT_COURIER" ) );
3160 fam.append( tr( "SMESH_FONT_TIMES" ) );
3161 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3163 setPreferenceProperty( tfont, "families", fam );
3164 setPreferenceProperty( tfont, "system", false );
3165 setPreferenceProperty( tfont, "widget_flags", wflag );
3166 setPreferenceProperty( lfont, "families", fam );
3167 setPreferenceProperty( lfont, "system", false );
3168 setPreferenceProperty( lfont, "widget_flags", wflag );
3170 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3172 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3173 setPreferenceProperty( numcol, "min", 2 );
3174 setPreferenceProperty( numcol, "max", 256 );
3176 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3177 setPreferenceProperty( numlab, "min", 2 );
3178 setPreferenceProperty( numlab, "max", 65 );
3180 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3181 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3182 QStringList orients;
3183 orients.append( tr( "SMESH_VERTICAL" ) );
3184 orients.append( tr( "SMESH_HORIZONTAL" ) );
3185 indices.clear(); indices.append( 0 ); indices.append( 1 );
3186 setPreferenceProperty( orient, "strings", orients );
3187 setPreferenceProperty( orient, "indexes", indices );
3189 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3190 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3191 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3192 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3193 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3194 setPreferenceProperty( xv, "step", 0.1 );
3195 setPreferenceProperty( xv, "min", 0.0 );
3196 setPreferenceProperty( xv, "max", 1.0 );
3197 setPreferenceProperty( yv, "step", 0.1 );
3198 setPreferenceProperty( yv, "min", 0.0 );
3199 setPreferenceProperty( yv, "max", 1.0 );
3200 setPreferenceProperty( wv, "step", 0.1 );
3201 setPreferenceProperty( wv, "min", 0.0 );
3202 setPreferenceProperty( wv, "max", 1.0 );
3203 setPreferenceProperty( hv, "min", 0.0 );
3204 setPreferenceProperty( hv, "max", 1.0 );
3205 setPreferenceProperty( hv, "step", 0.1 );
3207 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3208 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3209 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3210 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3211 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3212 setPreferenceProperty( xv, "min", 0.0 );
3213 setPreferenceProperty( xv, "max", 1.0 );
3214 setPreferenceProperty( xv, "step", 0.1 );
3215 setPreferenceProperty( xh, "min", 0.0 );
3216 setPreferenceProperty( xh, "max", 1.0 );
3217 setPreferenceProperty( xh, "step", 0.1 );
3218 setPreferenceProperty( yh, "min", 0.0 );
3219 setPreferenceProperty( yh, "max", 1.0 );
3220 setPreferenceProperty( yh, "step", 0.1 );
3221 setPreferenceProperty( wh, "min", 0.0 );
3222 setPreferenceProperty( wh, "max", 1.0 );
3223 setPreferenceProperty( wh, "step", 0.1 );
3224 setPreferenceProperty( hh, "min", 0.0 );
3225 setPreferenceProperty( hh, "max", 1.0 );
3226 setPreferenceProperty( hh, "step", 0.1 );
3229 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3231 if( sect=="SMESH" ){
3232 float sbX1,sbY1,sbW,sbH;
3233 float aTol = 1.00000009999999;
3234 std::string aWarning;
3235 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3236 if( name=="selection_object_color" || name=="selection_element_color" ||
3237 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3238 name=="selection_precision_node" || name=="selection_precision_element" )
3239 SMESH::UpdateSelectionProp( this );
3240 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3241 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3242 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3243 if(sbX1+sbW > aTol){
3244 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3247 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3248 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3251 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3252 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3253 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3254 if(sbY1+sbH > aTol){
3255 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3258 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3259 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3262 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3263 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3264 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3265 if(sbX1+sbW > aTol){
3266 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3269 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3270 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3273 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3274 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3275 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3276 if(sbY1+sbH > aTol){
3277 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3280 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3281 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3285 if(aWarning.size() != 0){
3286 aWarning += "The default values are applied instead.";
3287 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3288 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3289 QObject::tr(aWarning.c_str()),
3290 QObject::tr("SMESH_BUT_OK"));
3295 //================================================================================
3297 * \brief Update something in accordance with update flags
3298 * \param theFlags - update flags
3300 * Update viewer or/and object browser etc. in accordance with update flags ( see
3301 * LightApp_UpdateFlags enumeration ).
3303 //================================================================================
3304 void SMESHGUI::update( const int flags )
3306 if ( flags & UF_Viewer | flags & UF_Forced )
3307 SMESH::UpdateView();
3309 SalomeApp_Module::update( flags );
3312 //================================================================================
3314 * \brief Set default selection mode
3316 * SLOT called when operation commited. Sets default selection mode
3318 //================================================================================
3319 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3321 SVTK_ViewWindow* vtkWnd =
3322 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3324 vtkWnd->SetSelectionMode( ActorSelection );
3327 //================================================================================
3329 * \brief Set default selection mode
3331 * SLOT called when operation aborted. Sets default selection mode
3333 //================================================================================
3334 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3336 SVTK_ViewWindow* vtkWnd =
3337 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3339 vtkWnd->SetSelectionMode( ActorSelection );
3342 //================================================================================
3344 * \brief Creates operation with given identifier
3345 * \param id - identifier of operation to be started
3346 * \return Pointer on created operation or NULL if operation is not created
3348 * Virtual method redefined from the base class creates operation with given id.
3349 * It is called called automatically from startOperation method of base class.
3351 //================================================================================
3352 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3354 LightApp_Operation* op = 0;
3355 // to do : create operation here
3358 case 702: // Create mesh
3359 op = new SMESHGUI_MeshOp( true, true );
3361 case 703: // Create sub-mesh
3362 op = new SMESHGUI_MeshOp( true, false );
3364 case 704: // Edit mesh/sub-mesh
3365 op = new SMESHGUI_MeshOp( false );
3367 case 417: //convert to quadratic
3368 op = new SMESHGUI_ConvToQuadOp();
3370 case 4067: // make mesh pass through point
3371 op = new SMESHGUI_MakeNodeAtPointOp();
3378 op = SalomeApp_Module::createOperation( id );
3382 //================================================================================
3384 * \brief Stops current operations and starts a given one
3385 * \param id - The id of the operation to start
3387 //================================================================================
3389 void SMESHGUI::switchToOperation(int id)
3391 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3392 activeStudy()->abortAllOperations();
3393 startOperation( id );
3396 LightApp_Displayer* SMESHGUI::displayer()
3399 myDisplayer = new SMESHGUI_Displayer( getApp() );