1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_EditMeshDlg.h"
61 #include "SMESHGUI_MeshPatternDlg.h"
62 #include "SMESHGUI_Selection.h"
63 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
64 #include "SMESHGUI_ConvToQuadOp.h"
65 #include "SMESHGUI_MeshOp.h"
66 #include "SMESHGUI_Displayer.h"
67 #include "SMESHGUI_MakeNodeAtPointDlg.h"
68 #include "SMESHGUI_BuildCompoundDlg.h"
69 #include "SMESHGUI_ComputeDlg.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"
149 #include <Standard_ErrorHandler.hxx>
155 //=============================================================
156 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
159 void ExportMeshToFile(int theCommandID);
161 void SetDisplayMode(int theCommandID);
163 void SetDisplayEntity(int theCommandID);
165 void Control( int theCommandID );
169 //=============================================================
170 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
176 if(theCommandID == 113){
177 filter.append(QObject::tr("MED files (*.med)"));
178 filter.append(QObject::tr("All files (*)"));
179 }else if (theCommandID == 112){
180 filter.append(QObject::tr("IDEAS files (*.unv)"));
181 }else if (theCommandID == 111){
182 filter.append(QObject::tr("DAT files (*.dat)"));
184 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
187 QObject::tr("Import mesh"),
189 if(!filename.isEmpty()) {
190 SUIT_OverrideCursor wc;
191 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
194 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
195 switch ( theCommandID ) {
198 aMeshes->length( 1 );
199 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
204 SMESH::DriverMED_ReadStatus res;
205 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
206 if ( res != SMESH::DRS_OK ) {
208 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
209 QObject::tr("SMESH_WRN_WARNING"),
210 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
211 QObject::tr("SMESH_BUT_OK"));
212 aMeshes->length( 0 );
219 bool isEmpty = false;
220 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
221 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
223 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
224 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
225 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
226 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
227 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
234 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
235 QObject::tr("SMESH_WRN_WARNING"),
236 QObject::tr("SMESH_DRS_EMPTY"),
237 QObject::tr("SMESH_BUT_OK"));
241 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
243 catch (const SALOME::SALOME_Exception& S_ex){
245 SalomeApp_Tools::QtCatchCorbaException(S_ex);
252 void ExportMeshToFile( int theCommandID )
254 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
255 SALOME_ListIO selected;
257 aSel->selectedObjects( selected );
259 if(selected.Extent()){
260 Handle(SALOME_InteractiveObject) anIObject = selected.First();
261 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
262 if ( !aMesh->_is_nil() ) {
263 QString aFilter, aTitle = QObject::tr("Export mesh");
264 QMap<QString, SMESH::MED_VERSION> aFilterMap;
265 QMap<QString, int> aFilterMapSTL;
266 switch ( theCommandID ) {
270 if (aMesh->HasDuplicatedGroupNamesMED()) {
271 int aRet = SUIT_MessageBox::warn2
272 (SMESHGUI::desktop(),
273 QObject::tr("SMESH_WRN_WARNING"),
274 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
275 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
281 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
282 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
287 aFilter = QObject::tr("DAT files (*.dat)");
292 if (aMesh->NbPyramids()) {
293 int aRet = SUIT_MessageBox::warn2
294 (SMESHGUI::desktop(),
295 QObject::tr("SMESH_WRN_WARNING"),
296 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
297 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
302 aFilter = QObject::tr("IDEAS files (*.unv)");
310 there must be check on others mesh elements not equal triangles
312 if (aMesh->NbTriangles() < 1) {
313 SUIT_MessageBox::warn1
314 (SMESHGUI::desktop(),
315 QObject::tr("SMESH_WRN_WARNING"),
316 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
317 QObject::tr("SMESH_BUT_OK"));
320 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
321 int aRet = SUIT_MessageBox::warn2
322 (SMESHGUI::desktop(),
323 QObject::tr("SMESH_WRN_WARNING"),
324 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
325 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
331 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
332 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
340 SMESH::MED_VERSION aFormat;
341 // Init the parameter with the default value
342 bool aIsASCII_STL = true;
343 bool toCreateGroups = false;
344 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
346 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
348 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
350 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
352 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
354 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
355 for ( ; it != aFilterMapSTL.end(); ++it )
356 filters.push_back( it.key() );
358 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
359 fd->setCaption( aTitle );
360 fd->setFilters( filters );
361 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
365 aFilename = fd->selectedFile();
366 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
373 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
374 for ( ; it != aFilterMap.end(); ++it )
375 filters.push_back( it.key() );
377 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
378 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
379 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
380 fd->setCaption( aTitle );
381 fd->setFilters( filters );
382 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
383 fd->SetChecked(toCreateGroups);
387 aFilename = fd->selectedFile();
388 aFormat = aFilterMap[fd->selectedFilter()];
390 if ( !aFilename.isEmpty()
391 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
392 && aFormat==SMESH::MED_V2_1) {
393 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
394 QObject::tr("SMESH_WRN_WARNING"),
395 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
396 QObject::tr("SMESH_BUT_YES"),
397 QObject::tr("SMESH_BUT_NO"),
404 toCreateGroups = fd->IsChecked();
407 if ( !aFilename.isEmpty() ) {
408 // Check whether the file already exists and delete it if yes
409 QFile aFile( aFilename );
410 if ( aFile.exists() )
412 SUIT_OverrideCursor wc;
415 bool Renumber = false ;
416 // PAL 14172 : Check of we have to renumber or not from the preferences before export
418 Renumber= resMgr->booleanValue("SMESH","renumbering");
420 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
421 aMeshEditor->RenumberNodes();
422 aMeshEditor->RenumberElements();
423 if ( SMESHGUI::automaticUpdate() )
426 switch ( theCommandID ) {
429 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
433 aMesh->ExportDAT( aFilename.latin1() );
437 aMesh->ExportUNV( aFilename.latin1() );
441 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
447 catch (const SALOME::SALOME_Exception& S_ex){
449 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
450 QObject::tr("SMESH_WRN_WARNING"),
451 QObject::tr("SMESH_EXPORT_FAILED"),
452 QObject::tr("SMESH_BUT_OK"));
460 inline void InverseEntityMode(unsigned int& theOutputMode,
461 unsigned int theMode)
463 bool anIsNotPresent = ~theOutputMode & theMode;
465 theOutputMode |= theMode;
467 theOutputMode &= ~theMode;
470 void SetDisplayEntity(int theCommandID){
471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
472 SALOME_ListIO selected;
474 aSel->selectedObjects( selected );
476 if(selected.Extent() >= 1){
477 SALOME_ListIteratorOfListIO It( selected );
478 for(; It.More(); It.Next()){
479 Handle(SALOME_InteractiveObject) IObject = It.Value();
480 if(IObject->hasEntry()){
481 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
482 unsigned int aMode = anActor->GetEntityMode();
483 switch(theCommandID){
485 InverseEntityMode(aMode,SMESH_Actor::eEdges);
488 InverseEntityMode(aMode,SMESH_Actor::eFaces);
491 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
494 aMode = SMESH_Actor::eAllEntity;
498 anActor->SetEntityMode(aMode);
506 SALOME_ListIO selected;
507 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
511 LightApp_SelectionMgr* aSel = app->selectionMgr();
512 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
513 if( !aSel || !appStudy )
516 aSel->selectedObjects( selected );
517 if( selected.IsEmpty() )
520 Handle(SALOME_InteractiveObject) anIObject = selected.First();
522 _PTR(Study) aStudy = appStudy->studyDS();
523 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
524 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
525 if( aMainObject->_is_nil() )
528 aMainObject->SetAutoColor( true );
530 QValueList<SALOMEDS::Color> aReservedColors;
532 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
533 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
535 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
536 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
538 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
539 aGroupObject->SetColor( aColor );
540 aReservedColors.append( aColor );
542 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
543 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
545 if( aGroupObject->GetType() == SMESH::NODE )
546 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
547 else if( aGroupObject->GetType() == SMESH::EDGE )
548 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
550 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
554 SMESH::RepaintCurrentView();
557 void DisableAutoColor(){
558 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
559 SALOME_ListIO selected;
561 aSel->selectedObjects( selected );
563 if(selected.Extent()){
564 Handle(SALOME_InteractiveObject) anIObject = selected.First();
565 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
566 if ( !aMesh->_is_nil() ) {
567 aMesh->SetAutoColor( false );
572 void SetDisplayMode(int theCommandID){
573 SALOME_ListIO selected;
574 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
579 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
580 if( !aSel || !appStudy )
583 _PTR(Study) aStudy = appStudy->studyDS();
585 aSel->selectedObjects( selected );
587 if(selected.Extent() >= 1){
588 switch(theCommandID){
590 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
591 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
595 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
596 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
599 SALOME_ListIteratorOfListIO It( selected );
600 for(; It.More(); It.Next()){
601 Handle(SALOME_InteractiveObject) IObject = It.Value();
602 if(IObject->hasEntry()){
603 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
604 switch(theCommandID){
606 anActor->SetRepresentation(SMESH_Actor::eEdge);
609 anActor->SetRepresentation(SMESH_Actor::eSurface);
612 if(anActor->IsShrunk())
615 anActor->SetShrink();
618 anActor->SetRepresentation(SMESH_Actor::ePoint);
621 vtkFloatingPointType color[3];
622 anActor->GetSufaceColor(color[0], color[1], color[2]);
623 int c0 = int (color[0] * 255);
624 int c1 = int (color[1] * 255);
625 int c2 = int (color[2] * 255);
626 QColor c(c0, c1, c2);
628 vtkFloatingPointType edgecolor[3];
629 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
630 c0 = int (edgecolor[0] * 255);
631 c1 = int (edgecolor[1] * 255);
632 c2 = int (edgecolor[2] * 255);
633 QColor e(c0, c1, c2);
635 vtkFloatingPointType backfacecolor[3];
636 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
637 c0 = int (backfacecolor[0] * 255);
638 c1 = int (backfacecolor[1] * 255);
639 c2 = int (backfacecolor[2] * 255);
640 QColor b(c0, c1, c2);
642 vtkFloatingPointType nodecolor[3];
643 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
644 c0 = int (nodecolor[0] * 255);
645 c1 = int (nodecolor[1] * 255);
646 c2 = int (nodecolor[2] * 255);
647 QColor n(c0, c1, c2);
649 int Edgewidth = (int)anActor->GetLineWidth();
652 int intValue = int(anActor->GetNodeSize());
653 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
655 SMESHGUI_Preferences_ColorDlg *aDlg =
656 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
657 aDlg->SetColor(1, c);
658 aDlg->SetColor(2, e);
659 aDlg->SetColor(3, n);
660 aDlg->SetColor(4, b);
661 aDlg->SetIntValue(1, Edgewidth);
662 aDlg->SetIntValue(2, intValue);
663 aDlg->SetIntValue(3, int(Shrink*100.));
665 QColor color = aDlg->GetColor(1);
666 QColor edgecolor = aDlg->GetColor(2);
667 QColor nodecolor = aDlg->GetColor(3);
668 QColor backfacecolor = aDlg->GetColor(4);
669 /* actor color and backface color */
670 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
671 vtkFloatingPointType (color.green()) / 255.,
672 vtkFloatingPointType (color.blue()) / 255.);
673 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
674 vtkFloatingPointType (backfacecolor.green()) / 255.,
675 vtkFloatingPointType (backfacecolor.blue()) / 255.);
678 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
679 vtkFloatingPointType (edgecolor.green()) / 255.,
680 vtkFloatingPointType (edgecolor.blue()) / 255.);
682 /* Shrink factor and size edges */
683 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
684 anActor->SetLineWidth(aDlg->GetIntValue(1));
686 /* Nodes color and size */
687 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
688 vtkFloatingPointType (nodecolor.green()) / 255.,
689 vtkFloatingPointType (nodecolor.blue()) / 255.);
690 anActor->SetNodeSize(aDlg->GetIntValue(2));
692 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
693 if( !aGroupObject->_is_nil() )
695 SALOMEDS::Color aColor;
696 aColor.R = (float)color.red() / 255.0;
697 aColor.G = (float)color.green() / 255.0;
698 aColor.B = (float)color.blue() / 255.0;
699 aGroupObject->SetColor( aColor );
709 SMESH::RepaintCurrentView();
713 void Control( int theCommandID )
715 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
716 SALOME_ListIO selected;
718 aSel->selectedObjects( selected );
720 if( !selected.IsEmpty() ){
721 Handle(SALOME_InteractiveObject) anIO = selected.First();
724 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
725 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
726 switch ( theCommandID ){
728 aTitle = QObject::tr( "LENGTH_EDGES" );
729 aControl = SMESH_Actor::eLength;
732 aTitle = QObject::tr( "LENGTH2D_EDGES" );
733 aControl = SMESH_Actor::eLength2D;
736 aTitle = QObject::tr( "FREE_EDGES" );
737 aControl = SMESH_Actor::eFreeEdges;
740 aTitle = QObject::tr( "FREE_BORDERS" );
741 aControl = SMESH_Actor::eFreeBorders;
744 aTitle = QObject::tr( "MULTI_BORDERS" );
745 aControl = SMESH_Actor::eMultiConnection;
748 aTitle = QObject::tr( "MULTI2D_BORDERS" );
749 aControl = SMESH_Actor::eMultiConnection2D;
752 aTitle = QObject::tr( "AREA_ELEMENTS" );
753 aControl = SMESH_Actor::eArea;
756 aTitle = QObject::tr( "TAPER_ELEMENTS" );
757 aControl = SMESH_Actor::eTaper;
760 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
761 aControl = SMESH_Actor::eAspectRatio;
764 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
765 aControl = SMESH_Actor::eAspectRatio3D;
768 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
769 aControl = SMESH_Actor::eMinimumAngle;
772 aTitle = QObject::tr( "WARP_ELEMENTS" );
773 aControl = SMESH_Actor::eWarping;
776 aTitle = QObject::tr( "SKEW_ELEMENTS" );
777 aControl = SMESH_Actor::eSkew;
780 aTitle = QObject::tr( "SMESH_VOLUME" );
781 aControl = SMESH_Actor::eVolume3D;
784 anActor->SetControlMode(aControl);
785 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
786 SMESH::RepaintCurrentView();
793 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
794 MeshObjectType theType,
795 const QString theInTypeName,
796 QString & theOutTypeName)
798 SMESH_TypeFilter aTypeFilter( theType );
800 if( !theIO.IsNull() )
802 entry = theIO->getEntry();
803 LightApp_DataOwner owner( entry );
804 if ( aTypeFilter.isOk( &owner )) {
805 theOutTypeName = theInTypeName;
813 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
815 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
816 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
818 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
819 CORBA::String_var anID = aSComp->GetID().c_str();
820 if (!strcmp(anID.in(),theIO->getEntry()))
826 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
827 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
828 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
829 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
830 CheckOIType ( theIO, GROUP, "Group", aTypeName )
838 QString CheckHomogeneousSelection()
840 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
841 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
842 SALOME_ListIO selected;
844 aSel->selectedObjects( selected );
846 QString RefType = CheckTypeObject(selected.First());
847 SALOME_ListIteratorOfListIO It(selected);
848 for (; It.More(); It.Next())
850 Handle(SALOME_InteractiveObject) IObject = It.Value();
851 QString Type = CheckTypeObject(IObject);
852 if (Type.compare(RefType) != 0)
853 return "Heterogeneous Selection";
860 void SMESHGUI::OnEditDelete()
862 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
863 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
864 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
866 QString aParentComponent = QString::null;
867 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
869 QString cur = anIt.Value()->getComponentDataType();
870 if( aParentComponent.isNull() )
871 aParentComponent = cur;
872 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
873 aParentComponent = "";
876 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
877 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
878 QObject::tr("ERR_ERROR"),
879 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
880 QObject::tr("BUT_OK") );
883 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
884 if (SUIT_MessageBox::warn2
885 (SMESHGUI::desktop(),
886 QObject::tr("SMESH_WRN_WARNING"),
887 QObject::tr("SMESH_REALLY_DELETE"),
888 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
891 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
892 SUIT_ViewManager* vm = anApp->activeViewManager();
893 int nbSf = vm->getViewsCount();
895 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
896 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
897 _PTR(GenericAttribute) anAttr;
898 _PTR(AttributeIOR) anIOR;
900 SALOME_ListIteratorOfListIO It(selected);
902 aStudyBuilder->NewCommand(); // There is a transaction
903 for(; It.More(); It.Next()){ // loop on selected IO's
904 Handle(SALOME_InteractiveObject) IObject = It.Value();
905 if(IObject->hasEntry()) {
906 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
908 // disable removal of "SMESH" component object
909 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
911 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
915 // put the whole hierarchy of sub-objects of the selected SO into a list and
916 // then treat them all starting from the deepest objects (at list back)
918 list< _PTR(SObject) > listSO;
919 listSO.push_back( aSO );
920 list< _PTR(SObject) >::iterator itSO = listSO.begin();
921 for ( ; itSO != listSO.end(); ++itSO ) {
922 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
923 for (it->InitEx(false); it->More(); it->Next())
924 listSO.push_back( it->Value() );
927 // treat SO's in the list starting from the back
929 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
930 for ( ; ritSO != listSO.rend(); ++ritSO ) {
931 _PTR(SObject) SO = *ritSO;
933 string anEntry = SO->GetID();
935 /** Erase graphical object **/
936 if(SO->FindAttribute(anAttr, "AttributeIOR")){
937 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
938 for(int i = 0; i < nbSf; i++){
939 SUIT_ViewWindow *sf = aViews[i];
940 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
941 SMESH::RemoveActor(sf,anActor);
946 /** Remove an object from data structures **/
947 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
948 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
949 if ( !aGroup->_is_nil() ) { // DELETE GROUP
950 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
951 aMesh->RemoveGroup( aGroup );
953 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
954 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
955 aMesh->RemoveSubMesh( aSubMesh );
957 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
959 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
962 IObject = new SALOME_InteractiveObject
963 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
964 QString objType = CheckTypeObject(IObject);
965 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
966 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
967 aStudyBuilder->RemoveObjectWithChildren( SO );
969 else {// default action: remove SObject from the study
970 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
971 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
973 aStudyBuilder->RemoveObjectWithChildren( SO );
977 } /* listSO back loop */
978 } /* IObject->hasEntry() */
980 aStudyBuilder->CommitCommand();
982 /* Clear any previous selection */
984 aSel->setSelectedObjects( l1 );
986 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
991 SMESHGUI_EXPORT CAM_Module* createModule()
993 return new SMESHGUI();
997 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
999 //=============================================================================
1003 //=============================================================================
1004 SMESHGUI::SMESHGUI() :
1005 SalomeApp_Module( "SMESH" )
1007 if ( CORBA::is_nil( myComponentSMESH ) )
1009 CORBA::Boolean anIsEmbeddedMode;
1010 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1013 myActiveDialogBox = 0;
1014 myFilterLibraryDlg = 0;
1018 SMESH::GetFilterManager();
1019 SMESH::GetPattern();
1021 /* load resources for all available meshers */
1022 SMESH::InitAvailableHypotheses();
1025 //=============================================================================
1029 //=============================================================================
1030 SMESHGUI::~SMESHGUI()
1032 SMESH::GetFilterManager()->Destroy();
1033 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1036 //=============================================================================
1040 //=============================================================================
1041 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1043 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1045 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1050 bool SMESHGUI::automaticUpdate()
1052 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1056 return resMgr->booleanValue( "SMESH", "auto_update", false );
1059 //=============================================================================
1063 //=============================================================================
1064 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1066 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1069 //=============================================================================
1073 //=============================================================================
1074 SMESHGUI* SMESHGUI::GetSMESHGUI()
1076 SMESHGUI* smeshMod = 0;
1077 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1080 CAM_Module* module = app->module( "Mesh" );
1081 smeshMod = dynamic_cast<SMESHGUI*>( module );
1084 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1086 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1089 _PTR(Study) aStudy = study->studyDS();
1091 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1100 Standard_EXPORT SMESHGUI* GetComponentGUI()
1102 return SMESHGUI::GetSMESHGUI();
1106 //=============================================================================
1110 //=============================================================================
1111 void SMESHGUI::SetState(int aState)
1116 //=============================================================================
1120 //=============================================================================
1121 void SMESHGUI::ResetState()
1126 //=============================================================================
1130 //=============================================================================
1131 void SMESHGUI::EmitSignalDeactivateDialog()
1133 emit SignalDeactivateActiveDialog();
1136 //=============================================================================
1140 //=============================================================================
1141 void SMESHGUI::EmitSignalStudyFrameChanged()
1143 emit SignalStudyFrameChanged();
1146 //=============================================================================
1150 //=============================================================================
1151 void SMESHGUI::EmitSignalCloseAllDialogs()
1153 emit SignalCloseAllDialogs();
1156 //=============================================================================
1160 //=============================================================================
1161 QDialog *SMESHGUI::GetActiveDialogBox()
1163 return myActiveDialogBox;
1166 //=============================================================================
1170 //=============================================================================
1171 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1173 myActiveDialogBox = (QDialog *) aDlg;
1177 //=============================================================================
1181 //=============================================================================
1182 SUIT_Desktop* SMESHGUI::desktop()
1184 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1186 return app->desktop();
1191 //=============================================================================
1195 //=============================================================================
1196 SalomeApp_Study* SMESHGUI::activeStudy()
1198 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1200 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1205 //=============================================================================
1209 //=============================================================================
1210 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1212 /* Here the position is on the bottom right corner - 10 */
1213 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1215 SUIT_Desktop *PP = desktop();
1216 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1217 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1221 //=============================================================================
1225 //=============================================================================
1226 static int isStudyLocked(_PTR(Study) theStudy){
1227 return theStudy->GetProperties()->IsLocked();
1230 static bool checkLock(_PTR(Study) theStudy) {
1231 if (isStudyLocked(theStudy)) {
1232 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1233 QObject::tr("WRN_WARNING"),
1234 QObject::tr("WRN_STUDY_LOCKED"),
1235 QObject::tr("BUT_OK") );
1241 //=======================================================================
1242 //function : CheckActiveStudyLocked
1244 //=======================================================================
1246 bool SMESHGUI::isActiveStudyLocked()
1248 _PTR(Study) aStudy = activeStudy()->studyDS();
1249 return checkLock( aStudy );
1252 //=============================================================================
1256 //=============================================================================
1257 bool SMESHGUI::OnGUIEvent( int theCommandID )
1259 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1263 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1264 SUIT_ResourceMgr* mgr = resourceMgr();
1268 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1269 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1272 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1273 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1275 //QAction* act = action( theCommandID );
1277 switch (theCommandID) {
1279 if(checkLock(aStudy)) break;
1287 if(checkLock(aStudy)) break;
1288 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1292 case 122: // EXPORT MED
1301 ::ExportMeshToFile(theCommandID);
1305 case 200: // SCALAR BAR
1307 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1308 SALOME_ListIO selected;
1310 aSel->selectedObjects( selected );
1312 if( selected.Extent() ) {
1313 Handle(SALOME_InteractiveObject) anIO = selected.First();
1314 if( anIO->hasEntry() ) {
1315 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1316 anActor->SetControlMode( SMESH_Actor::eNone );
1324 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1334 ::DisableAutoColor();
1337 case 1134: // Clipping
1338 case 1133: // Tranparency
1339 case 1132: // Colors / Size
1346 ::SetDisplayMode(theCommandID);
1352 case 219: // Volumes
1353 case 220: // All Entity
1354 ::SetDisplayEntity(theCommandID);
1359 if(checkLock(aStudy)) break;
1361 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1364 SMESH::UpdateView();
1366 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1367 SMESH::OnVisuException();
1369 catch (...) { // PAL16774 (Crash after display of many groups)
1370 SMESH::OnVisuException();
1374 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1375 aSel->selectedObjects( l );
1376 aSel->setSelectedObjects( l );
1381 case 301: // DISPLAY
1382 case 302: // DISPLAY ONLY
1384 SMESH::EDisplaing anAction;
1385 switch (theCommandID) {
1386 case 300: anAction = SMESH::eErase; break;
1387 case 301: anAction = SMESH::eDisplay; break;
1388 case 302: anAction = SMESH::eDisplayOnly; break;
1391 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1392 SALOME_ListIO sel_objects, to_process;
1394 aSel->selectedObjects( sel_objects );
1396 if( theCommandID==302 )
1397 startOperation( myEraseAll );
1399 extractContainers( sel_objects, to_process );
1402 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1406 SALOME_ListIteratorOfListIO It( to_process );
1407 for (; It.More(); It.Next()) {
1408 Handle(SALOME_InteractiveObject) IOS = It.Value();
1409 if (IOS->hasEntry()) {
1410 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1411 break; // PAL16774 (Crash after display of many groups)
1412 if (anAction == SMESH::eDisplayOnly)
1413 anAction = SMESH::eDisplay;
1418 // PAL13338 + PAL15161 -->
1419 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1420 SMESH::UpdateView();
1421 // PAL13338 + PAL15161 <--
1423 catch (...) { // PAL16774 (Crash after display of many groups)
1424 SMESH::OnVisuException();
1427 if (anAction == SMESH::eErase) {
1429 aSel->setSelectedObjects( l1 );
1432 aSel->setSelectedObjects( to_process );
1439 if(checkLock(aStudy)) break;
1442 EmitSignalDeactivateDialog();
1444 new SMESHGUI_NodesDlg(this);
1447 SUIT_MessageBox::warn1(desktop(),
1448 tr("SMESH_WRN_WARNING"),
1449 tr("SMESH_WRN_VIEWER_VTK"),
1450 tr("SMESH_BUT_OK"));
1455 case 2151: // FILTER
1459 EmitSignalDeactivateDialog();
1460 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1465 case 406: // MOVE NODE
1469 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1470 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1474 if(checkLock(aStudy)) break;
1475 new SMESHGUI_MoveNodesDlg(this);
1479 case 701: // COMPUTE MESH
1481 if (checkLock(aStudy)) break;
1483 startOperation( 701 );
1487 case 702: // Create mesh
1488 startOperation( 702 );
1490 case 703: // Create sub-mesh
1491 startOperation( 703 );
1493 case 704: // Edit mesh/sub-mesh
1494 startOperation( 704 );
1496 case 710: // Build compound mesh
1498 if (checkLock(aStudy)) break;
1499 EmitSignalDeactivateDialog();
1500 new SMESHGUI_BuildCompoundDlg( this );
1503 case 407: // DIAGONAL INVERSION
1504 case 408: // Delete diagonal
1508 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1509 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1513 if ( checkLock( aStudy ) )
1516 /*Standard_Boolean aRes;
1517 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1518 if ( aMesh->_is_nil() )
1520 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1521 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1525 EmitSignalDeactivateDialog();
1526 if ( theCommandID == 407 )
1527 new SMESHGUI_TrianglesInversionDlg(this);
1529 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1532 case 409: // Change orientation
1533 case 410: // Union of triangles
1534 case 411: // Cutting of quadrangles
1538 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1539 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1543 if ( checkLock( aStudy ) )
1546 EmitSignalDeactivateDialog();
1547 SMESHGUI_MultiEditDlg* aDlg = NULL;
1548 if ( theCommandID == 409 )
1549 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1550 else if ( theCommandID == 410 )
1551 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1553 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1558 case 412: // Smoothing
1560 if(checkLock(aStudy)) break;
1562 EmitSignalDeactivateDialog();
1563 new SMESHGUI_SmoothingDlg( this );
1566 SUIT_MessageBox::warn1(desktop(),
1567 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1568 tr("SMESH_BUT_OK"));
1572 case 413: // Extrusion
1574 if (checkLock(aStudy)) break;
1576 EmitSignalDeactivateDialog();
1577 new SMESHGUI_ExtrusionDlg ( this );
1579 SUIT_MessageBox::warn1(desktop(),
1580 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1581 tr("SMESH_BUT_OK"));
1585 case 414: // Revolution
1587 if(checkLock(aStudy)) break;
1589 EmitSignalDeactivateDialog();
1590 new SMESHGUI_RevolutionDlg( this );
1593 SUIT_MessageBox::warn1(desktop(),
1594 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1595 tr("SMESH_BUT_OK"));
1599 case 415: // Pattern mapping
1601 if ( checkLock( aStudy ) )
1605 EmitSignalDeactivateDialog();
1606 new SMESHGUI_MeshPatternDlg( this );
1609 SUIT_MessageBox::warn1(desktop(),
1610 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1611 tr("SMESH_BUT_OK"));
1615 case 416: // Extrusion along a path
1617 if (checkLock(aStudy)) break;
1619 EmitSignalDeactivateDialog();
1620 new SMESHGUI_ExtrusionAlongPathDlg( this );
1622 SUIT_MessageBox::warn1(desktop(),
1623 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1624 tr("SMESH_BUT_OK"));
1628 case 417: // Convert mesh to quadratic
1630 startOperation( 417 );
1631 /* if (checkLock(aStudy)) break;
1633 EmitSignalDeactivateDialog();
1634 new SMESHGUI_ConvToQuadDlg();
1636 SUIT_MessageBox::warn1(desktop(),
1637 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1638 tr("SMESH_BUT_OK"));
1642 case 801: // CREATE GROUP
1646 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1647 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1651 if(checkLock(aStudy)) break;
1652 EmitSignalDeactivateDialog();
1653 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1655 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1656 SALOME_ListIO selected;
1658 aSel->selectedObjects( selected );
1660 int nbSel = selected.Extent();
1662 // check if mesh is selected
1663 aMesh = SMESH::GetMeshByIO( selected.First() );
1665 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1670 case 802: // CONSTRUCT GROUP
1674 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1675 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1679 if(checkLock(aStudy)) break;
1680 EmitSignalDeactivateDialog();
1682 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1683 SALOME_ListIO selected;
1685 aSel->selectedObjects( selected );
1687 int nbSel = selected.Extent();
1689 // check if submesh is selected
1690 Handle(SALOME_InteractiveObject) IObject = selected.First();
1691 if (IObject->hasEntry()) {
1692 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1694 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1695 if (!aSubMesh->_is_nil()) {
1697 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1698 // get submesh elements list by types
1699 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1700 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1701 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1702 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1703 // create group for each type o elements
1704 QString aName = IObject->getName();
1705 if (aNodes->length() > 0) {
1706 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1707 aGroup->Add(aNodes.inout());
1709 if (aEdges->length() > 0) {
1710 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1711 aGroup->Add(aEdges.inout());
1713 if (aFaces->length() > 0) {
1714 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1715 aGroup->Add(aFaces.inout());
1717 if (aVolumes->length() > 0) {
1718 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1719 aGroup->Add(aVolumes.inout());
1724 catch(const SALOME::SALOME_Exception & S_ex){
1725 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1732 SUIT_MessageBox::warn1(desktop(),
1733 tr("SMESH_WRN_WARNING"),
1734 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1735 tr("SMESH_BUT_OK"));
1740 case 803: // EDIT GROUP
1744 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1745 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1749 if(checkLock(aStudy)) break;
1750 EmitSignalDeactivateDialog();
1752 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1753 SALOME_ListIO selected;
1755 aSel->selectedObjects( selected );
1757 SALOME_ListIteratorOfListIO It (selected);
1758 int nbSelectedGroups = 0;
1759 for ( ; It.More(); It.Next() )
1761 SMESH::SMESH_GroupBase_var aGroup =
1762 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1763 if (!aGroup->_is_nil()) {
1765 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1769 if (nbSelectedGroups == 0)
1771 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1777 case 804: // Add elements to group
1779 if(checkLock(aStudy)) break;
1780 if (myState == 800) {
1781 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1782 if (aDlg) aDlg->onAdd();
1787 case 805: // Remove elements from group
1789 if(checkLock(aStudy)) break;
1790 if (myState == 800) {
1791 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1792 if (aDlg) aDlg->onRemove();
1797 case 810: // Union Groups
1798 case 811: // Intersect groups
1799 case 812: // Cut groups
1803 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1804 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1808 if ( checkLock( aStudy ) )
1811 EmitSignalDeactivateDialog();
1814 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1815 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1816 else aMode = SMESHGUI_GroupOpDlg::CUT;
1818 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1822 case 813: // Delete groups with their contents
1826 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1827 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1831 if ( checkLock( aStudy ) )
1834 EmitSignalDeactivateDialog();
1836 new SMESHGUI_DeleteGroupDlg( this );
1840 case 900: // MESH INFOS
1842 EmitSignalDeactivateDialog();
1843 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1844 SALOME_ListIO selected;
1846 aSel->selectedObjects( selected );
1848 if ( selected.Extent() > 1 ) { // a dlg for each IO
1850 SALOME_ListIteratorOfListIO It (selected);
1851 for ( ; It.More(); It.Next() ) {
1852 IOs.Clear(); IOs.Append( It.Value() );
1853 aSel->setSelectedObjects( IOs );
1854 new SMESHGUI_MeshInfosDlg(this, "", false);
1856 // restore selection
1857 aSel->setSelectedObjects( selected );
1860 new SMESHGUI_MeshInfosDlg(this, "", false);
1864 case 902: // STANDARD MESH INFOS
1866 EmitSignalDeactivateDialog();
1867 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1868 SALOME_ListIO selected;
1870 aSel->selectedObjects( selected );
1872 if ( selected.Extent() > 1 ) { // a dlg for each IO
1874 SALOME_ListIteratorOfListIO It (selected);
1875 for ( ; It.More(); It.Next() ) {
1877 IOs.Append( It.Value() );
1878 aSel->setSelectedObjects( IOs );
1879 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1881 // restore selection
1882 aSel->setSelectedObjects( selected );
1885 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1889 case 1100: // EDIT HYPOTHESIS
1891 if(checkLock(aStudy)) break;
1893 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1894 SALOME_ListIO selected;
1896 aSel->selectedObjects( selected );
1898 int nbSel = selected.Extent();
1901 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1902 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1904 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1905 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1906 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1907 if ( !aHypothesis->_is_nil() )
1909 CORBA::String_var aHypType = aHypothesis->GetName();
1910 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1912 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1919 updateObjBrowser( true );
1923 case 1101: // RENAME
1925 if ( checkLock( aStudy ) )
1928 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1929 SALOME_ListIO selected;
1931 aSel->selectedObjects( selected );
1933 SALOME_ListIteratorOfListIO It( selected );
1934 for ( ; It.More(); It.Next() )
1936 Handle(SALOME_InteractiveObject) IObject = It.Value();
1937 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1938 _PTR(GenericAttribute) anAttr;
1939 _PTR(AttributeName) aName;
1942 if ( obj->FindAttribute(anAttr, "AttributeName") )
1945 QString newName = QString(aName->Value().c_str());
1946 newName = LightApp_NameDlg::getName(desktop(), newName);
1947 if ( !newName.isEmpty() )
1949 //old source: aStudy->renameIObject( IObject, newName );
1950 aName->SetValue( newName.latin1() );
1952 // if current object is group update group's name
1953 SMESH::SMESH_GroupBase_var aGroup =
1954 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1955 if (!aGroup->_is_nil() )
1956 aGroup->SetName( newName.latin1() );
1966 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1968 if(checkLock(aStudy)) break;
1969 SUIT_OverrideCursor wc;
1971 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1972 SALOME_ListIO selected;
1974 aSel->selectedObjects( selected, QString::null, false );
1976 SALOME_ListIteratorOfListIO It(selected);
1977 for (int i = 0; It.More(); It.Next(), i++) {
1978 Handle(SALOME_InteractiveObject) IObject = It.Value();
1979 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1982 aSel->setSelectedObjects( l1 );
1987 case 401: // GEOM::EDGE
1988 case 4021: // TRIANGLE
1990 case 4023: // POLYGON
1994 if(checkLock(aStudy)) break;
1996 EmitSignalDeactivateDialog();
1997 SMDSAbs_ElementType type = SMDSAbs_Edge;
1999 switch (theCommandID) {
2000 case 4021: // TRIANGLE
2001 type = SMDSAbs_Face; nbNodes = 3; break;
2003 type = SMDSAbs_Face; nbNodes = 4; break;
2005 type = SMDSAbs_Volume; nbNodes = 4; break;
2006 case 4023: // POLYGON
2007 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2009 type = SMDSAbs_Volume; nbNodes = 8; break;
2010 case 4033: // POLYHEDRE
2011 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2014 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2017 SUIT_MessageBox::warn1(desktop(),
2018 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2019 tr("SMESH_BUT_OK"));
2023 case 4033: // POLYHEDRON
2025 if(checkLock(aStudy)) break;
2027 EmitSignalDeactivateDialog();
2028 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2031 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2032 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2033 tr("SMESH_BUT_OK"));
2037 case 4034: // QUADRATIC EDGE
2038 case 4035: // QUADRATIC TRIANGLE
2039 case 4036: // QUADRATIC QUADRANGLE
2040 case 4037: // QUADRATIC TETRAHEDRON
2041 case 4038: // QUADRATIC PYRAMID
2042 case 4039: // QUADRATIC PENTAHEDRON
2043 case 4040: // QUADRATIC HEXAHEDRON
2045 if(checkLock(aStudy)) break;
2047 EmitSignalDeactivateDialog();
2050 switch (theCommandID) {
2052 type = QUAD_EDGE; break;
2054 type = QUAD_TRIANGLE; break;
2056 type = QUAD_QUADRANGLE; break;
2058 type = QUAD_TETRAHEDRON; break;
2060 type = QUAD_PYRAMID; break;
2062 type = QUAD_PENTAHEDRON; break;
2064 type = QUAD_HEXAHEDRON;
2068 new SMESHGUI_AddQuadraticElementDlg( this, type );
2071 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4041: // REMOVES NODES
2079 if(checkLock(aStudy)) break;
2081 EmitSignalDeactivateDialog();
2082 new SMESHGUI_RemoveNodesDlg(this);
2085 SUIT_MessageBox::warn1(desktop(),
2086 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2087 tr("SMESH_BUT_OK"));
2091 case 4042: // REMOVES ELEMENTS
2093 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2096 new SMESHGUI_RemoveElementsDlg(this);
2100 SUIT_MessageBox::warn1(desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2102 tr("SMESH_BUT_OK"));
2106 case 4051: // RENUMBERING NODES
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 new SMESHGUI_RenumberingDlg( this, "", 0);
2115 SUIT_MessageBox::warn1(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2117 tr("SMESH_BUT_OK"));
2121 case 4052: // RENUMBERING ELEMENTS
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 new SMESHGUI_RenumberingDlg( this, "", 1);
2130 SUIT_MessageBox::warn1(desktop(),
2131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2132 tr("SMESH_BUT_OK"));
2136 case 4061: // TRANSLATION
2138 if(checkLock(aStudy)) break;
2140 EmitSignalDeactivateDialog();
2141 new SMESHGUI_TranslationDlg( this );
2144 SUIT_MessageBox::warn1(desktop(),
2145 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2146 tr("SMESH_BUT_OK"));
2150 case 4062: // ROTATION
2152 if(checkLock(aStudy)) break;
2154 EmitSignalDeactivateDialog();
2155 new SMESHGUI_RotationDlg( this );
2158 SUIT_MessageBox::warn1(desktop(),
2159 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2160 tr("SMESH_BUT_OK"));
2164 case 4063: // SYMMETRY
2166 if(checkLock(aStudy)) break;
2168 EmitSignalDeactivateDialog();
2169 new SMESHGUI_SymmetryDlg( this );
2172 SUIT_MessageBox::warn1(desktop(),
2173 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2174 tr("SMESH_BUT_OK"));
2178 case 4064: // SEWING
2180 if(checkLock(aStudy)) break;
2182 EmitSignalDeactivateDialog();
2183 new SMESHGUI_SewingDlg( this );
2186 SUIT_MessageBox::warn1(desktop(),
2187 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2188 tr("SMESH_BUT_OK"));
2192 case 4065: // MERGE NODES
2194 if(checkLock(aStudy)) break;
2196 EmitSignalDeactivateDialog();
2197 new SMESHGUI_EditMeshDlg( this, 0 );
2200 SUIT_MessageBox::warn1(desktop(),
2201 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2202 tr("SMESH_BUT_OK"));
2206 case 4066: // MERGE EQUAL ELEMENTS
2208 if (checkLock(aStudy)) break;
2210 EmitSignalDeactivateDialog();
2211 new SMESHGUI_EditMeshDlg( this, 1 );
2213 SUIT_MessageBox::warn1(desktop(),
2214 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2215 tr("SMESH_BUT_OK"));
2220 case 4067: // MAKE MESH PASS THROUGH POINT
2221 startOperation( 4067 );
2224 case 5105: // Library of selection filters
2226 static QValueList<int> aTypes;
2227 if ( aTypes.isEmpty() )
2229 aTypes.append( SMESH::NODE );
2230 aTypes.append( SMESH::EDGE );
2231 aTypes.append( SMESH::FACE );
2232 aTypes.append( SMESH::VOLUME );
2234 if (!myFilterLibraryDlg)
2235 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2236 else if (myFilterLibraryDlg->isHidden())
2237 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2238 myFilterLibraryDlg->raise();
2242 case 6017: // CONTROLS
2258 LightApp_SelectionMgr* mgr = selectionMgr();
2259 SALOME_ListIO selected; mgr->selectedObjects( selected );
2261 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2262 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2264 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2265 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2266 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2267 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2268 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2269 ::Control( theCommandID );
2274 SUIT_MessageBox::warn1(desktop(),
2275 tr( "SMESH_WRN_WARNING" ),
2276 tr( "SMESH_BAD_SELECTION" ),
2277 tr( "SMESH_BUT_OK" ) );
2281 SUIT_MessageBox::warn1(desktop(),
2282 tr( "SMESH_WRN_WARNING" ),
2283 tr( "NOT_A_VTK_VIEWER" ),
2284 tr( "SMESH_BUT_OK" ) );
2289 LightApp_SelectionMgr* mgr = selectionMgr();
2290 SALOME_ListIO selected; mgr->selectedObjects( selected );
2292 SALOME_ListIteratorOfListIO it(selected);
2293 for(; it.More(); it.Next()) {
2294 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2295 if(anIObject->hasEntry()) {
2296 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2297 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2305 LightApp_SelectionMgr* mgr = selectionMgr();
2306 SALOME_ListIO selected; mgr->selectedObjects( selected );
2308 if (selected.Extent() == 1) {
2309 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2310 if(anIObject->hasEntry())
2311 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2312 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2319 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2320 //updateObjBrowser();
2324 //=============================================================================
2328 //=============================================================================
2329 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2334 //=============================================================================
2338 //=============================================================================
2339 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2344 //=============================================================================
2348 //=============================================================================
2349 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2354 //=============================================================================
2355 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2356 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2358 //=============================================================================
2359 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2360 SUIT_ViewWindow* wnd )
2362 if(theIO->hasEntry()){
2363 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2364 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2368 //=======================================================================
2369 // function : createSMESHAction
2371 //=======================================================================
2372 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2375 QWidget* parent = application()->desktop();
2376 SUIT_ResourceMgr* resMgr = resourceMgr();
2378 if ( icon_id.length() )
2379 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2381 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2382 if ( !pix.isNull() )
2383 icon = QIconSet( pix );
2385 QString tooltip = tr( QString( "TOP_" )+po_id ),
2386 menu = tr( QString( "MEN_" )+po_id ),
2387 status_bar = tr( QString( "STB_" )+po_id );
2389 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2392 //=======================================================================
2393 // function : createPopupItem
2395 //=======================================================================
2396 void SMESHGUI::createPopupItem( const int id,
2397 const QString& clients,
2398 const QString& types,
2399 const QString& theRule,
2404 parentId = popupMgr()->actionId( action( pId ) );
2406 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2407 popupMgr()->insert( action( id ), parentId, 0 );
2409 QChar lc = QtxPopupMgr::Selection::defEquality();
2410 QString rule = "(%1) and (%2) and (%3)";
2411 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2412 if( clients.isEmpty() )
2413 rule = rule.arg( QString( "true" ) );
2415 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2416 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2419 bool cont = myRules.contains( id );
2421 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2423 popupMgr()->setRule( action( id ), rule, true );
2424 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2427 //=======================================================================
2428 // function : initialize
2430 //=======================================================================
2431 void SMESHGUI::initialize( CAM_Application* app )
2433 SalomeApp_Module::initialize( app );
2435 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2437 /* Automatic Update flag */
2438 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2440 // ----- create actions --------------
2442 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2443 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2444 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2445 createSMESHAction( 114, "NUM" );
2446 createSMESHAction( 121, "DAT" );
2447 createSMESHAction( 122, "MED" );
2448 createSMESHAction( 123, "UNV" );
2449 createSMESHAction( 140, "STL" );
2450 createSMESHAction( 124, "EXPORT_DAT" );
2451 createSMESHAction( 125, "EXPORT_MED" );
2452 createSMESHAction( 126, "EXPORT_UNV" );
2453 createSMESHAction( 141, "EXPORT_STL" );
2454 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2455 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2456 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2457 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2458 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2459 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2460 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2461 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2462 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2463 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2464 createSMESHAction( 804, "ADD" );
2465 createSMESHAction( 805, "REMOVE" );
2466 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2467 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2468 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2469 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2470 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2471 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2472 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2473 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2474 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2475 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2476 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2477 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2478 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2479 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2480 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2481 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2482 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2483 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2484 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2485 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2486 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2487 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2488 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2489 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2490 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2491 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2492 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2493 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2494 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2495 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2496 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2497 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2498 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2499 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2500 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2501 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2502 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2503 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2504 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2505 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2506 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2507 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2508 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2509 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2510 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2511 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2512 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2513 createSMESHAction( 415, "MAP", "ICON_MAP" );
2514 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2515 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2516 createSMESHAction( 200, "RESET" );
2517 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2518 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2519 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2520 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2521 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2522 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2523 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2524 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2525 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2526 createSMESHAction( 220, "ALL" );
2527 createSMESHAction( 1100, "EDIT_HYPO" );
2528 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2529 createSMESHAction( 1102, "UNASSIGN" );
2530 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2531 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2532 createSMESHAction( 1131, "DISPMODE" );
2533 createSMESHAction( 1132, "COLORS" );
2534 createSMESHAction( 1133, "TRANSP" );
2535 createSMESHAction( 1134, "CLIP" );
2536 createSMESHAction( 1135, "DISP_ENT" );
2537 createSMESHAction( 1136, "AUTO_COLOR" );
2538 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2539 createSMESHAction( 2000, "CTRL" );
2541 createSMESHAction( 300, "ERASE" );
2542 createSMESHAction( 301, "DISPLAY" );
2543 createSMESHAction( 302, "DISPLAY_ONLY" );
2544 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2545 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2546 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2547 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2548 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2549 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2550 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2551 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2553 // ----- create menu --------------
2554 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2555 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2556 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2557 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2558 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2559 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2560 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2562 createMenu( separator(), fileId );
2564 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2565 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2566 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2567 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2568 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2569 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2571 createMenu( 111, importId, -1 );
2572 createMenu( 112, importId, -1 );
2573 createMenu( 113, importId, -1 );
2575 createMenu( 121, exportId, -1 );
2576 createMenu( 122, exportId, -1 );
2577 createMenu( 123, exportId, -1 );
2578 createMenu( 140, exportId, -1 ); // export to stl STL
2580 createMenu( separator(), fileId, 10 );
2582 createMenu( 33, editId, -1 );
2584 createMenu( 5105, toolsId, -1 );
2586 createMenu( 702, meshId, -1 );
2587 createMenu( 703, meshId, -1 );
2588 createMenu( 704, meshId, -1 );
2589 createMenu( 710, meshId, -1 );
2590 createMenu( separator(), meshId, -1 );
2591 createMenu( 701, meshId, -1 );
2592 createMenu( separator(), meshId, -1 );
2593 createMenu( 801, meshId, -1 );
2594 createMenu( 802, meshId, -1 );
2595 createMenu( 803, meshId, -1 );
2596 createMenu( separator(), meshId, -1 );
2597 createMenu( 810, meshId, -1 );
2598 createMenu( 811, meshId, -1 );
2599 createMenu( 812, meshId, -1 );
2600 createMenu( separator(), meshId, -1 );
2601 createMenu( 813, meshId, -1 );
2602 createMenu( separator(), meshId, -1 );
2603 createMenu( 900, meshId, -1 );
2604 createMenu( 902, meshId, -1 );
2605 createMenu( separator(), meshId, -1 );
2607 createMenu( 6003, ctrlId, -1 );
2608 createMenu( 6001, ctrlId, -1 );
2609 createMenu( 6004, ctrlId, -1 );
2610 createMenu( separator(), ctrlId, -1 );
2611 createMenu( 6002, ctrlId, -1 );
2612 createMenu( 6018, ctrlId, -1 );
2613 createMenu( 6019, ctrlId, -1 );
2614 createMenu( 6011, ctrlId, -1 );
2615 createMenu( 6012, ctrlId, -1 );
2616 createMenu( 6013, ctrlId, -1 );
2617 createMenu( 6014, ctrlId, -1 );
2618 createMenu( 6015, ctrlId, -1 );
2619 createMenu( 6016, ctrlId, -1 );
2620 createMenu( separator(), ctrlId, -1 );
2621 createMenu( 6017, ctrlId, -1 );
2622 createMenu( 6009, ctrlId, -1 );
2623 createMenu( separator(), ctrlId, -1 );
2625 createMenu( 400, addId, -1 );
2626 createMenu( 401, addId, -1 );
2627 createMenu( 4021, addId, -1 );
2628 createMenu( 4022, addId, -1 );
2629 createMenu( 4023, addId, -1 );
2630 createMenu( 4031, addId, -1 );
2631 createMenu( 4032, addId, -1 );
2632 createMenu( 4033, addId, -1 );
2633 createMenu( separator(), addId, -1 );
2634 createMenu( 4034, addId, -1 );
2635 createMenu( 4035, addId, -1 );
2636 createMenu( 4036, addId, -1 );
2637 createMenu( 4037, addId, -1 );
2638 createMenu( 4038, addId, -1 );
2639 createMenu( 4039, addId, -1 );
2640 createMenu( 4040, addId, -1 );
2642 createMenu( 4041, removeId, -1 );
2643 createMenu( 4042, removeId, -1 );
2645 createMenu( 4051, renumId, -1 );
2646 createMenu( 4052, renumId, -1 );
2648 createMenu( 4061, transfId, -1 );
2649 createMenu( 4062, transfId, -1 );
2650 createMenu( 4063, transfId, -1 );
2651 createMenu( 4064, transfId, -1 );
2652 createMenu( 4065, transfId, -1 );
2653 createMenu( 4066, transfId, -1 );
2655 createMenu( 406, modifyId, -1 );
2656 createMenu( 4067,modifyId, -1 );
2657 createMenu( 407, modifyId, -1 );
2658 createMenu( 408, modifyId, -1 );
2659 createMenu( 409, modifyId, -1 );
2660 createMenu( 410, modifyId, -1 );
2661 createMenu( 411, modifyId, -1 );
2662 createMenu( 412, modifyId, -1 );
2663 createMenu( 413, modifyId, -1 );
2664 createMenu( 416, modifyId, -1 );
2665 createMenu( 414, modifyId, -1 );
2666 createMenu( 415, modifyId, -1 );
2667 createMenu( 417, modifyId, -1 );
2669 createMenu( 214, viewId, -1 );
2671 // ----- create toolbars --------------
2672 int meshTb = createTool( tr( "TB_MESH" ) ),
2673 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2674 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2675 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2676 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2678 createTool( 702, meshTb );
2679 createTool( 703, meshTb );
2680 createTool( 704, meshTb );
2681 createTool( 710, meshTb );
2682 createTool( separator(), meshTb );
2683 createTool( 701, meshTb );
2684 createTool( separator(), meshTb );
2685 createTool( 801, meshTb );
2686 createTool( 802, meshTb );
2687 createTool( 803, meshTb );
2688 createTool( separator(), meshTb );
2689 createTool( 900, meshTb );
2690 createTool( 902, meshTb );
2691 createTool( separator(), meshTb );
2693 createTool( 6001, ctrlTb );
2694 createTool( 6003, ctrlTb );
2695 createTool( 6004, ctrlTb );
2696 createTool( separator(), ctrlTb );
2697 createTool( 6002, ctrlTb );
2698 createTool( 6018, ctrlTb );
2699 createTool( 6019, ctrlTb );
2700 createTool( 6011, ctrlTb );
2701 createTool( 6012, ctrlTb );
2702 createTool( 6013, ctrlTb );
2703 createTool( 6014, ctrlTb );
2704 createTool( 6015, ctrlTb );
2705 createTool( 6016, ctrlTb );
2706 createTool( separator(), ctrlTb );
2707 createTool( 6017, ctrlTb );
2708 createTool( 6009, ctrlTb );
2709 createTool( separator(), ctrlTb );
2711 createTool( 400, addRemTb );
2712 createTool( 401, addRemTb );
2713 createTool( 4021, addRemTb );
2714 createTool( 4022, addRemTb );
2715 createTool( 4023, addRemTb );
2716 createTool( 4031, addRemTb );
2717 createTool( 4032, addRemTb );
2718 createTool( 4033, addRemTb );
2719 createTool( separator(), addRemTb );
2720 createTool( 4034, addRemTb );
2721 createTool( 4035, addRemTb );
2722 createTool( 4036, addRemTb );
2723 createTool( 4037, addRemTb );
2724 createTool( 4038, addRemTb );
2725 createTool( 4039, addRemTb );
2726 createTool( 4040, addRemTb );
2727 createTool( separator(), addRemTb );
2728 createTool( 4041, addRemTb );
2729 createTool( 4042, addRemTb );
2730 createTool( separator(), addRemTb );
2731 createTool( 4051, addRemTb );
2732 createTool( 4052, addRemTb );
2733 createTool( separator(), addRemTb );
2734 createTool( 4061, addRemTb );
2735 createTool( 4062, addRemTb );
2736 createTool( 4063, addRemTb );
2737 createTool( 4064, addRemTb );
2738 createTool( 4065, addRemTb );
2739 createTool( 4066, addRemTb );
2740 createTool( separator(), addRemTb );
2742 createTool( 406, modifyTb );
2743 createTool( 4067,modifyTb );
2744 createTool( 407, modifyTb );
2745 createTool( 408, modifyTb );
2746 createTool( 409, modifyTb );
2747 createTool( 410, modifyTb );
2748 createTool( 411, modifyTb );
2749 createTool( 412, modifyTb );
2750 createTool( 413, modifyTb );
2751 createTool( 416, modifyTb );
2752 createTool( 414, modifyTb );
2753 createTool( 415, modifyTb );
2754 createTool( 417, modifyTb );
2756 createTool( 214, dispModeTb );
2760 QString OB = "'ObjectBrowser'",
2761 View = "'" + SVTK_Viewer::Type() + "'",
2763 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2764 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2765 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2766 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2767 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2768 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2769 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2770 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2771 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2772 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2773 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2775 mesh_group = mesh + " " + subMesh + " " + group,
2776 hyp_alg = hypo + " " + algo;
2778 // popup for object browser
2780 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2781 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2782 createPopupItem( 803, OB, group ); // EDIT_GROUP
2783 popupMgr()->insert( separator(), -1, 0 );
2784 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2785 createPopupItem( 214, OB, mesh_group ); // UPDATE
2786 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2787 createPopupItem( 902, OB, mesh ); // STD_INFO
2788 popupMgr()->insert( separator(), -1, 0 );
2789 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2790 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2791 popupMgr()->insert( separator(), -1, 0 );
2792 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2793 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2794 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2795 popupMgr()->insert( separator(), -1, 0 );
2797 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2798 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2799 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2800 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2801 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2802 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2803 popupMgr()->insert( separator(), -1, 0 );
2806 createPopupItem( 803, View, group ); // EDIT_GROUP
2807 createPopupItem( 804, View, elems ); // ADD
2808 createPopupItem( 805, View, elems ); // REMOVE
2809 popupMgr()->insert( separator(), -1, 0 );
2810 createPopupItem( 214, View, mesh_group ); // UPDATE
2811 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2812 createPopupItem( 902, View, mesh ); // STD_INFO
2813 popupMgr()->insert( separator(), -1, 0 );
2815 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2816 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2817 popupMgr()->insert( separator(), -1, 0 );
2821 isInvisible("not( isVisible )"),
2822 isEmpty("numberOfNodes = 0"),
2823 isNotEmpty("numberOfNodes <> 0"),
2825 // has nodes, edges, etc in VISIBLE! actor
2826 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2827 hasElems("(count( elemTypes ) > 0)"),
2828 hasDifferentElems("(count( elemTypes ) > 1)"),
2829 hasEdges("({'Edge'} in elemTypes)"),
2830 hasFaces("({'Face'} in elemTypes)"),
2831 hasVolumes("({'Volume'} in elemTypes)");
2833 QString lc = QtxPopupMgr::Selection::defEquality();
2834 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2835 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2836 aType = aType.arg( mesh_group );
2837 QString aMeshInVTK = aClient + "&&" + aType;
2839 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2840 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2841 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2843 //-------------------------------------------------
2845 //-------------------------------------------------
2846 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2848 popupMgr()->insert( action( 9010 ), anId, -1 );
2849 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2850 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2852 popupMgr()->insert( action( 9011 ), anId, -1 );
2853 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2854 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2856 popupMgr()->insert( separator(), -1, -1 );
2858 //-------------------------------------------------
2860 //-------------------------------------------------
2861 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2863 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2864 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2865 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2867 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2868 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2869 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2871 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2872 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2873 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2875 popupMgr()->insert( separator(), anId, -1 );
2877 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2878 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2879 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2881 //-------------------------------------------------
2883 //-------------------------------------------------
2884 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2886 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2888 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2889 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2890 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2892 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2893 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2894 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2896 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2897 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2898 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2900 popupMgr()->insert( separator(), anId, -1 );
2902 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2903 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2905 //-------------------------------------------------
2907 //-------------------------------------------------
2908 popupMgr()->insert( action( 1132 ), -1, -1 );
2909 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2911 //-------------------------------------------------
2913 //-------------------------------------------------
2914 popupMgr()->insert( action( 1133 ), -1, -1 );
2915 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2917 //-------------------------------------------------
2919 //-------------------------------------------------
2920 popupMgr()->insert( action( 1134 ), -1, -1 );
2921 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2923 popupMgr()->insert( separator(), -1, -1 );
2925 //-------------------------------------------------
2927 //-------------------------------------------------
2929 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2930 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2931 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2933 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2935 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2936 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2938 popupMgr()->insert( separator(), anId, -1 );
2940 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2941 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2942 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2944 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2945 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2946 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2948 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2949 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2950 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2952 popupMgr()->insert( separator(), anId, -1 );
2954 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2955 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2956 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2958 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2959 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2960 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2962 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2963 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2964 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2966 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2967 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2968 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2970 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2971 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2972 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2974 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2975 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2976 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2978 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2979 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2980 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2982 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2983 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2984 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2986 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2987 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2988 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2990 popupMgr()->insert( separator(), anId, -1 );
2992 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2993 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2994 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2996 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2997 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2998 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
3000 popupMgr()->insert( separator(), anId, -1 );
3002 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3003 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
3005 popupMgr()->insert( separator(), -1, -1 );
3007 //-------------------------------------------------
3009 //-------------------------------------------------
3010 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3011 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3012 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3013 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3015 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3016 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3018 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3019 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3021 popupMgr()->insert( separator(), -1, -1 );
3023 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3024 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3027 bool SMESHGUI::activateModule( SUIT_Study* study )
3029 bool res = SalomeApp_Module::activateModule( study );
3031 setMenuShown( true );
3032 setToolShown( true );
3034 // Reset actions accelerator keys
3035 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3036 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3037 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3042 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3044 setMenuShown( false );
3045 setToolShown( false );
3047 EmitSignalCloseAllDialogs();
3049 // Unset actions accelerator keys
3050 action(111)->setAccel(QKeySequence()); // Import DAT
3051 action(112)->setAccel(QKeySequence()); // Import UNV
3052 action(113)->setAccel(QKeySequence()); // Import MED
3054 return SalomeApp_Module::deactivateModule( study );
3057 void SMESHGUI::studyClosed( SUIT_Study* s )
3059 SMESH::RemoveVisuData( s->id() );
3060 SalomeApp_Module::studyClosed( s );
3063 void SMESHGUI::OnGUIEvent()
3065 const QObject* obj = sender();
3066 if ( !obj || !obj->inherits( "QAction" ) )
3068 int id = actionId((QAction*)obj);
3073 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3075 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3076 if ( CORBA::is_nil( myComponentSMESH ) )
3078 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3080 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3081 return aGUI.myComponentSMESH;
3084 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3085 return myComponentSMESH;
3088 QString SMESHGUI::engineIOR() const
3090 CORBA::ORB_var anORB = getApp()->orb();
3091 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3092 return QString( anIOR.in() );
3095 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3097 SMESHGUI_Selection sel;
3098 sel.init( client, selectionMgr() );
3099 popupMgr()->updatePopup( menu, &sel );
3102 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3104 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3105 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3108 void SMESHGUI::viewManagers( QStringList& list ) const
3110 list.append( SVTK_Viewer::Type() );
3113 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3115 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3116 SMESH::UpdateSelectionProp( this );
3119 void SMESHGUI::createPreferences()
3121 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3123 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3124 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3126 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3127 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3128 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3130 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3131 setPreferenceProperty( precGroup, "columns", 1 );
3133 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3135 setPreferenceProperty( prec, "min", 0 );
3136 setPreferenceProperty( prec, "max", 16 );
3138 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3139 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3141 modes.append( "Wireframe" );
3142 modes.append( "Shading" );
3143 modes.append( "Nodes" );
3144 modes.append( "Shrink" );
3145 QValueList<QVariant> indices;
3146 indices.append( 0 );
3147 indices.append( 1 );
3148 indices.append( 2 );
3149 indices.append( 3 );
3150 setPreferenceProperty( dispmode, "strings", modes );
3151 setPreferenceProperty( dispmode, "indexes", indices );
3153 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3154 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3155 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3157 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3158 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3160 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3161 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3163 setPreferenceProperty( nodeSz, "min", 1 );
3164 setPreferenceProperty( nodeSz, "max", 5 );
3166 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3168 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3169 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3170 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3171 addPreference( "", elemGroup, LightApp_Preferences::Space );
3173 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3174 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3176 setPreferenceProperty( elemW, "min", 1 );
3177 setPreferenceProperty( elemW, "max", 5 );
3179 setPreferenceProperty( shrink, "min", 0 );
3180 setPreferenceProperty( shrink, "max", 100 );
3182 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3184 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3186 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3187 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3188 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3190 setPreferenceProperty( selW, "min", 1 );
3191 setPreferenceProperty( selW, "max", 5 );
3193 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3195 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3196 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3198 setPreferenceProperty( preW, "min", 1 );
3199 setPreferenceProperty( preW, "max", 5 );
3201 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3203 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3204 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3205 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3207 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3208 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3210 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3211 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3212 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3213 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3216 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3217 fam.append( tr( "SMESH_FONT_COURIER" ) );
3218 fam.append( tr( "SMESH_FONT_TIMES" ) );
3219 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3221 setPreferenceProperty( tfont, "families", fam );
3222 setPreferenceProperty( tfont, "system", false );
3223 setPreferenceProperty( tfont, "widget_flags", wflag );
3224 setPreferenceProperty( lfont, "families", fam );
3225 setPreferenceProperty( lfont, "system", false );
3226 setPreferenceProperty( lfont, "widget_flags", wflag );
3228 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3230 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3231 setPreferenceProperty( numcol, "min", 2 );
3232 setPreferenceProperty( numcol, "max", 256 );
3234 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3235 setPreferenceProperty( numlab, "min", 2 );
3236 setPreferenceProperty( numlab, "max", 65 );
3238 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3239 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3240 QStringList orients;
3241 orients.append( tr( "SMESH_VERTICAL" ) );
3242 orients.append( tr( "SMESH_HORIZONTAL" ) );
3243 indices.clear(); indices.append( 0 ); indices.append( 1 );
3244 setPreferenceProperty( orient, "strings", orients );
3245 setPreferenceProperty( orient, "indexes", indices );
3247 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3248 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3249 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3250 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3251 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3252 setPreferenceProperty( xv, "step", 0.1 );
3253 setPreferenceProperty( xv, "min", 0.0 );
3254 setPreferenceProperty( xv, "max", 1.0 );
3255 setPreferenceProperty( yv, "step", 0.1 );
3256 setPreferenceProperty( yv, "min", 0.0 );
3257 setPreferenceProperty( yv, "max", 1.0 );
3258 setPreferenceProperty( wv, "step", 0.1 );
3259 setPreferenceProperty( wv, "min", 0.0 );
3260 setPreferenceProperty( wv, "max", 1.0 );
3261 setPreferenceProperty( hv, "min", 0.0 );
3262 setPreferenceProperty( hv, "max", 1.0 );
3263 setPreferenceProperty( hv, "step", 0.1 );
3265 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3266 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3267 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3268 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3269 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3270 setPreferenceProperty( xv, "min", 0.0 );
3271 setPreferenceProperty( xv, "max", 1.0 );
3272 setPreferenceProperty( xv, "step", 0.1 );
3273 setPreferenceProperty( xh, "min", 0.0 );
3274 setPreferenceProperty( xh, "max", 1.0 );
3275 setPreferenceProperty( xh, "step", 0.1 );
3276 setPreferenceProperty( yh, "min", 0.0 );
3277 setPreferenceProperty( yh, "max", 1.0 );
3278 setPreferenceProperty( yh, "step", 0.1 );
3279 setPreferenceProperty( wh, "min", 0.0 );
3280 setPreferenceProperty( wh, "max", 1.0 );
3281 setPreferenceProperty( wh, "step", 0.1 );
3282 setPreferenceProperty( hh, "min", 0.0 );
3283 setPreferenceProperty( hh, "max", 1.0 );
3284 setPreferenceProperty( hh, "step", 0.1 );
3287 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3289 if( sect=="SMESH" ){
3290 float sbX1,sbY1,sbW,sbH;
3291 float aTol = 1.00000009999999;
3292 std::string aWarning;
3293 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3294 if( name=="selection_object_color" || name=="selection_element_color" ||
3295 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3296 name=="selection_precision_node" || name=="selection_precision_element" ||
3297 name=="selection_precision_object")
3298 SMESH::UpdateSelectionProp( this );
3299 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3300 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3301 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3302 if(sbX1+sbW > aTol){
3303 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3306 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3307 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3310 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3311 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3312 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3313 if(sbY1+sbH > aTol){
3314 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3315 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3316 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3319 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3320 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3321 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3322 if(sbX1+sbW > aTol){
3323 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3326 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3327 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3330 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3331 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3332 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3333 if(sbY1+sbH > aTol){
3334 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3337 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3338 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3342 if(aWarning.size() != 0){
3343 aWarning += "The default values are applied instead.";
3344 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3345 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3346 QObject::tr(aWarning.c_str()),
3347 QObject::tr("SMESH_BUT_OK"));
3352 //================================================================================
3354 * \brief Update something in accordance with update flags
3355 * \param theFlags - update flags
3357 * Update viewer or/and object browser etc. in accordance with update flags ( see
3358 * LightApp_UpdateFlags enumeration ).
3360 //================================================================================
3361 void SMESHGUI::update( const int flags )
3363 if ( flags & UF_Viewer | flags & UF_Forced )
3364 SMESH::UpdateView();
3366 SalomeApp_Module::update( flags );
3369 //================================================================================
3371 * \brief Set default selection mode
3373 * SLOT called when operation commited. Sets default selection mode
3375 //================================================================================
3376 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3378 SVTK_ViewWindow* vtkWnd =
3379 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3381 vtkWnd->SetSelectionMode( ActorSelection );
3384 //================================================================================
3386 * \brief Set default selection mode
3388 * SLOT called when operation aborted. Sets default selection mode
3390 //================================================================================
3391 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3393 SVTK_ViewWindow* vtkWnd =
3394 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3396 vtkWnd->SetSelectionMode( ActorSelection );
3399 //================================================================================
3401 * \brief Creates operation with given identifier
3402 * \param id - identifier of operation to be started
3403 * \return Pointer on created operation or NULL if operation is not created
3405 * Virtual method redefined from the base class creates operation with given id.
3406 * It is called called automatically from startOperation method of base class.
3408 //================================================================================
3409 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3411 LightApp_Operation* op = 0;
3412 // to do : create operation here
3415 case 701: // Compute mesh
3416 op = new SMESHGUI_ComputeOp();
3418 case 702: // Create mesh
3419 op = new SMESHGUI_MeshOp( true, true );
3421 case 703: // Create sub-mesh
3422 op = new SMESHGUI_MeshOp( true, false );
3424 case 704: // Edit mesh/sub-mesh
3425 op = new SMESHGUI_MeshOp( false );
3427 case 417: //convert to quadratic
3428 op = new SMESHGUI_ConvToQuadOp();
3430 case 4067: // make mesh pass through point
3431 op = new SMESHGUI_MakeNodeAtPointOp();
3438 op = SalomeApp_Module::createOperation( id );
3442 //================================================================================
3444 * \brief Stops current operations and starts a given one
3445 * \param id - The id of the operation to start
3447 //================================================================================
3449 void SMESHGUI::switchToOperation(int id)
3451 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3452 activeStudy()->abortAllOperations();
3453 startOperation( id );
3456 LightApp_Displayer* SMESHGUI::displayer()
3459 myDisplayer = new SMESHGUI_Displayer( getApp() );
3463 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3466 int aTolerance = 64;
3467 int anIterations = 0;
3473 if( anIterations % aPeriod == 0 )
3476 if( aTolerance < 1 )
3479 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3481 aHue = (int)( 360.0 * rand() / RAND_MAX );
3482 //cout << "Hue = " << aHue << endl;
3484 //cout << "Auto colors : ";
3486 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3487 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3488 for( ; it != itEnd; ++it )
3490 SALOMEDS::Color anAutoColor = *it;
3491 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3494 aQColor.getHsv( &h, &s, &v );
3496 if( abs( h - aHue ) < aTolerance )
3499 //cout << "break (diff = " << abs( h - aHue ) << ")";
3509 //cout << "Hue of the returned color = " << aHue << endl;
3511 aColor.setHsv( aHue, 255, 255 );
3513 SALOMEDS::Color aSColor;
3514 aSColor.R = (double)aColor.red() / 255.0;
3515 aSColor.G = (double)aColor.green() / 255.0;
3516 aSColor.B = (double)aColor.blue() / 255.0;