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_AddMeshElementDlg.h"
29 #include "SMESHGUI_AddQuadraticElementDlg.h"
30 #include "SMESHGUI_BuildCompoundDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_ComputeDlg.h"
33 #include "SMESHGUI_ConvToQuadOp.h"
34 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
35 #include "SMESHGUI_DeleteGroupDlg.h"
36 #include "SMESHGUI_Displayer.h"
37 #include "SMESHGUI_EditMeshDlg.h"
38 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
39 #include "SMESHGUI_ExtrusionDlg.h"
40 #include "SMESHGUI_FileInfoDlg.h"
41 #include "SMESHGUI_FilterDlg.h"
42 #include "SMESHGUI_FilterLibraryDlg.h"
43 #include "SMESHGUI_FindElemByPointDlg.h"
44 #include "SMESHGUI_GroupDlg.h"
45 #include "SMESHGUI_GroupOnShapeDlg.h"
46 #include "SMESHGUI_GroupOpDlg.h"
47 #include "SMESHGUI_Hypotheses.h"
48 #include "SMESHGUI_Make2DFrom3DOp.h"
49 #include "SMESHGUI_MakeNodeAtPointDlg.h"
50 #include "SMESHGUI_MeshInfosDlg.h"
51 #include "SMESHGUI_MeshOp.h"
52 #include "SMESHGUI_MeshOrderOp.h"
53 #include "SMESHGUI_MeshPatternDlg.h"
54 #include "SMESHGUI_MoveNodesDlg.h"
55 #include "SMESHGUI_MultiEditDlg.h"
56 #include "SMESHGUI_NodesDlg.h"
57 #include "SMESHGUI_Preferences_ColorDlg.h"
58 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
59 #include "SMESHGUI_RemoveElementsDlg.h"
60 #include "SMESHGUI_RemoveNodesDlg.h"
61 #include "SMESHGUI_RenumberingDlg.h"
62 #include "SMESHGUI_RevolutionDlg.h"
63 #include "SMESHGUI_RotationDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_SewingDlg.h"
66 #include "SMESHGUI_SingleEditDlg.h"
67 #include "SMESHGUI_SmoothingDlg.h"
68 #include "SMESHGUI_StandardMeshInfosDlg.h"
69 #include "SMESHGUI_SymmetryDlg.h"
70 #include "SMESHGUI_TranslationDlg.h"
71 #include "SMESHGUI_TransparencyDlg.h"
72 #include "SMESHGUI_WhatIsDlg.h"
74 #include "SMESHGUI_Utils.h"
75 #include "SMESHGUI_MeshUtils.h"
76 #include "SMESHGUI_GroupUtils.h"
77 #include "SMESHGUI_FilterUtils.h"
78 #include "SMESHGUI_PatternUtils.h"
79 #include "SMESHGUI_VTKUtils.h"
80 #include "SMESHGUI_HypothesesUtils.h"
82 #include <SMESH_Client.hxx>
83 #include <SMESH_Actor.h>
84 #include <SMESH_TypeFilter.hxx>
86 // SALOME GUI includes
87 #include <SalomeApp_Tools.h>
88 #include <SalomeApp_Study.h>
89 #include <SalomeApp_Application.h>
90 #include <SalomeApp_CheckFileDlg.h>
92 #include <LightApp_DataOwner.h>
93 #include <LightApp_Preferences.h>
94 #include <LightApp_SelectionMgr.h>
95 #include <LightApp_UpdateFlags.h>
96 #include <LightApp_NameDlg.h>
98 #include <SVTK_ViewWindow.h>
99 #include <SVTK_ViewModel.h>
100 #include <SVTK_ViewManager.h>
102 #include <VTKViewer_Algorithm.h>
104 #include <SUIT_MessageBox.h>
105 #include <SUIT_ResourceMgr.h>
106 #include <SUIT_FileDlg.h>
107 #include <SUIT_Desktop.h>
108 #include <SUIT_OverrideCursor.h>
109 #include <SUIT_Session.h>
111 #include <QtxPopupMgr.h>
112 #include <QtxFontEdit.h>
114 #include <SALOME_ListIO.hxx>
115 #include <SALOME_ListIteratorOfListIO.hxx>
118 #include <SALOMEconfig.h>
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
120 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
123 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
127 #include <boost/shared_ptr.hpp>
130 #include <vtkScalarBarActor.h>
131 #include <vtkCamera.h>
132 #include <vtkRenderer.h>
133 #include <vtkPlane.h>
135 // SALOME KERNEL includes
136 #include <SALOMEDS_Study.hxx>
137 #include <SALOMEDSClient_StudyBuilder.hxx>
138 #include <SALOMEDSClient_SComponent.hxx>
139 #include <SALOMEDSClient_ClientFactory.hxx>
140 #include <SALOMEDSClient_IParameters.hxx>
143 #include <Standard_ErrorHandler.hxx>
144 #include <NCollection_DataMap.hxx>
148 //=============================================================
149 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
152 void ExportMeshToFile(int theCommandID);
154 void SetDisplayMode(int theCommandID);
156 void SetDisplayEntity(int theCommandID);
158 void Control( int theCommandID );
162 //=============================================================
163 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
167 std::string myExtension;
169 if ( theCommandID == 113 ) {
170 filter.append( QObject::tr( "MED files (*.med)" ) );
171 filter.append( QObject::tr( "All files (*)" ) );
173 else if ( theCommandID == 112 ) {
174 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
176 else if ( theCommandID == 111 ) {
177 filter.append( QObject::tr( "DAT files (*.dat)" ) );
180 QString anInitialPath = "";
181 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
182 anInitialPath = QDir::currentPath();
184 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
187 QObject::tr( "SMESH_IMPORT_MESH" ) );
188 if ( filenames.count() > 0 ) {
189 SUIT_OverrideCursor wc;
190 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
193 bool isEmpty = false;
194 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
195 QString filename = *it;
196 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
198 switch ( theCommandID ) {
201 // DAT format (currently unsupported)
202 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
203 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
209 aMeshes->length( 1 );
210 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
211 if ( aMeshes[0]->_is_nil() )
212 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
213 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
219 SMESH::DriverMED_ReadStatus res;
220 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
221 if ( res != SMESH::DRS_OK ) {
222 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
223 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
229 catch ( const SALOME::SALOME_Exception& S_ex ) {
230 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
231 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
234 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
235 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
237 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
238 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
239 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
240 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
241 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
249 // update Object browser
250 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
252 // show Error message box if there were errors
253 if ( errors.count() > 0 ) {
254 SUIT_MessageBox::critical( SMESHGUI::desktop(),
255 QObject::tr( "SMESH_ERROR" ),
256 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
259 // show warning message box, if some imported mesh is empty
261 SUIT_MessageBox::warning( SMESHGUI::desktop(),
262 QObject::tr( "SMESH_WRN_WARNING" ),
263 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
268 void ExportMeshToFile( int theCommandID )
270 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
271 SALOME_ListIO selected;
273 aSel->selectedObjects( selected );
275 SMESH::SMESH_Mesh_var aMesh;
276 if(selected.Extent() == 1)
277 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
278 if ( aMesh->_is_nil() ) {
279 SUIT_MessageBox::warning( SMESHGUI::desktop(),
280 QObject::tr( "SMESH_WRN_WARNING" ),
281 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
285 Handle(SALOME_InteractiveObject) anIObject = selected.First();
286 QString aFilter, aTitle = QObject::tr("Export mesh");
287 QMap<QString, SMESH::MED_VERSION> aFilterMap;
288 QMap<QString, int> aFilterMapSTL;
289 switch ( theCommandID ) {
293 if (aMesh->HasDuplicatedGroupNamesMED()) {
294 int aRet = SUIT_MessageBox::warning
295 (SMESHGUI::desktop(),
296 QObject::tr("SMESH_WRN_WARNING"),
297 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
298 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
299 if (aRet != SUIT_MessageBox::Yes)
303 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
304 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
305 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
306 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
311 aFilter = QObject::tr("DAT files (*.dat)");
316 if (aMesh->NbPyramids()) {
317 int aRet = SUIT_MessageBox::warning
318 (SMESHGUI::desktop(),
319 QObject::tr("SMESH_WRN_WARNING"),
320 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
321 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
322 if (aRet != SUIT_MessageBox::Yes)
325 aFilter = QObject::tr("IDEAS files (*.unv)");
333 there must be check on others mesh elements not equal triangles
335 if (aMesh->NbTriangles() < 1) {
336 SUIT_MessageBox::warning
337 (SMESHGUI::desktop(),
338 QObject::tr("SMESH_WRN_WARNING"),
339 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
342 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
343 int aRet = SUIT_MessageBox::warning
344 (SMESHGUI::desktop(),
345 QObject::tr("SMESH_WRN_WARNING"),
346 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
347 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
348 if (aRet != SUIT_MessageBox::Yes)
352 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
353 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
361 SMESH::MED_VERSION aFormat;
362 // Init the parameter with the default value
363 bool aIsASCII_STL = true;
364 bool toCreateGroups = false;
365 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
367 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
369 QString anInitialPath = "";
370 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
371 anInitialPath = QDir::currentPath();
373 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
374 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
375 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
376 aFilter, aTitle, false);
378 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
380 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
381 for ( ; it != aFilterMapSTL.end(); ++it )
382 filters.push_back( it.key() );
384 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
385 fd->setWindowTitle( aTitle );
386 fd->setFilters( filters );
387 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
388 if ( !anInitialPath.isEmpty() )
389 fd->setDirectory( anInitialPath );
390 fd->selectFile(anIObject->getName());
394 aFilename = fd->selectedFile();
395 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
400 else { // Export to MED
402 QString aDefaultFilter;
403 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
404 for ( ; it != aFilterMap.end(); ++it ) {
405 filters.push_back( it.key() );
406 if (it.value() == SMESH::MED_V2_2)
407 aDefaultFilter = it.key();
410 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
411 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
412 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
413 fd->setWindowTitle( aTitle );
414 fd->setFilters( filters );
415 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
416 fd->selectFilter(aDefaultFilter);
417 fd->SetChecked(toCreateGroups);
418 if ( !anInitialPath.isEmpty() )
419 fd->setDirectory( anInitialPath );
420 fd->selectFile(anIObject->getName());
424 aFilename = fd->selectedFile();
425 aFormat = aFilterMap[fd->selectedFilter()];
427 if ( !aFilename.isEmpty()
428 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
429 && aFormat==SMESH::MED_V2_1) {
430 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
431 QObject::tr("SMESH_WRN_WARNING"),
432 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
433 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
434 if (aRet != SUIT_MessageBox::Yes) {
439 toCreateGroups = fd->IsChecked();
442 if ( !aFilename.isEmpty() ) {
443 // Check whether the file already exists and delete it if yes
444 QFile aFile( aFilename );
445 if ( aFile.exists() )
447 SUIT_OverrideCursor wc;
450 bool Renumber = false;
451 // PAL 14172 : Check of we have to renumber or not from the preferences before export
453 Renumber= resMgr->booleanValue("SMESH","renumbering");
455 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
456 aMeshEditor->RenumberNodes();
457 aMeshEditor->RenumberElements();
458 if ( SMESHGUI::automaticUpdate() )
461 switch ( theCommandID ) {
464 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
468 aMesh->ExportDAT( aFilename.toLatin1().data() );
472 aMesh->ExportUNV( aFilename.toLatin1().data() );
476 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
482 catch (const SALOME::SALOME_Exception& S_ex){
484 SUIT_MessageBox::warning(SMESHGUI::desktop(),
485 QObject::tr("SMESH_WRN_WARNING"),
486 QObject::tr("SMESH_EXPORT_FAILED"));
492 inline void InverseEntityMode(unsigned int& theOutputMode,
493 unsigned int theMode)
495 bool anIsNotPresent = ~theOutputMode & theMode;
497 theOutputMode |= theMode;
499 theOutputMode &= ~theMode;
502 void SetDisplayEntity(int theCommandID){
503 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
504 SALOME_ListIO selected;
506 aSel->selectedObjects( selected );
508 if(selected.Extent() >= 1){
509 SALOME_ListIteratorOfListIO It( selected );
510 for( ; It.More(); It.Next()){
511 Handle(SALOME_InteractiveObject) IObject = It.Value();
512 if(IObject->hasEntry()){
513 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
514 unsigned int aMode = anActor->GetEntityMode();
515 switch(theCommandID){
517 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
520 InverseEntityMode(aMode,SMESH_Actor::eEdges);
523 InverseEntityMode(aMode,SMESH_Actor::eFaces);
526 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
529 aMode = SMESH_Actor::eAllEntity;
533 anActor->SetEntityMode(aMode);
541 SALOME_ListIO selected;
542 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
546 LightApp_SelectionMgr* aSel = app->selectionMgr();
547 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
548 if( !aSel || !appStudy )
551 aSel->selectedObjects( selected );
552 if( selected.IsEmpty() )
555 Handle(SALOME_InteractiveObject) anIObject = selected.First();
557 _PTR(Study) aStudy = appStudy->studyDS();
558 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
559 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
560 if( aMainObject->_is_nil() )
563 aMainObject->SetAutoColor( true );
565 QList<SALOMEDS::Color> aReservedColors;
567 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
568 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
570 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
571 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
573 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
574 aGroupObject->SetColor( aColor );
575 aReservedColors.append( aColor );
577 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
578 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
580 if( aGroupObject->GetType() == SMESH::NODE )
581 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
582 else if( aGroupObject->GetType() == SMESH::EDGE )
583 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
585 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
589 SMESH::RepaintCurrentView();
592 void DisableAutoColor(){
593 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
594 SALOME_ListIO selected;
596 aSel->selectedObjects( selected );
598 if(selected.Extent()){
599 Handle(SALOME_InteractiveObject) anIObject = selected.First();
600 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
601 if ( !aMesh->_is_nil() ) {
602 aMesh->SetAutoColor( false );
607 void SetDisplayMode(int theCommandID){
608 SALOME_ListIO selected;
609 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
613 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
614 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
615 if( !aSel || !appStudy )
618 _PTR(Study) aStudy = appStudy->studyDS();
620 aSel->selectedObjects( selected );
622 if(selected.Extent() >= 1){
623 switch(theCommandID){
625 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
626 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
630 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
631 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
634 SALOME_ListIteratorOfListIO It( selected );
635 for( ; It.More(); It.Next()){
636 Handle(SALOME_InteractiveObject) IObject = It.Value();
637 if(IObject->hasEntry()){
638 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
639 switch(theCommandID){
641 anActor->SetRepresentation(SMESH_Actor::eEdge);
644 anActor->SetRepresentation(SMESH_Actor::eSurface);
647 if(anActor->IsShrunk())
650 anActor->SetShrink();
653 anActor->SetRepresentation(SMESH_Actor::ePoint);
656 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
657 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
660 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
661 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
664 vtkFloatingPointType color[3];
665 anActor->GetSufaceColor(color[0], color[1], color[2]);
666 int c0 = int (color[0] * 255);
667 int c1 = int (color[1] * 255);
668 int c2 = int (color[2] * 255);
669 QColor c(c0, c1, c2);
671 vtkFloatingPointType edgecolor[3];
672 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
673 c0 = int (edgecolor[0] * 255);
674 c1 = int (edgecolor[1] * 255);
675 c2 = int (edgecolor[2] * 255);
676 QColor e(c0, c1, c2);
678 vtkFloatingPointType backfacecolor[3];
679 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
680 c0 = int (backfacecolor[0] * 255);
681 c1 = int (backfacecolor[1] * 255);
682 c2 = int (backfacecolor[2] * 255);
683 QColor b(c0, c1, c2);
685 vtkFloatingPointType nodecolor[3];
686 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
687 c0 = int (nodecolor[0] * 255);
688 c1 = int (nodecolor[1] * 255);
689 c2 = int (nodecolor[2] * 255);
690 QColor n(c0, c1, c2);
692 int Edgewidth = (int)anActor->GetLineWidth();
695 int intValue = int(anActor->GetNodeSize());
696 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
698 SMESHGUI_Preferences_ColorDlg *aDlg =
699 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
700 aDlg->SetColor(1, c);
701 aDlg->SetColor(2, e);
702 aDlg->SetColor(3, n);
703 aDlg->SetColor(4, b);
704 aDlg->SetIntValue(1, Edgewidth);
705 aDlg->SetIntValue(2, intValue);
706 aDlg->SetIntValue(3, int(Shrink*100.));
708 QColor color = aDlg->GetColor(1);
709 QColor edgecolor = aDlg->GetColor(2);
710 QColor nodecolor = aDlg->GetColor(3);
711 QColor backfacecolor = aDlg->GetColor(4);
712 /* actor color and backface color */
713 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
714 vtkFloatingPointType (color.green()) / 255.,
715 vtkFloatingPointType (color.blue()) / 255.);
716 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
717 vtkFloatingPointType (backfacecolor.green()) / 255.,
718 vtkFloatingPointType (backfacecolor.blue()) / 255.);
721 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
722 vtkFloatingPointType (edgecolor.green()) / 255.,
723 vtkFloatingPointType (edgecolor.blue()) / 255.);
725 /* Shrink factor and size edges */
726 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
727 anActor->SetLineWidth(aDlg->GetIntValue(1));
729 /* Nodes color and size */
730 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
731 vtkFloatingPointType (nodecolor.green()) / 255.,
732 vtkFloatingPointType (nodecolor.blue()) / 255.);
733 anActor->SetNodeSize(aDlg->GetIntValue(2));
735 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
736 if( !aGroupObject->_is_nil() )
738 SMESH::ElementType anElementType = aGroupObject->GetType();
740 switch( anElementType )
742 case SMESH::NODE: aColor = nodecolor; break;
743 case SMESH::EDGE: aColor = edgecolor; break;
744 default: aColor = color; break;
747 SALOMEDS::Color aGroupColor;
748 aGroupColor.R = (float)aColor.red() / 255.0;
749 aGroupColor.G = (float)aColor.green() / 255.0;
750 aGroupColor.B = (float)aColor.blue() / 255.0;
751 aGroupObject->SetColor( aGroupColor );
761 SMESH::RepaintCurrentView();
765 void Control( int theCommandID )
767 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
768 SALOME_ListIO selected;
770 aSel->selectedObjects( selected );
772 if( !selected.IsEmpty() ){
773 Handle(SALOME_InteractiveObject) anIO = selected.First();
776 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
777 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
778 switch ( theCommandID ){
780 aTitle = QObject::tr( "LENGTH_EDGES" );
781 aControl = SMESH_Actor::eLength;
784 aTitle = QObject::tr( "LENGTH2D_EDGES" );
785 aControl = SMESH_Actor::eLength2D;
788 aTitle = QObject::tr( "FREE_EDGES" );
789 aControl = SMESH_Actor::eFreeEdges;
792 aTitle = QObject::tr( "FREE_BORDERS" );
793 aControl = SMESH_Actor::eFreeBorders;
796 aTitle = QObject::tr( "MULTI_BORDERS" );
797 aControl = SMESH_Actor::eMultiConnection;
800 aTitle = QObject::tr( "FREE_NODES" );
801 aControl = SMESH_Actor::eFreeNodes;
804 aTitle = QObject::tr( "MULTI2D_BORDERS" );
805 aControl = SMESH_Actor::eMultiConnection2D;
808 aTitle = QObject::tr( "AREA_ELEMENTS" );
809 aControl = SMESH_Actor::eArea;
812 aTitle = QObject::tr( "TAPER_ELEMENTS" );
813 aControl = SMESH_Actor::eTaper;
816 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
817 aControl = SMESH_Actor::eAspectRatio;
820 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
821 aControl = SMESH_Actor::eAspectRatio3D;
824 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
825 aControl = SMESH_Actor::eMinimumAngle;
828 aTitle = QObject::tr( "WARP_ELEMENTS" );
829 aControl = SMESH_Actor::eWarping;
832 aTitle = QObject::tr( "SKEW_ELEMENTS" );
833 aControl = SMESH_Actor::eSkew;
836 aTitle = QObject::tr( "SMESH_VOLUME" );
837 aControl = SMESH_Actor::eVolume3D;
840 aTitle = QObject::tr( "FREE_FACES" );
841 aControl = SMESH_Actor::eFreeFaces;
844 anActor->SetControlMode(aControl);
845 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
846 SMESH::RepaintCurrentView();
853 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
854 MeshObjectType theType,
855 const QString theInTypeName,
856 QString & theOutTypeName)
858 SMESH_TypeFilter aTypeFilter( theType );
860 if( !theIO.IsNull() )
862 entry = theIO->getEntry();
863 LightApp_DataOwner owner( entry );
864 if ( aTypeFilter.isOk( &owner )) {
865 theOutTypeName = theInTypeName;
873 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
875 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
876 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
878 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
879 CORBA::String_var anID = aSComp->GetID().c_str();
880 if (!strcmp(anID.in(),theIO->getEntry()))
886 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
887 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
888 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
889 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
890 CheckOIType ( theIO, GROUP, "Group", aTypeName )
898 QString CheckHomogeneousSelection()
900 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
901 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
902 SALOME_ListIO selected;
904 aSel->selectedObjects( selected );
906 QString RefType = CheckTypeObject(selected.First());
907 SALOME_ListIteratorOfListIO It(selected);
908 for ( ; It.More(); It.Next())
910 Handle(SALOME_InteractiveObject) IObject = It.Value();
911 QString Type = CheckTypeObject(IObject);
912 if (Type.compare(RefType) != 0)
913 return "Heterogeneous Selection";
920 void SMESHGUI::OnEditDelete()
922 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
923 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
924 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
926 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
927 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
928 _PTR(GenericAttribute) anAttr;
929 _PTR(AttributeIOR) anIOR;
933 QString aParentComponent = QString::null;
934 Handle(SALOME_InteractiveObject) anIO;
935 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
938 QString cur = anIO->getComponentDataType();
939 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
941 // check if object is reference
942 _PTR(SObject) aRefSObj;
943 aNameList.append("\n - ");
944 if ( aSO->ReferencedObject( aRefSObj ) ) {
945 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
946 aNameList.append( aRefName );
947 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
950 aNameList.append(anIO->getName());
954 if( aParentComponent.isNull() )
955 aParentComponent = cur;
956 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
957 aParentComponent = "";
960 if ( objectCount == 0 )
961 return; // No Valid Objects Selected
963 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
964 SUIT_MessageBox::warning( SMESHGUI::desktop(),
965 QObject::tr("ERR_ERROR"),
966 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
969 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
970 if (SUIT_MessageBox::warning
971 (SMESHGUI::desktop(),
972 QObject::tr("SMESH_WRN_WARNING"),
973 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
974 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
975 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
978 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
979 SUIT_ViewManager* vm = anApp->activeViewManager();
980 int nbSf = vm->getViewsCount();
982 SALOME_ListIteratorOfListIO It(selected);
984 aStudyBuilder->NewCommand(); // There is a transaction
985 for( ; It.More(); It.Next()){ // loop on selected IO's
986 Handle(SALOME_InteractiveObject) IObject = It.Value();
987 if(IObject->hasEntry()) {
988 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
990 // disable removal of "SMESH" component object
991 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
993 if ( engineIOR() == anIOR->Value().c_str() )
996 //Check the referenced object
997 _PTR(SObject) aRefSObject;
998 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
999 aSO = aRefSObject; // Delete main Object instead of reference
1001 // put the whole hierarchy of sub-objects of the selected SO into a list and
1002 // then treat them all starting from the deepest objects (at list back)
1004 std::list< _PTR(SObject) > listSO;
1005 listSO.push_back( aSO );
1006 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1007 for ( ; itSO != listSO.end(); ++itSO ) {
1008 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1009 for (it->InitEx(false); it->More(); it->Next())
1010 listSO.push_back( it->Value() );
1013 // treat SO's in the list starting from the back
1015 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1016 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1017 _PTR(SObject) SO = *ritSO;
1018 if ( !SO ) continue;
1019 std::string anEntry = SO->GetID();
1021 /** Erase graphical object **/
1022 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1023 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1024 for(int i = 0; i < nbSf; i++){
1025 SUIT_ViewWindow *sf = aViews[i];
1026 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1027 SMESH::RemoveActor(sf,anActor);
1032 /** Remove an object from data structures **/
1033 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1034 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1035 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1036 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1037 aMesh->RemoveGroup( aGroup );
1039 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1040 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1041 aMesh->RemoveSubMesh( aSubMesh );
1043 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1045 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1048 IObject = new SALOME_InteractiveObject
1049 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1050 QString objType = CheckTypeObject(IObject);
1051 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1052 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1053 aStudyBuilder->RemoveObjectWithChildren( SO );
1055 else {// default action: remove SObject from the study
1056 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1057 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1059 aStudyBuilder->RemoveObjectWithChildren( SO );
1063 } /* listSO back loop */
1064 } /* IObject->hasEntry() */
1066 aStudyBuilder->CommitCommand();
1068 /* Clear any previous selection */
1070 aSel->setSelectedObjects( l1 );
1072 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1077 SMESHGUI_EXPORT CAM_Module* createModule()
1079 return new SMESHGUI();
1083 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1085 //=============================================================================
1089 //=============================================================================
1090 SMESHGUI::SMESHGUI() :
1091 SalomeApp_Module( "SMESH" ),
1092 LightApp_Module( "SMESH" )
1094 if ( CORBA::is_nil( myComponentSMESH ) )
1096 CORBA::Boolean anIsEmbeddedMode;
1097 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1099 // 0019923: EDF 765 SMESH : default values of hypothesis
1100 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1101 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1102 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1103 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1104 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1107 myActiveDialogBox = 0;
1108 myFilterLibraryDlg = 0;
1112 SMESH::GetFilterManager();
1113 SMESH::GetPattern();
1115 /* load resources for all available meshers */
1116 SMESH::InitAvailableHypotheses();
1119 //=============================================================================
1123 //=============================================================================
1124 SMESHGUI::~SMESHGUI()
1126 SMESH::GetFilterManager()->Destroy();
1127 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1130 //=============================================================================
1134 //=============================================================================
1135 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1137 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1139 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1144 bool SMESHGUI::automaticUpdate()
1146 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1150 return resMgr->booleanValue( "SMESH", "auto_update", false );
1153 //=============================================================================
1157 //=============================================================================
1158 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1160 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1163 //=============================================================================
1167 //=============================================================================
1168 SMESHGUI* SMESHGUI::GetSMESHGUI()
1170 SMESHGUI* smeshMod = 0;
1171 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1174 CAM_Module* module = app->module( "Mesh" );
1175 smeshMod = dynamic_cast<SMESHGUI*>( module );
1178 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1180 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1183 _PTR(Study) aStudy = study->studyDS();
1185 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1194 Standard_EXPORT SMESHGUI* GetComponentGUI()
1196 return SMESHGUI::GetSMESHGUI();
1200 //=============================================================================
1204 //=============================================================================
1205 void SMESHGUI::SetState(int aState)
1210 //=============================================================================
1214 //=============================================================================
1215 void SMESHGUI::ResetState()
1220 //=============================================================================
1224 //=============================================================================
1225 void SMESHGUI::EmitSignalDeactivateDialog()
1227 emit SignalDeactivateActiveDialog();
1230 //=============================================================================
1234 //=============================================================================
1235 void SMESHGUI::EmitSignalStudyFrameChanged()
1237 emit SignalStudyFrameChanged();
1240 //=============================================================================
1244 //=============================================================================
1245 void SMESHGUI::EmitSignalCloseAllDialogs()
1247 emit SignalCloseAllDialogs();
1250 //=============================================================================
1254 //=============================================================================
1255 void SMESHGUI::EmitSignalVisibilityChanged()
1257 emit SignalVisibilityChanged();
1260 //=============================================================================
1264 //=============================================================================
1265 QDialog *SMESHGUI::GetActiveDialogBox()
1267 return myActiveDialogBox;
1270 //=============================================================================
1274 //=============================================================================
1275 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1277 myActiveDialogBox = (QDialog *) aDlg;
1281 //=============================================================================
1285 //=============================================================================
1286 SUIT_Desktop* SMESHGUI::desktop()
1288 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1290 return app->desktop();
1295 //=============================================================================
1299 //=============================================================================
1300 SalomeApp_Study* SMESHGUI::activeStudy()
1302 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1304 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1309 //=============================================================================
1313 //=============================================================================
1314 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1316 /* Here the position is on the bottom right corner - 10 */
1317 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1319 SUIT_Desktop *PP = desktop();
1320 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1321 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1325 //=============================================================================
1329 //=============================================================================
1330 static int isStudyLocked(_PTR(Study) theStudy){
1331 return theStudy->GetProperties()->IsLocked();
1334 static bool checkLock(_PTR(Study) theStudy) {
1335 if (isStudyLocked(theStudy)) {
1336 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1337 QObject::tr("WRN_WARNING"),
1338 QObject::tr("WRN_STUDY_LOCKED") );
1344 //=======================================================================
1345 //function : CheckActiveStudyLocked
1347 //=======================================================================
1349 bool SMESHGUI::isActiveStudyLocked()
1351 _PTR(Study) aStudy = activeStudy()->studyDS();
1352 return checkLock( aStudy );
1355 //=============================================================================
1359 //=============================================================================
1360 bool SMESHGUI::OnGUIEvent( int theCommandID )
1362 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1366 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1367 SUIT_ResourceMgr* mgr = resourceMgr();
1371 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1372 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1375 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1376 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1378 //QAction* act = action( theCommandID );
1380 switch (theCommandID) {
1382 if(checkLock(aStudy)) break;
1390 if(checkLock(aStudy)) break;
1391 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1395 case 150: //MED FILE INFORMATION
1397 SALOME_ListIO selected;
1398 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1400 aSel->selectedObjects( selected );
1401 if( selected.Extent() )
1403 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1404 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1405 if ( !aMesh->_is_nil() )
1407 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1414 case 122: // EXPORT MED
1423 ::ExportMeshToFile(theCommandID);
1427 case 200: // SCALAR BAR
1429 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1430 SALOME_ListIO selected;
1432 aSel->selectedObjects( selected );
1434 if( selected.Extent() ) {
1435 Handle(SALOME_InteractiveObject) anIO = selected.First();
1436 if( anIO->hasEntry() ) {
1437 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1438 anActor->SetControlMode( SMESH_Actor::eNone );
1446 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1456 ::DisableAutoColor();
1459 case 1134: // Clipping
1460 case 1133: // Tranparency
1461 case 1132: // Colors / Size
1468 ::SetDisplayMode(theCommandID);
1471 //2D quadratic representation
1474 ::SetDisplayMode(theCommandID);
1478 case 216: // 0D elements
1481 case 219: // Volumes
1482 case 220: // All Entity
1483 ::SetDisplayEntity(theCommandID);
1486 case 221: // Orientation of faces
1488 LightApp_SelectionMgr* mgr = selectionMgr();
1489 SALOME_ListIO selected; mgr->selectedObjects( selected );
1491 SALOME_ListIteratorOfListIO it(selected);
1492 for( ; it.More(); it.Next()) {
1493 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1494 if(anIObject->hasEntry()) {
1495 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1496 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1505 if(checkLock(aStudy)) break;
1507 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1510 SMESH::UpdateView();
1512 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1513 SMESH::OnVisuException();
1515 catch (...) { // PAL16774 (Crash after display of many groups)
1516 SMESH::OnVisuException();
1520 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1521 aSel->selectedObjects( l );
1522 aSel->setSelectedObjects( l );
1527 case 301: // DISPLAY
1528 case 302: // DISPLAY ONLY
1530 SMESH::EDisplaing anAction;
1531 switch (theCommandID) {
1532 case 300: anAction = SMESH::eErase; break;
1533 case 301: anAction = SMESH::eDisplay; break;
1534 case 302: anAction = SMESH::eDisplayOnly; break;
1537 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1538 SALOME_ListIO sel_objects, to_process;
1540 aSel->selectedObjects( sel_objects );
1542 if( theCommandID==302 )
1543 startOperation( myEraseAll );
1545 extractContainers( sel_objects, to_process );
1548 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1552 SALOME_ListIteratorOfListIO It( to_process );
1553 for ( ; It.More(); It.Next()) {
1554 Handle(SALOME_InteractiveObject) IOS = It.Value();
1555 if (IOS->hasEntry()) {
1556 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1557 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1558 break; // PAL16774 (Crash after display of many groups)
1560 if (anAction == SMESH::eDisplayOnly)
1561 anAction = SMESH::eDisplay;
1566 // PAL13338 + PAL15161 -->
1567 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1568 SMESH::UpdateView();
1569 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1571 // PAL13338 + PAL15161 <--
1573 catch (...) { // PAL16774 (Crash after display of many groups)
1574 SMESH::OnVisuException();
1577 if (anAction == SMESH::eErase) {
1579 aSel->setSelectedObjects( l1 );
1582 aSel->setSelectedObjects( to_process );
1589 if(checkLock(aStudy)) break;
1592 EmitSignalDeactivateDialog();
1594 ( new SMESHGUI_NodesDlg( this ) )->show();
1597 SUIT_MessageBox::warning(desktop(),
1598 tr("SMESH_WRN_WARNING"),
1599 tr("SMESH_WRN_VIEWER_VTK"));
1604 case 2151: // FILTER
1608 EmitSignalDeactivateDialog();
1609 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1614 case 406: // MOVE NODE
1618 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1619 tr( "NOT_A_VTK_VIEWER" ) );
1623 if(checkLock(aStudy)) break;
1624 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1628 case 701: // COMPUTE MESH
1629 case 711: // PRECOMPUTE MESH
1630 case 712: // EVALUATE MESH
1631 case 713: // MESH ORDER
1633 if (checkLock(aStudy)) break;
1634 startOperation( theCommandID );
1638 case 702: // Create mesh
1639 case 703: // Create sub-mesh
1640 case 704: // Edit mesh/sub-mesh
1641 startOperation( theCommandID );
1643 case 710: // Build compound mesh
1645 if (checkLock(aStudy)) break;
1646 EmitSignalDeactivateDialog();
1647 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1651 case 407: // DIAGONAL INVERSION
1652 case 408: // Delete diagonal
1656 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1657 tr( "NOT_A_VTK_VIEWER" ) );
1661 if ( checkLock( aStudy ) )
1664 /*Standard_Boolean aRes;
1665 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1666 if ( aMesh->_is_nil() )
1668 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1669 tr( "SMESH_BAD_SELECTION" ) );
1673 EmitSignalDeactivateDialog();
1674 if ( theCommandID == 407 )
1675 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1677 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1680 case 409: // Change orientation
1681 case 410: // Union of triangles
1682 case 411: // Cutting of quadrangles
1686 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1687 tr( "NOT_A_VTK_VIEWER" ) );
1691 if ( checkLock( aStudy ) )
1694 EmitSignalDeactivateDialog();
1695 SMESHGUI_MultiEditDlg* aDlg = NULL;
1696 if ( theCommandID == 409 )
1697 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1698 else if ( theCommandID == 410 )
1699 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1701 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1706 case 412: // Smoothing
1708 if(checkLock(aStudy)) break;
1710 EmitSignalDeactivateDialog();
1711 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1714 SUIT_MessageBox::warning(desktop(),
1715 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1719 case 413: // Extrusion
1721 if (checkLock(aStudy)) break;
1723 EmitSignalDeactivateDialog();
1724 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1726 SUIT_MessageBox::warning(desktop(),
1727 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1731 case 414: // Revolution
1733 if(checkLock(aStudy)) break;
1735 EmitSignalDeactivateDialog();
1736 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1739 SUIT_MessageBox::warning(desktop(),
1740 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1744 case 415: // Pattern mapping
1746 if ( checkLock( aStudy ) )
1750 EmitSignalDeactivateDialog();
1751 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1754 SUIT_MessageBox::warning(desktop(),
1755 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1759 case 416: // Extrusion along a path
1761 if (checkLock(aStudy)) break;
1763 EmitSignalDeactivateDialog();
1764 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1766 SUIT_MessageBox::warning(desktop(),
1767 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1771 case 417: // Convert mesh to quadratic
1773 startOperation( 417 );
1774 /* if (checkLock(aStudy)) break;
1776 EmitSignalDeactivateDialog();
1777 new SMESHGUI_ConvToQuadDlg();
1779 SUIT_MessageBox::warning(desktop(),
1780 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1784 case 418: // create 2D mesh from 3D
1786 startOperation( 418 );
1789 case 806: // CREATE GEO GROUP
1791 startOperation( 806 );
1794 case 801: // CREATE GROUP
1798 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1799 tr( "NOT_A_VTK_VIEWER" ) );
1803 if(checkLock(aStudy)) break;
1804 EmitSignalDeactivateDialog();
1805 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1807 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1808 SALOME_ListIO selected;
1810 aSel->selectedObjects( selected );
1812 int nbSel = selected.Extent();
1814 // check if mesh is selected
1815 aMesh = SMESH::GetMeshByIO( selected.First() );
1817 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1822 case 802: // CONSTRUCT GROUP
1826 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1827 tr( "NOT_A_VTK_VIEWER" ) );
1831 if(checkLock(aStudy)) break;
1832 EmitSignalDeactivateDialog();
1834 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1835 SALOME_ListIO selected;
1837 aSel->selectedObjects( selected );
1839 int nbSel = selected.Extent();
1841 // check if submesh is selected
1842 Handle(SALOME_InteractiveObject) IObject = selected.First();
1843 if (IObject->hasEntry()) {
1844 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1846 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1847 if (!aSubMesh->_is_nil()) {
1849 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1850 // get submesh elements list by types
1851 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1852 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1853 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1854 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1855 // create group for each type o elements
1856 QString aName = IObject->getName();
1857 if (aNodes->length() > 0) {
1858 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1859 aGroup->Add(aNodes.inout());
1861 if (aEdges->length() > 0) {
1862 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1863 aGroup->Add(aEdges.inout());
1865 if (aFaces->length() > 0) {
1866 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1867 aGroup->Add(aFaces.inout());
1869 if (aVolumes->length() > 0) {
1870 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1871 aGroup->Add(aVolumes.inout());
1876 catch(const SALOME::SALOME_Exception & S_ex){
1877 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1884 SUIT_MessageBox::warning(desktop(),
1885 tr("SMESH_WRN_WARNING"),
1886 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1891 case 803: // EDIT GROUP
1895 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1896 tr( "NOT_A_VTK_VIEWER" ) );
1900 if(checkLock(aStudy)) break;
1901 EmitSignalDeactivateDialog();
1903 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1904 SALOME_ListIO selected;
1906 aSel->selectedObjects( selected );
1908 SALOME_ListIteratorOfListIO It (selected);
1909 int nbSelectedGroups = 0;
1910 for ( ; It.More(); It.Next() )
1912 SMESH::SMESH_GroupBase_var aGroup =
1913 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1914 if (!aGroup->_is_nil()) {
1916 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1920 if (nbSelectedGroups == 0)
1922 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1928 case 804: // Add elements to group
1930 if(checkLock(aStudy)) break;
1931 if (myState == 800) {
1932 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1933 if (aDlg) aDlg->onAdd();
1938 case 805: // Remove elements from group
1940 if(checkLock(aStudy)) break;
1941 if (myState == 800) {
1942 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1943 if (aDlg) aDlg->onRemove();
1948 case 815: // Edit GEOM GROUP as standalone
1952 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1953 tr( "NOT_A_VTK_VIEWER" ) );
1957 if(checkLock(aStudy)) break;
1958 EmitSignalDeactivateDialog();
1960 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1961 SALOME_ListIO selected;
1963 aSel->selectedObjects( selected );
1965 SALOME_ListIteratorOfListIO It (selected);
1966 for ( ; It.More(); It.Next() )
1968 SMESH::SMESH_GroupOnGeom_var aGroup =
1969 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
1970 if (!aGroup->_is_nil()) {
1971 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
1978 case 810: // Union Groups
1979 case 811: // Intersect groups
1980 case 812: // Cut groups
1984 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1985 tr( "NOT_A_VTK_VIEWER" ) );
1989 if ( checkLock( aStudy ) )
1992 EmitSignalDeactivateDialog();
1994 SMESHGUI_GroupOpDlg* aDlg = 0;
1995 if ( theCommandID == 810 )
1996 aDlg = new SMESHGUI_UnionGroupsDlg( this );
1997 else if ( theCommandID == 811 )
1998 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2000 aDlg = new SMESHGUI_CutGroupsDlg( this );
2007 case 814: // Create groups of entities from existing groups of superior dimensions
2009 if ( checkLock( aStudy ) )
2012 EmitSignalDeactivateDialog();
2013 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2019 case 813: // Delete groups with their contents
2023 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2024 tr( "NOT_A_VTK_VIEWER" ) );
2028 if ( checkLock( aStudy ) )
2031 EmitSignalDeactivateDialog();
2033 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2037 case 900: // MESH INFOS
2039 EmitSignalDeactivateDialog();
2040 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2041 SALOME_ListIO selected;
2043 aSel->selectedObjects( selected );
2045 if ( selected.Extent() > 1 ) { // a dlg for each IO
2047 SALOME_ListIteratorOfListIO It (selected);
2048 for ( ; It.More(); It.Next() ) {
2049 IOs.Clear(); IOs.Append( It.Value() );
2050 aSel->setSelectedObjects( IOs );
2051 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2053 // restore selection
2054 aSel->setSelectedObjects( selected );
2057 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2061 case 902: // STANDARD MESH INFOS
2063 EmitSignalDeactivateDialog();
2064 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2065 SALOME_ListIO selected;
2067 aSel->selectedObjects( selected );
2069 if ( selected.Extent() > 1 ) { // a dlg for each IO
2071 SALOME_ListIteratorOfListIO It (selected);
2072 for ( ; It.More(); It.Next() ) {
2074 IOs.Append( It.Value() );
2075 aSel->setSelectedObjects( IOs );
2076 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2078 // restore selection
2079 aSel->setSelectedObjects( selected );
2082 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2086 case 903: // WHAT IS
2088 EmitSignalDeactivateDialog();
2089 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2093 case 904: // FIND ELEM
2095 startOperation( theCommandID );
2099 case 1100: // EDIT HYPOTHESIS
2101 if(checkLock(aStudy)) break;
2103 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2104 SALOME_ListIO selected;
2106 aSel->selectedObjects( selected );
2108 int nbSel = selected.Extent();
2111 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2112 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2114 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2115 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2116 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2117 if ( !aHypothesis->_is_nil() )
2120 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2121 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2123 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2134 case 1101: // RENAME
2136 if ( checkLock( aStudy ) )
2139 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2140 SALOME_ListIO selected;
2142 aSel->selectedObjects( selected );
2144 bool isAny = false; // is there any appropriate object selected
2146 SALOME_ListIteratorOfListIO It( selected );
2147 for ( ; It.More(); It.Next() )
2149 Handle(SALOME_InteractiveObject) IObject = It.Value();
2150 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2151 _PTR(GenericAttribute) anAttr;
2152 _PTR(AttributeName) aName;
2155 if ( obj->FindAttribute(anAttr, "AttributeName") )
2158 QString newName = QString(aName->Value().c_str());
2160 // check type to prevent renaming of inappropriate objects
2161 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2162 if (aType == MESH || aType == GROUP ||
2163 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2164 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2165 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2166 aType == HYPOTHESIS || aType == ALGORITHM)
2169 newName = LightApp_NameDlg::getName(desktop(), newName);
2170 if ( !newName.isEmpty() )
2172 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2174 // update name of group object and its actor
2175 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2176 if( !aGroupObject->_is_nil() )
2178 aGroupObject->SetName( newName.toLatin1().data() );
2179 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2180 anActor->setName( newName.toLatin1().data() );
2191 SUIT_MessageBox::warning(desktop(),
2192 QObject::tr("SMESH_WRN_WARNING"),
2193 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2198 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2200 if(checkLock(aStudy)) break;
2201 SUIT_OverrideCursor wc;
2203 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2204 SALOME_ListIO selected;
2206 aSel->selectedObjects( selected, QString::null, false );
2208 SALOME_ListIteratorOfListIO It(selected);
2209 for (int i = 0; It.More(); It.Next(), i++) {
2210 Handle(SALOME_InteractiveObject) IObject = It.Value();
2211 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2214 aSel->setSelectedObjects( l1 );
2219 case 4009: // ELEM0D
2220 case 4010: // GEOM::EDGE
2221 case 4021: // TRIANGLE
2223 case 4023: // POLYGON
2227 if(checkLock(aStudy)) break;
2229 EmitSignalDeactivateDialog();
2230 SMDSAbs_ElementType type = SMDSAbs_Edge;
2232 switch (theCommandID) {
2233 case 4009: // ELEM0D
2234 type = SMDSAbs_0DElement; nbNodes = 1; break;
2235 case 4021: // TRIANGLE
2236 type = SMDSAbs_Face; nbNodes = 3; break;
2238 type = SMDSAbs_Face; nbNodes = 4; break;
2240 type = SMDSAbs_Volume; nbNodes = 4; break;
2241 case 4023: // POLYGON
2242 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2244 type = SMDSAbs_Volume; nbNodes = 8; break;
2245 case 4033: // POLYHEDRE
2246 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2249 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2252 SUIT_MessageBox::warning(desktop(),
2253 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2257 case 4033: // POLYHEDRON
2259 if(checkLock(aStudy)) break;
2261 EmitSignalDeactivateDialog();
2262 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2265 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2266 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2270 case 4034: // QUADRATIC EDGE
2271 case 4035: // QUADRATIC TRIANGLE
2272 case 4036: // QUADRATIC QUADRANGLE
2273 case 4037: // QUADRATIC TETRAHEDRON
2274 case 4038: // QUADRATIC PYRAMID
2275 case 4039: // QUADRATIC PENTAHEDRON
2276 case 4040: // QUADRATIC HEXAHEDRON
2278 if(checkLock(aStudy)) break;
2280 EmitSignalDeactivateDialog();
2283 switch (theCommandID) {
2285 type = QUAD_EDGE; break;
2287 type = QUAD_TRIANGLE; break;
2289 type = QUAD_QUADRANGLE; break;
2291 type = QUAD_TETRAHEDRON; break;
2293 type = QUAD_PYRAMID; break;
2295 type = QUAD_PENTAHEDRON; break;
2297 type = QUAD_HEXAHEDRON;
2301 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2304 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2305 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2309 case 4041: // REMOVES NODES
2311 if(checkLock(aStudy)) break;
2313 EmitSignalDeactivateDialog();
2314 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2317 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2318 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2322 case 4042: // REMOVES ELEMENTS
2324 if(checkLock(aStudy)) break;
2326 EmitSignalDeactivateDialog();
2327 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2331 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2332 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2336 case 4043: { // CLEAR_MESH
2338 if(checkLock(aStudy)) break;
2340 SALOME_ListIO selected;
2341 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2342 aSel->selectedObjects( selected );
2344 SUIT_OverrideCursor wc;
2345 SALOME_ListIteratorOfListIO It (selected);
2346 for ( ; It.More(); It.Next() )
2348 Handle(SALOME_InteractiveObject) IOS = It.Value();
2349 SMESH::SMESH_Mesh_var aMesh =
2350 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2351 if ( aMesh->_is_nil()) continue;
2353 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2355 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2356 SMESH::ModifiedMesh( aMeshSObj, false, true);
2357 // hide groups and submeshes
2358 _PTR(ChildIterator) anIter =
2359 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2360 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2362 _PTR(SObject) so = anIter->Value();
2363 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2366 catch (const SALOME::SALOME_Exception& S_ex){
2368 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2372 SMESH::UpdateView();
2376 case 4051: // RENUMBERING NODES
2378 if(checkLock(aStudy)) break;
2380 EmitSignalDeactivateDialog();
2381 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2385 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2386 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2390 case 4052: // RENUMBERING ELEMENTS
2392 if(checkLock(aStudy)) break;
2394 EmitSignalDeactivateDialog();
2395 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2399 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2404 case 4061: // TRANSLATION
2406 if(checkLock(aStudy)) break;
2408 EmitSignalDeactivateDialog();
2409 ( new SMESHGUI_TranslationDlg( this ) )->show();
2412 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2413 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2417 case 4062: // ROTATION
2419 if(checkLock(aStudy)) break;
2421 EmitSignalDeactivateDialog();
2422 ( new SMESHGUI_RotationDlg( this ) )->show();
2425 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2426 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2430 case 4063: // SYMMETRY
2432 if(checkLock(aStudy)) break;
2434 EmitSignalDeactivateDialog();
2435 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2438 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2439 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2443 case 4064: // SEWING
2445 if(checkLock(aStudy)) break;
2447 EmitSignalDeactivateDialog();
2448 ( new SMESHGUI_SewingDlg( this ) )->show();
2451 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2452 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2456 case 4065: // MERGE NODES
2458 if(checkLock(aStudy)) break;
2460 EmitSignalDeactivateDialog();
2461 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2464 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2469 case 4066: // MERGE EQUAL ELEMENTS
2471 if (checkLock(aStudy)) break;
2473 EmitSignalDeactivateDialog();
2474 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2476 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2477 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2482 case 4067: // MAKE MESH PASS THROUGH POINT
2483 startOperation( 4067 );
2486 case 5105: // Library of selection filters
2488 static QList<int> aTypes;
2489 if ( aTypes.isEmpty() )
2491 aTypes.append( SMESH::NODE );
2492 aTypes.append( SMESH::EDGE );
2493 aTypes.append( SMESH::FACE );
2494 aTypes.append( SMESH::VOLUME );
2496 if (!myFilterLibraryDlg)
2497 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2498 else if (myFilterLibraryDlg->isHidden())
2499 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2500 myFilterLibraryDlg->raise();
2504 case 6017: // CONTROLS
2522 LightApp_SelectionMgr* mgr = selectionMgr();
2523 SALOME_ListIO selected; mgr->selectedObjects( selected );
2525 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2526 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2528 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2529 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2530 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2531 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2532 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2533 ::Control( theCommandID );
2538 SUIT_MessageBox::warning(desktop(),
2539 tr( "SMESH_WRN_WARNING" ),
2540 tr( "SMESH_BAD_SELECTION" ) );
2544 SUIT_MessageBox::warning(desktop(),
2545 tr( "SMESH_WRN_WARNING" ),
2546 tr( "NOT_A_VTK_VIEWER" ) );
2551 LightApp_SelectionMgr* mgr = selectionMgr();
2552 SALOME_ListIO selected; mgr->selectedObjects( selected );
2554 SALOME_ListIteratorOfListIO it(selected);
2555 for( ; it.More(); it.Next()) {
2556 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2557 if(anIObject->hasEntry()) {
2558 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2559 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2567 LightApp_SelectionMgr* mgr = selectionMgr();
2568 SALOME_ListIO selected; mgr->selectedObjects( selected );
2570 if (selected.Extent() == 1) {
2571 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2572 if(anIObject->hasEntry())
2573 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2574 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2581 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2582 //updateObjBrowser();
2586 //=============================================================================
2590 //=============================================================================
2591 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2596 //=============================================================================
2600 //=============================================================================
2601 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2606 //=============================================================================
2610 //=============================================================================
2611 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2616 //=============================================================================
2617 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2618 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2620 //=============================================================================
2621 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2622 SUIT_ViewWindow* wnd )
2624 if(theIO->hasEntry()){
2625 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2626 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2630 //=======================================================================
2631 // function : createSMESHAction
2633 //=======================================================================
2634 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2637 QWidget* parent = application()->desktop();
2638 SUIT_ResourceMgr* resMgr = resourceMgr();
2640 if ( !icon_id.isEmpty() )
2641 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2643 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2644 if ( !pix.isNull() )
2645 icon = QIcon( pix );
2647 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2648 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2649 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2651 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2654 //=======================================================================
2655 // function : createPopupItem
2657 //=======================================================================
2658 void SMESHGUI::createPopupItem( const int id,
2659 const QString& clients,
2660 const QString& types,
2661 const QString& theRule,
2666 parentId = popupMgr()->actionId( action( pId ) );
2668 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2669 popupMgr()->insert( action( id ), parentId, 0 );
2671 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2672 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2673 QString rule = "(%1) and (%2) and (%3)";
2674 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2675 if( clients.isEmpty() )
2676 rule = rule.arg( QString( "true" ) );
2678 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2679 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2682 bool cont = myRules.contains( id );
2684 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2686 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2687 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2690 //=======================================================================
2691 // function : initialize
2693 //=======================================================================
2694 void SMESHGUI::initialize( CAM_Application* app )
2696 SalomeApp_Module::initialize( app );
2698 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2700 /* Automatic Update flag */
2701 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2703 // ----- create actions --------------
2705 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2706 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2707 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2708 createSMESHAction( 114, "NUM" );
2709 createSMESHAction( 121, "DAT" );
2710 createSMESHAction( 122, "MED" );
2711 createSMESHAction( 123, "UNV" );
2712 createSMESHAction( 140, "STL" );
2713 createSMESHAction( 124, "EXPORT_DAT" );
2714 createSMESHAction( 125, "EXPORT_MED" );
2715 createSMESHAction( 126, "EXPORT_UNV" );
2716 createSMESHAction( 141, "EXPORT_STL" );
2717 createSMESHAction( 150, "FILE_INFO" );
2718 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2719 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2720 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2721 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2722 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2723 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2724 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2725 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2726 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2727 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2728 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2729 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2730 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2731 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2732 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2733 createSMESHAction( 804, "ADD" );
2734 createSMESHAction( 805, "REMOVE" );
2735 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2736 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2737 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2738 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2739 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2740 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2741 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2742 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2743 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2744 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2745 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2746 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2747 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2748 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2749 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2750 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2751 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2752 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2753 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2754 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2755 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2756 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2757 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2758 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2759 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2760 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2761 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2762 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2763 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2764 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2765 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2766 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2767 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2768 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2769 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2770 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2771 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2772 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2773 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2774 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2775 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2776 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2777 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2778 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2779 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2780 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2781 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2782 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2783 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2784 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2785 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2786 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2787 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2788 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2789 createSMESHAction( 415, "MAP", "ICON_MAP" );
2790 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2791 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2792 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2793 createSMESHAction( 200, "RESET" );
2794 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2795 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2796 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2797 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2798 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2799 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2800 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2801 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2802 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2803 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2804 createSMESHAction( 220, "ALL" );
2805 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2807 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2808 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2810 createSMESHAction( 1100, "EDIT_HYPO" );
2811 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2812 createSMESHAction( 1102, "UNASSIGN" );
2813 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2814 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2815 createSMESHAction( 1131, "DISPMODE" );
2816 createSMESHAction( 1132, "COLORS" );
2817 createSMESHAction( 1133, "TRANSP" );
2818 createSMESHAction( 1134, "CLIP" );
2819 createSMESHAction( 1135, "DISP_ENT" );
2820 createSMESHAction( 1136, "AUTO_COLOR" );
2821 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2822 createSMESHAction( 2000, "CTRL" );
2824 createSMESHAction( 300, "ERASE" );
2825 createSMESHAction( 301, "DISPLAY" );
2826 createSMESHAction( 302, "DISPLAY_ONLY" );
2827 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2828 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2829 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2830 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2831 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2832 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2833 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2834 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2836 // ----- create menu --------------
2837 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2838 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2839 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2840 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2841 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2842 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2843 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2845 createMenu( separator(), fileId );
2847 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2848 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2849 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2850 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2851 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2852 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2854 createMenu( 111, importId, -1 );
2855 createMenu( 112, importId, -1 );
2856 createMenu( 113, importId, -1 );
2858 createMenu( 121, exportId, -1 );
2859 createMenu( 122, exportId, -1 );
2860 createMenu( 123, exportId, -1 );
2861 createMenu( 140, exportId, -1 ); // export to stl STL
2863 createMenu( separator(), fileId, 10 );
2865 createMenu( 33, editId, -1 );
2867 createMenu( 5105, toolsId, -1 );
2869 createMenu( 702, meshId, -1 ); // "Mesh" menu
2870 createMenu( 703, meshId, -1 );
2871 createMenu( 704, meshId, -1 );
2872 createMenu( 710, meshId, -1 );
2873 createMenu( separator(), meshId, -1 );
2874 createMenu( 701, meshId, -1 );
2875 createMenu( 711, meshId, -1 );
2876 createMenu( 712, meshId, -1 );
2877 createMenu( 713, meshId, -1 );
2878 createMenu( separator(), meshId, -1 );
2879 createMenu( 801, meshId, -1 );
2880 createMenu( 806, meshId, -1 );
2881 createMenu( 802, meshId, -1 );
2882 createMenu( 803, meshId, -1 );
2883 createMenu( 815, meshId, -1 );
2884 createMenu( separator(), meshId, -1 );
2885 createMenu( 810, meshId, -1 );
2886 createMenu( 811, meshId, -1 );
2887 createMenu( 812, meshId, -1 );
2888 createMenu( separator(), meshId, -1 );
2889 createMenu( 814, meshId, -1 );
2890 createMenu( separator(), meshId, -1 );
2891 createMenu( 813, meshId, -1 );
2892 createMenu( separator(), meshId, -1 );
2893 createMenu( 900, meshId, -1 );
2894 createMenu( 902, meshId, -1 );
2895 createMenu( 903, meshId, -1 );
2896 createMenu( 904, meshId, -1 );
2897 createMenu( separator(), meshId, -1 );
2899 createMenu( 6003, ctrlId, -1 );
2900 createMenu( 6001, ctrlId, -1 );
2901 createMenu( 6004, ctrlId, -1 );
2902 createMenu( separator(), ctrlId, -1 );
2903 createMenu( 6005, ctrlId, -1 );
2904 createMenu( 6002, ctrlId, -1 );
2905 createMenu( 6018, ctrlId, -1 );
2906 createMenu( 6019, ctrlId, -1 );
2907 createMenu( 6011, ctrlId, -1 );
2908 createMenu( 6012, ctrlId, -1 );
2909 createMenu( 6013, ctrlId, -1 );
2910 createMenu( 6014, ctrlId, -1 );
2911 createMenu( 6015, ctrlId, -1 );
2912 createMenu( 6016, ctrlId, -1 );
2913 createMenu( separator(), ctrlId, -1 );
2914 createMenu( 6017, ctrlId, -1 );
2915 createMenu( 6009, ctrlId, -1 );
2916 createMenu( 6021, ctrlId, -1 );
2917 createMenu( separator(), ctrlId, -1 );
2919 createMenu( 4000, addId, -1 );
2920 createMenu( 4009, addId, -1 );
2921 createMenu( 4010, addId, -1 );
2922 createMenu( 4021, addId, -1 );
2923 createMenu( 4022, addId, -1 );
2924 createMenu( 4023, addId, -1 );
2925 createMenu( 4031, addId, -1 );
2926 createMenu( 4032, addId, -1 );
2927 createMenu( 4033, addId, -1 );
2928 createMenu( separator(), addId, -1 );
2929 createMenu( 4034, addId, -1 );
2930 createMenu( 4035, addId, -1 );
2931 createMenu( 4036, addId, -1 );
2932 createMenu( 4037, addId, -1 );
2933 createMenu( 4038, addId, -1 );
2934 createMenu( 4039, addId, -1 );
2935 createMenu( 4040, addId, -1 );
2937 createMenu( 4041, removeId, -1 );
2938 createMenu( 4042, removeId, -1 );
2939 createMenu( 4043, removeId, -1 );
2941 createMenu( 4051, renumId, -1 );
2942 createMenu( 4052, renumId, -1 );
2944 createMenu( 4061, transfId, -1 );
2945 createMenu( 4062, transfId, -1 );
2946 createMenu( 4063, transfId, -1 );
2947 createMenu( 4064, transfId, -1 );
2948 createMenu( 4065, transfId, -1 );
2949 createMenu( 4066, transfId, -1 );
2951 createMenu( 406, modifyId, -1 );
2952 createMenu( 4067,modifyId, -1 );
2953 createMenu( 407, modifyId, -1 );
2954 createMenu( 408, modifyId, -1 );
2955 createMenu( 409, modifyId, -1 );
2956 createMenu( 410, modifyId, -1 );
2957 createMenu( 411, modifyId, -1 );
2958 createMenu( 412, modifyId, -1 );
2959 createMenu( 413, modifyId, -1 );
2960 createMenu( 416, modifyId, -1 );
2961 createMenu( 414, modifyId, -1 );
2962 createMenu( 415, modifyId, -1 );
2963 createMenu( 417, modifyId, -1 );
2964 createMenu( 418, modifyId, -1 );
2966 createMenu( 214, viewId, -1 );
2968 // ----- create toolbars --------------
2969 int meshTb = createTool( tr( "TB_MESH" ) ),
2970 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2971 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2972 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2973 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2975 createTool( 702, meshTb );
2976 createTool( 703, meshTb );
2977 createTool( 704, meshTb );
2978 createTool( 710, meshTb );
2979 createTool( separator(), meshTb );
2980 createTool( 701, meshTb );
2981 createTool( 711, meshTb );
2982 createTool( 712, meshTb );
2983 createTool( 713, meshTb );
2984 createTool( separator(), meshTb );
2985 createTool( 801, meshTb );
2986 createTool( 806, meshTb );
2987 createTool( 802, meshTb );
2988 createTool( 803, meshTb );
2989 //createTool( 815, meshTb );
2990 createTool( separator(), meshTb );
2991 createTool( 900, meshTb );
2992 createTool( 902, meshTb );
2993 createTool( 903, meshTb );
2994 createTool( 904, meshTb );
2995 createTool( separator(), meshTb );
2997 createTool( 6001, ctrlTb );
2998 createTool( 6003, ctrlTb );
2999 createTool( 6004, ctrlTb );
3000 createTool( separator(), ctrlTb );
3001 createTool( 6005, ctrlTb );
3002 createTool( 6002, ctrlTb );
3003 createTool( 6018, ctrlTb );
3004 createTool( 6019, ctrlTb );
3005 createTool( 6011, ctrlTb );
3006 createTool( 6012, ctrlTb );
3007 createTool( 6013, ctrlTb );
3008 createTool( 6014, ctrlTb );
3009 createTool( 6015, ctrlTb );
3010 createTool( 6016, ctrlTb );
3011 createTool( separator(), ctrlTb );
3012 createTool( 6017, ctrlTb );
3013 createTool( 6009, ctrlTb );
3014 createTool( 6021, ctrlTb );
3015 createTool( separator(), ctrlTb );
3017 createTool( 4000, addRemTb );
3018 createTool( 4009, addRemTb );
3019 createTool( 4010, addRemTb );
3020 createTool( 4021, addRemTb );
3021 createTool( 4022, addRemTb );
3022 createTool( 4023, addRemTb );
3023 createTool( 4031, addRemTb );
3024 createTool( 4032, addRemTb );
3025 createTool( 4033, addRemTb );
3026 createTool( separator(), addRemTb );
3027 createTool( 4034, addRemTb );
3028 createTool( 4035, addRemTb );
3029 createTool( 4036, addRemTb );
3030 createTool( 4037, addRemTb );
3031 createTool( 4038, addRemTb );
3032 createTool( 4039, addRemTb );
3033 createTool( 4040, addRemTb );
3034 createTool( separator(), addRemTb );
3035 createTool( 4041, addRemTb );
3036 createTool( 4042, addRemTb );
3037 createTool( 4043, addRemTb );
3038 createTool( separator(), addRemTb );
3039 createTool( 4051, addRemTb );
3040 createTool( 4052, addRemTb );
3041 createTool( separator(), addRemTb );
3042 createTool( 4061, addRemTb );
3043 createTool( 4062, addRemTb );
3044 createTool( 4063, addRemTb );
3045 createTool( 4064, addRemTb );
3046 createTool( 4065, addRemTb );
3047 createTool( 4066, addRemTb );
3048 createTool( separator(), addRemTb );
3050 createTool( 406, modifyTb );
3051 createTool( 4067,modifyTb );
3052 createTool( 407, modifyTb );
3053 createTool( 408, modifyTb );
3054 createTool( 409, modifyTb );
3055 createTool( 410, modifyTb );
3056 createTool( 411, modifyTb );
3057 createTool( 412, modifyTb );
3058 createTool( 413, modifyTb );
3059 createTool( 416, modifyTb );
3060 createTool( 414, modifyTb );
3061 createTool( 415, modifyTb );
3062 createTool( 417, modifyTb );
3063 createTool( 418, modifyTb );
3065 createTool( 214, dispModeTb );
3067 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3068 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3071 QString OB = "'ObjectBrowser'",
3072 View = "'" + SVTK_Viewer::Type() + "'",
3074 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3075 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3076 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3077 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3078 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3079 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3080 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3081 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3082 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3083 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3084 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3086 mesh_group = mesh + " " + subMesh + " " + group,
3087 hyp_alg = hypo + " " + algo;
3089 // popup for object browser
3091 isInvisible("not( isVisible )"),
3092 isEmpty("numberOfNodes = 0"),
3093 isNotEmpty("numberOfNodes <> 0"),
3095 // has nodes, edges, etc in VISIBLE! actor
3096 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3097 hasElems("(count( elemTypes ) > 0)"),
3098 hasDifferentElems("(count( elemTypes ) > 1)"),
3099 hasElems0d("({'Elem0d'} in elemTypes)"),
3100 hasEdges("({'Edge'} in elemTypes)"),
3101 hasFaces("({'Face'} in elemTypes)"),
3102 hasVolumes("({'Volume'} in elemTypes)");
3104 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3105 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3106 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3107 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3108 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3109 createPopupItem( 803, OB, group ); // EDIT_GROUP
3110 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3112 popupMgr()->insert( separator(), -1, 0 );
3113 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3114 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3115 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3116 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3117 createPopupItem( 214, OB, mesh_group ); // UPDATE
3118 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3119 createPopupItem( 902, OB, mesh ); // STD_INFO
3120 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3121 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3122 popupMgr()->insert( separator(), -1, 0 );
3123 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3124 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3125 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3126 popupMgr()->insert( separator(), -1, 0 );
3127 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3128 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3129 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3130 popupMgr()->insert( separator(), -1, 0 );
3131 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3132 popupMgr()->insert( separator(), -1, 0 );
3133 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3134 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3135 popupMgr()->insert( separator(), -1, 0 );
3137 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3139 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3140 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3141 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3142 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3143 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3144 popupMgr()->insert( separator(), -1, 0 );
3147 createPopupItem( 803, View, group ); // EDIT_GROUP
3148 createPopupItem( 804, View, elems ); // ADD
3149 createPopupItem( 805, View, elems ); // REMOVE
3151 popupMgr()->insert( separator(), -1, 0 );
3152 createPopupItem( 214, View, mesh_group ); // UPDATE
3153 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3154 createPopupItem( 902, View, mesh ); // STD_INFO
3155 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3156 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3157 popupMgr()->insert( separator(), -1, 0 );
3159 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3160 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3161 popupMgr()->insert( separator(), -1, 0 );
3164 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3165 QString aType = QString( "%1type in {%2}" ).arg( lc );
3166 aType = aType.arg( mesh_group );
3167 QString aMeshInVTK = aClient + "&&" + aType;
3169 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3170 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3171 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3173 //-------------------------------------------------
3175 //-------------------------------------------------
3176 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3178 popupMgr()->insert( action( 9010 ), anId, -1 );
3179 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3180 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3182 popupMgr()->insert( action( 9011 ), anId, -1 );
3183 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3184 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3186 popupMgr()->insert( separator(), -1, -1 );
3188 //-------------------------------------------------
3190 //-------------------------------------------------
3191 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3193 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3194 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3195 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3197 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3198 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3199 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3201 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3202 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3203 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3205 popupMgr()->insert( separator(), anId, -1 );
3207 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3208 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3209 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3211 //-------------------------------------------------
3213 //-------------------------------------------------
3214 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3216 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3218 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3219 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3220 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3222 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3223 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3224 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3226 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3227 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3228 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3230 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3231 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3232 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3234 popupMgr()->insert( separator(), anId, -1 );
3236 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3237 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3240 //-------------------------------------------------
3241 // Representation of the 2D Quadratic elements
3242 //-------------------------------------------------
3243 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3244 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3245 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3246 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3248 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3249 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3250 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3252 //-------------------------------------------------
3253 // Orientation of faces
3254 //-------------------------------------------------
3255 popupMgr()->insert( action( 221 ), -1, -1 );
3256 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3257 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3259 //-------------------------------------------------
3261 //-------------------------------------------------
3262 popupMgr()->insert( action( 1132 ), -1, -1 );
3263 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3265 //-------------------------------------------------
3267 //-------------------------------------------------
3268 popupMgr()->insert( action( 1133 ), -1, -1 );
3269 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3271 //-------------------------------------------------
3273 //-------------------------------------------------
3274 popupMgr()->insert( action( 1134 ), -1, -1 );
3275 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3277 popupMgr()->insert( separator(), -1, -1 );
3279 //-------------------------------------------------
3281 //-------------------------------------------------
3283 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3284 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3285 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3286 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3288 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3290 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3291 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3293 popupMgr()->insert( separator(), anId, -1 );
3295 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3296 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3297 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3299 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3300 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3301 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3303 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3304 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3305 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3307 popupMgr()->insert( separator(), anId, -1 );
3309 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3310 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3311 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3313 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3314 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3315 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3317 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3318 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3319 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3321 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3322 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3323 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3325 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3326 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3327 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3329 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3330 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3331 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3333 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3334 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3335 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3337 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3338 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3339 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3341 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3342 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3343 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3345 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3346 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3347 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3349 popupMgr()->insert( separator(), anId, -1 );
3351 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3352 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3353 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3355 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3356 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3357 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3359 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3360 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3361 QtxPopupMgr::VisibleRule );
3362 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3364 popupMgr()->insert( separator(), anId, -1 );
3366 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3367 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3369 popupMgr()->insert( separator(), -1, -1 );
3371 //-------------------------------------------------
3373 //-------------------------------------------------
3374 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3375 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3376 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3377 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3379 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3380 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3382 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3383 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3385 popupMgr()->insert( separator(), -1, -1 );
3387 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3388 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3391 //================================================================================
3393 * \brief Return true if SMESH or GEOM objects are selected.
3394 * Is called form LightApp_Module::activateModule() which clear selection if
3395 * not isSelectionCompatible()
3397 //================================================================================
3399 bool SMESHGUI::isSelectionCompatible()
3401 bool isCompatible = true;
3402 SALOME_ListIO selected;
3403 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3404 Sel->selectedObjects( selected );
3406 SALOME_ListIteratorOfListIO It( selected );
3407 for ( ; isCompatible && It.More(); It.Next())
3409 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3410 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3412 return isCompatible;
3416 bool SMESHGUI::reusableOperation( const int id )
3418 // compute, evaluate and precompute are not reusable operations
3419 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3422 bool SMESHGUI::activateModule( SUIT_Study* study )
3424 bool res = SalomeApp_Module::activateModule( study );
3426 setMenuShown( true );
3427 setToolShown( true );
3429 // Reset actions accelerator keys
3430 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3431 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3432 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3434 action( 33)->setEnabled(true); // Delete: Key_Delete
3435 action(1101)->setEnabled(true); // Rename: Key_F2
3437 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3438 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3439 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3440 if ( _PTR(Study) aStudy = s->studyDS()) {
3441 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3442 updateObjBrowser(); // objects can be removed
3448 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3450 setMenuShown( false );
3451 setToolShown( false );
3453 EmitSignalCloseAllDialogs();
3455 // Unset actions accelerator keys
3456 action(111)->setShortcut(QKeySequence()); // Import DAT
3457 action(112)->setShortcut(QKeySequence()); // Import UNV
3458 action(113)->setShortcut(QKeySequence()); // Import MED
3460 action( 33)->setEnabled(false); // Delete: Key_Delete
3461 action(1101)->setEnabled(false); // Rename: Key_F2
3463 return SalomeApp_Module::deactivateModule( study );
3466 void SMESHGUI::studyClosed( SUIT_Study* s )
3468 SMESH::RemoveVisuData( s->id() );
3469 SalomeApp_Module::studyClosed( s );
3472 void SMESHGUI::OnGUIEvent()
3474 const QObject* obj = sender();
3475 if ( !obj || !obj->inherits( "QAction" ) )
3477 int id = actionId((QAction*)obj);
3482 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3484 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3485 if ( CORBA::is_nil( myComponentSMESH ) )
3487 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3489 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3490 return aGUI.myComponentSMESH;
3493 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3494 return myComponentSMESH;
3497 QString SMESHGUI::engineIOR() const
3499 CORBA::ORB_var anORB = getApp()->orb();
3500 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3501 return QString( anIOR.in() );
3504 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3506 SalomeApp_Module::contextMenuPopup( client, menu, title );
3508 selectionMgr()->selectedObjects( lst );
3509 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3510 Handle(SALOME_InteractiveObject) io = lst.First();
3511 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3512 _PTR(Study) study = appStudy->studyDS();
3513 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3515 QString aName = QString( obj->GetName().c_str() );
3516 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3517 aName.remove( (aName.length() - 1), 1 );
3523 LightApp_Selection* SMESHGUI::createSelection() const
3525 return new SMESHGUI_Selection();
3528 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3530 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3531 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3534 void SMESHGUI::viewManagers( QStringList& list ) const
3536 list.append( SVTK_Viewer::Type() );
3539 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3541 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3542 SMESH::UpdateSelectionProp( this );
3545 void SMESHGUI::createPreferences()
3547 // General tab ------------------------------------------------------------------------
3548 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3550 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3551 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3553 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3554 setPreferenceProperty( qaGroup, "columns", 2 );
3555 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3556 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3557 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3558 setPreferenceProperty( prec, "min", 0 );
3559 setPreferenceProperty( prec, "max", 16 );
3561 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3562 setPreferenceProperty( dispgroup, "columns", 2 );
3563 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3565 modes.append( "Wireframe" );
3566 modes.append( "Shading" );
3567 modes.append( "Nodes" );
3568 modes.append( "Shrink" );
3569 QList<QVariant> indices;
3570 indices.append( 0 );
3571 indices.append( 1 );
3572 indices.append( 2 );
3573 indices.append( 3 );
3574 setPreferenceProperty( dispmode, "strings", modes );
3575 setPreferenceProperty( dispmode, "indexes", indices );
3577 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3578 setPreferenceProperty( arcgroup, "columns", 2 );
3579 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3580 QStringList quadraticModes;
3581 quadraticModes.append("Lines");
3582 quadraticModes.append("Arcs");
3584 indices.append( 0 );
3585 indices.append( 1 );
3586 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3587 setPreferenceProperty( quadraticmode, "indexes", indices );
3589 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3590 "SMESH", "max_angle" );
3591 setPreferenceProperty( maxAngle, "min", 1 );
3592 setPreferenceProperty( maxAngle, "max", 90 );
3596 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3597 setPreferenceProperty( exportgroup, "columns", 2 );
3598 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3599 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3601 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3602 setPreferenceProperty( computeGroup, "columns", 2 );
3603 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3605 modes.append( "Never" );
3606 modes.append( "Errors only" );
3607 modes.append( "Always" );
3609 indices.append( 0 );
3610 indices.append( 1 );
3611 indices.append( 2 );
3612 setPreferenceProperty( notifyMode, "strings", modes );
3613 setPreferenceProperty( notifyMode, "indexes", indices );
3615 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3616 setPreferenceProperty( segGroup, "columns", 2 );
3617 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3618 "SMESH", "segmentation" );
3619 setPreferenceProperty( segLen, "min", 1 );
3620 setPreferenceProperty( segLen, "max", 10000000 );
3621 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3622 "SMESH", "nb_segments_per_edge" );
3623 setPreferenceProperty( nbSeg, "min", 1 );
3624 setPreferenceProperty( nbSeg, "max", 10000000 );
3626 // Mesh tab ------------------------------------------------------------------------
3627 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3628 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3629 setPreferenceProperty( nodeGroup, "columns", 2 );
3631 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3632 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3634 setPreferenceProperty( nodeSz, "min", 1 );
3635 setPreferenceProperty( nodeSz, "max", 5 );
3637 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3638 setPreferenceProperty( elemGroup, "columns", 2 );
3640 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3641 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3642 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3643 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3645 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3646 //setPreferenceProperty( sp, "hstretch", 0 );
3647 //setPreferenceProperty( sp, "vstretch", 0 );
3649 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3650 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3651 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3652 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3653 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3654 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3655 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3657 setPreferenceProperty( size0d, "min", 1 );
3658 setPreferenceProperty( size0d, "max", 10 );
3660 setPreferenceProperty( sp, "hstretch", 0 );
3661 setPreferenceProperty( sp, "vstretch", 0 );
3663 setPreferenceProperty( elemW, "min", 1 );
3664 setPreferenceProperty( elemW, "max", 5 );
3666 setPreferenceProperty( shrink, "min", 0 );
3667 setPreferenceProperty( shrink, "max", 100 );
3669 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3670 setPreferenceProperty( orientGroup, "columns", 1 );
3672 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3673 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3675 setPreferenceProperty( orientScale, "min", 0.05 );
3676 setPreferenceProperty( orientScale, "max", 0.5 );
3677 setPreferenceProperty( orientScale, "step", 0.05 );
3679 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3681 // Selection tab ------------------------------------------------------------------------
3682 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3684 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3685 setPreferenceProperty( selGroup, "columns", 2 );
3687 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3688 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3689 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3691 setPreferenceProperty( selW, "min", 1 );
3692 setPreferenceProperty( selW, "max", 5 );
3694 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3695 setPreferenceProperty( preGroup, "columns", 2 );
3697 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3698 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3700 setPreferenceProperty( preW, "min", 1 );
3701 setPreferenceProperty( preW, "max", 5 );
3703 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3704 setPreferenceProperty( precSelGroup, "columns", 2 );
3706 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3707 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3708 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3710 // Scalar Bar tab ------------------------------------------------------------------------
3711 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3712 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3713 setPreferenceProperty( fontGr, "columns", 2 );
3715 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3716 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3718 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3719 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3721 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3722 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3724 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3725 setPreferenceProperty( numcol, "min", 2 );
3726 setPreferenceProperty( numcol, "max", 256 );
3728 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3729 setPreferenceProperty( numlab, "min", 2 );
3730 setPreferenceProperty( numlab, "max", 65 );
3732 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3733 setPreferenceProperty( orientGr, "columns", 2 );
3734 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3735 QStringList orients;
3736 orients.append( tr( "SMESH_VERTICAL" ) );
3737 orients.append( tr( "SMESH_HORIZONTAL" ) );
3738 indices.clear(); indices.append( 0 ); indices.append( 1 );
3739 setPreferenceProperty( orient, "strings", orients );
3740 setPreferenceProperty( orient, "indexes", indices );
3742 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3743 setPreferenceProperty( posVSizeGr, "columns", 2 );
3744 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3745 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3746 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3747 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3748 setPreferenceProperty( xv, "step", 0.1 );
3749 setPreferenceProperty( xv, "min", 0.0 );
3750 setPreferenceProperty( xv, "max", 1.0 );
3751 setPreferenceProperty( yv, "step", 0.1 );
3752 setPreferenceProperty( yv, "min", 0.0 );
3753 setPreferenceProperty( yv, "max", 1.0 );
3754 setPreferenceProperty( wv, "step", 0.1 );
3755 setPreferenceProperty( wv, "min", 0.0 );
3756 setPreferenceProperty( wv, "max", 1.0 );
3757 setPreferenceProperty( hv, "min", 0.0 );
3758 setPreferenceProperty( hv, "max", 1.0 );
3759 setPreferenceProperty( hv, "step", 0.1 );
3761 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3762 setPreferenceProperty( posHSizeGr, "columns", 2 );
3763 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3764 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3765 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3766 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3767 setPreferenceProperty( xv, "min", 0.0 );
3768 setPreferenceProperty( xv, "max", 1.0 );
3769 setPreferenceProperty( xv, "step", 0.1 );
3770 setPreferenceProperty( xh, "min", 0.0 );
3771 setPreferenceProperty( xh, "max", 1.0 );
3772 setPreferenceProperty( xh, "step", 0.1 );
3773 setPreferenceProperty( yh, "min", 0.0 );
3774 setPreferenceProperty( yh, "max", 1.0 );
3775 setPreferenceProperty( yh, "step", 0.1 );
3776 setPreferenceProperty( wh, "min", 0.0 );
3777 setPreferenceProperty( wh, "max", 1.0 );
3778 setPreferenceProperty( wh, "step", 0.1 );
3779 setPreferenceProperty( hh, "min", 0.0 );
3780 setPreferenceProperty( hh, "max", 1.0 );
3781 setPreferenceProperty( hh, "step", 0.1 );
3784 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3786 if( sect=="SMESH" ) {
3787 float sbX1,sbY1,sbW,sbH;
3788 float aTol = 1.00000009999999;
3789 std::string aWarning;
3790 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3791 if( name=="selection_object_color" || name=="selection_element_color" ||
3792 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3793 name=="selection_precision_node" || name=="selection_precision_element" ||
3794 name=="selection_precision_object")
3795 SMESH::UpdateSelectionProp( this );
3796 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3797 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3798 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3799 if(sbX1+sbW > aTol){
3800 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3803 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3804 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3807 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3808 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3809 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3810 if(sbY1+sbH > aTol){
3811 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3812 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3813 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3816 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3817 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3818 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3819 if(sbX1+sbW > aTol){
3820 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3823 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3824 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3827 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3828 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3829 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3830 if(sbY1+sbH > aTol){
3831 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3834 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3835 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3838 else if ( name == "segmentation" ) {
3839 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3840 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3842 else if ( name == "nb_segments_per_edge" ) {
3843 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3844 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3847 if(aWarning.size() != 0){
3848 aWarning += "The default values are applied instead.";
3849 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3850 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3851 QObject::tr(aWarning.c_str()));
3856 //================================================================================
3858 * \brief Update something in accordance with update flags
3859 * \param theFlags - update flags
3861 * Update viewer or/and object browser etc. in accordance with update flags ( see
3862 * LightApp_UpdateFlags enumeration ).
3864 //================================================================================
3865 void SMESHGUI::update( const int flags )
3867 if ( flags & UF_Viewer | flags & UF_Forced )
3868 SMESH::UpdateView();
3870 SalomeApp_Module::update( flags );
3873 //================================================================================
3875 * \brief Set default selection mode
3877 * SLOT called when operation commited. Sets default selection mode
3879 //================================================================================
3880 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3882 SVTK_ViewWindow* vtkWnd =
3883 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3885 vtkWnd->SetSelectionMode( ActorSelection );
3888 //================================================================================
3890 * \brief Set default selection mode
3892 * SLOT called when operation aborted. Sets default selection mode
3894 //================================================================================
3895 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3897 SVTK_ViewWindow* vtkWnd =
3898 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3900 vtkWnd->SetSelectionMode( ActorSelection );
3903 //================================================================================
3905 * \brief Creates operation with given identifier
3906 * \param id - identifier of operation to be started
3907 * \return Pointer on created operation or NULL if operation is not created
3909 * Virtual method redefined from the base class creates operation with given id.
3910 * It is called called automatically from startOperation method of base class.
3912 //================================================================================
3913 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3915 LightApp_Operation* op = 0;
3916 // to do : create operation here
3919 case 417: //convert to quadratic
3920 op = new SMESHGUI_ConvToQuadOp();
3922 case 418: // create 2D mesh as boundary on 3D
3923 op = new SMESHGUI_Make2DFrom3DOp();
3925 case 701: // Compute mesh
3926 op = new SMESHGUI_ComputeOp();
3928 case 702: // Create mesh
3929 op = new SMESHGUI_MeshOp( true, true );
3931 case 703: // Create sub-mesh
3932 op = new SMESHGUI_MeshOp( true, false );
3934 case 704: // Edit mesh/sub-mesh
3935 op = new SMESHGUI_MeshOp( false );
3937 case 711: // Precompute mesh
3938 op = new SMESHGUI_PrecomputeOp();
3940 case 712: // Evaluate mesh
3941 op = new SMESHGUI_EvaluateOp();
3943 case 713: // Evaluate mesh
3944 op = new SMESHGUI_MeshOrderOp();
3946 case 806: // Create group on geom
3947 op = new SMESHGUI_GroupOnShapeOp();
3949 case 904: // Find element
3950 op = new SMESHGUI_FindElemByPointOp();
3952 case 4067: // make mesh pass through point
3953 op = new SMESHGUI_MakeNodeAtPointOp();
3960 op = SalomeApp_Module::createOperation( id );
3964 //================================================================================
3966 * \brief Stops current operations and starts a given one
3967 * \param id - The id of the operation to start
3969 //================================================================================
3971 void SMESHGUI::switchToOperation(int id)
3973 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3974 activeStudy()->abortAllOperations();
3975 startOperation( id );
3978 LightApp_Displayer* SMESHGUI::displayer()
3981 myDisplayer = new SMESHGUI_Displayer( getApp() );
3985 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3988 int aTolerance = 64;
3989 int anIterations = 0;
3995 if( anIterations % aPeriod == 0 )
3998 if( aTolerance < 1 )
4001 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4003 aHue = (int)( 360.0 * rand() / RAND_MAX );
4004 //cout << "Hue = " << aHue << endl;
4006 //cout << "Auto colors : ";
4008 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4009 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4010 for( ; it != itEnd; ++it )
4012 SALOMEDS::Color anAutoColor = *it;
4013 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4016 aQColor.getHsv( &h, &s, &v );
4018 if( abs( h - aHue ) < aTolerance )
4021 //cout << "break (diff = " << abs( h - aHue ) << ")";
4031 //cout << "Hue of the returned color = " << aHue << endl;
4033 aColor.setHsv( aHue, 255, 255 );
4035 SALOMEDS::Color aSColor;
4036 aSColor.R = (double)aColor.red() / 255.0;
4037 aSColor.G = (double)aColor.green() / 255.0;
4038 aSColor.B = (double)aColor.blue() / 255.0;
4043 const char gSeparator = '_'; // character used to separate parameter names
4044 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4047 * \brief Store visual parameters
4049 * This method is called just before the study document is saved.
4050 * Store visual parameters in AttributeParameter attribue(s)
4052 void SMESHGUI::storeVisualParameters (int savePoint)
4054 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4055 if (!appStudy || !appStudy->studyDS())
4057 _PTR(Study) studyDS = appStudy->studyDS();
4059 // componentName is used for encoding of entries when storing them in IParameters
4060 std::string componentName = myComponentSMESH->ComponentDataType();
4061 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4062 //if (!aSComponent) return;
4065 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4066 componentName.c_str(),
4068 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4070 // viewers counters are used for storing view_numbers in IParameters
4073 // main cycle to store parameters of displayed objects
4074 QList<SUIT_ViewManager*> lst;
4075 QList<SUIT_ViewManager*>::Iterator it;
4076 getApp()->viewManagers(lst);
4077 for (it = lst.begin(); it != lst.end(); it++)
4079 SUIT_ViewManager* vman = *it;
4080 QString vType = vman->getType();
4082 // saving VTK actors properties
4083 if (vType == SVTK_Viewer::Type())
4085 QVector<SUIT_ViewWindow*> views = vman->getViews();
4086 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4088 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4090 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4091 vtkActorCollection* allActors = aCopy.GetActors();
4092 allActors->InitTraversal();
4093 while (vtkActor* actor = allActors->GetNextActor())
4095 if (actor->GetVisibility()) // store only visible actors
4097 SMESH_Actor* aSmeshActor = 0;
4098 if (actor->IsA("SMESH_Actor"))
4099 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4100 if (aSmeshActor && aSmeshActor->hasIO())
4102 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4105 // entry is "encoded" = it does NOT contain component adress,
4106 // since it is a subject to change on next component loading
4107 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4109 std::string param, vtkParam = vType.toLatin1().data();
4110 vtkParam += gSeparator;
4111 vtkParam += QString::number(vtkViewers).toLatin1().data();
4112 vtkParam += gSeparator;
4115 param = vtkParam + "Visibility";
4116 ip->setParameter(entry, param, "On");
4119 param = vtkParam + "Representation";
4120 ip->setParameter(entry, param, QString::number
4121 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4124 param = vtkParam + "IsShrunk";
4125 ip->setParameter(entry, param, QString::number
4126 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4128 // Displayed entities
4129 unsigned int aMode = aSmeshActor->GetEntityMode();
4130 bool isE = aMode & SMESH_Actor::eEdges;
4131 bool isF = aMode & SMESH_Actor::eFaces;
4132 bool isV = aMode & SMESH_Actor::eVolumes;
4134 QString modeStr ("e");
4135 modeStr += gDigitsSep; modeStr += QString::number(isE);
4136 modeStr += gDigitsSep; modeStr += "f";
4137 modeStr += gDigitsSep; modeStr += QString::number(isF);
4138 modeStr += gDigitsSep; modeStr += "v";
4139 modeStr += gDigitsSep; modeStr += QString::number(isV);
4141 param = vtkParam + "Entities";
4142 ip->setParameter(entry, param, modeStr.toLatin1().data());
4144 // Colors (surface:edge:)
4145 vtkFloatingPointType r, g, b;
4147 aSmeshActor->GetSufaceColor(r, g, b);
4148 QString colorStr ("surface");
4149 colorStr += gDigitsSep; colorStr += QString::number(r);
4150 colorStr += gDigitsSep; colorStr += QString::number(g);
4151 colorStr += gDigitsSep; colorStr += QString::number(b);
4153 aSmeshActor->GetBackSufaceColor(r, g, b);
4154 colorStr += gDigitsSep; colorStr += "backsurface";
4155 colorStr += gDigitsSep; colorStr += QString::number(r);
4156 colorStr += gDigitsSep; colorStr += QString::number(g);
4157 colorStr += gDigitsSep; colorStr += QString::number(b);
4159 aSmeshActor->GetEdgeColor(r, g, b);
4160 colorStr += gDigitsSep; colorStr += "edge";
4161 colorStr += gDigitsSep; colorStr += QString::number(r);
4162 colorStr += gDigitsSep; colorStr += QString::number(g);
4163 colorStr += gDigitsSep; colorStr += QString::number(b);
4165 aSmeshActor->GetNodeColor(r, g, b);
4166 colorStr += gDigitsSep; colorStr += "node";
4167 colorStr += gDigitsSep; colorStr += QString::number(r);
4168 colorStr += gDigitsSep; colorStr += QString::number(g);
4169 colorStr += gDigitsSep; colorStr += QString::number(b);
4171 param = vtkParam + "Colors";
4172 ip->setParameter(entry, param, colorStr.toLatin1().data());
4174 // Sizes of lines and points
4175 QString sizeStr ("line");
4176 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4177 sizeStr += gDigitsSep; sizeStr += "node";
4178 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4179 sizeStr += gDigitsSep; sizeStr += "shrink";
4180 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4182 param = vtkParam + "Sizes";
4183 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4186 param = vtkParam + "Opacity";
4187 ip->setParameter(entry, param,
4188 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4191 param = vtkParam + "ClippingPlane";
4192 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4194 ip->setParameter(entry, param, "Off");
4195 for (int ipl = 0; ipl < nPlanes; ipl++) {
4196 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4197 SMESH::Orientation anOrientation;
4199 vtkFloatingPointType anAngle[2];
4200 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4201 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4202 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4203 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4204 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4206 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4208 } // if (io->hasEntry())
4209 } // SMESH_Actor && hasIO
4211 } // while.. actors traversal
4215 } // if (SVTK view model)
4216 } // for (viewManagers)
4220 * \brief Restore visual parameters
4222 * This method is called after the study document is opened.
4223 * Restore visual parameters from AttributeParameter attribue(s)
4225 void SMESHGUI::restoreVisualParameters (int savePoint)
4227 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4228 if (!appStudy || !appStudy->studyDS())
4230 _PTR(Study) studyDS = appStudy->studyDS();
4232 // componentName is used for encoding of entries when storing them in IParameters
4233 std::string componentName = myComponentSMESH->ComponentDataType();
4234 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4235 //if (!aSComponent) return;
4238 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4239 componentName.c_str(),
4241 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4243 std::vector<std::string> entries = ip->getEntries();
4245 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4247 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4248 QString entry (ip->decodeEntry(*entIt).c_str());
4250 // Check that the entry corresponds to a real object in the Study
4251 // as the object may be deleted or modified after the visual state is saved.
4252 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4253 if (!so) continue; //Skip the not existent entry
4255 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4256 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4258 std::vector<std::string>::iterator namesIt = paramNames.begin();
4259 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4261 // actors are stored in a map after displaying of them for
4262 // quicker access in the future: map < viewID to actor >
4263 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4265 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4267 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4268 // '_' is used as separator and should not be used in viewer type or parameter names.
4269 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4270 if (lst.size() != 3)
4273 QString viewerTypStr = lst[0];
4274 QString viewIndexStr = lst[1];
4275 QString paramNameStr = lst[2];
4278 int viewIndex = viewIndexStr.toUInt(&ok);
4279 if (!ok) // bad conversion of view index to integer
4283 if (viewerTypStr == SVTK_Viewer::Type())
4285 SMESH_Actor* aSmeshActor = 0;
4286 if (vtkActors.IsBound(viewIndex))
4287 aSmeshActor = vtkActors.Find(viewIndex);
4289 if (paramNameStr == "Visibility")
4291 if (!aSmeshActor && displayer())
4293 QList<SUIT_ViewManager*> lst;
4294 getApp()->viewManagers(viewerTypStr, lst);
4296 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4297 if (viewIndex >= 0 && viewIndex < lst.count()) {
4298 SUIT_ViewManager* vman = lst.at(viewIndex);
4299 SUIT_ViewModel* vmodel = vman->getViewModel();
4300 // SVTK view model can be casted to SALOME_View
4301 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4303 // store displayed actor in a temporary map for quicker
4304 // access later when restoring other parameters
4305 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4306 vtkRenderer* Renderer = vtkView->getRenderer();
4307 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4308 vtkActorCollection* theActors = aCopy.GetActors();
4309 theActors->InitTraversal();
4310 bool isFound = false;
4311 vtkActor *ac = theActors->GetNextActor();
4312 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4313 if (ac->IsA("SMESH_Actor")) {
4314 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4315 if (aGeomAc->hasIO()) {
4316 Handle(SALOME_InteractiveObject) io =
4317 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4318 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4320 vtkActors.Bind(viewIndex, aGeomAc);
4327 } // if (paramNameStr == "Visibility")
4330 // the rest properties "work" with SMESH_Actor
4333 QString val ((*valuesIt).c_str());
4336 if (paramNameStr == "Representation") {
4337 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4340 else if (paramNameStr == "IsShrunk") {
4342 if (!aSmeshActor->IsShrunk())
4343 aSmeshActor->SetShrink();
4346 if (aSmeshActor->IsShrunk())
4347 aSmeshActor->UnShrink();
4350 // Displayed entities
4351 else if (paramNameStr == "Entities") {
4352 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4353 if (mode.count() == 6) {
4354 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4355 MESSAGE("Invalid order of data in Entities, must be: "
4356 "e:0/1:f:0/1:v:0/1");
4359 unsigned int aMode = aSmeshActor->GetEntityMode();
4360 unsigned int aNewMode =
4361 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4362 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4363 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4364 if (aNewMode != aMode)
4365 aSmeshActor->SetEntityMode(aNewMode);
4370 else if (paramNameStr == "Colors") {
4371 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4372 if (colors.count() == 16) {
4373 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4374 colors[8] != "edge" || colors[12] != "node") {
4375 MESSAGE("Invalid order of data in Colors, must be: "
4376 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4379 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4380 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4381 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4382 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4386 // Sizes of lines and points
4387 else if (paramNameStr == "Sizes") {
4388 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4389 if (sizes.count() == 6) {
4390 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4391 MESSAGE("Invalid order of data in Sizes, must be: "
4392 "line:int:node:int:shrink:float");
4395 aSmeshActor->SetLineWidth(sizes[1].toInt());
4396 aSmeshActor->SetNodeSize(sizes[3].toInt());
4397 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4402 else if (paramNameStr == "Opacity") {
4403 aSmeshActor->SetOpacity(val.toFloat());
4406 else if (paramNameStr.startsWith("ClippingPlane")) {
4407 cout << "$$$ ClippingPlane 1" << endl;
4408 if (paramNameStr == "ClippingPlane1" || val == "Off")
4409 aSmeshActor->RemoveAllClippingPlanes();
4411 cout << "$$$ ClippingPlane 2" << endl;
4412 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4413 if (vals.count() == 4) { // format check: 4 values
4414 cout << "$$$ ClippingPlane 3" << endl;
4415 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4416 double aDistance = vals[1].toFloat();
4417 vtkFloatingPointType anAngle[2];
4418 anAngle[0] = vals[2].toFloat();
4419 anAngle[1] = vals[3].toFloat();
4421 QList<SUIT_ViewManager*> lst;
4422 getApp()->viewManagers(viewerTypStr, lst);
4423 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4424 if (viewIndex >= 0 && viewIndex < lst.count()) {
4425 SUIT_ViewManager* vman = lst.at(viewIndex);
4426 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4427 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4428 anOrientation, aDistance, anAngle);
4433 } // if (aSmeshActor)
4434 } // other parameters than Visibility
4436 } // for names/parameters iterator
4437 } // for entries iterator
4439 // update all VTK views
4440 QList<SUIT_ViewManager*> lst;
4441 getApp()->viewManagers(lst);
4442 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4443 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4444 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4445 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4446 vtkView->getRenderer()->ResetCameraClippingRange();
4453 \brief Adds preferences for dfont of VTK viewer
4455 \param pIf group identifier
4456 \param param parameter
4457 \return identifier of preferences
4459 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4461 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4463 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4466 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4467 fam.append( tr( "SMESH_FONT_COURIER" ) );
4468 fam.append( tr( "SMESH_FONT_TIMES" ) );
4470 setPreferenceProperty( tfont, "fonts", fam );
4472 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4473 setPreferenceProperty( tfont, "features", f );
4479 \brief Actions after hypothesis edition
4480 Updates object browser after hypothesis edition
4482 void SMESHGUI::onHypothesisEdit( int result )
4484 updateObjBrowser( true );