1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_NodesDlg.h"
29 #include "SMESHGUI_TransparencyDlg.h"
30 #include "SMESHGUI_ClippingDlg.h"
31 #include "SMESHGUI_GroupDlg.h"
32 #include "SMESHGUI_RemoveNodesDlg.h"
33 #include "SMESHGUI_RemoveElementsDlg.h"
34 #include "SMESHGUI_MeshInfosDlg.h"
35 #include "SMESHGUI_StandardMeshInfosDlg.h"
36 #include "SMESHGUI_WhatIsDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_MoveNodesDlg.h"
41 #include "SMESHGUI_AddMeshElementDlg.h"
42 #include "SMESHGUI_AddQuadraticElementDlg.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_SingleEditDlg.h"
46 #include "SMESHGUI_MultiEditDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_DeleteGroupDlg.h"
49 #include "SMESHGUI_SmoothingDlg.h"
50 #include "SMESHGUI_RenumberingDlg.h"
51 #include "SMESHGUI_ExtrusionDlg.h"
52 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
53 #include "SMESHGUI_RevolutionDlg.h"
54 #include "SMESHGUI_TranslationDlg.h"
55 #include "SMESHGUI_RotationDlg.h"
56 #include "SMESHGUI_SymmetryDlg.h"
57 #include "SMESHGUI_SewingDlg.h"
58 #include "SMESHGUI_EditMeshDlg.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_Selection.h"
61 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
62 #include "SMESHGUI_ConvToQuadOp.h"
63 #include "SMESHGUI_MeshOp.h"
64 #include "SMESHGUI_Displayer.h"
65 #include "SMESHGUI_MakeNodeAtPointDlg.h"
66 #include "SMESHGUI_BuildCompoundDlg.h"
67 #include "SMESHGUI_ComputeDlg.h"
68 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include <SMESH_Client.hxx>
79 #include <SMESH_Actor.h>
80 #include <SMESH_TypeFilter.hxx>
82 // SALOME GUI includes
83 #include <SalomeApp_Tools.h>
84 #include <SalomeApp_Study.h>
85 #include <SalomeApp_Application.h>
86 #include <SalomeApp_CheckFileDlg.h>
88 #include <LightApp_DataOwner.h>
89 #include <LightApp_Preferences.h>
90 #include <LightApp_SelectionMgr.h>
91 #include <LightApp_UpdateFlags.h>
92 #include <LightApp_NameDlg.h>
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_ViewManager.h>
98 #include <SUIT_MessageBox.h>
99 #include <SUIT_ResourceMgr.h>
100 #include <SUIT_FileDlg.h>
101 #include <SUIT_Desktop.h>
102 #include <SUIT_OverrideCursor.h>
103 #include <SUIT_Session.h>
105 #include <QtxPopupMgr.h>
106 #include <QtxFontEdit.h>
108 #include <SALOME_ListIO.hxx>
109 #include <SALOME_ListIteratorOfListIO.hxx>
112 #include <SALOMEconfig.h>
113 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
114 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
117 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
121 #include <boost/shared_ptr.hpp>
124 #include <vtkScalarBarActor.h>
126 // SALOME KERNEL includes
127 #include <SALOMEDS_Study.hxx>
128 #include <SALOMEDSClient_StudyBuilder.hxx>
129 #include <SALOMEDSClient_SComponent.hxx>
132 #include <Standard_ErrorHandler.hxx>
136 //=============================================================
137 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
140 void ExportMeshToFile(int theCommandID);
142 void SetDisplayMode(int theCommandID);
144 void SetDisplayEntity(int theCommandID);
146 void Control( int theCommandID );
150 //=============================================================
151 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
155 std::string myExtension;
157 if ( theCommandID == 113 ) {
158 filter.append( QObject::tr( "MED files (*.med)" ) );
159 filter.append( QObject::tr( "All files (*)" ) );
161 else if ( theCommandID == 112 ) {
162 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
164 else if ( theCommandID == 111 ) {
165 filter.append( QObject::tr( "DAT files (*.dat)" ) );
168 QString anInitialPath = "";
169 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
170 anInitialPath = QDir::currentPath();
172 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
175 QObject::tr( "SMESH_IMPORT_MESH" ) );
176 if ( filenames.count() > 0 ) {
177 SUIT_OverrideCursor wc;
178 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
181 bool isEmpty = false;
182 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
183 QString filename = *it;
184 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
186 switch ( theCommandID ) {
189 // DAT format (currently unsupported)
190 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
191 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
197 aMeshes->length( 1 );
198 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
199 if ( aMeshes[0]->_is_nil() )
200 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
201 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
207 SMESH::DriverMED_ReadStatus res;
208 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
209 if ( res != SMESH::DRS_OK ) {
210 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
211 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
217 catch ( const SALOME::SALOME_Exception& S_ex ) {
218 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
219 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
222 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
223 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
225 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
226 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
227 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
228 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
229 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
237 // update Object browser
238 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
240 // show Error message box if there were errors
241 if ( errors.count() > 0 ) {
242 SUIT_MessageBox::critical( SMESHGUI::desktop(),
243 QObject::tr( "SMESH_ERROR" ),
244 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
247 // show warning message box, if some imported mesh is empty
249 SUIT_MessageBox::warning( SMESHGUI::desktop(),
250 QObject::tr( "SMESH_WRN_WARNING" ),
251 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
256 void ExportMeshToFile( int theCommandID )
258 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
259 SALOME_ListIO selected;
261 aSel->selectedObjects( selected );
263 if(selected.Extent()){
264 Handle(SALOME_InteractiveObject) anIObject = selected.First();
265 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
266 if ( !aMesh->_is_nil() ) {
267 QString aFilter, aTitle = QObject::tr("Export mesh");
268 QMap<QString, SMESH::MED_VERSION> aFilterMap;
269 QMap<QString, int> aFilterMapSTL;
270 switch ( theCommandID ) {
274 if (aMesh->HasDuplicatedGroupNamesMED()) {
275 int aRet = SUIT_MessageBox::warning
276 (SMESHGUI::desktop(),
277 QObject::tr("SMESH_WRN_WARNING"),
278 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
279 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
280 if (aRet != SUIT_MessageBox::Yes)
284 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
285 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
286 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
287 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
292 aFilter = QObject::tr("DAT files (*.dat)");
297 if (aMesh->NbPyramids()) {
298 int aRet = SUIT_MessageBox::warning
299 (SMESHGUI::desktop(),
300 QObject::tr("SMESH_WRN_WARNING"),
301 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
302 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
303 if (aRet != SUIT_MessageBox::Yes)
306 aFilter = QObject::tr("IDEAS files (*.unv)");
314 there must be check on others mesh elements not equal triangles
316 if (aMesh->NbTriangles() < 1) {
317 SUIT_MessageBox::warning
318 (SMESHGUI::desktop(),
319 QObject::tr("SMESH_WRN_WARNING"),
320 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
323 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
324 int aRet = SUIT_MessageBox::warning
325 (SMESHGUI::desktop(),
326 QObject::tr("SMESH_WRN_WARNING"),
327 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
328 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
329 if (aRet != SUIT_MessageBox::Yes)
333 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
334 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
342 SMESH::MED_VERSION aFormat;
343 // Init the parameter with the default value
344 bool aIsASCII_STL = true;
345 bool toCreateGroups = false;
346 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
348 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
350 QString anInitialPath = "";
351 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
352 anInitialPath = QDir::currentPath();
354 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
355 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
356 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
357 aFilter, aTitle, false);
359 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
361 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
362 for ( ; it != aFilterMapSTL.end(); ++it )
363 filters.push_back( it.key() );
365 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
366 fd->setWindowTitle( aTitle );
367 fd->setFilters( filters );
368 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
369 if ( !anInitialPath.isEmpty() )
370 fd->setDirectory( anInitialPath );
371 fd->selectFile(anIObject->getName());
375 aFilename = fd->selectedFile();
376 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
381 else { // Export to MED
383 QString aDefaultFilter;
384 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
385 for ( ; it != aFilterMap.end(); ++it ) {
386 filters.push_back( it.key() );
387 if (it.value() == SMESH::MED_V2_2)
388 aDefaultFilter = it.key();
391 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
392 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
393 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
394 fd->setWindowTitle( aTitle );
395 fd->setFilters( filters );
396 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
397 fd->selectFilter(aDefaultFilter);
398 fd->SetChecked(toCreateGroups);
399 if ( !anInitialPath.isEmpty() )
400 fd->setDirectory( anInitialPath );
401 fd->selectFile(anIObject->getName());
405 aFilename = fd->selectedFile();
406 aFormat = aFilterMap[fd->selectedFilter()];
408 if ( !aFilename.isEmpty()
409 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
410 && aFormat==SMESH::MED_V2_1) {
411 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
412 QObject::tr("SMESH_WRN_WARNING"),
413 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
414 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
415 if (aRet != SUIT_MessageBox::Yes) {
420 toCreateGroups = fd->IsChecked();
423 if ( !aFilename.isEmpty() ) {
424 // Check whether the file already exists and delete it if yes
425 QFile aFile( aFilename );
426 if ( aFile.exists() )
428 SUIT_OverrideCursor wc;
431 bool Renumber = false;
432 // PAL 14172 : Check of we have to renumber or not from the preferences before export
434 Renumber= resMgr->booleanValue("SMESH","renumbering");
436 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
437 aMeshEditor->RenumberNodes();
438 aMeshEditor->RenumberElements();
439 if ( SMESHGUI::automaticUpdate() )
442 switch ( theCommandID ) {
445 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
449 aMesh->ExportDAT( aFilename.toLatin1().data() );
453 aMesh->ExportUNV( aFilename.toLatin1().data() );
457 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
463 catch (const SALOME::SALOME_Exception& S_ex){
465 SUIT_MessageBox::warning(SMESHGUI::desktop(),
466 QObject::tr("SMESH_WRN_WARNING"),
467 QObject::tr("SMESH_EXPORT_FAILED"));
475 inline void InverseEntityMode(unsigned int& theOutputMode,
476 unsigned int theMode)
478 bool anIsNotPresent = ~theOutputMode & theMode;
480 theOutputMode |= theMode;
482 theOutputMode &= ~theMode;
485 void SetDisplayEntity(int theCommandID){
486 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
487 SALOME_ListIO selected;
489 aSel->selectedObjects( selected );
491 if(selected.Extent() >= 1){
492 SALOME_ListIteratorOfListIO It( selected );
493 for( ; It.More(); It.Next()){
494 Handle(SALOME_InteractiveObject) IObject = It.Value();
495 if(IObject->hasEntry()){
496 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
497 unsigned int aMode = anActor->GetEntityMode();
498 switch(theCommandID){
500 InverseEntityMode(aMode,SMESH_Actor::eEdges);
503 InverseEntityMode(aMode,SMESH_Actor::eFaces);
506 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
509 aMode = SMESH_Actor::eAllEntity;
513 anActor->SetEntityMode(aMode);
521 SALOME_ListIO selected;
522 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
526 LightApp_SelectionMgr* aSel = app->selectionMgr();
527 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
528 if( !aSel || !appStudy )
531 aSel->selectedObjects( selected );
532 if( selected.IsEmpty() )
535 Handle(SALOME_InteractiveObject) anIObject = selected.First();
537 _PTR(Study) aStudy = appStudy->studyDS();
538 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
539 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
540 if( aMainObject->_is_nil() )
543 aMainObject->SetAutoColor( true );
545 QList<SALOMEDS::Color> aReservedColors;
547 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
548 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
550 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
551 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
553 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
554 aGroupObject->SetColor( aColor );
555 aReservedColors.append( aColor );
557 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
558 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
560 if( aGroupObject->GetType() == SMESH::NODE )
561 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
562 else if( aGroupObject->GetType() == SMESH::EDGE )
563 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
565 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
569 SMESH::RepaintCurrentView();
572 void DisableAutoColor(){
573 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
574 SALOME_ListIO selected;
576 aSel->selectedObjects( selected );
578 if(selected.Extent()){
579 Handle(SALOME_InteractiveObject) anIObject = selected.First();
580 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
581 if ( !aMesh->_is_nil() ) {
582 aMesh->SetAutoColor( false );
587 void SetDisplayMode(int theCommandID){
588 SALOME_ListIO selected;
589 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
593 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
594 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
595 if( !aSel || !appStudy )
598 _PTR(Study) aStudy = appStudy->studyDS();
600 aSel->selectedObjects( selected );
602 if(selected.Extent() >= 1){
603 switch(theCommandID){
605 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
606 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
610 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
611 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
614 SALOME_ListIteratorOfListIO It( selected );
615 for( ; It.More(); It.Next()){
616 Handle(SALOME_InteractiveObject) IObject = It.Value();
617 if(IObject->hasEntry()){
618 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
619 switch(theCommandID){
621 anActor->SetRepresentation(SMESH_Actor::eEdge);
624 anActor->SetRepresentation(SMESH_Actor::eSurface);
627 if(anActor->IsShrunk())
630 anActor->SetShrink();
633 anActor->SetRepresentation(SMESH_Actor::ePoint);
636 vtkFloatingPointType color[3];
637 anActor->GetSufaceColor(color[0], color[1], color[2]);
638 int c0 = int (color[0] * 255);
639 int c1 = int (color[1] * 255);
640 int c2 = int (color[2] * 255);
641 QColor c(c0, c1, c2);
643 vtkFloatingPointType edgecolor[3];
644 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
645 c0 = int (edgecolor[0] * 255);
646 c1 = int (edgecolor[1] * 255);
647 c2 = int (edgecolor[2] * 255);
648 QColor e(c0, c1, c2);
650 vtkFloatingPointType backfacecolor[3];
651 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
652 c0 = int (backfacecolor[0] * 255);
653 c1 = int (backfacecolor[1] * 255);
654 c2 = int (backfacecolor[2] * 255);
655 QColor b(c0, c1, c2);
657 vtkFloatingPointType nodecolor[3];
658 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
659 c0 = int (nodecolor[0] * 255);
660 c1 = int (nodecolor[1] * 255);
661 c2 = int (nodecolor[2] * 255);
662 QColor n(c0, c1, c2);
664 int Edgewidth = (int)anActor->GetLineWidth();
667 int intValue = int(anActor->GetNodeSize());
668 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
670 SMESHGUI_Preferences_ColorDlg *aDlg =
671 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
672 aDlg->SetColor(1, c);
673 aDlg->SetColor(2, e);
674 aDlg->SetColor(3, n);
675 aDlg->SetColor(4, b);
676 aDlg->SetIntValue(1, Edgewidth);
677 aDlg->SetIntValue(2, intValue);
678 aDlg->SetIntValue(3, int(Shrink*100.));
680 QColor color = aDlg->GetColor(1);
681 QColor edgecolor = aDlg->GetColor(2);
682 QColor nodecolor = aDlg->GetColor(3);
683 QColor backfacecolor = aDlg->GetColor(4);
684 /* actor color and backface color */
685 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
686 vtkFloatingPointType (color.green()) / 255.,
687 vtkFloatingPointType (color.blue()) / 255.);
688 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
689 vtkFloatingPointType (backfacecolor.green()) / 255.,
690 vtkFloatingPointType (backfacecolor.blue()) / 255.);
693 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
694 vtkFloatingPointType (edgecolor.green()) / 255.,
695 vtkFloatingPointType (edgecolor.blue()) / 255.);
697 /* Shrink factor and size edges */
698 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
699 anActor->SetLineWidth(aDlg->GetIntValue(1));
701 /* Nodes color and size */
702 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
703 vtkFloatingPointType (nodecolor.green()) / 255.,
704 vtkFloatingPointType (nodecolor.blue()) / 255.);
705 anActor->SetNodeSize(aDlg->GetIntValue(2));
707 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
708 if( !aGroupObject->_is_nil() )
710 SALOMEDS::Color aColor;
711 aColor.R = (float)color.red() / 255.0;
712 aColor.G = (float)color.green() / 255.0;
713 aColor.B = (float)color.blue() / 255.0;
714 aGroupObject->SetColor( aColor );
724 SMESH::RepaintCurrentView();
728 void Control( int theCommandID )
730 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
731 SALOME_ListIO selected;
733 aSel->selectedObjects( selected );
735 if( !selected.IsEmpty() ){
736 Handle(SALOME_InteractiveObject) anIO = selected.First();
739 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
740 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
741 switch ( theCommandID ){
743 aTitle = QObject::tr( "LENGTH_EDGES" );
744 aControl = SMESH_Actor::eLength;
747 aTitle = QObject::tr( "LENGTH2D_EDGES" );
748 aControl = SMESH_Actor::eLength2D;
751 aTitle = QObject::tr( "FREE_EDGES" );
752 aControl = SMESH_Actor::eFreeEdges;
755 aTitle = QObject::tr( "FREE_BORDERS" );
756 aControl = SMESH_Actor::eFreeBorders;
759 aTitle = QObject::tr( "MULTI_BORDERS" );
760 aControl = SMESH_Actor::eMultiConnection;
763 aTitle = QObject::tr( "MULTI2D_BORDERS" );
764 aControl = SMESH_Actor::eMultiConnection2D;
767 aTitle = QObject::tr( "AREA_ELEMENTS" );
768 aControl = SMESH_Actor::eArea;
771 aTitle = QObject::tr( "TAPER_ELEMENTS" );
772 aControl = SMESH_Actor::eTaper;
775 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
776 aControl = SMESH_Actor::eAspectRatio;
779 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
780 aControl = SMESH_Actor::eAspectRatio3D;
783 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
784 aControl = SMESH_Actor::eMinimumAngle;
787 aTitle = QObject::tr( "WARP_ELEMENTS" );
788 aControl = SMESH_Actor::eWarping;
791 aTitle = QObject::tr( "SKEW_ELEMENTS" );
792 aControl = SMESH_Actor::eSkew;
795 aTitle = QObject::tr( "SMESH_VOLUME" );
796 aControl = SMESH_Actor::eVolume3D;
799 anActor->SetControlMode(aControl);
800 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
801 SMESH::RepaintCurrentView();
808 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
809 MeshObjectType theType,
810 const QString theInTypeName,
811 QString & theOutTypeName)
813 SMESH_TypeFilter aTypeFilter( theType );
815 if( !theIO.IsNull() )
817 entry = theIO->getEntry();
818 LightApp_DataOwner owner( entry );
819 if ( aTypeFilter.isOk( &owner )) {
820 theOutTypeName = theInTypeName;
828 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
830 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
831 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
833 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
834 CORBA::String_var anID = aSComp->GetID().c_str();
835 if (!strcmp(anID.in(),theIO->getEntry()))
841 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
842 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
843 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
844 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
845 CheckOIType ( theIO, GROUP, "Group", aTypeName )
853 QString CheckHomogeneousSelection()
855 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
856 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
857 SALOME_ListIO selected;
859 aSel->selectedObjects( selected );
861 QString RefType = CheckTypeObject(selected.First());
862 SALOME_ListIteratorOfListIO It(selected);
863 for ( ; It.More(); It.Next())
865 Handle(SALOME_InteractiveObject) IObject = It.Value();
866 QString Type = CheckTypeObject(IObject);
867 if (Type.compare(RefType) != 0)
868 return "Heterogeneous Selection";
875 void SMESHGUI::OnEditDelete()
877 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
878 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
879 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
881 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
882 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
883 _PTR(GenericAttribute) anAttr;
884 _PTR(AttributeIOR) anIOR;
887 QString aParentComponent = QString::null;
888 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
890 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
892 // check if object is not reference
893 _PTR(SObject) refobj;
894 if ( !aSO->ReferencedObject( refobj ) )
898 QString cur = anIt.Value()->getComponentDataType();
899 if( aParentComponent.isNull() )
900 aParentComponent = cur;
901 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
902 aParentComponent = "";
905 if ( objectCount == 0 )
906 return; // No Valid Objects Selected
908 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
909 SUIT_MessageBox::warning( SMESHGUI::desktop(),
910 QObject::tr("ERR_ERROR"),
911 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
914 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
915 if (SUIT_MessageBox::warning
916 (SMESHGUI::desktop(),
917 QObject::tr("SMESH_WRN_WARNING"),
918 QObject::tr("SMESH_REALLY_DELETE"),
919 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
920 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
923 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
924 SUIT_ViewManager* vm = anApp->activeViewManager();
925 int nbSf = vm->getViewsCount();
927 SALOME_ListIteratorOfListIO It(selected);
929 aStudyBuilder->NewCommand(); // There is a transaction
930 for( ; It.More(); It.Next()){ // loop on selected IO's
931 Handle(SALOME_InteractiveObject) IObject = It.Value();
932 if(IObject->hasEntry()) {
933 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
935 // disable removal of "SMESH" component object
936 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
938 if ( engineIOR() == anIOR->Value().c_str() )
942 _PTR(SObject) refobj;
943 if ( aSO && aSO->ReferencedObject( refobj ) )
944 continue; // skip references
946 // put the whole hierarchy of sub-objects of the selected SO into a list and
947 // then treat them all starting from the deepest objects (at list back)
949 std::list< _PTR(SObject) > listSO;
950 listSO.push_back( aSO );
951 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
952 for ( ; itSO != listSO.end(); ++itSO ) {
953 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
954 for (it->InitEx(false); it->More(); it->Next())
955 listSO.push_back( it->Value() );
958 // treat SO's in the list starting from the back
960 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
961 for ( ; ritSO != listSO.rend(); ++ritSO ) {
962 _PTR(SObject) SO = *ritSO;
964 std::string anEntry = SO->GetID();
966 /** Erase graphical object **/
967 if(SO->FindAttribute(anAttr, "AttributeIOR")){
968 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
969 for(int i = 0; i < nbSf; i++){
970 SUIT_ViewWindow *sf = aViews[i];
971 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
972 SMESH::RemoveActor(sf,anActor);
977 /** Remove an object from data structures **/
978 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
979 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
980 if ( !aGroup->_is_nil() ) { // DELETE GROUP
981 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
982 aMesh->RemoveGroup( aGroup );
984 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
985 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
986 aMesh->RemoveSubMesh( aSubMesh );
988 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
990 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
993 IObject = new SALOME_InteractiveObject
994 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
995 QString objType = CheckTypeObject(IObject);
996 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
997 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
998 aStudyBuilder->RemoveObjectWithChildren( SO );
1000 else {// default action: remove SObject from the study
1001 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1002 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1004 aStudyBuilder->RemoveObjectWithChildren( SO );
1008 } /* listSO back loop */
1009 } /* IObject->hasEntry() */
1011 aStudyBuilder->CommitCommand();
1013 /* Clear any previous selection */
1015 aSel->setSelectedObjects( l1 );
1017 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1022 SMESHGUI_EXPORT CAM_Module* createModule()
1024 return new SMESHGUI();
1028 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1030 //=============================================================================
1034 //=============================================================================
1035 SMESHGUI::SMESHGUI() :
1036 SalomeApp_Module( "SMESH" )
1038 if ( CORBA::is_nil( myComponentSMESH ) )
1040 CORBA::Boolean anIsEmbeddedMode;
1041 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1044 myActiveDialogBox = 0;
1045 myFilterLibraryDlg = 0;
1049 SMESH::GetFilterManager();
1050 SMESH::GetPattern();
1052 /* load resources for all available meshers */
1053 SMESH::InitAvailableHypotheses();
1056 //=============================================================================
1060 //=============================================================================
1061 SMESHGUI::~SMESHGUI()
1063 SMESH::GetFilterManager()->Destroy();
1064 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1067 //=============================================================================
1071 //=============================================================================
1072 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1074 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1076 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1081 bool SMESHGUI::automaticUpdate()
1083 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1087 return resMgr->booleanValue( "SMESH", "auto_update", false );
1090 //=============================================================================
1094 //=============================================================================
1095 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1097 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1100 //=============================================================================
1104 //=============================================================================
1105 SMESHGUI* SMESHGUI::GetSMESHGUI()
1107 SMESHGUI* smeshMod = 0;
1108 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1111 CAM_Module* module = app->module( "Mesh" );
1112 smeshMod = dynamic_cast<SMESHGUI*>( module );
1115 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1117 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1120 _PTR(Study) aStudy = study->studyDS();
1122 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1131 Standard_EXPORT SMESHGUI* GetComponentGUI()
1133 return SMESHGUI::GetSMESHGUI();
1137 //=============================================================================
1141 //=============================================================================
1142 void SMESHGUI::SetState(int aState)
1147 //=============================================================================
1151 //=============================================================================
1152 void SMESHGUI::ResetState()
1157 //=============================================================================
1161 //=============================================================================
1162 void SMESHGUI::EmitSignalDeactivateDialog()
1164 emit SignalDeactivateActiveDialog();
1167 //=============================================================================
1171 //=============================================================================
1172 void SMESHGUI::EmitSignalStudyFrameChanged()
1174 emit SignalStudyFrameChanged();
1177 //=============================================================================
1181 //=============================================================================
1182 void SMESHGUI::EmitSignalCloseAllDialogs()
1184 emit SignalCloseAllDialogs();
1187 //=============================================================================
1191 //=============================================================================
1192 QDialog *SMESHGUI::GetActiveDialogBox()
1194 return myActiveDialogBox;
1197 //=============================================================================
1201 //=============================================================================
1202 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1204 myActiveDialogBox = (QDialog *) aDlg;
1208 //=============================================================================
1212 //=============================================================================
1213 SUIT_Desktop* SMESHGUI::desktop()
1215 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1217 return app->desktop();
1222 //=============================================================================
1226 //=============================================================================
1227 SalomeApp_Study* SMESHGUI::activeStudy()
1229 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1231 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1236 //=============================================================================
1240 //=============================================================================
1241 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1243 /* Here the position is on the bottom right corner - 10 */
1244 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1246 SUIT_Desktop *PP = desktop();
1247 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1248 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1252 //=============================================================================
1256 //=============================================================================
1257 static int isStudyLocked(_PTR(Study) theStudy){
1258 return theStudy->GetProperties()->IsLocked();
1261 static bool checkLock(_PTR(Study) theStudy) {
1262 if (isStudyLocked(theStudy)) {
1263 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1264 QObject::tr("WRN_WARNING"),
1265 QObject::tr("WRN_STUDY_LOCKED") );
1271 //=======================================================================
1272 //function : CheckActiveStudyLocked
1274 //=======================================================================
1276 bool SMESHGUI::isActiveStudyLocked()
1278 _PTR(Study) aStudy = activeStudy()->studyDS();
1279 return checkLock( aStudy );
1282 //=============================================================================
1286 //=============================================================================
1287 bool SMESHGUI::OnGUIEvent( int theCommandID )
1289 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1293 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1294 SUIT_ResourceMgr* mgr = resourceMgr();
1298 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1299 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1302 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1303 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1305 //QAction* act = action( theCommandID );
1307 switch (theCommandID) {
1309 if(checkLock(aStudy)) break;
1317 if(checkLock(aStudy)) break;
1318 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1322 case 150: //MED FILE INFORMATION
1324 SALOME_ListIO selected;
1325 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1327 aSel->selectedObjects( selected );
1328 if( selected.Extent() )
1330 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1331 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1332 if ( !aMesh->_is_nil() )
1334 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1341 case 122: // EXPORT MED
1350 ::ExportMeshToFile(theCommandID);
1354 case 200: // SCALAR BAR
1356 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1357 SALOME_ListIO selected;
1359 aSel->selectedObjects( selected );
1361 if( selected.Extent() ) {
1362 Handle(SALOME_InteractiveObject) anIO = selected.First();
1363 if( anIO->hasEntry() ) {
1364 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1365 anActor->SetControlMode( SMESH_Actor::eNone );
1373 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1383 ::DisableAutoColor();
1386 case 1134: // Clipping
1387 case 1133: // Tranparency
1388 case 1132: // Colors / Size
1395 ::SetDisplayMode(theCommandID);
1401 case 219: // Volumes
1402 case 220: // All Entity
1403 ::SetDisplayEntity(theCommandID);
1406 case 221: // Orientation of faces
1408 LightApp_SelectionMgr* mgr = selectionMgr();
1409 SALOME_ListIO selected; mgr->selectedObjects( selected );
1411 SALOME_ListIteratorOfListIO it(selected);
1412 for( ; it.More(); it.Next()) {
1413 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1414 if(anIObject->hasEntry()) {
1415 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1416 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1425 if(checkLock(aStudy)) break;
1427 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1430 SMESH::UpdateView();
1432 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1433 SMESH::OnVisuException();
1435 catch (...) { // PAL16774 (Crash after display of many groups)
1436 SMESH::OnVisuException();
1440 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1441 aSel->selectedObjects( l );
1442 aSel->setSelectedObjects( l );
1447 case 301: // DISPLAY
1448 case 302: // DISPLAY ONLY
1450 SMESH::EDisplaing anAction;
1451 switch (theCommandID) {
1452 case 300: anAction = SMESH::eErase; break;
1453 case 301: anAction = SMESH::eDisplay; break;
1454 case 302: anAction = SMESH::eDisplayOnly; break;
1457 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1458 SALOME_ListIO sel_objects, to_process;
1460 aSel->selectedObjects( sel_objects );
1462 if( theCommandID==302 )
1463 startOperation( myEraseAll );
1465 extractContainers( sel_objects, to_process );
1468 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1472 SALOME_ListIteratorOfListIO It( to_process );
1473 for ( ; It.More(); It.Next()) {
1474 Handle(SALOME_InteractiveObject) IOS = It.Value();
1475 if (IOS->hasEntry()) {
1476 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1477 break; // PAL16774 (Crash after display of many groups)
1478 if (anAction == SMESH::eDisplayOnly)
1479 anAction = SMESH::eDisplay;
1484 // PAL13338 + PAL15161 -->
1485 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1486 SMESH::UpdateView();
1487 // PAL13338 + PAL15161 <--
1489 catch (...) { // PAL16774 (Crash after display of many groups)
1490 SMESH::OnVisuException();
1493 if (anAction == SMESH::eErase) {
1495 aSel->setSelectedObjects( l1 );
1498 aSel->setSelectedObjects( to_process );
1505 if(checkLock(aStudy)) break;
1508 EmitSignalDeactivateDialog();
1510 ( new SMESHGUI_NodesDlg( this ) )->show();
1513 SUIT_MessageBox::warning(desktop(),
1514 tr("SMESH_WRN_WARNING"),
1515 tr("SMESH_WRN_VIEWER_VTK"));
1520 case 2151: // FILTER
1524 EmitSignalDeactivateDialog();
1525 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1530 case 406: // MOVE NODE
1534 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1535 tr( "NOT_A_VTK_VIEWER" ) );
1539 if(checkLock(aStudy)) break;
1540 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1544 case 701: // COMPUTE MESH
1546 if (checkLock(aStudy)) break;
1548 startOperation( 701 );
1552 case 702: // Create mesh
1553 startOperation( 702 );
1555 case 703: // Create sub-mesh
1556 startOperation( 703 );
1558 case 704: // Edit mesh/sub-mesh
1559 startOperation( 704 );
1561 case 710: // Build compound mesh
1563 if (checkLock(aStudy)) break;
1564 EmitSignalDeactivateDialog();
1565 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1569 case 407: // DIAGONAL INVERSION
1570 case 408: // Delete diagonal
1574 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1575 tr( "NOT_A_VTK_VIEWER" ) );
1579 if ( checkLock( aStudy ) )
1582 /*Standard_Boolean aRes;
1583 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1584 if ( aMesh->_is_nil() )
1586 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1587 tr( "SMESH_BAD_SELECTION" ) );
1591 EmitSignalDeactivateDialog();
1592 if ( theCommandID == 407 )
1593 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1595 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1598 case 409: // Change orientation
1599 case 410: // Union of triangles
1600 case 411: // Cutting of quadrangles
1604 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1605 tr( "NOT_A_VTK_VIEWER" ) );
1609 if ( checkLock( aStudy ) )
1612 EmitSignalDeactivateDialog();
1613 SMESHGUI_MultiEditDlg* aDlg = NULL;
1614 if ( theCommandID == 409 )
1615 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1616 else if ( theCommandID == 410 )
1617 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1619 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1624 case 412: // Smoothing
1626 if(checkLock(aStudy)) break;
1628 EmitSignalDeactivateDialog();
1629 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1632 SUIT_MessageBox::warning(desktop(),
1633 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1637 case 413: // Extrusion
1639 if (checkLock(aStudy)) break;
1641 EmitSignalDeactivateDialog();
1642 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1644 SUIT_MessageBox::warning(desktop(),
1645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1649 case 414: // Revolution
1651 if(checkLock(aStudy)) break;
1653 EmitSignalDeactivateDialog();
1654 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1657 SUIT_MessageBox::warning(desktop(),
1658 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1662 case 415: // Pattern mapping
1664 if ( checkLock( aStudy ) )
1668 EmitSignalDeactivateDialog();
1669 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1672 SUIT_MessageBox::warning(desktop(),
1673 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1677 case 416: // Extrusion along a path
1679 if (checkLock(aStudy)) break;
1681 EmitSignalDeactivateDialog();
1682 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1684 SUIT_MessageBox::warning(desktop(),
1685 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1689 case 417: // Convert mesh to quadratic
1691 startOperation( 417 );
1692 /* if (checkLock(aStudy)) break;
1694 EmitSignalDeactivateDialog();
1695 new SMESHGUI_ConvToQuadDlg();
1697 SUIT_MessageBox::warning(desktop(),
1698 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1702 case 801: // CREATE GROUP
1706 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1707 tr( "NOT_A_VTK_VIEWER" ) );
1711 if(checkLock(aStudy)) break;
1712 EmitSignalDeactivateDialog();
1713 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1715 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1716 SALOME_ListIO selected;
1718 aSel->selectedObjects( selected );
1720 int nbSel = selected.Extent();
1722 // check if mesh is selected
1723 aMesh = SMESH::GetMeshByIO( selected.First() );
1725 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1730 case 802: // CONSTRUCT GROUP
1734 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1735 tr( "NOT_A_VTK_VIEWER" ) );
1739 if(checkLock(aStudy)) break;
1740 EmitSignalDeactivateDialog();
1742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1743 SALOME_ListIO selected;
1745 aSel->selectedObjects( selected );
1747 int nbSel = selected.Extent();
1749 // check if submesh is selected
1750 Handle(SALOME_InteractiveObject) IObject = selected.First();
1751 if (IObject->hasEntry()) {
1752 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1754 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1755 if (!aSubMesh->_is_nil()) {
1757 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1758 // get submesh elements list by types
1759 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1760 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1761 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1762 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1763 // create group for each type o elements
1764 QString aName = IObject->getName();
1765 if (aNodes->length() > 0) {
1766 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1767 aGroup->Add(aNodes.inout());
1769 if (aEdges->length() > 0) {
1770 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1771 aGroup->Add(aEdges.inout());
1773 if (aFaces->length() > 0) {
1774 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1775 aGroup->Add(aFaces.inout());
1777 if (aVolumes->length() > 0) {
1778 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1779 aGroup->Add(aVolumes.inout());
1784 catch(const SALOME::SALOME_Exception & S_ex){
1785 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1792 SUIT_MessageBox::warning(desktop(),
1793 tr("SMESH_WRN_WARNING"),
1794 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1799 case 803: // EDIT GROUP
1803 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1804 tr( "NOT_A_VTK_VIEWER" ) );
1808 if(checkLock(aStudy)) break;
1809 EmitSignalDeactivateDialog();
1811 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1812 SALOME_ListIO selected;
1814 aSel->selectedObjects( selected );
1816 SALOME_ListIteratorOfListIO It (selected);
1817 int nbSelectedGroups = 0;
1818 for ( ; It.More(); It.Next() )
1820 SMESH::SMESH_GroupBase_var aGroup =
1821 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1822 if (!aGroup->_is_nil()) {
1824 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1828 if (nbSelectedGroups == 0)
1830 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1836 case 804: // Add elements to group
1838 if(checkLock(aStudy)) break;
1839 if (myState == 800) {
1840 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1841 if (aDlg) aDlg->onAdd();
1846 case 805: // Remove elements from group
1848 if(checkLock(aStudy)) break;
1849 if (myState == 800) {
1850 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1851 if (aDlg) aDlg->onRemove();
1856 case 810: // Union Groups
1857 case 811: // Intersect groups
1858 case 812: // Cut groups
1862 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1863 tr( "NOT_A_VTK_VIEWER" ) );
1867 if ( checkLock( aStudy ) )
1870 EmitSignalDeactivateDialog();
1873 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1874 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1875 else aMode = SMESHGUI_GroupOpDlg::CUT;
1877 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1881 case 813: // Delete groups with their contents
1885 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1886 tr( "NOT_A_VTK_VIEWER" ) );
1890 if ( checkLock( aStudy ) )
1893 EmitSignalDeactivateDialog();
1895 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1899 case 900: // MESH INFOS
1901 EmitSignalDeactivateDialog();
1902 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1903 SALOME_ListIO selected;
1905 aSel->selectedObjects( selected );
1907 if ( selected.Extent() > 1 ) { // a dlg for each IO
1909 SALOME_ListIteratorOfListIO It (selected);
1910 for ( ; It.More(); It.Next() ) {
1911 IOs.Clear(); IOs.Append( It.Value() );
1912 aSel->setSelectedObjects( IOs );
1913 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1915 // restore selection
1916 aSel->setSelectedObjects( selected );
1919 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1923 case 902: // STANDARD MESH INFOS
1925 EmitSignalDeactivateDialog();
1926 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1927 SALOME_ListIO selected;
1929 aSel->selectedObjects( selected );
1931 if ( selected.Extent() > 1 ) { // a dlg for each IO
1933 SALOME_ListIteratorOfListIO It (selected);
1934 for ( ; It.More(); It.Next() ) {
1936 IOs.Append( It.Value() );
1937 aSel->setSelectedObjects( IOs );
1938 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1940 // restore selection
1941 aSel->setSelectedObjects( selected );
1944 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1948 case 903: // WHAT IS
1950 EmitSignalDeactivateDialog();
1951 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1955 case 1100: // EDIT HYPOTHESIS
1957 if(checkLock(aStudy)) break;
1959 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1960 SALOME_ListIO selected;
1962 aSel->selectedObjects( selected );
1964 int nbSel = selected.Extent();
1967 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1968 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1970 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1971 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1972 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1973 if ( !aHypothesis->_is_nil() )
1975 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
1977 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1984 updateObjBrowser( true );
1988 case 1101: // RENAME
1990 if ( checkLock( aStudy ) )
1993 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1994 SALOME_ListIO selected;
1996 aSel->selectedObjects( selected );
1998 bool isAny = false; // iss there any appropriate object selected
2000 SALOME_ListIteratorOfListIO It( selected );
2001 for ( ; It.More(); It.Next() )
2003 Handle(SALOME_InteractiveObject) IObject = It.Value();
2004 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2005 _PTR(GenericAttribute) anAttr;
2006 _PTR(AttributeName) aName;
2009 if ( obj->FindAttribute(anAttr, "AttributeName") )
2012 QString newName = QString(aName->Value().c_str());
2014 // check type to prevent renaming of inappropriate objects
2015 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2016 if (aType == MESH || aType == GROUP ||
2017 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2018 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2019 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2020 aType == HYPOTHESIS || aType == ALGORITHM)
2023 newName = LightApp_NameDlg::getName(desktop(), newName);
2024 if ( !newName.isEmpty() )
2026 //old source: aStudy->renameIObject( IObject, newName );
2027 aName->SetValue( newName.toLatin1().constData() );
2029 // if current object is group update group's name
2030 SMESH::SMESH_GroupBase_var aGroup =
2031 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2032 if (!aGroup->_is_nil() )
2033 aGroup->SetName( newName.toLatin1().constData() );
2043 SUIT_MessageBox::warning(desktop(),
2044 QObject::tr("SMESH_WRN_WARNING"),
2045 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2050 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2052 if(checkLock(aStudy)) break;
2053 SUIT_OverrideCursor wc;
2055 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2056 SALOME_ListIO selected;
2058 aSel->selectedObjects( selected, QString::null, false );
2060 SALOME_ListIteratorOfListIO It(selected);
2061 for (int i = 0; It.More(); It.Next(), i++) {
2062 Handle(SALOME_InteractiveObject) IObject = It.Value();
2063 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2066 aSel->setSelectedObjects( l1 );
2071 case 401: // GEOM::EDGE
2072 case 4021: // TRIANGLE
2074 case 4023: // POLYGON
2078 if(checkLock(aStudy)) break;
2080 EmitSignalDeactivateDialog();
2081 SMDSAbs_ElementType type = SMDSAbs_Edge;
2083 switch (theCommandID) {
2084 case 4021: // TRIANGLE
2085 type = SMDSAbs_Face; nbNodes = 3; break;
2087 type = SMDSAbs_Face; nbNodes = 4; break;
2089 type = SMDSAbs_Volume; nbNodes = 4; break;
2090 case 4023: // POLYGON
2091 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2093 type = SMDSAbs_Volume; nbNodes = 8; break;
2094 case 4033: // POLYHEDRE
2095 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2098 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2101 SUIT_MessageBox::warning(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2106 case 4033: // POLYHEDRON
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2114 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2115 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2119 case 4034: // QUADRATIC EDGE
2120 case 4035: // QUADRATIC TRIANGLE
2121 case 4036: // QUADRATIC QUADRANGLE
2122 case 4037: // QUADRATIC TETRAHEDRON
2123 case 4038: // QUADRATIC PYRAMID
2124 case 4039: // QUADRATIC PENTAHEDRON
2125 case 4040: // QUADRATIC HEXAHEDRON
2127 if(checkLock(aStudy)) break;
2129 EmitSignalDeactivateDialog();
2132 switch (theCommandID) {
2134 type = QUAD_EDGE; break;
2136 type = QUAD_TRIANGLE; break;
2138 type = QUAD_QUADRANGLE; break;
2140 type = QUAD_TETRAHEDRON; break;
2142 type = QUAD_PYRAMID; break;
2144 type = QUAD_PENTAHEDRON; break;
2146 type = QUAD_HEXAHEDRON;
2150 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2153 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2154 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2158 case 4041: // REMOVES NODES
2160 if(checkLock(aStudy)) break;
2162 EmitSignalDeactivateDialog();
2163 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2166 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2167 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2171 case 4042: // REMOVES ELEMENTS
2173 if(checkLock(aStudy)) break;
2175 EmitSignalDeactivateDialog();
2176 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2180 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2181 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2185 case 4043: { // CLEAR_MESH
2187 if(checkLock(aStudy)) break;
2189 SALOME_ListIO selected;
2190 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2191 aSel->selectedObjects( selected );
2193 SUIT_OverrideCursor wc;
2194 SALOME_ListIteratorOfListIO It (selected);
2195 for ( ; It.More(); It.Next() )
2197 Handle(SALOME_InteractiveObject) IOS = It.Value();
2198 SMESH::SMESH_Mesh_var aMesh =
2199 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2200 if ( aMesh->_is_nil()) continue;
2202 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2204 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2205 SMESH::ModifiedMesh( aMeshSObj, false, true);
2206 // hide groups and submeshes
2207 _PTR(ChildIterator) anIter =
2208 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2209 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2211 _PTR(SObject) so = anIter->Value();
2212 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2215 catch (const SALOME::SALOME_Exception& S_ex){
2217 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2221 SMESH::UpdateView();
2225 case 4051: // RENUMBERING NODES
2227 if(checkLock(aStudy)) break;
2229 EmitSignalDeactivateDialog();
2230 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2234 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2235 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2239 case 4052: // RENUMBERING ELEMENTS
2241 if(checkLock(aStudy)) break;
2243 EmitSignalDeactivateDialog();
2244 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2248 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2249 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2253 case 4061: // TRANSLATION
2255 if(checkLock(aStudy)) break;
2257 EmitSignalDeactivateDialog();
2258 ( new SMESHGUI_TranslationDlg( this ) )->show();
2261 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2262 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2266 case 4062: // ROTATION
2268 if(checkLock(aStudy)) break;
2270 EmitSignalDeactivateDialog();
2271 ( new SMESHGUI_RotationDlg( this ) )->show();
2274 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2275 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2279 case 4063: // SYMMETRY
2281 if(checkLock(aStudy)) break;
2283 EmitSignalDeactivateDialog();
2284 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2287 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2288 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2292 case 4064: // SEWING
2294 if(checkLock(aStudy)) break;
2296 EmitSignalDeactivateDialog();
2297 ( new SMESHGUI_SewingDlg( this ) )->show();
2300 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2301 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2305 case 4065: // MERGE NODES
2307 if(checkLock(aStudy)) break;
2309 EmitSignalDeactivateDialog();
2310 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2313 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2314 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2318 case 4066: // MERGE EQUAL ELEMENTS
2320 if (checkLock(aStudy)) break;
2322 EmitSignalDeactivateDialog();
2323 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2325 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2326 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2331 case 4067: // MAKE MESH PASS THROUGH POINT
2332 startOperation( 4067 );
2335 case 5105: // Library of selection filters
2337 static QList<int> aTypes;
2338 if ( aTypes.isEmpty() )
2340 aTypes.append( SMESH::NODE );
2341 aTypes.append( SMESH::EDGE );
2342 aTypes.append( SMESH::FACE );
2343 aTypes.append( SMESH::VOLUME );
2345 if (!myFilterLibraryDlg)
2346 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2347 else if (myFilterLibraryDlg->isHidden())
2348 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2349 myFilterLibraryDlg->raise();
2353 case 6017: // CONTROLS
2369 LightApp_SelectionMgr* mgr = selectionMgr();
2370 SALOME_ListIO selected; mgr->selectedObjects( selected );
2372 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2373 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2375 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2376 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2377 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2378 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2379 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2380 ::Control( theCommandID );
2385 SUIT_MessageBox::warning(desktop(),
2386 tr( "SMESH_WRN_WARNING" ),
2387 tr( "SMESH_BAD_SELECTION" ) );
2391 SUIT_MessageBox::warning(desktop(),
2392 tr( "SMESH_WRN_WARNING" ),
2393 tr( "NOT_A_VTK_VIEWER" ) );
2398 LightApp_SelectionMgr* mgr = selectionMgr();
2399 SALOME_ListIO selected; mgr->selectedObjects( selected );
2401 SALOME_ListIteratorOfListIO it(selected);
2402 for( ; it.More(); it.Next()) {
2403 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2404 if(anIObject->hasEntry()) {
2405 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2406 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2414 LightApp_SelectionMgr* mgr = selectionMgr();
2415 SALOME_ListIO selected; mgr->selectedObjects( selected );
2417 if (selected.Extent() == 1) {
2418 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2419 if(anIObject->hasEntry())
2420 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2421 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2428 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2429 //updateObjBrowser();
2433 //=============================================================================
2437 //=============================================================================
2438 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2443 //=============================================================================
2447 //=============================================================================
2448 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2453 //=============================================================================
2457 //=============================================================================
2458 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2463 //=============================================================================
2464 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2465 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2467 //=============================================================================
2468 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2469 SUIT_ViewWindow* wnd )
2471 if(theIO->hasEntry()){
2472 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2473 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2477 //=======================================================================
2478 // function : createSMESHAction
2480 //=======================================================================
2481 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2484 QWidget* parent = application()->desktop();
2485 SUIT_ResourceMgr* resMgr = resourceMgr();
2487 if ( !icon_id.isEmpty() )
2488 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2490 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2491 if ( !pix.isNull() )
2492 icon = QIcon( pix );
2494 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2495 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2496 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2498 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2501 //=======================================================================
2502 // function : createPopupItem
2504 //=======================================================================
2505 void SMESHGUI::createPopupItem( const int id,
2506 const QString& clients,
2507 const QString& types,
2508 const QString& theRule,
2513 parentId = popupMgr()->actionId( action( pId ) );
2515 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2516 popupMgr()->insert( action( id ), parentId, 0 );
2518 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2519 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2520 QString rule = "(%1) and (%2) and (%3)";
2521 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2522 if( clients.isEmpty() )
2523 rule = rule.arg( QString( "true" ) );
2525 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2526 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2529 bool cont = myRules.contains( id );
2531 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2533 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2534 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2537 //=======================================================================
2538 // function : initialize
2540 //=======================================================================
2541 void SMESHGUI::initialize( CAM_Application* app )
2543 SalomeApp_Module::initialize( app );
2545 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2547 /* Automatic Update flag */
2548 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2550 // ----- create actions --------------
2552 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2553 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2554 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2555 createSMESHAction( 114, "NUM" );
2556 createSMESHAction( 121, "DAT" );
2557 createSMESHAction( 122, "MED" );
2558 createSMESHAction( 123, "UNV" );
2559 createSMESHAction( 140, "STL" );
2560 createSMESHAction( 124, "EXPORT_DAT" );
2561 createSMESHAction( 125, "EXPORT_MED" );
2562 createSMESHAction( 126, "EXPORT_UNV" );
2563 createSMESHAction( 141, "EXPORT_STL" );
2564 createSMESHAction( 150, "FILE_INFO" );
2565 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2566 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2567 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2568 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2569 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2570 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2571 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2572 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2573 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2574 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2575 createSMESHAction( 804, "ADD" );
2576 createSMESHAction( 805, "REMOVE" );
2577 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2578 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2579 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2580 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2581 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2582 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2583 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2584 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2585 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2586 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2587 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2588 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2589 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2590 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2591 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2592 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2593 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2594 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2595 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2596 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2597 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2598 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2599 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2600 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2601 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2602 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2603 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2604 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2605 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2606 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2607 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2608 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2609 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2610 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2611 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2612 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2613 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2614 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2615 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2616 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2617 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2618 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2619 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2620 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2621 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2622 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2623 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2624 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2625 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2626 createSMESHAction( 415, "MAP", "ICON_MAP" );
2627 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2628 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2629 createSMESHAction( 200, "RESET" );
2630 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2631 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2632 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2633 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2634 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2635 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2636 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2637 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2638 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2639 createSMESHAction( 220, "ALL" );
2640 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2641 createSMESHAction( 1100, "EDIT_HYPO" );
2642 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2643 createSMESHAction( 1102, "UNASSIGN" );
2644 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2645 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2646 createSMESHAction( 1131, "DISPMODE" );
2647 createSMESHAction( 1132, "COLORS" );
2648 createSMESHAction( 1133, "TRANSP" );
2649 createSMESHAction( 1134, "CLIP" );
2650 createSMESHAction( 1135, "DISP_ENT" );
2651 createSMESHAction( 1136, "AUTO_COLOR" );
2652 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2653 createSMESHAction( 2000, "CTRL" );
2655 createSMESHAction( 300, "ERASE" );
2656 createSMESHAction( 301, "DISPLAY" );
2657 createSMESHAction( 302, "DISPLAY_ONLY" );
2658 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2659 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2660 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2661 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2662 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2663 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2664 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2665 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2667 // ----- create menu --------------
2668 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2669 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2670 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2671 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2672 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2673 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2674 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2676 createMenu( separator(), fileId );
2678 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2679 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2680 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2681 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2682 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2683 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2685 createMenu( 111, importId, -1 );
2686 createMenu( 112, importId, -1 );
2687 createMenu( 113, importId, -1 );
2689 createMenu( 121, exportId, -1 );
2690 createMenu( 122, exportId, -1 );
2691 createMenu( 123, exportId, -1 );
2692 createMenu( 140, exportId, -1 ); // export to stl STL
2694 createMenu( separator(), fileId, 10 );
2696 createMenu( 33, editId, -1 );
2698 createMenu( 5105, toolsId, -1 );
2700 createMenu( 702, meshId, -1 ); // "Mesh" menu
2701 createMenu( 703, meshId, -1 );
2702 createMenu( 704, meshId, -1 );
2703 createMenu( 710, meshId, -1 );
2704 createMenu( separator(), meshId, -1 );
2705 createMenu( 701, meshId, -1 );
2706 createMenu( separator(), meshId, -1 );
2707 createMenu( 801, meshId, -1 );
2708 createMenu( 802, meshId, -1 );
2709 createMenu( 803, meshId, -1 );
2710 createMenu( separator(), meshId, -1 );
2711 createMenu( 810, meshId, -1 );
2712 createMenu( 811, meshId, -1 );
2713 createMenu( 812, meshId, -1 );
2714 createMenu( separator(), meshId, -1 );
2715 createMenu( 813, meshId, -1 );
2716 createMenu( separator(), meshId, -1 );
2717 createMenu( 900, meshId, -1 );
2718 createMenu( 902, meshId, -1 );
2719 createMenu( 903, meshId, -1 );
2720 createMenu( separator(), meshId, -1 );
2722 createMenu( 6003, ctrlId, -1 );
2723 createMenu( 6001, ctrlId, -1 );
2724 createMenu( 6004, ctrlId, -1 );
2725 createMenu( separator(), ctrlId, -1 );
2726 createMenu( 6002, ctrlId, -1 );
2727 createMenu( 6018, ctrlId, -1 );
2728 createMenu( 6019, ctrlId, -1 );
2729 createMenu( 6011, ctrlId, -1 );
2730 createMenu( 6012, ctrlId, -1 );
2731 createMenu( 6013, ctrlId, -1 );
2732 createMenu( 6014, ctrlId, -1 );
2733 createMenu( 6015, ctrlId, -1 );
2734 createMenu( 6016, ctrlId, -1 );
2735 createMenu( separator(), ctrlId, -1 );
2736 createMenu( 6017, ctrlId, -1 );
2737 createMenu( 6009, ctrlId, -1 );
2738 createMenu( separator(), ctrlId, -1 );
2740 createMenu( 400, addId, -1 );
2741 createMenu( 401, addId, -1 );
2742 createMenu( 4021, addId, -1 );
2743 createMenu( 4022, addId, -1 );
2744 createMenu( 4023, addId, -1 );
2745 createMenu( 4031, addId, -1 );
2746 createMenu( 4032, addId, -1 );
2747 createMenu( 4033, addId, -1 );
2748 createMenu( separator(), addId, -1 );
2749 createMenu( 4034, addId, -1 );
2750 createMenu( 4035, addId, -1 );
2751 createMenu( 4036, addId, -1 );
2752 createMenu( 4037, addId, -1 );
2753 createMenu( 4038, addId, -1 );
2754 createMenu( 4039, addId, -1 );
2755 createMenu( 4040, addId, -1 );
2757 createMenu( 4041, removeId, -1 );
2758 createMenu( 4042, removeId, -1 );
2759 createMenu( 4043, removeId, -1 );
2761 createMenu( 4051, renumId, -1 );
2762 createMenu( 4052, renumId, -1 );
2764 createMenu( 4061, transfId, -1 );
2765 createMenu( 4062, transfId, -1 );
2766 createMenu( 4063, transfId, -1 );
2767 createMenu( 4064, transfId, -1 );
2768 createMenu( 4065, transfId, -1 );
2769 createMenu( 4066, transfId, -1 );
2771 createMenu( 406, modifyId, -1 );
2772 createMenu( 4067,modifyId, -1 );
2773 createMenu( 407, modifyId, -1 );
2774 createMenu( 408, modifyId, -1 );
2775 createMenu( 409, modifyId, -1 );
2776 createMenu( 410, modifyId, -1 );
2777 createMenu( 411, modifyId, -1 );
2778 createMenu( 412, modifyId, -1 );
2779 createMenu( 413, modifyId, -1 );
2780 createMenu( 416, modifyId, -1 );
2781 createMenu( 414, modifyId, -1 );
2782 createMenu( 415, modifyId, -1 );
2783 createMenu( 417, modifyId, -1 );
2785 createMenu( 214, viewId, -1 );
2787 // ----- create toolbars --------------
2788 int meshTb = createTool( tr( "TB_MESH" ) ),
2789 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2790 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2791 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2792 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2794 createTool( 702, meshTb );
2795 createTool( 703, meshTb );
2796 createTool( 704, meshTb );
2797 createTool( 710, meshTb );
2798 createTool( separator(), meshTb );
2799 createTool( 701, meshTb );
2800 createTool( separator(), meshTb );
2801 createTool( 801, meshTb );
2802 createTool( 802, meshTb );
2803 createTool( 803, meshTb );
2804 createTool( separator(), meshTb );
2805 createTool( 900, meshTb );
2806 createTool( 902, meshTb );
2807 createTool( 903, meshTb );
2808 createTool( separator(), meshTb );
2810 createTool( 6001, ctrlTb );
2811 createTool( 6003, ctrlTb );
2812 createTool( 6004, ctrlTb );
2813 createTool( separator(), ctrlTb );
2814 createTool( 6002, ctrlTb );
2815 createTool( 6018, ctrlTb );
2816 createTool( 6019, ctrlTb );
2817 createTool( 6011, ctrlTb );
2818 createTool( 6012, ctrlTb );
2819 createTool( 6013, ctrlTb );
2820 createTool( 6014, ctrlTb );
2821 createTool( 6015, ctrlTb );
2822 createTool( 6016, ctrlTb );
2823 createTool( separator(), ctrlTb );
2824 createTool( 6017, ctrlTb );
2825 createTool( 6009, ctrlTb );
2826 createTool( separator(), ctrlTb );
2828 createTool( 400, addRemTb );
2829 createTool( 401, addRemTb );
2830 createTool( 4021, addRemTb );
2831 createTool( 4022, addRemTb );
2832 createTool( 4023, addRemTb );
2833 createTool( 4031, addRemTb );
2834 createTool( 4032, addRemTb );
2835 createTool( 4033, addRemTb );
2836 createTool( separator(), addRemTb );
2837 createTool( 4034, addRemTb );
2838 createTool( 4035, addRemTb );
2839 createTool( 4036, addRemTb );
2840 createTool( 4037, addRemTb );
2841 createTool( 4038, addRemTb );
2842 createTool( 4039, addRemTb );
2843 createTool( 4040, addRemTb );
2844 createTool( separator(), addRemTb );
2845 createTool( 4041, addRemTb );
2846 createTool( 4042, addRemTb );
2847 createTool( 4043, addRemTb );
2848 createTool( separator(), addRemTb );
2849 createTool( 4051, addRemTb );
2850 createTool( 4052, addRemTb );
2851 createTool( separator(), addRemTb );
2852 createTool( 4061, addRemTb );
2853 createTool( 4062, addRemTb );
2854 createTool( 4063, addRemTb );
2855 createTool( 4064, addRemTb );
2856 createTool( 4065, addRemTb );
2857 createTool( 4066, addRemTb );
2858 createTool( separator(), addRemTb );
2860 createTool( 406, modifyTb );
2861 createTool( 4067,modifyTb );
2862 createTool( 407, modifyTb );
2863 createTool( 408, modifyTb );
2864 createTool( 409, modifyTb );
2865 createTool( 410, modifyTb );
2866 createTool( 411, modifyTb );
2867 createTool( 412, modifyTb );
2868 createTool( 413, modifyTb );
2869 createTool( 416, modifyTb );
2870 createTool( 414, modifyTb );
2871 createTool( 415, modifyTb );
2872 createTool( 417, modifyTb );
2874 createTool( 214, dispModeTb );
2876 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2877 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
2880 QString OB = "'ObjectBrowser'",
2881 View = "'" + SVTK_Viewer::Type() + "'",
2883 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2884 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2885 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2886 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2887 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2888 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2889 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2890 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2891 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2892 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2893 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2895 mesh_group = mesh + " " + subMesh + " " + group,
2896 hyp_alg = hypo + " " + algo;
2898 // popup for object browser
2900 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2901 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2902 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2903 createPopupItem( 803, OB, group ); // EDIT_GROUP
2904 popupMgr()->insert( separator(), -1, 0 );
2905 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2906 createPopupItem( 214, OB, mesh_group ); // UPDATE
2907 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2908 createPopupItem( 902, OB, mesh ); // STD_INFO
2909 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2910 popupMgr()->insert( separator(), -1, 0 );
2911 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2912 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2913 popupMgr()->insert( separator(), -1, 0 );
2914 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2915 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2916 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2917 popupMgr()->insert( separator(), -1, 0 );
2918 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2919 popupMgr()->insert( separator(), -1, 0 );
2921 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2923 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2924 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2925 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2926 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2927 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2928 popupMgr()->insert( separator(), -1, 0 );
2931 createPopupItem( 803, View, group ); // EDIT_GROUP
2932 createPopupItem( 804, View, elems ); // ADD
2933 createPopupItem( 805, View, elems ); // REMOVE
2934 popupMgr()->insert( separator(), -1, 0 );
2935 createPopupItem( 214, View, mesh_group ); // UPDATE
2936 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2937 createPopupItem( 902, View, mesh ); // STD_INFO
2938 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2939 popupMgr()->insert( separator(), -1, 0 );
2941 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2942 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2943 popupMgr()->insert( separator(), -1, 0 );
2947 isInvisible("not( isVisible )"),
2948 isEmpty("numberOfNodes = 0"),
2949 isNotEmpty("numberOfNodes <> 0"),
2951 // has nodes, edges, etc in VISIBLE! actor
2952 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2953 hasElems("(count( elemTypes ) > 0)"),
2954 hasDifferentElems("(count( elemTypes ) > 1)"),
2955 hasEdges("({'Edge'} in elemTypes)"),
2956 hasFaces("({'Face'} in elemTypes)"),
2957 hasVolumes("({'Volume'} in elemTypes)");
2959 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2960 QString aType = QString( "%1type in {%2}" ).arg( lc );
2961 aType = aType.arg( mesh_group );
2962 QString aMeshInVTK = aClient + "&&" + aType;
2964 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2965 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2966 QString aSelCount = QString( "%1 > 0" ).arg( dc );
2968 //-------------------------------------------------
2970 //-------------------------------------------------
2971 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2973 popupMgr()->insert( action( 9010 ), anId, -1 );
2974 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
2975 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
2977 popupMgr()->insert( action( 9011 ), anId, -1 );
2978 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
2979 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
2981 popupMgr()->insert( separator(), -1, -1 );
2983 //-------------------------------------------------
2985 //-------------------------------------------------
2986 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2988 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2989 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
2990 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
2992 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2993 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
2994 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
2996 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2997 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
2998 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3000 popupMgr()->insert( separator(), anId, -1 );
3002 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3003 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3004 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3006 //-------------------------------------------------
3008 //-------------------------------------------------
3009 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3011 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3013 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3014 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3015 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3017 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3018 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3019 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3021 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3022 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3023 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3025 popupMgr()->insert( separator(), anId, -1 );
3027 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3028 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3030 //-------------------------------------------------
3031 // Orientation of faces
3032 //-------------------------------------------------
3033 popupMgr()->insert( action( 221 ), -1, -1 );
3034 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3035 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3037 //-------------------------------------------------
3039 //-------------------------------------------------
3040 popupMgr()->insert( action( 1132 ), -1, -1 );
3041 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3043 //-------------------------------------------------
3045 //-------------------------------------------------
3046 popupMgr()->insert( action( 1133 ), -1, -1 );
3047 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3049 //-------------------------------------------------
3051 //-------------------------------------------------
3052 popupMgr()->insert( action( 1134 ), -1, -1 );
3053 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3055 popupMgr()->insert( separator(), -1, -1 );
3057 //-------------------------------------------------
3059 //-------------------------------------------------
3061 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3062 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3063 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3065 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3067 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3068 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3070 popupMgr()->insert( separator(), anId, -1 );
3072 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3073 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3074 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3076 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3077 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3078 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3080 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3081 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3082 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3084 popupMgr()->insert( separator(), anId, -1 );
3086 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3087 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3088 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3090 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3091 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3092 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3094 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3095 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3096 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3098 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3099 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3100 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3102 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3103 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3104 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3106 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3107 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3108 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3110 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3111 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3112 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3114 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3115 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3116 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3118 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3119 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3120 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3122 popupMgr()->insert( separator(), anId, -1 );
3124 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3125 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3126 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3128 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3129 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3130 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3132 popupMgr()->insert( separator(), anId, -1 );
3134 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3135 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3137 popupMgr()->insert( separator(), -1, -1 );
3139 //-------------------------------------------------
3141 //-------------------------------------------------
3142 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3143 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3144 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3145 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3147 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3148 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3150 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3151 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3153 popupMgr()->insert( separator(), -1, -1 );
3155 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3156 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3159 //================================================================================
3161 * \brief Return true if SMESH or GEOM objects are selected.
3162 * Is called form LightApp_Module::activateModule() which clear selection if
3163 * not isSelectionCompatible()
3165 //================================================================================
3167 bool SMESHGUI::isSelectionCompatible()
3169 bool isCompatible = true;
3170 SALOME_ListIO selected;
3171 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3172 Sel->selectedObjects( selected );
3174 SALOME_ListIteratorOfListIO It( selected );
3175 for ( ; isCompatible && It.More(); It.Next())
3177 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3178 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3180 return isCompatible;
3183 bool SMESHGUI::activateModule( SUIT_Study* study )
3185 bool res = SalomeApp_Module::activateModule( study );
3187 setMenuShown( true );
3188 setToolShown( true );
3190 // Reset actions accelerator keys
3191 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3192 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3193 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3195 action( 33)->setEnabled(true); // Delete: Key_Delete
3196 action(1101)->setEnabled(true); // Rename: Key_F2
3201 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3203 setMenuShown( false );
3204 setToolShown( false );
3206 EmitSignalCloseAllDialogs();
3208 // Unset actions accelerator keys
3209 action(111)->setShortcut(QKeySequence()); // Import DAT
3210 action(112)->setShortcut(QKeySequence()); // Import UNV
3211 action(113)->setShortcut(QKeySequence()); // Import MED
3213 action( 33)->setEnabled(false); // Delete: Key_Delete
3214 action(1101)->setEnabled(false); // Rename: Key_F2
3216 return SalomeApp_Module::deactivateModule( study );
3219 void SMESHGUI::studyClosed( SUIT_Study* s )
3221 SMESH::RemoveVisuData( s->id() );
3222 SalomeApp_Module::studyClosed( s );
3225 void SMESHGUI::OnGUIEvent()
3227 const QObject* obj = sender();
3228 if ( !obj || !obj->inherits( "QAction" ) )
3230 int id = actionId((QAction*)obj);
3235 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3237 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3238 if ( CORBA::is_nil( myComponentSMESH ) )
3240 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3242 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3243 return aGUI.myComponentSMESH;
3246 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3247 return myComponentSMESH;
3250 QString SMESHGUI::engineIOR() const
3252 CORBA::ORB_var anORB = getApp()->orb();
3253 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3254 return QString( anIOR.in() );
3257 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3259 SalomeApp_Module::contextMenuPopup( client, menu, title );
3261 selectionMgr()->selectedObjects( lst );
3262 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3263 Handle(SALOME_InteractiveObject) io = lst.First();
3264 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3265 _PTR(Study) study = appStudy->studyDS();
3266 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3268 QString aName = QString( obj->GetName().c_str() );
3269 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3270 aName.remove( (aName.length() - 1), 1 );
3276 LightApp_Selection* SMESHGUI::createSelection() const
3278 return new SMESHGUI_Selection();
3281 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3283 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3284 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3287 void SMESHGUI::viewManagers( QStringList& list ) const
3289 list.append( SVTK_Viewer::Type() );
3292 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3294 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3295 SMESH::UpdateSelectionProp( this );
3298 void SMESHGUI::createPreferences()
3300 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3302 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3303 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3305 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3306 setPreferenceProperty( qaGroup, "columns", 2 );
3307 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3308 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3310 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3311 setPreferenceProperty( precGroup, "columns", 2 );
3313 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3315 setPreferenceProperty( prec, "min", 0 );
3316 setPreferenceProperty( prec, "max", 16 );
3318 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3319 setPreferenceProperty( dispgroup, "columns", 2 );
3320 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3322 modes.append( "Wireframe" );
3323 modes.append( "Shading" );
3324 modes.append( "Nodes" );
3325 modes.append( "Shrink" );
3326 QList<QVariant> indices;
3327 indices.append( 0 );
3328 indices.append( 1 );
3329 indices.append( 2 );
3330 indices.append( 3 );
3331 setPreferenceProperty( dispmode, "strings", modes );
3332 setPreferenceProperty( dispmode, "indexes", indices );
3334 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3335 setPreferenceProperty( exportgroup, "columns", 2 );
3336 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3337 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3339 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3340 setPreferenceProperty( computeGroup, "columns", 2 );
3341 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3343 modes.append( "Never" );
3344 modes.append( "Errors only" );
3345 modes.append( "Always" );
3347 indices.append( 0 );
3348 indices.append( 1 );
3349 indices.append( 2 );
3350 setPreferenceProperty( notifyMode, "strings", modes );
3351 setPreferenceProperty( notifyMode, "indexes", indices );
3353 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3354 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3355 setPreferenceProperty( nodeGroup, "columns", 2 );
3357 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3358 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3360 setPreferenceProperty( nodeSz, "min", 1 );
3361 setPreferenceProperty( nodeSz, "max", 5 );
3363 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3364 setPreferenceProperty( elemGroup, "columns", 2 );
3366 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3367 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3368 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3369 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3371 setPreferenceProperty( sp, "hstretch", 0 );
3372 setPreferenceProperty( sp, "vstretch", 0 );
3374 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3375 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3377 setPreferenceProperty( elemW, "min", 1 );
3378 setPreferenceProperty( elemW, "max", 5 );
3380 setPreferenceProperty( shrink, "min", 0 );
3381 setPreferenceProperty( shrink, "max", 100 );
3383 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3384 setPreferenceProperty( orientGroup, "columns", 1 );
3386 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3387 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3389 setPreferenceProperty( orientScale, "min", 0 );
3390 setPreferenceProperty( orientScale, "max", 1 );
3391 setPreferenceProperty( orientScale, "step", 0.1 );
3393 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3395 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3397 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3398 setPreferenceProperty( selGroup, "columns", 2 );
3400 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3401 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3402 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3404 setPreferenceProperty( selW, "min", 1 );
3405 setPreferenceProperty( selW, "max", 5 );
3407 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3408 setPreferenceProperty( preGroup, "columns", 2 );
3410 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3411 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3413 setPreferenceProperty( preW, "min", 1 );
3414 setPreferenceProperty( preW, "max", 5 );
3416 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3417 setPreferenceProperty( precSelGroup, "columns", 2 );
3419 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3420 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3421 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3423 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3424 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3425 setPreferenceProperty( fontGr, "columns", 2 );
3427 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3428 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3429 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3430 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3433 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3434 fam.append( tr( "SMESH_FONT_COURIER" ) );
3435 fam.append( tr( "SMESH_FONT_TIMES" ) );
3436 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3438 setPreferenceProperty( tfont, "families", fam );
3439 setPreferenceProperty( tfont, "system", false );
3440 setPreferenceProperty( tfont, "widget_flags", wflag );
3441 setPreferenceProperty( lfont, "families", fam );
3442 setPreferenceProperty( lfont, "system", false );
3443 setPreferenceProperty( lfont, "widget_flags", wflag );
3445 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3446 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3448 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3449 setPreferenceProperty( numcol, "min", 2 );
3450 setPreferenceProperty( numcol, "max", 256 );
3452 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3453 setPreferenceProperty( numlab, "min", 2 );
3454 setPreferenceProperty( numlab, "max", 65 );
3456 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3457 setPreferenceProperty( orientGr, "columns", 2 );
3458 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3459 QStringList orients;
3460 orients.append( tr( "SMESH_VERTICAL" ) );
3461 orients.append( tr( "SMESH_HORIZONTAL" ) );
3462 indices.clear(); indices.append( 0 ); indices.append( 1 );
3463 setPreferenceProperty( orient, "strings", orients );
3464 setPreferenceProperty( orient, "indexes", indices );
3466 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3467 setPreferenceProperty( posVSizeGr, "columns", 2 );
3468 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3469 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3470 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3471 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3472 setPreferenceProperty( xv, "step", 0.1 );
3473 setPreferenceProperty( xv, "min", 0.0 );
3474 setPreferenceProperty( xv, "max", 1.0 );
3475 setPreferenceProperty( yv, "step", 0.1 );
3476 setPreferenceProperty( yv, "min", 0.0 );
3477 setPreferenceProperty( yv, "max", 1.0 );
3478 setPreferenceProperty( wv, "step", 0.1 );
3479 setPreferenceProperty( wv, "min", 0.0 );
3480 setPreferenceProperty( wv, "max", 1.0 );
3481 setPreferenceProperty( hv, "min", 0.0 );
3482 setPreferenceProperty( hv, "max", 1.0 );
3483 setPreferenceProperty( hv, "step", 0.1 );
3485 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3486 setPreferenceProperty( posHSizeGr, "columns", 2 );
3487 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3488 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3489 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3490 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3491 setPreferenceProperty( xv, "min", 0.0 );
3492 setPreferenceProperty( xv, "max", 1.0 );
3493 setPreferenceProperty( xv, "step", 0.1 );
3494 setPreferenceProperty( xh, "min", 0.0 );
3495 setPreferenceProperty( xh, "max", 1.0 );
3496 setPreferenceProperty( xh, "step", 0.1 );
3497 setPreferenceProperty( yh, "min", 0.0 );
3498 setPreferenceProperty( yh, "max", 1.0 );
3499 setPreferenceProperty( yh, "step", 0.1 );
3500 setPreferenceProperty( wh, "min", 0.0 );
3501 setPreferenceProperty( wh, "max", 1.0 );
3502 setPreferenceProperty( wh, "step", 0.1 );
3503 setPreferenceProperty( hh, "min", 0.0 );
3504 setPreferenceProperty( hh, "max", 1.0 );
3505 setPreferenceProperty( hh, "step", 0.1 );
3508 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3510 if( sect=="SMESH" ){
3511 float sbX1,sbY1,sbW,sbH;
3512 float aTol = 1.00000009999999;
3513 std::string aWarning;
3514 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3515 if( name=="selection_object_color" || name=="selection_element_color" ||
3516 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3517 name=="selection_precision_node" || name=="selection_precision_element" ||
3518 name=="selection_precision_object")
3519 SMESH::UpdateSelectionProp( this );
3520 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3521 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3522 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3523 if(sbX1+sbW > aTol){
3524 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3527 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3528 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3531 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3532 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3533 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3534 if(sbY1+sbH > aTol){
3535 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3536 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3537 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3540 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3541 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3542 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3543 if(sbX1+sbW > aTol){
3544 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3547 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3548 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3551 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3552 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3553 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3554 if(sbY1+sbH > aTol){
3555 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3558 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3559 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3563 if(aWarning.size() != 0){
3564 aWarning += "The default values are applied instead.";
3565 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3566 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3567 QObject::tr(aWarning.c_str()));
3572 //================================================================================
3574 * \brief Update something in accordance with update flags
3575 * \param theFlags - update flags
3577 * Update viewer or/and object browser etc. in accordance with update flags ( see
3578 * LightApp_UpdateFlags enumeration ).
3580 //================================================================================
3581 void SMESHGUI::update( const int flags )
3583 if ( flags & UF_Viewer | flags & UF_Forced )
3584 SMESH::UpdateView();
3586 SalomeApp_Module::update( flags );
3589 //================================================================================
3591 * \brief Set default selection mode
3593 * SLOT called when operation commited. Sets default selection mode
3595 //================================================================================
3596 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3598 SVTK_ViewWindow* vtkWnd =
3599 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3601 vtkWnd->SetSelectionMode( ActorSelection );
3604 //================================================================================
3606 * \brief Set default selection mode
3608 * SLOT called when operation aborted. Sets default selection mode
3610 //================================================================================
3611 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3613 SVTK_ViewWindow* vtkWnd =
3614 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3616 vtkWnd->SetSelectionMode( ActorSelection );
3619 //================================================================================
3621 * \brief Creates operation with given identifier
3622 * \param id - identifier of operation to be started
3623 * \return Pointer on created operation or NULL if operation is not created
3625 * Virtual method redefined from the base class creates operation with given id.
3626 * It is called called automatically from startOperation method of base class.
3628 //================================================================================
3629 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3631 LightApp_Operation* op = 0;
3632 // to do : create operation here
3635 case 701: // Compute mesh
3636 op = new SMESHGUI_ComputeOp();
3638 case 702: // Create mesh
3639 op = new SMESHGUI_MeshOp( true, true );
3641 case 703: // Create sub-mesh
3642 op = new SMESHGUI_MeshOp( true, false );
3644 case 704: // Edit mesh/sub-mesh
3645 op = new SMESHGUI_MeshOp( false );
3647 case 417: //convert to quadratic
3648 op = new SMESHGUI_ConvToQuadOp();
3650 case 4067: // make mesh pass through point
3651 op = new SMESHGUI_MakeNodeAtPointOp();
3658 op = SalomeApp_Module::createOperation( id );
3662 //================================================================================
3664 * \brief Stops current operations and starts a given one
3665 * \param id - The id of the operation to start
3667 //================================================================================
3669 void SMESHGUI::switchToOperation(int id)
3671 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3672 activeStudy()->abortAllOperations();
3673 startOperation( id );
3676 LightApp_Displayer* SMESHGUI::displayer()
3679 myDisplayer = new SMESHGUI_Displayer( getApp() );
3683 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3686 int aTolerance = 64;
3687 int anIterations = 0;
3693 if( anIterations % aPeriod == 0 )
3696 if( aTolerance < 1 )
3699 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3701 aHue = (int)( 360.0 * rand() / RAND_MAX );
3702 //cout << "Hue = " << aHue << endl;
3704 //cout << "Auto colors : ";
3706 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3707 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3708 for( ; it != itEnd; ++it )
3710 SALOMEDS::Color anAutoColor = *it;
3711 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3714 aQColor.getHsv( &h, &s, &v );
3716 if( abs( h - aHue ) < aTolerance )
3719 //cout << "break (diff = " << abs( h - aHue ) << ")";
3729 //cout << "Hue of the returned color = " << aHue << endl;
3731 aColor.setHsv( aHue, 255, 255 );
3733 SALOMEDS::Color aSColor;
3734 aSColor.R = (double)aColor.red() / 255.0;
3735 aSColor.G = (double)aColor.green() / 255.0;
3736 aSColor.B = (double)aColor.blue() / 255.0;