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->selectFilter( filters.last() );
361 fd->SetChecked(toCreateGroups);
365 aFilename = fd->selectedFile();
366 aFormat = aFilterMap[fd->selectedFilter()];
368 if ( !aFilename.isEmpty()
369 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
370 && aFormat==SMESH::MED_V2_1) {
371 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
372 QObject::tr("SMESH_WRN_WARNING"),
373 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
374 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
375 if (aRet != SUIT_MessageBox::Yes) {
380 toCreateGroups = fd->IsChecked();
383 if ( !aFilename.isEmpty() ) {
384 // Check whether the file already exists and delete it if yes
385 QFile aFile( aFilename );
386 if ( aFile.exists() )
388 SUIT_OverrideCursor wc;
391 bool Renumber = false;
392 // PAL 14172 : Check of we have to renumber or not from the preferences before export
394 Renumber= resMgr->booleanValue("SMESH","renumbering");
396 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
397 aMeshEditor->RenumberNodes();
398 aMeshEditor->RenumberElements();
399 if ( SMESHGUI::automaticUpdate() )
402 switch ( theCommandID ) {
405 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
409 aMesh->ExportDAT( aFilename.toLatin1().data() );
413 aMesh->ExportUNV( aFilename.toLatin1().data() );
417 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
423 catch (const SALOME::SALOME_Exception& S_ex){
425 SUIT_MessageBox::warning(SMESHGUI::desktop(),
426 QObject::tr("SMESH_WRN_WARNING"),
427 QObject::tr("SMESH_EXPORT_FAILED"));
435 inline void InverseEntityMode(unsigned int& theOutputMode,
436 unsigned int theMode)
438 bool anIsNotPresent = ~theOutputMode & theMode;
440 theOutputMode |= theMode;
442 theOutputMode &= ~theMode;
445 void SetDisplayEntity(int theCommandID){
446 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
447 SALOME_ListIO selected;
449 aSel->selectedObjects( selected );
451 if(selected.Extent() >= 1){
452 SALOME_ListIteratorOfListIO It( selected );
453 for( ; It.More(); It.Next()){
454 Handle(SALOME_InteractiveObject) IObject = It.Value();
455 if(IObject->hasEntry()){
456 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
457 unsigned int aMode = anActor->GetEntityMode();
458 switch(theCommandID){
460 InverseEntityMode(aMode,SMESH_Actor::eEdges);
463 InverseEntityMode(aMode,SMESH_Actor::eFaces);
466 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
469 aMode = SMESH_Actor::eAllEntity;
473 anActor->SetEntityMode(aMode);
481 SALOME_ListIO selected;
482 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
486 LightApp_SelectionMgr* aSel = app->selectionMgr();
487 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
488 if( !aSel || !appStudy )
491 aSel->selectedObjects( selected );
492 if( selected.IsEmpty() )
495 Handle(SALOME_InteractiveObject) anIObject = selected.First();
497 _PTR(Study) aStudy = appStudy->studyDS();
498 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
499 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
500 if( aMainObject->_is_nil() )
503 aMainObject->SetAutoColor( true );
505 QList<SALOMEDS::Color> aReservedColors;
507 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
508 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
510 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
511 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
513 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
514 aGroupObject->SetColor( aColor );
515 aReservedColors.append( aColor );
517 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
518 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
520 if( aGroupObject->GetType() == SMESH::NODE )
521 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
522 else if( aGroupObject->GetType() == SMESH::EDGE )
523 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
525 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
529 SMESH::RepaintCurrentView();
532 void DisableAutoColor(){
533 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
534 SALOME_ListIO selected;
536 aSel->selectedObjects( selected );
538 if(selected.Extent()){
539 Handle(SALOME_InteractiveObject) anIObject = selected.First();
540 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
541 if ( !aMesh->_is_nil() ) {
542 aMesh->SetAutoColor( false );
547 void SetDisplayMode(int theCommandID){
548 SALOME_ListIO selected;
549 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
553 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
554 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
555 if( !aSel || !appStudy )
558 _PTR(Study) aStudy = appStudy->studyDS();
560 aSel->selectedObjects( selected );
562 if(selected.Extent() >= 1){
563 switch(theCommandID){
565 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
566 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
570 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
571 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
574 SALOME_ListIteratorOfListIO It( selected );
575 for( ; It.More(); It.Next()){
576 Handle(SALOME_InteractiveObject) IObject = It.Value();
577 if(IObject->hasEntry()){
578 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
579 switch(theCommandID){
581 anActor->SetRepresentation(SMESH_Actor::eEdge);
584 anActor->SetRepresentation(SMESH_Actor::eSurface);
587 if(anActor->IsShrunk())
590 anActor->SetShrink();
593 anActor->SetRepresentation(SMESH_Actor::ePoint);
596 vtkFloatingPointType color[3];
597 anActor->GetSufaceColor(color[0], color[1], color[2]);
598 int c0 = int (color[0] * 255);
599 int c1 = int (color[1] * 255);
600 int c2 = int (color[2] * 255);
601 QColor c(c0, c1, c2);
603 vtkFloatingPointType edgecolor[3];
604 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
605 c0 = int (edgecolor[0] * 255);
606 c1 = int (edgecolor[1] * 255);
607 c2 = int (edgecolor[2] * 255);
608 QColor e(c0, c1, c2);
610 vtkFloatingPointType backfacecolor[3];
611 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
612 c0 = int (backfacecolor[0] * 255);
613 c1 = int (backfacecolor[1] * 255);
614 c2 = int (backfacecolor[2] * 255);
615 QColor b(c0, c1, c2);
617 vtkFloatingPointType nodecolor[3];
618 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
619 c0 = int (nodecolor[0] * 255);
620 c1 = int (nodecolor[1] * 255);
621 c2 = int (nodecolor[2] * 255);
622 QColor n(c0, c1, c2);
624 int Edgewidth = (int)anActor->GetLineWidth();
627 int intValue = int(anActor->GetNodeSize());
628 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
630 SMESHGUI_Preferences_ColorDlg *aDlg =
631 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
632 aDlg->SetColor(1, c);
633 aDlg->SetColor(2, e);
634 aDlg->SetColor(3, n);
635 aDlg->SetColor(4, b);
636 aDlg->SetIntValue(1, Edgewidth);
637 aDlg->SetIntValue(2, intValue);
638 aDlg->SetIntValue(3, int(Shrink*100.));
640 QColor color = aDlg->GetColor(1);
641 QColor edgecolor = aDlg->GetColor(2);
642 QColor nodecolor = aDlg->GetColor(3);
643 QColor backfacecolor = aDlg->GetColor(4);
644 /* actor color and backface color */
645 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
646 vtkFloatingPointType (color.green()) / 255.,
647 vtkFloatingPointType (color.blue()) / 255.);
648 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
649 vtkFloatingPointType (backfacecolor.green()) / 255.,
650 vtkFloatingPointType (backfacecolor.blue()) / 255.);
653 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
654 vtkFloatingPointType (edgecolor.green()) / 255.,
655 vtkFloatingPointType (edgecolor.blue()) / 255.);
657 /* Shrink factor and size edges */
658 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
659 anActor->SetLineWidth(aDlg->GetIntValue(1));
661 /* Nodes color and size */
662 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
663 vtkFloatingPointType (nodecolor.green()) / 255.,
664 vtkFloatingPointType (nodecolor.blue()) / 255.);
665 anActor->SetNodeSize(aDlg->GetIntValue(2));
667 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
668 if( !aGroupObject->_is_nil() )
670 SALOMEDS::Color aColor;
671 aColor.R = (float)color.red() / 255.0;
672 aColor.G = (float)color.green() / 255.0;
673 aColor.B = (float)color.blue() / 255.0;
674 aGroupObject->SetColor( aColor );
684 SMESH::RepaintCurrentView();
688 void Control( int theCommandID )
690 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
691 SALOME_ListIO selected;
693 aSel->selectedObjects( selected );
695 if( !selected.IsEmpty() ){
696 Handle(SALOME_InteractiveObject) anIO = selected.First();
699 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
700 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
701 switch ( theCommandID ){
703 aTitle = QObject::tr( "LENGTH_EDGES" );
704 aControl = SMESH_Actor::eLength;
707 aTitle = QObject::tr( "LENGTH2D_EDGES" );
708 aControl = SMESH_Actor::eLength2D;
711 aTitle = QObject::tr( "FREE_EDGES" );
712 aControl = SMESH_Actor::eFreeEdges;
715 aTitle = QObject::tr( "FREE_BORDERS" );
716 aControl = SMESH_Actor::eFreeBorders;
719 aTitle = QObject::tr( "MULTI_BORDERS" );
720 aControl = SMESH_Actor::eMultiConnection;
723 aTitle = QObject::tr( "MULTI2D_BORDERS" );
724 aControl = SMESH_Actor::eMultiConnection2D;
727 aTitle = QObject::tr( "AREA_ELEMENTS" );
728 aControl = SMESH_Actor::eArea;
731 aTitle = QObject::tr( "TAPER_ELEMENTS" );
732 aControl = SMESH_Actor::eTaper;
735 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
736 aControl = SMESH_Actor::eAspectRatio;
739 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
740 aControl = SMESH_Actor::eAspectRatio3D;
743 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
744 aControl = SMESH_Actor::eMinimumAngle;
747 aTitle = QObject::tr( "WARP_ELEMENTS" );
748 aControl = SMESH_Actor::eWarping;
751 aTitle = QObject::tr( "SKEW_ELEMENTS" );
752 aControl = SMESH_Actor::eSkew;
755 aTitle = QObject::tr( "SMESH_VOLUME" );
756 aControl = SMESH_Actor::eVolume3D;
759 anActor->SetControlMode(aControl);
760 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
761 SMESH::RepaintCurrentView();
768 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
769 MeshObjectType theType,
770 const QString theInTypeName,
771 QString & theOutTypeName)
773 SMESH_TypeFilter aTypeFilter( theType );
775 if( !theIO.IsNull() )
777 entry = theIO->getEntry();
778 LightApp_DataOwner owner( entry );
779 if ( aTypeFilter.isOk( &owner )) {
780 theOutTypeName = theInTypeName;
788 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
790 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
791 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
793 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
794 CORBA::String_var anID = aSComp->GetID().c_str();
795 if (!strcmp(anID.in(),theIO->getEntry()))
801 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
802 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
803 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
804 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
805 CheckOIType ( theIO, GROUP, "Group", aTypeName )
813 QString CheckHomogeneousSelection()
815 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
816 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
817 SALOME_ListIO selected;
819 aSel->selectedObjects( selected );
821 QString RefType = CheckTypeObject(selected.First());
822 SALOME_ListIteratorOfListIO It(selected);
823 for ( ; It.More(); It.Next())
825 Handle(SALOME_InteractiveObject) IObject = It.Value();
826 QString Type = CheckTypeObject(IObject);
827 if (Type.compare(RefType) != 0)
828 return "Heterogeneous Selection";
835 void SMESHGUI::OnEditDelete()
837 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
838 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
839 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
841 QString aParentComponent = QString::null;
842 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
844 QString cur = anIt.Value()->getComponentDataType();
845 if( aParentComponent.isNull() )
846 aParentComponent = cur;
847 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
848 aParentComponent = "";
851 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
852 SUIT_MessageBox::warning( SMESHGUI::desktop(),
853 QObject::tr("ERR_ERROR"),
854 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
857 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
858 if (SUIT_MessageBox::warning
859 (SMESHGUI::desktop(),
860 QObject::tr("SMESH_WRN_WARNING"),
861 QObject::tr("SMESH_REALLY_DELETE"),
862 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
863 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
866 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
867 SUIT_ViewManager* vm = anApp->activeViewManager();
868 int nbSf = vm->getViewsCount();
870 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
871 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
872 _PTR(GenericAttribute) anAttr;
873 _PTR(AttributeIOR) anIOR;
875 SALOME_ListIteratorOfListIO It(selected);
877 aStudyBuilder->NewCommand(); // There is a transaction
878 for( ; It.More(); It.Next()){ // loop on selected IO's
879 Handle(SALOME_InteractiveObject) IObject = It.Value();
880 if(IObject->hasEntry()) {
881 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
883 // disable removal of "SMESH" component object
884 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
886 if ( engineIOR() == anIOR->Value().c_str() )
890 // put the whole hierarchy of sub-objects of the selected SO into a list and
891 // then treat them all starting from the deepest objects (at list back)
893 std::list< _PTR(SObject) > listSO;
894 listSO.push_back( aSO );
895 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
896 for ( ; itSO != listSO.end(); ++itSO ) {
897 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
898 for (it->InitEx(false); it->More(); it->Next())
899 listSO.push_back( it->Value() );
902 // treat SO's in the list starting from the back
904 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
905 for ( ; ritSO != listSO.rend(); ++ritSO ) {
906 _PTR(SObject) SO = *ritSO;
908 std::string anEntry = SO->GetID();
910 /** Erase graphical object **/
911 if(SO->FindAttribute(anAttr, "AttributeIOR")){
912 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
913 for(int i = 0; i < nbSf; i++){
914 SUIT_ViewWindow *sf = aViews[i];
915 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
916 SMESH::RemoveActor(sf,anActor);
921 /** Remove an object from data structures **/
922 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
923 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
924 if ( !aGroup->_is_nil() ) { // DELETE GROUP
925 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
926 aMesh->RemoveGroup( aGroup );
928 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
929 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
930 aMesh->RemoveSubMesh( aSubMesh );
932 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
934 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
937 IObject = new SALOME_InteractiveObject
938 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
939 QString objType = CheckTypeObject(IObject);
940 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
941 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
942 aStudyBuilder->RemoveObjectWithChildren( SO );
944 else {// default action: remove SObject from the study
945 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
946 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
948 aStudyBuilder->RemoveObjectWithChildren( SO );
952 } /* listSO back loop */
953 } /* IObject->hasEntry() */
955 aStudyBuilder->CommitCommand();
957 /* Clear any previous selection */
959 aSel->setSelectedObjects( l1 );
961 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
966 SMESHGUI_EXPORT CAM_Module* createModule()
968 return new SMESHGUI();
972 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
974 //=============================================================================
978 //=============================================================================
979 SMESHGUI::SMESHGUI() :
980 SalomeApp_Module( "SMESH" )
982 if ( CORBA::is_nil( myComponentSMESH ) )
984 CORBA::Boolean anIsEmbeddedMode;
985 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
988 myActiveDialogBox = 0;
989 myFilterLibraryDlg = 0;
993 SMESH::GetFilterManager();
996 /* load resources for all available meshers */
997 SMESH::InitAvailableHypotheses();
1000 //=============================================================================
1004 //=============================================================================
1005 SMESHGUI::~SMESHGUI()
1007 SMESH::GetFilterManager()->Destroy();
1008 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1011 //=============================================================================
1015 //=============================================================================
1016 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1018 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1020 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1025 bool SMESHGUI::automaticUpdate()
1027 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1031 return resMgr->booleanValue( "SMESH", "auto_update", false );
1034 //=============================================================================
1038 //=============================================================================
1039 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1041 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1044 //=============================================================================
1048 //=============================================================================
1049 SMESHGUI* SMESHGUI::GetSMESHGUI()
1051 SMESHGUI* smeshMod = 0;
1052 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1055 CAM_Module* module = app->module( "Mesh" );
1056 smeshMod = dynamic_cast<SMESHGUI*>( module );
1059 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1061 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1064 _PTR(Study) aStudy = study->studyDS();
1066 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1075 Standard_EXPORT SMESHGUI* GetComponentGUI()
1077 return SMESHGUI::GetSMESHGUI();
1081 //=============================================================================
1085 //=============================================================================
1086 void SMESHGUI::SetState(int aState)
1091 //=============================================================================
1095 //=============================================================================
1096 void SMESHGUI::ResetState()
1101 //=============================================================================
1105 //=============================================================================
1106 void SMESHGUI::EmitSignalDeactivateDialog()
1108 emit SignalDeactivateActiveDialog();
1111 //=============================================================================
1115 //=============================================================================
1116 void SMESHGUI::EmitSignalStudyFrameChanged()
1118 emit SignalStudyFrameChanged();
1121 //=============================================================================
1125 //=============================================================================
1126 void SMESHGUI::EmitSignalCloseAllDialogs()
1128 emit SignalCloseAllDialogs();
1131 //=============================================================================
1135 //=============================================================================
1136 QDialog *SMESHGUI::GetActiveDialogBox()
1138 return myActiveDialogBox;
1141 //=============================================================================
1145 //=============================================================================
1146 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1148 myActiveDialogBox = (QDialog *) aDlg;
1152 //=============================================================================
1156 //=============================================================================
1157 SUIT_Desktop* SMESHGUI::desktop()
1159 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1161 return app->desktop();
1166 //=============================================================================
1170 //=============================================================================
1171 SalomeApp_Study* SMESHGUI::activeStudy()
1173 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1175 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1180 //=============================================================================
1184 //=============================================================================
1185 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1187 /* Here the position is on the bottom right corner - 10 */
1188 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1190 SUIT_Desktop *PP = desktop();
1191 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1192 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1196 //=============================================================================
1200 //=============================================================================
1201 static int isStudyLocked(_PTR(Study) theStudy){
1202 return theStudy->GetProperties()->IsLocked();
1205 static bool checkLock(_PTR(Study) theStudy) {
1206 if (isStudyLocked(theStudy)) {
1207 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1208 QObject::tr("WRN_WARNING"),
1209 QObject::tr("WRN_STUDY_LOCKED") );
1215 //=======================================================================
1216 //function : CheckActiveStudyLocked
1218 //=======================================================================
1220 bool SMESHGUI::isActiveStudyLocked()
1222 _PTR(Study) aStudy = activeStudy()->studyDS();
1223 return checkLock( aStudy );
1226 //=============================================================================
1230 //=============================================================================
1231 bool SMESHGUI::OnGUIEvent( int theCommandID )
1233 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1237 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1238 SUIT_ResourceMgr* mgr = resourceMgr();
1242 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1243 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1246 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1247 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1249 //QAction* act = action( theCommandID );
1251 switch (theCommandID) {
1253 if(checkLock(aStudy)) break;
1261 if(checkLock(aStudy)) break;
1262 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1266 case 122: // EXPORT MED
1275 ::ExportMeshToFile(theCommandID);
1279 case 200: // SCALAR BAR
1281 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1282 SALOME_ListIO selected;
1284 aSel->selectedObjects( selected );
1286 if( selected.Extent() ) {
1287 Handle(SALOME_InteractiveObject) anIO = selected.First();
1288 if( anIO->hasEntry() ) {
1289 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1290 anActor->SetControlMode( SMESH_Actor::eNone );
1298 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1308 ::DisableAutoColor();
1311 case 1134: // Clipping
1312 case 1133: // Tranparency
1313 case 1132: // Colors / Size
1320 ::SetDisplayMode(theCommandID);
1326 case 219: // Volumes
1327 case 220: // All Entity
1328 ::SetDisplayEntity(theCommandID);
1333 if(checkLock(aStudy)) break;
1335 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1338 SMESH::UpdateView();
1340 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1341 SMESH::OnVisuException();
1343 catch (...) { // PAL16774 (Crash after display of many groups)
1344 SMESH::OnVisuException();
1348 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1349 aSel->selectedObjects( l );
1350 aSel->setSelectedObjects( l );
1355 case 301: // DISPLAY
1356 case 302: // DISPLAY ONLY
1358 SMESH::EDisplaing anAction;
1359 switch (theCommandID) {
1360 case 300: anAction = SMESH::eErase; break;
1361 case 301: anAction = SMESH::eDisplay; break;
1362 case 302: anAction = SMESH::eDisplayOnly; break;
1365 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1366 SALOME_ListIO sel_objects, to_process;
1368 aSel->selectedObjects( sel_objects );
1370 if( theCommandID==302 )
1371 startOperation( myEraseAll );
1373 extractContainers( sel_objects, to_process );
1376 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1380 SALOME_ListIteratorOfListIO It( to_process );
1381 for ( ; It.More(); It.Next()) {
1382 Handle(SALOME_InteractiveObject) IOS = It.Value();
1383 if (IOS->hasEntry()) {
1384 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1385 break; // PAL16774 (Crash after display of many groups)
1386 if (anAction == SMESH::eDisplayOnly)
1387 anAction = SMESH::eDisplay;
1392 // PAL13338 + PAL15161 -->
1393 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1394 SMESH::UpdateView();
1395 // PAL13338 + PAL15161 <--
1397 catch (...) { // PAL16774 (Crash after display of many groups)
1398 SMESH::OnVisuException();
1401 if (anAction == SMESH::eErase) {
1403 aSel->setSelectedObjects( l1 );
1406 aSel->setSelectedObjects( to_process );
1413 if(checkLock(aStudy)) break;
1416 EmitSignalDeactivateDialog();
1418 ( new SMESHGUI_NodesDlg( this ) )->show();
1421 SUIT_MessageBox::warning(desktop(),
1422 tr("SMESH_WRN_WARNING"),
1423 tr("SMESH_WRN_VIEWER_VTK"));
1428 case 2151: // FILTER
1432 EmitSignalDeactivateDialog();
1433 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1438 case 406: // MOVE NODE
1442 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1443 tr( "NOT_A_VTK_VIEWER" ) );
1447 if(checkLock(aStudy)) break;
1448 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1452 case 701: // COMPUTE MESH
1454 if (checkLock(aStudy)) break;
1456 startOperation( 701 );
1460 case 702: // Create mesh
1461 startOperation( 702 );
1463 case 703: // Create sub-mesh
1464 startOperation( 703 );
1466 case 704: // Edit mesh/sub-mesh
1467 startOperation( 704 );
1469 case 710: // Build compound mesh
1471 if (checkLock(aStudy)) break;
1472 EmitSignalDeactivateDialog();
1473 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1476 case 407: // DIAGONAL INVERSION
1477 case 408: // Delete diagonal
1481 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1482 tr( "NOT_A_VTK_VIEWER" ) );
1486 if ( checkLock( aStudy ) )
1489 /*Standard_Boolean aRes;
1490 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1491 if ( aMesh->_is_nil() )
1493 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1494 tr( "SMESH_BAD_SELECTION" ) );
1498 EmitSignalDeactivateDialog();
1499 if ( theCommandID == 407 )
1500 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1502 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1505 case 409: // Change orientation
1506 case 410: // Union of triangles
1507 case 411: // Cutting of quadrangles
1511 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1512 tr( "NOT_A_VTK_VIEWER" ) );
1516 if ( checkLock( aStudy ) )
1519 EmitSignalDeactivateDialog();
1520 SMESHGUI_MultiEditDlg* aDlg = NULL;
1521 if ( theCommandID == 409 )
1522 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1523 else if ( theCommandID == 410 )
1524 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1526 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1531 case 412: // Smoothing
1533 if(checkLock(aStudy)) break;
1535 EmitSignalDeactivateDialog();
1536 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1539 SUIT_MessageBox::warning(desktop(),
1540 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1544 case 413: // Extrusion
1546 if (checkLock(aStudy)) break;
1548 EmitSignalDeactivateDialog();
1549 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1551 SUIT_MessageBox::warning(desktop(),
1552 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1556 case 414: // Revolution
1558 if(checkLock(aStudy)) break;
1560 EmitSignalDeactivateDialog();
1561 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1564 SUIT_MessageBox::warning(desktop(),
1565 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1569 case 415: // Pattern mapping
1571 if ( checkLock( aStudy ) )
1575 EmitSignalDeactivateDialog();
1576 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1579 SUIT_MessageBox::warning(desktop(),
1580 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1584 case 416: // Extrusion along a path
1586 if (checkLock(aStudy)) break;
1588 EmitSignalDeactivateDialog();
1589 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1591 SUIT_MessageBox::warning(desktop(),
1592 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1596 case 417: // Convert mesh to quadratic
1598 startOperation( 417 );
1599 /* if (checkLock(aStudy)) break;
1601 EmitSignalDeactivateDialog();
1602 new SMESHGUI_ConvToQuadDlg();
1604 SUIT_MessageBox::warning(desktop(),
1605 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1609 case 801: // CREATE GROUP
1613 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1614 tr( "NOT_A_VTK_VIEWER" ) );
1618 if(checkLock(aStudy)) break;
1619 EmitSignalDeactivateDialog();
1620 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1622 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1623 SALOME_ListIO selected;
1625 aSel->selectedObjects( selected );
1627 int nbSel = selected.Extent();
1629 // check if mesh is selected
1630 aMesh = SMESH::GetMeshByIO( selected.First() );
1632 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1637 case 802: // CONSTRUCT GROUP
1641 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1642 tr( "NOT_A_VTK_VIEWER" ) );
1646 if(checkLock(aStudy)) break;
1647 EmitSignalDeactivateDialog();
1649 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1650 SALOME_ListIO selected;
1652 aSel->selectedObjects( selected );
1654 int nbSel = selected.Extent();
1656 // check if submesh is selected
1657 Handle(SALOME_InteractiveObject) IObject = selected.First();
1658 if (IObject->hasEntry()) {
1659 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1661 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1662 if (!aSubMesh->_is_nil()) {
1664 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1665 // get submesh elements list by types
1666 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1667 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1668 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1669 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1670 // create group for each type o elements
1671 QString aName = IObject->getName();
1672 if (aNodes->length() > 0) {
1673 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1674 aGroup->Add(aNodes.inout());
1676 if (aEdges->length() > 0) {
1677 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1678 aGroup->Add(aEdges.inout());
1680 if (aFaces->length() > 0) {
1681 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1682 aGroup->Add(aFaces.inout());
1684 if (aVolumes->length() > 0) {
1685 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1686 aGroup->Add(aVolumes.inout());
1691 catch(const SALOME::SALOME_Exception & S_ex){
1692 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1699 SUIT_MessageBox::warning(desktop(),
1700 tr("SMESH_WRN_WARNING"),
1701 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1706 case 803: // EDIT GROUP
1710 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1711 tr( "NOT_A_VTK_VIEWER" ) );
1715 if(checkLock(aStudy)) break;
1716 EmitSignalDeactivateDialog();
1718 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1719 SALOME_ListIO selected;
1721 aSel->selectedObjects( selected );
1723 SALOME_ListIteratorOfListIO It (selected);
1724 int nbSelectedGroups = 0;
1725 for ( ; It.More(); It.Next() )
1727 SMESH::SMESH_GroupBase_var aGroup =
1728 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1729 if (!aGroup->_is_nil()) {
1731 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1735 if (nbSelectedGroups == 0)
1737 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1743 case 804: // Add elements to group
1745 if(checkLock(aStudy)) break;
1746 if (myState == 800) {
1747 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1748 if (aDlg) aDlg->onAdd();
1753 case 805: // Remove elements from group
1755 if(checkLock(aStudy)) break;
1756 if (myState == 800) {
1757 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1758 if (aDlg) aDlg->onRemove();
1763 case 810: // Union Groups
1764 case 811: // Intersect groups
1765 case 812: // Cut groups
1769 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1770 tr( "NOT_A_VTK_VIEWER" ) );
1774 if ( checkLock( aStudy ) )
1777 EmitSignalDeactivateDialog();
1780 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1781 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1782 else aMode = SMESHGUI_GroupOpDlg::CUT;
1784 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1788 case 813: // Delete groups with their contents
1792 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1793 tr( "NOT_A_VTK_VIEWER" ) );
1797 if ( checkLock( aStudy ) )
1800 EmitSignalDeactivateDialog();
1802 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1806 case 900: // MESH INFOS
1808 EmitSignalDeactivateDialog();
1809 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1810 SALOME_ListIO selected;
1812 aSel->selectedObjects( selected );
1814 if ( selected.Extent() > 1 ) { // a dlg for each IO
1816 SALOME_ListIteratorOfListIO It (selected);
1817 for ( ; It.More(); It.Next() ) {
1818 IOs.Clear(); IOs.Append( It.Value() );
1819 aSel->setSelectedObjects( IOs );
1820 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1822 // restore selection
1823 aSel->setSelectedObjects( selected );
1826 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1830 case 902: // STANDARD MESH INFOS
1832 EmitSignalDeactivateDialog();
1833 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1834 SALOME_ListIO selected;
1836 aSel->selectedObjects( selected );
1838 if ( selected.Extent() > 1 ) { // a dlg for each IO
1840 SALOME_ListIteratorOfListIO It (selected);
1841 for ( ; It.More(); It.Next() ) {
1843 IOs.Append( It.Value() );
1844 aSel->setSelectedObjects( IOs );
1845 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1847 // restore selection
1848 aSel->setSelectedObjects( selected );
1851 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1855 case 903: // WHAT IS
1857 EmitSignalDeactivateDialog();
1858 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1862 case 1100: // EDIT HYPOTHESIS
1864 if(checkLock(aStudy)) break;
1866 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1867 SALOME_ListIO selected;
1869 aSel->selectedObjects( selected );
1871 int nbSel = selected.Extent();
1874 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1875 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1877 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1878 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1879 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1880 if ( !aHypothesis->_is_nil() )
1882 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
1884 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1891 updateObjBrowser( true );
1895 case 1101: // RENAME
1897 if ( checkLock( aStudy ) )
1900 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1901 SALOME_ListIO selected;
1903 aSel->selectedObjects( selected );
1905 SALOME_ListIteratorOfListIO It( selected );
1906 for ( ; It.More(); It.Next() )
1908 Handle(SALOME_InteractiveObject) IObject = It.Value();
1909 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1910 _PTR(GenericAttribute) anAttr;
1911 _PTR(AttributeName) aName;
1914 if ( obj->FindAttribute(anAttr, "AttributeName") )
1917 QString newName = QString(aName->Value().c_str());
1918 newName = LightApp_NameDlg::getName(desktop(), newName);
1919 if ( !newName.isEmpty() )
1921 //old source: aStudy->renameIObject( IObject, newName );
1922 aName->SetValue( newName.toLatin1().data() );
1924 // if current object is group update group's name
1925 SMESH::SMESH_GroupBase_var aGroup =
1926 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1927 if (!aGroup->_is_nil() )
1928 aGroup->SetName( newName.toLatin1().data() );
1938 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1940 if(checkLock(aStudy)) break;
1941 SUIT_OverrideCursor wc;
1943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1944 SALOME_ListIO selected;
1946 aSel->selectedObjects( selected, QString::null, false );
1948 SALOME_ListIteratorOfListIO It(selected);
1949 for (int i = 0; It.More(); It.Next(), i++) {
1950 Handle(SALOME_InteractiveObject) IObject = It.Value();
1951 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1954 aSel->setSelectedObjects( l1 );
1959 case 401: // GEOM::EDGE
1960 case 4021: // TRIANGLE
1962 case 4023: // POLYGON
1966 if(checkLock(aStudy)) break;
1968 EmitSignalDeactivateDialog();
1969 SMDSAbs_ElementType type = SMDSAbs_Edge;
1971 switch (theCommandID) {
1972 case 4021: // TRIANGLE
1973 type = SMDSAbs_Face; nbNodes = 3; break;
1975 type = SMDSAbs_Face; nbNodes = 4; break;
1977 type = SMDSAbs_Volume; nbNodes = 4; break;
1978 case 4023: // POLYGON
1979 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1981 type = SMDSAbs_Volume; nbNodes = 8; break;
1982 case 4033: // POLYHEDRE
1983 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1986 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
1989 SUIT_MessageBox::warning(desktop(),
1990 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1994 case 4033: // POLYHEDRON
1996 if(checkLock(aStudy)) break;
1998 EmitSignalDeactivateDialog();
1999 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2002 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2007 case 4034: // QUADRATIC EDGE
2008 case 4035: // QUADRATIC TRIANGLE
2009 case 4036: // QUADRATIC QUADRANGLE
2010 case 4037: // QUADRATIC TETRAHEDRON
2011 case 4038: // QUADRATIC PYRAMID
2012 case 4039: // QUADRATIC PENTAHEDRON
2013 case 4040: // QUADRATIC HEXAHEDRON
2015 if(checkLock(aStudy)) break;
2017 EmitSignalDeactivateDialog();
2020 switch (theCommandID) {
2022 type = QUAD_EDGE; break;
2024 type = QUAD_TRIANGLE; break;
2026 type = QUAD_QUADRANGLE; break;
2028 type = QUAD_TETRAHEDRON; break;
2030 type = QUAD_PYRAMID; break;
2032 type = QUAD_PENTAHEDRON; break;
2034 type = QUAD_HEXAHEDRON;
2038 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2041 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2046 case 4041: // REMOVES NODES
2048 if(checkLock(aStudy)) break;
2050 EmitSignalDeactivateDialog();
2051 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2054 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2059 case 4042: // REMOVES ELEMENTS
2061 if(checkLock(aStudy)) break;
2063 EmitSignalDeactivateDialog();
2064 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2068 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2069 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2073 case 4051: // RENUMBERING NODES
2075 if(checkLock(aStudy)) break;
2077 EmitSignalDeactivateDialog();
2078 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2082 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2083 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2087 case 4052: // RENUMBERING ELEMENTS
2089 if(checkLock(aStudy)) break;
2091 EmitSignalDeactivateDialog();
2092 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2096 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2097 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2101 case 4061: // TRANSLATION
2103 if(checkLock(aStudy)) break;
2105 EmitSignalDeactivateDialog();
2106 ( new SMESHGUI_TranslationDlg( this ) )->show();
2109 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2110 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2114 case 4062: // ROTATION
2116 if(checkLock(aStudy)) break;
2118 EmitSignalDeactivateDialog();
2119 ( new SMESHGUI_RotationDlg( this ) )->show();
2122 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2123 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2127 case 4063: // SYMMETRY
2129 if(checkLock(aStudy)) break;
2131 EmitSignalDeactivateDialog();
2132 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2135 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2136 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2140 case 4064: // SEWING
2142 if(checkLock(aStudy)) break;
2144 EmitSignalDeactivateDialog();
2145 ( new SMESHGUI_SewingDlg( this ) )->show();
2148 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2149 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2153 case 4065: // MERGE NODES
2155 if(checkLock(aStudy)) break;
2157 EmitSignalDeactivateDialog();
2158 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2161 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2162 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2166 case 4066: // MERGE EQUAL ELEMENTS
2168 if (checkLock(aStudy)) break;
2170 EmitSignalDeactivateDialog();
2171 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2173 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2174 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2179 case 4067: // MAKE MESH PASS THROUGH POINT
2180 startOperation( 4067 );
2183 case 5105: // Library of selection filters
2185 static QList<int> aTypes;
2186 if ( aTypes.isEmpty() )
2188 aTypes.append( SMESH::NODE );
2189 aTypes.append( SMESH::EDGE );
2190 aTypes.append( SMESH::FACE );
2191 aTypes.append( SMESH::VOLUME );
2193 if (!myFilterLibraryDlg)
2194 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2195 else if (myFilterLibraryDlg->isHidden())
2196 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2197 myFilterLibraryDlg->raise();
2201 case 6017: // CONTROLS
2217 LightApp_SelectionMgr* mgr = selectionMgr();
2218 SALOME_ListIO selected; mgr->selectedObjects( selected );
2220 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2221 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2223 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2224 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2225 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2226 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2227 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2228 ::Control( theCommandID );
2233 SUIT_MessageBox::warning(desktop(),
2234 tr( "SMESH_WRN_WARNING" ),
2235 tr( "SMESH_BAD_SELECTION" ) );
2239 SUIT_MessageBox::warning(desktop(),
2240 tr( "SMESH_WRN_WARNING" ),
2241 tr( "NOT_A_VTK_VIEWER" ) );
2246 LightApp_SelectionMgr* mgr = selectionMgr();
2247 SALOME_ListIO selected; mgr->selectedObjects( selected );
2249 SALOME_ListIteratorOfListIO it(selected);
2250 for( ; it.More(); it.Next()) {
2251 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2252 if(anIObject->hasEntry()) {
2253 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2254 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2262 LightApp_SelectionMgr* mgr = selectionMgr();
2263 SALOME_ListIO selected; mgr->selectedObjects( selected );
2265 if (selected.Extent() == 1) {
2266 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2267 if(anIObject->hasEntry())
2268 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2269 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2276 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2277 //updateObjBrowser();
2281 //=============================================================================
2285 //=============================================================================
2286 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2291 //=============================================================================
2295 //=============================================================================
2296 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2301 //=============================================================================
2305 //=============================================================================
2306 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2311 //=============================================================================
2312 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2313 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2315 //=============================================================================
2316 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2317 SUIT_ViewWindow* wnd )
2319 if(theIO->hasEntry()){
2320 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2321 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2325 //=======================================================================
2326 // function : createSMESHAction
2328 //=======================================================================
2329 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2332 QWidget* parent = application()->desktop();
2333 SUIT_ResourceMgr* resMgr = resourceMgr();
2335 if ( !icon_id.isEmpty() )
2336 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2338 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2339 if ( !pix.isNull() )
2340 icon = QIcon( pix );
2342 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2343 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2344 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2346 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2349 //=======================================================================
2350 // function : createPopupItem
2352 //=======================================================================
2353 void SMESHGUI::createPopupItem( const int id,
2354 const QString& clients,
2355 const QString& types,
2356 const QString& theRule,
2361 parentId = popupMgr()->actionId( action( pId ) );
2363 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2364 popupMgr()->insert( action( id ), parentId, 0 );
2366 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2367 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2368 QString rule = "(%1) and (%2) and (%3)";
2369 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2370 if( clients.isEmpty() )
2371 rule = rule.arg( QString( "true" ) );
2373 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2374 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2377 bool cont = myRules.contains( id );
2379 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2381 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2382 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2385 //=======================================================================
2386 // function : initialize
2388 //=======================================================================
2389 void SMESHGUI::initialize( CAM_Application* app )
2391 SalomeApp_Module::initialize( app );
2393 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2395 /* Automatic Update flag */
2396 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2398 // ----- create actions --------------
2400 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2401 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2402 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2403 createSMESHAction( 114, "NUM" );
2404 createSMESHAction( 121, "DAT" );
2405 createSMESHAction( 122, "MED" );
2406 createSMESHAction( 123, "UNV" );
2407 createSMESHAction( 140, "STL" );
2408 createSMESHAction( 124, "EXPORT_DAT" );
2409 createSMESHAction( 125, "EXPORT_MED" );
2410 createSMESHAction( 126, "EXPORT_UNV" );
2411 createSMESHAction( 141, "EXPORT_STL" );
2412 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2413 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2414 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2415 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2416 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2417 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2418 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2419 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2420 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2421 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2422 createSMESHAction( 804, "ADD" );
2423 createSMESHAction( 805, "REMOVE" );
2424 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2425 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2426 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2427 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2428 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2429 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2430 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2431 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2432 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2433 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2434 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2435 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2436 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2437 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2438 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2439 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2440 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2441 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2442 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2443 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2444 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2445 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2446 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2447 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2448 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2449 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2450 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2451 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2452 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2453 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2454 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2455 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2456 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2457 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2458 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2459 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2460 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2461 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2462 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2463 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2464 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2465 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2466 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2467 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2468 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2469 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2470 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2471 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2472 createSMESHAction( 415, "MAP", "ICON_MAP" );
2473 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2474 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2475 createSMESHAction( 200, "RESET" );
2476 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2477 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2478 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2479 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2480 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2481 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2482 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2483 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2484 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2485 createSMESHAction( 220, "ALL" );
2486 createSMESHAction( 1100, "EDIT_HYPO" );
2487 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2488 createSMESHAction( 1102, "UNASSIGN" );
2489 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2490 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2491 createSMESHAction( 1131, "DISPMODE" );
2492 createSMESHAction( 1132, "COLORS" );
2493 createSMESHAction( 1133, "TRANSP" );
2494 createSMESHAction( 1134, "CLIP" );
2495 createSMESHAction( 1135, "DISP_ENT" );
2496 createSMESHAction( 1136, "AUTO_COLOR" );
2497 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2498 createSMESHAction( 2000, "CTRL" );
2500 createSMESHAction( 300, "ERASE" );
2501 createSMESHAction( 301, "DISPLAY" );
2502 createSMESHAction( 302, "DISPLAY_ONLY" );
2503 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2504 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2505 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2506 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2507 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2508 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2509 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2510 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2512 // ----- create menu --------------
2513 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2514 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2515 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2516 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2517 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2518 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2519 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2521 createMenu( separator(), fileId );
2523 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2524 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2525 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2526 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2527 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2528 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2530 createMenu( 111, importId, -1 );
2531 createMenu( 112, importId, -1 );
2532 createMenu( 113, importId, -1 );
2534 createMenu( 121, exportId, -1 );
2535 createMenu( 122, exportId, -1 );
2536 createMenu( 123, exportId, -1 );
2537 createMenu( 140, exportId, -1 ); // export to stl STL
2539 createMenu( separator(), fileId, 10 );
2541 createMenu( 33, editId, -1 );
2543 createMenu( 5105, toolsId, -1 );
2545 createMenu( 702, meshId, -1 );
2546 createMenu( 703, meshId, -1 );
2547 createMenu( 704, meshId, -1 );
2548 createMenu( 710, meshId, -1 );
2549 createMenu( separator(), meshId, -1 );
2550 createMenu( 701, meshId, -1 );
2551 createMenu( separator(), meshId, -1 );
2552 createMenu( 801, meshId, -1 );
2553 createMenu( 802, meshId, -1 );
2554 createMenu( 803, meshId, -1 );
2555 createMenu( separator(), meshId, -1 );
2556 createMenu( 810, meshId, -1 );
2557 createMenu( 811, meshId, -1 );
2558 createMenu( 812, meshId, -1 );
2559 createMenu( separator(), meshId, -1 );
2560 createMenu( 813, meshId, -1 );
2561 createMenu( separator(), meshId, -1 );
2562 createMenu( 900, meshId, -1 );
2563 createMenu( 902, meshId, -1 );
2564 createMenu( 903, meshId, -1 );
2565 createMenu( separator(), meshId, -1 );
2567 createMenu( 6003, ctrlId, -1 );
2568 createMenu( 6001, ctrlId, -1 );
2569 createMenu( 6004, ctrlId, -1 );
2570 createMenu( separator(), ctrlId, -1 );
2571 createMenu( 6002, ctrlId, -1 );
2572 createMenu( 6018, ctrlId, -1 );
2573 createMenu( 6019, ctrlId, -1 );
2574 createMenu( 6011, ctrlId, -1 );
2575 createMenu( 6012, ctrlId, -1 );
2576 createMenu( 6013, ctrlId, -1 );
2577 createMenu( 6014, ctrlId, -1 );
2578 createMenu( 6015, ctrlId, -1 );
2579 createMenu( 6016, ctrlId, -1 );
2580 createMenu( separator(), ctrlId, -1 );
2581 createMenu( 6017, ctrlId, -1 );
2582 createMenu( 6009, ctrlId, -1 );
2583 createMenu( separator(), ctrlId, -1 );
2585 createMenu( 400, addId, -1 );
2586 createMenu( 401, addId, -1 );
2587 createMenu( 4021, addId, -1 );
2588 createMenu( 4022, addId, -1 );
2589 createMenu( 4023, addId, -1 );
2590 createMenu( 4031, addId, -1 );
2591 createMenu( 4032, addId, -1 );
2592 createMenu( 4033, addId, -1 );
2593 createMenu( separator(), addId, -1 );
2594 createMenu( 4034, addId, -1 );
2595 createMenu( 4035, addId, -1 );
2596 createMenu( 4036, addId, -1 );
2597 createMenu( 4037, addId, -1 );
2598 createMenu( 4038, addId, -1 );
2599 createMenu( 4039, addId, -1 );
2600 createMenu( 4040, addId, -1 );
2602 createMenu( 4041, removeId, -1 );
2603 createMenu( 4042, removeId, -1 );
2605 createMenu( 4051, renumId, -1 );
2606 createMenu( 4052, renumId, -1 );
2608 createMenu( 4061, transfId, -1 );
2609 createMenu( 4062, transfId, -1 );
2610 createMenu( 4063, transfId, -1 );
2611 createMenu( 4064, transfId, -1 );
2612 createMenu( 4065, transfId, -1 );
2613 createMenu( 4066, transfId, -1 );
2615 createMenu( 406, modifyId, -1 );
2616 createMenu( 4067,modifyId, -1 );
2617 createMenu( 407, modifyId, -1 );
2618 createMenu( 408, modifyId, -1 );
2619 createMenu( 409, modifyId, -1 );
2620 createMenu( 410, modifyId, -1 );
2621 createMenu( 411, modifyId, -1 );
2622 createMenu( 412, modifyId, -1 );
2623 createMenu( 413, modifyId, -1 );
2624 createMenu( 416, modifyId, -1 );
2625 createMenu( 414, modifyId, -1 );
2626 createMenu( 415, modifyId, -1 );
2627 createMenu( 417, modifyId, -1 );
2629 createMenu( 214, viewId, -1 );
2631 // ----- create toolbars --------------
2632 int meshTb = createTool( tr( "TB_MESH" ) ),
2633 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2634 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2635 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2636 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2638 createTool( 702, meshTb );
2639 createTool( 703, meshTb );
2640 createTool( 704, meshTb );
2641 createTool( 710, meshTb );
2642 createTool( separator(), meshTb );
2643 createTool( 701, meshTb );
2644 createTool( separator(), meshTb );
2645 createTool( 801, meshTb );
2646 createTool( 802, meshTb );
2647 createTool( 803, meshTb );
2648 createTool( separator(), meshTb );
2649 createTool( 900, meshTb );
2650 createTool( 902, meshTb );
2651 createTool( 903, meshTb );
2652 createTool( separator(), meshTb );
2654 createTool( 6001, ctrlTb );
2655 createTool( 6003, ctrlTb );
2656 createTool( 6004, ctrlTb );
2657 createTool( separator(), ctrlTb );
2658 createTool( 6002, ctrlTb );
2659 createTool( 6018, ctrlTb );
2660 createTool( 6019, ctrlTb );
2661 createTool( 6011, ctrlTb );
2662 createTool( 6012, ctrlTb );
2663 createTool( 6013, ctrlTb );
2664 createTool( 6014, ctrlTb );
2665 createTool( 6015, ctrlTb );
2666 createTool( 6016, ctrlTb );
2667 createTool( separator(), ctrlTb );
2668 createTool( 6017, ctrlTb );
2669 createTool( 6009, ctrlTb );
2670 createTool( separator(), ctrlTb );
2672 createTool( 400, addRemTb );
2673 createTool( 401, addRemTb );
2674 createTool( 4021, addRemTb );
2675 createTool( 4022, addRemTb );
2676 createTool( 4023, addRemTb );
2677 createTool( 4031, addRemTb );
2678 createTool( 4032, addRemTb );
2679 createTool( 4033, addRemTb );
2680 createTool( separator(), addRemTb );
2681 createTool( 4034, addRemTb );
2682 createTool( 4035, addRemTb );
2683 createTool( 4036, addRemTb );
2684 createTool( 4037, addRemTb );
2685 createTool( 4038, addRemTb );
2686 createTool( 4039, addRemTb );
2687 createTool( 4040, addRemTb );
2688 createTool( separator(), addRemTb );
2689 createTool( 4041, addRemTb );
2690 createTool( 4042, addRemTb );
2691 createTool( separator(), addRemTb );
2692 createTool( 4051, addRemTb );
2693 createTool( 4052, addRemTb );
2694 createTool( separator(), addRemTb );
2695 createTool( 4061, addRemTb );
2696 createTool( 4062, addRemTb );
2697 createTool( 4063, addRemTb );
2698 createTool( 4064, addRemTb );
2699 createTool( 4065, addRemTb );
2700 createTool( 4066, addRemTb );
2701 createTool( separator(), addRemTb );
2703 createTool( 406, modifyTb );
2704 createTool( 4067,modifyTb );
2705 createTool( 407, modifyTb );
2706 createTool( 408, modifyTb );
2707 createTool( 409, modifyTb );
2708 createTool( 410, modifyTb );
2709 createTool( 411, modifyTb );
2710 createTool( 412, modifyTb );
2711 createTool( 413, modifyTb );
2712 createTool( 416, modifyTb );
2713 createTool( 414, modifyTb );
2714 createTool( 415, modifyTb );
2715 createTool( 417, modifyTb );
2717 createTool( 214, dispModeTb );
2719 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2720 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2723 QString OB = "'ObjectBrowser'",
2724 View = "'" + SVTK_Viewer::Type() + "'",
2726 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2727 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2728 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2729 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2730 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2731 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2732 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2733 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2734 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2735 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2736 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2738 mesh_group = mesh + " " + subMesh + " " + group,
2739 hyp_alg = hypo + " " + algo;
2741 // popup for object browser
2743 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2744 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2745 createPopupItem( 803, OB, group ); // EDIT_GROUP
2746 popupMgr()->insert( separator(), -1, 0 );
2747 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2748 createPopupItem( 214, OB, mesh_group ); // UPDATE
2749 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2750 createPopupItem( 902, OB, mesh ); // STD_INFO
2751 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2752 popupMgr()->insert( separator(), -1, 0 );
2753 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2754 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2755 popupMgr()->insert( separator(), -1, 0 );
2756 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2757 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2758 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2759 popupMgr()->insert( separator(), -1, 0 );
2761 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2762 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2763 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2764 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2765 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2766 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2767 popupMgr()->insert( separator(), -1, 0 );
2770 createPopupItem( 803, View, group ); // EDIT_GROUP
2771 createPopupItem( 804, View, elems ); // ADD
2772 createPopupItem( 805, View, elems ); // REMOVE
2773 popupMgr()->insert( separator(), -1, 0 );
2774 createPopupItem( 214, View, mesh_group ); // UPDATE
2775 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2776 createPopupItem( 902, View, mesh ); // STD_INFO
2777 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2778 popupMgr()->insert( separator(), -1, 0 );
2780 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2781 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2782 popupMgr()->insert( separator(), -1, 0 );
2786 isInvisible("not( isVisible )"),
2787 isEmpty("numberOfNodes = 0"),
2788 isNotEmpty("numberOfNodes <> 0"),
2790 // has nodes, edges, etc in VISIBLE! actor
2791 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2792 hasElems("(count( elemTypes ) > 0)"),
2793 hasDifferentElems("(count( elemTypes ) > 1)"),
2794 hasEdges("({'Edge'} in elemTypes)"),
2795 hasFaces("({'Face'} in elemTypes)"),
2796 hasVolumes("({'Volume'} in elemTypes)");
2798 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2799 QString aType = QString( "%1type in {%2}" ).arg( lc );
2800 aType = aType.arg( mesh_group );
2801 QString aMeshInVTK = aClient + "&&" + aType;
2803 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2804 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2805 QString aSelCount = QString( "%1 > 0" ).arg( dc );
2807 //-------------------------------------------------
2809 //-------------------------------------------------
2810 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2812 popupMgr()->insert( action( 9010 ), anId, -1 );
2813 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
2814 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
2816 popupMgr()->insert( action( 9011 ), anId, -1 );
2817 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
2818 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
2820 popupMgr()->insert( separator(), -1, -1 );
2822 //-------------------------------------------------
2824 //-------------------------------------------------
2825 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2827 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2828 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
2829 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
2831 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2832 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
2833 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
2835 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2836 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
2837 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
2839 popupMgr()->insert( separator(), anId, -1 );
2841 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2842 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
2843 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
2845 //-------------------------------------------------
2847 //-------------------------------------------------
2848 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2850 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2852 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2853 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
2854 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
2856 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2857 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
2858 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
2860 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2861 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
2862 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
2864 popupMgr()->insert( separator(), anId, -1 );
2866 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2867 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
2869 //-------------------------------------------------
2871 //-------------------------------------------------
2872 popupMgr()->insert( action( 1132 ), -1, -1 );
2873 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2875 //-------------------------------------------------
2877 //-------------------------------------------------
2878 popupMgr()->insert( action( 1133 ), -1, -1 );
2879 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2881 //-------------------------------------------------
2883 //-------------------------------------------------
2884 popupMgr()->insert( action( 1134 ), -1, -1 );
2885 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
2887 popupMgr()->insert( separator(), -1, -1 );
2889 //-------------------------------------------------
2891 //-------------------------------------------------
2893 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2894 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2895 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2897 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2899 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2900 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2902 popupMgr()->insert( separator(), anId, -1 );
2904 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2905 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2906 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
2908 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2909 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2910 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
2912 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2913 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
2914 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
2916 popupMgr()->insert( separator(), anId, -1 );
2918 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2919 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2920 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
2922 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2923 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2924 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
2926 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2927 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2928 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
2930 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2931 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2932 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
2934 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2935 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2936 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
2938 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2939 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2940 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
2942 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2943 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2944 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
2946 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2947 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2948 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
2950 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2951 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
2952 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
2954 popupMgr()->insert( separator(), anId, -1 );
2956 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2957 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2958 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
2960 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2961 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
2962 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
2964 popupMgr()->insert( separator(), anId, -1 );
2966 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2967 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
2969 popupMgr()->insert( separator(), -1, -1 );
2971 //-------------------------------------------------
2973 //-------------------------------------------------
2974 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2975 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2976 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2977 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
2979 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2980 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
2982 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2983 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
2985 popupMgr()->insert( separator(), -1, -1 );
2987 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2988 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2991 bool SMESHGUI::activateModule( SUIT_Study* study )
2993 bool res = SalomeApp_Module::activateModule( study );
2995 setMenuShown( true );
2996 setToolShown( true );
2998 // Reset actions accelerator keys
2999 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3000 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3001 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3006 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3008 setMenuShown( false );
3009 setToolShown( false );
3011 EmitSignalCloseAllDialogs();
3013 // Unset actions accelerator keys
3014 action(111)->setShortcut(QKeySequence()); // Import DAT
3015 action(112)->setShortcut(QKeySequence()); // Import UNV
3016 action(113)->setShortcut(QKeySequence()); // Import MED
3018 return SalomeApp_Module::deactivateModule( study );
3021 void SMESHGUI::studyClosed( SUIT_Study* s )
3023 SMESH::RemoveVisuData( s->id() );
3024 SalomeApp_Module::studyClosed( s );
3027 void SMESHGUI::OnGUIEvent()
3029 const QObject* obj = sender();
3030 if ( !obj || !obj->inherits( "QAction" ) )
3032 int id = actionId((QAction*)obj);
3037 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3039 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3040 if ( CORBA::is_nil( myComponentSMESH ) )
3042 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3044 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3045 return aGUI.myComponentSMESH;
3048 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3049 return myComponentSMESH;
3052 QString SMESHGUI::engineIOR() const
3054 CORBA::ORB_var anORB = getApp()->orb();
3055 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3056 return QString( anIOR.in() );
3059 LightApp_Selection* SMESHGUI::createSelection() const
3061 return new SMESHGUI_Selection();
3064 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3066 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3067 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3070 void SMESHGUI::viewManagers( QStringList& list ) const
3072 list.append( SVTK_Viewer::Type() );
3075 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3077 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3078 SMESH::UpdateSelectionProp( this );
3081 void SMESHGUI::createPreferences()
3083 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3085 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3086 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3088 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3089 setPreferenceProperty( qaGroup, "columns", 2 );
3090 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3091 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3093 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3094 setPreferenceProperty( precGroup, "columns", 2 );
3096 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3098 setPreferenceProperty( prec, "min", 0 );
3099 setPreferenceProperty( prec, "max", 16 );
3101 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3102 setPreferenceProperty( dispgroup, "columns", 2 );
3103 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3105 modes.append( "Wireframe" );
3106 modes.append( "Shading" );
3107 modes.append( "Nodes" );
3108 modes.append( "Shrink" );
3109 QList<QVariant> indices;
3110 indices.append( 0 );
3111 indices.append( 1 );
3112 indices.append( 2 );
3113 indices.append( 3 );
3114 setPreferenceProperty( dispmode, "strings", modes );
3115 setPreferenceProperty( dispmode, "indexes", indices );
3117 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3118 setPreferenceProperty( exportgroup, "columns", 2 );
3119 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3120 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3122 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3123 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3124 setPreferenceProperty( nodeGroup, "columns", 2 );
3126 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3127 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3129 setPreferenceProperty( nodeSz, "min", 1 );
3130 setPreferenceProperty( nodeSz, "max", 5 );
3132 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3133 setPreferenceProperty( elemGroup, "columns", 2 );
3135 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3136 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3137 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3138 addPreference( "", elemGroup, LightApp_Preferences::Space );
3140 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3141 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3143 setPreferenceProperty( elemW, "min", 1 );
3144 setPreferenceProperty( elemW, "max", 5 );
3146 setPreferenceProperty( shrink, "min", 0 );
3147 setPreferenceProperty( shrink, "max", 100 );
3149 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3151 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3152 setPreferenceProperty( selGroup, "columns", 2 );
3154 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3155 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3156 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3158 setPreferenceProperty( selW, "min", 1 );
3159 setPreferenceProperty( selW, "max", 5 );
3161 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3162 setPreferenceProperty( preGroup, "columns", 2 );
3164 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3165 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3167 setPreferenceProperty( preW, "min", 1 );
3168 setPreferenceProperty( preW, "max", 5 );
3170 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3171 setPreferenceProperty( precSelGroup, "columns", 2 );
3173 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3174 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3175 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3177 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3178 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3179 setPreferenceProperty( fontGr, "columns", 4 );
3181 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3182 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3183 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3184 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3187 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3188 fam.append( tr( "SMESH_FONT_COURIER" ) );
3189 fam.append( tr( "SMESH_FONT_TIMES" ) );
3190 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3192 setPreferenceProperty( tfont, "families", fam );
3193 setPreferenceProperty( tfont, "system", false );
3194 setPreferenceProperty( tfont, "widget_flags", wflag );
3195 setPreferenceProperty( lfont, "families", fam );
3196 setPreferenceProperty( lfont, "system", false );
3197 setPreferenceProperty( lfont, "widget_flags", wflag );
3199 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3200 setPreferenceProperty( colorsLabelsGr, "columns", 4 );
3202 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3203 setPreferenceProperty( numcol, "min", 2 );
3204 setPreferenceProperty( numcol, "max", 256 );
3206 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3207 setPreferenceProperty( numlab, "min", 2 );
3208 setPreferenceProperty( numlab, "max", 65 );
3210 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3211 setPreferenceProperty( orientGr, "columns", 2 );
3212 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3213 QStringList orients;
3214 orients.append( tr( "SMESH_VERTICAL" ) );
3215 orients.append( tr( "SMESH_HORIZONTAL" ) );
3216 indices.clear(); indices.append( 0 ); indices.append( 1 );
3217 setPreferenceProperty( orient, "strings", orients );
3218 setPreferenceProperty( orient, "indexes", indices );
3220 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3221 setPreferenceProperty( posVSizeGr, "columns", 4 );
3222 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3223 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3224 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3225 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3226 setPreferenceProperty( xv, "step", 0.1 );
3227 setPreferenceProperty( xv, "min", 0.0 );
3228 setPreferenceProperty( xv, "max", 1.0 );
3229 setPreferenceProperty( yv, "step", 0.1 );
3230 setPreferenceProperty( yv, "min", 0.0 );
3231 setPreferenceProperty( yv, "max", 1.0 );
3232 setPreferenceProperty( wv, "step", 0.1 );
3233 setPreferenceProperty( wv, "min", 0.0 );
3234 setPreferenceProperty( wv, "max", 1.0 );
3235 setPreferenceProperty( hv, "min", 0.0 );
3236 setPreferenceProperty( hv, "max", 1.0 );
3237 setPreferenceProperty( hv, "step", 0.1 );
3239 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3240 setPreferenceProperty( posHSizeGr, "columns", 4 );
3241 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3242 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3243 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3244 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3245 setPreferenceProperty( xv, "min", 0.0 );
3246 setPreferenceProperty( xv, "max", 1.0 );
3247 setPreferenceProperty( xv, "step", 0.1 );
3248 setPreferenceProperty( xh, "min", 0.0 );
3249 setPreferenceProperty( xh, "max", 1.0 );
3250 setPreferenceProperty( xh, "step", 0.1 );
3251 setPreferenceProperty( yh, "min", 0.0 );
3252 setPreferenceProperty( yh, "max", 1.0 );
3253 setPreferenceProperty( yh, "step", 0.1 );
3254 setPreferenceProperty( wh, "min", 0.0 );
3255 setPreferenceProperty( wh, "max", 1.0 );
3256 setPreferenceProperty( wh, "step", 0.1 );
3257 setPreferenceProperty( hh, "min", 0.0 );
3258 setPreferenceProperty( hh, "max", 1.0 );
3259 setPreferenceProperty( hh, "step", 0.1 );
3262 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3264 if( sect=="SMESH" ){
3265 float sbX1,sbY1,sbW,sbH;
3266 float aTol = 1.00000009999999;
3267 std::string aWarning;
3268 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3269 if( name=="selection_object_color" || name=="selection_element_color" ||
3270 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3271 name=="selection_precision_node" || name=="selection_precision_element" ||
3272 name=="selection_precision_object")
3273 SMESH::UpdateSelectionProp( this );
3274 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3275 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3276 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3277 if(sbX1+sbW > aTol){
3278 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3281 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3282 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3285 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3286 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3287 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3288 if(sbY1+sbH > aTol){
3289 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3290 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3291 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3294 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3295 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3296 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3297 if(sbX1+sbW > aTol){
3298 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3301 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3302 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3305 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3306 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3307 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3308 if(sbY1+sbH > aTol){
3309 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3312 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3313 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3317 if(aWarning.size() != 0){
3318 aWarning += "The default values are applied instead.";
3319 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3320 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3321 QObject::tr(aWarning.c_str()));
3326 //================================================================================
3328 * \brief Update something in accordance with update flags
3329 * \param theFlags - update flags
3331 * Update viewer or/and object browser etc. in accordance with update flags ( see
3332 * LightApp_UpdateFlags enumeration ).
3334 //================================================================================
3335 void SMESHGUI::update( const int flags )
3337 if ( flags & UF_Viewer | flags & UF_Forced )
3338 SMESH::UpdateView();
3340 SalomeApp_Module::update( flags );
3343 //================================================================================
3345 * \brief Set default selection mode
3347 * SLOT called when operation commited. Sets default selection mode
3349 //================================================================================
3350 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3352 SVTK_ViewWindow* vtkWnd =
3353 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3355 vtkWnd->SetSelectionMode( ActorSelection );
3358 //================================================================================
3360 * \brief Set default selection mode
3362 * SLOT called when operation aborted. Sets default selection mode
3364 //================================================================================
3365 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3367 SVTK_ViewWindow* vtkWnd =
3368 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3370 vtkWnd->SetSelectionMode( ActorSelection );
3373 //================================================================================
3375 * \brief Creates operation with given identifier
3376 * \param id - identifier of operation to be started
3377 * \return Pointer on created operation or NULL if operation is not created
3379 * Virtual method redefined from the base class creates operation with given id.
3380 * It is called called automatically from startOperation method of base class.
3382 //================================================================================
3383 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3385 LightApp_Operation* op = 0;
3386 // to do : create operation here
3389 case 701: // Compute mesh
3390 op = new SMESHGUI_ComputeOp();
3392 case 702: // Create mesh
3393 op = new SMESHGUI_MeshOp( true, true );
3395 case 703: // Create sub-mesh
3396 op = new SMESHGUI_MeshOp( true, false );
3398 case 704: // Edit mesh/sub-mesh
3399 op = new SMESHGUI_MeshOp( false );
3401 case 417: //convert to quadratic
3402 op = new SMESHGUI_ConvToQuadOp();
3404 case 4067: // make mesh pass through point
3405 op = new SMESHGUI_MakeNodeAtPointOp();
3412 op = SalomeApp_Module::createOperation( id );
3416 //================================================================================
3418 * \brief Stops current operations and starts a given one
3419 * \param id - The id of the operation to start
3421 //================================================================================
3423 void SMESHGUI::switchToOperation(int id)
3425 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3426 activeStudy()->abortAllOperations();
3427 startOperation( id );
3430 LightApp_Displayer* SMESHGUI::displayer()
3433 myDisplayer = new SMESHGUI_Displayer( getApp() );
3437 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3440 int aTolerance = 64;
3441 int anIterations = 0;
3447 if( anIterations % aPeriod == 0 )
3450 if( aTolerance < 1 )
3453 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3455 aHue = (int)( 360.0 * rand() / RAND_MAX );
3456 //cout << "Hue = " << aHue << endl;
3458 //cout << "Auto colors : ";
3460 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3461 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3462 for( ; it != itEnd; ++it )
3464 SALOMEDS::Color anAutoColor = *it;
3465 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3468 aQColor.getHsv( &h, &s, &v );
3470 if( abs( h - aHue ) < aTolerance )
3473 //cout << "break (diff = " << abs( h - aHue ) << ")";
3483 //cout << "Hue of the returned color = " << aHue << endl;
3485 aColor.setHsv( aHue, 255, 255 );
3487 SALOMEDS::Color aSColor;
3488 aSColor.R = (double)aColor.red() / 255.0;
3489 aSColor.G = (double)aColor.green() / 255.0;
3490 aSColor.B = (double)aColor.blue() / 255.0;