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"
69 #include "SMESHGUI_Utils.h"
70 #include "SMESHGUI_MeshUtils.h"
71 #include "SMESHGUI_GroupUtils.h"
72 #include "SMESHGUI_FilterUtils.h"
73 #include "SMESHGUI_PatternUtils.h"
74 #include "SMESHGUI_VTKUtils.h"
75 #include "SMESHGUI_HypothesesUtils.h"
77 #include <SMESH_Client.hxx>
78 #include <SMESH_Actor.h>
79 #include <SMESH_TypeFilter.hxx>
81 // SALOME GUI includes
82 #include <SalomeApp_Tools.h>
83 #include <SalomeApp_Study.h>
84 #include <SalomeApp_Application.h>
85 #include <SalomeApp_CheckFileDlg.h>
87 #include <LightApp_DataOwner.h>
88 #include <LightApp_Preferences.h>
89 #include <LightApp_SelectionMgr.h>
90 #include <LightApp_UpdateFlags.h>
91 #include <LightApp_NameDlg.h>
93 #include <SVTK_ViewWindow.h>
94 #include <SVTK_ViewModel.h>
95 #include <SVTK_ViewManager.h>
97 #include <SUIT_MessageBox.h>
98 #include <SUIT_ResourceMgr.h>
99 #include <SUIT_FileDlg.h>
100 #include <SUIT_Desktop.h>
101 #include <SUIT_OverrideCursor.h>
102 #include <SUIT_Session.h>
104 #include <QtxPopupMgr.h>
105 #include <QtxFontEdit.h>
107 #include <SALOME_ListIO.hxx>
108 #include <SALOME_ListIteratorOfListIO.hxx>
111 #include <SALOMEconfig.h>
112 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
113 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
116 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
120 #include <boost/shared_ptr.hpp>
123 #include <vtkScalarBarActor.h>
125 // SALOME KERNEL includes
126 #include <SALOMEDS_Study.hxx>
127 #include <SALOMEDSClient_StudyBuilder.hxx>
128 #include <SALOMEDSClient_SComponent.hxx>
131 #include <Standard_ErrorHandler.hxx>
135 //=============================================================
136 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
139 void ExportMeshToFile(int theCommandID);
141 void SetDisplayMode(int theCommandID);
143 void SetDisplayEntity(int theCommandID);
145 void Control( int theCommandID );
149 //=============================================================
150 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 std::string myExtension;
156 if(theCommandID == 113){
157 filter.append(QObject::tr("MED files (*.med)"));
158 filter.append(QObject::tr("All files (*)"));
159 }else if (theCommandID == 112){
160 filter.append(QObject::tr("IDEAS files (*.unv)"));
161 }else if (theCommandID == 111){
162 filter.append(QObject::tr("DAT files (*.dat)"));
164 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
167 QObject::tr("Import mesh"),
169 if(!filename.isEmpty()) {
170 SUIT_OverrideCursor wc;
171 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
174 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
175 switch ( theCommandID ) {
178 aMeshes->length( 1 );
179 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.toLatin1().data());
184 SMESH::DriverMED_ReadStatus res;
185 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.toLatin1().data(),res);
186 if ( res != SMESH::DRS_OK ) {
188 SUIT_MessageBox::warning(SMESHGUI::desktop(),
189 QObject::tr("SMESH_WRN_WARNING"),
190 QObject::tr(QString("SMESH_DRS_%1").arg(res).
192 aMeshes->length( 0 );
199 bool isEmpty = false;
200 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
201 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
203 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
204 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
205 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
206 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
207 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
214 SUIT_MessageBox::warning(SMESHGUI::desktop(),
215 QObject::tr("SMESH_WRN_WARNING"),
216 QObject::tr("SMESH_DRS_EMPTY"));
220 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
222 catch (const SALOME::SALOME_Exception& S_ex){
224 SalomeApp_Tools::QtCatchCorbaException(S_ex);
231 void ExportMeshToFile( int theCommandID )
233 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
234 SALOME_ListIO selected;
236 aSel->selectedObjects( selected );
238 if(selected.Extent()){
239 Handle(SALOME_InteractiveObject) anIObject = selected.First();
240 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
241 if ( !aMesh->_is_nil() ) {
242 QString aFilter, aTitle = QObject::tr("Export mesh");
243 QMap<QString, SMESH::MED_VERSION> aFilterMap;
244 QMap<QString, int> aFilterMapSTL;
245 switch ( theCommandID ) {
249 if (aMesh->HasDuplicatedGroupNamesMED()) {
250 int aRet = SUIT_MessageBox::warning
251 (SMESHGUI::desktop(),
252 QObject::tr("SMESH_WRN_WARNING"),
253 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
254 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
255 if (aRet != SUIT_MessageBox::Yes)
259 QString v21( aMesh->GetVersionString( SMESH::MED_V2_1, 2));
260 QString v22( aMesh->GetVersionString( SMESH::MED_V2_2, 2));
261 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
262 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
267 aFilter = QObject::tr("DAT files (*.dat)");
272 if (aMesh->NbPyramids()) {
273 int aRet = SUIT_MessageBox::warning
274 (SMESHGUI::desktop(),
275 QObject::tr("SMESH_WRN_WARNING"),
276 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
277 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
278 if (aRet != SUIT_MessageBox::Yes)
281 aFilter = QObject::tr("IDEAS files (*.unv)");
289 there must be check on others mesh elements not equal triangles
291 if (aMesh->NbTriangles() < 1) {
292 SUIT_MessageBox::warning
293 (SMESHGUI::desktop(),
294 QObject::tr("SMESH_WRN_WARNING"),
295 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
298 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
299 int aRet = SUIT_MessageBox::warning
300 (SMESHGUI::desktop(),
301 QObject::tr("SMESH_WRN_WARNING"),
302 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
303 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
304 if (aRet != SUIT_MessageBox::Yes)
308 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
309 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
317 SMESH::MED_VERSION aFormat;
318 // Init the parameter with the default value
319 bool aIsASCII_STL = true;
320 bool toCreateGroups = false;
321 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
323 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
325 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
327 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
329 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
331 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
332 for ( ; it != aFilterMapSTL.end(); ++it )
333 filters.push_back( it.key() );
335 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
336 fd->setWindowTitle( aTitle );
337 fd->setFilters( filters );
338 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
342 aFilename = fd->selectedFile();
343 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
350 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
351 for ( ; it != aFilterMap.end(); ++it )
352 filters.push_back( it.key() );
354 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
355 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
356 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
357 fd->setWindowTitle( aTitle );
358 fd->setFilters( filters );
359 fd->selectFilter( QObject::tr("MED 2.2 (*.med)") );
360 fd->SetChecked(toCreateGroups);
364 aFilename = fd->selectedFile();
365 aFormat = aFilterMap[fd->selectedFilter()];
367 if ( !aFilename.isEmpty()
368 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
369 && aFormat==SMESH::MED_V2_1) {
370 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
371 QObject::tr("SMESH_WRN_WARNING"),
372 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
373 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
374 if (aRet != SUIT_MessageBox::Yes) {
379 toCreateGroups = fd->IsChecked();
382 if ( !aFilename.isEmpty() ) {
383 // Check whether the file already exists and delete it if yes
384 QFile aFile( aFilename );
385 if ( aFile.exists() )
387 SUIT_OverrideCursor wc;
390 bool Renumber = false;
391 // PAL 14172 : Check of we have to renumber or not from the preferences before export
393 Renumber= resMgr->booleanValue("SMESH","renumbering");
395 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
396 aMeshEditor->RenumberNodes();
397 aMeshEditor->RenumberElements();
398 if ( SMESHGUI::automaticUpdate() )
401 switch ( theCommandID ) {
404 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
408 aMesh->ExportDAT( aFilename.toLatin1().data() );
412 aMesh->ExportUNV( aFilename.toLatin1().data() );
416 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
422 catch (const SALOME::SALOME_Exception& S_ex){
424 SUIT_MessageBox::warning(SMESHGUI::desktop(),
425 QObject::tr("SMESH_WRN_WARNING"),
426 QObject::tr("SMESH_EXPORT_FAILED"));
434 inline void InverseEntityMode(unsigned int& theOutputMode,
435 unsigned int theMode)
437 bool anIsNotPresent = ~theOutputMode & theMode;
439 theOutputMode |= theMode;
441 theOutputMode &= ~theMode;
444 void SetDisplayEntity(int theCommandID){
445 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
446 SALOME_ListIO selected;
448 aSel->selectedObjects( selected );
450 if(selected.Extent() >= 1){
451 SALOME_ListIteratorOfListIO It( selected );
452 for( ; It.More(); It.Next()){
453 Handle(SALOME_InteractiveObject) IObject = It.Value();
454 if(IObject->hasEntry()){
455 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
456 unsigned int aMode = anActor->GetEntityMode();
457 switch(theCommandID){
459 InverseEntityMode(aMode,SMESH_Actor::eEdges);
462 InverseEntityMode(aMode,SMESH_Actor::eFaces);
465 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
468 aMode = SMESH_Actor::eAllEntity;
472 anActor->SetEntityMode(aMode);
480 SALOME_ListIO selected;
481 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
485 LightApp_SelectionMgr* aSel = app->selectionMgr();
486 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
487 if( !aSel || !appStudy )
490 aSel->selectedObjects( selected );
491 if( selected.IsEmpty() )
494 Handle(SALOME_InteractiveObject) anIObject = selected.First();
496 _PTR(Study) aStudy = appStudy->studyDS();
497 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
498 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
499 if( aMainObject->_is_nil() )
502 aMainObject->SetAutoColor( true );
504 QList<SALOMEDS::Color> aReservedColors;
506 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
507 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
509 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
510 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
512 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
513 aGroupObject->SetColor( aColor );
514 aReservedColors.append( aColor );
516 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
517 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
519 if( aGroupObject->GetType() == SMESH::NODE )
520 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
521 else if( aGroupObject->GetType() == SMESH::EDGE )
522 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
524 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
528 SMESH::RepaintCurrentView();
531 void DisableAutoColor(){
532 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
533 SALOME_ListIO selected;
535 aSel->selectedObjects( selected );
537 if(selected.Extent()){
538 Handle(SALOME_InteractiveObject) anIObject = selected.First();
539 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
540 if ( !aMesh->_is_nil() ) {
541 aMesh->SetAutoColor( false );
546 void SetDisplayMode(int theCommandID){
547 SALOME_ListIO selected;
548 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
552 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
553 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
554 if( !aSel || !appStudy )
557 _PTR(Study) aStudy = appStudy->studyDS();
559 aSel->selectedObjects( selected );
561 if(selected.Extent() >= 1){
562 switch(theCommandID){
564 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
565 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
569 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
570 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
573 SALOME_ListIteratorOfListIO It( selected );
574 for( ; It.More(); It.Next()){
575 Handle(SALOME_InteractiveObject) IObject = It.Value();
576 if(IObject->hasEntry()){
577 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
578 switch(theCommandID){
580 anActor->SetRepresentation(SMESH_Actor::eEdge);
583 anActor->SetRepresentation(SMESH_Actor::eSurface);
586 if(anActor->IsShrunk())
589 anActor->SetShrink();
592 anActor->SetRepresentation(SMESH_Actor::ePoint);
595 vtkFloatingPointType color[3];
596 anActor->GetSufaceColor(color[0], color[1], color[2]);
597 int c0 = int (color[0] * 255);
598 int c1 = int (color[1] * 255);
599 int c2 = int (color[2] * 255);
600 QColor c(c0, c1, c2);
602 vtkFloatingPointType edgecolor[3];
603 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
604 c0 = int (edgecolor[0] * 255);
605 c1 = int (edgecolor[1] * 255);
606 c2 = int (edgecolor[2] * 255);
607 QColor e(c0, c1, c2);
609 vtkFloatingPointType backfacecolor[3];
610 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
611 c0 = int (backfacecolor[0] * 255);
612 c1 = int (backfacecolor[1] * 255);
613 c2 = int (backfacecolor[2] * 255);
614 QColor b(c0, c1, c2);
616 vtkFloatingPointType nodecolor[3];
617 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
618 c0 = int (nodecolor[0] * 255);
619 c1 = int (nodecolor[1] * 255);
620 c2 = int (nodecolor[2] * 255);
621 QColor n(c0, c1, c2);
623 int Edgewidth = (int)anActor->GetLineWidth();
626 int intValue = int(anActor->GetNodeSize());
627 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
629 SMESHGUI_Preferences_ColorDlg *aDlg =
630 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
631 aDlg->SetColor(1, c);
632 aDlg->SetColor(2, e);
633 aDlg->SetColor(3, n);
634 aDlg->SetColor(4, b);
635 aDlg->SetIntValue(1, Edgewidth);
636 aDlg->SetIntValue(2, intValue);
637 aDlg->SetIntValue(3, int(Shrink*100.));
639 QColor color = aDlg->GetColor(1);
640 QColor edgecolor = aDlg->GetColor(2);
641 QColor nodecolor = aDlg->GetColor(3);
642 QColor backfacecolor = aDlg->GetColor(4);
643 /* actor color and backface color */
644 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
645 vtkFloatingPointType (color.green()) / 255.,
646 vtkFloatingPointType (color.blue()) / 255.);
647 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
648 vtkFloatingPointType (backfacecolor.green()) / 255.,
649 vtkFloatingPointType (backfacecolor.blue()) / 255.);
652 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
653 vtkFloatingPointType (edgecolor.green()) / 255.,
654 vtkFloatingPointType (edgecolor.blue()) / 255.);
656 /* Shrink factor and size edges */
657 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
658 anActor->SetLineWidth(aDlg->GetIntValue(1));
660 /* Nodes color and size */
661 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
662 vtkFloatingPointType (nodecolor.green()) / 255.,
663 vtkFloatingPointType (nodecolor.blue()) / 255.);
664 anActor->SetNodeSize(aDlg->GetIntValue(2));
666 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
667 if( !aGroupObject->_is_nil() )
669 SALOMEDS::Color aColor;
670 aColor.R = (float)color.red() / 255.0;
671 aColor.G = (float)color.green() / 255.0;
672 aColor.B = (float)color.blue() / 255.0;
673 aGroupObject->SetColor( aColor );
683 SMESH::RepaintCurrentView();
687 void Control( int theCommandID )
689 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
690 SALOME_ListIO selected;
692 aSel->selectedObjects( selected );
694 if( !selected.IsEmpty() ){
695 Handle(SALOME_InteractiveObject) anIO = selected.First();
698 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
699 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
700 switch ( theCommandID ){
702 aTitle = QObject::tr( "LENGTH_EDGES" );
703 aControl = SMESH_Actor::eLength;
706 aTitle = QObject::tr( "LENGTH2D_EDGES" );
707 aControl = SMESH_Actor::eLength2D;
710 aTitle = QObject::tr( "FREE_EDGES" );
711 aControl = SMESH_Actor::eFreeEdges;
714 aTitle = QObject::tr( "FREE_BORDERS" );
715 aControl = SMESH_Actor::eFreeBorders;
718 aTitle = QObject::tr( "MULTI_BORDERS" );
719 aControl = SMESH_Actor::eMultiConnection;
722 aTitle = QObject::tr( "MULTI2D_BORDERS" );
723 aControl = SMESH_Actor::eMultiConnection2D;
726 aTitle = QObject::tr( "AREA_ELEMENTS" );
727 aControl = SMESH_Actor::eArea;
730 aTitle = QObject::tr( "TAPER_ELEMENTS" );
731 aControl = SMESH_Actor::eTaper;
734 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
735 aControl = SMESH_Actor::eAspectRatio;
738 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
739 aControl = SMESH_Actor::eAspectRatio3D;
742 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
743 aControl = SMESH_Actor::eMinimumAngle;
746 aTitle = QObject::tr( "WARP_ELEMENTS" );
747 aControl = SMESH_Actor::eWarping;
750 aTitle = QObject::tr( "SKEW_ELEMENTS" );
751 aControl = SMESH_Actor::eSkew;
754 aTitle = QObject::tr( "SMESH_VOLUME" );
755 aControl = SMESH_Actor::eVolume3D;
758 anActor->SetControlMode(aControl);
759 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
760 SMESH::RepaintCurrentView();
767 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
768 MeshObjectType theType,
769 const QString theInTypeName,
770 QString & theOutTypeName)
772 SMESH_TypeFilter aTypeFilter( theType );
774 if( !theIO.IsNull() )
776 entry = theIO->getEntry();
777 LightApp_DataOwner owner( entry );
778 if ( aTypeFilter.isOk( &owner )) {
779 theOutTypeName = theInTypeName;
787 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
789 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
790 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
792 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
793 CORBA::String_var anID = aSComp->GetID().c_str();
794 if (!strcmp(anID.in(),theIO->getEntry()))
800 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
801 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
802 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
803 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
804 CheckOIType ( theIO, GROUP, "Group", aTypeName )
812 QString CheckHomogeneousSelection()
814 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
815 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
816 SALOME_ListIO selected;
818 aSel->selectedObjects( selected );
820 QString RefType = CheckTypeObject(selected.First());
821 SALOME_ListIteratorOfListIO It(selected);
822 for ( ; It.More(); It.Next())
824 Handle(SALOME_InteractiveObject) IObject = It.Value();
825 QString Type = CheckTypeObject(IObject);
826 if (Type.compare(RefType) != 0)
827 return "Heterogeneous Selection";
834 void SMESHGUI::OnEditDelete()
836 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
837 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
838 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
840 QString aParentComponent = QString::null;
841 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
843 QString cur = anIt.Value()->getComponentDataType();
844 if( aParentComponent.isNull() )
845 aParentComponent = cur;
846 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
847 aParentComponent = "";
850 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
851 SUIT_MessageBox::warning( SMESHGUI::desktop(),
852 QObject::tr("ERR_ERROR"),
853 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
856 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
857 if (SUIT_MessageBox::warning
858 (SMESHGUI::desktop(),
859 QObject::tr("SMESH_WRN_WARNING"),
860 QObject::tr("SMESH_REALLY_DELETE"),
861 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
862 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
865 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
866 SUIT_ViewManager* vm = anApp->activeViewManager();
867 int nbSf = vm->getViewsCount();
869 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
870 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
871 _PTR(GenericAttribute) anAttr;
872 _PTR(AttributeIOR) anIOR;
874 SALOME_ListIteratorOfListIO It(selected);
876 aStudyBuilder->NewCommand(); // There is a transaction
877 for( ; It.More(); It.Next()){ // loop on selected IO's
878 Handle(SALOME_InteractiveObject) IObject = It.Value();
879 if(IObject->hasEntry()) {
880 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
882 // disable removal of "SMESH" component object
883 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
885 if ( engineIOR() == anIOR->Value().c_str() )
889 // put the whole hierarchy of sub-objects of the selected SO into a list and
890 // then treat them all starting from the deepest objects (at list back)
892 std::list< _PTR(SObject) > listSO;
893 listSO.push_back( aSO );
894 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
895 for ( ; itSO != listSO.end(); ++itSO ) {
896 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
897 for (it->InitEx(false); it->More(); it->Next())
898 listSO.push_back( it->Value() );
901 // treat SO's in the list starting from the back
903 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
904 for ( ; ritSO != listSO.rend(); ++ritSO ) {
905 _PTR(SObject) SO = *ritSO;
907 std::string anEntry = SO->GetID();
909 /** Erase graphical object **/
910 if(SO->FindAttribute(anAttr, "AttributeIOR")){
911 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
912 for(int i = 0; i < nbSf; i++){
913 SUIT_ViewWindow *sf = aViews[i];
914 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
915 SMESH::RemoveActor(sf,anActor);
920 /** Remove an object from data structures **/
921 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
922 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
923 if ( !aGroup->_is_nil() ) { // DELETE GROUP
924 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
925 aMesh->RemoveGroup( aGroup );
927 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
928 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
929 aMesh->RemoveSubMesh( aSubMesh );
931 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
933 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
936 IObject = new SALOME_InteractiveObject
937 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
938 QString objType = CheckTypeObject(IObject);
939 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
940 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
941 aStudyBuilder->RemoveObjectWithChildren( SO );
943 else {// default action: remove SObject from the study
944 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
945 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
947 aStudyBuilder->RemoveObjectWithChildren( SO );
951 } /* listSO back loop */
952 } /* IObject->hasEntry() */
954 aStudyBuilder->CommitCommand();
956 /* Clear any previous selection */
958 aSel->setSelectedObjects( l1 );
960 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
965 SMESHGUI_EXPORT CAM_Module* createModule()
967 return new SMESHGUI();
971 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
973 //=============================================================================
977 //=============================================================================
978 SMESHGUI::SMESHGUI() :
979 SalomeApp_Module( "SMESH" )
981 if ( CORBA::is_nil( myComponentSMESH ) )
983 CORBA::Boolean anIsEmbeddedMode;
984 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
987 myActiveDialogBox = 0;
988 myFilterLibraryDlg = 0;
992 SMESH::GetFilterManager();
995 /* load resources for all available meshers */
996 SMESH::InitAvailableHypotheses();
999 //=============================================================================
1003 //=============================================================================
1004 SMESHGUI::~SMESHGUI()
1006 SMESH::GetFilterManager()->Destroy();
1007 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1010 //=============================================================================
1014 //=============================================================================
1015 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1017 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1019 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1024 bool SMESHGUI::automaticUpdate()
1026 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1030 return resMgr->booleanValue( "SMESH", "auto_update", false );
1033 //=============================================================================
1037 //=============================================================================
1038 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1040 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1043 //=============================================================================
1047 //=============================================================================
1048 SMESHGUI* SMESHGUI::GetSMESHGUI()
1050 SMESHGUI* smeshMod = 0;
1051 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1054 CAM_Module* module = app->module( "Mesh" );
1055 smeshMod = dynamic_cast<SMESHGUI*>( module );
1058 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1060 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1063 _PTR(Study) aStudy = study->studyDS();
1065 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1074 Standard_EXPORT SMESHGUI* GetComponentGUI()
1076 return SMESHGUI::GetSMESHGUI();
1080 //=============================================================================
1084 //=============================================================================
1085 void SMESHGUI::SetState(int aState)
1090 //=============================================================================
1094 //=============================================================================
1095 void SMESHGUI::ResetState()
1100 //=============================================================================
1104 //=============================================================================
1105 void SMESHGUI::EmitSignalDeactivateDialog()
1107 emit SignalDeactivateActiveDialog();
1110 //=============================================================================
1114 //=============================================================================
1115 void SMESHGUI::EmitSignalStudyFrameChanged()
1117 emit SignalStudyFrameChanged();
1120 //=============================================================================
1124 //=============================================================================
1125 void SMESHGUI::EmitSignalCloseAllDialogs()
1127 emit SignalCloseAllDialogs();
1130 //=============================================================================
1134 //=============================================================================
1135 QDialog *SMESHGUI::GetActiveDialogBox()
1137 return myActiveDialogBox;
1140 //=============================================================================
1144 //=============================================================================
1145 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1147 myActiveDialogBox = (QDialog *) aDlg;
1151 //=============================================================================
1155 //=============================================================================
1156 SUIT_Desktop* SMESHGUI::desktop()
1158 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1160 return app->desktop();
1165 //=============================================================================
1169 //=============================================================================
1170 SalomeApp_Study* SMESHGUI::activeStudy()
1172 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1174 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1179 //=============================================================================
1183 //=============================================================================
1184 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1186 /* Here the position is on the bottom right corner - 10 */
1187 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1189 SUIT_Desktop *PP = desktop();
1190 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1191 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1195 //=============================================================================
1199 //=============================================================================
1200 static int isStudyLocked(_PTR(Study) theStudy){
1201 return theStudy->GetProperties()->IsLocked();
1204 static bool checkLock(_PTR(Study) theStudy) {
1205 if (isStudyLocked(theStudy)) {
1206 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1207 QObject::tr("WRN_WARNING"),
1208 QObject::tr("WRN_STUDY_LOCKED") );
1214 //=======================================================================
1215 //function : CheckActiveStudyLocked
1217 //=======================================================================
1219 bool SMESHGUI::isActiveStudyLocked()
1221 _PTR(Study) aStudy = activeStudy()->studyDS();
1222 return checkLock( aStudy );
1225 //=============================================================================
1229 //=============================================================================
1230 bool SMESHGUI::OnGUIEvent( int theCommandID )
1232 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1236 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1237 SUIT_ResourceMgr* mgr = resourceMgr();
1241 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1242 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1245 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1246 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1248 //QAction* act = action( theCommandID );
1250 switch (theCommandID) {
1252 if(checkLock(aStudy)) break;
1260 if(checkLock(aStudy)) break;
1261 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1265 case 122: // EXPORT MED
1274 ::ExportMeshToFile(theCommandID);
1278 case 200: // SCALAR BAR
1280 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1281 SALOME_ListIO selected;
1283 aSel->selectedObjects( selected );
1285 if( selected.Extent() ) {
1286 Handle(SALOME_InteractiveObject) anIO = selected.First();
1287 if( anIO->hasEntry() ) {
1288 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1289 anActor->SetControlMode( SMESH_Actor::eNone );
1297 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1307 ::DisableAutoColor();
1310 case 1134: // Clipping
1311 case 1133: // Tranparency
1312 case 1132: // Colors / Size
1319 ::SetDisplayMode(theCommandID);
1325 case 219: // Volumes
1326 case 220: // All Entity
1327 ::SetDisplayEntity(theCommandID);
1332 if(checkLock(aStudy)) break;
1334 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1337 SMESH::UpdateView();
1339 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1340 SMESH::OnVisuException();
1342 catch (...) { // PAL16774 (Crash after display of many groups)
1343 SMESH::OnVisuException();
1347 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1348 aSel->selectedObjects( l );
1349 aSel->setSelectedObjects( l );
1354 case 301: // DISPLAY
1355 case 302: // DISPLAY ONLY
1357 SMESH::EDisplaing anAction;
1358 switch (theCommandID) {
1359 case 300: anAction = SMESH::eErase; break;
1360 case 301: anAction = SMESH::eDisplay; break;
1361 case 302: anAction = SMESH::eDisplayOnly; break;
1364 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1365 SALOME_ListIO sel_objects, to_process;
1367 aSel->selectedObjects( sel_objects );
1369 if( theCommandID==302 )
1370 startOperation( myEraseAll );
1372 extractContainers( sel_objects, to_process );
1375 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1379 SALOME_ListIteratorOfListIO It( to_process );
1380 for ( ; It.More(); It.Next()) {
1381 Handle(SALOME_InteractiveObject) IOS = It.Value();
1382 if (IOS->hasEntry()) {
1383 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1384 break; // PAL16774 (Crash after display of many groups)
1385 if (anAction == SMESH::eDisplayOnly)
1386 anAction = SMESH::eDisplay;
1391 // PAL13338 + PAL15161 -->
1392 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1393 SMESH::UpdateView();
1394 // PAL13338 + PAL15161 <--
1396 catch (...) { // PAL16774 (Crash after display of many groups)
1397 SMESH::OnVisuException();
1400 if (anAction == SMESH::eErase) {
1402 aSel->setSelectedObjects( l1 );
1405 aSel->setSelectedObjects( to_process );
1412 if(checkLock(aStudy)) break;
1415 EmitSignalDeactivateDialog();
1417 ( new SMESHGUI_NodesDlg( this ) )->show();
1420 SUIT_MessageBox::warning(desktop(),
1421 tr("SMESH_WRN_WARNING"),
1422 tr("SMESH_WRN_VIEWER_VTK"));
1427 case 2151: // FILTER
1431 EmitSignalDeactivateDialog();
1432 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1437 case 406: // MOVE NODE
1441 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1442 tr( "NOT_A_VTK_VIEWER" ) );
1446 if(checkLock(aStudy)) break;
1447 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1451 case 701: // COMPUTE MESH
1453 if (checkLock(aStudy)) break;
1455 startOperation( 701 );
1459 case 702: // Create mesh
1460 startOperation( 702 );
1462 case 703: // Create sub-mesh
1463 startOperation( 703 );
1465 case 704: // Edit mesh/sub-mesh
1466 startOperation( 704 );
1468 case 710: // Build compound mesh
1470 if (checkLock(aStudy)) break;
1471 EmitSignalDeactivateDialog();
1472 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1475 case 407: // DIAGONAL INVERSION
1476 case 408: // Delete diagonal
1480 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1481 tr( "NOT_A_VTK_VIEWER" ) );
1485 if ( checkLock( aStudy ) )
1488 /*Standard_Boolean aRes;
1489 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1490 if ( aMesh->_is_nil() )
1492 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1493 tr( "SMESH_BAD_SELECTION" ) );
1497 EmitSignalDeactivateDialog();
1498 if ( theCommandID == 407 )
1499 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1501 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1504 case 409: // Change orientation
1505 case 410: // Union of triangles
1506 case 411: // Cutting of quadrangles
1510 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1511 tr( "NOT_A_VTK_VIEWER" ) );
1515 if ( checkLock( aStudy ) )
1518 EmitSignalDeactivateDialog();
1519 SMESHGUI_MultiEditDlg* aDlg = NULL;
1520 if ( theCommandID == 409 )
1521 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1522 else if ( theCommandID == 410 )
1523 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1525 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1530 case 412: // Smoothing
1532 if(checkLock(aStudy)) break;
1534 EmitSignalDeactivateDialog();
1535 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1538 SUIT_MessageBox::warning(desktop(),
1539 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1543 case 413: // Extrusion
1545 if (checkLock(aStudy)) break;
1547 EmitSignalDeactivateDialog();
1548 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1550 SUIT_MessageBox::warning(desktop(),
1551 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1555 case 414: // Revolution
1557 if(checkLock(aStudy)) break;
1559 EmitSignalDeactivateDialog();
1560 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1563 SUIT_MessageBox::warning(desktop(),
1564 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1568 case 415: // Pattern mapping
1570 if ( checkLock( aStudy ) )
1574 EmitSignalDeactivateDialog();
1575 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1578 SUIT_MessageBox::warning(desktop(),
1579 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1583 case 416: // Extrusion along a path
1585 if (checkLock(aStudy)) break;
1587 EmitSignalDeactivateDialog();
1588 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1590 SUIT_MessageBox::warning(desktop(),
1591 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1595 case 417: // Convert mesh to quadratic
1597 startOperation( 417 );
1598 /* if (checkLock(aStudy)) break;
1600 EmitSignalDeactivateDialog();
1601 new SMESHGUI_ConvToQuadDlg();
1603 SUIT_MessageBox::warning(desktop(),
1604 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1608 case 801: // CREATE GROUP
1612 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1613 tr( "NOT_A_VTK_VIEWER" ) );
1617 if(checkLock(aStudy)) break;
1618 EmitSignalDeactivateDialog();
1619 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1621 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1622 SALOME_ListIO selected;
1624 aSel->selectedObjects( selected );
1626 int nbSel = selected.Extent();
1628 // check if mesh is selected
1629 aMesh = SMESH::GetMeshByIO( selected.First() );
1631 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1636 case 802: // CONSTRUCT GROUP
1640 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1641 tr( "NOT_A_VTK_VIEWER" ) );
1645 if(checkLock(aStudy)) break;
1646 EmitSignalDeactivateDialog();
1648 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1649 SALOME_ListIO selected;
1651 aSel->selectedObjects( selected );
1653 int nbSel = selected.Extent();
1655 // check if submesh is selected
1656 Handle(SALOME_InteractiveObject) IObject = selected.First();
1657 if (IObject->hasEntry()) {
1658 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1660 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1661 if (!aSubMesh->_is_nil()) {
1663 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1664 // get submesh elements list by types
1665 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1666 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1667 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1668 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1669 // create group for each type o elements
1670 QString aName = IObject->getName();
1671 if (aNodes->length() > 0) {
1672 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1673 aGroup->Add(aNodes.inout());
1675 if (aEdges->length() > 0) {
1676 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1677 aGroup->Add(aEdges.inout());
1679 if (aFaces->length() > 0) {
1680 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1681 aGroup->Add(aFaces.inout());
1683 if (aVolumes->length() > 0) {
1684 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1685 aGroup->Add(aVolumes.inout());
1690 catch(const SALOME::SALOME_Exception & S_ex){
1691 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1698 SUIT_MessageBox::warning(desktop(),
1699 tr("SMESH_WRN_WARNING"),
1700 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1705 case 803: // EDIT GROUP
1709 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1710 tr( "NOT_A_VTK_VIEWER" ) );
1714 if(checkLock(aStudy)) break;
1715 EmitSignalDeactivateDialog();
1717 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1718 SALOME_ListIO selected;
1720 aSel->selectedObjects( selected );
1722 SALOME_ListIteratorOfListIO It (selected);
1723 int nbSelectedGroups = 0;
1724 for ( ; It.More(); It.Next() )
1726 SMESH::SMESH_GroupBase_var aGroup =
1727 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1728 if (!aGroup->_is_nil()) {
1730 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1734 if (nbSelectedGroups == 0)
1736 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1742 case 804: // Add elements to group
1744 if(checkLock(aStudy)) break;
1745 if (myState == 800) {
1746 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1747 if (aDlg) aDlg->onAdd();
1752 case 805: // Remove elements from group
1754 if(checkLock(aStudy)) break;
1755 if (myState == 800) {
1756 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1757 if (aDlg) aDlg->onRemove();
1762 case 810: // Union Groups
1763 case 811: // Intersect groups
1764 case 812: // Cut groups
1768 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1769 tr( "NOT_A_VTK_VIEWER" ) );
1773 if ( checkLock( aStudy ) )
1776 EmitSignalDeactivateDialog();
1779 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1780 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1781 else aMode = SMESHGUI_GroupOpDlg::CUT;
1783 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1787 case 813: // Delete groups with their contents
1791 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1792 tr( "NOT_A_VTK_VIEWER" ) );
1796 if ( checkLock( aStudy ) )
1799 EmitSignalDeactivateDialog();
1801 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1805 case 900: // MESH INFOS
1807 EmitSignalDeactivateDialog();
1808 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1809 SALOME_ListIO selected;
1811 aSel->selectedObjects( selected );
1813 if ( selected.Extent() > 1 ) { // a dlg for each IO
1815 SALOME_ListIteratorOfListIO It (selected);
1816 for ( ; It.More(); It.Next() ) {
1817 IOs.Clear(); IOs.Append( It.Value() );
1818 aSel->setSelectedObjects( IOs );
1819 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1821 // restore selection
1822 aSel->setSelectedObjects( selected );
1825 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1829 case 902: // STANDARD MESH INFOS
1831 EmitSignalDeactivateDialog();
1832 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1833 SALOME_ListIO selected;
1835 aSel->selectedObjects( selected );
1837 if ( selected.Extent() > 1 ) { // a dlg for each IO
1839 SALOME_ListIteratorOfListIO It (selected);
1840 for ( ; It.More(); It.Next() ) {
1842 IOs.Append( It.Value() );
1843 aSel->setSelectedObjects( IOs );
1844 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1846 // restore selection
1847 aSel->setSelectedObjects( selected );
1850 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1854 case 903: // WHAT IS
1856 EmitSignalDeactivateDialog();
1857 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1861 case 1100: // EDIT HYPOTHESIS
1863 if(checkLock(aStudy)) break;
1865 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1866 SALOME_ListIO selected;
1868 aSel->selectedObjects( selected );
1870 int nbSel = selected.Extent();
1873 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1874 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1876 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1877 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1878 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1879 if ( !aHypothesis->_is_nil() )
1881 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
1883 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1890 updateObjBrowser( true );
1894 case 1101: // RENAME
1896 if ( checkLock( aStudy ) )
1899 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1900 SALOME_ListIO selected;
1902 aSel->selectedObjects( selected );
1904 SALOME_ListIteratorOfListIO It( selected );
1905 for ( ; It.More(); It.Next() )
1907 Handle(SALOME_InteractiveObject) IObject = It.Value();
1908 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1909 _PTR(GenericAttribute) anAttr;
1910 _PTR(AttributeName) aName;
1913 if ( obj->FindAttribute(anAttr, "AttributeName") )
1916 QString newName = QString(aName->Value().c_str());
1917 newName = LightApp_NameDlg::getName(desktop(), newName);
1918 if ( !newName.isEmpty() )
1920 //old source: aStudy->renameIObject( IObject, newName );
1921 aName->SetValue( newName.toLatin1().data() );
1923 // if current object is group update group's name
1924 SMESH::SMESH_GroupBase_var aGroup =
1925 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1926 if (!aGroup->_is_nil() )
1927 aGroup->SetName( newName.toLatin1().data() );
1937 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1939 if(checkLock(aStudy)) break;
1940 SUIT_OverrideCursor wc;
1942 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1943 SALOME_ListIO selected;
1945 aSel->selectedObjects( selected, QString::null, false );
1947 SALOME_ListIteratorOfListIO It(selected);
1948 for (int i = 0; It.More(); It.Next(), i++) {
1949 Handle(SALOME_InteractiveObject) IObject = It.Value();
1950 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1953 aSel->setSelectedObjects( l1 );
1958 case 401: // GEOM::EDGE
1959 case 4021: // TRIANGLE
1961 case 4023: // POLYGON
1965 if(checkLock(aStudy)) break;
1967 EmitSignalDeactivateDialog();
1968 SMDSAbs_ElementType type = SMDSAbs_Edge;
1970 switch (theCommandID) {
1971 case 4021: // TRIANGLE
1972 type = SMDSAbs_Face; nbNodes = 3; break;
1974 type = SMDSAbs_Face; nbNodes = 4; break;
1976 type = SMDSAbs_Volume; nbNodes = 4; break;
1977 case 4023: // POLYGON
1978 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1980 type = SMDSAbs_Volume; nbNodes = 8; break;
1981 case 4033: // POLYHEDRE
1982 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1985 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
1988 SUIT_MessageBox::warning(desktop(),
1989 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1993 case 4033: // POLYHEDRON
1995 if(checkLock(aStudy)) break;
1997 EmitSignalDeactivateDialog();
1998 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2001 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2002 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2006 case 4034: // QUADRATIC EDGE
2007 case 4035: // QUADRATIC TRIANGLE
2008 case 4036: // QUADRATIC QUADRANGLE
2009 case 4037: // QUADRATIC TETRAHEDRON
2010 case 4038: // QUADRATIC PYRAMID
2011 case 4039: // QUADRATIC PENTAHEDRON
2012 case 4040: // QUADRATIC HEXAHEDRON
2014 if(checkLock(aStudy)) break;
2016 EmitSignalDeactivateDialog();
2019 switch (theCommandID) {
2021 type = QUAD_EDGE; break;
2023 type = QUAD_TRIANGLE; break;
2025 type = QUAD_QUADRANGLE; break;
2027 type = QUAD_TETRAHEDRON; break;
2029 type = QUAD_PYRAMID; break;
2031 type = QUAD_PENTAHEDRON; break;
2033 type = QUAD_HEXAHEDRON;
2037 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2040 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2041 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2045 case 4041: // REMOVES NODES
2047 if(checkLock(aStudy)) break;
2049 EmitSignalDeactivateDialog();
2050 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2053 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2058 case 4042: // REMOVES ELEMENTS
2060 if(checkLock(aStudy)) break;
2062 EmitSignalDeactivateDialog();
2063 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2067 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2068 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2072 case 4051: // RENUMBERING NODES
2074 if(checkLock(aStudy)) break;
2076 EmitSignalDeactivateDialog();
2077 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2081 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2082 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2086 case 4052: // RENUMBERING ELEMENTS
2088 if(checkLock(aStudy)) break;
2090 EmitSignalDeactivateDialog();
2091 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2095 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2096 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2100 case 4061: // TRANSLATION
2102 if(checkLock(aStudy)) break;
2104 EmitSignalDeactivateDialog();
2105 ( new SMESHGUI_TranslationDlg( this ) )->show();
2108 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2109 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2113 case 4062: // ROTATION
2115 if(checkLock(aStudy)) break;
2117 EmitSignalDeactivateDialog();
2118 ( new SMESHGUI_RotationDlg( this ) )->show();
2121 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2122 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2126 case 4063: // SYMMETRY
2128 if(checkLock(aStudy)) break;
2130 EmitSignalDeactivateDialog();
2131 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2134 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2135 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2139 case 4064: // SEWING
2141 if(checkLock(aStudy)) break;
2143 EmitSignalDeactivateDialog();
2144 ( new SMESHGUI_SewingDlg( this ) )->show();
2147 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2148 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2152 case 4065: // MERGE NODES
2154 if(checkLock(aStudy)) break;
2156 EmitSignalDeactivateDialog();
2157 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2160 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2165 case 4066: // MERGE EQUAL ELEMENTS
2167 if (checkLock(aStudy)) break;
2169 EmitSignalDeactivateDialog();
2170 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2172 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2173 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2178 case 4067: // MAKE MESH PASS THROUGH POINT
2179 startOperation( 4067 );
2182 case 5105: // Library of selection filters
2184 static QList<int> aTypes;
2185 if ( aTypes.isEmpty() )
2187 aTypes.append( SMESH::NODE );
2188 aTypes.append( SMESH::EDGE );
2189 aTypes.append( SMESH::FACE );
2190 aTypes.append( SMESH::VOLUME );
2192 if (!myFilterLibraryDlg)
2193 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2194 else if (myFilterLibraryDlg->isHidden())
2195 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2196 myFilterLibraryDlg->raise();
2200 case 6017: // CONTROLS
2216 LightApp_SelectionMgr* mgr = selectionMgr();
2217 SALOME_ListIO selected; mgr->selectedObjects( selected );
2219 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2220 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2222 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2223 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2224 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2225 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2226 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2227 ::Control( theCommandID );
2232 SUIT_MessageBox::warning(desktop(),
2233 tr( "SMESH_WRN_WARNING" ),
2234 tr( "SMESH_BAD_SELECTION" ) );
2238 SUIT_MessageBox::warning(desktop(),
2239 tr( "SMESH_WRN_WARNING" ),
2240 tr( "NOT_A_VTK_VIEWER" ) );
2245 LightApp_SelectionMgr* mgr = selectionMgr();
2246 SALOME_ListIO selected; mgr->selectedObjects( selected );
2248 SALOME_ListIteratorOfListIO it(selected);
2249 for( ; it.More(); it.Next()) {
2250 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2251 if(anIObject->hasEntry()) {
2252 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2253 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2261 LightApp_SelectionMgr* mgr = selectionMgr();
2262 SALOME_ListIO selected; mgr->selectedObjects( selected );
2264 if (selected.Extent() == 1) {
2265 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2266 if(anIObject->hasEntry())
2267 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2268 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2275 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2276 //updateObjBrowser();
2280 //=============================================================================
2284 //=============================================================================
2285 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2290 //=============================================================================
2294 //=============================================================================
2295 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2300 //=============================================================================
2304 //=============================================================================
2305 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2310 //=============================================================================
2311 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2312 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2314 //=============================================================================
2315 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2316 SUIT_ViewWindow* wnd )
2318 if(theIO->hasEntry()){
2319 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2320 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2324 //=======================================================================
2325 // function : createSMESHAction
2327 //=======================================================================
2328 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2331 QWidget* parent = application()->desktop();
2332 SUIT_ResourceMgr* resMgr = resourceMgr();
2334 if ( !icon_id.isEmpty() )
2335 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2337 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2338 if ( !pix.isNull() )
2339 icon = QIcon( pix );
2341 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2342 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2343 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2345 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2348 //=======================================================================
2349 // function : createPopupItem
2351 //=======================================================================
2352 void SMESHGUI::createPopupItem( const int id,
2353 const QString& clients,
2354 const QString& types,
2355 const QString& theRule,
2360 parentId = popupMgr()->actionId( action( pId ) );
2362 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2363 popupMgr()->insert( action( id ), parentId, 0 );
2365 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2366 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2367 QString rule = "(%1) and (%2) and (%3)";
2368 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2369 if( clients.isEmpty() )
2370 rule = rule.arg( QString( "true" ) );
2372 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2373 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2376 bool cont = myRules.contains( id );
2378 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2380 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2381 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2384 //=======================================================================
2385 // function : initialize
2387 //=======================================================================
2388 void SMESHGUI::initialize( CAM_Application* app )
2390 SalomeApp_Module::initialize( app );
2392 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2394 /* Automatic Update flag */
2395 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2397 // ----- create actions --------------
2399 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2400 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2401 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2402 createSMESHAction( 114, "NUM" );
2403 createSMESHAction( 121, "DAT" );
2404 createSMESHAction( 122, "MED" );
2405 createSMESHAction( 123, "UNV" );
2406 createSMESHAction( 140, "STL" );
2407 createSMESHAction( 124, "EXPORT_DAT" );
2408 createSMESHAction( 125, "EXPORT_MED" );
2409 createSMESHAction( 126, "EXPORT_UNV" );
2410 createSMESHAction( 141, "EXPORT_STL" );
2411 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2412 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2413 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2414 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2415 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2416 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2417 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2418 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2419 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2420 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2421 createSMESHAction( 804, "ADD" );
2422 createSMESHAction( 805, "REMOVE" );
2423 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2424 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2425 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2426 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2427 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2428 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2429 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2430 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2431 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2432 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2433 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2434 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2435 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2436 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2437 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2438 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2439 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2440 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2441 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2442 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2443 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2444 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2445 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2446 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2447 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2448 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2449 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2450 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2451 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2452 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2453 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2454 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2455 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2456 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2457 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2458 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2459 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2460 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2461 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2462 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2463 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2464 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2465 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2466 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2467 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2468 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2469 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2470 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2471 createSMESHAction( 415, "MAP", "ICON_MAP" );
2472 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2473 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2474 createSMESHAction( 200, "RESET" );
2475 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2476 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2477 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2478 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2479 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2480 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2481 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2482 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2483 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2484 createSMESHAction( 220, "ALL" );
2485 createSMESHAction( 1100, "EDIT_HYPO" );
2486 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2487 createSMESHAction( 1102, "UNASSIGN" );
2488 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2489 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2490 createSMESHAction( 1131, "DISPMODE" );
2491 createSMESHAction( 1132, "COLORS" );
2492 createSMESHAction( 1133, "TRANSP" );
2493 createSMESHAction( 1134, "CLIP" );
2494 createSMESHAction( 1135, "DISP_ENT" );
2495 createSMESHAction( 1136, "AUTO_COLOR" );
2496 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2497 createSMESHAction( 2000, "CTRL" );
2499 createSMESHAction( 300, "ERASE" );
2500 createSMESHAction( 301, "DISPLAY" );
2501 createSMESHAction( 302, "DISPLAY_ONLY" );
2502 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2503 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2504 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2505 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2506 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2507 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2508 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2509 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2511 // ----- create menu --------------
2512 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2513 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2514 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2515 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2516 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2517 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2518 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2520 createMenu( separator(), fileId );
2522 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2523 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2524 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2525 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2526 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2527 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2529 createMenu( 111, importId, -1 );
2530 createMenu( 112, importId, -1 );
2531 createMenu( 113, importId, -1 );
2533 createMenu( 121, exportId, -1 );
2534 createMenu( 122, exportId, -1 );
2535 createMenu( 123, exportId, -1 );
2536 createMenu( 140, exportId, -1 ); // export to stl STL
2538 createMenu( separator(), fileId, 10 );
2540 createMenu( 33, editId, -1 );
2542 createMenu( 5105, toolsId, -1 );
2544 createMenu( 702, meshId, -1 );
2545 createMenu( 703, meshId, -1 );
2546 createMenu( 704, meshId, -1 );
2547 createMenu( 710, meshId, -1 );
2548 createMenu( separator(), meshId, -1 );
2549 createMenu( 701, meshId, -1 );
2550 createMenu( separator(), meshId, -1 );
2551 createMenu( 801, meshId, -1 );
2552 createMenu( 802, meshId, -1 );
2553 createMenu( 803, meshId, -1 );
2554 createMenu( separator(), meshId, -1 );
2555 createMenu( 810, meshId, -1 );
2556 createMenu( 811, meshId, -1 );
2557 createMenu( 812, meshId, -1 );
2558 createMenu( separator(), meshId, -1 );
2559 createMenu( 813, meshId, -1 );
2560 createMenu( separator(), meshId, -1 );
2561 createMenu( 900, meshId, -1 );
2562 createMenu( 902, meshId, -1 );
2563 createMenu( 903, meshId, -1 );
2564 createMenu( separator(), meshId, -1 );
2566 createMenu( 6003, ctrlId, -1 );
2567 createMenu( 6001, ctrlId, -1 );
2568 createMenu( 6004, ctrlId, -1 );
2569 createMenu( separator(), ctrlId, -1 );
2570 createMenu( 6002, ctrlId, -1 );
2571 createMenu( 6018, ctrlId, -1 );
2572 createMenu( 6019, ctrlId, -1 );
2573 createMenu( 6011, ctrlId, -1 );
2574 createMenu( 6012, ctrlId, -1 );
2575 createMenu( 6013, ctrlId, -1 );
2576 createMenu( 6014, ctrlId, -1 );
2577 createMenu( 6015, ctrlId, -1 );
2578 createMenu( 6016, ctrlId, -1 );
2579 createMenu( separator(), ctrlId, -1 );
2580 createMenu( 6017, ctrlId, -1 );
2581 createMenu( 6009, ctrlId, -1 );
2582 createMenu( separator(), ctrlId, -1 );
2584 createMenu( 400, addId, -1 );
2585 createMenu( 401, addId, -1 );
2586 createMenu( 4021, addId, -1 );
2587 createMenu( 4022, addId, -1 );
2588 createMenu( 4023, addId, -1 );
2589 createMenu( 4031, addId, -1 );
2590 createMenu( 4032, addId, -1 );
2591 createMenu( 4033, addId, -1 );
2592 createMenu( separator(), addId, -1 );
2593 createMenu( 4034, addId, -1 );
2594 createMenu( 4035, addId, -1 );
2595 createMenu( 4036, addId, -1 );
2596 createMenu( 4037, addId, -1 );
2597 createMenu( 4038, addId, -1 );
2598 createMenu( 4039, addId, -1 );
2599 createMenu( 4040, addId, -1 );
2601 createMenu( 4041, removeId, -1 );
2602 createMenu( 4042, removeId, -1 );
2604 createMenu( 4051, renumId, -1 );
2605 createMenu( 4052, renumId, -1 );
2607 createMenu( 4061, transfId, -1 );
2608 createMenu( 4062, transfId, -1 );
2609 createMenu( 4063, transfId, -1 );
2610 createMenu( 4064, transfId, -1 );
2611 createMenu( 4065, transfId, -1 );
2612 createMenu( 4066, transfId, -1 );
2614 createMenu( 406, modifyId, -1 );
2615 createMenu( 4067,modifyId, -1 );
2616 createMenu( 407, modifyId, -1 );
2617 createMenu( 408, modifyId, -1 );
2618 createMenu( 409, modifyId, -1 );
2619 createMenu( 410, modifyId, -1 );
2620 createMenu( 411, modifyId, -1 );
2621 createMenu( 412, modifyId, -1 );
2622 createMenu( 413, modifyId, -1 );
2623 createMenu( 416, modifyId, -1 );
2624 createMenu( 414, modifyId, -1 );
2625 createMenu( 415, modifyId, -1 );
2626 createMenu( 417, modifyId, -1 );
2628 createMenu( 214, viewId, -1 );
2630 // ----- create toolbars --------------
2631 int meshTb = createTool( tr( "TB_MESH" ) ),
2632 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2633 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2634 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2635 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2637 createTool( 702, meshTb );
2638 createTool( 703, meshTb );
2639 createTool( 704, meshTb );
2640 createTool( 710, meshTb );
2641 createTool( separator(), meshTb );
2642 createTool( 701, meshTb );
2643 createTool( separator(), meshTb );
2644 createTool( 801, meshTb );
2645 createTool( 802, meshTb );
2646 createTool( 803, meshTb );
2647 createTool( separator(), meshTb );
2648 createTool( 900, meshTb );
2649 createTool( 902, meshTb );
2650 createTool( 903, meshTb );
2651 createTool( separator(), meshTb );
2653 createTool( 6001, ctrlTb );
2654 createTool( 6003, ctrlTb );
2655 createTool( 6004, ctrlTb );
2656 createTool( separator(), ctrlTb );
2657 createTool( 6002, ctrlTb );
2658 createTool( 6018, ctrlTb );
2659 createTool( 6019, ctrlTb );
2660 createTool( 6011, ctrlTb );
2661 createTool( 6012, ctrlTb );
2662 createTool( 6013, ctrlTb );
2663 createTool( 6014, ctrlTb );
2664 createTool( 6015, ctrlTb );
2665 createTool( 6016, ctrlTb );
2666 createTool( separator(), ctrlTb );
2667 createTool( 6017, ctrlTb );
2668 createTool( 6009, ctrlTb );
2669 createTool( separator(), ctrlTb );
2671 createTool( 400, addRemTb );
2672 createTool( 401, addRemTb );
2673 createTool( 4021, addRemTb );
2674 createTool( 4022, addRemTb );
2675 createTool( 4023, addRemTb );
2676 createTool( 4031, addRemTb );
2677 createTool( 4032, addRemTb );
2678 createTool( 4033, addRemTb );
2679 createTool( separator(), addRemTb );
2680 createTool( 4034, addRemTb );
2681 createTool( 4035, addRemTb );
2682 createTool( 4036, addRemTb );
2683 createTool( 4037, addRemTb );
2684 createTool( 4038, addRemTb );
2685 createTool( 4039, addRemTb );
2686 createTool( 4040, addRemTb );
2687 createTool( separator(), addRemTb );
2688 createTool( 4041, addRemTb );
2689 createTool( 4042, addRemTb );
2690 createTool( separator(), addRemTb );
2691 createTool( 4051, addRemTb );
2692 createTool( 4052, addRemTb );
2693 createTool( separator(), addRemTb );
2694 createTool( 4061, addRemTb );
2695 createTool( 4062, addRemTb );
2696 createTool( 4063, addRemTb );
2697 createTool( 4064, addRemTb );
2698 createTool( 4065, addRemTb );
2699 createTool( 4066, addRemTb );
2700 createTool( separator(), addRemTb );
2702 createTool( 406, modifyTb );
2703 createTool( 4067,modifyTb );
2704 createTool( 407, modifyTb );
2705 createTool( 408, modifyTb );
2706 createTool( 409, modifyTb );
2707 createTool( 410, modifyTb );
2708 createTool( 411, modifyTb );
2709 createTool( 412, modifyTb );
2710 createTool( 413, modifyTb );
2711 createTool( 416, modifyTb );
2712 createTool( 414, modifyTb );
2713 createTool( 415, modifyTb );
2714 createTool( 417, modifyTb );
2716 createTool( 214, dispModeTb );
2718 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2719 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2722 QString OB = "'ObjectBrowser'",
2723 View = "'" + SVTK_Viewer::Type() + "'",
2725 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2726 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2727 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2728 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2729 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2730 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2731 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2732 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2733 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2734 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2735 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2737 mesh_group = mesh + " " + subMesh + " " + group,
2738 hyp_alg = hypo + " " + algo;
2740 // popup for object browser
2742 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2743 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2744 createPopupItem( 803, OB, group ); // EDIT_GROUP
2745 popupMgr()->insert( separator(), -1, 0 );
2746 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2747 createPopupItem( 214, OB, mesh_group ); // UPDATE
2748 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2749 createPopupItem( 902, OB, mesh ); // STD_INFO
2750 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2751 popupMgr()->insert( separator(), -1, 0 );
2752 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2753 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2754 popupMgr()->insert( separator(), -1, 0 );
2755 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2756 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2757 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2758 popupMgr()->insert( separator(), -1, 0 );
2760 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2761 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2762 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2763 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2764 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2765 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2766 popupMgr()->insert( separator(), -1, 0 );
2769 createPopupItem( 803, View, group ); // EDIT_GROUP
2770 createPopupItem( 804, View, elems ); // ADD
2771 createPopupItem( 805, View, elems ); // REMOVE
2772 popupMgr()->insert( separator(), -1, 0 );
2773 createPopupItem( 214, View, mesh_group ); // UPDATE
2774 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2775 createPopupItem( 902, View, mesh ); // STD_INFO
2776 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2777 popupMgr()->insert( separator(), -1, 0 );
2779 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2780 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2781 popupMgr()->insert( separator(), -1, 0 );
2785 isInvisible("not( isVisible )"),
2786 isEmpty("numberOfNodes = 0"),
2787 isNotEmpty("numberOfNodes <> 0"),
2789 // has nodes, edges, etc in VISIBLE! actor
2790 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2791 hasElems("(count( elemTypes ) > 0)"),
2792 hasDifferentElems("(count( elemTypes ) > 1)"),
2793 hasEdges("({'Edge'} in elemTypes)"),
2794 hasFaces("({'Face'} in elemTypes)"),
2795 hasVolumes("({'Volume'} in elemTypes)");
2797 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2798 QString aType = QString( "%1type in {%2}" ).arg( lc );
2799 aType = aType.arg( mesh_group );
2800 QString aMeshInVTK = aClient + "&&" + aType;
2802 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2803 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2804 QString aSelCount = QString( "%1 > 0" ).arg( dc );
2806 //-------------------------------------------------
2808 //-------------------------------------------------
2809 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2811 popupMgr()->insert( action( 9010 ), anId, -1 );
2812 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
2813 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
2815 popupMgr()->insert( action( 9011 ), anId, -1 );
2816 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
2817 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
2819 popupMgr()->insert( separator(), -1, -1 );
2821 //-------------------------------------------------
2823 //-------------------------------------------------
2824 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2826 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2827 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
2828 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
2830 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2831 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
2832 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
2834 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2835 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
2836 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
2838 popupMgr()->insert( separator(), anId, -1 );
2840 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2841 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
2842 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
2844 //-------------------------------------------------
2846 //-------------------------------------------------
2847 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2849 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2851 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2852 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
2853 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
2855 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2856 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
2857 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
2859 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2860 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
2861 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
2863 popupMgr()->insert( separator(), anId, -1 );
2865 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2866 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
2868 //-------------------------------------------------
2870 //-------------------------------------------------
2871 popupMgr()->insert( action( 1132 ), -1, -1 );
2872 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2874 //-------------------------------------------------
2876 //-------------------------------------------------
2877 popupMgr()->insert( action( 1133 ), -1, -1 );
2878 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2880 //-------------------------------------------------
2882 //-------------------------------------------------
2883 popupMgr()->insert( action( 1134 ), -1, -1 );
2884 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2886 popupMgr()->insert( separator(), -1, -1 );
2888 //-------------------------------------------------
2890 //-------------------------------------------------
2892 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2893 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2894 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2896 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2898 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2899 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2901 popupMgr()->insert( separator(), anId, -1 );
2903 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2904 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2905 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
2907 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2908 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2909 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
2911 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2912 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2913 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
2915 popupMgr()->insert( separator(), anId, -1 );
2917 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2918 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2919 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
2921 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2922 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2923 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
2925 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2926 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2927 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
2929 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2930 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2931 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
2933 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2934 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2935 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
2937 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2938 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2939 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
2941 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2942 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2943 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
2945 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2946 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2947 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
2949 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2950 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2951 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
2953 popupMgr()->insert( separator(), anId, -1 );
2955 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2956 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2957 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
2959 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2960 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2961 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
2963 popupMgr()->insert( separator(), anId, -1 );
2965 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2966 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2968 popupMgr()->insert( separator(), -1, -1 );
2970 //-------------------------------------------------
2972 //-------------------------------------------------
2973 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2974 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2975 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2976 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
2978 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2979 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
2981 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2982 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
2984 popupMgr()->insert( separator(), -1, -1 );
2986 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2987 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2990 bool SMESHGUI::activateModule( SUIT_Study* study )
2992 bool res = SalomeApp_Module::activateModule( study );
2994 setMenuShown( true );
2995 setToolShown( true );
2997 // Reset actions accelerator keys
2998 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
2999 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3000 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3005 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3007 setMenuShown( false );
3008 setToolShown( false );
3010 EmitSignalCloseAllDialogs();
3012 // Unset actions accelerator keys
3013 action(111)->setShortcut(QKeySequence()); // Import DAT
3014 action(112)->setShortcut(QKeySequence()); // Import UNV
3015 action(113)->setShortcut(QKeySequence()); // Import MED
3017 return SalomeApp_Module::deactivateModule( study );
3020 void SMESHGUI::studyClosed( SUIT_Study* s )
3022 SMESH::RemoveVisuData( s->id() );
3023 SalomeApp_Module::studyClosed( s );
3026 void SMESHGUI::OnGUIEvent()
3028 const QObject* obj = sender();
3029 if ( !obj || !obj->inherits( "QAction" ) )
3031 int id = actionId((QAction*)obj);
3036 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3038 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3039 if ( CORBA::is_nil( myComponentSMESH ) )
3041 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3043 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3044 return aGUI.myComponentSMESH;
3047 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3048 return myComponentSMESH;
3051 QString SMESHGUI::engineIOR() const
3053 CORBA::ORB_var anORB = getApp()->orb();
3054 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3055 return QString( anIOR.in() );
3058 LightApp_Selection* SMESHGUI::createSelection() const
3060 return new SMESHGUI_Selection();
3063 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3065 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3066 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3069 void SMESHGUI::viewManagers( QStringList& list ) const
3071 list.append( SVTK_Viewer::Type() );
3074 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3076 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3077 SMESH::UpdateSelectionProp( this );
3080 void SMESHGUI::createPreferences()
3082 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3084 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3085 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3087 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3088 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3089 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3091 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3092 setPreferenceProperty( precGroup, "columns", 1 );
3094 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3096 setPreferenceProperty( prec, "min", 0 );
3097 setPreferenceProperty( prec, "max", 16 );
3099 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3100 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3102 modes.append( "Wireframe" );
3103 modes.append( "Shading" );
3104 modes.append( "Nodes" );
3105 modes.append( "Shrink" );
3106 QList<QVariant> indices;
3107 indices.append( 0 );
3108 indices.append( 1 );
3109 indices.append( 2 );
3110 indices.append( 3 );
3111 setPreferenceProperty( dispmode, "strings", modes );
3112 setPreferenceProperty( dispmode, "indexes", indices );
3114 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3115 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3116 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3118 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3119 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3121 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3122 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3124 setPreferenceProperty( nodeSz, "min", 1 );
3125 setPreferenceProperty( nodeSz, "max", 5 );
3127 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3129 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3130 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3131 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3132 addPreference( "", elemGroup, LightApp_Preferences::Space );
3134 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3135 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3137 setPreferenceProperty( elemW, "min", 1 );
3138 setPreferenceProperty( elemW, "max", 5 );
3140 setPreferenceProperty( shrink, "min", 0 );
3141 setPreferenceProperty( shrink, "max", 100 );
3143 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3145 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3147 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3148 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3149 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3151 setPreferenceProperty( selW, "min", 1 );
3152 setPreferenceProperty( selW, "max", 5 );
3154 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3156 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3157 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3159 setPreferenceProperty( preW, "min", 1 );
3160 setPreferenceProperty( preW, "max", 5 );
3162 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3164 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3165 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3166 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3168 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3169 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3171 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3172 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3173 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3174 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3177 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3178 fam.append( tr( "SMESH_FONT_COURIER" ) );
3179 fam.append( tr( "SMESH_FONT_TIMES" ) );
3180 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3182 setPreferenceProperty( tfont, "families", fam );
3183 setPreferenceProperty( tfont, "system", false );
3184 setPreferenceProperty( tfont, "widget_flags", wflag );
3185 setPreferenceProperty( lfont, "families", fam );
3186 setPreferenceProperty( lfont, "system", false );
3187 setPreferenceProperty( lfont, "widget_flags", wflag );
3189 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3191 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3192 setPreferenceProperty( numcol, "min", 2 );
3193 setPreferenceProperty( numcol, "max", 256 );
3195 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3196 setPreferenceProperty( numlab, "min", 2 );
3197 setPreferenceProperty( numlab, "max", 65 );
3199 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3200 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3201 QStringList orients;
3202 orients.append( tr( "SMESH_VERTICAL" ) );
3203 orients.append( tr( "SMESH_HORIZONTAL" ) );
3204 indices.clear(); indices.append( 0 ); indices.append( 1 );
3205 setPreferenceProperty( orient, "strings", orients );
3206 setPreferenceProperty( orient, "indexes", indices );
3208 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3209 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3210 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3211 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3212 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3213 setPreferenceProperty( xv, "step", 0.1 );
3214 setPreferenceProperty( xv, "min", 0.0 );
3215 setPreferenceProperty( xv, "max", 1.0 );
3216 setPreferenceProperty( yv, "step", 0.1 );
3217 setPreferenceProperty( yv, "min", 0.0 );
3218 setPreferenceProperty( yv, "max", 1.0 );
3219 setPreferenceProperty( wv, "step", 0.1 );
3220 setPreferenceProperty( wv, "min", 0.0 );
3221 setPreferenceProperty( wv, "max", 1.0 );
3222 setPreferenceProperty( hv, "min", 0.0 );
3223 setPreferenceProperty( hv, "max", 1.0 );
3224 setPreferenceProperty( hv, "step", 0.1 );
3226 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3227 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3228 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3229 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3230 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3231 setPreferenceProperty( xv, "min", 0.0 );
3232 setPreferenceProperty( xv, "max", 1.0 );
3233 setPreferenceProperty( xv, "step", 0.1 );
3234 setPreferenceProperty( xh, "min", 0.0 );
3235 setPreferenceProperty( xh, "max", 1.0 );
3236 setPreferenceProperty( xh, "step", 0.1 );
3237 setPreferenceProperty( yh, "min", 0.0 );
3238 setPreferenceProperty( yh, "max", 1.0 );
3239 setPreferenceProperty( yh, "step", 0.1 );
3240 setPreferenceProperty( wh, "min", 0.0 );
3241 setPreferenceProperty( wh, "max", 1.0 );
3242 setPreferenceProperty( wh, "step", 0.1 );
3243 setPreferenceProperty( hh, "min", 0.0 );
3244 setPreferenceProperty( hh, "max", 1.0 );
3245 setPreferenceProperty( hh, "step", 0.1 );
3248 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3250 if( sect=="SMESH" ){
3251 float sbX1,sbY1,sbW,sbH;
3252 float aTol = 1.00000009999999;
3253 std::string aWarning;
3254 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3255 if( name=="selection_object_color" || name=="selection_element_color" ||
3256 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3257 name=="selection_precision_node" || name=="selection_precision_element" ||
3258 name=="selection_precision_object")
3259 SMESH::UpdateSelectionProp( this );
3260 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3261 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3262 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3263 if(sbX1+sbW > aTol){
3264 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3267 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3268 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3271 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3272 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3273 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3274 if(sbY1+sbH > aTol){
3275 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3276 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3277 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3280 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3281 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3282 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3283 if(sbX1+sbW > aTol){
3284 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3287 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3288 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3291 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3292 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3293 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3294 if(sbY1+sbH > aTol){
3295 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3298 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3299 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3303 if(aWarning.size() != 0){
3304 aWarning += "The default values are applied instead.";
3305 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3306 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3307 QObject::tr(aWarning.c_str()));
3312 //================================================================================
3314 * \brief Update something in accordance with update flags
3315 * \param theFlags - update flags
3317 * Update viewer or/and object browser etc. in accordance with update flags ( see
3318 * LightApp_UpdateFlags enumeration ).
3320 //================================================================================
3321 void SMESHGUI::update( const int flags )
3323 if ( flags & UF_Viewer | flags & UF_Forced )
3324 SMESH::UpdateView();
3326 SalomeApp_Module::update( flags );
3329 //================================================================================
3331 * \brief Set default selection mode
3333 * SLOT called when operation commited. Sets default selection mode
3335 //================================================================================
3336 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3338 SVTK_ViewWindow* vtkWnd =
3339 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3341 vtkWnd->SetSelectionMode( ActorSelection );
3344 //================================================================================
3346 * \brief Set default selection mode
3348 * SLOT called when operation aborted. Sets default selection mode
3350 //================================================================================
3351 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3353 SVTK_ViewWindow* vtkWnd =
3354 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3356 vtkWnd->SetSelectionMode( ActorSelection );
3359 //================================================================================
3361 * \brief Creates operation with given identifier
3362 * \param id - identifier of operation to be started
3363 * \return Pointer on created operation or NULL if operation is not created
3365 * Virtual method redefined from the base class creates operation with given id.
3366 * It is called called automatically from startOperation method of base class.
3368 //================================================================================
3369 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3371 LightApp_Operation* op = 0;
3372 // to do : create operation here
3375 case 701: // Compute mesh
3376 op = new SMESHGUI_ComputeOp();
3378 case 702: // Create mesh
3379 op = new SMESHGUI_MeshOp( true, true );
3381 case 703: // Create sub-mesh
3382 op = new SMESHGUI_MeshOp( true, false );
3384 case 704: // Edit mesh/sub-mesh
3385 op = new SMESHGUI_MeshOp( false );
3387 case 417: //convert to quadratic
3388 op = new SMESHGUI_ConvToQuadOp();
3390 case 4067: // make mesh pass through point
3391 op = new SMESHGUI_MakeNodeAtPointOp();
3398 op = SalomeApp_Module::createOperation( id );
3402 //================================================================================
3404 * \brief Stops current operations and starts a given one
3405 * \param id - The id of the operation to start
3407 //================================================================================
3409 void SMESHGUI::switchToOperation(int id)
3411 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3412 activeStudy()->abortAllOperations();
3413 startOperation( id );
3416 LightApp_Displayer* SMESHGUI::displayer()
3419 myDisplayer = new SMESHGUI_Displayer( getApp() );
3423 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3426 int aTolerance = 64;
3427 int anIterations = 0;
3433 if( anIterations % aPeriod == 0 )
3436 if( aTolerance < 1 )
3439 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3441 aHue = (int)( 360.0 * rand() / RAND_MAX );
3442 //cout << "Hue = " << aHue << endl;
3444 //cout << "Auto colors : ";
3446 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3447 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3448 for( ; it != itEnd; ++it )
3450 SALOMEDS::Color anAutoColor = *it;
3451 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3454 aQColor.getHsv( &h, &s, &v );
3456 if( abs( h - aHue ) < aTolerance )
3459 //cout << "break (diff = " << abs( h - aHue ) << ")";
3469 //cout << "Hue of the returned color = " << aHue << endl;
3471 aColor.setHsv( aHue, 255, 255 );
3473 SALOMEDS::Color aSColor;
3474 aSColor.R = (double)aColor.red() / 255.0;
3475 aSColor.G = (double)aColor.green() / 255.0;
3476 aSColor.B = (double)aColor.blue() / 255.0;