1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_BuildCompoundDlg.h"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_GEOMGenUtils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include "SMESH_Actor.h"
81 #include "SMESH_Object.h"
82 #include "SMESH_TypeFilter.hxx"
84 #include "SalomeApp_Tools.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_CheckFileDlg.h"
88 #include "SalomeApp_ImportOperation.h"
90 #include "LightApp_DataOwner.h"
91 #include "LightApp_Preferences.h"
92 #include "LightApp_VTKSelector.h"
93 #include "LightApp_Operation.h"
94 #include "LightApp_UpdateFlags.h"
95 #include "LightApp_NameDlg.h"
97 #include <SVTK_ViewWindow.h>
98 #include <SVTK_ViewModel.h>
99 #include <SVTK_InteractorStyle.h>
100 #include <SVTK_RenderWindowInteractor.h>
101 #include <SVTK_ViewManager.h>
103 #include "OB_Browser.h"
105 #include "SUIT_Tools.h"
106 #include "SUIT_MessageBox.h"
107 #include "SUIT_ResourceMgr.h"
108 #include "SUIT_FileDlg.h"
109 #include "SUIT_Desktop.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
127 #define INCLUDE_MENUITEM_DEF
128 #include <qpopupmenu.h>
134 #include <boost/shared_ptr.hpp>
137 #include <vtkRenderer.h>
138 #include <vtkRenderWindow.h>
139 #include <vtkActorCollection.h>
140 #include <vtkScalarBarActor.h>
141 #include <vtkUnstructuredGrid.h>
143 #include "utilities.h"
145 #include "SALOMEDS_Study.hxx"
146 #include "SALOMEDSClient_StudyBuilder.hxx"
147 #include "SALOMEDSClient_SComponent.hxx"
153 //=============================================================
154 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
157 void ExportMeshToFile(int theCommandID);
159 void SetDisplayMode(int theCommandID);
161 void SetDisplayEntity(int theCommandID);
163 void Control( int theCommandID );
167 //=============================================================
168 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
174 if(theCommandID == 113){
175 filter.append(QObject::tr("MED files (*.med)"));
176 filter.append(QObject::tr("All files (*)"));
177 }else if (theCommandID == 112){
178 filter.append(QObject::tr("IDEAS files (*.unv)"));
179 }else if (theCommandID == 111){
180 filter.append(QObject::tr("DAT files (*.dat)"));
182 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
185 QObject::tr("Import mesh"),
187 if(!filename.isEmpty()) {
188 SUIT_OverrideCursor wc;
189 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
192 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 aMeshes->length( 1 );
197 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
202 SMESH::DriverMED_ReadStatus res;
203 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
204 if ( res != SMESH::DRS_OK ) {
206 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
207 QObject::tr("SMESH_WRN_WARNING"),
208 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
209 QObject::tr("SMESH_BUT_OK"));
210 aMeshes->length( 0 );
217 bool isEmpty = false;
218 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
219 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
221 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
222 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
223 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
224 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
225 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
232 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
233 QObject::tr("SMESH_WRN_WARNING"),
234 QObject::tr("SMESH_DRS_EMPTY"),
235 QObject::tr("SMESH_BUT_OK"));
239 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
241 catch (const SALOME::SALOME_Exception& S_ex){
243 SalomeApp_Tools::QtCatchCorbaException(S_ex);
250 void ExportMeshToFile( int theCommandID )
252 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
253 SALOME_ListIO selected;
255 aSel->selectedObjects( selected );
257 if(selected.Extent()){
258 Handle(SALOME_InteractiveObject) anIObject = selected.First();
259 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
260 if ( !aMesh->_is_nil() ) {
261 QString aFilter, aTitle = QObject::tr("Export mesh");
262 QMap<QString, SMESH::MED_VERSION> aFilterMap;
263 QMap<QString, int> aFilterMapSTL;
264 switch ( theCommandID ) {
268 if (aMesh->HasDuplicatedGroupNamesMED()) {
269 int aRet = SUIT_MessageBox::warn2
270 (SMESHGUI::desktop(),
271 QObject::tr("SMESH_WRN_WARNING"),
272 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
273 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
279 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
280 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
285 aFilter = QObject::tr("DAT files (*.dat)");
290 if (aMesh->NbPyramids()) {
291 int aRet = SUIT_MessageBox::warn2
292 (SMESHGUI::desktop(),
293 QObject::tr("SMESH_WRN_WARNING"),
294 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
295 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
300 aFilter = QObject::tr("IDEAS files (*.unv)");
308 there must be check on others mesh elements not equal triangles
310 if (aMesh->NbTriangles() < 1) {
311 int aRet = SUIT_MessageBox::warn1
312 (SMESHGUI::desktop(),
313 QObject::tr("SMESH_WRN_WARNING"),
314 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
315 QObject::tr("SMESH_BUT_OK"));
318 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
319 int aRet = SUIT_MessageBox::warn2
320 (SMESHGUI::desktop(),
321 QObject::tr("SMESH_WRN_WARNING"),
322 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
323 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
329 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
330 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
338 SMESH::MED_VERSION aFormat;
339 // Init the parameter with the default value
340 bool aIsASCII_STL = true;
341 bool toCreateGroups = false;
342 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
344 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
346 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
348 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
350 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
352 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
353 for ( ; it != aFilterMapSTL.end(); ++it )
354 filters.push_back( it.key() );
356 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
357 fd->setCaption( aTitle );
358 fd->setFilters( filters );
359 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
363 aFilename = fd->selectedFile();
364 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
371 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
372 for ( ; it != aFilterMap.end(); ++it )
373 filters.push_back( it.key() );
375 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
376 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
377 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
378 fd->setCaption( aTitle );
379 fd->setFilters( filters );
380 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
381 fd->SetChecked(toCreateGroups);
385 aFilename = fd->selectedFile();
386 aFormat = aFilterMap[fd->selectedFilter()];
388 if ( !aFilename.isEmpty()
389 && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
390 && aFormat==SMESH::MED_V2_1) {
391 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
392 QObject::tr("SMESH_WRN_WARNING"),
393 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
394 QObject::tr("SMESH_BUT_YES"),
395 QObject::tr("SMESH_BUT_NO"),
402 toCreateGroups = fd->IsChecked();
405 if ( !aFilename.isEmpty() ) {
406 // Check whether the file already exists and delete it if yes
407 QFile aFile( aFilename );
408 if ( aFile.exists() )
410 SUIT_OverrideCursor wc;
413 bool Renumber = false ;
414 // PAL 14172 : Check of we have to renumber or not from the preferences before export
416 Renumber= resMgr->booleanValue("SMESH","renumbering");
418 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
419 aMeshEditor->RenumberNodes();
420 aMeshEditor->RenumberElements();
421 if ( SMESHGUI::automaticUpdate() )
424 switch ( theCommandID ) {
427 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
431 aMesh->ExportDAT( aFilename.latin1() );
435 aMesh->ExportUNV( aFilename.latin1() );
439 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
445 catch (const SALOME::SALOME_Exception& S_ex){
447 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
448 QObject::tr("SMESH_WRN_WARNING"),
449 QObject::tr("SMESH_EXPORT_FAILED"),
450 QObject::tr("SMESH_BUT_OK"));
458 inline void InverseEntityMode(unsigned int& theOutputMode,
459 unsigned int theMode)
461 bool anIsNotPresent = ~theOutputMode & theMode;
463 theOutputMode |= theMode;
465 theOutputMode &= ~theMode;
468 void SetDisplayEntity(int theCommandID){
469 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
470 SALOME_ListIO selected;
472 aSel->selectedObjects( selected );
474 if(selected.Extent() >= 1){
475 SALOME_ListIteratorOfListIO It( selected );
476 for(; It.More(); It.Next()){
477 Handle(SALOME_InteractiveObject) IObject = It.Value();
478 if(IObject->hasEntry()){
479 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
480 unsigned int aMode = anActor->GetEntityMode();
481 switch(theCommandID){
483 InverseEntityMode(aMode,SMESH_Actor::eEdges);
486 InverseEntityMode(aMode,SMESH_Actor::eFaces);
489 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
492 aMode = SMESH_Actor::eAllEntity;
496 anActor->SetEntityMode(aMode);
503 void SetDisplayMode(int theCommandID){
504 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
505 SALOME_ListIO selected;
507 aSel->selectedObjects( selected );
509 if(selected.Extent() >= 1){
510 switch(theCommandID){
512 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
513 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
517 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
518 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
521 SALOME_ListIteratorOfListIO It( selected );
522 for(; It.More(); It.Next()){
523 Handle(SALOME_InteractiveObject) IObject = It.Value();
524 if(IObject->hasEntry()){
525 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
526 switch(theCommandID){
528 anActor->SetRepresentation(SMESH_Actor::eEdge);
531 anActor->SetRepresentation(SMESH_Actor::eSurface);
534 if(anActor->IsShrunk())
537 anActor->SetShrink();
540 anActor->SetRepresentation(SMESH_Actor::ePoint);
543 vtkFloatingPointType color[3];
544 anActor->GetSufaceColor(color[0], color[1], color[2]);
545 int c0 = int (color[0] * 255);
546 int c1 = int (color[1] * 255);
547 int c2 = int (color[2] * 255);
548 QColor c(c0, c1, c2);
550 vtkFloatingPointType edgecolor[3];
551 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
552 c0 = int (edgecolor[0] * 255);
553 c1 = int (edgecolor[1] * 255);
554 c2 = int (edgecolor[2] * 255);
555 QColor e(c0, c1, c2);
557 vtkFloatingPointType backfacecolor[3];
558 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
559 c0 = int (backfacecolor[0] * 255);
560 c1 = int (backfacecolor[1] * 255);
561 c2 = int (backfacecolor[2] * 255);
562 QColor b(c0, c1, c2);
564 vtkFloatingPointType nodecolor[3];
565 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
566 c0 = int (nodecolor[0] * 255);
567 c1 = int (nodecolor[1] * 255);
568 c2 = int (nodecolor[2] * 255);
569 QColor n(c0, c1, c2);
571 int Edgewidth = (int)anActor->GetLineWidth();
574 int intValue = int(anActor->GetNodeSize());
575 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
577 SMESHGUI_Preferences_ColorDlg *aDlg =
578 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
579 aDlg->SetColor(1, c);
580 aDlg->SetColor(2, e);
581 aDlg->SetColor(3, n);
582 aDlg->SetColor(4, b);
583 aDlg->SetIntValue(1, Edgewidth);
584 aDlg->SetIntValue(2, intValue);
585 aDlg->SetIntValue(3, int(Shrink*100.));
587 QColor color = aDlg->GetColor(1);
588 QColor edgecolor = aDlg->GetColor(2);
589 QColor nodecolor = aDlg->GetColor(3);
590 QColor backfacecolor = aDlg->GetColor(4);
591 /* actor color and backface color */
592 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
593 vtkFloatingPointType (color.green()) / 255.,
594 vtkFloatingPointType (color.blue()) / 255.);
595 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
596 vtkFloatingPointType (backfacecolor.green()) / 255.,
597 vtkFloatingPointType (backfacecolor.blue()) / 255.);
600 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
601 vtkFloatingPointType (edgecolor.green()) / 255.,
602 vtkFloatingPointType (edgecolor.blue()) / 255.);
604 /* Shrink factor and size edges */
605 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
606 anActor->SetLineWidth(aDlg->GetIntValue(1));
608 /* Nodes color and size */
609 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
610 vtkFloatingPointType (nodecolor.green()) / 255.,
611 vtkFloatingPointType (nodecolor.blue()) / 255.);
612 anActor->SetNodeSize(aDlg->GetIntValue(2));
621 SMESH::RepaintCurrentView();
625 void Control( int theCommandID )
627 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
628 SALOME_ListIO selected;
630 aSel->selectedObjects( selected );
632 if( !selected.IsEmpty() ){
633 Handle(SALOME_InteractiveObject) anIO = selected.First();
636 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
637 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
638 switch ( theCommandID ){
640 aTitle = QObject::tr( "LENGTH_EDGES" );
641 aControl = SMESH_Actor::eLength;
644 aTitle = QObject::tr( "LENGTH2D_EDGES" );
645 aControl = SMESH_Actor::eLength2D;
648 aTitle = QObject::tr( "FREE_EDGES" );
649 aControl = SMESH_Actor::eFreeEdges;
652 aTitle = QObject::tr( "FREE_BORDERS" );
653 aControl = SMESH_Actor::eFreeBorders;
656 aTitle = QObject::tr( "MULTI_BORDERS" );
657 aControl = SMESH_Actor::eMultiConnection;
660 aTitle = QObject::tr( "MULTI2D_BORDERS" );
661 aControl = SMESH_Actor::eMultiConnection2D;
664 aTitle = QObject::tr( "AREA_ELEMENTS" );
665 aControl = SMESH_Actor::eArea;
668 aTitle = QObject::tr( "TAPER_ELEMENTS" );
669 aControl = SMESH_Actor::eTaper;
672 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
673 aControl = SMESH_Actor::eAspectRatio;
676 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
677 aControl = SMESH_Actor::eAspectRatio3D;
680 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
681 aControl = SMESH_Actor::eMinimumAngle;
684 aTitle = QObject::tr( "WARP_ELEMENTS" );
685 aControl = SMESH_Actor::eWarping;
688 aTitle = QObject::tr( "SKEW_ELEMENTS" );
689 aControl = SMESH_Actor::eSkew;
692 aTitle = QObject::tr( "SMESH_VOLUME" );
693 aControl = SMESH_Actor::eVolume3D;
696 anActor->SetControlMode(aControl);
697 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
698 SMESH::RepaintCurrentView();
705 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
706 MeshObjectType theType,
707 const QString theInTypeName,
708 QString & theOutTypeName)
710 SMESH_TypeFilter aTypeFilter( theType );
712 if( !theIO.IsNull() )
714 entry = theIO->getEntry();
715 LightApp_DataOwner owner( entry );
716 if ( aTypeFilter.isOk( &owner )) {
717 theOutTypeName = theInTypeName;
725 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
727 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
728 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
730 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
731 CORBA::String_var anID = aSComp->GetID().c_str();
732 if (!strcmp(anID.in(),theIO->getEntry()))
738 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
739 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
740 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
741 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
742 CheckOIType ( theIO, GROUP, "Group", aTypeName )
750 QString CheckHomogeneousSelection()
752 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
753 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
754 SALOME_ListIO selected;
756 aSel->selectedObjects( selected );
758 QString RefType = CheckTypeObject(selected.First());
759 SALOME_ListIteratorOfListIO It(selected);
760 for (; It.More(); It.Next())
762 Handle(SALOME_InteractiveObject) IObject = It.Value();
763 QString Type = CheckTypeObject(IObject);
764 if (Type.compare(RefType) != 0)
765 return "Heterogeneous Selection";
772 void SMESHGUI::OnEditDelete()
774 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
775 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
776 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
778 QString aParentComponent = QString::null;
779 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
781 QString cur = anIt.Value()->getComponentDataType();
782 if( aParentComponent.isNull() )
783 aParentComponent = cur;
784 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
785 aParentComponent = "";
788 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
789 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
790 QObject::tr("ERR_ERROR"),
791 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
792 QObject::tr("BUT_OK") );
795 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
796 if (SUIT_MessageBox::warn2
797 (SMESHGUI::desktop(),
798 QObject::tr("SMESH_WRN_WARNING"),
799 QObject::tr("SMESH_REALLY_DELETE"),
800 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
803 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
804 SUIT_ViewManager* vm = anApp->activeViewManager();
805 int nbSf = vm->getViewsCount();
807 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
808 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
809 _PTR(GenericAttribute) anAttr;
810 _PTR(AttributeIOR) anIOR;
812 SALOME_ListIteratorOfListIO It(selected);
814 aStudyBuilder->NewCommand(); // There is a transaction
815 for(; It.More(); It.Next()){ // loop on selected IO's
816 Handle(SALOME_InteractiveObject) IObject = It.Value();
817 if(IObject->hasEntry()) {
818 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
820 // disable removal of "SMESH" component object
821 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
823 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
827 // put the whole hierarchy of sub-objects of the selected SO into a list and
828 // then treat them all starting from the deepest objects (at list back)
830 list< _PTR(SObject) > listSO;
831 listSO.push_back( aSO );
832 list< _PTR(SObject) >::iterator itSO = listSO.begin();
833 for ( ; itSO != listSO.end(); ++itSO ) {
834 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
835 for (it->InitEx(false); it->More(); it->Next())
836 listSO.push_back( it->Value() );
839 // treat SO's in the list starting from the back
841 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
842 for ( ; ritSO != listSO.rend(); ++ritSO ) {
843 _PTR(SObject) SO = *ritSO;
845 string anEntry = SO->GetID();
847 /** Erase graphical object **/
848 if(SO->FindAttribute(anAttr, "AttributeIOR")){
849 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
850 for(int i = 0; i < nbSf; i++){
851 SUIT_ViewWindow *sf = aViews[i];
852 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
853 SMESH::RemoveActor(sf,anActor);
858 /** Remove an object from data structures **/
859 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
860 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
861 if ( !aGroup->_is_nil() ) { // DELETE GROUP
862 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
863 aMesh->RemoveGroup( aGroup );
865 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
866 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
867 aMesh->RemoveSubMesh( aSubMesh );
869 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
871 SMESH::ModifiedMesh(aMeshSO, false);
874 IObject = new SALOME_InteractiveObject
875 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
876 QString objType = CheckTypeObject(IObject);
877 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
878 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
879 aStudyBuilder->RemoveObjectWithChildren( SO );
881 else {// default action: remove SObject from the study
882 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
883 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
885 aStudyBuilder->RemoveObjectWithChildren( SO );
889 } /* listSO back loop */
890 } /* IObject->hasEntry() */
892 aStudyBuilder->CommitCommand();
894 /* Clear any previous selection */
896 aSel->setSelectedObjects( l1 );
898 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
903 Standard_EXPORT CAM_Module* createModule()
905 return new SMESHGUI();
909 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
911 //=============================================================================
915 //=============================================================================
916 SMESHGUI::SMESHGUI() :
917 SalomeApp_Module( "SMESH" )
919 if ( CORBA::is_nil( myComponentSMESH ) )
921 CORBA::Boolean anIsEmbeddedMode;
922 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
925 myActiveDialogBox = 0;
926 myFilterLibraryDlg = 0;
930 SMESH::GetFilterManager();
933 /* load resources for all available meshers */
934 SMESH::InitAvailableHypotheses();
937 //=============================================================================
941 //=============================================================================
942 SMESHGUI::~SMESHGUI()
944 SMESH::GetFilterManager()->Destroy();
945 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
948 //=============================================================================
952 //=============================================================================
953 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
955 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
957 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
962 bool SMESHGUI::automaticUpdate()
964 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
968 return resMgr->booleanValue( "SMESH", "auto_update", false );
971 //=============================================================================
975 //=============================================================================
976 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
978 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
981 //=============================================================================
985 //=============================================================================
986 SMESHGUI* SMESHGUI::GetSMESHGUI()
988 SMESHGUI* smeshMod = 0;
989 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
992 CAM_Module* module = app->module( "Mesh" );
993 smeshMod = dynamic_cast<SMESHGUI*>( module );
996 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
998 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1001 _PTR(Study) aStudy = study->studyDS();
1003 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1012 Standard_EXPORT SMESHGUI* GetComponentGUI()
1014 return SMESHGUI::GetSMESHGUI();
1018 //=============================================================================
1022 //=============================================================================
1023 void SMESHGUI::SetState(int aState)
1028 //=============================================================================
1032 //=============================================================================
1033 void SMESHGUI::ResetState()
1038 //=============================================================================
1042 //=============================================================================
1043 void SMESHGUI::EmitSignalDeactivateDialog()
1045 emit SignalDeactivateActiveDialog();
1048 //=============================================================================
1052 //=============================================================================
1053 void SMESHGUI::EmitSignalStudyFrameChanged()
1055 emit SignalStudyFrameChanged();
1058 //=============================================================================
1062 //=============================================================================
1063 void SMESHGUI::EmitSignalCloseAllDialogs()
1065 emit SignalCloseAllDialogs();
1068 //=============================================================================
1072 //=============================================================================
1073 QDialog *SMESHGUI::GetActiveDialogBox()
1075 return myActiveDialogBox;
1078 //=============================================================================
1082 //=============================================================================
1083 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1085 myActiveDialogBox = (QDialog *) aDlg;
1089 //=============================================================================
1093 //=============================================================================
1094 SUIT_Desktop* SMESHGUI::desktop()
1096 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1098 return app->desktop();
1103 //=============================================================================
1107 //=============================================================================
1108 SalomeApp_Study* SMESHGUI::activeStudy()
1110 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1112 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1117 //=============================================================================
1121 //=============================================================================
1122 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1124 /* Here the position is on the bottom right corner - 10 */
1125 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1127 SUIT_Desktop *PP = desktop();
1128 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1129 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1133 //=============================================================================
1137 //=============================================================================
1138 static int isStudyLocked(_PTR(Study) theStudy){
1139 return theStudy->GetProperties()->IsLocked();
1142 static bool checkLock(_PTR(Study) theStudy) {
1143 if (isStudyLocked(theStudy)) {
1144 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1145 QObject::tr("WRN_WARNING"),
1146 QObject::tr("WRN_STUDY_LOCKED"),
1147 QObject::tr("BUT_OK") );
1153 //=======================================================================
1154 //function : CheckActiveStudyLocked
1156 //=======================================================================
1158 bool SMESHGUI::isActiveStudyLocked()
1160 _PTR(Study) aStudy = activeStudy()->studyDS();
1161 return checkLock( aStudy );
1164 //=============================================================================
1168 //=============================================================================
1169 bool SMESHGUI::OnGUIEvent( int theCommandID )
1171 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1175 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1176 SUIT_ResourceMgr* mgr = resourceMgr();
1180 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1181 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1184 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1185 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1187 //QAction* act = action( theCommandID );
1189 switch (theCommandID) {
1191 if(checkLock(aStudy)) break;
1199 if(checkLock(aStudy)) break;
1200 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1204 case 122: // EXPORT MED
1213 ::ExportMeshToFile(theCommandID);
1217 case 200: // SCALAR BAR
1219 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1220 SALOME_ListIO selected;
1222 aSel->selectedObjects( selected );
1224 if( selected.Extent() ) {
1225 Handle(SALOME_InteractiveObject) anIO = selected.First();
1226 if( anIO->hasEntry() ) {
1227 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1228 anActor->SetControlMode( SMESH_Actor::eNone );
1236 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1240 case 1134: // Clipping
1241 case 1133: // Tranparency
1242 case 1132: // Colors / Size
1249 ::SetDisplayMode(theCommandID);
1255 case 219: // Volumes
1256 case 220: // All Entity
1257 ::SetDisplayEntity(theCommandID);
1262 if(checkLock(aStudy)) break;
1263 SMESH::UpdateView();
1266 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1267 aSel->selectedObjects( l );
1268 aSel->setSelectedObjects( l );
1273 case 301: // DISPLAY
1274 case 302: // DISPLAY ONLY
1276 SMESH::EDisplaing anAction;
1277 switch (theCommandID) {
1278 case 300: anAction = SMESH::eErase; break;
1279 case 301: anAction = SMESH::eDisplay; break;
1280 case 302: anAction = SMESH::eDisplayOnly; break;
1283 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1284 SALOME_ListIO sel_objects, to_process;
1286 aSel->selectedObjects( sel_objects );
1288 if( theCommandID==302 )
1289 startOperation( myEraseAll );
1291 extractContainers( sel_objects, to_process );
1294 SALOME_ListIteratorOfListIO It( to_process );
1295 for (; It.More(); It.Next()) {
1296 Handle(SALOME_InteractiveObject) IOS = It.Value();
1297 if (IOS->hasEntry()) {
1298 SMESH::UpdateView(anAction, IOS->getEntry());
1299 if (anAction == SMESH::eDisplayOnly)
1300 anAction = SMESH::eDisplay;
1305 // PAL13338 + PAL15161 -->
1306 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) /*&& !automaticUpdate()*/ )
1307 SMESH::UpdateView();
1308 // PAL13338 + PAL15161 <--
1310 if (anAction == SMESH::eErase) {
1312 aSel->setSelectedObjects( l1 );
1315 aSel->setSelectedObjects( to_process );
1322 if(checkLock(aStudy)) break;
1325 EmitSignalDeactivateDialog();
1327 new SMESHGUI_NodesDlg(this);
1330 SUIT_MessageBox::warn1(desktop(),
1331 tr("SMESH_WRN_WARNING"),
1332 tr("SMESH_WRN_VIEWER_VTK"),
1333 tr("SMESH_BUT_OK"));
1338 case 2151: // FILTER
1342 EmitSignalDeactivateDialog();
1343 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1348 case 406: // MOVE NODE
1352 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1353 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1357 if(checkLock(aStudy)) break;
1358 new SMESHGUI_MoveNodesDlg(this);
1362 case 701: // COMPUTE MESH
1364 if (checkLock(aStudy)) break;
1366 LightApp_SelectionMgr *Sel = selectionMgr();
1367 SALOME_ListIO selected; Sel->selectedObjects( selected );
1369 int nbSel = selected.Extent();
1371 SUIT_MessageBox::warn1(desktop(),
1372 tr("SMESH_WRN_WARNING"),
1373 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1374 tr("SMESH_BUT_OK"));
1378 SMESH::SMESH_Mesh_var aMesh;
1379 SMESH::SMESH_subMesh_var aSubMesh;
1380 Handle(SALOME_InteractiveObject) IObject = selected.First();
1381 if (IObject->hasEntry()) {
1382 _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1383 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1384 if ( aShapeObject->_is_nil() ) {
1389 aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1390 aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1391 if ( !aSubMesh->_is_nil() )
1392 aMesh = aSubMesh->GetFather();
1394 if (!aMesh->_is_nil()) {
1395 SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1396 if ( errors->length() > 0 ) {
1397 SUIT_MessageBox::warn1(desktop(),
1398 tr("SMESH_WRN_WARNING"),
1399 SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1400 tr("SMESH_BUT_OK"));
1405 if (GetSMESHGen()->Compute(aMesh, aShapeObject))
1406 SMESH::ModifiedMesh(aMeshSObj, true);
1408 SUIT_MessageBox::warn1(desktop(),
1409 tr("SMESH_WRN_WARNING"),
1410 tr("SMESH_WRN_COMPUTE_FAILED"),
1411 tr("SMESH_BUT_OK"));
1413 catch(const SALOME::SALOME_Exception & S_ex){
1414 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1419 if (automaticUpdate()) {
1420 SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
1422 CORBA::Long anId = aStudy->StudyId();
1423 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
1425 aVisualObj->Update();
1426 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1428 anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
1430 SMESH::DisplayActor(aVTKView, anActor); //apo
1434 SMESH::RepaintCurrentView();
1435 Sel->setSelectedObjects( selected );
1445 case 702: // Create mesh
1446 startOperation( 702 );
1448 case 703: // Create sub-mesh
1449 startOperation( 703 );
1451 case 704: // Edit mesh/sub-mesh
1452 startOperation( 704 );
1454 case 710: // Build compound mesh
1456 if (checkLock(aStudy)) break;
1457 EmitSignalDeactivateDialog();
1458 new SMESHGUI_BuildCompoundDlg( this );
1461 case 407: // DIAGONAL INVERSION
1462 case 408: // Delete diagonal
1466 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1467 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1471 if ( checkLock( aStudy ) )
1474 /*Standard_Boolean aRes;
1475 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1476 if ( aMesh->_is_nil() )
1478 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1479 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1483 EmitSignalDeactivateDialog();
1484 if ( theCommandID == 407 )
1485 new SMESHGUI_TrianglesInversionDlg(this);
1487 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1490 case 409: // Change orientation
1491 case 410: // Union of triangles
1492 case 411: // Cutting of quadrangles
1496 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1497 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1501 if ( checkLock( aStudy ) )
1504 EmitSignalDeactivateDialog();
1505 SMESHGUI_MultiEditDlg* aDlg = NULL;
1506 if ( theCommandID == 409 )
1507 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1508 else if ( theCommandID == 410 )
1509 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1511 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1516 case 412: // Smoothing
1518 if(checkLock(aStudy)) break;
1520 EmitSignalDeactivateDialog();
1521 new SMESHGUI_SmoothingDlg( this );
1524 SUIT_MessageBox::warn1(desktop(),
1525 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1526 tr("SMESH_BUT_OK"));
1530 case 413: // Extrusion
1532 if (checkLock(aStudy)) break;
1534 EmitSignalDeactivateDialog();
1535 new SMESHGUI_ExtrusionDlg ( this );
1537 SUIT_MessageBox::warn1(desktop(),
1538 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1539 tr("SMESH_BUT_OK"));
1543 case 414: // Revolution
1545 if(checkLock(aStudy)) break;
1547 EmitSignalDeactivateDialog();
1548 new SMESHGUI_RevolutionDlg( this );
1551 SUIT_MessageBox::warn1(desktop(),
1552 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1553 tr("SMESH_BUT_OK"));
1557 case 415: // Pattern mapping
1559 if ( checkLock( aStudy ) )
1563 EmitSignalDeactivateDialog();
1564 new SMESHGUI_MeshPatternDlg( this );
1567 SUIT_MessageBox::warn1(desktop(),
1568 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1569 tr("SMESH_BUT_OK"));
1573 case 416: // Extrusion along a path
1575 if (checkLock(aStudy)) break;
1577 EmitSignalDeactivateDialog();
1578 new SMESHGUI_ExtrusionAlongPathDlg( this );
1580 SUIT_MessageBox::warn1(desktop(),
1581 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1582 tr("SMESH_BUT_OK"));
1586 case 417: // Convert mesh to quadratic
1588 startOperation( 417 );
1589 /* if (checkLock(aStudy)) break;
1591 EmitSignalDeactivateDialog();
1592 new SMESHGUI_ConvToQuadDlg();
1594 SUIT_MessageBox::warn1(desktop(),
1595 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1596 tr("SMESH_BUT_OK"));
1600 case 801: // CREATE GROUP
1604 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1605 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1609 if(checkLock(aStudy)) break;
1610 EmitSignalDeactivateDialog();
1611 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1613 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1614 SALOME_ListIO selected;
1616 aSel->selectedObjects( selected );
1618 int nbSel = selected.Extent();
1620 // check if mesh is selected
1621 aMesh = SMESH::GetMeshByIO( selected.First() );
1623 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1628 case 802: // CONSTRUCT GROUP
1632 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1633 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1637 if(checkLock(aStudy)) break;
1638 EmitSignalDeactivateDialog();
1640 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1641 SALOME_ListIO selected;
1643 aSel->selectedObjects( selected );
1645 int nbSel = selected.Extent();
1647 // check if submesh is selected
1648 Handle(SALOME_InteractiveObject) IObject = selected.First();
1649 if (IObject->hasEntry()) {
1650 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1652 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1653 if (!aSubMesh->_is_nil()) {
1655 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1656 // get submesh elements list by types
1657 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1658 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1659 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1660 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1661 // create group for each type o elements
1662 QString aName = IObject->getName();
1663 if (aNodes->length() > 0) {
1664 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1665 aGroup->Add(aNodes.inout());
1667 if (aEdges->length() > 0) {
1668 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1669 aGroup->Add(aEdges.inout());
1671 if (aFaces->length() > 0) {
1672 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1673 aGroup->Add(aFaces.inout());
1675 if (aVolumes->length() > 0) {
1676 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1677 aGroup->Add(aVolumes.inout());
1682 catch(const SALOME::SALOME_Exception & S_ex){
1683 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1690 SUIT_MessageBox::warn1(desktop(),
1691 tr("SMESH_WRN_WARNING"),
1692 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1693 tr("SMESH_BUT_OK"));
1698 case 803: // EDIT GROUP
1702 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1703 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1707 if(checkLock(aStudy)) break;
1708 EmitSignalDeactivateDialog();
1710 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1711 SALOME_ListIO selected;
1713 aSel->selectedObjects( selected );
1715 SALOME_ListIteratorOfListIO It (selected);
1716 int nbSelectedGroups = 0;
1717 for ( ; It.More(); It.Next() )
1719 SMESH::SMESH_GroupBase_var aGroup =
1720 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1721 if (!aGroup->_is_nil()) {
1723 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1727 if (nbSelectedGroups == 0)
1729 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1735 case 804: // Add elements to group
1737 if(checkLock(aStudy)) break;
1738 if (myState == 800) {
1739 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1740 if (aDlg) aDlg->onAdd();
1745 case 805: // Remove elements from group
1747 if(checkLock(aStudy)) break;
1748 if (myState == 800) {
1749 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1750 if (aDlg) aDlg->onRemove();
1755 case 810: // Union Groups
1756 case 811: // Intersect groups
1757 case 812: // Cut groups
1761 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1762 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1766 if ( checkLock( aStudy ) )
1769 EmitSignalDeactivateDialog();
1772 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1773 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1774 else aMode = SMESHGUI_GroupOpDlg::CUT;
1776 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1780 case 813: // Delete groups with their contents
1784 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1785 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1789 if ( checkLock( aStudy ) )
1792 EmitSignalDeactivateDialog();
1794 new SMESHGUI_DeleteGroupDlg( this );
1798 case 900: // MESH INFOS
1800 EmitSignalDeactivateDialog();
1801 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1802 SALOME_ListIO selected;
1804 aSel->selectedObjects( selected );
1806 if ( selected.Extent() > 1 ) { // a dlg for each IO
1808 SALOME_ListIteratorOfListIO It (selected);
1809 for ( ; It.More(); It.Next() ) {
1810 IOs.Clear(); IOs.Append( It.Value() );
1811 aSel->setSelectedObjects( IOs );
1812 new SMESHGUI_MeshInfosDlg(this, "", false);
1814 // restore selection
1815 aSel->setSelectedObjects( selected );
1818 new SMESHGUI_MeshInfosDlg(this, "", false);
1822 case 902: // STANDARD MESH INFOS
1824 EmitSignalDeactivateDialog();
1825 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1826 SALOME_ListIO selected;
1828 aSel->selectedObjects( selected );
1830 if ( selected.Extent() > 1 ) { // a dlg for each IO
1832 SALOME_ListIteratorOfListIO It (selected);
1833 for ( ; It.More(); It.Next() ) {
1835 IOs.Append( It.Value() );
1836 aSel->setSelectedObjects( IOs );
1837 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1839 // restore selection
1840 aSel->setSelectedObjects( selected );
1843 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1847 case 1100: // EDIT HYPOTHESIS
1849 if(checkLock(aStudy)) break;
1851 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1852 SALOME_ListIO selected;
1854 aSel->selectedObjects( selected );
1856 int nbSel = selected.Extent();
1859 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1861 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1862 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1863 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1864 if ( !Hyp->_is_nil() )
1866 char* sName = Hyp->GetName();
1867 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1869 aCreator->edit( Hyp.in(), desktop() );
1876 updateObjBrowser( true );
1880 case 1101: // RENAME
1882 if ( checkLock( aStudy ) )
1885 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1886 SALOME_ListIO selected;
1888 aSel->selectedObjects( selected );
1890 SALOME_ListIteratorOfListIO It( selected );
1891 for ( ; It.More(); It.Next() )
1893 Handle(SALOME_InteractiveObject) IObject = It.Value();
1894 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1895 _PTR(GenericAttribute) anAttr;
1896 _PTR(AttributeName) aName;
1899 if ( obj->FindAttribute(anAttr, "AttributeName") )
1902 QString newName = QString(aName->Value().c_str());
1903 newName = LightApp_NameDlg::getName(desktop(), newName);
1904 if ( !newName.isEmpty() )
1906 //old source: aStudy->renameIObject( IObject, newName );
1907 aName->SetValue( newName.latin1() );
1909 // if current object is group update group's name
1910 SMESH::SMESH_GroupBase_var aGroup =
1911 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1912 if (!aGroup->_is_nil() )
1913 aGroup->SetName( newName.latin1() );
1923 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1925 if(checkLock(aStudy)) break;
1926 SUIT_OverrideCursor wc;
1928 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1929 SALOME_ListIO selected;
1931 aSel->selectedObjects( selected, QString::null, false );
1933 SALOME_ListIteratorOfListIO It(selected);
1934 for (int i = 0; It.More(); It.Next(), i++) {
1935 Handle(SALOME_InteractiveObject) IObject = It.Value();
1936 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1939 aSel->setSelectedObjects( l1 );
1944 case 401: // GEOM::EDGE
1945 case 4021: // TRIANGLE
1947 case 4023: // POLYGON
1951 if(checkLock(aStudy)) break;
1953 EmitSignalDeactivateDialog();
1954 SMDSAbs_ElementType type = SMDSAbs_Edge;
1956 switch (theCommandID) {
1957 case 4021: // TRIANGLE
1958 type = SMDSAbs_Face; nbNodes = 3; break;
1960 type = SMDSAbs_Face; nbNodes = 4; break;
1962 type = SMDSAbs_Volume; nbNodes = 4; break;
1963 case 4023: // POLYGON
1964 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1966 type = SMDSAbs_Volume; nbNodes = 8; break;
1967 case 4033: // POLYHEDRE
1968 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1971 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1974 SUIT_MessageBox::warn1(desktop(),
1975 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1976 tr("SMESH_BUT_OK"));
1980 case 4033: // POLYHEDRON
1982 if(checkLock(aStudy)) break;
1984 EmitSignalDeactivateDialog();
1985 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1988 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1989 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1990 tr("SMESH_BUT_OK"));
1994 case 4034: // QUADRATIC EDGE
1995 case 4035: // QUADRATIC TRIANGLE
1996 case 4036: // QUADRATIC QUADRANGLE
1997 case 4037: // QUADRATIC TETRAHEDRON
1998 case 4038: // QUADRATIC PYRAMID
1999 case 4039: // QUADRATIC PENTAHEDRON
2000 case 4040: // QUADRATIC HEXAHEDRON
2002 if(checkLock(aStudy)) break;
2004 EmitSignalDeactivateDialog();
2007 switch (theCommandID) {
2009 type = QUAD_EDGE; break;
2011 type = QUAD_TRIANGLE; break;
2013 type = QUAD_QUADRANGLE; break;
2015 type = QUAD_TETRAHEDRON; break;
2017 type = QUAD_PYRAMID; break;
2019 type = QUAD_PENTAHEDRON; break;
2021 type = QUAD_HEXAHEDRON;
2025 new SMESHGUI_AddQuadraticElementDlg( this, type );
2028 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2029 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2030 tr("SMESH_BUT_OK"));
2034 case 4041: // REMOVES NODES
2036 if(checkLock(aStudy)) break;
2038 EmitSignalDeactivateDialog();
2039 new SMESHGUI_RemoveNodesDlg(this);
2042 SUIT_MessageBox::warn1(desktop(),
2043 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2044 tr("SMESH_BUT_OK"));
2048 case 4042: // REMOVES ELEMENTS
2050 if(checkLock(aStudy)) break;
2052 EmitSignalDeactivateDialog();
2053 new SMESHGUI_RemoveElementsDlg(this);
2057 SUIT_MessageBox::warn1(desktop(),
2058 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2059 tr("SMESH_BUT_OK"));
2063 case 4051: // RENUMBERING NODES
2065 if(checkLock(aStudy)) break;
2067 EmitSignalDeactivateDialog();
2068 new SMESHGUI_RenumberingDlg( this, "", 0);
2072 SUIT_MessageBox::warn1(desktop(),
2073 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2074 tr("SMESH_BUT_OK"));
2078 case 4052: // RENUMBERING ELEMENTS
2080 if(checkLock(aStudy)) break;
2082 EmitSignalDeactivateDialog();
2083 new SMESHGUI_RenumberingDlg( this, "", 1);
2087 SUIT_MessageBox::warn1(desktop(),
2088 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2089 tr("SMESH_BUT_OK"));
2093 case 4061: // TRANSLATION
2095 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 new SMESHGUI_TranslationDlg( this );
2101 SUIT_MessageBox::warn1(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2103 tr("SMESH_BUT_OK"));
2107 case 4062: // ROTATION
2109 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 new SMESHGUI_RotationDlg( this );
2115 SUIT_MessageBox::warn1(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2117 tr("SMESH_BUT_OK"));
2121 case 4063: // SYMMETRY
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_SymmetryDlg( this );
2129 SUIT_MessageBox::warn1(desktop(),
2130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2131 tr("SMESH_BUT_OK"));
2135 case 4064: // SEWING
2137 if(checkLock(aStudy)) break;
2139 EmitSignalDeactivateDialog();
2140 new SMESHGUI_SewingDlg( this );
2143 SUIT_MessageBox::warn1(desktop(),
2144 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2145 tr("SMESH_BUT_OK"));
2149 case 4065: // MERGE NODES
2151 if(checkLock(aStudy)) break;
2153 EmitSignalDeactivateDialog();
2154 new SMESHGUI_MergeNodesDlg( this );
2157 SUIT_MessageBox::warn1(desktop(),
2158 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2159 tr("SMESH_BUT_OK"));
2163 case 4066: // MERGE EQUAL ELEMENTS
2165 if (checkLock(aStudy)) break;
2167 EmitSignalDeactivateDialog();
2168 new SMESHGUI_EditMeshDlg(this,
2169 "SMESH_MERGE_ELEMENTS_TITLE",
2170 "ICON_DLG_MERGE_ELEMENTS",
2171 1); // MergeEqualElemets
2173 SUIT_MessageBox::warn1(desktop(),
2174 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2175 tr("SMESH_BUT_OK"));
2180 case 4067: // MAKE MESH PASS THROUGH POINT
2181 startOperation( 4067 );
2184 case 5105: // Library of selection filters
2186 static QValueList<int> aTypes;
2187 if ( aTypes.isEmpty() )
2189 aTypes.append( SMESH::NODE );
2190 aTypes.append( SMESH::EDGE );
2191 aTypes.append( SMESH::FACE );
2192 aTypes.append( SMESH::VOLUME );
2194 if (!myFilterLibraryDlg)
2195 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2196 else if (myFilterLibraryDlg->isHidden())
2197 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2198 myFilterLibraryDlg->raise();
2202 case 6017: // CONTROLS
2218 LightApp_SelectionMgr* mgr = selectionMgr();
2219 SALOME_ListIO selected; mgr->selectedObjects( selected );
2221 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2222 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2224 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2225 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2226 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2227 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2228 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2229 ::Control( theCommandID );
2234 SUIT_MessageBox::warn1(desktop(),
2235 tr( "SMESH_WRN_WARNING" ),
2236 tr( "SMESH_BAD_SELECTION" ),
2237 tr( "SMESH_BUT_OK" ) );
2241 SUIT_MessageBox::warn1(desktop(),
2242 tr( "SMESH_WRN_WARNING" ),
2243 tr( "NOT_A_VTK_VIEWER" ),
2244 tr( "SMESH_BUT_OK" ) );
2249 LightApp_SelectionMgr* mgr = selectionMgr();
2250 SALOME_ListIO selected; mgr->selectedObjects( selected );
2252 SALOME_ListIteratorOfListIO it(selected);
2253 for(; it.More(); it.Next()) {
2254 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2255 if(anIObject->hasEntry()) {
2256 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2257 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2265 LightApp_SelectionMgr* mgr = selectionMgr();
2266 SALOME_ListIO selected; mgr->selectedObjects( selected );
2268 if (selected.Extent() == 1) {
2269 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2270 if(anIObject->hasEntry())
2271 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2272 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2279 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2280 //updateObjBrowser();
2284 //=============================================================================
2288 //=============================================================================
2289 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2294 //=============================================================================
2298 //=============================================================================
2299 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2304 //=============================================================================
2308 //=============================================================================
2309 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2314 //=============================================================================
2315 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2316 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2318 //=============================================================================
2319 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2320 SUIT_ViewWindow* wnd )
2322 if(theIO->hasEntry()){
2323 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2324 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2328 //=======================================================================
2329 // function : createSMESHAction
2331 //=======================================================================
2332 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2335 QWidget* parent = application()->desktop();
2336 SUIT_ResourceMgr* resMgr = resourceMgr();
2338 if ( icon_id.length() )
2339 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2341 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2342 if ( !pix.isNull() )
2343 icon = QIconSet( pix );
2345 QString tooltip = tr( QString( "TOP_" )+po_id ),
2346 menu = tr( QString( "MEN_" )+po_id ),
2347 status_bar = tr( QString( "STB_" )+po_id );
2349 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2352 //=======================================================================
2353 // function : createPopupItem
2355 //=======================================================================
2356 void SMESHGUI::createPopupItem( const int id,
2357 const QString& clients,
2358 const QString& types,
2359 const QString& theRule,
2364 parentId = popupMgr()->actionId( action( pId ) );
2366 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2367 popupMgr()->insert( action( id ), parentId, 0 );
2369 QChar lc = QtxPopupMgr::Selection::defEquality();
2370 QString rule = "(%1) and (%2) and (%3)";
2371 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2372 if( clients.isEmpty() )
2373 rule = rule.arg( QString( "true" ) );
2375 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2376 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2379 bool cont = myRules.contains( id );
2381 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2383 popupMgr()->setRule( action( id ), rule, true );
2384 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2387 //=======================================================================
2388 // function : initialize
2390 //=======================================================================
2391 void SMESHGUI::initialize( CAM_Application* app )
2393 SalomeApp_Module::initialize( app );
2395 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2397 /* Automatic Update flag */
2398 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2400 // ----- create actions --------------
2402 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2403 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2404 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2405 createSMESHAction( 114, "NUM" );
2406 createSMESHAction( 121, "DAT" );
2407 createSMESHAction( 122, "MED" );
2408 createSMESHAction( 123, "UNV" );
2409 createSMESHAction( 140, "STL" );
2410 createSMESHAction( 124, "EXPORT_DAT" );
2411 createSMESHAction( 125, "EXPORT_MED" );
2412 createSMESHAction( 126, "EXPORT_UNV" );
2413 createSMESHAction( 141, "EXPORT_STL" );
2414 createSMESHAction( 33, "DELETE", "ICON_DELETE" );
2415 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2416 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2417 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2418 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2419 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2420 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2421 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2422 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2423 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2424 createSMESHAction( 804, "ADD" );
2425 createSMESHAction( 805, "REMOVE" );
2426 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2427 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2428 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2429 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2430 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2431 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2432 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2433 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2434 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2435 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2436 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2437 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2438 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2439 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2440 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2441 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2442 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2443 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2444 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2445 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2446 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2447 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2448 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2449 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2450 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2451 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2452 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2453 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2454 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2455 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2456 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2457 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2458 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2459 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2460 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2461 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2462 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2463 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2464 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2465 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2466 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2467 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2468 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2469 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2470 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2471 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2472 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2473 createSMESHAction( 415, "MAP", "ICON_MAP" );
2474 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2475 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2476 createSMESHAction( 200, "RESET" );
2477 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2478 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2479 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2480 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2481 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2482 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2483 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2484 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2485 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2486 createSMESHAction( 220, "ALL" );
2487 createSMESHAction( 1100, "EDIT_HYPO" );
2488 createSMESHAction( 1101, "RENAME" );
2489 createSMESHAction( 1102, "UNASSIGN" );
2490 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2491 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2492 createSMESHAction( 1131, "DISPMODE" );
2493 createSMESHAction( 1132, "COLORS" );
2494 createSMESHAction( 1133, "TRANSP" );
2495 createSMESHAction( 1134, "CLIP" );
2496 createSMESHAction( 1135, "DISP_ENT" );
2497 createSMESHAction( 2000, "CTRL" );
2499 createSMESHAction( 300, "ERASE" );
2500 createSMESHAction( 301, "DISPLAY" );
2501 createSMESHAction( 302, "DISPLAY_ONLY" );
2502 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2503 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2504 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2505 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2506 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2507 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2508 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2509 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2511 // ----- create menu --------------
2512 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2513 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2514 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2515 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2516 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2517 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2518 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2520 createMenu( separator(), fileId );
2522 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2523 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2524 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2525 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2526 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2527 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2529 createMenu( 111, importId, -1 );
2530 createMenu( 112, importId, -1 );
2531 createMenu( 113, importId, -1 );
2533 createMenu( 121, exportId, -1 );
2534 createMenu( 122, exportId, -1 );
2535 createMenu( 123, exportId, -1 );
2536 createMenu( 140, exportId, -1 ); // export to stl STL
2538 createMenu( separator(), fileId, 10 );
2540 createMenu( 33, editId, -1 );
2542 createMenu( 5105, toolsId, -1 );
2544 createMenu( 702, meshId, -1 );
2545 createMenu( 703, meshId, -1 );
2546 createMenu( 704, meshId, -1 );
2547 createMenu( 710, meshId, -1 );
2548 createMenu( separator(), meshId, -1 );
2549 createMenu( 701, meshId, -1 );
2550 createMenu( separator(), meshId, -1 );
2551 createMenu( 801, meshId, -1 );
2552 createMenu( 802, meshId, -1 );
2553 createMenu( 803, meshId, -1 );
2554 createMenu( separator(), meshId, -1 );
2555 createMenu( 810, meshId, -1 );
2556 createMenu( 811, meshId, -1 );
2557 createMenu( 812, meshId, -1 );
2558 createMenu( separator(), meshId, -1 );
2559 createMenu( 813, meshId, -1 );
2560 createMenu( separator(), meshId, -1 );
2561 createMenu( 900, meshId, -1 );
2562 createMenu( 902, meshId, -1 );
2563 createMenu( separator(), meshId, -1 );
2565 createMenu( 6003, ctrlId, -1 );
2566 createMenu( 6001, ctrlId, -1 );
2567 createMenu( 6004, ctrlId, -1 );
2568 createMenu( separator(), ctrlId, -1 );
2569 createMenu( 6002, ctrlId, -1 );
2570 createMenu( 6018, ctrlId, -1 );
2571 createMenu( 6019, ctrlId, -1 );
2572 createMenu( 6011, ctrlId, -1 );
2573 createMenu( 6012, ctrlId, -1 );
2574 createMenu( 6013, ctrlId, -1 );
2575 createMenu( 6014, ctrlId, -1 );
2576 createMenu( 6015, ctrlId, -1 );
2577 createMenu( 6016, ctrlId, -1 );
2578 createMenu( separator(), ctrlId, -1 );
2579 createMenu( 6017, ctrlId, -1 );
2580 createMenu( 6009, ctrlId, -1 );
2581 createMenu( separator(), ctrlId, -1 );
2583 createMenu( 400, addId, -1 );
2584 createMenu( 401, addId, -1 );
2585 createMenu( 4021, addId, -1 );
2586 createMenu( 4022, addId, -1 );
2587 createMenu( 4023, addId, -1 );
2588 createMenu( 4031, addId, -1 );
2589 createMenu( 4032, addId, -1 );
2590 createMenu( 4033, addId, -1 );
2591 createMenu( separator(), addId, -1 );
2592 createMenu( 4034, addId, -1 );
2593 createMenu( 4035, addId, -1 );
2594 createMenu( 4036, addId, -1 );
2595 createMenu( 4037, addId, -1 );
2596 createMenu( 4038, addId, -1 );
2597 createMenu( 4039, addId, -1 );
2598 createMenu( 4040, addId, -1 );
2600 createMenu( 4041, removeId, -1 );
2601 createMenu( 4042, removeId, -1 );
2603 createMenu( 4051, renumId, -1 );
2604 createMenu( 4052, renumId, -1 );
2606 createMenu( 4061, transfId, -1 );
2607 createMenu( 4062, transfId, -1 );
2608 createMenu( 4063, transfId, -1 );
2609 createMenu( 4064, transfId, -1 );
2610 createMenu( 4065, transfId, -1 );
2611 createMenu( 4066, transfId, -1 );
2613 createMenu( 406, modifyId, -1 );
2614 createMenu( 4067,modifyId, -1 );
2615 createMenu( 407, modifyId, -1 );
2616 createMenu( 408, modifyId, -1 );
2617 createMenu( 409, modifyId, -1 );
2618 createMenu( 410, modifyId, -1 );
2619 createMenu( 411, modifyId, -1 );
2620 createMenu( 412, modifyId, -1 );
2621 createMenu( 413, modifyId, -1 );
2622 createMenu( 416, modifyId, -1 );
2623 createMenu( 414, modifyId, -1 );
2624 createMenu( 415, modifyId, -1 );
2625 createMenu( 417, modifyId, -1 );
2627 createMenu( 214, viewId, -1 );
2629 // ----- create toolbars --------------
2630 int meshTb = createTool( tr( "TB_MESH" ) ),
2631 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2632 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2633 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2634 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2636 createTool( 702, meshTb );
2637 createTool( 703, meshTb );
2638 createTool( 704, meshTb );
2639 createTool( 710, meshTb );
2640 createTool( separator(), meshTb );
2641 createTool( 701, meshTb );
2642 createTool( separator(), meshTb );
2643 createTool( 801, meshTb );
2644 createTool( 802, meshTb );
2645 createTool( 803, meshTb );
2646 createTool( separator(), meshTb );
2647 createTool( 900, meshTb );
2648 createTool( 902, meshTb );
2649 createTool( separator(), meshTb );
2651 createTool( 6001, ctrlTb );
2652 createTool( 6003, ctrlTb );
2653 createTool( 6004, ctrlTb );
2654 createTool( separator(), ctrlTb );
2655 createTool( 6002, ctrlTb );
2656 createTool( 6018, ctrlTb );
2657 createTool( 6019, ctrlTb );
2658 createTool( 6011, ctrlTb );
2659 createTool( 6012, ctrlTb );
2660 createTool( 6013, ctrlTb );
2661 createTool( 6014, ctrlTb );
2662 createTool( 6015, ctrlTb );
2663 createTool( 6016, ctrlTb );
2664 createTool( separator(), ctrlTb );
2665 createTool( 6017, ctrlTb );
2666 createTool( 6009, ctrlTb );
2667 createTool( separator(), ctrlTb );
2669 createTool( 400, addRemTb );
2670 createTool( 401, addRemTb );
2671 createTool( 4021, addRemTb );
2672 createTool( 4022, addRemTb );
2673 createTool( 4023, addRemTb );
2674 createTool( 4031, addRemTb );
2675 createTool( 4032, addRemTb );
2676 createTool( 4033, addRemTb );
2677 createTool( separator(), addRemTb );
2678 createTool( 4034, addRemTb );
2679 createTool( 4035, addRemTb );
2680 createTool( 4036, addRemTb );
2681 createTool( 4037, addRemTb );
2682 createTool( 4038, addRemTb );
2683 createTool( 4039, addRemTb );
2684 createTool( 4040, addRemTb );
2685 createTool( separator(), addRemTb );
2686 createTool( 4041, addRemTb );
2687 createTool( 4042, addRemTb );
2688 createTool( separator(), addRemTb );
2689 createTool( 4051, addRemTb );
2690 createTool( 4052, addRemTb );
2691 createTool( separator(), addRemTb );
2692 createTool( 4061, addRemTb );
2693 createTool( 4062, addRemTb );
2694 createTool( 4063, addRemTb );
2695 createTool( 4064, addRemTb );
2696 createTool( 4065, addRemTb );
2697 createTool( 4066, addRemTb );
2698 createTool( separator(), addRemTb );
2700 createTool( 406, modifyTb );
2701 createTool( 4067,modifyTb );
2702 createTool( 407, modifyTb );
2703 createTool( 408, modifyTb );
2704 createTool( 409, modifyTb );
2705 createTool( 410, modifyTb );
2706 createTool( 411, modifyTb );
2707 createTool( 412, modifyTb );
2708 createTool( 413, modifyTb );
2709 createTool( 416, modifyTb );
2710 createTool( 414, modifyTb );
2711 createTool( 415, modifyTb );
2712 createTool( 417, modifyTb );
2714 createTool( 214, dispModeTb );
2718 QString OB = "'ObjectBrowser'",
2719 View = "'" + SVTK_Viewer::Type() + "'",
2721 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2722 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2723 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2724 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2725 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2726 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2727 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2728 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2729 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2730 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2731 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2733 mesh_group = mesh + " " + subMesh + " " + group,
2734 hyp_alg = hypo + " " + algo;
2736 // popup for object browser
2738 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2739 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2740 createPopupItem( 803, OB, group ); // EDIT_GROUP
2741 popupMgr()->insert( separator(), -1, 0 );
2742 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2743 createPopupItem( 214, OB, mesh_group ); // UPDATE
2744 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2745 createPopupItem( 902, OB, mesh ); // STD_INFO
2746 popupMgr()->insert( separator(), -1, 0 );
2747 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2748 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2749 popupMgr()->insert( separator(), -1, 0 );
2750 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2751 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2752 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2753 popupMgr()->insert( separator(), -1, 0 );
2755 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2756 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2757 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2758 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2759 createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2760 popupMgr()->insert( separator(), -1, 0 );
2763 createPopupItem( 803, View, group ); // EDIT_GROUP
2764 createPopupItem( 804, View, elems ); // ADD
2765 createPopupItem( 805, View, elems ); // REMOVE
2766 popupMgr()->insert( separator(), -1, 0 );
2767 createPopupItem( 214, View, mesh_group ); // UPDATE
2768 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2769 createPopupItem( 902, View, mesh ); // STD_INFO
2770 popupMgr()->insert( separator(), -1, 0 );
2774 isInvisible("not( isVisible )"),
2775 isEmpty("numberOfNodes = 0"),
2776 isNotEmpty("numberOfNodes <> 0"),
2778 // has nodes, edges, etc in VISIBLE! actor
2779 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2780 hasElems("(count( elemTypes ) > 0)"),
2781 hasDifferentElems("(count( elemTypes ) > 1)"),
2782 hasEdges("({'Edge'} in elemTypes)"),
2783 hasFaces("({'Face'} in elemTypes)"),
2784 hasVolumes("({'Volume'} in elemTypes)");
2786 QString lc = QtxPopupMgr::Selection::defEquality();
2787 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2788 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2789 aType = aType.arg( mesh_group );
2790 QString aMeshInVTK = aClient + "&&" + aType;
2792 //-------------------------------------------------
2794 //-------------------------------------------------
2795 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2797 popupMgr()->insert( action( 9010 ), anId, -1 );
2798 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2799 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2801 popupMgr()->insert( action( 9011 ), anId, -1 );
2802 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2803 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2805 popupMgr()->insert( separator(), -1, -1 );
2807 //-------------------------------------------------
2809 //-------------------------------------------------
2810 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2812 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2813 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2814 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2816 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2817 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2818 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2820 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2821 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2822 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2824 popupMgr()->insert( separator(), anId, -1 );
2826 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2827 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2828 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2830 //-------------------------------------------------
2832 //-------------------------------------------------
2833 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2835 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2837 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2838 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2839 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2841 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2842 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2843 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2845 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2846 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2847 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2849 popupMgr()->insert( separator(), anId, -1 );
2851 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2852 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2854 //-------------------------------------------------
2856 //-------------------------------------------------
2857 popupMgr()->insert( action( 1132 ), -1, -1 );
2858 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2860 //-------------------------------------------------
2862 //-------------------------------------------------
2863 popupMgr()->insert( action( 1133 ), -1, -1 );
2864 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2866 //-------------------------------------------------
2868 //-------------------------------------------------
2869 popupMgr()->insert( action( 1134 ), -1, -1 );
2870 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2872 popupMgr()->insert( separator(), -1, -1 );
2874 //-------------------------------------------------
2876 //-------------------------------------------------
2878 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2879 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2880 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2882 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2884 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2885 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2887 popupMgr()->insert( separator(), anId, -1 );
2889 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2890 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2891 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2893 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2894 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2895 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2897 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2898 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2899 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2901 popupMgr()->insert( separator(), anId, -1 );
2903 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2904 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2905 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2907 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2908 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2909 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2911 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2912 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2913 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2915 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2916 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2917 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2919 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2920 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2921 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2923 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2924 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2925 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2927 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2928 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2929 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2931 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2932 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2933 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2935 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2936 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2937 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2939 popupMgr()->insert( separator(), anId, -1 );
2941 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2942 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2943 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2945 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2946 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2947 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2949 popupMgr()->insert( separator(), anId, -1 );
2951 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2952 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2954 popupMgr()->insert( separator(), -1, -1 );
2956 //-------------------------------------------------
2958 //-------------------------------------------------
2959 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2960 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2961 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2963 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2964 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2965 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2966 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2968 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2969 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2971 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2972 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2974 popupMgr()->insert( separator(), -1, -1 );
2976 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2977 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2980 bool SMESHGUI::activateModule( SUIT_Study* study )
2982 bool res = SalomeApp_Module::activateModule( study );
2984 setMenuShown( true );
2985 setToolShown( true );
2987 // Reset actions accelerator keys
2988 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2989 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2990 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2995 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2997 setMenuShown( false );
2998 setToolShown( false );
3000 EmitSignalCloseAllDialogs();
3002 // Unset actions accelerator keys
3003 action(111)->setAccel(QKeySequence()); // Import DAT
3004 action(112)->setAccel(QKeySequence()); // Import UNV
3005 action(113)->setAccel(QKeySequence()); // Import MED
3007 return SalomeApp_Module::deactivateModule( study );
3010 void SMESHGUI::OnGUIEvent()
3012 const QObject* obj = sender();
3013 if ( !obj || !obj->inherits( "QAction" ) )
3015 int id = actionId((QAction*)obj);
3020 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3022 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3023 if ( CORBA::is_nil( myComponentSMESH ) )
3025 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3027 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3028 return aGUI.myComponentSMESH;
3031 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3032 return myComponentSMESH;
3035 QString SMESHGUI::engineIOR() const
3037 CORBA::ORB_var anORB = getApp()->orb();
3038 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3042 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3044 SMESHGUI_Selection sel;
3045 sel.init( client, selectionMgr() );
3046 popupMgr()->updatePopup( menu, &sel );
3049 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3051 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3052 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3055 void SMESHGUI::viewManagers( QStringList& list ) const
3057 list.append( SVTK_Viewer::Type() );
3060 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3062 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3063 SMESH::UpdateSelectionProp( this );
3066 void SMESHGUI::createPreferences()
3068 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3070 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3071 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3073 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3074 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3075 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3077 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3078 setPreferenceProperty( precGroup, "columns", 1 );
3080 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3082 setPreferenceProperty( prec, "min", 0 );
3083 setPreferenceProperty( prec, "max", 16 );
3085 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3086 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3088 modes.append( "Wireframe" );
3089 modes.append( "Shading" );
3090 modes.append( "Nodes" );
3091 modes.append( "Shrink" );
3092 QValueList<QVariant> indices;
3093 indices.append( 0 );
3094 indices.append( 1 );
3095 indices.append( 2 );
3096 indices.append( 3 );
3097 setPreferenceProperty( dispmode, "strings", modes );
3098 setPreferenceProperty( dispmode, "indexes", indices );
3100 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3101 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3102 int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3104 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3105 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3107 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3108 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3110 setPreferenceProperty( nodeSz, "min", 1 );
3111 setPreferenceProperty( nodeSz, "max", 5 );
3113 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3115 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3116 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3117 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3118 addPreference( "", elemGroup, LightApp_Preferences::Space );
3120 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3121 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3123 setPreferenceProperty( elemW, "min", 1 );
3124 setPreferenceProperty( elemW, "max", 5 );
3126 setPreferenceProperty( shrink, "min", 0 );
3127 setPreferenceProperty( shrink, "max", 100 );
3129 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3131 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3133 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3134 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3135 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3137 setPreferenceProperty( selW, "min", 1 );
3138 setPreferenceProperty( selW, "max", 5 );
3140 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3142 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3143 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3145 setPreferenceProperty( preW, "min", 1 );
3146 setPreferenceProperty( preW, "max", 5 );
3148 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3150 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3151 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3153 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3154 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3156 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3157 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3158 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3159 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3162 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3163 fam.append( tr( "SMESH_FONT_COURIER" ) );
3164 fam.append( tr( "SMESH_FONT_TIMES" ) );
3165 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3167 setPreferenceProperty( tfont, "families", fam );
3168 setPreferenceProperty( tfont, "system", false );
3169 setPreferenceProperty( tfont, "widget_flags", wflag );
3170 setPreferenceProperty( lfont, "families", fam );
3171 setPreferenceProperty( lfont, "system", false );
3172 setPreferenceProperty( lfont, "widget_flags", wflag );
3174 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3176 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3177 setPreferenceProperty( numcol, "min", 2 );
3178 setPreferenceProperty( numcol, "max", 256 );
3180 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3181 setPreferenceProperty( numlab, "min", 2 );
3182 setPreferenceProperty( numlab, "max", 65 );
3184 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3185 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3186 QStringList orients;
3187 orients.append( tr( "SMESH_VERTICAL" ) );
3188 orients.append( tr( "SMESH_HORIZONTAL" ) );
3189 indices.clear(); indices.append( 0 ); indices.append( 1 );
3190 setPreferenceProperty( orient, "strings", orients );
3191 setPreferenceProperty( orient, "indexes", indices );
3193 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3194 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3195 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3196 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3197 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3198 setPreferenceProperty( xv, "step", 0.1 );
3199 setPreferenceProperty( xv, "min", 0.0 );
3200 setPreferenceProperty( xv, "max", 1.0 );
3201 setPreferenceProperty( yv, "step", 0.1 );
3202 setPreferenceProperty( yv, "min", 0.0 );
3203 setPreferenceProperty( yv, "max", 1.0 );
3204 setPreferenceProperty( wv, "step", 0.1 );
3205 setPreferenceProperty( wv, "min", 0.0 );
3206 setPreferenceProperty( wv, "max", 1.0 );
3207 setPreferenceProperty( hv, "min", 0.0 );
3208 setPreferenceProperty( hv, "max", 1.0 );
3209 setPreferenceProperty( hv, "step", 0.1 );
3211 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3212 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3213 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3214 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3215 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3216 setPreferenceProperty( xv, "min", 0.0 );
3217 setPreferenceProperty( xv, "max", 1.0 );
3218 setPreferenceProperty( xv, "step", 0.1 );
3219 setPreferenceProperty( xh, "min", 0.0 );
3220 setPreferenceProperty( xh, "max", 1.0 );
3221 setPreferenceProperty( xh, "step", 0.1 );
3222 setPreferenceProperty( yh, "min", 0.0 );
3223 setPreferenceProperty( yh, "max", 1.0 );
3224 setPreferenceProperty( yh, "step", 0.1 );
3225 setPreferenceProperty( wh, "min", 0.0 );
3226 setPreferenceProperty( wh, "max", 1.0 );
3227 setPreferenceProperty( wh, "step", 0.1 );
3228 setPreferenceProperty( hh, "min", 0.0 );
3229 setPreferenceProperty( hh, "max", 1.0 );
3230 setPreferenceProperty( hh, "step", 0.1 );
3233 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3235 if( sect=="SMESH" ){
3236 float sbX1,sbY1,sbW,sbH;
3237 float aTol = 1.00000009999999;
3238 std::string aWarning;
3239 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3240 if( name=="selection_object_color" || name=="selection_element_color" ||
3241 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3242 name=="selection_precision_node" || name=="selection_precision_element" )
3243 SMESH::UpdateSelectionProp( this );
3244 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3245 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3246 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3247 if(sbX1+sbW > aTol){
3248 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3251 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3252 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3255 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3256 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3257 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3258 if(sbY1+sbH > aTol){
3259 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3262 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3263 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3266 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3267 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3268 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3269 if(sbX1+sbW > aTol){
3270 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3273 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3274 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3277 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3278 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3279 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3280 if(sbY1+sbH > aTol){
3281 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3284 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3285 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3289 if(aWarning.size() != 0){
3290 aWarning += "The default values are applied instead.";
3291 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3292 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3293 QObject::tr(aWarning.c_str()),
3294 QObject::tr("SMESH_BUT_OK"));
3299 //================================================================================
3301 * \brief Update something in accordance with update flags
3302 * \param theFlags - update flags
3304 * Update viewer or/and object browser etc. in accordance with update flags ( see
3305 * LightApp_UpdateFlags enumeration ).
3307 //================================================================================
3308 void SMESHGUI::update( const int flags )
3310 if ( flags & UF_Viewer | flags & UF_Forced )
3311 SMESH::UpdateView();
3313 SalomeApp_Module::update( flags );
3316 //================================================================================
3318 * \brief Set default selection mode
3320 * SLOT called when operation commited. Sets default selection mode
3322 //================================================================================
3323 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3325 SVTK_ViewWindow* vtkWnd =
3326 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3328 vtkWnd->SetSelectionMode( ActorSelection );
3331 //================================================================================
3333 * \brief Set default selection mode
3335 * SLOT called when operation aborted. Sets default selection mode
3337 //================================================================================
3338 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3340 SVTK_ViewWindow* vtkWnd =
3341 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3343 vtkWnd->SetSelectionMode( ActorSelection );
3346 //================================================================================
3348 * \brief Creates operation with given identifier
3349 * \param id - identifier of operation to be started
3350 * \return Pointer on created operation or NULL if operation is not created
3352 * Virtual method redefined from the base class creates operation with given id.
3353 * It is called called automatically from startOperation method of base class.
3355 //================================================================================
3356 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3358 LightApp_Operation* op = 0;
3359 // to do : create operation here
3362 case 702: // Create mesh
3363 op = new SMESHGUI_MeshOp( true, true );
3365 case 703: // Create sub-mesh
3366 op = new SMESHGUI_MeshOp( true, false );
3368 case 704: // Edit mesh/sub-mesh
3369 op = new SMESHGUI_MeshOp( false );
3371 case 417: //convert to quadratic
3372 op = new SMESHGUI_ConvToQuadOp();
3374 case 4067: // make mesh pass through point
3375 op = new SMESHGUI_MakeNodeAtPointOp();
3382 op = SalomeApp_Module::createOperation( id );
3386 //================================================================================
3388 * \brief Stops current operations and starts a given one
3389 * \param id - The id of the operation to start
3391 //================================================================================
3393 void SMESHGUI::switchToOperation(int id)
3395 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3396 activeStudy()->abortAllOperations();
3397 startOperation( id );
3400 LightApp_Displayer* SMESHGUI::displayer()
3403 myDisplayer = new SMESHGUI_Displayer( getApp() );