1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // 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_GroupOnShapeDlg.h"
49 #include "SMESHGUI_DeleteGroupDlg.h"
50 #include "SMESHGUI_SmoothingDlg.h"
51 #include "SMESHGUI_RenumberingDlg.h"
52 #include "SMESHGUI_ExtrusionDlg.h"
53 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
54 #include "SMESHGUI_RevolutionDlg.h"
55 #include "SMESHGUI_TranslationDlg.h"
56 #include "SMESHGUI_RotationDlg.h"
57 #include "SMESHGUI_SymmetryDlg.h"
58 #include "SMESHGUI_SewingDlg.h"
59 #include "SMESHGUI_EditMeshDlg.h"
60 #include "SMESHGUI_MeshPatternDlg.h"
61 #include "SMESHGUI_Selection.h"
62 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
63 #include "SMESHGUI_ConvToQuadOp.h"
64 #include "SMESHGUI_MeshOp.h"
65 #include "SMESHGUI_Displayer.h"
66 #include "SMESHGUI_MakeNodeAtPointDlg.h"
67 #include "SMESHGUI_BuildCompoundDlg.h"
68 #include "SMESHGUI_ComputeDlg.h"
69 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Make2DFrom3DOp.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include <SMESH_Client.hxx>
81 #include <SMESH_Actor.h>
82 #include <SMESH_TypeFilter.hxx>
84 // SALOME GUI includes
85 #include <SalomeApp_Tools.h>
86 #include <SalomeApp_Study.h>
87 #include <SalomeApp_Application.h>
88 #include <SalomeApp_CheckFileDlg.h>
90 #include <LightApp_DataOwner.h>
91 #include <LightApp_Preferences.h>
92 #include <LightApp_SelectionMgr.h>
93 #include <LightApp_UpdateFlags.h>
94 #include <LightApp_NameDlg.h>
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_ViewManager.h>
100 #include <VTKViewer_Algorithm.h>
102 #include <SUIT_MessageBox.h>
103 #include <SUIT_ResourceMgr.h>
104 #include <SUIT_FileDlg.h>
105 #include <SUIT_Desktop.h>
106 #include <SUIT_OverrideCursor.h>
107 #include <SUIT_Session.h>
109 #include <QtxPopupMgr.h>
110 #include <QtxFontEdit.h>
112 #include <SALOME_ListIO.hxx>
113 #include <SALOME_ListIteratorOfListIO.hxx>
116 #include <SALOMEconfig.h>
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
118 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
121 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
125 #include <boost/shared_ptr.hpp>
128 #include <vtkScalarBarActor.h>
129 #include <vtkCamera.h>
130 #include <vtkRenderer.h>
131 #include <vtkPlane.h>
133 // SALOME KERNEL includes
134 #include <SALOMEDS_Study.hxx>
135 #include <SALOMEDSClient_StudyBuilder.hxx>
136 #include <SALOMEDSClient_SComponent.hxx>
137 #include <SALOMEDSClient_ClientFactory.hxx>
138 #include <SALOMEDSClient_IParameters.hxx>
141 #include <Standard_ErrorHandler.hxx>
142 #include <NCollection_DataMap.hxx>
146 //=============================================================
147 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
150 void ExportMeshToFile(int theCommandID);
152 void SetDisplayMode(int theCommandID);
154 void SetDisplayEntity(int theCommandID);
156 void Control( int theCommandID );
160 //=============================================================
161 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
165 std::string myExtension;
167 if ( theCommandID == 113 ) {
168 filter.append( QObject::tr( "MED files (*.med)" ) );
169 filter.append( QObject::tr( "All files (*)" ) );
171 else if ( theCommandID == 112 ) {
172 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
174 else if ( theCommandID == 111 ) {
175 filter.append( QObject::tr( "DAT files (*.dat)" ) );
177 else if ( theCommandID == 115 ) {
178 filter.append( QObject::tr( "SAUV files (*.sauv *.sauve)" ) );
179 filter.append( QObject::tr( "All files (*)" ) );
182 QString anInitialPath = "";
183 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
184 anInitialPath = QDir::currentPath();
186 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
189 QObject::tr( "SMESH_IMPORT_MESH" ) );
190 if ( filenames.count() > 0 ) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 bool isEmpty = false;
196 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
197 QString filename = *it;
198 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
200 switch ( theCommandID ) {
203 // DAT format (currently unsupported)
204 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
205 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
211 aMeshes->length( 1 );
212 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
213 if ( aMeshes[0]->_is_nil() )
214 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
215 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
221 SMESH::DriverMED_ReadStatus res;
222 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
223 if ( res != SMESH::DRS_OK ) {
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
231 catch ( const SALOME::SALOME_Exception& S_ex ) {
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
236 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
237 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
239 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
240 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
241 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
242 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
243 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
251 // update Object browser
252 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
254 // show Error message box if there were errors
255 if ( errors.count() > 0 ) {
256 SUIT_MessageBox::critical( SMESHGUI::desktop(),
257 QObject::tr( "SMESH_ERROR" ),
258 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
261 // show warning message box, if some imported mesh is empty
263 SUIT_MessageBox::warning( SMESHGUI::desktop(),
264 QObject::tr( "SMESH_WRN_WARNING" ),
265 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
270 void ExportMeshToFile( int theCommandID )
272 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
273 SALOME_ListIO selected;
275 aSel->selectedObjects( selected );
277 SMESH::SMESH_Mesh_var aMesh;
278 if(selected.Extent() == 1)
279 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
280 if ( aMesh->_is_nil() ) {
281 SUIT_MessageBox::warning( SMESHGUI::desktop(),
282 QObject::tr( "SMESH_WRN_WARNING" ),
283 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
287 Handle(SALOME_InteractiveObject) anIObject = selected.First();
288 QString aFilter, aTitle = QObject::tr("Export mesh");
289 QMap<QString, SMESH::MED_VERSION> aFilterMap;
290 QMap<QString, int> aFilterMapSTL;
291 switch ( theCommandID ) {
297 if (aMesh->HasDuplicatedGroupNamesMED()) {
298 int aRet = SUIT_MessageBox::warning
299 (SMESHGUI::desktop(),
300 QObject::tr("SMESH_WRN_WARNING"),
301 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
302 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
303 if (aRet != SUIT_MessageBox::Yes)
306 switch ( theCommandID ) {
311 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
312 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
313 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
314 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
320 aFilterMap.insert("SAUV files (*.sauv *.sauve)", SMESH::MED_V2_2 );
321 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
329 aFilter = QObject::tr("DAT files (*.dat)");
334 if (aMesh->NbPyramids()) {
335 int aRet = SUIT_MessageBox::warning
336 (SMESHGUI::desktop(),
337 QObject::tr("SMESH_WRN_WARNING"),
338 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
339 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
340 if (aRet != SUIT_MessageBox::Yes)
343 aFilter = QObject::tr("IDEAS files (*.unv)");
351 there must be check on others mesh elements not equal triangles
353 if (aMesh->NbTriangles() < 1) {
354 SUIT_MessageBox::warning
355 (SMESHGUI::desktop(),
356 QObject::tr("SMESH_WRN_WARNING"),
357 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
360 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
361 int aRet = SUIT_MessageBox::warning
362 (SMESHGUI::desktop(),
363 QObject::tr("SMESH_WRN_WARNING"),
364 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
365 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
366 if (aRet != SUIT_MessageBox::Yes)
370 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
371 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
379 SMESH::MED_VERSION aFormat;
380 // Init the parameter with the default value
381 bool aIsASCII_STL = true;
382 bool toCreateGroups = false;
383 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
385 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
387 QString anInitialPath = "";
388 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
389 anInitialPath = QDir::currentPath();
391 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141 && theCommandID != 142 && theCommandID != 143) {
392 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
393 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
394 aFilter, aTitle, false);
396 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
398 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
399 for ( ; it != aFilterMapSTL.end(); ++it )
400 filters.push_back( it.key() );
402 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
403 fd->setWindowTitle( aTitle );
404 fd->setFilters( filters );
405 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
406 if ( !anInitialPath.isEmpty() )
407 fd->setDirectory( anInitialPath );
408 fd->selectFile(anIObject->getName());
412 aFilename = fd->selectedFile();
413 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
418 else { // Export to MED
420 QString aDefaultFilter;
421 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
422 for ( ; it != aFilterMap.end(); ++it ) {
423 filters.push_back( it.key() );
424 if (it.value() == SMESH::MED_V2_2)
425 aDefaultFilter = it.key();
428 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
429 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
430 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
431 fd->setWindowTitle( aTitle );
432 fd->setFilters( filters );
433 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
434 fd->selectFilter(aDefaultFilter);
435 fd->SetChecked(toCreateGroups);
436 if ( !anInitialPath.isEmpty() )
437 fd->setDirectory( anInitialPath );
438 fd->selectFile(anIObject->getName());
442 aFilename = fd->selectedFile();
443 aFormat = aFilterMap[fd->selectedFilter()];
445 if ( !aFilename.isEmpty()
446 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
447 && aFormat==SMESH::MED_V2_1) {
448 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
449 QObject::tr("SMESH_WRN_WARNING"),
450 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
451 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
452 if (aRet != SUIT_MessageBox::Yes) {
457 toCreateGroups = fd->IsChecked();
460 if ( !aFilename.isEmpty() ) {
461 // Check whether the file already exists and delete it if yes
462 QFile aFile( aFilename );
463 if ( aFile.exists() )
465 SUIT_OverrideCursor wc;
468 bool Renumber = false;
469 // PAL 14172 : Check of we have to renumber or not from the preferences before export
471 Renumber= resMgr->booleanValue("SMESH","renumbering");
473 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
474 aMeshEditor->RenumberNodes();
475 aMeshEditor->RenumberElements();
476 if ( SMESHGUI::automaticUpdate() )
479 switch ( theCommandID ) {
482 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
487 std::string file_out = aFilename.toLatin1().data();
488 std::string file_tmp = file_out + "_tmp.med";
490 aMesh->ExportToMED( file_tmp.c_str(), toCreateGroups, aFormat );
492 cmd = "%PYTHONBIN% ";
497 cmd += "from medutilities import convert ; convert(r'" + file_tmp + "', 'MED', 'GIBI', 1, r'" + file_out + "')";
499 cmd += "from medutilities import my_remove ; my_remove(r'" + file_tmp + "')";
506 aMesh->ExportDAT( aFilename.toLatin1().data() );
510 aMesh->ExportUNV( aFilename.toLatin1().data() );
514 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
520 catch (const SALOME::SALOME_Exception& S_ex){
522 SUIT_MessageBox::warning(SMESHGUI::desktop(),
523 QObject::tr("SMESH_WRN_WARNING"),
524 QObject::tr("SMESH_EXPORT_FAILED"));
530 inline void InverseEntityMode(unsigned int& theOutputMode,
531 unsigned int theMode)
533 bool anIsNotPresent = ~theOutputMode & theMode;
535 theOutputMode |= theMode;
537 theOutputMode &= ~theMode;
540 void SetDisplayEntity(int theCommandID){
541 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
542 SALOME_ListIO selected;
544 aSel->selectedObjects( selected );
546 if(selected.Extent() >= 1){
547 SALOME_ListIteratorOfListIO It( selected );
548 for( ; It.More(); It.Next()){
549 Handle(SALOME_InteractiveObject) IObject = It.Value();
550 if(IObject->hasEntry()){
551 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
552 unsigned int aMode = anActor->GetEntityMode();
553 switch(theCommandID){
555 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
558 InverseEntityMode(aMode,SMESH_Actor::eEdges);
561 InverseEntityMode(aMode,SMESH_Actor::eFaces);
564 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
567 aMode = SMESH_Actor::eAllEntity;
571 anActor->SetEntityMode(aMode);
579 SALOME_ListIO selected;
580 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
584 LightApp_SelectionMgr* aSel = app->selectionMgr();
585 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
586 if( !aSel || !appStudy )
589 aSel->selectedObjects( selected );
590 if( selected.IsEmpty() )
593 Handle(SALOME_InteractiveObject) anIObject = selected.First();
595 _PTR(Study) aStudy = appStudy->studyDS();
596 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
597 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
598 if( aMainObject->_is_nil() )
601 aMainObject->SetAutoColor( true );
603 QList<SALOMEDS::Color> aReservedColors;
605 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
606 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
608 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
609 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
611 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
612 aGroupObject->SetColor( aColor );
613 aReservedColors.append( aColor );
615 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
616 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
618 if( aGroupObject->GetType() == SMESH::NODE )
619 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
620 else if( aGroupObject->GetType() == SMESH::EDGE )
621 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
623 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
627 SMESH::RepaintCurrentView();
630 void DisableAutoColor(){
631 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
632 SALOME_ListIO selected;
634 aSel->selectedObjects( selected );
636 if(selected.Extent()){
637 Handle(SALOME_InteractiveObject) anIObject = selected.First();
638 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
639 if ( !aMesh->_is_nil() ) {
640 aMesh->SetAutoColor( false );
645 void SetDisplayMode(int theCommandID){
646 SALOME_ListIO selected;
647 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
651 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
652 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
653 if( !aSel || !appStudy )
656 _PTR(Study) aStudy = appStudy->studyDS();
658 aSel->selectedObjects( selected );
660 if(selected.Extent() >= 1){
661 switch(theCommandID){
663 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
664 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
668 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
669 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
672 SALOME_ListIteratorOfListIO It( selected );
673 for( ; It.More(); It.Next()){
674 Handle(SALOME_InteractiveObject) IObject = It.Value();
675 if(IObject->hasEntry()){
676 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
677 switch(theCommandID){
679 anActor->SetRepresentation(SMESH_Actor::eEdge);
682 anActor->SetRepresentation(SMESH_Actor::eSurface);
685 if(anActor->IsShrunk())
688 anActor->SetShrink();
691 anActor->SetRepresentation(SMESH_Actor::ePoint);
694 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
695 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
698 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
699 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
702 vtkFloatingPointType color[3];
703 anActor->GetSufaceColor(color[0], color[1], color[2]);
704 int c0 = int (color[0] * 255);
705 int c1 = int (color[1] * 255);
706 int c2 = int (color[2] * 255);
707 QColor c(c0, c1, c2);
709 vtkFloatingPointType edgecolor[3];
710 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
711 c0 = int (edgecolor[0] * 255);
712 c1 = int (edgecolor[1] * 255);
713 c2 = int (edgecolor[2] * 255);
714 QColor e(c0, c1, c2);
716 vtkFloatingPointType backfacecolor[3];
717 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
718 c0 = int (backfacecolor[0] * 255);
719 c1 = int (backfacecolor[1] * 255);
720 c2 = int (backfacecolor[2] * 255);
721 QColor b(c0, c1, c2);
723 vtkFloatingPointType nodecolor[3];
724 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
725 c0 = int (nodecolor[0] * 255);
726 c1 = int (nodecolor[1] * 255);
727 c2 = int (nodecolor[2] * 255);
728 QColor n(c0, c1, c2);
730 int Edgewidth = (int)anActor->GetLineWidth();
733 int intValue = int(anActor->GetNodeSize());
734 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
736 SMESHGUI_Preferences_ColorDlg *aDlg =
737 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
738 aDlg->SetColor(1, c);
739 aDlg->SetColor(2, e);
740 aDlg->SetColor(3, n);
741 aDlg->SetColor(4, b);
742 aDlg->SetIntValue(1, Edgewidth);
743 aDlg->SetIntValue(2, intValue);
744 aDlg->SetIntValue(3, int(Shrink*100.));
746 QColor color = aDlg->GetColor(1);
747 QColor edgecolor = aDlg->GetColor(2);
748 QColor nodecolor = aDlg->GetColor(3);
749 QColor backfacecolor = aDlg->GetColor(4);
750 /* actor color and backface color */
751 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
752 vtkFloatingPointType (color.green()) / 255.,
753 vtkFloatingPointType (color.blue()) / 255.);
754 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
755 vtkFloatingPointType (backfacecolor.green()) / 255.,
756 vtkFloatingPointType (backfacecolor.blue()) / 255.);
759 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
760 vtkFloatingPointType (edgecolor.green()) / 255.,
761 vtkFloatingPointType (edgecolor.blue()) / 255.);
763 /* Shrink factor and size edges */
764 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
765 anActor->SetLineWidth(aDlg->GetIntValue(1));
767 /* Nodes color and size */
768 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
769 vtkFloatingPointType (nodecolor.green()) / 255.,
770 vtkFloatingPointType (nodecolor.blue()) / 255.);
771 anActor->SetNodeSize(aDlg->GetIntValue(2));
773 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
774 if( !aGroupObject->_is_nil() )
776 SMESH::ElementType anElementType = aGroupObject->GetType();
778 switch( anElementType )
780 case SMESH::NODE: aColor = nodecolor; break;
781 case SMESH::EDGE: aColor = edgecolor; break;
782 default: aColor = color; break;
785 SALOMEDS::Color aGroupColor;
786 aGroupColor.R = (float)aColor.red() / 255.0;
787 aGroupColor.G = (float)aColor.green() / 255.0;
788 aGroupColor.B = (float)aColor.blue() / 255.0;
789 aGroupObject->SetColor( aGroupColor );
799 SMESH::RepaintCurrentView();
803 void Control( int theCommandID )
805 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
806 SALOME_ListIO selected;
808 aSel->selectedObjects( selected );
810 if( !selected.IsEmpty() ){
811 Handle(SALOME_InteractiveObject) anIO = selected.First();
814 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
815 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
816 switch ( theCommandID ){
818 aTitle = QObject::tr( "LENGTH_EDGES" );
819 aControl = SMESH_Actor::eLength;
822 aTitle = QObject::tr( "LENGTH2D_EDGES" );
823 aControl = SMESH_Actor::eLength2D;
826 aTitle = QObject::tr( "FREE_EDGES" );
827 aControl = SMESH_Actor::eFreeEdges;
830 aTitle = QObject::tr( "FREE_BORDERS" );
831 aControl = SMESH_Actor::eFreeBorders;
834 aTitle = QObject::tr( "MULTI_BORDERS" );
835 aControl = SMESH_Actor::eMultiConnection;
838 aTitle = QObject::tr( "FREE_NODES" );
839 aControl = SMESH_Actor::eFreeNodes;
842 aTitle = QObject::tr( "MULTI2D_BORDERS" );
843 aControl = SMESH_Actor::eMultiConnection2D;
846 aTitle = QObject::tr( "AREA_ELEMENTS" );
847 aControl = SMESH_Actor::eArea;
850 aTitle = QObject::tr( "TAPER_ELEMENTS" );
851 aControl = SMESH_Actor::eTaper;
854 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
855 aControl = SMESH_Actor::eAspectRatio;
858 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
859 aControl = SMESH_Actor::eAspectRatio3D;
862 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
863 aControl = SMESH_Actor::eMinimumAngle;
866 aTitle = QObject::tr( "WARP_ELEMENTS" );
867 aControl = SMESH_Actor::eWarping;
870 aTitle = QObject::tr( "SKEW_ELEMENTS" );
871 aControl = SMESH_Actor::eSkew;
874 aTitle = QObject::tr( "SMESH_VOLUME" );
875 aControl = SMESH_Actor::eVolume3D;
878 aTitle = QObject::tr( "FREE_FACES" );
879 aControl = SMESH_Actor::eFreeFaces;
882 anActor->SetControlMode(aControl);
883 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
884 SMESH::RepaintCurrentView();
891 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
892 MeshObjectType theType,
893 const QString theInTypeName,
894 QString & theOutTypeName)
896 SMESH_TypeFilter aTypeFilter( theType );
898 if( !theIO.IsNull() )
900 entry = theIO->getEntry();
901 LightApp_DataOwner owner( entry );
902 if ( aTypeFilter.isOk( &owner )) {
903 theOutTypeName = theInTypeName;
911 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
913 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
914 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
916 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
917 CORBA::String_var anID = aSComp->GetID().c_str();
918 if (!strcmp(anID.in(),theIO->getEntry()))
924 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
925 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
926 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
927 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
928 CheckOIType ( theIO, GROUP, "Group", aTypeName )
936 QString CheckHomogeneousSelection()
938 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
939 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
940 SALOME_ListIO selected;
942 aSel->selectedObjects( selected );
944 QString RefType = CheckTypeObject(selected.First());
945 SALOME_ListIteratorOfListIO It(selected);
946 for ( ; It.More(); It.Next())
948 Handle(SALOME_InteractiveObject) IObject = It.Value();
949 QString Type = CheckTypeObject(IObject);
950 if (Type.compare(RefType) != 0)
951 return "Heterogeneous Selection";
958 void SMESHGUI::OnEditDelete()
960 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
961 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
962 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
964 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
965 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
966 _PTR(GenericAttribute) anAttr;
967 _PTR(AttributeIOR) anIOR;
971 QString aParentComponent = QString::null;
972 Handle(SALOME_InteractiveObject) anIO;
973 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
976 QString cur = anIO->getComponentDataType();
977 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
979 // check if object is reference
980 _PTR(SObject) aRefSObj;
981 aNameList.append("\n - ");
982 if ( aSO->ReferencedObject( aRefSObj ) ) {
983 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
984 aNameList.append( aRefName );
985 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
988 aNameList.append(anIO->getName());
992 if( aParentComponent.isNull() )
993 aParentComponent = cur;
994 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
995 aParentComponent = "";
998 if ( objectCount == 0 )
999 return; // No Valid Objects Selected
1001 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1002 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1003 QObject::tr("ERR_ERROR"),
1004 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1007 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1008 if (SUIT_MessageBox::warning
1009 (SMESHGUI::desktop(),
1010 QObject::tr("SMESH_WRN_WARNING"),
1011 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1012 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1013 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1016 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1017 SUIT_ViewManager* vm = anApp->activeViewManager();
1018 int nbSf = vm->getViewsCount();
1020 SALOME_ListIteratorOfListIO It(selected);
1022 aStudyBuilder->NewCommand(); // There is a transaction
1023 for( ; It.More(); It.Next()){ // loop on selected IO's
1024 Handle(SALOME_InteractiveObject) IObject = It.Value();
1025 if(IObject->hasEntry()) {
1026 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1028 // disable removal of "SMESH" component object
1029 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1031 if ( engineIOR() == anIOR->Value().c_str() )
1034 //Check the referenced object
1035 _PTR(SObject) aRefSObject;
1036 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1037 aSO = aRefSObject; // Delete main Object instead of reference
1039 // put the whole hierarchy of sub-objects of the selected SO into a list and
1040 // then treat them all starting from the deepest objects (at list back)
1042 std::list< _PTR(SObject) > listSO;
1043 listSO.push_back( aSO );
1044 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1045 for ( ; itSO != listSO.end(); ++itSO ) {
1046 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1047 for (it->InitEx(false); it->More(); it->Next())
1048 listSO.push_back( it->Value() );
1051 // treat SO's in the list starting from the back
1053 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1054 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1055 _PTR(SObject) SO = *ritSO;
1056 if ( !SO ) continue;
1057 std::string anEntry = SO->GetID();
1059 /** Erase graphical object **/
1060 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1061 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1062 for(int i = 0; i < nbSf; i++){
1063 SUIT_ViewWindow *sf = aViews[i];
1064 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1065 SMESH::RemoveActor(sf,anActor);
1070 /** Remove an object from data structures **/
1071 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1072 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1073 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1074 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1075 aMesh->RemoveGroup( aGroup );
1077 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1078 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1079 aMesh->RemoveSubMesh( aSubMesh );
1081 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1083 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1086 IObject = new SALOME_InteractiveObject
1087 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1088 QString objType = CheckTypeObject(IObject);
1089 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1090 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1091 aStudyBuilder->RemoveObjectWithChildren( SO );
1093 else {// default action: remove SObject from the study
1094 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1095 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1097 aStudyBuilder->RemoveObjectWithChildren( SO );
1101 } /* listSO back loop */
1102 } /* IObject->hasEntry() */
1104 aStudyBuilder->CommitCommand();
1106 /* Clear any previous selection */
1108 aSel->setSelectedObjects( l1 );
1110 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1115 SMESHGUI_EXPORT CAM_Module* createModule()
1117 return new SMESHGUI();
1121 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1123 //=============================================================================
1127 //=============================================================================
1128 SMESHGUI::SMESHGUI() :
1129 SalomeApp_Module( "SMESH" ),
1130 LightApp_Module( "SMESH" )
1132 if ( CORBA::is_nil( myComponentSMESH ) )
1134 CORBA::Boolean anIsEmbeddedMode;
1135 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1137 // 0019923: EDF 765 SMESH : default values of hypothesis
1138 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1139 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1140 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1141 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1142 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1145 myActiveDialogBox = 0;
1146 myFilterLibraryDlg = 0;
1150 SMESH::GetFilterManager();
1151 SMESH::GetPattern();
1153 /* load resources for all available meshers */
1154 SMESH::InitAvailableHypotheses();
1157 //=============================================================================
1161 //=============================================================================
1162 SMESHGUI::~SMESHGUI()
1164 SMESH::GetFilterManager()->Destroy();
1165 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1168 //=============================================================================
1172 //=============================================================================
1173 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1175 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1177 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1182 bool SMESHGUI::automaticUpdate()
1184 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1188 return resMgr->booleanValue( "SMESH", "auto_update", false );
1191 //=============================================================================
1195 //=============================================================================
1196 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1198 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1201 //=============================================================================
1205 //=============================================================================
1206 SMESHGUI* SMESHGUI::GetSMESHGUI()
1208 SMESHGUI* smeshMod = 0;
1209 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1212 CAM_Module* module = app->module( "Mesh" );
1213 smeshMod = dynamic_cast<SMESHGUI*>( module );
1216 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1218 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1221 _PTR(Study) aStudy = study->studyDS();
1223 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1232 Standard_EXPORT SMESHGUI* GetComponentGUI()
1234 return SMESHGUI::GetSMESHGUI();
1238 //=============================================================================
1242 //=============================================================================
1243 void SMESHGUI::SetState(int aState)
1248 //=============================================================================
1252 //=============================================================================
1253 void SMESHGUI::ResetState()
1258 //=============================================================================
1262 //=============================================================================
1263 void SMESHGUI::EmitSignalDeactivateDialog()
1265 emit SignalDeactivateActiveDialog();
1268 //=============================================================================
1272 //=============================================================================
1273 void SMESHGUI::EmitSignalStudyFrameChanged()
1275 emit SignalStudyFrameChanged();
1278 //=============================================================================
1282 //=============================================================================
1283 void SMESHGUI::EmitSignalCloseAllDialogs()
1285 emit SignalCloseAllDialogs();
1288 //=============================================================================
1292 //=============================================================================
1293 void SMESHGUI::EmitSignalVisibilityChanged()
1295 emit SignalVisibilityChanged();
1298 //=============================================================================
1302 //=============================================================================
1303 QDialog *SMESHGUI::GetActiveDialogBox()
1305 return myActiveDialogBox;
1308 //=============================================================================
1312 //=============================================================================
1313 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1315 myActiveDialogBox = (QDialog *) aDlg;
1319 //=============================================================================
1323 //=============================================================================
1324 SUIT_Desktop* SMESHGUI::desktop()
1326 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1328 return app->desktop();
1333 //=============================================================================
1337 //=============================================================================
1338 SalomeApp_Study* SMESHGUI::activeStudy()
1340 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1342 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1347 //=============================================================================
1351 //=============================================================================
1352 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1354 /* Here the position is on the bottom right corner - 10 */
1355 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1357 SUIT_Desktop *PP = desktop();
1358 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1359 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1363 //=============================================================================
1367 //=============================================================================
1368 static int isStudyLocked(_PTR(Study) theStudy){
1369 return theStudy->GetProperties()->IsLocked();
1372 static bool checkLock(_PTR(Study) theStudy) {
1373 if (isStudyLocked(theStudy)) {
1374 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1375 QObject::tr("WRN_WARNING"),
1376 QObject::tr("WRN_STUDY_LOCKED") );
1382 //=======================================================================
1383 //function : CheckActiveStudyLocked
1385 //=======================================================================
1387 bool SMESHGUI::isActiveStudyLocked()
1389 _PTR(Study) aStudy = activeStudy()->studyDS();
1390 return checkLock( aStudy );
1393 //=============================================================================
1397 //=============================================================================
1398 bool SMESHGUI::OnGUIEvent( int theCommandID )
1400 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1404 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1405 SUIT_ResourceMgr* mgr = resourceMgr();
1409 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1410 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1413 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1414 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1416 //QAction* act = action( theCommandID );
1418 switch (theCommandID) {
1420 if(checkLock(aStudy)) break;
1429 if(checkLock(aStudy)) break;
1430 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1434 case 150: //MED FILE INFORMATION
1436 SALOME_ListIO selected;
1437 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1439 aSel->selectedObjects( selected );
1440 if( selected.Extent() )
1442 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1443 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1444 if ( !aMesh->_is_nil() )
1446 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1453 case 122: // EXPORT MED
1464 ::ExportMeshToFile(theCommandID);
1468 case 200: // SCALAR BAR
1470 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1471 SALOME_ListIO selected;
1473 aSel->selectedObjects( selected );
1475 if( selected.Extent() ) {
1476 Handle(SALOME_InteractiveObject) anIO = selected.First();
1477 if( anIO->hasEntry() ) {
1478 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1479 anActor->SetControlMode( SMESH_Actor::eNone );
1487 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1497 ::DisableAutoColor();
1500 case 1134: // Clipping
1501 case 1133: // Tranparency
1502 case 1132: // Colors / Size
1509 ::SetDisplayMode(theCommandID);
1512 //2D quadratic representation
1515 ::SetDisplayMode(theCommandID);
1519 case 216: // 0D elements
1522 case 219: // Volumes
1523 case 220: // All Entity
1524 ::SetDisplayEntity(theCommandID);
1527 case 221: // Orientation of faces
1529 LightApp_SelectionMgr* mgr = selectionMgr();
1530 SALOME_ListIO selected; mgr->selectedObjects( selected );
1532 SALOME_ListIteratorOfListIO it(selected);
1533 for( ; it.More(); it.Next()) {
1534 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1535 if(anIObject->hasEntry()) {
1536 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1537 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1546 if(checkLock(aStudy)) break;
1548 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1551 SMESH::UpdateView();
1553 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1554 SMESH::OnVisuException();
1556 catch (...) { // PAL16774 (Crash after display of many groups)
1557 SMESH::OnVisuException();
1561 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1562 aSel->selectedObjects( l );
1563 aSel->setSelectedObjects( l );
1568 case 301: // DISPLAY
1569 case 302: // DISPLAY ONLY
1571 SMESH::EDisplaing anAction;
1572 switch (theCommandID) {
1573 case 300: anAction = SMESH::eErase; break;
1574 case 301: anAction = SMESH::eDisplay; break;
1575 case 302: anAction = SMESH::eDisplayOnly; break;
1578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1579 SALOME_ListIO sel_objects, to_process;
1581 aSel->selectedObjects( sel_objects );
1583 if( theCommandID==302 )
1584 startOperation( myEraseAll );
1586 extractContainers( sel_objects, to_process );
1589 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1593 SALOME_ListIteratorOfListIO It( to_process );
1594 for ( ; It.More(); It.Next()) {
1595 Handle(SALOME_InteractiveObject) IOS = It.Value();
1596 if (IOS->hasEntry()) {
1597 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1598 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1599 break; // PAL16774 (Crash after display of many groups)
1601 if (anAction == SMESH::eDisplayOnly)
1602 anAction = SMESH::eDisplay;
1607 // PAL13338 + PAL15161 -->
1608 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1609 SMESH::UpdateView();
1610 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1612 // PAL13338 + PAL15161 <--
1614 catch (...) { // PAL16774 (Crash after display of many groups)
1615 SMESH::OnVisuException();
1618 if (anAction == SMESH::eErase) {
1620 aSel->setSelectedObjects( l1 );
1623 aSel->setSelectedObjects( to_process );
1630 if(checkLock(aStudy)) break;
1633 EmitSignalDeactivateDialog();
1635 ( new SMESHGUI_NodesDlg( this ) )->show();
1638 SUIT_MessageBox::warning(desktop(),
1639 tr("SMESH_WRN_WARNING"),
1640 tr("SMESH_WRN_VIEWER_VTK"));
1645 case 2151: // FILTER
1649 EmitSignalDeactivateDialog();
1650 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1655 case 406: // MOVE NODE
1659 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1660 tr( "NOT_A_VTK_VIEWER" ) );
1664 if(checkLock(aStudy)) break;
1665 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1669 case 701: // COMPUTE MESH
1670 case 711: // PRECOMPUTE MESH
1671 case 712: // EVALUATE MESH
1673 if (checkLock(aStudy)) break;
1674 startOperation( theCommandID );
1678 case 702: // Create mesh
1679 case 703: // Create sub-mesh
1680 case 704: // Edit mesh/sub-mesh
1681 startOperation( theCommandID );
1683 case 710: // Build compound mesh
1685 if (checkLock(aStudy)) break;
1686 EmitSignalDeactivateDialog();
1687 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1691 case 407: // DIAGONAL INVERSION
1692 case 408: // Delete diagonal
1696 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1697 tr( "NOT_A_VTK_VIEWER" ) );
1701 if ( checkLock( aStudy ) )
1704 /*Standard_Boolean aRes;
1705 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1706 if ( aMesh->_is_nil() )
1708 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1709 tr( "SMESH_BAD_SELECTION" ) );
1713 EmitSignalDeactivateDialog();
1714 if ( theCommandID == 407 )
1715 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1717 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1720 case 409: // Change orientation
1721 case 410: // Union of triangles
1722 case 411: // Cutting of quadrangles
1726 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1727 tr( "NOT_A_VTK_VIEWER" ) );
1731 if ( checkLock( aStudy ) )
1734 EmitSignalDeactivateDialog();
1735 SMESHGUI_MultiEditDlg* aDlg = NULL;
1736 if ( theCommandID == 409 )
1737 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1738 else if ( theCommandID == 410 )
1739 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1741 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1746 case 412: // Smoothing
1748 if(checkLock(aStudy)) break;
1750 EmitSignalDeactivateDialog();
1751 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1754 SUIT_MessageBox::warning(desktop(),
1755 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1759 case 413: // Extrusion
1761 if (checkLock(aStudy)) break;
1763 EmitSignalDeactivateDialog();
1764 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1766 SUIT_MessageBox::warning(desktop(),
1767 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1771 case 414: // Revolution
1773 if(checkLock(aStudy)) break;
1775 EmitSignalDeactivateDialog();
1776 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1779 SUIT_MessageBox::warning(desktop(),
1780 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1784 case 415: // Pattern mapping
1786 if ( checkLock( aStudy ) )
1790 EmitSignalDeactivateDialog();
1791 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1794 SUIT_MessageBox::warning(desktop(),
1795 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1799 case 416: // Extrusion along a path
1801 if (checkLock(aStudy)) break;
1803 EmitSignalDeactivateDialog();
1804 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1806 SUIT_MessageBox::warning(desktop(),
1807 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1811 case 417: // Convert mesh to quadratic
1813 startOperation( 417 );
1814 /* if (checkLock(aStudy)) break;
1816 EmitSignalDeactivateDialog();
1817 new SMESHGUI_ConvToQuadDlg();
1819 SUIT_MessageBox::warning(desktop(),
1820 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1824 case 418: // create 2D mesh from 3D
1826 startOperation( 418 );
1829 case 806: // CREATE GEO GROUP
1831 startOperation( 806 );
1834 case 801: // CREATE GROUP
1838 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1839 tr( "NOT_A_VTK_VIEWER" ) );
1843 if(checkLock(aStudy)) break;
1844 EmitSignalDeactivateDialog();
1845 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1847 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1848 SALOME_ListIO selected;
1850 aSel->selectedObjects( selected );
1852 int nbSel = selected.Extent();
1854 // check if mesh is selected
1855 aMesh = SMESH::GetMeshByIO( selected.First() );
1857 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1862 case 802: // CONSTRUCT GROUP
1866 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1867 tr( "NOT_A_VTK_VIEWER" ) );
1871 if(checkLock(aStudy)) break;
1872 EmitSignalDeactivateDialog();
1874 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1875 SALOME_ListIO selected;
1877 aSel->selectedObjects( selected );
1879 int nbSel = selected.Extent();
1881 // check if submesh is selected
1882 Handle(SALOME_InteractiveObject) IObject = selected.First();
1883 if (IObject->hasEntry()) {
1884 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1886 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1887 if (!aSubMesh->_is_nil()) {
1889 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1890 // get submesh elements list by types
1891 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1892 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1893 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1894 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1895 // create group for each type o elements
1896 QString aName = IObject->getName();
1897 if (aNodes->length() > 0) {
1898 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1899 aGroup->Add(aNodes.inout());
1901 if (aEdges->length() > 0) {
1902 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1903 aGroup->Add(aEdges.inout());
1905 if (aFaces->length() > 0) {
1906 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1907 aGroup->Add(aFaces.inout());
1909 if (aVolumes->length() > 0) {
1910 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1911 aGroup->Add(aVolumes.inout());
1916 catch(const SALOME::SALOME_Exception & S_ex){
1917 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1924 SUIT_MessageBox::warning(desktop(),
1925 tr("SMESH_WRN_WARNING"),
1926 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1931 case 803: // EDIT GROUP
1935 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1936 tr( "NOT_A_VTK_VIEWER" ) );
1940 if(checkLock(aStudy)) break;
1941 EmitSignalDeactivateDialog();
1943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1944 SALOME_ListIO selected;
1946 aSel->selectedObjects( selected );
1948 SALOME_ListIteratorOfListIO It (selected);
1949 int nbSelectedGroups = 0;
1950 for ( ; It.More(); It.Next() )
1952 SMESH::SMESH_GroupBase_var aGroup =
1953 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1954 if (!aGroup->_is_nil()) {
1956 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1960 if (nbSelectedGroups == 0)
1962 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1968 case 804: // Add elements to group
1970 if(checkLock(aStudy)) break;
1971 if (myState == 800) {
1972 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1973 if (aDlg) aDlg->onAdd();
1978 case 805: // Remove elements from group
1980 if(checkLock(aStudy)) break;
1981 if (myState == 800) {
1982 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1983 if (aDlg) aDlg->onRemove();
1988 case 815: // Edit GEOM GROUP as standalone
1992 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1993 tr( "NOT_A_VTK_VIEWER" ) );
1997 if(checkLock(aStudy)) break;
1998 EmitSignalDeactivateDialog();
2000 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2001 SALOME_ListIO selected;
2003 aSel->selectedObjects( selected );
2005 SALOME_ListIteratorOfListIO It (selected);
2006 for ( ; It.More(); It.Next() )
2008 SMESH::SMESH_GroupOnGeom_var aGroup =
2009 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2010 if (!aGroup->_is_nil()) {
2011 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2018 case 810: // Union Groups
2019 case 811: // Intersect groups
2020 case 812: // Cut groups
2024 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2025 tr( "NOT_A_VTK_VIEWER" ) );
2029 if ( checkLock( aStudy ) )
2032 EmitSignalDeactivateDialog();
2034 SMESHGUI_GroupOpDlg* aDlg = 0;
2035 if ( theCommandID == 810 )
2036 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2037 else if ( theCommandID == 811 )
2038 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2040 aDlg = new SMESHGUI_CutGroupsDlg( this );
2047 case 814: // Create groups of entities from existing groups of superior dimensions
2049 if ( checkLock( aStudy ) )
2052 EmitSignalDeactivateDialog();
2053 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2059 case 813: // Delete groups with their contents
2063 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2064 tr( "NOT_A_VTK_VIEWER" ) );
2068 if ( checkLock( aStudy ) )
2071 EmitSignalDeactivateDialog();
2073 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2077 case 900: // MESH INFOS
2079 EmitSignalDeactivateDialog();
2080 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2081 SALOME_ListIO selected;
2083 aSel->selectedObjects( selected );
2085 if ( selected.Extent() > 1 ) { // a dlg for each IO
2087 SALOME_ListIteratorOfListIO It (selected);
2088 for ( ; It.More(); It.Next() ) {
2089 IOs.Clear(); IOs.Append( It.Value() );
2090 aSel->setSelectedObjects( IOs );
2091 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2093 // restore selection
2094 aSel->setSelectedObjects( selected );
2097 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2101 case 902: // STANDARD MESH INFOS
2103 EmitSignalDeactivateDialog();
2104 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2105 SALOME_ListIO selected;
2107 aSel->selectedObjects( selected );
2109 if ( selected.Extent() > 1 ) { // a dlg for each IO
2111 SALOME_ListIteratorOfListIO It (selected);
2112 for ( ; It.More(); It.Next() ) {
2114 IOs.Append( It.Value() );
2115 aSel->setSelectedObjects( IOs );
2116 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2118 // restore selection
2119 aSel->setSelectedObjects( selected );
2122 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2126 case 903: // WHAT IS
2128 EmitSignalDeactivateDialog();
2129 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2133 case 1100: // EDIT HYPOTHESIS
2135 if(checkLock(aStudy)) break;
2137 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2138 SALOME_ListIO selected;
2140 aSel->selectedObjects( selected );
2142 int nbSel = selected.Extent();
2145 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2146 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2148 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2149 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2150 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2151 if ( !aHypothesis->_is_nil() )
2154 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2155 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2157 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2168 case 1101: // RENAME
2170 if ( checkLock( aStudy ) )
2173 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2174 SALOME_ListIO selected;
2176 aSel->selectedObjects( selected );
2178 bool isAny = false; // is there any appropriate object selected
2180 SALOME_ListIteratorOfListIO It( selected );
2181 for ( ; It.More(); It.Next() )
2183 Handle(SALOME_InteractiveObject) IObject = It.Value();
2184 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2185 _PTR(GenericAttribute) anAttr;
2186 _PTR(AttributeName) aName;
2189 if ( obj->FindAttribute(anAttr, "AttributeName") )
2192 QString newName = QString(aName->Value().c_str());
2194 // check type to prevent renaming of inappropriate objects
2195 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2196 if (aType == MESH || aType == GROUP ||
2197 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2198 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2199 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2200 aType == HYPOTHESIS || aType == ALGORITHM)
2203 newName = LightApp_NameDlg::getName(desktop(), newName);
2204 if ( !newName.isEmpty() )
2206 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2208 // update name of group object and its actor
2209 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2210 if( !aGroupObject->_is_nil() )
2212 aGroupObject->SetName( newName.toLatin1().data() );
2213 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2214 anActor->setName( newName.toLatin1().data() );
2225 SUIT_MessageBox::warning(desktop(),
2226 QObject::tr("SMESH_WRN_WARNING"),
2227 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2232 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2234 if(checkLock(aStudy)) break;
2235 SUIT_OverrideCursor wc;
2237 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2238 SALOME_ListIO selected;
2240 aSel->selectedObjects( selected, QString::null, false );
2242 SALOME_ListIteratorOfListIO It(selected);
2243 for (int i = 0; It.More(); It.Next(), i++) {
2244 Handle(SALOME_InteractiveObject) IObject = It.Value();
2245 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2248 aSel->setSelectedObjects( l1 );
2253 case 4009: // ELEM0D
2254 case 4010: // GEOM::EDGE
2255 case 4021: // TRIANGLE
2257 case 4023: // POLYGON
2261 if(checkLock(aStudy)) break;
2263 EmitSignalDeactivateDialog();
2264 SMDSAbs_ElementType type = SMDSAbs_Edge;
2266 switch (theCommandID) {
2267 case 4009: // ELEM0D
2268 type = SMDSAbs_0DElement; nbNodes = 1; break;
2269 case 4021: // TRIANGLE
2270 type = SMDSAbs_Face; nbNodes = 3; break;
2272 type = SMDSAbs_Face; nbNodes = 4; break;
2274 type = SMDSAbs_Volume; nbNodes = 4; break;
2275 case 4023: // POLYGON
2276 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2278 type = SMDSAbs_Volume; nbNodes = 8; break;
2279 case 4033: // POLYHEDRE
2280 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2283 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2286 SUIT_MessageBox::warning(desktop(),
2287 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2291 case 4033: // POLYHEDRON
2293 if(checkLock(aStudy)) break;
2295 EmitSignalDeactivateDialog();
2296 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2299 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2304 case 4034: // QUADRATIC EDGE
2305 case 4035: // QUADRATIC TRIANGLE
2306 case 4036: // QUADRATIC QUADRANGLE
2307 case 4037: // QUADRATIC TETRAHEDRON
2308 case 4038: // QUADRATIC PYRAMID
2309 case 4039: // QUADRATIC PENTAHEDRON
2310 case 4040: // QUADRATIC HEXAHEDRON
2312 if(checkLock(aStudy)) break;
2314 EmitSignalDeactivateDialog();
2317 switch (theCommandID) {
2319 type = QUAD_EDGE; break;
2321 type = QUAD_TRIANGLE; break;
2323 type = QUAD_QUADRANGLE; break;
2325 type = QUAD_TETRAHEDRON; break;
2327 type = QUAD_PYRAMID; break;
2329 type = QUAD_PENTAHEDRON; break;
2331 type = QUAD_HEXAHEDRON;
2335 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2338 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2343 case 4041: // REMOVES NODES
2345 if(checkLock(aStudy)) break;
2347 EmitSignalDeactivateDialog();
2348 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2351 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2352 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2356 case 4042: // REMOVES ELEMENTS
2358 if(checkLock(aStudy)) break;
2360 EmitSignalDeactivateDialog();
2361 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2365 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2366 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2370 case 4043: { // CLEAR_MESH
2372 if(checkLock(aStudy)) break;
2374 SALOME_ListIO selected;
2375 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2376 aSel->selectedObjects( selected );
2378 SUIT_OverrideCursor wc;
2379 SALOME_ListIteratorOfListIO It (selected);
2380 for ( ; It.More(); It.Next() )
2382 Handle(SALOME_InteractiveObject) IOS = It.Value();
2383 SMESH::SMESH_Mesh_var aMesh =
2384 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2385 if ( aMesh->_is_nil()) continue;
2387 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2389 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2390 SMESH::ModifiedMesh( aMeshSObj, false, true);
2391 // hide groups and submeshes
2392 _PTR(ChildIterator) anIter =
2393 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2394 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2396 _PTR(SObject) so = anIter->Value();
2397 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2400 catch (const SALOME::SALOME_Exception& S_ex){
2402 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2406 SMESH::UpdateView();
2410 case 4051: // RENUMBERING NODES
2412 if(checkLock(aStudy)) break;
2414 EmitSignalDeactivateDialog();
2415 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2419 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2420 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2424 case 4052: // RENUMBERING ELEMENTS
2426 if(checkLock(aStudy)) break;
2428 EmitSignalDeactivateDialog();
2429 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2433 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2434 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2438 case 4061: // TRANSLATION
2440 if(checkLock(aStudy)) break;
2442 EmitSignalDeactivateDialog();
2443 ( new SMESHGUI_TranslationDlg( this ) )->show();
2446 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2447 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2451 case 4062: // ROTATION
2453 if(checkLock(aStudy)) break;
2455 EmitSignalDeactivateDialog();
2456 ( new SMESHGUI_RotationDlg( this ) )->show();
2459 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2460 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2464 case 4063: // SYMMETRY
2466 if(checkLock(aStudy)) break;
2468 EmitSignalDeactivateDialog();
2469 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2472 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2477 case 4064: // SEWING
2479 if(checkLock(aStudy)) break;
2481 EmitSignalDeactivateDialog();
2482 ( new SMESHGUI_SewingDlg( this ) )->show();
2485 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2490 case 4065: // MERGE NODES
2492 if(checkLock(aStudy)) break;
2494 EmitSignalDeactivateDialog();
2495 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2498 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2499 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2503 case 4066: // MERGE EQUAL ELEMENTS
2505 if (checkLock(aStudy)) break;
2507 EmitSignalDeactivateDialog();
2508 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2510 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2511 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2516 case 4067: // MAKE MESH PASS THROUGH POINT
2517 startOperation( 4067 );
2520 case 5105: // Library of selection filters
2522 static QList<int> aTypes;
2523 if ( aTypes.isEmpty() )
2525 aTypes.append( SMESH::NODE );
2526 aTypes.append( SMESH::EDGE );
2527 aTypes.append( SMESH::FACE );
2528 aTypes.append( SMESH::VOLUME );
2530 if (!myFilterLibraryDlg)
2531 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2532 else if (myFilterLibraryDlg->isHidden())
2533 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2534 myFilterLibraryDlg->raise();
2538 case 6017: // CONTROLS
2556 LightApp_SelectionMgr* mgr = selectionMgr();
2557 SALOME_ListIO selected; mgr->selectedObjects( selected );
2559 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2560 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2562 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2563 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2564 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2565 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2566 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2567 ::Control( theCommandID );
2572 SUIT_MessageBox::warning(desktop(),
2573 tr( "SMESH_WRN_WARNING" ),
2574 tr( "SMESH_BAD_SELECTION" ) );
2578 SUIT_MessageBox::warning(desktop(),
2579 tr( "SMESH_WRN_WARNING" ),
2580 tr( "NOT_A_VTK_VIEWER" ) );
2585 LightApp_SelectionMgr* mgr = selectionMgr();
2586 SALOME_ListIO selected; mgr->selectedObjects( selected );
2588 SALOME_ListIteratorOfListIO it(selected);
2589 for( ; it.More(); it.Next()) {
2590 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2591 if(anIObject->hasEntry()) {
2592 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2593 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2601 LightApp_SelectionMgr* mgr = selectionMgr();
2602 SALOME_ListIO selected; mgr->selectedObjects( selected );
2604 if (selected.Extent() == 1) {
2605 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2606 if(anIObject->hasEntry())
2607 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2608 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2615 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2616 //updateObjBrowser();
2620 //=============================================================================
2624 //=============================================================================
2625 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2630 //=============================================================================
2634 //=============================================================================
2635 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2640 //=============================================================================
2644 //=============================================================================
2645 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2650 //=============================================================================
2651 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2652 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2654 //=============================================================================
2655 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2656 SUIT_ViewWindow* wnd )
2658 if(theIO->hasEntry()){
2659 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2660 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2664 //=======================================================================
2665 // function : createSMESHAction
2667 //=======================================================================
2668 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2671 QWidget* parent = application()->desktop();
2672 SUIT_ResourceMgr* resMgr = resourceMgr();
2674 if ( !icon_id.isEmpty() )
2675 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2677 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2678 if ( !pix.isNull() )
2679 icon = QIcon( pix );
2681 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2682 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2683 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2685 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2688 //=======================================================================
2689 // function : createPopupItem
2691 //=======================================================================
2692 void SMESHGUI::createPopupItem( const int id,
2693 const QString& clients,
2694 const QString& types,
2695 const QString& theRule,
2700 parentId = popupMgr()->actionId( action( pId ) );
2702 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2703 popupMgr()->insert( action( id ), parentId, 0 );
2705 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2706 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2707 QString rule = "(%1) and (%2) and (%3)";
2708 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2709 if( clients.isEmpty() )
2710 rule = rule.arg( QString( "true" ) );
2712 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2713 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2716 bool cont = myRules.contains( id );
2718 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2720 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2721 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2724 //=======================================================================
2725 // function : initialize
2727 //=======================================================================
2728 void SMESHGUI::initialize( CAM_Application* app )
2730 SalomeApp_Module::initialize( app );
2732 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2734 /* Automatic Update flag */
2735 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2737 // ----- create actions --------------
2739 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2740 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2741 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2742 createSMESHAction( 115, "SAUV" );
2743 createSMESHAction( 114, "NUM" );
2744 createSMESHAction( 121, "DAT" );
2745 createSMESHAction( 122, "MED" );
2746 createSMESHAction( 123, "UNV" );
2747 createSMESHAction( 140, "STL" );
2748 createSMESHAction( 142, "SAUV" );
2749 createSMESHAction( 124, "EXPORT_DAT" );
2750 createSMESHAction( 125, "EXPORT_MED" );
2751 createSMESHAction( 126, "EXPORT_UNV" );
2752 createSMESHAction( 141, "EXPORT_STL" );
2753 createSMESHAction( 143, "EXPORT_SAUV" );
2754 createSMESHAction( 150, "FILE_INFO" );
2755 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2756 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2757 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2758 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2759 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2760 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2761 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2762 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2763 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2764 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2765 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2766 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2767 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2768 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2769 createSMESHAction( 804, "ADD" );
2770 createSMESHAction( 805, "REMOVE" );
2771 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2772 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2773 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2774 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2775 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2776 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2777 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2778 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2779 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2780 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2781 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2782 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2783 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2784 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2785 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2786 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2787 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2788 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2789 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2790 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2791 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2792 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2793 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2794 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2795 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2796 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2797 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2798 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2799 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2800 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2801 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2802 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2803 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2804 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2805 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2806 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2807 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2808 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2809 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2810 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2811 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2812 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2813 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2814 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2815 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2816 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2817 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2818 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2819 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2820 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2821 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2822 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2823 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2824 createSMESHAction( 415, "MAP", "ICON_MAP" );
2825 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2826 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2827 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2828 createSMESHAction( 200, "RESET" );
2829 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2830 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2831 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2832 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2833 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2834 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2835 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2836 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2837 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2838 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2839 createSMESHAction( 220, "ALL" );
2840 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2842 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2843 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2845 createSMESHAction( 1100, "EDIT_HYPO" );
2846 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2847 createSMESHAction( 1102, "UNASSIGN" );
2848 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2849 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2850 createSMESHAction( 1131, "DISPMODE" );
2851 createSMESHAction( 1132, "COLORS" );
2852 createSMESHAction( 1133, "TRANSP" );
2853 createSMESHAction( 1134, "CLIP" );
2854 createSMESHAction( 1135, "DISP_ENT" );
2855 createSMESHAction( 1136, "AUTO_COLOR" );
2856 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2857 createSMESHAction( 2000, "CTRL" );
2859 createSMESHAction( 300, "ERASE" );
2860 createSMESHAction( 301, "DISPLAY" );
2861 createSMESHAction( 302, "DISPLAY_ONLY" );
2862 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2863 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2864 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2865 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2866 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2867 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2868 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2869 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2871 // ----- create menu --------------
2872 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2873 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2874 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2875 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2876 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2877 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2878 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2880 createMenu( separator(), fileId );
2882 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2883 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2884 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2885 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2886 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2887 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2889 createMenu( 111, importId, -1 );
2890 createMenu( 112, importId, -1 );
2891 createMenu( 113, importId, -1 );
2892 createMenu( 115, importId, -1 );
2894 createMenu( 121, exportId, -1 );
2895 createMenu( 122, exportId, -1 );
2896 createMenu( 123, exportId, -1 );
2897 createMenu( 140, exportId, -1 ); // export to stl STL
2898 createMenu( 142, exportId, -1 );
2900 createMenu( separator(), fileId, 10 );
2902 createMenu( 33, editId, -1 );
2904 createMenu( 5105, toolsId, -1 );
2906 createMenu( 702, meshId, -1 ); // "Mesh" menu
2907 createMenu( 703, meshId, -1 );
2908 createMenu( 704, meshId, -1 );
2909 createMenu( 710, meshId, -1 );
2910 createMenu( separator(), meshId, -1 );
2911 createMenu( 701, meshId, -1 );
2912 createMenu( 711, meshId, -1 );
2913 createMenu( 712, meshId, -1 );
2914 createMenu( separator(), meshId, -1 );
2915 createMenu( 801, meshId, -1 );
2916 createMenu( 806, meshId, -1 );
2917 createMenu( 802, meshId, -1 );
2918 createMenu( 803, meshId, -1 );
2919 createMenu( 815, meshId, -1 );
2920 createMenu( separator(), meshId, -1 );
2921 createMenu( 810, meshId, -1 );
2922 createMenu( 811, meshId, -1 );
2923 createMenu( 812, meshId, -1 );
2924 createMenu( separator(), meshId, -1 );
2925 createMenu( 814, meshId, -1 );
2926 createMenu( separator(), meshId, -1 );
2927 createMenu( 813, meshId, -1 );
2928 createMenu( separator(), meshId, -1 );
2929 createMenu( 900, meshId, -1 );
2930 createMenu( 902, meshId, -1 );
2931 createMenu( 903, meshId, -1 );
2932 createMenu( separator(), meshId, -1 );
2934 createMenu( 6003, ctrlId, -1 );
2935 createMenu( 6001, ctrlId, -1 );
2936 createMenu( 6004, ctrlId, -1 );
2937 createMenu( separator(), ctrlId, -1 );
2938 createMenu( 6005, ctrlId, -1 );
2939 createMenu( 6002, ctrlId, -1 );
2940 createMenu( 6018, ctrlId, -1 );
2941 createMenu( 6019, ctrlId, -1 );
2942 createMenu( 6011, ctrlId, -1 );
2943 createMenu( 6012, ctrlId, -1 );
2944 createMenu( 6013, ctrlId, -1 );
2945 createMenu( 6014, ctrlId, -1 );
2946 createMenu( 6015, ctrlId, -1 );
2947 createMenu( 6016, ctrlId, -1 );
2948 createMenu( separator(), ctrlId, -1 );
2949 createMenu( 6017, ctrlId, -1 );
2950 createMenu( 6009, ctrlId, -1 );
2951 createMenu( 6021, ctrlId, -1 );
2952 createMenu( separator(), ctrlId, -1 );
2954 createMenu( 4000, addId, -1 );
2955 createMenu( 4009, addId, -1 );
2956 createMenu( 4010, addId, -1 );
2957 createMenu( 4021, addId, -1 );
2958 createMenu( 4022, addId, -1 );
2959 createMenu( 4023, addId, -1 );
2960 createMenu( 4031, addId, -1 );
2961 createMenu( 4032, addId, -1 );
2962 createMenu( 4033, addId, -1 );
2963 createMenu( separator(), addId, -1 );
2964 createMenu( 4034, addId, -1 );
2965 createMenu( 4035, addId, -1 );
2966 createMenu( 4036, addId, -1 );
2967 createMenu( 4037, addId, -1 );
2968 createMenu( 4038, addId, -1 );
2969 createMenu( 4039, addId, -1 );
2970 createMenu( 4040, addId, -1 );
2972 createMenu( 4041, removeId, -1 );
2973 createMenu( 4042, removeId, -1 );
2974 createMenu( 4043, removeId, -1 );
2976 createMenu( 4051, renumId, -1 );
2977 createMenu( 4052, renumId, -1 );
2979 createMenu( 4061, transfId, -1 );
2980 createMenu( 4062, transfId, -1 );
2981 createMenu( 4063, transfId, -1 );
2982 createMenu( 4064, transfId, -1 );
2983 createMenu( 4065, transfId, -1 );
2984 createMenu( 4066, transfId, -1 );
2986 createMenu( 406, modifyId, -1 );
2987 createMenu( 4067,modifyId, -1 );
2988 createMenu( 407, modifyId, -1 );
2989 createMenu( 408, modifyId, -1 );
2990 createMenu( 409, modifyId, -1 );
2991 createMenu( 410, modifyId, -1 );
2992 createMenu( 411, modifyId, -1 );
2993 createMenu( 412, modifyId, -1 );
2994 createMenu( 413, modifyId, -1 );
2995 createMenu( 416, modifyId, -1 );
2996 createMenu( 414, modifyId, -1 );
2997 createMenu( 415, modifyId, -1 );
2998 createMenu( 417, modifyId, -1 );
2999 createMenu( 418, modifyId, -1 );
3001 createMenu( 214, viewId, -1 );
3003 // ----- create toolbars --------------
3004 int meshTb = createTool( tr( "TB_MESH" ) ),
3005 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3006 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3007 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3008 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3010 createTool( 702, meshTb );
3011 createTool( 703, meshTb );
3012 createTool( 704, meshTb );
3013 createTool( 710, meshTb );
3014 createTool( separator(), meshTb );
3015 createTool( 701, meshTb );
3016 createTool( 711, meshTb );
3017 createTool( 712, meshTb );
3018 createTool( separator(), meshTb );
3019 createTool( 801, meshTb );
3020 createTool( 806, meshTb );
3021 createTool( 802, meshTb );
3022 createTool( 803, meshTb );
3023 //createTool( 815, meshTb );
3024 createTool( separator(), meshTb );
3025 createTool( 900, meshTb );
3026 createTool( 902, meshTb );
3027 createTool( 903, meshTb );
3028 createTool( separator(), meshTb );
3030 createTool( 6001, ctrlTb );
3031 createTool( 6003, ctrlTb );
3032 createTool( 6004, ctrlTb );
3033 createTool( separator(), ctrlTb );
3034 createTool( 6005, ctrlTb );
3035 createTool( 6002, ctrlTb );
3036 createTool( 6018, ctrlTb );
3037 createTool( 6019, ctrlTb );
3038 createTool( 6011, ctrlTb );
3039 createTool( 6012, ctrlTb );
3040 createTool( 6013, ctrlTb );
3041 createTool( 6014, ctrlTb );
3042 createTool( 6015, ctrlTb );
3043 createTool( 6016, ctrlTb );
3044 createTool( separator(), ctrlTb );
3045 createTool( 6017, ctrlTb );
3046 createTool( 6009, ctrlTb );
3047 createTool( 6021, ctrlTb );
3048 createTool( separator(), ctrlTb );
3050 createTool( 4000, addRemTb );
3051 createTool( 4009, addRemTb );
3052 createTool( 4010, addRemTb );
3053 createTool( 4021, addRemTb );
3054 createTool( 4022, addRemTb );
3055 createTool( 4023, addRemTb );
3056 createTool( 4031, addRemTb );
3057 createTool( 4032, addRemTb );
3058 createTool( 4033, addRemTb );
3059 createTool( separator(), addRemTb );
3060 createTool( 4034, addRemTb );
3061 createTool( 4035, addRemTb );
3062 createTool( 4036, addRemTb );
3063 createTool( 4037, addRemTb );
3064 createTool( 4038, addRemTb );
3065 createTool( 4039, addRemTb );
3066 createTool( 4040, addRemTb );
3067 createTool( separator(), addRemTb );
3068 createTool( 4041, addRemTb );
3069 createTool( 4042, addRemTb );
3070 createTool( 4043, addRemTb );
3071 createTool( separator(), addRemTb );
3072 createTool( 4051, addRemTb );
3073 createTool( 4052, addRemTb );
3074 createTool( separator(), addRemTb );
3075 createTool( 4061, addRemTb );
3076 createTool( 4062, addRemTb );
3077 createTool( 4063, addRemTb );
3078 createTool( 4064, addRemTb );
3079 createTool( 4065, addRemTb );
3080 createTool( 4066, addRemTb );
3081 createTool( separator(), addRemTb );
3083 createTool( 406, modifyTb );
3084 createTool( 4067,modifyTb );
3085 createTool( 407, modifyTb );
3086 createTool( 408, modifyTb );
3087 createTool( 409, modifyTb );
3088 createTool( 410, modifyTb );
3089 createTool( 411, modifyTb );
3090 createTool( 412, modifyTb );
3091 createTool( 413, modifyTb );
3092 createTool( 416, modifyTb );
3093 createTool( 414, modifyTb );
3094 createTool( 415, modifyTb );
3095 createTool( 417, modifyTb );
3096 createTool( 418, modifyTb );
3098 createTool( 214, dispModeTb );
3100 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3101 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3104 QString OB = "'ObjectBrowser'",
3105 View = "'" + SVTK_Viewer::Type() + "'",
3107 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3108 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3109 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3110 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3111 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3112 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3113 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3114 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3115 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3116 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3117 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3119 mesh_group = mesh + " " + subMesh + " " + group,
3120 hyp_alg = hypo + " " + algo;
3122 // popup for object browser
3124 isInvisible("not( isVisible )"),
3125 isEmpty("numberOfNodes = 0"),
3126 isNotEmpty("numberOfNodes <> 0"),
3128 // has nodes, edges, etc in VISIBLE! actor
3129 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3130 hasElems("(count( elemTypes ) > 0)"),
3131 hasDifferentElems("(count( elemTypes ) > 1)"),
3132 hasElems0d("({'Elem0d'} in elemTypes)"),
3133 hasEdges("({'Edge'} in elemTypes)"),
3134 hasFaces("({'Face'} in elemTypes)"),
3135 hasVolumes("({'Volume'} in elemTypes)");
3137 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3138 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3139 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3140 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3141 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3142 createPopupItem( 803, OB, group ); // EDIT_GROUP
3143 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3145 popupMgr()->insert( separator(), -1, 0 );
3146 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3147 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3148 createPopupItem( 712, OB, mesh, "&& isComputable" ); // COMPUTE
3149 createPopupItem( 214, OB, mesh_group ); // UPDATE
3150 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3151 createPopupItem( 902, OB, mesh ); // STD_INFO
3152 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3153 popupMgr()->insert( separator(), -1, 0 );
3154 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3155 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3156 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3157 popupMgr()->insert( separator(), -1, 0 );
3158 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3159 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3160 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3161 popupMgr()->insert( separator(), -1, 0 );
3162 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3163 popupMgr()->insert( separator(), -1, 0 );
3164 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3165 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3166 popupMgr()->insert( separator(), -1, 0 );
3168 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3170 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3171 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3172 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3173 createPopupItem( 143, OB, mesh, only_one_non_empty ); // EXPORT_SAUV
3174 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3175 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3176 popupMgr()->insert( separator(), -1, 0 );
3179 createPopupItem( 803, View, group ); // EDIT_GROUP
3180 createPopupItem( 804, View, elems ); // ADD
3181 createPopupItem( 805, View, elems ); // REMOVE
3183 popupMgr()->insert( separator(), -1, 0 );
3184 createPopupItem( 214, View, mesh_group ); // UPDATE
3185 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3186 createPopupItem( 902, View, mesh ); // STD_INFO
3187 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3188 popupMgr()->insert( separator(), -1, 0 );
3190 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3191 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3192 popupMgr()->insert( separator(), -1, 0 );
3195 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3196 QString aType = QString( "%1type in {%2}" ).arg( lc );
3197 aType = aType.arg( mesh_group );
3198 QString aMeshInVTK = aClient + "&&" + aType;
3200 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3201 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3202 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3204 //-------------------------------------------------
3206 //-------------------------------------------------
3207 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3209 popupMgr()->insert( action( 9010 ), anId, -1 );
3210 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3211 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3213 popupMgr()->insert( action( 9011 ), anId, -1 );
3214 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3215 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3217 popupMgr()->insert( separator(), -1, -1 );
3219 //-------------------------------------------------
3221 //-------------------------------------------------
3222 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3224 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3225 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3226 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3228 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3229 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3230 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3232 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3233 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3234 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3236 popupMgr()->insert( separator(), anId, -1 );
3238 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3239 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3240 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3242 //-------------------------------------------------
3244 //-------------------------------------------------
3245 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3247 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3249 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3250 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3251 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3253 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3254 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3255 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3257 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3258 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3259 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3261 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3262 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3263 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3265 popupMgr()->insert( separator(), anId, -1 );
3267 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3268 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3271 //-------------------------------------------------
3272 // Representation of the 2D Quadratic elements
3273 //-------------------------------------------------
3274 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3275 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3276 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3277 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3279 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3280 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3281 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3283 //-------------------------------------------------
3284 // Orientation of faces
3285 //-------------------------------------------------
3286 popupMgr()->insert( action( 221 ), -1, -1 );
3287 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3288 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3290 //-------------------------------------------------
3292 //-------------------------------------------------
3293 popupMgr()->insert( action( 1132 ), -1, -1 );
3294 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3296 //-------------------------------------------------
3298 //-------------------------------------------------
3299 popupMgr()->insert( action( 1133 ), -1, -1 );
3300 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3302 //-------------------------------------------------
3304 //-------------------------------------------------
3305 popupMgr()->insert( action( 1134 ), -1, -1 );
3306 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3308 popupMgr()->insert( separator(), -1, -1 );
3310 //-------------------------------------------------
3312 //-------------------------------------------------
3314 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3315 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3316 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3317 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3319 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3321 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3322 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3324 popupMgr()->insert( separator(), anId, -1 );
3326 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3327 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3328 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3330 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3331 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3332 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3334 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3335 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3336 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3338 popupMgr()->insert( separator(), anId, -1 );
3340 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3341 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3342 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3344 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3345 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3346 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3348 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3349 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3350 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3352 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3353 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3354 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3356 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3357 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3358 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3360 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3361 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3362 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3364 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3365 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3366 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3368 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3369 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3370 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3372 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3373 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3374 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3376 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3377 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3378 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3380 popupMgr()->insert( separator(), anId, -1 );
3382 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3383 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3384 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3386 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3387 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3388 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3390 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3391 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3392 QtxPopupMgr::VisibleRule );
3393 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3395 popupMgr()->insert( separator(), anId, -1 );
3397 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3398 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3400 popupMgr()->insert( separator(), -1, -1 );
3402 //-------------------------------------------------
3404 //-------------------------------------------------
3405 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3406 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3407 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3408 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3410 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3411 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3413 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3414 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3416 popupMgr()->insert( separator(), -1, -1 );
3418 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3419 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3422 //================================================================================
3424 * \brief Return true if SMESH or GEOM objects are selected.
3425 * Is called form LightApp_Module::activateModule() which clear selection if
3426 * not isSelectionCompatible()
3428 //================================================================================
3430 bool SMESHGUI::isSelectionCompatible()
3432 bool isCompatible = true;
3433 SALOME_ListIO selected;
3434 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3435 Sel->selectedObjects( selected );
3437 SALOME_ListIteratorOfListIO It( selected );
3438 for ( ; isCompatible && It.More(); It.Next())
3440 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3441 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3443 return isCompatible;
3446 bool SMESHGUI::activateModule( SUIT_Study* study )
3448 bool res = SalomeApp_Module::activateModule( study );
3450 setMenuShown( true );
3451 setToolShown( true );
3453 // Reset actions accelerator keys
3454 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3455 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3456 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3458 action( 33)->setEnabled(true); // Delete: Key_Delete
3459 action(1101)->setEnabled(true); // Rename: Key_F2
3461 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3462 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3463 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3464 if ( _PTR(Study) aStudy = s->studyDS()) {
3465 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3466 updateObjBrowser(); // objects can be removed
3472 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3474 setMenuShown( false );
3475 setToolShown( false );
3477 EmitSignalCloseAllDialogs();
3479 // Unset actions accelerator keys
3480 action(111)->setShortcut(QKeySequence()); // Import DAT
3481 action(112)->setShortcut(QKeySequence()); // Import UNV
3482 action(113)->setShortcut(QKeySequence()); // Import MED
3484 action( 33)->setEnabled(false); // Delete: Key_Delete
3485 action(1101)->setEnabled(false); // Rename: Key_F2
3487 return SalomeApp_Module::deactivateModule( study );
3490 void SMESHGUI::studyClosed( SUIT_Study* s )
3492 SMESH::RemoveVisuData( s->id() );
3493 SalomeApp_Module::studyClosed( s );
3496 void SMESHGUI::OnGUIEvent()
3498 const QObject* obj = sender();
3499 if ( !obj || !obj->inherits( "QAction" ) )
3501 int id = actionId((QAction*)obj);
3506 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3508 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3509 if ( CORBA::is_nil( myComponentSMESH ) )
3511 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3513 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3514 return aGUI.myComponentSMESH;
3517 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3518 return myComponentSMESH;
3521 QString SMESHGUI::engineIOR() const
3523 CORBA::ORB_var anORB = getApp()->orb();
3524 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3525 return QString( anIOR.in() );
3528 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3530 SalomeApp_Module::contextMenuPopup( client, menu, title );
3532 selectionMgr()->selectedObjects( lst );
3533 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3534 Handle(SALOME_InteractiveObject) io = lst.First();
3535 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3536 _PTR(Study) study = appStudy->studyDS();
3537 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3539 QString aName = QString( obj->GetName().c_str() );
3540 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3541 aName.remove( (aName.length() - 1), 1 );
3547 LightApp_Selection* SMESHGUI::createSelection() const
3549 return new SMESHGUI_Selection();
3552 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3554 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3555 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3558 void SMESHGUI::viewManagers( QStringList& list ) const
3560 list.append( SVTK_Viewer::Type() );
3563 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3565 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3566 SMESH::UpdateSelectionProp( this );
3569 void SMESHGUI::createPreferences()
3571 // General tab ------------------------------------------------------------------------
3572 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3574 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3575 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3577 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3578 setPreferenceProperty( qaGroup, "columns", 2 );
3579 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3580 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3581 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3582 setPreferenceProperty( prec, "min", 0 );
3583 setPreferenceProperty( prec, "max", 16 );
3585 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3586 setPreferenceProperty( dispgroup, "columns", 2 );
3587 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3589 modes.append( "Wireframe" );
3590 modes.append( "Shading" );
3591 modes.append( "Nodes" );
3592 modes.append( "Shrink" );
3593 QList<QVariant> indices;
3594 indices.append( 0 );
3595 indices.append( 1 );
3596 indices.append( 2 );
3597 indices.append( 3 );
3598 setPreferenceProperty( dispmode, "strings", modes );
3599 setPreferenceProperty( dispmode, "indexes", indices );
3601 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3602 setPreferenceProperty( arcgroup, "columns", 2 );
3603 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3604 QStringList quadraticModes;
3605 quadraticModes.append("Lines");
3606 quadraticModes.append("Arcs");
3608 indices.append( 0 );
3609 indices.append( 1 );
3610 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3611 setPreferenceProperty( quadraticmode, "indexes", indices );
3613 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3614 "SMESH", "max_angle" );
3615 setPreferenceProperty( maxAngle, "min", 1 );
3616 setPreferenceProperty( maxAngle, "max", 90 );
3620 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3621 setPreferenceProperty( exportgroup, "columns", 2 );
3622 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3623 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3625 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3626 setPreferenceProperty( computeGroup, "columns", 2 );
3627 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3629 modes.append( "Never" );
3630 modes.append( "Errors only" );
3631 modes.append( "Always" );
3633 indices.append( 0 );
3634 indices.append( 1 );
3635 indices.append( 2 );
3636 setPreferenceProperty( notifyMode, "strings", modes );
3637 setPreferenceProperty( notifyMode, "indexes", indices );
3639 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3640 setPreferenceProperty( segGroup, "columns", 2 );
3641 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3642 "SMESH", "segmentation" );
3643 setPreferenceProperty( segLen, "min", 1 );
3644 setPreferenceProperty( segLen, "max", 10000000 );
3645 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3646 "SMESH", "nb_segments_per_edge" );
3647 setPreferenceProperty( nbSeg, "min", 1 );
3648 setPreferenceProperty( nbSeg, "max", 10000000 );
3650 // Mesh tab ------------------------------------------------------------------------
3651 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3652 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3653 setPreferenceProperty( nodeGroup, "columns", 2 );
3655 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3656 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3658 setPreferenceProperty( nodeSz, "min", 1 );
3659 setPreferenceProperty( nodeSz, "max", 5 );
3661 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3662 setPreferenceProperty( elemGroup, "columns", 2 );
3664 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3665 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3666 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3667 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3669 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3670 //setPreferenceProperty( sp, "hstretch", 0 );
3671 //setPreferenceProperty( sp, "vstretch", 0 );
3673 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3674 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3675 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3676 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3677 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3678 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3679 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3681 setPreferenceProperty( size0d, "min", 1 );
3682 setPreferenceProperty( size0d, "max", 10 );
3684 setPreferenceProperty( sp, "hstretch", 0 );
3685 setPreferenceProperty( sp, "vstretch", 0 );
3687 setPreferenceProperty( elemW, "min", 1 );
3688 setPreferenceProperty( elemW, "max", 5 );
3690 setPreferenceProperty( shrink, "min", 0 );
3691 setPreferenceProperty( shrink, "max", 100 );
3693 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3694 setPreferenceProperty( orientGroup, "columns", 1 );
3696 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3697 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3699 setPreferenceProperty( orientScale, "min", 0.05 );
3700 setPreferenceProperty( orientScale, "max", 0.5 );
3701 setPreferenceProperty( orientScale, "step", 0.05 );
3703 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3705 // Selection tab ------------------------------------------------------------------------
3706 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3708 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3709 setPreferenceProperty( selGroup, "columns", 2 );
3711 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3712 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3713 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3715 setPreferenceProperty( selW, "min", 1 );
3716 setPreferenceProperty( selW, "max", 5 );
3718 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3719 setPreferenceProperty( preGroup, "columns", 2 );
3721 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3722 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3724 setPreferenceProperty( preW, "min", 1 );
3725 setPreferenceProperty( preW, "max", 5 );
3727 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3728 setPreferenceProperty( precSelGroup, "columns", 2 );
3730 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3731 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3732 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3734 // Scalar Bar tab ------------------------------------------------------------------------
3735 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3736 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3737 setPreferenceProperty( fontGr, "columns", 2 );
3739 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3740 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3742 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3743 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3745 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3746 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3748 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3749 setPreferenceProperty( numcol, "min", 2 );
3750 setPreferenceProperty( numcol, "max", 256 );
3752 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3753 setPreferenceProperty( numlab, "min", 2 );
3754 setPreferenceProperty( numlab, "max", 65 );
3756 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3757 setPreferenceProperty( orientGr, "columns", 2 );
3758 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3759 QStringList orients;
3760 orients.append( tr( "SMESH_VERTICAL" ) );
3761 orients.append( tr( "SMESH_HORIZONTAL" ) );
3762 indices.clear(); indices.append( 0 ); indices.append( 1 );
3763 setPreferenceProperty( orient, "strings", orients );
3764 setPreferenceProperty( orient, "indexes", indices );
3766 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3767 setPreferenceProperty( posVSizeGr, "columns", 2 );
3768 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3769 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3770 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3771 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3772 setPreferenceProperty( xv, "step", 0.1 );
3773 setPreferenceProperty( xv, "min", 0.0 );
3774 setPreferenceProperty( xv, "max", 1.0 );
3775 setPreferenceProperty( yv, "step", 0.1 );
3776 setPreferenceProperty( yv, "min", 0.0 );
3777 setPreferenceProperty( yv, "max", 1.0 );
3778 setPreferenceProperty( wv, "step", 0.1 );
3779 setPreferenceProperty( wv, "min", 0.0 );
3780 setPreferenceProperty( wv, "max", 1.0 );
3781 setPreferenceProperty( hv, "min", 0.0 );
3782 setPreferenceProperty( hv, "max", 1.0 );
3783 setPreferenceProperty( hv, "step", 0.1 );
3785 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3786 setPreferenceProperty( posHSizeGr, "columns", 2 );
3787 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3788 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3789 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3790 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3791 setPreferenceProperty( xv, "min", 0.0 );
3792 setPreferenceProperty( xv, "max", 1.0 );
3793 setPreferenceProperty( xv, "step", 0.1 );
3794 setPreferenceProperty( xh, "min", 0.0 );
3795 setPreferenceProperty( xh, "max", 1.0 );
3796 setPreferenceProperty( xh, "step", 0.1 );
3797 setPreferenceProperty( yh, "min", 0.0 );
3798 setPreferenceProperty( yh, "max", 1.0 );
3799 setPreferenceProperty( yh, "step", 0.1 );
3800 setPreferenceProperty( wh, "min", 0.0 );
3801 setPreferenceProperty( wh, "max", 1.0 );
3802 setPreferenceProperty( wh, "step", 0.1 );
3803 setPreferenceProperty( hh, "min", 0.0 );
3804 setPreferenceProperty( hh, "max", 1.0 );
3805 setPreferenceProperty( hh, "step", 0.1 );
3808 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3810 if( sect=="SMESH" ) {
3811 float sbX1,sbY1,sbW,sbH;
3812 float aTol = 1.00000009999999;
3813 std::string aWarning;
3814 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3815 if( name=="selection_object_color" || name=="selection_element_color" ||
3816 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3817 name=="selection_precision_node" || name=="selection_precision_element" ||
3818 name=="selection_precision_object")
3819 SMESH::UpdateSelectionProp( this );
3820 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3821 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3822 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3823 if(sbX1+sbW > aTol){
3824 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3827 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3828 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3831 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3832 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3833 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3834 if(sbY1+sbH > aTol){
3835 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3836 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3837 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3840 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3841 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3842 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3843 if(sbX1+sbW > aTol){
3844 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3847 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3848 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3851 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3852 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3853 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3854 if(sbY1+sbH > aTol){
3855 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3858 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3859 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3862 else if ( name == "segmentation" ) {
3863 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3864 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3866 else if ( name == "nb_segments_per_edge" ) {
3867 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3868 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3871 if(aWarning.size() != 0){
3872 aWarning += "The default values are applied instead.";
3873 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3874 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3875 QObject::tr(aWarning.c_str()));
3880 //================================================================================
3882 * \brief Update something in accordance with update flags
3883 * \param theFlags - update flags
3885 * Update viewer or/and object browser etc. in accordance with update flags ( see
3886 * LightApp_UpdateFlags enumeration ).
3888 //================================================================================
3889 void SMESHGUI::update( const int flags )
3891 if ( flags & UF_Viewer | flags & UF_Forced )
3892 SMESH::UpdateView();
3894 SalomeApp_Module::update( flags );
3897 //================================================================================
3899 * \brief Set default selection mode
3901 * SLOT called when operation commited. Sets default selection mode
3903 //================================================================================
3904 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3906 SVTK_ViewWindow* vtkWnd =
3907 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3909 vtkWnd->SetSelectionMode( ActorSelection );
3912 //================================================================================
3914 * \brief Set default selection mode
3916 * SLOT called when operation aborted. Sets default selection mode
3918 //================================================================================
3919 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3921 SVTK_ViewWindow* vtkWnd =
3922 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3924 vtkWnd->SetSelectionMode( ActorSelection );
3927 //================================================================================
3929 * \brief Creates operation with given identifier
3930 * \param id - identifier of operation to be started
3931 * \return Pointer on created operation or NULL if operation is not created
3933 * Virtual method redefined from the base class creates operation with given id.
3934 * It is called called automatically from startOperation method of base class.
3936 //================================================================================
3937 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3939 LightApp_Operation* op = 0;
3940 // to do : create operation here
3943 case 701: // Compute mesh
3944 op = new SMESHGUI_ComputeOp();
3946 case 702: // Create mesh
3947 op = new SMESHGUI_MeshOp( true, true );
3949 case 703: // Create sub-mesh
3950 op = new SMESHGUI_MeshOp( true, false );
3952 case 704: // Edit mesh/sub-mesh
3953 op = new SMESHGUI_MeshOp( false );
3955 case 711: // Precompute mesh
3956 op = new SMESHGUI_PrecomputeOp();
3958 case 712: // Evaluate mesh
3959 op = new SMESHGUI_EvaluateOp();
3961 case 806: // Create group on geom
3962 op = new SMESHGUI_GroupOnShapeOp();
3964 case 417: //convert to quadratic
3965 op = new SMESHGUI_ConvToQuadOp();
3967 case 418: // create 2D mesh as boundary on 3D
3968 op = new SMESHGUI_Make2DFrom3DOp();
3970 case 4067: // make mesh pass through point
3971 op = new SMESHGUI_MakeNodeAtPointOp();
3978 op = SalomeApp_Module::createOperation( id );
3982 //================================================================================
3984 * \brief Stops current operations and starts a given one
3985 * \param id - The id of the operation to start
3987 //================================================================================
3989 void SMESHGUI::switchToOperation(int id)
3991 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3992 activeStudy()->abortAllOperations();
3993 startOperation( id );
3996 LightApp_Displayer* SMESHGUI::displayer()
3999 myDisplayer = new SMESHGUI_Displayer( getApp() );
4003 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4006 int aTolerance = 64;
4007 int anIterations = 0;
4013 if( anIterations % aPeriod == 0 )
4016 if( aTolerance < 1 )
4019 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4021 aHue = (int)( 360.0 * rand() / RAND_MAX );
4022 //cout << "Hue = " << aHue << endl;
4024 //cout << "Auto colors : ";
4026 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4027 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4028 for( ; it != itEnd; ++it )
4030 SALOMEDS::Color anAutoColor = *it;
4031 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4034 aQColor.getHsv( &h, &s, &v );
4036 if( abs( h - aHue ) < aTolerance )
4039 //cout << "break (diff = " << abs( h - aHue ) << ")";
4049 //cout << "Hue of the returned color = " << aHue << endl;
4051 aColor.setHsv( aHue, 255, 255 );
4053 SALOMEDS::Color aSColor;
4054 aSColor.R = (double)aColor.red() / 255.0;
4055 aSColor.G = (double)aColor.green() / 255.0;
4056 aSColor.B = (double)aColor.blue() / 255.0;
4061 const char gSeparator = '_'; // character used to separate parameter names
4062 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4065 * \brief Store visual parameters
4067 * This method is called just before the study document is saved.
4068 * Store visual parameters in AttributeParameter attribue(s)
4070 void SMESHGUI::storeVisualParameters (int savePoint)
4072 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4073 if (!appStudy || !appStudy->studyDS())
4075 _PTR(Study) studyDS = appStudy->studyDS();
4077 // componentName is used for encoding of entries when storing them in IParameters
4078 std::string componentName = myComponentSMESH->ComponentDataType();
4079 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4080 //if (!aSComponent) return;
4083 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4084 componentName.c_str(),
4086 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4088 // viewers counters are used for storing view_numbers in IParameters
4091 // main cycle to store parameters of displayed objects
4092 QList<SUIT_ViewManager*> lst;
4093 QList<SUIT_ViewManager*>::Iterator it;
4094 getApp()->viewManagers(lst);
4095 for (it = lst.begin(); it != lst.end(); it++)
4097 SUIT_ViewManager* vman = *it;
4098 QString vType = vman->getType();
4100 // saving VTK actors properties
4101 if (vType == SVTK_Viewer::Type())
4103 QVector<SUIT_ViewWindow*> views = vman->getViews();
4104 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4106 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4108 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4109 vtkActorCollection* allActors = aCopy.GetActors();
4110 allActors->InitTraversal();
4111 while (vtkActor* actor = allActors->GetNextActor())
4113 if (actor->GetVisibility()) // store only visible actors
4115 SMESH_Actor* aSmeshActor = 0;
4116 if (actor->IsA("SMESH_Actor"))
4117 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4118 if (aSmeshActor && aSmeshActor->hasIO())
4120 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4123 // entry is "encoded" = it does NOT contain component adress,
4124 // since it is a subject to change on next component loading
4125 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4127 std::string param, vtkParam = vType.toLatin1().data();
4128 vtkParam += gSeparator;
4129 vtkParam += QString::number(vtkViewers).toLatin1().data();
4130 vtkParam += gSeparator;
4133 param = vtkParam + "Visibility";
4134 ip->setParameter(entry, param, "On");
4137 param = vtkParam + "Representation";
4138 ip->setParameter(entry, param, QString::number
4139 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4142 param = vtkParam + "IsShrunk";
4143 ip->setParameter(entry, param, QString::number
4144 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4146 // Displayed entities
4147 unsigned int aMode = aSmeshActor->GetEntityMode();
4148 bool isE = aMode & SMESH_Actor::eEdges;
4149 bool isF = aMode & SMESH_Actor::eFaces;
4150 bool isV = aMode & SMESH_Actor::eVolumes;
4152 QString modeStr ("e");
4153 modeStr += gDigitsSep; modeStr += QString::number(isE);
4154 modeStr += gDigitsSep; modeStr += "f";
4155 modeStr += gDigitsSep; modeStr += QString::number(isF);
4156 modeStr += gDigitsSep; modeStr += "v";
4157 modeStr += gDigitsSep; modeStr += QString::number(isV);
4159 param = vtkParam + "Entities";
4160 ip->setParameter(entry, param, modeStr.toLatin1().data());
4162 // Colors (surface:edge:)
4163 vtkFloatingPointType r, g, b;
4165 aSmeshActor->GetSufaceColor(r, g, b);
4166 QString colorStr ("surface");
4167 colorStr += gDigitsSep; colorStr += QString::number(r);
4168 colorStr += gDigitsSep; colorStr += QString::number(g);
4169 colorStr += gDigitsSep; colorStr += QString::number(b);
4171 aSmeshActor->GetBackSufaceColor(r, g, b);
4172 colorStr += gDigitsSep; colorStr += "backsurface";
4173 colorStr += gDigitsSep; colorStr += QString::number(r);
4174 colorStr += gDigitsSep; colorStr += QString::number(g);
4175 colorStr += gDigitsSep; colorStr += QString::number(b);
4177 aSmeshActor->GetEdgeColor(r, g, b);
4178 colorStr += gDigitsSep; colorStr += "edge";
4179 colorStr += gDigitsSep; colorStr += QString::number(r);
4180 colorStr += gDigitsSep; colorStr += QString::number(g);
4181 colorStr += gDigitsSep; colorStr += QString::number(b);
4183 aSmeshActor->GetNodeColor(r, g, b);
4184 colorStr += gDigitsSep; colorStr += "node";
4185 colorStr += gDigitsSep; colorStr += QString::number(r);
4186 colorStr += gDigitsSep; colorStr += QString::number(g);
4187 colorStr += gDigitsSep; colorStr += QString::number(b);
4189 param = vtkParam + "Colors";
4190 ip->setParameter(entry, param, colorStr.toLatin1().data());
4192 // Sizes of lines and points
4193 QString sizeStr ("line");
4194 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4195 sizeStr += gDigitsSep; sizeStr += "node";
4196 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4197 sizeStr += gDigitsSep; sizeStr += "shrink";
4198 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4200 param = vtkParam + "Sizes";
4201 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4204 param = vtkParam + "Opacity";
4205 ip->setParameter(entry, param,
4206 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4209 param = vtkParam + "ClippingPlane";
4210 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4212 ip->setParameter(entry, param, "Off");
4213 for (int ipl = 0; ipl < nPlanes; ipl++) {
4214 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4215 SMESH::Orientation anOrientation;
4217 vtkFloatingPointType anAngle[2];
4218 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4219 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4220 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4221 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4222 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4224 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4226 } // if (io->hasEntry())
4227 } // SMESH_Actor && hasIO
4229 } // while.. actors traversal
4233 } // if (SVTK view model)
4234 } // for (viewManagers)
4238 * \brief Restore visual parameters
4240 * This method is called after the study document is opened.
4241 * Restore visual parameters from AttributeParameter attribue(s)
4243 void SMESHGUI::restoreVisualParameters (int savePoint)
4245 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4246 if (!appStudy || !appStudy->studyDS())
4248 _PTR(Study) studyDS = appStudy->studyDS();
4250 // componentName is used for encoding of entries when storing them in IParameters
4251 std::string componentName = myComponentSMESH->ComponentDataType();
4252 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4253 //if (!aSComponent) return;
4256 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4257 componentName.c_str(),
4259 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4261 std::vector<std::string> entries = ip->getEntries();
4263 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4265 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4266 QString entry (ip->decodeEntry(*entIt).c_str());
4268 // Check that the entry corresponds to a real object in the Study
4269 // as the object may be deleted or modified after the visual state is saved.
4270 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4271 if (!so) continue; //Skip the not existent entry
4273 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4274 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4276 std::vector<std::string>::iterator namesIt = paramNames.begin();
4277 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4279 // actors are stored in a map after displaying of them for
4280 // quicker access in the future: map < viewID to actor >
4281 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4283 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4285 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4286 // '_' is used as separator and should not be used in viewer type or parameter names.
4287 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4288 if (lst.size() != 3)
4291 QString viewerTypStr = lst[0];
4292 QString viewIndexStr = lst[1];
4293 QString paramNameStr = lst[2];
4296 int viewIndex = viewIndexStr.toUInt(&ok);
4297 if (!ok) // bad conversion of view index to integer
4301 if (viewerTypStr == SVTK_Viewer::Type())
4303 SMESH_Actor* aSmeshActor = 0;
4304 if (vtkActors.IsBound(viewIndex))
4305 aSmeshActor = vtkActors.Find(viewIndex);
4307 if (paramNameStr == "Visibility")
4309 if (!aSmeshActor && displayer())
4311 QList<SUIT_ViewManager*> lst;
4312 getApp()->viewManagers(viewerTypStr, lst);
4314 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4315 if (viewIndex >= 0 && viewIndex < lst.count()) {
4316 SUIT_ViewManager* vman = lst.at(viewIndex);
4317 SUIT_ViewModel* vmodel = vman->getViewModel();
4318 // SVTK view model can be casted to SALOME_View
4319 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4321 // store displayed actor in a temporary map for quicker
4322 // access later when restoring other parameters
4323 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4324 vtkRenderer* Renderer = vtkView->getRenderer();
4325 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4326 vtkActorCollection* theActors = aCopy.GetActors();
4327 theActors->InitTraversal();
4328 bool isFound = false;
4329 vtkActor *ac = theActors->GetNextActor();
4330 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4331 if (ac->IsA("SMESH_Actor")) {
4332 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4333 if (aGeomAc->hasIO()) {
4334 Handle(SALOME_InteractiveObject) io =
4335 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4336 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4338 vtkActors.Bind(viewIndex, aGeomAc);
4345 } // if (paramNameStr == "Visibility")
4348 // the rest properties "work" with SMESH_Actor
4351 QString val ((*valuesIt).c_str());
4354 if (paramNameStr == "Representation") {
4355 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4358 else if (paramNameStr == "IsShrunk") {
4360 if (!aSmeshActor->IsShrunk())
4361 aSmeshActor->SetShrink();
4364 if (aSmeshActor->IsShrunk())
4365 aSmeshActor->UnShrink();
4368 // Displayed entities
4369 else if (paramNameStr == "Entities") {
4370 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4371 if (mode.count() == 6) {
4372 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4373 MESSAGE("Invalid order of data in Entities, must be: "
4374 "e:0/1:f:0/1:v:0/1");
4377 unsigned int aMode = aSmeshActor->GetEntityMode();
4378 unsigned int aNewMode =
4379 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4380 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4381 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4382 if (aNewMode != aMode)
4383 aSmeshActor->SetEntityMode(aNewMode);
4388 else if (paramNameStr == "Colors") {
4389 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4390 if (colors.count() == 16) {
4391 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4392 colors[8] != "edge" || colors[12] != "node") {
4393 MESSAGE("Invalid order of data in Colors, must be: "
4394 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4397 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4398 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4399 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4400 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4404 // Sizes of lines and points
4405 else if (paramNameStr == "Sizes") {
4406 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4407 if (sizes.count() == 6) {
4408 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4409 MESSAGE("Invalid order of data in Sizes, must be: "
4410 "line:int:node:int:shrink:float");
4413 aSmeshActor->SetLineWidth(sizes[1].toInt());
4414 aSmeshActor->SetNodeSize(sizes[3].toInt());
4415 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4420 else if (paramNameStr == "Opacity") {
4421 aSmeshActor->SetOpacity(val.toFloat());
4424 else if (paramNameStr.startsWith("ClippingPlane")) {
4425 cout << "$$$ ClippingPlane 1" << endl;
4426 if (paramNameStr == "ClippingPlane1" || val == "Off")
4427 aSmeshActor->RemoveAllClippingPlanes();
4429 cout << "$$$ ClippingPlane 2" << endl;
4430 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4431 if (vals.count() == 4) { // format check: 4 values
4432 cout << "$$$ ClippingPlane 3" << endl;
4433 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4434 double aDistance = vals[1].toFloat();
4435 vtkFloatingPointType anAngle[2];
4436 anAngle[0] = vals[2].toFloat();
4437 anAngle[1] = vals[3].toFloat();
4439 QList<SUIT_ViewManager*> lst;
4440 getApp()->viewManagers(viewerTypStr, lst);
4441 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4442 if (viewIndex >= 0 && viewIndex < lst.count()) {
4443 SUIT_ViewManager* vman = lst.at(viewIndex);
4444 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4445 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4446 anOrientation, aDistance, anAngle);
4451 } // if (aSmeshActor)
4452 } // other parameters than Visibility
4454 } // for names/parameters iterator
4455 } // for entries iterator
4457 // update all VTK views
4458 QList<SUIT_ViewManager*> lst;
4459 getApp()->viewManagers(lst);
4460 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4461 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4462 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4463 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4464 vtkView->getRenderer()->ResetCameraClippingRange();
4471 \brief Adds preferences for dfont of VTK viewer
4473 \param pIf group identifier
4474 \param param parameter
4475 \return identifier of preferences
4477 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4479 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4481 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4484 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4485 fam.append( tr( "SMESH_FONT_COURIER" ) );
4486 fam.append( tr( "SMESH_FONT_TIMES" ) );
4488 setPreferenceProperty( tfont, "fonts", fam );
4490 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4491 setPreferenceProperty( tfont, "features", f );
4497 \brief Actions after hypothesis edition
4498 Updates object browser after hypothesis edition
4500 void SMESHGUI::onHypothesisEdit( int result )
4502 updateObjBrowser( true );