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, Open CASCADE S.A.S.
28 #include "SMESHGUI_NodesDlg.h"
29 #include "SMESHGUI_TransparencyDlg.h"
30 #include "SMESHGUI_ClippingDlg.h"
31 #include "SMESHGUI_GroupDlg.h"
32 #include "SMESHGUI_RemoveNodesDlg.h"
33 #include "SMESHGUI_RemoveElementsDlg.h"
34 #include "SMESHGUI_MeshInfosDlg.h"
35 #include "SMESHGUI_StandardMeshInfosDlg.h"
36 #include "SMESHGUI_WhatIsDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_MoveNodesDlg.h"
41 #include "SMESHGUI_AddMeshElementDlg.h"
42 #include "SMESHGUI_AddQuadraticElementDlg.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_SingleEditDlg.h"
46 #include "SMESHGUI_MultiEditDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_DeleteGroupDlg.h"
49 #include "SMESHGUI_SmoothingDlg.h"
50 #include "SMESHGUI_RenumberingDlg.h"
51 #include "SMESHGUI_ExtrusionDlg.h"
52 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
53 #include "SMESHGUI_RevolutionDlg.h"
54 #include "SMESHGUI_TranslationDlg.h"
55 #include "SMESHGUI_RotationDlg.h"
56 #include "SMESHGUI_SymmetryDlg.h"
57 #include "SMESHGUI_SewingDlg.h"
58 #include "SMESHGUI_EditMeshDlg.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_Selection.h"
61 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
62 #include "SMESHGUI_ConvToQuadOp.h"
63 #include "SMESHGUI_MeshOp.h"
64 #include "SMESHGUI_Displayer.h"
65 #include "SMESHGUI_MakeNodeAtPointDlg.h"
66 #include "SMESHGUI_BuildCompoundDlg.h"
67 #include "SMESHGUI_ComputeDlg.h"
68 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include <SMESH_Client.hxx>
79 #include <SMESH_Actor.h>
80 #include <SMESH_TypeFilter.hxx>
82 // SALOME GUI includes
83 #include <SalomeApp_Tools.h>
84 #include <SalomeApp_Study.h>
85 #include <SalomeApp_Application.h>
86 #include <SalomeApp_CheckFileDlg.h>
88 #include <LightApp_DataOwner.h>
89 #include <LightApp_Preferences.h>
90 #include <LightApp_SelectionMgr.h>
91 #include <LightApp_UpdateFlags.h>
92 #include <LightApp_NameDlg.h>
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_ViewManager.h>
98 #include <SUIT_MessageBox.h>
99 #include <SUIT_ResourceMgr.h>
100 #include <SUIT_FileDlg.h>
101 #include <SUIT_Desktop.h>
102 #include <SUIT_OverrideCursor.h>
103 #include <SUIT_Session.h>
105 #include <QtxPopupMgr.h>
106 #include <QtxFontEdit.h>
108 #include <SALOME_ListIO.hxx>
109 #include <SALOME_ListIteratorOfListIO.hxx>
112 #include <SALOMEconfig.h>
113 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
114 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
117 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
121 #include <boost/shared_ptr.hpp>
124 #include <vtkScalarBarActor.h>
126 // SALOME KERNEL includes
127 #include <SALOMEDS_Study.hxx>
128 #include <SALOMEDSClient_StudyBuilder.hxx>
129 #include <SALOMEDSClient_SComponent.hxx>
132 #include <Standard_ErrorHandler.hxx>
136 //=============================================================
137 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
140 void ExportMeshToFile(int theCommandID);
142 void SetDisplayMode(int theCommandID);
144 void SetDisplayEntity(int theCommandID);
146 void Control( int theCommandID );
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
155 std::string myExtension;
157 if(theCommandID == 113){
158 filter.append(QObject::tr("MED files (*.med)"));
159 filter.append(QObject::tr("All files (*)"));
160 }else if (theCommandID == 112){
161 filter.append(QObject::tr("IDEAS files (*.unv)"));
162 }else if (theCommandID == 111){
163 filter.append(QObject::tr("DAT files (*.dat)"));
165 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
168 QObject::tr("Import mesh"),
170 if(!filename.isEmpty()) {
171 SUIT_OverrideCursor wc;
172 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
175 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
176 switch ( theCommandID ) {
179 aMeshes->length( 1 );
180 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.toLatin1().data());
185 SMESH::DriverMED_ReadStatus res;
186 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.toLatin1().data(),res);
187 if ( res != SMESH::DRS_OK ) {
189 SUIT_MessageBox::warning(SMESHGUI::desktop(),
190 QObject::tr("SMESH_WRN_WARNING"),
191 QObject::tr(QString("SMESH_DRS_%1").arg(res).
193 aMeshes->length( 0 );
200 bool isEmpty = false;
201 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
202 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
204 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
205 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
206 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
207 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
208 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
215 SUIT_MessageBox::warning(SMESHGUI::desktop(),
216 QObject::tr("SMESH_WRN_WARNING"),
217 QObject::tr("SMESH_DRS_EMPTY"));
221 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
223 catch (const SALOME::SALOME_Exception& S_ex){
225 SalomeApp_Tools::QtCatchCorbaException(S_ex);
232 void ExportMeshToFile( int theCommandID )
234 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
235 SALOME_ListIO selected;
237 aSel->selectedObjects( selected );
239 if(selected.Extent()){
240 Handle(SALOME_InteractiveObject) anIObject = selected.First();
241 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
242 if ( !aMesh->_is_nil() ) {
243 QString aFilter, aTitle = QObject::tr("Export mesh");
244 QMap<QString, SMESH::MED_VERSION> aFilterMap;
245 QMap<QString, int> aFilterMapSTL;
246 switch ( theCommandID ) {
250 if (aMesh->HasDuplicatedGroupNamesMED()) {
251 int aRet = SUIT_MessageBox::warning
252 (SMESHGUI::desktop(),
253 QObject::tr("SMESH_WRN_WARNING"),
254 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
255 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
256 if (aRet != SUIT_MessageBox::Yes)
260 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
261 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
262 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
263 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
268 aFilter = QObject::tr("DAT files (*.dat)");
273 if (aMesh->NbPyramids()) {
274 int aRet = SUIT_MessageBox::warning
275 (SMESHGUI::desktop(),
276 QObject::tr("SMESH_WRN_WARNING"),
277 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
278 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
279 if (aRet != SUIT_MessageBox::Yes)
282 aFilter = QObject::tr("IDEAS files (*.unv)");
290 there must be check on others mesh elements not equal triangles
292 if (aMesh->NbTriangles() < 1) {
293 SUIT_MessageBox::warning
294 (SMESHGUI::desktop(),
295 QObject::tr("SMESH_WRN_WARNING"),
296 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
299 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
300 int aRet = SUIT_MessageBox::warning
301 (SMESHGUI::desktop(),
302 QObject::tr("SMESH_WRN_WARNING"),
303 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
304 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
305 if (aRet != SUIT_MessageBox::Yes)
309 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
310 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
318 SMESH::MED_VERSION aFormat;
319 // Init the parameter with the default value
320 bool aIsASCII_STL = true;
321 bool toCreateGroups = false;
322 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
324 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
326 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
328 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
330 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
332 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
333 for ( ; it != aFilterMapSTL.end(); ++it )
334 filters.push_back( it.key() );
336 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
337 fd->setWindowTitle( aTitle );
338 fd->setFilters( filters );
339 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
343 aFilename = fd->selectedFile();
344 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
351 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
352 for ( ; it != aFilterMap.end(); ++it )
353 filters.push_back( it.key() );
355 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
356 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
357 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
358 fd->setWindowTitle( aTitle );
359 fd->setFilters( filters );
360 //fd->selectFilter( QObject::tr("MED 2.2 (*.med)") );
361 fd->selectFilter( filters.last() );
362 fd->SetChecked(toCreateGroups);
366 aFilename = fd->selectedFile();
367 aFormat = aFilterMap[fd->selectedFilter()];
369 if ( !aFilename.isEmpty()
370 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
371 && aFormat==SMESH::MED_V2_1) {
372 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
373 QObject::tr("SMESH_WRN_WARNING"),
374 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
375 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
376 if (aRet != SUIT_MessageBox::Yes) {
381 toCreateGroups = fd->IsChecked();
384 if ( !aFilename.isEmpty() ) {
385 // Check whether the file already exists and delete it if yes
386 QFile aFile( aFilename );
387 if ( aFile.exists() )
389 SUIT_OverrideCursor wc;
392 bool Renumber = false;
393 // PAL 14172 : Check of we have to renumber or not from the preferences before export
395 Renumber= resMgr->booleanValue("SMESH","renumbering");
397 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
398 aMeshEditor->RenumberNodes();
399 aMeshEditor->RenumberElements();
400 if ( SMESHGUI::automaticUpdate() )
403 switch ( theCommandID ) {
406 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
410 aMesh->ExportDAT( aFilename.toLatin1().data() );
414 aMesh->ExportUNV( aFilename.toLatin1().data() );
418 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
424 catch (const SALOME::SALOME_Exception& S_ex){
426 SUIT_MessageBox::warning(SMESHGUI::desktop(),
427 QObject::tr("SMESH_WRN_WARNING"),
428 QObject::tr("SMESH_EXPORT_FAILED"));
436 inline void InverseEntityMode(unsigned int& theOutputMode,
437 unsigned int theMode)
439 bool anIsNotPresent = ~theOutputMode & theMode;
441 theOutputMode |= theMode;
443 theOutputMode &= ~theMode;
446 void SetDisplayEntity(int theCommandID){
447 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
448 SALOME_ListIO selected;
450 aSel->selectedObjects( selected );
452 if(selected.Extent() >= 1){
453 SALOME_ListIteratorOfListIO It( selected );
454 for( ; It.More(); It.Next()){
455 Handle(SALOME_InteractiveObject) IObject = It.Value();
456 if(IObject->hasEntry()){
457 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
458 unsigned int aMode = anActor->GetEntityMode();
459 switch(theCommandID){
461 InverseEntityMode(aMode,SMESH_Actor::eEdges);
464 InverseEntityMode(aMode,SMESH_Actor::eFaces);
467 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
470 aMode = SMESH_Actor::eAllEntity;
474 anActor->SetEntityMode(aMode);
482 SALOME_ListIO selected;
483 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
487 LightApp_SelectionMgr* aSel = app->selectionMgr();
488 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
489 if( !aSel || !appStudy )
492 aSel->selectedObjects( selected );
493 if( selected.IsEmpty() )
496 Handle(SALOME_InteractiveObject) anIObject = selected.First();
498 _PTR(Study) aStudy = appStudy->studyDS();
499 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
500 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
501 if( aMainObject->_is_nil() )
504 aMainObject->SetAutoColor( true );
506 QList<SALOMEDS::Color> aReservedColors;
508 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
509 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
511 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
512 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
514 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
515 aGroupObject->SetColor( aColor );
516 aReservedColors.append( aColor );
518 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
519 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
521 if( aGroupObject->GetType() == SMESH::NODE )
522 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
523 else if( aGroupObject->GetType() == SMESH::EDGE )
524 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
526 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
530 SMESH::RepaintCurrentView();
533 void DisableAutoColor(){
534 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
535 SALOME_ListIO selected;
537 aSel->selectedObjects( selected );
539 if(selected.Extent()){
540 Handle(SALOME_InteractiveObject) anIObject = selected.First();
541 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
542 if ( !aMesh->_is_nil() ) {
543 aMesh->SetAutoColor( false );
548 void SetDisplayMode(int theCommandID){
549 SALOME_ListIO selected;
550 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
554 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
555 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
556 if( !aSel || !appStudy )
559 _PTR(Study) aStudy = appStudy->studyDS();
561 aSel->selectedObjects( selected );
563 if(selected.Extent() >= 1){
564 switch(theCommandID){
566 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
567 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
571 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
572 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
575 SALOME_ListIteratorOfListIO It( selected );
576 for( ; It.More(); It.Next()){
577 Handle(SALOME_InteractiveObject) IObject = It.Value();
578 if(IObject->hasEntry()){
579 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
580 switch(theCommandID){
582 anActor->SetRepresentation(SMESH_Actor::eEdge);
585 anActor->SetRepresentation(SMESH_Actor::eSurface);
588 if(anActor->IsShrunk())
591 anActor->SetShrink();
594 anActor->SetRepresentation(SMESH_Actor::ePoint);
597 vtkFloatingPointType color[3];
598 anActor->GetSufaceColor(color[0], color[1], color[2]);
599 int c0 = int (color[0] * 255);
600 int c1 = int (color[1] * 255);
601 int c2 = int (color[2] * 255);
602 QColor c(c0, c1, c2);
604 vtkFloatingPointType edgecolor[3];
605 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
606 c0 = int (edgecolor[0] * 255);
607 c1 = int (edgecolor[1] * 255);
608 c2 = int (edgecolor[2] * 255);
609 QColor e(c0, c1, c2);
611 vtkFloatingPointType backfacecolor[3];
612 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
613 c0 = int (backfacecolor[0] * 255);
614 c1 = int (backfacecolor[1] * 255);
615 c2 = int (backfacecolor[2] * 255);
616 QColor b(c0, c1, c2);
618 vtkFloatingPointType nodecolor[3];
619 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
620 c0 = int (nodecolor[0] * 255);
621 c1 = int (nodecolor[1] * 255);
622 c2 = int (nodecolor[2] * 255);
623 QColor n(c0, c1, c2);
625 int Edgewidth = (int)anActor->GetLineWidth();
628 int intValue = int(anActor->GetNodeSize());
629 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
631 SMESHGUI_Preferences_ColorDlg *aDlg =
632 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
633 aDlg->SetColor(1, c);
634 aDlg->SetColor(2, e);
635 aDlg->SetColor(3, n);
636 aDlg->SetColor(4, b);
637 aDlg->SetIntValue(1, Edgewidth);
638 aDlg->SetIntValue(2, intValue);
639 aDlg->SetIntValue(3, int(Shrink*100.));
641 QColor color = aDlg->GetColor(1);
642 QColor edgecolor = aDlg->GetColor(2);
643 QColor nodecolor = aDlg->GetColor(3);
644 QColor backfacecolor = aDlg->GetColor(4);
645 /* actor color and backface color */
646 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
647 vtkFloatingPointType (color.green()) / 255.,
648 vtkFloatingPointType (color.blue()) / 255.);
649 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
650 vtkFloatingPointType (backfacecolor.green()) / 255.,
651 vtkFloatingPointType (backfacecolor.blue()) / 255.);
654 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
655 vtkFloatingPointType (edgecolor.green()) / 255.,
656 vtkFloatingPointType (edgecolor.blue()) / 255.);
658 /* Shrink factor and size edges */
659 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
660 anActor->SetLineWidth(aDlg->GetIntValue(1));
662 /* Nodes color and size */
663 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
664 vtkFloatingPointType (nodecolor.green()) / 255.,
665 vtkFloatingPointType (nodecolor.blue()) / 255.);
666 anActor->SetNodeSize(aDlg->GetIntValue(2));
668 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
669 if( !aGroupObject->_is_nil() )
671 SALOMEDS::Color aColor;
672 aColor.R = (float)color.red() / 255.0;
673 aColor.G = (float)color.green() / 255.0;
674 aColor.B = (float)color.blue() / 255.0;
675 aGroupObject->SetColor( aColor );
685 SMESH::RepaintCurrentView();
689 void Control( int theCommandID )
691 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
692 SALOME_ListIO selected;
694 aSel->selectedObjects( selected );
696 if( !selected.IsEmpty() ){
697 Handle(SALOME_InteractiveObject) anIO = selected.First();
700 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
701 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
702 switch ( theCommandID ){
704 aTitle = QObject::tr( "LENGTH_EDGES" );
705 aControl = SMESH_Actor::eLength;
708 aTitle = QObject::tr( "LENGTH2D_EDGES" );
709 aControl = SMESH_Actor::eLength2D;
712 aTitle = QObject::tr( "FREE_EDGES" );
713 aControl = SMESH_Actor::eFreeEdges;
716 aTitle = QObject::tr( "FREE_BORDERS" );
717 aControl = SMESH_Actor::eFreeBorders;
720 aTitle = QObject::tr( "MULTI_BORDERS" );
721 aControl = SMESH_Actor::eMultiConnection;
724 aTitle = QObject::tr( "MULTI2D_BORDERS" );
725 aControl = SMESH_Actor::eMultiConnection2D;
728 aTitle = QObject::tr( "AREA_ELEMENTS" );
729 aControl = SMESH_Actor::eArea;
732 aTitle = QObject::tr( "TAPER_ELEMENTS" );
733 aControl = SMESH_Actor::eTaper;
736 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
737 aControl = SMESH_Actor::eAspectRatio;
740 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
741 aControl = SMESH_Actor::eAspectRatio3D;
744 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
745 aControl = SMESH_Actor::eMinimumAngle;
748 aTitle = QObject::tr( "WARP_ELEMENTS" );
749 aControl = SMESH_Actor::eWarping;
752 aTitle = QObject::tr( "SKEW_ELEMENTS" );
753 aControl = SMESH_Actor::eSkew;
756 aTitle = QObject::tr( "SMESH_VOLUME" );
757 aControl = SMESH_Actor::eVolume3D;
760 anActor->SetControlMode(aControl);
761 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
762 SMESH::RepaintCurrentView();
769 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
770 MeshObjectType theType,
771 const QString theInTypeName,
772 QString & theOutTypeName)
774 SMESH_TypeFilter aTypeFilter( theType );
776 if( !theIO.IsNull() )
778 entry = theIO->getEntry();
779 LightApp_DataOwner owner( entry );
780 if ( aTypeFilter.isOk( &owner )) {
781 theOutTypeName = theInTypeName;
789 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
791 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
792 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
794 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
795 CORBA::String_var anID = aSComp->GetID().c_str();
796 if (!strcmp(anID.in(),theIO->getEntry()))
802 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
803 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
804 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
805 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
806 CheckOIType ( theIO, GROUP, "Group", aTypeName )
814 QString CheckHomogeneousSelection()
816 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
817 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
818 SALOME_ListIO selected;
820 aSel->selectedObjects( selected );
822 QString RefType = CheckTypeObject(selected.First());
823 SALOME_ListIteratorOfListIO It(selected);
824 for ( ; It.More(); It.Next())
826 Handle(SALOME_InteractiveObject) IObject = It.Value();
827 QString Type = CheckTypeObject(IObject);
828 if (Type.compare(RefType) != 0)
829 return "Heterogeneous Selection";
836 void SMESHGUI::OnEditDelete()
838 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
839 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
840 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
842 QString aParentComponent = QString::null;
843 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
845 QString cur = anIt.Value()->getComponentDataType();
846 if( aParentComponent.isNull() )
847 aParentComponent = cur;
848 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
849 aParentComponent = "";
852 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
853 SUIT_MessageBox::warning( SMESHGUI::desktop(),
854 QObject::tr("ERR_ERROR"),
855 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
858 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
859 if (SUIT_MessageBox::warning
860 (SMESHGUI::desktop(),
861 QObject::tr("SMESH_WRN_WARNING"),
862 QObject::tr("SMESH_REALLY_DELETE"),
863 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
864 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
867 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
868 SUIT_ViewManager* vm = anApp->activeViewManager();
869 int nbSf = vm->getViewsCount();
871 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
872 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
873 _PTR(GenericAttribute) anAttr;
874 _PTR(AttributeIOR) anIOR;
876 SALOME_ListIteratorOfListIO It(selected);
878 aStudyBuilder->NewCommand(); // There is a transaction
879 for( ; It.More(); It.Next()){ // loop on selected IO's
880 Handle(SALOME_InteractiveObject) IObject = It.Value();
881 if(IObject->hasEntry()) {
882 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
884 // disable removal of "SMESH" component object
885 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
887 if ( engineIOR() == anIOR->Value().c_str() )
891 // put the whole hierarchy of sub-objects of the selected SO into a list and
892 // then treat them all starting from the deepest objects (at list back)
894 std::list< _PTR(SObject) > listSO;
895 listSO.push_back( aSO );
896 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
897 for ( ; itSO != listSO.end(); ++itSO ) {
898 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
899 for (it->InitEx(false); it->More(); it->Next())
900 listSO.push_back( it->Value() );
903 // treat SO's in the list starting from the back
905 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
906 for ( ; ritSO != listSO.rend(); ++ritSO ) {
907 _PTR(SObject) SO = *ritSO;
909 std::string anEntry = SO->GetID();
911 /** Erase graphical object **/
912 if(SO->FindAttribute(anAttr, "AttributeIOR")){
913 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
914 for(int i = 0; i < nbSf; i++){
915 SUIT_ViewWindow *sf = aViews[i];
916 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
917 SMESH::RemoveActor(sf,anActor);
922 /** Remove an object from data structures **/
923 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
924 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
925 if ( !aGroup->_is_nil() ) { // DELETE GROUP
926 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
927 aMesh->RemoveGroup( aGroup );
929 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
930 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
931 aMesh->RemoveSubMesh( aSubMesh );
933 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
935 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
938 IObject = new SALOME_InteractiveObject
939 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
940 QString objType = CheckTypeObject(IObject);
941 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
942 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
943 aStudyBuilder->RemoveObjectWithChildren( SO );
945 else {// default action: remove SObject from the study
946 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
947 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
949 aStudyBuilder->RemoveObjectWithChildren( SO );
953 } /* listSO back loop */
954 } /* IObject->hasEntry() */
956 aStudyBuilder->CommitCommand();
958 /* Clear any previous selection */
960 aSel->setSelectedObjects( l1 );
962 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
967 SMESHGUI_EXPORT CAM_Module* createModule()
969 return new SMESHGUI();
973 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
975 //=============================================================================
979 //=============================================================================
980 SMESHGUI::SMESHGUI() :
981 SalomeApp_Module( "SMESH" )
983 if ( CORBA::is_nil( myComponentSMESH ) )
985 CORBA::Boolean anIsEmbeddedMode;
986 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
989 myActiveDialogBox = 0;
990 myFilterLibraryDlg = 0;
994 SMESH::GetFilterManager();
997 /* load resources for all available meshers */
998 SMESH::InitAvailableHypotheses();
1001 //=============================================================================
1005 //=============================================================================
1006 SMESHGUI::~SMESHGUI()
1008 SMESH::GetFilterManager()->Destroy();
1009 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1012 //=============================================================================
1016 //=============================================================================
1017 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1019 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1021 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1026 bool SMESHGUI::automaticUpdate()
1028 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1032 return resMgr->booleanValue( "SMESH", "auto_update", false );
1035 //=============================================================================
1039 //=============================================================================
1040 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1042 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1045 //=============================================================================
1049 //=============================================================================
1050 SMESHGUI* SMESHGUI::GetSMESHGUI()
1052 SMESHGUI* smeshMod = 0;
1053 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1056 CAM_Module* module = app->module( "Mesh" );
1057 smeshMod = dynamic_cast<SMESHGUI*>( module );
1060 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1062 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1065 _PTR(Study) aStudy = study->studyDS();
1067 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1076 Standard_EXPORT SMESHGUI* GetComponentGUI()
1078 return SMESHGUI::GetSMESHGUI();
1082 //=============================================================================
1086 //=============================================================================
1087 void SMESHGUI::SetState(int aState)
1092 //=============================================================================
1096 //=============================================================================
1097 void SMESHGUI::ResetState()
1102 //=============================================================================
1106 //=============================================================================
1107 void SMESHGUI::EmitSignalDeactivateDialog()
1109 emit SignalDeactivateActiveDialog();
1112 //=============================================================================
1116 //=============================================================================
1117 void SMESHGUI::EmitSignalStudyFrameChanged()
1119 emit SignalStudyFrameChanged();
1122 //=============================================================================
1126 //=============================================================================
1127 void SMESHGUI::EmitSignalCloseAllDialogs()
1129 emit SignalCloseAllDialogs();
1132 //=============================================================================
1136 //=============================================================================
1137 QDialog *SMESHGUI::GetActiveDialogBox()
1139 return myActiveDialogBox;
1142 //=============================================================================
1146 //=============================================================================
1147 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1149 myActiveDialogBox = (QDialog *) aDlg;
1153 //=============================================================================
1157 //=============================================================================
1158 SUIT_Desktop* SMESHGUI::desktop()
1160 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1162 return app->desktop();
1167 //=============================================================================
1171 //=============================================================================
1172 SalomeApp_Study* SMESHGUI::activeStudy()
1174 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1176 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1181 //=============================================================================
1185 //=============================================================================
1186 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1188 /* Here the position is on the bottom right corner - 10 */
1189 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1191 SUIT_Desktop *PP = desktop();
1192 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1193 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1197 //=============================================================================
1201 //=============================================================================
1202 static int isStudyLocked(_PTR(Study) theStudy){
1203 return theStudy->GetProperties()->IsLocked();
1206 static bool checkLock(_PTR(Study) theStudy) {
1207 if (isStudyLocked(theStudy)) {
1208 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1209 QObject::tr("WRN_WARNING"),
1210 QObject::tr("WRN_STUDY_LOCKED") );
1216 //=======================================================================
1217 //function : CheckActiveStudyLocked
1219 //=======================================================================
1221 bool SMESHGUI::isActiveStudyLocked()
1223 _PTR(Study) aStudy = activeStudy()->studyDS();
1224 return checkLock( aStudy );
1227 //=============================================================================
1231 //=============================================================================
1232 bool SMESHGUI::OnGUIEvent( int theCommandID )
1234 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1238 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1239 SUIT_ResourceMgr* mgr = resourceMgr();
1243 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1244 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1247 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1248 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1250 //QAction* act = action( theCommandID );
1252 switch (theCommandID) {
1254 if(checkLock(aStudy)) break;
1262 if(checkLock(aStudy)) break;
1263 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1267 case 150: //MED FILE INFORMATION
1269 SALOME_ListIO selected;
1270 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1272 aSel->selectedObjects( selected );
1273 if( selected.Extent() )
1275 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1276 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1277 if ( !aMesh->_is_nil() )
1279 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1286 case 122: // EXPORT MED
1295 ::ExportMeshToFile(theCommandID);
1299 case 200: // SCALAR BAR
1301 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1302 SALOME_ListIO selected;
1304 aSel->selectedObjects( selected );
1306 if( selected.Extent() ) {
1307 Handle(SALOME_InteractiveObject) anIO = selected.First();
1308 if( anIO->hasEntry() ) {
1309 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1310 anActor->SetControlMode( SMESH_Actor::eNone );
1318 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1328 ::DisableAutoColor();
1331 case 1134: // Clipping
1332 case 1133: // Tranparency
1333 case 1132: // Colors / Size
1340 ::SetDisplayMode(theCommandID);
1346 case 219: // Volumes
1347 case 220: // All Entity
1348 ::SetDisplayEntity(theCommandID);
1353 if(checkLock(aStudy)) break;
1355 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1358 SMESH::UpdateView();
1360 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1361 SMESH::OnVisuException();
1363 catch (...) { // PAL16774 (Crash after display of many groups)
1364 SMESH::OnVisuException();
1368 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1369 aSel->selectedObjects( l );
1370 aSel->setSelectedObjects( l );
1375 case 301: // DISPLAY
1376 case 302: // DISPLAY ONLY
1378 SMESH::EDisplaing anAction;
1379 switch (theCommandID) {
1380 case 300: anAction = SMESH::eErase; break;
1381 case 301: anAction = SMESH::eDisplay; break;
1382 case 302: anAction = SMESH::eDisplayOnly; break;
1385 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1386 SALOME_ListIO sel_objects, to_process;
1388 aSel->selectedObjects( sel_objects );
1390 if( theCommandID==302 )
1391 startOperation( myEraseAll );
1393 extractContainers( sel_objects, to_process );
1396 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1400 SALOME_ListIteratorOfListIO It( to_process );
1401 for ( ; It.More(); It.Next()) {
1402 Handle(SALOME_InteractiveObject) IOS = It.Value();
1403 if (IOS->hasEntry()) {
1404 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1405 break; // PAL16774 (Crash after display of many groups)
1406 if (anAction == SMESH::eDisplayOnly)
1407 anAction = SMESH::eDisplay;
1412 // PAL13338 + PAL15161 -->
1413 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1414 SMESH::UpdateView();
1415 // PAL13338 + PAL15161 <--
1417 catch (...) { // PAL16774 (Crash after display of many groups)
1418 SMESH::OnVisuException();
1421 if (anAction == SMESH::eErase) {
1423 aSel->setSelectedObjects( l1 );
1426 aSel->setSelectedObjects( to_process );
1433 if(checkLock(aStudy)) break;
1436 EmitSignalDeactivateDialog();
1438 ( new SMESHGUI_NodesDlg( this ) )->show();
1441 SUIT_MessageBox::warning(desktop(),
1442 tr("SMESH_WRN_WARNING"),
1443 tr("SMESH_WRN_VIEWER_VTK"));
1448 case 2151: // FILTER
1452 EmitSignalDeactivateDialog();
1453 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1458 case 406: // MOVE NODE
1462 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1463 tr( "NOT_A_VTK_VIEWER" ) );
1467 if(checkLock(aStudy)) break;
1468 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1472 case 701: // COMPUTE MESH
1474 if (checkLock(aStudy)) break;
1476 startOperation( 701 );
1480 case 702: // Create mesh
1481 startOperation( 702 );
1483 case 703: // Create sub-mesh
1484 startOperation( 703 );
1486 case 704: // Edit mesh/sub-mesh
1487 startOperation( 704 );
1489 case 710: // Build compound mesh
1491 if (checkLock(aStudy)) break;
1492 EmitSignalDeactivateDialog();
1493 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1496 case 407: // DIAGONAL INVERSION
1497 case 408: // Delete diagonal
1501 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1502 tr( "NOT_A_VTK_VIEWER" ) );
1506 if ( checkLock( aStudy ) )
1509 /*Standard_Boolean aRes;
1510 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1511 if ( aMesh->_is_nil() )
1513 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1514 tr( "SMESH_BAD_SELECTION" ) );
1518 EmitSignalDeactivateDialog();
1519 if ( theCommandID == 407 )
1520 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1522 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1525 case 409: // Change orientation
1526 case 410: // Union of triangles
1527 case 411: // Cutting of quadrangles
1531 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1532 tr( "NOT_A_VTK_VIEWER" ) );
1536 if ( checkLock( aStudy ) )
1539 EmitSignalDeactivateDialog();
1540 SMESHGUI_MultiEditDlg* aDlg = NULL;
1541 if ( theCommandID == 409 )
1542 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1543 else if ( theCommandID == 410 )
1544 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1546 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1551 case 412: // Smoothing
1553 if(checkLock(aStudy)) break;
1555 EmitSignalDeactivateDialog();
1556 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1559 SUIT_MessageBox::warning(desktop(),
1560 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1564 case 413: // Extrusion
1566 if (checkLock(aStudy)) break;
1568 EmitSignalDeactivateDialog();
1569 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1571 SUIT_MessageBox::warning(desktop(),
1572 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1576 case 414: // Revolution
1578 if(checkLock(aStudy)) break;
1580 EmitSignalDeactivateDialog();
1581 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1584 SUIT_MessageBox::warning(desktop(),
1585 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1589 case 415: // Pattern mapping
1591 if ( checkLock( aStudy ) )
1595 EmitSignalDeactivateDialog();
1596 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1599 SUIT_MessageBox::warning(desktop(),
1600 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1604 case 416: // Extrusion along a path
1606 if (checkLock(aStudy)) break;
1608 EmitSignalDeactivateDialog();
1609 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1611 SUIT_MessageBox::warning(desktop(),
1612 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1616 case 417: // Convert mesh to quadratic
1618 startOperation( 417 );
1619 /* if (checkLock(aStudy)) break;
1621 EmitSignalDeactivateDialog();
1622 new SMESHGUI_ConvToQuadDlg();
1624 SUIT_MessageBox::warning(desktop(),
1625 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1629 case 801: // CREATE GROUP
1633 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1634 tr( "NOT_A_VTK_VIEWER" ) );
1638 if(checkLock(aStudy)) break;
1639 EmitSignalDeactivateDialog();
1640 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1642 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1643 SALOME_ListIO selected;
1645 aSel->selectedObjects( selected );
1647 int nbSel = selected.Extent();
1649 // check if mesh is selected
1650 aMesh = SMESH::GetMeshByIO( selected.First() );
1652 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1657 case 802: // CONSTRUCT GROUP
1661 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1662 tr( "NOT_A_VTK_VIEWER" ) );
1666 if(checkLock(aStudy)) break;
1667 EmitSignalDeactivateDialog();
1669 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1670 SALOME_ListIO selected;
1672 aSel->selectedObjects( selected );
1674 int nbSel = selected.Extent();
1676 // check if submesh is selected
1677 Handle(SALOME_InteractiveObject) IObject = selected.First();
1678 if (IObject->hasEntry()) {
1679 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1681 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1682 if (!aSubMesh->_is_nil()) {
1684 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1685 // get submesh elements list by types
1686 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1687 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1688 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1689 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1690 // create group for each type o elements
1691 QString aName = IObject->getName();
1692 if (aNodes->length() > 0) {
1693 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1694 aGroup->Add(aNodes.inout());
1696 if (aEdges->length() > 0) {
1697 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1698 aGroup->Add(aEdges.inout());
1700 if (aFaces->length() > 0) {
1701 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1702 aGroup->Add(aFaces.inout());
1704 if (aVolumes->length() > 0) {
1705 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1706 aGroup->Add(aVolumes.inout());
1711 catch(const SALOME::SALOME_Exception & S_ex){
1712 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1719 SUIT_MessageBox::warning(desktop(),
1720 tr("SMESH_WRN_WARNING"),
1721 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1726 case 803: // EDIT GROUP
1730 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1731 tr( "NOT_A_VTK_VIEWER" ) );
1735 if(checkLock(aStudy)) break;
1736 EmitSignalDeactivateDialog();
1738 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1739 SALOME_ListIO selected;
1741 aSel->selectedObjects( selected );
1743 SALOME_ListIteratorOfListIO It (selected);
1744 int nbSelectedGroups = 0;
1745 for ( ; It.More(); It.Next() )
1747 SMESH::SMESH_GroupBase_var aGroup =
1748 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1749 if (!aGroup->_is_nil()) {
1751 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1755 if (nbSelectedGroups == 0)
1757 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1763 case 804: // Add elements to group
1765 if(checkLock(aStudy)) break;
1766 if (myState == 800) {
1767 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1768 if (aDlg) aDlg->onAdd();
1773 case 805: // Remove elements from group
1775 if(checkLock(aStudy)) break;
1776 if (myState == 800) {
1777 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1778 if (aDlg) aDlg->onRemove();
1783 case 810: // Union Groups
1784 case 811: // Intersect groups
1785 case 812: // Cut groups
1789 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1790 tr( "NOT_A_VTK_VIEWER" ) );
1794 if ( checkLock( aStudy ) )
1797 EmitSignalDeactivateDialog();
1800 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1801 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1802 else aMode = SMESHGUI_GroupOpDlg::CUT;
1804 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1808 case 813: // Delete groups with their contents
1812 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1813 tr( "NOT_A_VTK_VIEWER" ) );
1817 if ( checkLock( aStudy ) )
1820 EmitSignalDeactivateDialog();
1822 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1826 case 900: // MESH INFOS
1828 EmitSignalDeactivateDialog();
1829 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1830 SALOME_ListIO selected;
1832 aSel->selectedObjects( selected );
1834 if ( selected.Extent() > 1 ) { // a dlg for each IO
1836 SALOME_ListIteratorOfListIO It (selected);
1837 for ( ; It.More(); It.Next() ) {
1838 IOs.Clear(); IOs.Append( It.Value() );
1839 aSel->setSelectedObjects( IOs );
1840 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1842 // restore selection
1843 aSel->setSelectedObjects( selected );
1846 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1850 case 902: // STANDARD MESH INFOS
1852 EmitSignalDeactivateDialog();
1853 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1854 SALOME_ListIO selected;
1856 aSel->selectedObjects( selected );
1858 if ( selected.Extent() > 1 ) { // a dlg for each IO
1860 SALOME_ListIteratorOfListIO It (selected);
1861 for ( ; It.More(); It.Next() ) {
1863 IOs.Append( It.Value() );
1864 aSel->setSelectedObjects( IOs );
1865 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1867 // restore selection
1868 aSel->setSelectedObjects( selected );
1871 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1875 case 903: // WHAT IS
1877 EmitSignalDeactivateDialog();
1878 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1882 case 1100: // EDIT HYPOTHESIS
1884 if(checkLock(aStudy)) break;
1886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1887 SALOME_ListIO selected;
1889 aSel->selectedObjects( selected );
1891 int nbSel = selected.Extent();
1894 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1895 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1897 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1898 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1899 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1900 if ( !aHypothesis->_is_nil() )
1902 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
1904 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1911 updateObjBrowser( true );
1915 case 1101: // RENAME
1917 if ( checkLock( aStudy ) )
1920 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1921 SALOME_ListIO selected;
1923 aSel->selectedObjects( selected );
1925 SALOME_ListIteratorOfListIO It( selected );
1926 for ( ; It.More(); It.Next() )
1928 Handle(SALOME_InteractiveObject) IObject = It.Value();
1929 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1930 _PTR(GenericAttribute) anAttr;
1931 _PTR(AttributeName) aName;
1934 if ( obj->FindAttribute(anAttr, "AttributeName") )
1937 QString newName = QString(aName->Value().c_str());
1938 newName = LightApp_NameDlg::getName(desktop(), newName);
1939 if ( !newName.isEmpty() )
1941 //old source: aStudy->renameIObject( IObject, newName );
1942 aName->SetValue( newName.toLatin1().data() );
1944 // if current object is group update group's name
1945 SMESH::SMESH_GroupBase_var aGroup =
1946 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1947 if (!aGroup->_is_nil() )
1948 aGroup->SetName( newName.toLatin1().data() );
1958 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1960 if(checkLock(aStudy)) break;
1961 SUIT_OverrideCursor wc;
1963 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1964 SALOME_ListIO selected;
1966 aSel->selectedObjects( selected, QString::null, false );
1968 SALOME_ListIteratorOfListIO It(selected);
1969 for (int i = 0; It.More(); It.Next(), i++) {
1970 Handle(SALOME_InteractiveObject) IObject = It.Value();
1971 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1974 aSel->setSelectedObjects( l1 );
1979 case 401: // GEOM::EDGE
1980 case 4021: // TRIANGLE
1982 case 4023: // POLYGON
1986 if(checkLock(aStudy)) break;
1988 EmitSignalDeactivateDialog();
1989 SMDSAbs_ElementType type = SMDSAbs_Edge;
1991 switch (theCommandID) {
1992 case 4021: // TRIANGLE
1993 type = SMDSAbs_Face; nbNodes = 3; break;
1995 type = SMDSAbs_Face; nbNodes = 4; break;
1997 type = SMDSAbs_Volume; nbNodes = 4; break;
1998 case 4023: // POLYGON
1999 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2001 type = SMDSAbs_Volume; nbNodes = 8; break;
2002 case 4033: // POLYHEDRE
2003 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2006 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2009 SUIT_MessageBox::warning(desktop(),
2010 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2014 case 4033: // POLYHEDRON
2016 if(checkLock(aStudy)) break;
2018 EmitSignalDeactivateDialog();
2019 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2022 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2023 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2027 case 4034: // QUADRATIC EDGE
2028 case 4035: // QUADRATIC TRIANGLE
2029 case 4036: // QUADRATIC QUADRANGLE
2030 case 4037: // QUADRATIC TETRAHEDRON
2031 case 4038: // QUADRATIC PYRAMID
2032 case 4039: // QUADRATIC PENTAHEDRON
2033 case 4040: // QUADRATIC HEXAHEDRON
2035 if(checkLock(aStudy)) break;
2037 EmitSignalDeactivateDialog();
2040 switch (theCommandID) {
2042 type = QUAD_EDGE; break;
2044 type = QUAD_TRIANGLE; break;
2046 type = QUAD_QUADRANGLE; break;
2048 type = QUAD_TETRAHEDRON; break;
2050 type = QUAD_PYRAMID; break;
2052 type = QUAD_PENTAHEDRON; break;
2054 type = QUAD_HEXAHEDRON;
2058 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2061 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2062 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2066 case 4041: // REMOVES NODES
2068 if(checkLock(aStudy)) break;
2070 EmitSignalDeactivateDialog();
2071 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2074 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2075 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2079 case 4042: // REMOVES ELEMENTS
2081 if(checkLock(aStudy)) break;
2083 EmitSignalDeactivateDialog();
2084 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2088 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2089 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2093 case 4051: // RENUMBERING NODES
2095 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2102 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2103 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2107 case 4052: // RENUMBERING ELEMENTS
2109 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2116 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2117 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2121 case 4061: // TRANSLATION
2123 if(checkLock(aStudy)) break;
2125 EmitSignalDeactivateDialog();
2126 ( new SMESHGUI_TranslationDlg( this ) )->show();
2129 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2134 case 4062: // ROTATION
2136 if(checkLock(aStudy)) break;
2138 EmitSignalDeactivateDialog();
2139 ( new SMESHGUI_RotationDlg( this ) )->show();
2142 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2143 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2147 case 4063: // SYMMETRY
2149 if(checkLock(aStudy)) break;
2151 EmitSignalDeactivateDialog();
2152 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2155 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2156 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2160 case 4064: // SEWING
2162 if(checkLock(aStudy)) break;
2164 EmitSignalDeactivateDialog();
2165 ( new SMESHGUI_SewingDlg( this ) )->show();
2168 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2169 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2173 case 4065: // MERGE NODES
2175 if(checkLock(aStudy)) break;
2177 EmitSignalDeactivateDialog();
2178 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2181 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2182 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2186 case 4066: // MERGE EQUAL ELEMENTS
2188 if (checkLock(aStudy)) break;
2190 EmitSignalDeactivateDialog();
2191 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2193 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2194 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2199 case 4067: // MAKE MESH PASS THROUGH POINT
2200 startOperation( 4067 );
2203 case 5105: // Library of selection filters
2205 static QList<int> aTypes;
2206 if ( aTypes.isEmpty() )
2208 aTypes.append( SMESH::NODE );
2209 aTypes.append( SMESH::EDGE );
2210 aTypes.append( SMESH::FACE );
2211 aTypes.append( SMESH::VOLUME );
2213 if (!myFilterLibraryDlg)
2214 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2215 else if (myFilterLibraryDlg->isHidden())
2216 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2217 myFilterLibraryDlg->raise();
2221 case 6017: // CONTROLS
2237 LightApp_SelectionMgr* mgr = selectionMgr();
2238 SALOME_ListIO selected; mgr->selectedObjects( selected );
2240 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2241 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2243 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2244 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2245 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2246 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2247 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2248 ::Control( theCommandID );
2253 SUIT_MessageBox::warning(desktop(),
2254 tr( "SMESH_WRN_WARNING" ),
2255 tr( "SMESH_BAD_SELECTION" ) );
2259 SUIT_MessageBox::warning(desktop(),
2260 tr( "SMESH_WRN_WARNING" ),
2261 tr( "NOT_A_VTK_VIEWER" ) );
2266 LightApp_SelectionMgr* mgr = selectionMgr();
2267 SALOME_ListIO selected; mgr->selectedObjects( selected );
2269 SALOME_ListIteratorOfListIO it(selected);
2270 for( ; it.More(); it.Next()) {
2271 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2272 if(anIObject->hasEntry()) {
2273 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2274 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2282 LightApp_SelectionMgr* mgr = selectionMgr();
2283 SALOME_ListIO selected; mgr->selectedObjects( selected );
2285 if (selected.Extent() == 1) {
2286 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2287 if(anIObject->hasEntry())
2288 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2289 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2296 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2297 //updateObjBrowser();
2301 //=============================================================================
2305 //=============================================================================
2306 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2311 //=============================================================================
2315 //=============================================================================
2316 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2321 //=============================================================================
2325 //=============================================================================
2326 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2331 //=============================================================================
2332 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2333 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2335 //=============================================================================
2336 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2337 SUIT_ViewWindow* wnd )
2339 if(theIO->hasEntry()){
2340 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2341 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2345 //=======================================================================
2346 // function : createSMESHAction
2348 //=======================================================================
2349 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2352 QWidget* parent = application()->desktop();
2353 SUIT_ResourceMgr* resMgr = resourceMgr();
2355 if ( !icon_id.isEmpty() )
2356 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2358 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2359 if ( !pix.isNull() )
2360 icon = QIcon( pix );
2362 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2363 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2364 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2366 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2369 //=======================================================================
2370 // function : createPopupItem
2372 //=======================================================================
2373 void SMESHGUI::createPopupItem( const int id,
2374 const QString& clients,
2375 const QString& types,
2376 const QString& theRule,
2381 parentId = popupMgr()->actionId( action( pId ) );
2383 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2384 popupMgr()->insert( action( id ), parentId, 0 );
2386 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2387 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2388 QString rule = "(%1) and (%2) and (%3)";
2389 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2390 if( clients.isEmpty() )
2391 rule = rule.arg( QString( "true" ) );
2393 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2394 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2397 bool cont = myRules.contains( id );
2399 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2401 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2402 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2405 //=======================================================================
2406 // function : initialize
2408 //=======================================================================
2409 void SMESHGUI::initialize( CAM_Application* app )
2411 SalomeApp_Module::initialize( app );
2413 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2415 /* Automatic Update flag */
2416 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2418 // ----- create actions --------------
2420 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2421 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2422 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2423 createSMESHAction( 114, "NUM" );
2424 createSMESHAction( 121, "DAT" );
2425 createSMESHAction( 122, "MED" );
2426 createSMESHAction( 123, "UNV" );
2427 createSMESHAction( 140, "STL" );
2428 createSMESHAction( 124, "EXPORT_DAT" );
2429 createSMESHAction( 125, "EXPORT_MED" );
2430 createSMESHAction( 126, "EXPORT_UNV" );
2431 createSMESHAction( 141, "EXPORT_STL" );
2432 createSMESHAction( 150, "FILE_INFO" );
2433 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2434 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2435 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2436 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2437 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2438 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2439 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2440 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2441 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2442 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2443 createSMESHAction( 804, "ADD" );
2444 createSMESHAction( 805, "REMOVE" );
2445 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2446 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2447 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2448 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2449 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2450 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2451 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2452 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2453 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2454 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2455 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2456 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2457 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2458 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2459 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2460 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2461 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2462 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2463 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2464 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2465 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2466 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2467 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2468 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2469 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2470 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2471 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2472 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2473 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2474 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2475 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2476 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2477 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2478 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2479 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2480 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2481 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2482 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2483 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2484 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2485 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2486 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2487 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2488 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2489 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2490 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2491 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2492 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2493 createSMESHAction( 415, "MAP", "ICON_MAP" );
2494 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2495 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2496 createSMESHAction( 200, "RESET" );
2497 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2498 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2499 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2500 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2501 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2502 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2503 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2504 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2505 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2506 createSMESHAction( 220, "ALL" );
2507 createSMESHAction( 1100, "EDIT_HYPO" );
2508 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2509 createSMESHAction( 1102, "UNASSIGN" );
2510 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2511 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2512 createSMESHAction( 1131, "DISPMODE" );
2513 createSMESHAction( 1132, "COLORS" );
2514 createSMESHAction( 1133, "TRANSP" );
2515 createSMESHAction( 1134, "CLIP" );
2516 createSMESHAction( 1135, "DISP_ENT" );
2517 createSMESHAction( 1136, "AUTO_COLOR" );
2518 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2519 createSMESHAction( 2000, "CTRL" );
2521 createSMESHAction( 300, "ERASE" );
2522 createSMESHAction( 301, "DISPLAY" );
2523 createSMESHAction( 302, "DISPLAY_ONLY" );
2524 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2525 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2526 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2527 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2528 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2529 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2530 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2531 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2533 // ----- create menu --------------
2534 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2535 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2536 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2537 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2538 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2539 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2540 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2542 createMenu( separator(), fileId );
2544 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2545 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2546 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2547 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2548 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2549 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2551 createMenu( 111, importId, -1 );
2552 createMenu( 112, importId, -1 );
2553 createMenu( 113, importId, -1 );
2555 createMenu( 121, exportId, -1 );
2556 createMenu( 122, exportId, -1 );
2557 createMenu( 123, exportId, -1 );
2558 createMenu( 140, exportId, -1 ); // export to stl STL
2560 createMenu( separator(), fileId, 10 );
2562 createMenu( 33, editId, -1 );
2564 createMenu( 5105, toolsId, -1 );
2566 createMenu( 702, meshId, -1 );
2567 createMenu( 703, meshId, -1 );
2568 createMenu( 704, meshId, -1 );
2569 createMenu( 710, meshId, -1 );
2570 createMenu( separator(), meshId, -1 );
2571 createMenu( 701, meshId, -1 );
2572 createMenu( separator(), meshId, -1 );
2573 createMenu( 801, meshId, -1 );
2574 createMenu( 802, meshId, -1 );
2575 createMenu( 803, meshId, -1 );
2576 createMenu( separator(), meshId, -1 );
2577 createMenu( 810, meshId, -1 );
2578 createMenu( 811, meshId, -1 );
2579 createMenu( 812, meshId, -1 );
2580 createMenu( separator(), meshId, -1 );
2581 createMenu( 813, meshId, -1 );
2582 createMenu( separator(), meshId, -1 );
2583 createMenu( 900, meshId, -1 );
2584 createMenu( 902, meshId, -1 );
2585 createMenu( 903, meshId, -1 );
2586 createMenu( separator(), meshId, -1 );
2588 createMenu( 6003, ctrlId, -1 );
2589 createMenu( 6001, ctrlId, -1 );
2590 createMenu( 6004, ctrlId, -1 );
2591 createMenu( separator(), ctrlId, -1 );
2592 createMenu( 6002, ctrlId, -1 );
2593 createMenu( 6018, ctrlId, -1 );
2594 createMenu( 6019, ctrlId, -1 );
2595 createMenu( 6011, ctrlId, -1 );
2596 createMenu( 6012, ctrlId, -1 );
2597 createMenu( 6013, ctrlId, -1 );
2598 createMenu( 6014, ctrlId, -1 );
2599 createMenu( 6015, ctrlId, -1 );
2600 createMenu( 6016, ctrlId, -1 );
2601 createMenu( separator(), ctrlId, -1 );
2602 createMenu( 6017, ctrlId, -1 );
2603 createMenu( 6009, ctrlId, -1 );
2604 createMenu( separator(), ctrlId, -1 );
2606 createMenu( 400, addId, -1 );
2607 createMenu( 401, addId, -1 );
2608 createMenu( 4021, addId, -1 );
2609 createMenu( 4022, addId, -1 );
2610 createMenu( 4023, addId, -1 );
2611 createMenu( 4031, addId, -1 );
2612 createMenu( 4032, addId, -1 );
2613 createMenu( 4033, addId, -1 );
2614 createMenu( separator(), addId, -1 );
2615 createMenu( 4034, addId, -1 );
2616 createMenu( 4035, addId, -1 );
2617 createMenu( 4036, addId, -1 );
2618 createMenu( 4037, addId, -1 );
2619 createMenu( 4038, addId, -1 );
2620 createMenu( 4039, addId, -1 );
2621 createMenu( 4040, addId, -1 );
2623 createMenu( 4041, removeId, -1 );
2624 createMenu( 4042, removeId, -1 );
2626 createMenu( 4051, renumId, -1 );
2627 createMenu( 4052, renumId, -1 );
2629 createMenu( 4061, transfId, -1 );
2630 createMenu( 4062, transfId, -1 );
2631 createMenu( 4063, transfId, -1 );
2632 createMenu( 4064, transfId, -1 );
2633 createMenu( 4065, transfId, -1 );
2634 createMenu( 4066, transfId, -1 );
2636 createMenu( 406, modifyId, -1 );
2637 createMenu( 4067,modifyId, -1 );
2638 createMenu( 407, modifyId, -1 );
2639 createMenu( 408, modifyId, -1 );
2640 createMenu( 409, modifyId, -1 );
2641 createMenu( 410, modifyId, -1 );
2642 createMenu( 411, modifyId, -1 );
2643 createMenu( 412, modifyId, -1 );
2644 createMenu( 413, modifyId, -1 );
2645 createMenu( 416, modifyId, -1 );
2646 createMenu( 414, modifyId, -1 );
2647 createMenu( 415, modifyId, -1 );
2648 createMenu( 417, modifyId, -1 );
2650 createMenu( 214, viewId, -1 );
2652 // ----- create toolbars --------------
2653 int meshTb = createTool( tr( "TB_MESH" ) ),
2654 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2655 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2656 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2657 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2659 createTool( 702, meshTb );
2660 createTool( 703, meshTb );
2661 createTool( 704, meshTb );
2662 createTool( 710, meshTb );
2663 createTool( separator(), meshTb );
2664 createTool( 701, meshTb );
2665 createTool( separator(), meshTb );
2666 createTool( 801, meshTb );
2667 createTool( 802, meshTb );
2668 createTool( 803, meshTb );
2669 createTool( separator(), meshTb );
2670 createTool( 900, meshTb );
2671 createTool( 902, meshTb );
2672 createTool( 903, meshTb );
2673 createTool( separator(), meshTb );
2675 createTool( 6001, ctrlTb );
2676 createTool( 6003, ctrlTb );
2677 createTool( 6004, ctrlTb );
2678 createTool( separator(), ctrlTb );
2679 createTool( 6002, ctrlTb );
2680 createTool( 6018, ctrlTb );
2681 createTool( 6019, ctrlTb );
2682 createTool( 6011, ctrlTb );
2683 createTool( 6012, ctrlTb );
2684 createTool( 6013, ctrlTb );
2685 createTool( 6014, ctrlTb );
2686 createTool( 6015, ctrlTb );
2687 createTool( 6016, ctrlTb );
2688 createTool( separator(), ctrlTb );
2689 createTool( 6017, ctrlTb );
2690 createTool( 6009, ctrlTb );
2691 createTool( separator(), ctrlTb );
2693 createTool( 400, addRemTb );
2694 createTool( 401, addRemTb );
2695 createTool( 4021, addRemTb );
2696 createTool( 4022, addRemTb );
2697 createTool( 4023, addRemTb );
2698 createTool( 4031, addRemTb );
2699 createTool( 4032, addRemTb );
2700 createTool( 4033, addRemTb );
2701 createTool( separator(), addRemTb );
2702 createTool( 4034, addRemTb );
2703 createTool( 4035, addRemTb );
2704 createTool( 4036, addRemTb );
2705 createTool( 4037, addRemTb );
2706 createTool( 4038, addRemTb );
2707 createTool( 4039, addRemTb );
2708 createTool( 4040, addRemTb );
2709 createTool( separator(), addRemTb );
2710 createTool( 4041, addRemTb );
2711 createTool( 4042, addRemTb );
2712 createTool( separator(), addRemTb );
2713 createTool( 4051, addRemTb );
2714 createTool( 4052, addRemTb );
2715 createTool( separator(), addRemTb );
2716 createTool( 4061, addRemTb );
2717 createTool( 4062, addRemTb );
2718 createTool( 4063, addRemTb );
2719 createTool( 4064, addRemTb );
2720 createTool( 4065, addRemTb );
2721 createTool( 4066, addRemTb );
2722 createTool( separator(), addRemTb );
2724 createTool( 406, modifyTb );
2725 createTool( 4067,modifyTb );
2726 createTool( 407, modifyTb );
2727 createTool( 408, modifyTb );
2728 createTool( 409, modifyTb );
2729 createTool( 410, modifyTb );
2730 createTool( 411, modifyTb );
2731 createTool( 412, modifyTb );
2732 createTool( 413, modifyTb );
2733 createTool( 416, modifyTb );
2734 createTool( 414, modifyTb );
2735 createTool( 415, modifyTb );
2736 createTool( 417, modifyTb );
2738 createTool( 214, dispModeTb );
2740 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2741 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2744 QString OB = "'ObjectBrowser'",
2745 View = "'" + SVTK_Viewer::Type() + "'",
2747 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2748 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2749 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2750 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2751 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2752 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2753 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2754 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2755 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2756 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2757 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2759 mesh_group = mesh + " " + subMesh + " " + group,
2760 hyp_alg = hypo + " " + algo;
2762 // popup for object browser
2764 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2765 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2766 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2767 createPopupItem( 803, OB, group ); // EDIT_GROUP
2768 popupMgr()->insert( separator(), -1, 0 );
2769 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2770 createPopupItem( 214, OB, mesh_group ); // UPDATE
2771 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2772 createPopupItem( 902, OB, mesh ); // STD_INFO
2773 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2774 popupMgr()->insert( separator(), -1, 0 );
2775 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2776 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2777 popupMgr()->insert( separator(), -1, 0 );
2778 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2779 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2780 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2781 popupMgr()->insert( separator(), -1, 0 );
2783 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2784 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2785 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2786 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2787 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2788 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2789 popupMgr()->insert( separator(), -1, 0 );
2792 createPopupItem( 803, View, group ); // EDIT_GROUP
2793 createPopupItem( 804, View, elems ); // ADD
2794 createPopupItem( 805, View, elems ); // REMOVE
2795 popupMgr()->insert( separator(), -1, 0 );
2796 createPopupItem( 214, View, mesh_group ); // UPDATE
2797 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2798 createPopupItem( 902, View, mesh ); // STD_INFO
2799 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2800 popupMgr()->insert( separator(), -1, 0 );
2802 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2803 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2804 popupMgr()->insert( separator(), -1, 0 );
2808 isInvisible("not( isVisible )"),
2809 isEmpty("numberOfNodes = 0"),
2810 isNotEmpty("numberOfNodes <> 0"),
2812 // has nodes, edges, etc in VISIBLE! actor
2813 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2814 hasElems("(count( elemTypes ) > 0)"),
2815 hasDifferentElems("(count( elemTypes ) > 1)"),
2816 hasEdges("({'Edge'} in elemTypes)"),
2817 hasFaces("({'Face'} in elemTypes)"),
2818 hasVolumes("({'Volume'} in elemTypes)");
2820 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2821 QString aType = QString( "%1type in {%2}" ).arg( lc );
2822 aType = aType.arg( mesh_group );
2823 QString aMeshInVTK = aClient + "&&" + aType;
2825 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2826 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2827 QString aSelCount = QString( "%1 > 0" ).arg( dc );
2829 //-------------------------------------------------
2831 //-------------------------------------------------
2832 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2834 popupMgr()->insert( action( 9010 ), anId, -1 );
2835 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
2836 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
2838 popupMgr()->insert( action( 9011 ), anId, -1 );
2839 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
2840 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
2842 popupMgr()->insert( separator(), -1, -1 );
2844 //-------------------------------------------------
2846 //-------------------------------------------------
2847 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2849 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2850 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
2851 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
2853 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2854 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
2855 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
2857 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2858 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
2859 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
2861 popupMgr()->insert( separator(), anId, -1 );
2863 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2864 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
2865 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
2867 //-------------------------------------------------
2869 //-------------------------------------------------
2870 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2872 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2874 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2875 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
2876 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
2878 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2879 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
2880 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
2882 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2883 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
2884 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
2886 popupMgr()->insert( separator(), anId, -1 );
2888 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2889 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
2891 //-------------------------------------------------
2893 //-------------------------------------------------
2894 popupMgr()->insert( action( 1132 ), -1, -1 );
2895 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2897 //-------------------------------------------------
2899 //-------------------------------------------------
2900 popupMgr()->insert( action( 1133 ), -1, -1 );
2901 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2903 //-------------------------------------------------
2905 //-------------------------------------------------
2906 popupMgr()->insert( action( 1134 ), -1, -1 );
2907 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2909 popupMgr()->insert( separator(), -1, -1 );
2911 //-------------------------------------------------
2913 //-------------------------------------------------
2915 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2916 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2917 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2919 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2921 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2922 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2924 popupMgr()->insert( separator(), anId, -1 );
2926 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2927 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2928 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
2930 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2931 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2932 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
2934 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2935 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2936 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
2938 popupMgr()->insert( separator(), anId, -1 );
2940 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2941 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2942 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
2944 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2945 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2946 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
2948 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2949 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2950 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
2952 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2953 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2954 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
2956 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2957 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2958 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
2960 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2961 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2962 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
2964 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2965 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2966 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
2968 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2969 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2970 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
2972 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2973 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2974 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
2976 popupMgr()->insert( separator(), anId, -1 );
2978 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2979 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2980 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
2982 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2983 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2984 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
2986 popupMgr()->insert( separator(), anId, -1 );
2988 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2989 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2991 popupMgr()->insert( separator(), -1, -1 );
2993 //-------------------------------------------------
2995 //-------------------------------------------------
2996 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2997 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2998 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2999 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3001 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3002 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3004 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3005 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3007 popupMgr()->insert( separator(), -1, -1 );
3009 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3010 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3013 bool SMESHGUI::activateModule( SUIT_Study* study )
3015 bool res = SalomeApp_Module::activateModule( study );
3017 setMenuShown( true );
3018 setToolShown( true );
3020 // Reset actions accelerator keys
3021 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3022 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3023 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3028 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3030 setMenuShown( false );
3031 setToolShown( false );
3033 EmitSignalCloseAllDialogs();
3035 // Unset actions accelerator keys
3036 action(111)->setShortcut(QKeySequence()); // Import DAT
3037 action(112)->setShortcut(QKeySequence()); // Import UNV
3038 action(113)->setShortcut(QKeySequence()); // Import MED
3040 return SalomeApp_Module::deactivateModule( study );
3043 void SMESHGUI::studyClosed( SUIT_Study* s )
3045 SMESH::RemoveVisuData( s->id() );
3046 SalomeApp_Module::studyClosed( s );
3049 void SMESHGUI::OnGUIEvent()
3051 const QObject* obj = sender();
3052 if ( !obj || !obj->inherits( "QAction" ) )
3054 int id = actionId((QAction*)obj);
3059 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3061 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3062 if ( CORBA::is_nil( myComponentSMESH ) )
3064 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3066 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3067 return aGUI.myComponentSMESH;
3070 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3071 return myComponentSMESH;
3074 QString SMESHGUI::engineIOR() const
3076 CORBA::ORB_var anORB = getApp()->orb();
3077 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3078 return QString( anIOR.in() );
3081 LightApp_Selection* SMESHGUI::createSelection() const
3083 return new SMESHGUI_Selection();
3086 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3088 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3089 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3092 void SMESHGUI::viewManagers( QStringList& list ) const
3094 list.append( SVTK_Viewer::Type() );
3097 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3099 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3100 SMESH::UpdateSelectionProp( this );
3103 void SMESHGUI::createPreferences()
3105 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3107 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3108 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3110 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3111 setPreferenceProperty( qaGroup, "columns", 2 );
3112 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3113 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3115 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3116 setPreferenceProperty( precGroup, "columns", 2 );
3118 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3120 setPreferenceProperty( prec, "min", 0 );
3121 setPreferenceProperty( prec, "max", 16 );
3123 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3124 setPreferenceProperty( dispgroup, "columns", 2 );
3125 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3127 modes.append( "Wireframe" );
3128 modes.append( "Shading" );
3129 modes.append( "Nodes" );
3130 modes.append( "Shrink" );
3131 QList<QVariant> indices;
3132 indices.append( 0 );
3133 indices.append( 1 );
3134 indices.append( 2 );
3135 indices.append( 3 );
3136 setPreferenceProperty( dispmode, "strings", modes );
3137 setPreferenceProperty( dispmode, "indexes", indices );
3139 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3140 setPreferenceProperty( exportgroup, "columns", 2 );
3141 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3142 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3144 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3145 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3146 setPreferenceProperty( nodeGroup, "columns", 2 );
3148 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3149 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3151 setPreferenceProperty( nodeSz, "min", 1 );
3152 setPreferenceProperty( nodeSz, "max", 5 );
3154 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3155 setPreferenceProperty( elemGroup, "columns", 2 );
3157 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3158 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3159 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3160 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3162 setPreferenceProperty( sp, "hstretch", 0 );
3163 setPreferenceProperty( sp, "vstretch", 0 );
3165 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3166 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3168 setPreferenceProperty( elemW, "min", 1 );
3169 setPreferenceProperty( elemW, "max", 5 );
3171 setPreferenceProperty( shrink, "min", 0 );
3172 setPreferenceProperty( shrink, "max", 100 );
3174 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3176 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3177 setPreferenceProperty( selGroup, "columns", 2 );
3179 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3180 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3181 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3183 setPreferenceProperty( selW, "min", 1 );
3184 setPreferenceProperty( selW, "max", 5 );
3186 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3187 setPreferenceProperty( preGroup, "columns", 2 );
3189 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3190 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3192 setPreferenceProperty( preW, "min", 1 );
3193 setPreferenceProperty( preW, "max", 5 );
3195 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3196 setPreferenceProperty( precSelGroup, "columns", 2 );
3198 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3199 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3200 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3202 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3203 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3204 setPreferenceProperty( fontGr, "columns", 2 );
3206 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3207 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3208 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3209 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3212 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3213 fam.append( tr( "SMESH_FONT_COURIER" ) );
3214 fam.append( tr( "SMESH_FONT_TIMES" ) );
3215 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3217 setPreferenceProperty( tfont, "families", fam );
3218 setPreferenceProperty( tfont, "system", false );
3219 setPreferenceProperty( tfont, "widget_flags", wflag );
3220 setPreferenceProperty( lfont, "families", fam );
3221 setPreferenceProperty( lfont, "system", false );
3222 setPreferenceProperty( lfont, "widget_flags", wflag );
3224 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3225 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3227 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3228 setPreferenceProperty( numcol, "min", 2 );
3229 setPreferenceProperty( numcol, "max", 256 );
3231 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3232 setPreferenceProperty( numlab, "min", 2 );
3233 setPreferenceProperty( numlab, "max", 65 );
3235 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3236 setPreferenceProperty( orientGr, "columns", 2 );
3237 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3238 QStringList orients;
3239 orients.append( tr( "SMESH_VERTICAL" ) );
3240 orients.append( tr( "SMESH_HORIZONTAL" ) );
3241 indices.clear(); indices.append( 0 ); indices.append( 1 );
3242 setPreferenceProperty( orient, "strings", orients );
3243 setPreferenceProperty( orient, "indexes", indices );
3245 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3246 setPreferenceProperty( posVSizeGr, "columns", 2 );
3247 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3248 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3249 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3250 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3251 setPreferenceProperty( xv, "step", 0.1 );
3252 setPreferenceProperty( xv, "min", 0.0 );
3253 setPreferenceProperty( xv, "max", 1.0 );
3254 setPreferenceProperty( yv, "step", 0.1 );
3255 setPreferenceProperty( yv, "min", 0.0 );
3256 setPreferenceProperty( yv, "max", 1.0 );
3257 setPreferenceProperty( wv, "step", 0.1 );
3258 setPreferenceProperty( wv, "min", 0.0 );
3259 setPreferenceProperty( wv, "max", 1.0 );
3260 setPreferenceProperty( hv, "min", 0.0 );
3261 setPreferenceProperty( hv, "max", 1.0 );
3262 setPreferenceProperty( hv, "step", 0.1 );
3264 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3265 setPreferenceProperty( posHSizeGr, "columns", 2 );
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::warning(SMESHGUI::desktop(),
3345 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3346 QObject::tr(aWarning.c_str()));
3351 //================================================================================
3353 * \brief Update something in accordance with update flags
3354 * \param theFlags - update flags
3356 * Update viewer or/and object browser etc. in accordance with update flags ( see
3357 * LightApp_UpdateFlags enumeration ).
3359 //================================================================================
3360 void SMESHGUI::update( const int flags )
3362 if ( flags & UF_Viewer | flags & UF_Forced )
3363 SMESH::UpdateView();
3365 SalomeApp_Module::update( flags );
3368 //================================================================================
3370 * \brief Set default selection mode
3372 * SLOT called when operation commited. Sets default selection mode
3374 //================================================================================
3375 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3377 SVTK_ViewWindow* vtkWnd =
3378 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3380 vtkWnd->SetSelectionMode( ActorSelection );
3383 //================================================================================
3385 * \brief Set default selection mode
3387 * SLOT called when operation aborted. Sets default selection mode
3389 //================================================================================
3390 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3392 SVTK_ViewWindow* vtkWnd =
3393 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3395 vtkWnd->SetSelectionMode( ActorSelection );
3398 //================================================================================
3400 * \brief Creates operation with given identifier
3401 * \param id - identifier of operation to be started
3402 * \return Pointer on created operation or NULL if operation is not created
3404 * Virtual method redefined from the base class creates operation with given id.
3405 * It is called called automatically from startOperation method of base class.
3407 //================================================================================
3408 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3410 LightApp_Operation* op = 0;
3411 // to do : create operation here
3414 case 701: // Compute mesh
3415 op = new SMESHGUI_ComputeOp();
3417 case 702: // Create mesh
3418 op = new SMESHGUI_MeshOp( true, true );
3420 case 703: // Create sub-mesh
3421 op = new SMESHGUI_MeshOp( true, false );
3423 case 704: // Edit mesh/sub-mesh
3424 op = new SMESHGUI_MeshOp( false );
3426 case 417: //convert to quadratic
3427 op = new SMESHGUI_ConvToQuadOp();
3429 case 4067: // make mesh pass through point
3430 op = new SMESHGUI_MakeNodeAtPointOp();
3437 op = SalomeApp_Module::createOperation( id );
3441 //================================================================================
3443 * \brief Stops current operations and starts a given one
3444 * \param id - The id of the operation to start
3446 //================================================================================
3448 void SMESHGUI::switchToOperation(int id)
3450 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3451 activeStudy()->abortAllOperations();
3452 startOperation( id );
3455 LightApp_Displayer* SMESHGUI::displayer()
3458 myDisplayer = new SMESHGUI_Displayer( getApp() );
3462 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3465 int aTolerance = 64;
3466 int anIterations = 0;
3472 if( anIterations % aPeriod == 0 )
3475 if( aTolerance < 1 )
3478 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3480 aHue = (int)( 360.0 * rand() / RAND_MAX );
3481 //cout << "Hue = " << aHue << endl;
3483 //cout << "Auto colors : ";
3485 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3486 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3487 for( ; it != itEnd; ++it )
3489 SALOMEDS::Color anAutoColor = *it;
3490 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3493 aQColor.getHsv( &h, &s, &v );
3495 if( abs( h - aHue ) < aTolerance )
3498 //cout << "break (diff = " << abs( h - aHue ) << ")";
3508 //cout << "Hue of the returned color = " << aHue << endl;
3510 aColor.setHsv( aHue, 255, 255 );
3512 SALOMEDS::Color aSColor;
3513 aSColor.R = (double)aColor.red() / 255.0;
3514 aSColor.G = (double)aColor.green() / 255.0;
3515 aSColor.B = (double)aColor.blue() / 255.0;