1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_NodesDlg.h"
29 #include "SMESHGUI_TransparencyDlg.h"
30 #include "SMESHGUI_ClippingDlg.h"
31 #include "SMESHGUI_GroupDlg.h"
32 #include "SMESHGUI_RemoveNodesDlg.h"
33 #include "SMESHGUI_RemoveElementsDlg.h"
34 #include "SMESHGUI_MeshInfosDlg.h"
35 #include "SMESHGUI_StandardMeshInfosDlg.h"
36 #include "SMESHGUI_WhatIsDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_MoveNodesDlg.h"
41 #include "SMESHGUI_AddMeshElementDlg.h"
42 #include "SMESHGUI_AddQuadraticElementDlg.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_SingleEditDlg.h"
46 #include "SMESHGUI_MultiEditDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_GroupOnShapeDlg.h"
49 #include "SMESHGUI_DeleteGroupDlg.h"
50 #include "SMESHGUI_SmoothingDlg.h"
51 #include "SMESHGUI_RenumberingDlg.h"
52 #include "SMESHGUI_ExtrusionDlg.h"
53 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
54 #include "SMESHGUI_RevolutionDlg.h"
55 #include "SMESHGUI_TranslationDlg.h"
56 #include "SMESHGUI_RotationDlg.h"
57 #include "SMESHGUI_SymmetryDlg.h"
58 #include "SMESHGUI_SewingDlg.h"
59 #include "SMESHGUI_EditMeshDlg.h"
60 #include "SMESHGUI_MeshPatternDlg.h"
61 #include "SMESHGUI_Selection.h"
62 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
63 #include "SMESHGUI_ConvToQuadOp.h"
64 #include "SMESHGUI_MeshOp.h"
65 #include "SMESHGUI_Displayer.h"
66 #include "SMESHGUI_MakeNodeAtPointDlg.h"
67 #include "SMESHGUI_BuildCompoundDlg.h"
68 #include "SMESHGUI_ComputeDlg.h"
69 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Make2DFrom3DOp.h"
72 #include "SMESHGUI_Utils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include <SMESH_Client.hxx>
81 #include <SMESH_Actor.h>
82 #include <SMESH_TypeFilter.hxx>
84 // SALOME GUI includes
85 #include <SalomeApp_Tools.h>
86 #include <SalomeApp_Study.h>
87 #include <SalomeApp_Application.h>
88 #include <SalomeApp_CheckFileDlg.h>
90 #include <LightApp_DataOwner.h>
91 #include <LightApp_Preferences.h>
92 #include <LightApp_SelectionMgr.h>
93 #include <LightApp_UpdateFlags.h>
94 #include <LightApp_NameDlg.h>
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_ViewManager.h>
100 #include <VTKViewer_Algorithm.h>
102 #include <SUIT_MessageBox.h>
103 #include <SUIT_ResourceMgr.h>
104 #include <SUIT_FileDlg.h>
105 #include <SUIT_Desktop.h>
106 #include <SUIT_OverrideCursor.h>
107 #include <SUIT_Session.h>
109 #include <QtxPopupMgr.h>
110 #include <QtxFontEdit.h>
112 #include <SALOME_ListIO.hxx>
113 #include <SALOME_ListIteratorOfListIO.hxx>
116 #include <SALOMEconfig.h>
117 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
118 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
121 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
125 #include <boost/shared_ptr.hpp>
128 #include <vtkScalarBarActor.h>
129 #include <vtkCamera.h>
130 #include <vtkRenderer.h>
131 #include <vtkPlane.h>
133 // SALOME KERNEL includes
134 #include <SALOMEDS_Study.hxx>
135 #include <SALOMEDSClient_StudyBuilder.hxx>
136 #include <SALOMEDSClient_SComponent.hxx>
137 #include <SALOMEDSClient_ClientFactory.hxx>
138 #include <SALOMEDSClient_IParameters.hxx>
141 #include <Standard_ErrorHandler.hxx>
142 #include <NCollection_DataMap.hxx>
146 //=============================================================
147 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
150 void ExportMeshToFile(int theCommandID);
152 void SetDisplayMode(int theCommandID);
154 void SetDisplayEntity(int theCommandID);
156 void Control( int theCommandID );
160 //=============================================================
161 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
165 std::string myExtension;
167 if ( theCommandID == 113 ) {
168 filter.append( QObject::tr( "MED files (*.med)" ) );
169 filter.append( QObject::tr( "All files (*)" ) );
171 else if ( theCommandID == 112 ) {
172 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
174 else if ( theCommandID == 111 ) {
175 filter.append( QObject::tr( "DAT files (*.dat)" ) );
178 QString anInitialPath = "";
179 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
180 anInitialPath = QDir::currentPath();
182 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
185 QObject::tr( "SMESH_IMPORT_MESH" ) );
186 if ( filenames.count() > 0 ) {
187 SUIT_OverrideCursor wc;
188 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
191 bool isEmpty = false;
192 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
193 QString filename = *it;
194 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
196 switch ( theCommandID ) {
199 // DAT format (currently unsupported)
200 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
201 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
207 aMeshes->length( 1 );
208 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
209 if ( aMeshes[0]->_is_nil() )
210 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
211 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
217 SMESH::DriverMED_ReadStatus res;
218 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
219 if ( res != SMESH::DRS_OK ) {
220 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
221 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
227 catch ( const SALOME::SALOME_Exception& S_ex ) {
228 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
229 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
232 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
233 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
235 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
236 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
237 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
238 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
239 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
247 // update Object browser
248 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
250 // show Error message box if there were errors
251 if ( errors.count() > 0 ) {
252 SUIT_MessageBox::critical( SMESHGUI::desktop(),
253 QObject::tr( "SMESH_ERROR" ),
254 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
257 // show warning message box, if some imported mesh is empty
259 SUIT_MessageBox::warning( SMESHGUI::desktop(),
260 QObject::tr( "SMESH_WRN_WARNING" ),
261 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
266 void ExportMeshToFile( int theCommandID )
268 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
269 SALOME_ListIO selected;
271 aSel->selectedObjects( selected );
273 SMESH::SMESH_Mesh_var aMesh;
274 if(selected.Extent() == 1)
275 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
276 if ( aMesh->_is_nil() ) {
277 SUIT_MessageBox::warning( SMESHGUI::desktop(),
278 QObject::tr( "SMESH_WRN_WARNING" ),
279 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
283 Handle(SALOME_InteractiveObject) anIObject = selected.First();
284 QString aFilter, aTitle = QObject::tr("Export mesh");
285 QMap<QString, SMESH::MED_VERSION> aFilterMap;
286 QMap<QString, int> aFilterMapSTL;
287 switch ( theCommandID ) {
291 if (aMesh->HasDuplicatedGroupNamesMED()) {
292 int aRet = SUIT_MessageBox::warning
293 (SMESHGUI::desktop(),
294 QObject::tr("SMESH_WRN_WARNING"),
295 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
296 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
297 if (aRet != SUIT_MessageBox::Yes)
301 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
302 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
303 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
304 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
309 aFilter = QObject::tr("DAT files (*.dat)");
314 if (aMesh->NbPyramids()) {
315 int aRet = SUIT_MessageBox::warning
316 (SMESHGUI::desktop(),
317 QObject::tr("SMESH_WRN_WARNING"),
318 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
319 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
320 if (aRet != SUIT_MessageBox::Yes)
323 aFilter = QObject::tr("IDEAS files (*.unv)");
331 there must be check on others mesh elements not equal triangles
333 if (aMesh->NbTriangles() < 1) {
334 SUIT_MessageBox::warning
335 (SMESHGUI::desktop(),
336 QObject::tr("SMESH_WRN_WARNING"),
337 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
340 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
341 int aRet = SUIT_MessageBox::warning
342 (SMESHGUI::desktop(),
343 QObject::tr("SMESH_WRN_WARNING"),
344 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
345 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
346 if (aRet != SUIT_MessageBox::Yes)
350 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
351 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
359 SMESH::MED_VERSION aFormat;
360 // Init the parameter with the default value
361 bool aIsASCII_STL = true;
362 bool toCreateGroups = false;
363 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
365 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
367 QString anInitialPath = "";
368 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
369 anInitialPath = QDir::currentPath();
371 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
372 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
373 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
374 aFilter, aTitle, false);
376 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
378 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
379 for ( ; it != aFilterMapSTL.end(); ++it )
380 filters.push_back( it.key() );
382 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
383 fd->setWindowTitle( aTitle );
384 fd->setFilters( filters );
385 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
386 if ( !anInitialPath.isEmpty() )
387 fd->setDirectory( anInitialPath );
388 fd->selectFile(anIObject->getName());
392 aFilename = fd->selectedFile();
393 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
398 else { // Export to MED
400 QString aDefaultFilter;
401 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
402 for ( ; it != aFilterMap.end(); ++it ) {
403 filters.push_back( it.key() );
404 if (it.value() == SMESH::MED_V2_2)
405 aDefaultFilter = it.key();
408 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
409 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
410 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
411 fd->setWindowTitle( aTitle );
412 fd->setFilters( filters );
413 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
414 fd->selectFilter(aDefaultFilter);
415 fd->SetChecked(toCreateGroups);
416 if ( !anInitialPath.isEmpty() )
417 fd->setDirectory( anInitialPath );
418 fd->selectFile(anIObject->getName());
422 aFilename = fd->selectedFile();
423 aFormat = aFilterMap[fd->selectedFilter()];
425 if ( !aFilename.isEmpty()
426 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
427 && aFormat==SMESH::MED_V2_1) {
428 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
429 QObject::tr("SMESH_WRN_WARNING"),
430 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
431 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
432 if (aRet != SUIT_MessageBox::Yes) {
437 toCreateGroups = fd->IsChecked();
440 if ( !aFilename.isEmpty() ) {
441 // Check whether the file already exists and delete it if yes
442 QFile aFile( aFilename );
443 if ( aFile.exists() )
445 SUIT_OverrideCursor wc;
448 bool Renumber = false;
449 // PAL 14172 : Check of we have to renumber or not from the preferences before export
451 Renumber= resMgr->booleanValue("SMESH","renumbering");
453 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
454 aMeshEditor->RenumberNodes();
455 aMeshEditor->RenumberElements();
456 if ( SMESHGUI::automaticUpdate() )
459 switch ( theCommandID ) {
462 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
466 aMesh->ExportDAT( aFilename.toLatin1().data() );
470 aMesh->ExportUNV( aFilename.toLatin1().data() );
474 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
480 catch (const SALOME::SALOME_Exception& S_ex){
482 SUIT_MessageBox::warning(SMESHGUI::desktop(),
483 QObject::tr("SMESH_WRN_WARNING"),
484 QObject::tr("SMESH_EXPORT_FAILED"));
490 inline void InverseEntityMode(unsigned int& theOutputMode,
491 unsigned int theMode)
493 bool anIsNotPresent = ~theOutputMode & theMode;
495 theOutputMode |= theMode;
497 theOutputMode &= ~theMode;
500 void SetDisplayEntity(int theCommandID){
501 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
502 SALOME_ListIO selected;
504 aSel->selectedObjects( selected );
506 if(selected.Extent() >= 1){
507 SALOME_ListIteratorOfListIO It( selected );
508 for( ; It.More(); It.Next()){
509 Handle(SALOME_InteractiveObject) IObject = It.Value();
510 if(IObject->hasEntry()){
511 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
512 unsigned int aMode = anActor->GetEntityMode();
513 switch(theCommandID){
515 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
518 InverseEntityMode(aMode,SMESH_Actor::eEdges);
521 InverseEntityMode(aMode,SMESH_Actor::eFaces);
524 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
527 aMode = SMESH_Actor::eAllEntity;
531 anActor->SetEntityMode(aMode);
539 SALOME_ListIO selected;
540 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
544 LightApp_SelectionMgr* aSel = app->selectionMgr();
545 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
546 if( !aSel || !appStudy )
549 aSel->selectedObjects( selected );
550 if( selected.IsEmpty() )
553 Handle(SALOME_InteractiveObject) anIObject = selected.First();
555 _PTR(Study) aStudy = appStudy->studyDS();
556 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
557 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
558 if( aMainObject->_is_nil() )
561 aMainObject->SetAutoColor( true );
563 QList<SALOMEDS::Color> aReservedColors;
565 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
566 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
568 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
569 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
571 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
572 aGroupObject->SetColor( aColor );
573 aReservedColors.append( aColor );
575 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
576 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
578 if( aGroupObject->GetType() == SMESH::NODE )
579 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
580 else if( aGroupObject->GetType() == SMESH::EDGE )
581 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
583 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
587 SMESH::RepaintCurrentView();
590 void DisableAutoColor(){
591 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
592 SALOME_ListIO selected;
594 aSel->selectedObjects( selected );
596 if(selected.Extent()){
597 Handle(SALOME_InteractiveObject) anIObject = selected.First();
598 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
599 if ( !aMesh->_is_nil() ) {
600 aMesh->SetAutoColor( false );
605 void SetDisplayMode(int theCommandID){
606 SALOME_ListIO selected;
607 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
611 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
612 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
613 if( !aSel || !appStudy )
616 _PTR(Study) aStudy = appStudy->studyDS();
618 aSel->selectedObjects( selected );
620 if(selected.Extent() >= 1){
621 switch(theCommandID){
623 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
624 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
628 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
629 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
632 SALOME_ListIteratorOfListIO It( selected );
633 for( ; It.More(); It.Next()){
634 Handle(SALOME_InteractiveObject) IObject = It.Value();
635 if(IObject->hasEntry()){
636 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
637 switch(theCommandID){
639 anActor->SetRepresentation(SMESH_Actor::eEdge);
642 anActor->SetRepresentation(SMESH_Actor::eSurface);
645 if(anActor->IsShrunk())
648 anActor->SetShrink();
651 anActor->SetRepresentation(SMESH_Actor::ePoint);
654 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
655 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
658 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
659 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
662 vtkFloatingPointType color[3];
663 anActor->GetSufaceColor(color[0], color[1], color[2]);
664 int c0 = int (color[0] * 255);
665 int c1 = int (color[1] * 255);
666 int c2 = int (color[2] * 255);
667 QColor c(c0, c1, c2);
669 vtkFloatingPointType edgecolor[3];
670 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
671 c0 = int (edgecolor[0] * 255);
672 c1 = int (edgecolor[1] * 255);
673 c2 = int (edgecolor[2] * 255);
674 QColor e(c0, c1, c2);
676 vtkFloatingPointType backfacecolor[3];
677 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
678 c0 = int (backfacecolor[0] * 255);
679 c1 = int (backfacecolor[1] * 255);
680 c2 = int (backfacecolor[2] * 255);
681 QColor b(c0, c1, c2);
683 vtkFloatingPointType nodecolor[3];
684 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
685 c0 = int (nodecolor[0] * 255);
686 c1 = int (nodecolor[1] * 255);
687 c2 = int (nodecolor[2] * 255);
688 QColor n(c0, c1, c2);
690 int Edgewidth = (int)anActor->GetLineWidth();
693 int intValue = int(anActor->GetNodeSize());
694 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
696 SMESHGUI_Preferences_ColorDlg *aDlg =
697 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
698 aDlg->SetColor(1, c);
699 aDlg->SetColor(2, e);
700 aDlg->SetColor(3, n);
701 aDlg->SetColor(4, b);
702 aDlg->SetIntValue(1, Edgewidth);
703 aDlg->SetIntValue(2, intValue);
704 aDlg->SetIntValue(3, int(Shrink*100.));
706 QColor color = aDlg->GetColor(1);
707 QColor edgecolor = aDlg->GetColor(2);
708 QColor nodecolor = aDlg->GetColor(3);
709 QColor backfacecolor = aDlg->GetColor(4);
710 /* actor color and backface color */
711 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
712 vtkFloatingPointType (color.green()) / 255.,
713 vtkFloatingPointType (color.blue()) / 255.);
714 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
715 vtkFloatingPointType (backfacecolor.green()) / 255.,
716 vtkFloatingPointType (backfacecolor.blue()) / 255.);
719 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
720 vtkFloatingPointType (edgecolor.green()) / 255.,
721 vtkFloatingPointType (edgecolor.blue()) / 255.);
723 /* Shrink factor and size edges */
724 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
725 anActor->SetLineWidth(aDlg->GetIntValue(1));
727 /* Nodes color and size */
728 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
729 vtkFloatingPointType (nodecolor.green()) / 255.,
730 vtkFloatingPointType (nodecolor.blue()) / 255.);
731 anActor->SetNodeSize(aDlg->GetIntValue(2));
733 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
734 if( !aGroupObject->_is_nil() )
736 SMESH::ElementType anElementType = aGroupObject->GetType();
738 switch( anElementType )
740 case SMESH::NODE: aColor = nodecolor; break;
741 case SMESH::EDGE: aColor = edgecolor; break;
742 default: aColor = color; break;
745 SALOMEDS::Color aGroupColor;
746 aGroupColor.R = (float)aColor.red() / 255.0;
747 aGroupColor.G = (float)aColor.green() / 255.0;
748 aGroupColor.B = (float)aColor.blue() / 255.0;
749 aGroupObject->SetColor( aGroupColor );
759 SMESH::RepaintCurrentView();
763 void Control( int theCommandID )
765 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
766 SALOME_ListIO selected;
768 aSel->selectedObjects( selected );
770 if( !selected.IsEmpty() ){
771 Handle(SALOME_InteractiveObject) anIO = selected.First();
774 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
775 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
776 switch ( theCommandID ){
778 aTitle = QObject::tr( "LENGTH_EDGES" );
779 aControl = SMESH_Actor::eLength;
782 aTitle = QObject::tr( "LENGTH2D_EDGES" );
783 aControl = SMESH_Actor::eLength2D;
786 aTitle = QObject::tr( "FREE_EDGES" );
787 aControl = SMESH_Actor::eFreeEdges;
790 aTitle = QObject::tr( "FREE_BORDERS" );
791 aControl = SMESH_Actor::eFreeBorders;
794 aTitle = QObject::tr( "MULTI_BORDERS" );
795 aControl = SMESH_Actor::eMultiConnection;
798 aTitle = QObject::tr( "FREE_NODES" );
799 aControl = SMESH_Actor::eFreeNodes;
802 aTitle = QObject::tr( "MULTI2D_BORDERS" );
803 aControl = SMESH_Actor::eMultiConnection2D;
806 aTitle = QObject::tr( "AREA_ELEMENTS" );
807 aControl = SMESH_Actor::eArea;
810 aTitle = QObject::tr( "TAPER_ELEMENTS" );
811 aControl = SMESH_Actor::eTaper;
814 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
815 aControl = SMESH_Actor::eAspectRatio;
818 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
819 aControl = SMESH_Actor::eAspectRatio3D;
822 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
823 aControl = SMESH_Actor::eMinimumAngle;
826 aTitle = QObject::tr( "WARP_ELEMENTS" );
827 aControl = SMESH_Actor::eWarping;
830 aTitle = QObject::tr( "SKEW_ELEMENTS" );
831 aControl = SMESH_Actor::eSkew;
834 aTitle = QObject::tr( "SMESH_VOLUME" );
835 aControl = SMESH_Actor::eVolume3D;
838 aTitle = QObject::tr( "FREE_FACES" );
839 aControl = SMESH_Actor::eFreeFaces;
842 anActor->SetControlMode(aControl);
843 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
844 SMESH::RepaintCurrentView();
851 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
852 MeshObjectType theType,
853 const QString theInTypeName,
854 QString & theOutTypeName)
856 SMESH_TypeFilter aTypeFilter( theType );
858 if( !theIO.IsNull() )
860 entry = theIO->getEntry();
861 LightApp_DataOwner owner( entry );
862 if ( aTypeFilter.isOk( &owner )) {
863 theOutTypeName = theInTypeName;
871 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
873 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
874 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
876 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
877 CORBA::String_var anID = aSComp->GetID().c_str();
878 if (!strcmp(anID.in(),theIO->getEntry()))
884 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
885 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
886 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
887 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
888 CheckOIType ( theIO, GROUP, "Group", aTypeName )
896 QString CheckHomogeneousSelection()
898 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
899 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
900 SALOME_ListIO selected;
902 aSel->selectedObjects( selected );
904 QString RefType = CheckTypeObject(selected.First());
905 SALOME_ListIteratorOfListIO It(selected);
906 for ( ; It.More(); It.Next())
908 Handle(SALOME_InteractiveObject) IObject = It.Value();
909 QString Type = CheckTypeObject(IObject);
910 if (Type.compare(RefType) != 0)
911 return "Heterogeneous Selection";
918 void SMESHGUI::OnEditDelete()
920 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
921 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
922 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
924 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
925 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
926 _PTR(GenericAttribute) anAttr;
927 _PTR(AttributeIOR) anIOR;
931 QString aParentComponent = QString::null;
932 Handle(SALOME_InteractiveObject) anIO;
933 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
936 QString cur = anIO->getComponentDataType();
937 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
939 // check if object is reference
940 _PTR(SObject) aRefSObj;
941 aNameList.append("\n - ");
942 if ( aSO->ReferencedObject( aRefSObj ) ) {
943 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
944 aNameList.append( aRefName );
945 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
948 aNameList.append(anIO->getName());
952 if( aParentComponent.isNull() )
953 aParentComponent = cur;
954 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
955 aParentComponent = "";
958 if ( objectCount == 0 )
959 return; // No Valid Objects Selected
961 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
962 SUIT_MessageBox::warning( SMESHGUI::desktop(),
963 QObject::tr("ERR_ERROR"),
964 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
967 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
968 if (SUIT_MessageBox::warning
969 (SMESHGUI::desktop(),
970 QObject::tr("SMESH_WRN_WARNING"),
971 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
972 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
973 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
976 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
977 SUIT_ViewManager* vm = anApp->activeViewManager();
978 int nbSf = vm->getViewsCount();
980 SALOME_ListIteratorOfListIO It(selected);
982 aStudyBuilder->NewCommand(); // There is a transaction
983 for( ; It.More(); It.Next()){ // loop on selected IO's
984 Handle(SALOME_InteractiveObject) IObject = It.Value();
985 if(IObject->hasEntry()) {
986 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
988 // disable removal of "SMESH" component object
989 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
991 if ( engineIOR() == anIOR->Value().c_str() )
994 //Check the referenced object
995 _PTR(SObject) aRefSObject;
996 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
997 aSO = aRefSObject; // Delete main Object instead of reference
999 // put the whole hierarchy of sub-objects of the selected SO into a list and
1000 // then treat them all starting from the deepest objects (at list back)
1002 std::list< _PTR(SObject) > listSO;
1003 listSO.push_back( aSO );
1004 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1005 for ( ; itSO != listSO.end(); ++itSO ) {
1006 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1007 for (it->InitEx(false); it->More(); it->Next())
1008 listSO.push_back( it->Value() );
1011 // treat SO's in the list starting from the back
1013 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1014 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1015 _PTR(SObject) SO = *ritSO;
1016 if ( !SO ) continue;
1017 std::string anEntry = SO->GetID();
1019 /** Erase graphical object **/
1020 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1021 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1022 for(int i = 0; i < nbSf; i++){
1023 SUIT_ViewWindow *sf = aViews[i];
1024 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1025 SMESH::RemoveActor(sf,anActor);
1030 /** Remove an object from data structures **/
1031 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1032 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1033 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1034 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1035 aMesh->RemoveGroup( aGroup );
1037 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1038 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1039 aMesh->RemoveSubMesh( aSubMesh );
1041 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1043 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1046 IObject = new SALOME_InteractiveObject
1047 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1048 QString objType = CheckTypeObject(IObject);
1049 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1050 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1051 aStudyBuilder->RemoveObjectWithChildren( SO );
1053 else {// default action: remove SObject from the study
1054 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1055 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1057 aStudyBuilder->RemoveObjectWithChildren( SO );
1061 } /* listSO back loop */
1062 } /* IObject->hasEntry() */
1064 aStudyBuilder->CommitCommand();
1066 /* Clear any previous selection */
1068 aSel->setSelectedObjects( l1 );
1070 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1075 SMESHGUI_EXPORT CAM_Module* createModule()
1077 return new SMESHGUI();
1081 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1083 //=============================================================================
1087 //=============================================================================
1088 SMESHGUI::SMESHGUI() :
1089 SalomeApp_Module( "SMESH" ),
1090 LightApp_Module( "SMESH" )
1092 if ( CORBA::is_nil( myComponentSMESH ) )
1094 CORBA::Boolean anIsEmbeddedMode;
1095 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1097 // 0019923: EDF 765 SMESH : default values of hypothesis
1098 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1099 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1100 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1101 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1102 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1105 myActiveDialogBox = 0;
1106 myFilterLibraryDlg = 0;
1110 SMESH::GetFilterManager();
1111 SMESH::GetPattern();
1113 /* load resources for all available meshers */
1114 SMESH::InitAvailableHypotheses();
1117 //=============================================================================
1121 //=============================================================================
1122 SMESHGUI::~SMESHGUI()
1124 SMESH::GetFilterManager()->Destroy();
1125 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1128 //=============================================================================
1132 //=============================================================================
1133 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1135 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1137 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1142 bool SMESHGUI::automaticUpdate()
1144 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1148 return resMgr->booleanValue( "SMESH", "auto_update", false );
1151 //=============================================================================
1155 //=============================================================================
1156 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1158 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1161 //=============================================================================
1165 //=============================================================================
1166 SMESHGUI* SMESHGUI::GetSMESHGUI()
1168 SMESHGUI* smeshMod = 0;
1169 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1172 CAM_Module* module = app->module( "Mesh" );
1173 smeshMod = dynamic_cast<SMESHGUI*>( module );
1176 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1178 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1181 _PTR(Study) aStudy = study->studyDS();
1183 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1192 Standard_EXPORT SMESHGUI* GetComponentGUI()
1194 return SMESHGUI::GetSMESHGUI();
1198 //=============================================================================
1202 //=============================================================================
1203 void SMESHGUI::SetState(int aState)
1208 //=============================================================================
1212 //=============================================================================
1213 void SMESHGUI::ResetState()
1218 //=============================================================================
1222 //=============================================================================
1223 void SMESHGUI::EmitSignalDeactivateDialog()
1225 emit SignalDeactivateActiveDialog();
1228 //=============================================================================
1232 //=============================================================================
1233 void SMESHGUI::EmitSignalStudyFrameChanged()
1235 emit SignalStudyFrameChanged();
1238 //=============================================================================
1242 //=============================================================================
1243 void SMESHGUI::EmitSignalCloseAllDialogs()
1245 emit SignalCloseAllDialogs();
1248 //=============================================================================
1252 //=============================================================================
1253 QDialog *SMESHGUI::GetActiveDialogBox()
1255 return myActiveDialogBox;
1258 //=============================================================================
1262 //=============================================================================
1263 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1265 myActiveDialogBox = (QDialog *) aDlg;
1269 //=============================================================================
1273 //=============================================================================
1274 SUIT_Desktop* SMESHGUI::desktop()
1276 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1278 return app->desktop();
1283 //=============================================================================
1287 //=============================================================================
1288 SalomeApp_Study* SMESHGUI::activeStudy()
1290 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1292 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1297 //=============================================================================
1301 //=============================================================================
1302 char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList)
1304 return theParametersList.join(":").toLatin1().data();
1307 //=============================================================================
1311 //=============================================================================
1312 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1314 /* Here the position is on the bottom right corner - 10 */
1315 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1317 SUIT_Desktop *PP = desktop();
1318 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1319 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1323 //=============================================================================
1327 //=============================================================================
1328 static int isStudyLocked(_PTR(Study) theStudy){
1329 return theStudy->GetProperties()->IsLocked();
1332 static bool checkLock(_PTR(Study) theStudy) {
1333 if (isStudyLocked(theStudy)) {
1334 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1335 QObject::tr("WRN_WARNING"),
1336 QObject::tr("WRN_STUDY_LOCKED") );
1342 //=======================================================================
1343 //function : CheckActiveStudyLocked
1345 //=======================================================================
1347 bool SMESHGUI::isActiveStudyLocked()
1349 _PTR(Study) aStudy = activeStudy()->studyDS();
1350 return checkLock( aStudy );
1353 //=============================================================================
1357 //=============================================================================
1358 bool SMESHGUI::OnGUIEvent( int theCommandID )
1360 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1364 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1365 SUIT_ResourceMgr* mgr = resourceMgr();
1369 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1370 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1373 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1374 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1376 //QAction* act = action( theCommandID );
1378 switch (theCommandID) {
1380 if(checkLock(aStudy)) break;
1388 if(checkLock(aStudy)) break;
1389 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1393 case 150: //MED FILE INFORMATION
1395 SALOME_ListIO selected;
1396 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1398 aSel->selectedObjects( selected );
1399 if( selected.Extent() )
1401 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1402 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1403 if ( !aMesh->_is_nil() )
1405 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1412 case 122: // EXPORT MED
1421 ::ExportMeshToFile(theCommandID);
1425 case 200: // SCALAR BAR
1427 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1428 SALOME_ListIO selected;
1430 aSel->selectedObjects( selected );
1432 if( selected.Extent() ) {
1433 Handle(SALOME_InteractiveObject) anIO = selected.First();
1434 if( anIO->hasEntry() ) {
1435 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1436 anActor->SetControlMode( SMESH_Actor::eNone );
1444 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1454 ::DisableAutoColor();
1457 case 1134: // Clipping
1458 case 1133: // Tranparency
1459 case 1132: // Colors / Size
1466 ::SetDisplayMode(theCommandID);
1469 //2D quadratic representation
1472 ::SetDisplayMode(theCommandID);
1476 case 216: // 0D elements
1479 case 219: // Volumes
1480 case 220: // All Entity
1481 ::SetDisplayEntity(theCommandID);
1484 case 221: // Orientation of faces
1486 LightApp_SelectionMgr* mgr = selectionMgr();
1487 SALOME_ListIO selected; mgr->selectedObjects( selected );
1489 SALOME_ListIteratorOfListIO it(selected);
1490 for( ; it.More(); it.Next()) {
1491 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1492 if(anIObject->hasEntry()) {
1493 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1494 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1503 if(checkLock(aStudy)) break;
1505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1508 SMESH::UpdateView();
1510 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1511 SMESH::OnVisuException();
1513 catch (...) { // PAL16774 (Crash after display of many groups)
1514 SMESH::OnVisuException();
1518 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1519 aSel->selectedObjects( l );
1520 aSel->setSelectedObjects( l );
1525 case 301: // DISPLAY
1526 case 302: // DISPLAY ONLY
1528 SMESH::EDisplaing anAction;
1529 switch (theCommandID) {
1530 case 300: anAction = SMESH::eErase; break;
1531 case 301: anAction = SMESH::eDisplay; break;
1532 case 302: anAction = SMESH::eDisplayOnly; break;
1535 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1536 SALOME_ListIO sel_objects, to_process;
1538 aSel->selectedObjects( sel_objects );
1540 if( theCommandID==302 )
1541 startOperation( myEraseAll );
1543 extractContainers( sel_objects, to_process );
1546 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1550 SALOME_ListIteratorOfListIO It( to_process );
1551 for ( ; It.More(); It.Next()) {
1552 Handle(SALOME_InteractiveObject) IOS = It.Value();
1553 if (IOS->hasEntry()) {
1554 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1555 break; // PAL16774 (Crash after display of many groups)
1556 if (anAction == SMESH::eDisplayOnly)
1557 anAction = SMESH::eDisplay;
1562 // PAL13338 + PAL15161 -->
1563 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1564 SMESH::UpdateView();
1565 // PAL13338 + PAL15161 <--
1567 catch (...) { // PAL16774 (Crash after display of many groups)
1568 SMESH::OnVisuException();
1571 if (anAction == SMESH::eErase) {
1573 aSel->setSelectedObjects( l1 );
1576 aSel->setSelectedObjects( to_process );
1583 if(checkLock(aStudy)) break;
1586 EmitSignalDeactivateDialog();
1588 ( new SMESHGUI_NodesDlg( this ) )->show();
1591 SUIT_MessageBox::warning(desktop(),
1592 tr("SMESH_WRN_WARNING"),
1593 tr("SMESH_WRN_VIEWER_VTK"));
1598 case 2151: // FILTER
1602 EmitSignalDeactivateDialog();
1603 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1608 case 406: // MOVE NODE
1612 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1613 tr( "NOT_A_VTK_VIEWER" ) );
1617 if(checkLock(aStudy)) break;
1618 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1622 case 701: // COMPUTE MESH
1623 case 711: // PRECOMPUTE MESH
1624 case 712: // EVALUATE MESH
1626 if (checkLock(aStudy)) break;
1627 startOperation( theCommandID );
1631 case 702: // Create mesh
1632 case 703: // Create sub-mesh
1633 case 704: // Edit mesh/sub-mesh
1634 startOperation( theCommandID );
1636 case 710: // Build compound mesh
1638 if (checkLock(aStudy)) break;
1639 EmitSignalDeactivateDialog();
1640 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1644 case 407: // DIAGONAL INVERSION
1645 case 408: // Delete diagonal
1649 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1650 tr( "NOT_A_VTK_VIEWER" ) );
1654 if ( checkLock( aStudy ) )
1657 /*Standard_Boolean aRes;
1658 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1659 if ( aMesh->_is_nil() )
1661 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1662 tr( "SMESH_BAD_SELECTION" ) );
1666 EmitSignalDeactivateDialog();
1667 if ( theCommandID == 407 )
1668 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1670 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1673 case 409: // Change orientation
1674 case 410: // Union of triangles
1675 case 411: // Cutting of quadrangles
1679 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1680 tr( "NOT_A_VTK_VIEWER" ) );
1684 if ( checkLock( aStudy ) )
1687 EmitSignalDeactivateDialog();
1688 SMESHGUI_MultiEditDlg* aDlg = NULL;
1689 if ( theCommandID == 409 )
1690 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1691 else if ( theCommandID == 410 )
1692 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1694 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1699 case 412: // Smoothing
1701 if(checkLock(aStudy)) break;
1703 EmitSignalDeactivateDialog();
1704 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1707 SUIT_MessageBox::warning(desktop(),
1708 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1712 case 413: // Extrusion
1714 if (checkLock(aStudy)) break;
1716 EmitSignalDeactivateDialog();
1717 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1719 SUIT_MessageBox::warning(desktop(),
1720 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1724 case 414: // Revolution
1726 if(checkLock(aStudy)) break;
1728 EmitSignalDeactivateDialog();
1729 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1732 SUIT_MessageBox::warning(desktop(),
1733 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1737 case 415: // Pattern mapping
1739 if ( checkLock( aStudy ) )
1743 EmitSignalDeactivateDialog();
1744 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1747 SUIT_MessageBox::warning(desktop(),
1748 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1752 case 416: // Extrusion along a path
1754 if (checkLock(aStudy)) break;
1756 EmitSignalDeactivateDialog();
1757 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1759 SUIT_MessageBox::warning(desktop(),
1760 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1764 case 417: // Convert mesh to quadratic
1766 startOperation( 417 );
1767 /* if (checkLock(aStudy)) break;
1769 EmitSignalDeactivateDialog();
1770 new SMESHGUI_ConvToQuadDlg();
1772 SUIT_MessageBox::warning(desktop(),
1773 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1777 case 418: // create 2D mesh from 3D
1779 startOperation( 418 );
1782 case 806: // CREATE GEO GROUP
1784 startOperation( 806 );
1787 case 801: // CREATE GROUP
1791 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1792 tr( "NOT_A_VTK_VIEWER" ) );
1796 if(checkLock(aStudy)) break;
1797 EmitSignalDeactivateDialog();
1798 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1800 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1801 SALOME_ListIO selected;
1803 aSel->selectedObjects( selected );
1805 int nbSel = selected.Extent();
1807 // check if mesh is selected
1808 aMesh = SMESH::GetMeshByIO( selected.First() );
1810 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1815 case 802: // CONSTRUCT GROUP
1819 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1820 tr( "NOT_A_VTK_VIEWER" ) );
1824 if(checkLock(aStudy)) break;
1825 EmitSignalDeactivateDialog();
1827 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1828 SALOME_ListIO selected;
1830 aSel->selectedObjects( selected );
1832 int nbSel = selected.Extent();
1834 // check if submesh is selected
1835 Handle(SALOME_InteractiveObject) IObject = selected.First();
1836 if (IObject->hasEntry()) {
1837 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1839 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1840 if (!aSubMesh->_is_nil()) {
1842 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1843 // get submesh elements list by types
1844 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1845 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1846 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1847 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1848 // create group for each type o elements
1849 QString aName = IObject->getName();
1850 if (aNodes->length() > 0) {
1851 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1852 aGroup->Add(aNodes.inout());
1854 if (aEdges->length() > 0) {
1855 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1856 aGroup->Add(aEdges.inout());
1858 if (aFaces->length() > 0) {
1859 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1860 aGroup->Add(aFaces.inout());
1862 if (aVolumes->length() > 0) {
1863 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1864 aGroup->Add(aVolumes.inout());
1869 catch(const SALOME::SALOME_Exception & S_ex){
1870 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1877 SUIT_MessageBox::warning(desktop(),
1878 tr("SMESH_WRN_WARNING"),
1879 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1884 case 803: // EDIT GROUP
1888 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1889 tr( "NOT_A_VTK_VIEWER" ) );
1893 if(checkLock(aStudy)) break;
1894 EmitSignalDeactivateDialog();
1896 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1897 SALOME_ListIO selected;
1899 aSel->selectedObjects( selected );
1901 SALOME_ListIteratorOfListIO It (selected);
1902 int nbSelectedGroups = 0;
1903 for ( ; It.More(); It.Next() )
1905 SMESH::SMESH_GroupBase_var aGroup =
1906 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1907 if (!aGroup->_is_nil()) {
1909 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1913 if (nbSelectedGroups == 0)
1915 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1921 case 804: // Add elements to group
1923 if(checkLock(aStudy)) break;
1924 if (myState == 800) {
1925 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1926 if (aDlg) aDlg->onAdd();
1931 case 805: // Remove elements from group
1933 if(checkLock(aStudy)) break;
1934 if (myState == 800) {
1935 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1936 if (aDlg) aDlg->onRemove();
1941 case 815: // Edit GEOM GROUP as standalone
1945 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1946 tr( "NOT_A_VTK_VIEWER" ) );
1950 if(checkLock(aStudy)) break;
1951 EmitSignalDeactivateDialog();
1953 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1954 SALOME_ListIO selected;
1956 aSel->selectedObjects( selected );
1958 SALOME_ListIteratorOfListIO It (selected);
1959 for ( ; It.More(); It.Next() )
1961 SMESH::SMESH_GroupOnGeom_var aGroup =
1962 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
1963 if (!aGroup->_is_nil()) {
1964 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
1971 case 810: // Union Groups
1972 case 811: // Intersect groups
1973 case 812: // Cut groups
1977 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1978 tr( "NOT_A_VTK_VIEWER" ) );
1982 if ( checkLock( aStudy ) )
1985 EmitSignalDeactivateDialog();
1987 SMESHGUI_GroupOpDlg* aDlg = 0;
1988 if ( theCommandID == 810 )
1989 aDlg = new SMESHGUI_UnionGroupsDlg( this );
1990 else if ( theCommandID == 811 )
1991 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
1993 aDlg = new SMESHGUI_CutGroupsDlg( this );
2000 case 814: // Create groups of entities from existing groups of superior dimensions
2002 if ( checkLock( aStudy ) )
2005 EmitSignalDeactivateDialog();
2006 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2012 case 813: // Delete groups with their contents
2016 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2017 tr( "NOT_A_VTK_VIEWER" ) );
2021 if ( checkLock( aStudy ) )
2024 EmitSignalDeactivateDialog();
2026 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2030 case 900: // MESH INFOS
2032 EmitSignalDeactivateDialog();
2033 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2034 SALOME_ListIO selected;
2036 aSel->selectedObjects( selected );
2038 if ( selected.Extent() > 1 ) { // a dlg for each IO
2040 SALOME_ListIteratorOfListIO It (selected);
2041 for ( ; It.More(); It.Next() ) {
2042 IOs.Clear(); IOs.Append( It.Value() );
2043 aSel->setSelectedObjects( IOs );
2044 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2046 // restore selection
2047 aSel->setSelectedObjects( selected );
2050 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2054 case 902: // STANDARD MESH INFOS
2056 EmitSignalDeactivateDialog();
2057 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2058 SALOME_ListIO selected;
2060 aSel->selectedObjects( selected );
2062 if ( selected.Extent() > 1 ) { // a dlg for each IO
2064 SALOME_ListIteratorOfListIO It (selected);
2065 for ( ; It.More(); It.Next() ) {
2067 IOs.Append( It.Value() );
2068 aSel->setSelectedObjects( IOs );
2069 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2071 // restore selection
2072 aSel->setSelectedObjects( selected );
2075 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2079 case 903: // WHAT IS
2081 EmitSignalDeactivateDialog();
2082 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2086 case 1100: // EDIT HYPOTHESIS
2088 if(checkLock(aStudy)) break;
2090 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2091 SALOME_ListIO selected;
2093 aSel->selectedObjects( selected );
2095 int nbSel = selected.Extent();
2098 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2099 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2101 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2102 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2103 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2104 if ( !aHypothesis->_is_nil() )
2107 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2108 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2110 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2121 case 1101: // RENAME
2123 if ( checkLock( aStudy ) )
2126 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2127 SALOME_ListIO selected;
2129 aSel->selectedObjects( selected );
2131 bool isAny = false; // is there any appropriate object selected
2133 SALOME_ListIteratorOfListIO It( selected );
2134 for ( ; It.More(); It.Next() )
2136 Handle(SALOME_InteractiveObject) IObject = It.Value();
2137 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2138 _PTR(GenericAttribute) anAttr;
2139 _PTR(AttributeName) aName;
2142 if ( obj->FindAttribute(anAttr, "AttributeName") )
2145 QString newName = QString(aName->Value().c_str());
2147 // check type to prevent renaming of inappropriate objects
2148 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2149 if (aType == MESH || aType == GROUP ||
2150 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2151 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2152 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2153 aType == HYPOTHESIS || aType == ALGORITHM)
2156 newName = LightApp_NameDlg::getName(desktop(), newName);
2157 if ( !newName.isEmpty() )
2159 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2161 // update name of group object and its actor
2162 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2163 if( !aGroupObject->_is_nil() )
2165 aGroupObject->SetName( newName.toLatin1().data() );
2166 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2167 anActor->setName( newName.toLatin1().data() );
2178 SUIT_MessageBox::warning(desktop(),
2179 QObject::tr("SMESH_WRN_WARNING"),
2180 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2185 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2187 if(checkLock(aStudy)) break;
2188 SUIT_OverrideCursor wc;
2190 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2191 SALOME_ListIO selected;
2193 aSel->selectedObjects( selected, QString::null, false );
2195 SALOME_ListIteratorOfListIO It(selected);
2196 for (int i = 0; It.More(); It.Next(), i++) {
2197 Handle(SALOME_InteractiveObject) IObject = It.Value();
2198 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2201 aSel->setSelectedObjects( l1 );
2206 case 4009: // ELEM0D
2207 case 4010: // GEOM::EDGE
2208 case 4021: // TRIANGLE
2210 case 4023: // POLYGON
2214 if(checkLock(aStudy)) break;
2216 EmitSignalDeactivateDialog();
2217 SMDSAbs_ElementType type = SMDSAbs_Edge;
2219 switch (theCommandID) {
2220 case 4009: // ELEM0D
2221 type = SMDSAbs_0DElement; nbNodes = 1; break;
2222 case 4021: // TRIANGLE
2223 type = SMDSAbs_Face; nbNodes = 3; break;
2225 type = SMDSAbs_Face; nbNodes = 4; break;
2227 type = SMDSAbs_Volume; nbNodes = 4; break;
2228 case 4023: // POLYGON
2229 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2231 type = SMDSAbs_Volume; nbNodes = 8; break;
2232 case 4033: // POLYHEDRE
2233 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2236 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2239 SUIT_MessageBox::warning(desktop(),
2240 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2244 case 4033: // POLYHEDRON
2246 if(checkLock(aStudy)) break;
2248 EmitSignalDeactivateDialog();
2249 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2252 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2253 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2257 case 4034: // QUADRATIC EDGE
2258 case 4035: // QUADRATIC TRIANGLE
2259 case 4036: // QUADRATIC QUADRANGLE
2260 case 4037: // QUADRATIC TETRAHEDRON
2261 case 4038: // QUADRATIC PYRAMID
2262 case 4039: // QUADRATIC PENTAHEDRON
2263 case 4040: // QUADRATIC HEXAHEDRON
2265 if(checkLock(aStudy)) break;
2267 EmitSignalDeactivateDialog();
2270 switch (theCommandID) {
2272 type = QUAD_EDGE; break;
2274 type = QUAD_TRIANGLE; break;
2276 type = QUAD_QUADRANGLE; break;
2278 type = QUAD_TETRAHEDRON; break;
2280 type = QUAD_PYRAMID; break;
2282 type = QUAD_PENTAHEDRON; break;
2284 type = QUAD_HEXAHEDRON;
2288 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2291 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2292 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2296 case 4041: // REMOVES NODES
2298 if(checkLock(aStudy)) break;
2300 EmitSignalDeactivateDialog();
2301 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2304 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2305 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2309 case 4042: // REMOVES ELEMENTS
2311 if(checkLock(aStudy)) break;
2313 EmitSignalDeactivateDialog();
2314 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2318 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2319 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2323 case 4043: { // CLEAR_MESH
2325 if(checkLock(aStudy)) break;
2327 SALOME_ListIO selected;
2328 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2329 aSel->selectedObjects( selected );
2331 SUIT_OverrideCursor wc;
2332 SALOME_ListIteratorOfListIO It (selected);
2333 for ( ; It.More(); It.Next() )
2335 Handle(SALOME_InteractiveObject) IOS = It.Value();
2336 SMESH::SMESH_Mesh_var aMesh =
2337 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2338 if ( aMesh->_is_nil()) continue;
2340 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2342 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2343 SMESH::ModifiedMesh( aMeshSObj, false, true);
2344 // hide groups and submeshes
2345 _PTR(ChildIterator) anIter =
2346 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2347 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2349 _PTR(SObject) so = anIter->Value();
2350 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2353 catch (const SALOME::SALOME_Exception& S_ex){
2355 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2359 SMESH::UpdateView();
2363 case 4051: // RENUMBERING NODES
2365 if(checkLock(aStudy)) break;
2367 EmitSignalDeactivateDialog();
2368 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2372 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2373 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2377 case 4052: // RENUMBERING ELEMENTS
2379 if(checkLock(aStudy)) break;
2381 EmitSignalDeactivateDialog();
2382 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2386 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2387 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2391 case 4061: // TRANSLATION
2393 if(checkLock(aStudy)) break;
2395 EmitSignalDeactivateDialog();
2396 ( new SMESHGUI_TranslationDlg( this ) )->show();
2399 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2404 case 4062: // ROTATION
2406 if(checkLock(aStudy)) break;
2408 EmitSignalDeactivateDialog();
2409 ( new SMESHGUI_RotationDlg( this ) )->show();
2412 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2413 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2417 case 4063: // SYMMETRY
2419 if(checkLock(aStudy)) break;
2421 EmitSignalDeactivateDialog();
2422 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2425 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2426 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2430 case 4064: // SEWING
2432 if(checkLock(aStudy)) break;
2434 EmitSignalDeactivateDialog();
2435 ( new SMESHGUI_SewingDlg( this ) )->show();
2438 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2439 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2443 case 4065: // MERGE NODES
2445 if(checkLock(aStudy)) break;
2447 EmitSignalDeactivateDialog();
2448 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2451 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2452 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2456 case 4066: // MERGE EQUAL ELEMENTS
2458 if (checkLock(aStudy)) break;
2460 EmitSignalDeactivateDialog();
2461 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2463 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2464 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2469 case 4067: // MAKE MESH PASS THROUGH POINT
2470 startOperation( 4067 );
2473 case 5105: // Library of selection filters
2475 static QList<int> aTypes;
2476 if ( aTypes.isEmpty() )
2478 aTypes.append( SMESH::NODE );
2479 aTypes.append( SMESH::EDGE );
2480 aTypes.append( SMESH::FACE );
2481 aTypes.append( SMESH::VOLUME );
2483 if (!myFilterLibraryDlg)
2484 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2485 else if (myFilterLibraryDlg->isHidden())
2486 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2487 myFilterLibraryDlg->raise();
2491 case 6017: // CONTROLS
2509 LightApp_SelectionMgr* mgr = selectionMgr();
2510 SALOME_ListIO selected; mgr->selectedObjects( selected );
2512 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2513 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2515 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2516 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2517 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2518 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2519 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2520 ::Control( theCommandID );
2525 SUIT_MessageBox::warning(desktop(),
2526 tr( "SMESH_WRN_WARNING" ),
2527 tr( "SMESH_BAD_SELECTION" ) );
2531 SUIT_MessageBox::warning(desktop(),
2532 tr( "SMESH_WRN_WARNING" ),
2533 tr( "NOT_A_VTK_VIEWER" ) );
2538 LightApp_SelectionMgr* mgr = selectionMgr();
2539 SALOME_ListIO selected; mgr->selectedObjects( selected );
2541 SALOME_ListIteratorOfListIO it(selected);
2542 for( ; it.More(); it.Next()) {
2543 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2544 if(anIObject->hasEntry()) {
2545 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2546 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2554 LightApp_SelectionMgr* mgr = selectionMgr();
2555 SALOME_ListIO selected; mgr->selectedObjects( selected );
2557 if (selected.Extent() == 1) {
2558 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2559 if(anIObject->hasEntry())
2560 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2561 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2568 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2569 //updateObjBrowser();
2573 //=============================================================================
2577 //=============================================================================
2578 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2583 //=============================================================================
2587 //=============================================================================
2588 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2593 //=============================================================================
2597 //=============================================================================
2598 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2603 //=============================================================================
2604 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2605 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2607 //=============================================================================
2608 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2609 SUIT_ViewWindow* wnd )
2611 if(theIO->hasEntry()){
2612 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2613 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2617 //=======================================================================
2618 // function : createSMESHAction
2620 //=======================================================================
2621 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2624 QWidget* parent = application()->desktop();
2625 SUIT_ResourceMgr* resMgr = resourceMgr();
2627 if ( !icon_id.isEmpty() )
2628 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2630 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2631 if ( !pix.isNull() )
2632 icon = QIcon( pix );
2634 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2635 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2636 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2638 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2641 //=======================================================================
2642 // function : createPopupItem
2644 //=======================================================================
2645 void SMESHGUI::createPopupItem( const int id,
2646 const QString& clients,
2647 const QString& types,
2648 const QString& theRule,
2653 parentId = popupMgr()->actionId( action( pId ) );
2655 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2656 popupMgr()->insert( action( id ), parentId, 0 );
2658 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2659 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2660 QString rule = "(%1) and (%2) and (%3)";
2661 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2662 if( clients.isEmpty() )
2663 rule = rule.arg( QString( "true" ) );
2665 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2666 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2669 bool cont = myRules.contains( id );
2671 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2673 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2674 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2677 //=======================================================================
2678 // function : initialize
2680 //=======================================================================
2681 void SMESHGUI::initialize( CAM_Application* app )
2683 SalomeApp_Module::initialize( app );
2685 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2687 /* Automatic Update flag */
2688 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2690 // ----- create actions --------------
2692 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2693 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2694 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2695 createSMESHAction( 114, "NUM" );
2696 createSMESHAction( 121, "DAT" );
2697 createSMESHAction( 122, "MED" );
2698 createSMESHAction( 123, "UNV" );
2699 createSMESHAction( 140, "STL" );
2700 createSMESHAction( 124, "EXPORT_DAT" );
2701 createSMESHAction( 125, "EXPORT_MED" );
2702 createSMESHAction( 126, "EXPORT_UNV" );
2703 createSMESHAction( 141, "EXPORT_STL" );
2704 createSMESHAction( 150, "FILE_INFO" );
2705 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2706 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2707 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2708 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2709 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2710 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2711 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2712 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2713 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2714 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2715 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2716 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2717 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2718 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2719 createSMESHAction( 804, "ADD" );
2720 createSMESHAction( 805, "REMOVE" );
2721 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2722 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2723 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2724 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2725 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2726 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2727 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2728 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2729 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2730 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2731 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2732 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2733 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2734 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2735 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2736 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2737 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2738 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2739 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2740 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2741 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2742 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2743 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2744 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2745 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2746 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2747 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2748 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2749 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2750 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2751 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2752 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2753 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2754 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2755 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2756 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2757 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2758 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2759 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2760 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2761 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2762 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2763 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2764 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2765 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2766 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2767 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2768 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2769 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2770 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2771 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2772 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2773 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2774 createSMESHAction( 415, "MAP", "ICON_MAP" );
2775 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2776 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2777 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2778 createSMESHAction( 200, "RESET" );
2779 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2780 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2781 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2782 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2783 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2784 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2785 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2786 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2787 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2788 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2789 createSMESHAction( 220, "ALL" );
2790 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2792 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2793 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2795 createSMESHAction( 1100, "EDIT_HYPO" );
2796 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2797 createSMESHAction( 1102, "UNASSIGN" );
2798 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2799 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2800 createSMESHAction( 1131, "DISPMODE" );
2801 createSMESHAction( 1132, "COLORS" );
2802 createSMESHAction( 1133, "TRANSP" );
2803 createSMESHAction( 1134, "CLIP" );
2804 createSMESHAction( 1135, "DISP_ENT" );
2805 createSMESHAction( 1136, "AUTO_COLOR" );
2806 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2807 createSMESHAction( 2000, "CTRL" );
2809 createSMESHAction( 300, "ERASE" );
2810 createSMESHAction( 301, "DISPLAY" );
2811 createSMESHAction( 302, "DISPLAY_ONLY" );
2812 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2813 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2814 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2815 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2816 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2817 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2818 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2819 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2821 // ----- create menu --------------
2822 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2823 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2824 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2825 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2826 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2827 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2828 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2830 createMenu( separator(), fileId );
2832 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2833 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2834 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2835 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2836 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2837 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2839 createMenu( 111, importId, -1 );
2840 createMenu( 112, importId, -1 );
2841 createMenu( 113, importId, -1 );
2843 createMenu( 121, exportId, -1 );
2844 createMenu( 122, exportId, -1 );
2845 createMenu( 123, exportId, -1 );
2846 createMenu( 140, exportId, -1 ); // export to stl STL
2848 createMenu( separator(), fileId, 10 );
2850 createMenu( 33, editId, -1 );
2852 createMenu( 5105, toolsId, -1 );
2854 createMenu( 702, meshId, -1 ); // "Mesh" menu
2855 createMenu( 703, meshId, -1 );
2856 createMenu( 704, meshId, -1 );
2857 createMenu( 710, meshId, -1 );
2858 createMenu( separator(), meshId, -1 );
2859 createMenu( 701, meshId, -1 );
2860 createMenu( 711, meshId, -1 );
2861 createMenu( 712, meshId, -1 );
2862 createMenu( separator(), meshId, -1 );
2863 createMenu( 801, meshId, -1 );
2864 createMenu( 806, meshId, -1 );
2865 createMenu( 802, meshId, -1 );
2866 createMenu( 803, meshId, -1 );
2867 createMenu( 815, meshId, -1 );
2868 createMenu( separator(), meshId, -1 );
2869 createMenu( 810, meshId, -1 );
2870 createMenu( 811, meshId, -1 );
2871 createMenu( 812, meshId, -1 );
2872 createMenu( separator(), meshId, -1 );
2873 createMenu( 814, meshId, -1 );
2874 createMenu( separator(), meshId, -1 );
2875 createMenu( 813, meshId, -1 );
2876 createMenu( separator(), meshId, -1 );
2877 createMenu( 900, meshId, -1 );
2878 createMenu( 902, meshId, -1 );
2879 createMenu( 903, meshId, -1 );
2880 createMenu( separator(), meshId, -1 );
2882 createMenu( 6003, ctrlId, -1 );
2883 createMenu( 6001, ctrlId, -1 );
2884 createMenu( 6004, ctrlId, -1 );
2885 createMenu( separator(), ctrlId, -1 );
2886 createMenu( 6005, ctrlId, -1 );
2887 createMenu( 6002, ctrlId, -1 );
2888 createMenu( 6018, ctrlId, -1 );
2889 createMenu( 6019, ctrlId, -1 );
2890 createMenu( 6011, ctrlId, -1 );
2891 createMenu( 6012, ctrlId, -1 );
2892 createMenu( 6013, ctrlId, -1 );
2893 createMenu( 6014, ctrlId, -1 );
2894 createMenu( 6015, ctrlId, -1 );
2895 createMenu( 6016, ctrlId, -1 );
2896 createMenu( separator(), ctrlId, -1 );
2897 createMenu( 6017, ctrlId, -1 );
2898 createMenu( 6009, ctrlId, -1 );
2899 createMenu( 6021, ctrlId, -1 );
2900 createMenu( separator(), ctrlId, -1 );
2902 createMenu( 4000, addId, -1 );
2903 createMenu( 4009, addId, -1 );
2904 createMenu( 4010, addId, -1 );
2905 createMenu( 4021, addId, -1 );
2906 createMenu( 4022, addId, -1 );
2907 createMenu( 4023, addId, -1 );
2908 createMenu( 4031, addId, -1 );
2909 createMenu( 4032, addId, -1 );
2910 createMenu( 4033, addId, -1 );
2911 createMenu( separator(), addId, -1 );
2912 createMenu( 4034, addId, -1 );
2913 createMenu( 4035, addId, -1 );
2914 createMenu( 4036, addId, -1 );
2915 createMenu( 4037, addId, -1 );
2916 createMenu( 4038, addId, -1 );
2917 createMenu( 4039, addId, -1 );
2918 createMenu( 4040, addId, -1 );
2920 createMenu( 4041, removeId, -1 );
2921 createMenu( 4042, removeId, -1 );
2922 createMenu( 4043, removeId, -1 );
2924 createMenu( 4051, renumId, -1 );
2925 createMenu( 4052, renumId, -1 );
2927 createMenu( 4061, transfId, -1 );
2928 createMenu( 4062, transfId, -1 );
2929 createMenu( 4063, transfId, -1 );
2930 createMenu( 4064, transfId, -1 );
2931 createMenu( 4065, transfId, -1 );
2932 createMenu( 4066, transfId, -1 );
2934 createMenu( 406, modifyId, -1 );
2935 createMenu( 4067,modifyId, -1 );
2936 createMenu( 407, modifyId, -1 );
2937 createMenu( 408, modifyId, -1 );
2938 createMenu( 409, modifyId, -1 );
2939 createMenu( 410, modifyId, -1 );
2940 createMenu( 411, modifyId, -1 );
2941 createMenu( 412, modifyId, -1 );
2942 createMenu( 413, modifyId, -1 );
2943 createMenu( 416, modifyId, -1 );
2944 createMenu( 414, modifyId, -1 );
2945 createMenu( 415, modifyId, -1 );
2946 createMenu( 417, modifyId, -1 );
2947 createMenu( 418, modifyId, -1 );
2949 createMenu( 214, viewId, -1 );
2951 // ----- create toolbars --------------
2952 int meshTb = createTool( tr( "TB_MESH" ) ),
2953 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2954 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2955 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2956 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2958 createTool( 702, meshTb );
2959 createTool( 703, meshTb );
2960 createTool( 704, meshTb );
2961 createTool( 710, meshTb );
2962 createTool( separator(), meshTb );
2963 createTool( 701, meshTb );
2964 createTool( 711, meshTb );
2965 createTool( 712, meshTb );
2966 createTool( separator(), meshTb );
2967 createTool( 801, meshTb );
2968 createTool( 806, meshTb );
2969 createTool( 802, meshTb );
2970 createTool( 803, meshTb );
2971 //createTool( 815, meshTb );
2972 createTool( separator(), meshTb );
2973 createTool( 900, meshTb );
2974 createTool( 902, meshTb );
2975 createTool( 903, meshTb );
2976 createTool( separator(), meshTb );
2978 createTool( 6001, ctrlTb );
2979 createTool( 6003, ctrlTb );
2980 createTool( 6004, ctrlTb );
2981 createTool( separator(), ctrlTb );
2982 createTool( 6005, ctrlTb );
2983 createTool( 6002, ctrlTb );
2984 createTool( 6018, ctrlTb );
2985 createTool( 6019, ctrlTb );
2986 createTool( 6011, ctrlTb );
2987 createTool( 6012, ctrlTb );
2988 createTool( 6013, ctrlTb );
2989 createTool( 6014, ctrlTb );
2990 createTool( 6015, ctrlTb );
2991 createTool( 6016, ctrlTb );
2992 createTool( separator(), ctrlTb );
2993 createTool( 6017, ctrlTb );
2994 createTool( 6009, ctrlTb );
2995 createTool( 6021, ctrlTb );
2996 createTool( separator(), ctrlTb );
2998 createTool( 4000, addRemTb );
2999 createTool( 4009, addRemTb );
3000 createTool( 4010, addRemTb );
3001 createTool( 4021, addRemTb );
3002 createTool( 4022, addRemTb );
3003 createTool( 4023, addRemTb );
3004 createTool( 4031, addRemTb );
3005 createTool( 4032, addRemTb );
3006 createTool( 4033, addRemTb );
3007 createTool( separator(), addRemTb );
3008 createTool( 4034, addRemTb );
3009 createTool( 4035, addRemTb );
3010 createTool( 4036, addRemTb );
3011 createTool( 4037, addRemTb );
3012 createTool( 4038, addRemTb );
3013 createTool( 4039, addRemTb );
3014 createTool( 4040, addRemTb );
3015 createTool( separator(), addRemTb );
3016 createTool( 4041, addRemTb );
3017 createTool( 4042, addRemTb );
3018 createTool( 4043, addRemTb );
3019 createTool( separator(), addRemTb );
3020 createTool( 4051, addRemTb );
3021 createTool( 4052, addRemTb );
3022 createTool( separator(), addRemTb );
3023 createTool( 4061, addRemTb );
3024 createTool( 4062, addRemTb );
3025 createTool( 4063, addRemTb );
3026 createTool( 4064, addRemTb );
3027 createTool( 4065, addRemTb );
3028 createTool( 4066, addRemTb );
3029 createTool( separator(), addRemTb );
3031 createTool( 406, modifyTb );
3032 createTool( 4067,modifyTb );
3033 createTool( 407, modifyTb );
3034 createTool( 408, modifyTb );
3035 createTool( 409, modifyTb );
3036 createTool( 410, modifyTb );
3037 createTool( 411, modifyTb );
3038 createTool( 412, modifyTb );
3039 createTool( 413, modifyTb );
3040 createTool( 416, modifyTb );
3041 createTool( 414, modifyTb );
3042 createTool( 415, modifyTb );
3043 createTool( 417, modifyTb );
3044 createTool( 418, modifyTb );
3046 createTool( 214, dispModeTb );
3048 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3049 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3052 QString OB = "'ObjectBrowser'",
3053 View = "'" + SVTK_Viewer::Type() + "'",
3055 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3056 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3057 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3058 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3059 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3060 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3061 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3062 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3063 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3064 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3065 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3067 mesh_group = mesh + " " + subMesh + " " + group,
3068 hyp_alg = hypo + " " + algo;
3070 // popup for object browser
3072 isInvisible("not( isVisible )"),
3073 isEmpty("numberOfNodes = 0"),
3074 isNotEmpty("numberOfNodes <> 0"),
3076 // has nodes, edges, etc in VISIBLE! actor
3077 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3078 hasElems("(count( elemTypes ) > 0)"),
3079 hasDifferentElems("(count( elemTypes ) > 1)"),
3080 hasElems0d("({'Elem0d'} in elemTypes)"),
3081 hasEdges("({'Edge'} in elemTypes)"),
3082 hasFaces("({'Face'} in elemTypes)"),
3083 hasVolumes("({'Volume'} in elemTypes)");
3085 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3086 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3087 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3088 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3089 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3090 createPopupItem( 803, OB, group ); // EDIT_GROUP
3091 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3093 popupMgr()->insert( separator(), -1, 0 );
3094 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3095 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3096 createPopupItem( 712, OB, mesh, "&& isComputable" ); // COMPUTE
3097 createPopupItem( 214, OB, mesh_group ); // UPDATE
3098 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3099 createPopupItem( 902, OB, mesh ); // STD_INFO
3100 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3101 popupMgr()->insert( separator(), -1, 0 );
3102 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3103 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3104 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3105 popupMgr()->insert( separator(), -1, 0 );
3106 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3107 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3108 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3109 popupMgr()->insert( separator(), -1, 0 );
3110 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3111 popupMgr()->insert( separator(), -1, 0 );
3112 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3113 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3114 popupMgr()->insert( separator(), -1, 0 );
3116 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3118 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3119 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3120 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3121 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3122 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3123 popupMgr()->insert( separator(), -1, 0 );
3126 createPopupItem( 803, View, group ); // EDIT_GROUP
3127 createPopupItem( 804, View, elems ); // ADD
3128 createPopupItem( 805, View, elems ); // REMOVE
3130 popupMgr()->insert( separator(), -1, 0 );
3131 createPopupItem( 214, View, mesh_group ); // UPDATE
3132 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3133 createPopupItem( 902, View, mesh ); // STD_INFO
3134 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3135 popupMgr()->insert( separator(), -1, 0 );
3137 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3138 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3139 popupMgr()->insert( separator(), -1, 0 );
3142 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3143 QString aType = QString( "%1type in {%2}" ).arg( lc );
3144 aType = aType.arg( mesh_group );
3145 QString aMeshInVTK = aClient + "&&" + aType;
3147 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3148 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3149 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3151 //-------------------------------------------------
3153 //-------------------------------------------------
3154 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3156 popupMgr()->insert( action( 9010 ), anId, -1 );
3157 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3158 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3160 popupMgr()->insert( action( 9011 ), anId, -1 );
3161 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3162 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3164 popupMgr()->insert( separator(), -1, -1 );
3166 //-------------------------------------------------
3168 //-------------------------------------------------
3169 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3171 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3172 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3173 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3175 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3176 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3177 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3179 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3180 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3181 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3183 popupMgr()->insert( separator(), anId, -1 );
3185 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3186 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3187 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3189 //-------------------------------------------------
3191 //-------------------------------------------------
3192 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3194 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3196 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3197 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3198 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3200 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3201 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3202 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3204 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3205 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3206 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3208 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3209 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3210 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3212 popupMgr()->insert( separator(), anId, -1 );
3214 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3215 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3218 //-------------------------------------------------
3219 // Representation of the 2D Quadratic elements
3220 //-------------------------------------------------
3221 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3222 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3223 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3224 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3226 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3227 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3228 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3230 //-------------------------------------------------
3231 // Orientation of faces
3232 //-------------------------------------------------
3233 popupMgr()->insert( action( 221 ), -1, -1 );
3234 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3235 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3237 //-------------------------------------------------
3239 //-------------------------------------------------
3240 popupMgr()->insert( action( 1132 ), -1, -1 );
3241 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3243 //-------------------------------------------------
3245 //-------------------------------------------------
3246 popupMgr()->insert( action( 1133 ), -1, -1 );
3247 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3249 //-------------------------------------------------
3251 //-------------------------------------------------
3252 popupMgr()->insert( action( 1134 ), -1, -1 );
3253 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3255 popupMgr()->insert( separator(), -1, -1 );
3257 //-------------------------------------------------
3259 //-------------------------------------------------
3261 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3262 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3263 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3264 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3266 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3268 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3269 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3271 popupMgr()->insert( separator(), anId, -1 );
3273 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3274 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3275 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3277 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3278 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3279 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3281 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3282 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3283 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3285 popupMgr()->insert( separator(), anId, -1 );
3287 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3288 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3289 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3291 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3292 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3293 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3295 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3296 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3297 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3299 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3300 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3301 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3303 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3304 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3305 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3307 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3308 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3309 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3311 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3312 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3313 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3315 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3316 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3317 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3319 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3320 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3321 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3323 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3324 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3325 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3327 popupMgr()->insert( separator(), anId, -1 );
3329 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3330 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3331 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3333 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3334 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3335 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3337 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3338 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3339 QtxPopupMgr::VisibleRule );
3340 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3342 popupMgr()->insert( separator(), anId, -1 );
3344 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3345 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3347 popupMgr()->insert( separator(), -1, -1 );
3349 //-------------------------------------------------
3351 //-------------------------------------------------
3352 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3353 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3354 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3355 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3357 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3358 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3360 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3361 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3363 popupMgr()->insert( separator(), -1, -1 );
3365 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3366 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3369 //================================================================================
3371 * \brief Return true if SMESH or GEOM objects are selected.
3372 * Is called form LightApp_Module::activateModule() which clear selection if
3373 * not isSelectionCompatible()
3375 //================================================================================
3377 bool SMESHGUI::isSelectionCompatible()
3379 bool isCompatible = true;
3380 SALOME_ListIO selected;
3381 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3382 Sel->selectedObjects( selected );
3384 SALOME_ListIteratorOfListIO It( selected );
3385 for ( ; isCompatible && It.More(); It.Next())
3387 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3388 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3390 return isCompatible;
3393 bool SMESHGUI::activateModule( SUIT_Study* study )
3395 bool res = SalomeApp_Module::activateModule( study );
3397 setMenuShown( true );
3398 setToolShown( true );
3400 // Reset actions accelerator keys
3401 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3402 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3403 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3405 action( 33)->setEnabled(true); // Delete: Key_Delete
3406 action(1101)->setEnabled(true); // Rename: Key_F2
3408 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3409 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3410 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3411 if ( _PTR(Study) aStudy = s->studyDS()) {
3412 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3413 updateObjBrowser(); // objects can be removed
3419 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3421 setMenuShown( false );
3422 setToolShown( false );
3424 EmitSignalCloseAllDialogs();
3426 // Unset actions accelerator keys
3427 action(111)->setShortcut(QKeySequence()); // Import DAT
3428 action(112)->setShortcut(QKeySequence()); // Import UNV
3429 action(113)->setShortcut(QKeySequence()); // Import MED
3431 action( 33)->setEnabled(false); // Delete: Key_Delete
3432 action(1101)->setEnabled(false); // Rename: Key_F2
3434 return SalomeApp_Module::deactivateModule( study );
3437 void SMESHGUI::studyClosed( SUIT_Study* s )
3439 SMESH::RemoveVisuData( s->id() );
3440 SalomeApp_Module::studyClosed( s );
3443 void SMESHGUI::OnGUIEvent()
3445 const QObject* obj = sender();
3446 if ( !obj || !obj->inherits( "QAction" ) )
3448 int id = actionId((QAction*)obj);
3453 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3455 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3456 if ( CORBA::is_nil( myComponentSMESH ) )
3458 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3460 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3461 return aGUI.myComponentSMESH;
3464 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3465 return myComponentSMESH;
3468 QString SMESHGUI::engineIOR() const
3470 CORBA::ORB_var anORB = getApp()->orb();
3471 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3472 return QString( anIOR.in() );
3475 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3477 SalomeApp_Module::contextMenuPopup( client, menu, title );
3479 selectionMgr()->selectedObjects( lst );
3480 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3481 Handle(SALOME_InteractiveObject) io = lst.First();
3482 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3483 _PTR(Study) study = appStudy->studyDS();
3484 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3486 QString aName = QString( obj->GetName().c_str() );
3487 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3488 aName.remove( (aName.length() - 1), 1 );
3494 LightApp_Selection* SMESHGUI::createSelection() const
3496 return new SMESHGUI_Selection();
3499 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3501 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3502 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3505 void SMESHGUI::viewManagers( QStringList& list ) const
3507 list.append( SVTK_Viewer::Type() );
3510 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3512 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3513 SMESH::UpdateSelectionProp( this );
3516 void SMESHGUI::createPreferences()
3518 // General tab ------------------------------------------------------------------------
3519 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3521 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3522 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3524 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3525 setPreferenceProperty( qaGroup, "columns", 2 );
3526 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3527 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3528 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3529 setPreferenceProperty( prec, "min", 0 );
3530 setPreferenceProperty( prec, "max", 16 );
3532 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3533 setPreferenceProperty( dispgroup, "columns", 2 );
3534 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3536 modes.append( "Wireframe" );
3537 modes.append( "Shading" );
3538 modes.append( "Nodes" );
3539 modes.append( "Shrink" );
3540 QList<QVariant> indices;
3541 indices.append( 0 );
3542 indices.append( 1 );
3543 indices.append( 2 );
3544 indices.append( 3 );
3545 setPreferenceProperty( dispmode, "strings", modes );
3546 setPreferenceProperty( dispmode, "indexes", indices );
3548 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3549 setPreferenceProperty( arcgroup, "columns", 2 );
3550 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3551 QStringList quadraticModes;
3552 quadraticModes.append("Lines");
3553 quadraticModes.append("Arcs");
3555 indices.append( 0 );
3556 indices.append( 1 );
3557 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3558 setPreferenceProperty( quadraticmode, "indexes", indices );
3560 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3561 "SMESH", "max_angle" );
3562 setPreferenceProperty( maxAngle, "min", 1 );
3563 setPreferenceProperty( maxAngle, "max", 90 );
3567 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3568 setPreferenceProperty( exportgroup, "columns", 2 );
3569 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3570 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3572 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3573 setPreferenceProperty( computeGroup, "columns", 2 );
3574 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3576 modes.append( "Never" );
3577 modes.append( "Errors only" );
3578 modes.append( "Always" );
3580 indices.append( 0 );
3581 indices.append( 1 );
3582 indices.append( 2 );
3583 setPreferenceProperty( notifyMode, "strings", modes );
3584 setPreferenceProperty( notifyMode, "indexes", indices );
3586 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3587 setPreferenceProperty( segGroup, "columns", 2 );
3588 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3589 "SMESH", "segmentation" );
3590 setPreferenceProperty( segLen, "min", 1 );
3591 setPreferenceProperty( segLen, "max", 10000000 );
3592 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3593 "SMESH", "nb_segments_per_edge" );
3594 setPreferenceProperty( nbSeg, "min", 1 );
3595 setPreferenceProperty( nbSeg, "max", 10000000 );
3597 // Mesh tab ------------------------------------------------------------------------
3598 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3599 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3600 setPreferenceProperty( nodeGroup, "columns", 2 );
3602 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3603 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3605 setPreferenceProperty( nodeSz, "min", 1 );
3606 setPreferenceProperty( nodeSz, "max", 5 );
3608 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3609 setPreferenceProperty( elemGroup, "columns", 2 );
3611 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3612 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3613 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3614 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3616 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3617 //setPreferenceProperty( sp, "hstretch", 0 );
3618 //setPreferenceProperty( sp, "vstretch", 0 );
3620 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3621 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3622 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3623 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3624 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3625 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3626 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3628 setPreferenceProperty( size0d, "min", 1 );
3629 setPreferenceProperty( size0d, "max", 10 );
3631 setPreferenceProperty( sp, "hstretch", 0 );
3632 setPreferenceProperty( sp, "vstretch", 0 );
3634 setPreferenceProperty( elemW, "min", 1 );
3635 setPreferenceProperty( elemW, "max", 5 );
3637 setPreferenceProperty( shrink, "min", 0 );
3638 setPreferenceProperty( shrink, "max", 100 );
3640 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3641 setPreferenceProperty( orientGroup, "columns", 1 );
3643 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3644 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3646 setPreferenceProperty( orientScale, "min", 0.05 );
3647 setPreferenceProperty( orientScale, "max", 0.5 );
3648 setPreferenceProperty( orientScale, "step", 0.05 );
3650 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3652 // Selection tab ------------------------------------------------------------------------
3653 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3655 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3656 setPreferenceProperty( selGroup, "columns", 2 );
3658 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3659 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3660 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3662 setPreferenceProperty( selW, "min", 1 );
3663 setPreferenceProperty( selW, "max", 5 );
3665 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3666 setPreferenceProperty( preGroup, "columns", 2 );
3668 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3669 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3671 setPreferenceProperty( preW, "min", 1 );
3672 setPreferenceProperty( preW, "max", 5 );
3674 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3675 setPreferenceProperty( precSelGroup, "columns", 2 );
3677 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3678 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3679 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3681 // Scalar Bar tab ------------------------------------------------------------------------
3682 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3683 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3684 setPreferenceProperty( fontGr, "columns", 2 );
3686 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3687 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3689 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3690 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3692 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3693 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3695 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3696 setPreferenceProperty( numcol, "min", 2 );
3697 setPreferenceProperty( numcol, "max", 256 );
3699 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3700 setPreferenceProperty( numlab, "min", 2 );
3701 setPreferenceProperty( numlab, "max", 65 );
3703 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3704 setPreferenceProperty( orientGr, "columns", 2 );
3705 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3706 QStringList orients;
3707 orients.append( tr( "SMESH_VERTICAL" ) );
3708 orients.append( tr( "SMESH_HORIZONTAL" ) );
3709 indices.clear(); indices.append( 0 ); indices.append( 1 );
3710 setPreferenceProperty( orient, "strings", orients );
3711 setPreferenceProperty( orient, "indexes", indices );
3713 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3714 setPreferenceProperty( posVSizeGr, "columns", 2 );
3715 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3716 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3717 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3718 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3719 setPreferenceProperty( xv, "step", 0.1 );
3720 setPreferenceProperty( xv, "min", 0.0 );
3721 setPreferenceProperty( xv, "max", 1.0 );
3722 setPreferenceProperty( yv, "step", 0.1 );
3723 setPreferenceProperty( yv, "min", 0.0 );
3724 setPreferenceProperty( yv, "max", 1.0 );
3725 setPreferenceProperty( wv, "step", 0.1 );
3726 setPreferenceProperty( wv, "min", 0.0 );
3727 setPreferenceProperty( wv, "max", 1.0 );
3728 setPreferenceProperty( hv, "min", 0.0 );
3729 setPreferenceProperty( hv, "max", 1.0 );
3730 setPreferenceProperty( hv, "step", 0.1 );
3732 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3733 setPreferenceProperty( posHSizeGr, "columns", 2 );
3734 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3735 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3736 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3737 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3738 setPreferenceProperty( xv, "min", 0.0 );
3739 setPreferenceProperty( xv, "max", 1.0 );
3740 setPreferenceProperty( xv, "step", 0.1 );
3741 setPreferenceProperty( xh, "min", 0.0 );
3742 setPreferenceProperty( xh, "max", 1.0 );
3743 setPreferenceProperty( xh, "step", 0.1 );
3744 setPreferenceProperty( yh, "min", 0.0 );
3745 setPreferenceProperty( yh, "max", 1.0 );
3746 setPreferenceProperty( yh, "step", 0.1 );
3747 setPreferenceProperty( wh, "min", 0.0 );
3748 setPreferenceProperty( wh, "max", 1.0 );
3749 setPreferenceProperty( wh, "step", 0.1 );
3750 setPreferenceProperty( hh, "min", 0.0 );
3751 setPreferenceProperty( hh, "max", 1.0 );
3752 setPreferenceProperty( hh, "step", 0.1 );
3755 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3757 if( sect=="SMESH" ) {
3758 float sbX1,sbY1,sbW,sbH;
3759 float aTol = 1.00000009999999;
3760 std::string aWarning;
3761 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3762 if( name=="selection_object_color" || name=="selection_element_color" ||
3763 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3764 name=="selection_precision_node" || name=="selection_precision_element" ||
3765 name=="selection_precision_object")
3766 SMESH::UpdateSelectionProp( this );
3767 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3768 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3769 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3770 if(sbX1+sbW > aTol){
3771 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3774 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3775 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3778 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3779 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3780 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3781 if(sbY1+sbH > aTol){
3782 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3783 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3784 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3787 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3788 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3789 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3790 if(sbX1+sbW > aTol){
3791 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3794 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3795 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3798 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3799 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3800 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3801 if(sbY1+sbH > aTol){
3802 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3805 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3806 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3809 else if ( name == "segmentation" ) {
3810 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3811 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3813 else if ( name == "nb_segments_per_edge" ) {
3814 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3815 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3818 if(aWarning.size() != 0){
3819 aWarning += "The default values are applied instead.";
3820 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3821 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3822 QObject::tr(aWarning.c_str()));
3827 //================================================================================
3829 * \brief Update something in accordance with update flags
3830 * \param theFlags - update flags
3832 * Update viewer or/and object browser etc. in accordance with update flags ( see
3833 * LightApp_UpdateFlags enumeration ).
3835 //================================================================================
3836 void SMESHGUI::update( const int flags )
3838 if ( flags & UF_Viewer | flags & UF_Forced )
3839 SMESH::UpdateView();
3841 SalomeApp_Module::update( flags );
3844 //================================================================================
3846 * \brief Set default selection mode
3848 * SLOT called when operation commited. Sets default selection mode
3850 //================================================================================
3851 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3853 SVTK_ViewWindow* vtkWnd =
3854 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3856 vtkWnd->SetSelectionMode( ActorSelection );
3859 //================================================================================
3861 * \brief Set default selection mode
3863 * SLOT called when operation aborted. Sets default selection mode
3865 //================================================================================
3866 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3868 SVTK_ViewWindow* vtkWnd =
3869 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3871 vtkWnd->SetSelectionMode( ActorSelection );
3874 //================================================================================
3876 * \brief Creates operation with given identifier
3877 * \param id - identifier of operation to be started
3878 * \return Pointer on created operation or NULL if operation is not created
3880 * Virtual method redefined from the base class creates operation with given id.
3881 * It is called called automatically from startOperation method of base class.
3883 //================================================================================
3884 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3886 LightApp_Operation* op = 0;
3887 // to do : create operation here
3890 case 701: // Compute mesh
3891 op = new SMESHGUI_ComputeOp();
3893 case 702: // Create mesh
3894 op = new SMESHGUI_MeshOp( true, true );
3896 case 703: // Create sub-mesh
3897 op = new SMESHGUI_MeshOp( true, false );
3899 case 704: // Edit mesh/sub-mesh
3900 op = new SMESHGUI_MeshOp( false );
3902 case 711: // Precompute mesh
3903 op = new SMESHGUI_PrecomputeOp();
3905 case 712: // Evaluate mesh
3906 op = new SMESHGUI_EvaluateOp();
3908 case 806: // Create group on geom
3909 op = new SMESHGUI_GroupOnShapeOp();
3911 case 417: //convert to quadratic
3912 op = new SMESHGUI_ConvToQuadOp();
3914 case 418: // create 2D mesh as boundary on 3D
3915 op = new SMESHGUI_Make2DFrom3DOp();
3917 case 4067: // make mesh pass through point
3918 op = new SMESHGUI_MakeNodeAtPointOp();
3925 op = SalomeApp_Module::createOperation( id );
3929 //================================================================================
3931 * \brief Stops current operations and starts a given one
3932 * \param id - The id of the operation to start
3934 //================================================================================
3936 void SMESHGUI::switchToOperation(int id)
3938 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3939 activeStudy()->abortAllOperations();
3940 startOperation( id );
3943 LightApp_Displayer* SMESHGUI::displayer()
3946 myDisplayer = new SMESHGUI_Displayer( getApp() );
3950 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3953 int aTolerance = 64;
3954 int anIterations = 0;
3960 if( anIterations % aPeriod == 0 )
3963 if( aTolerance < 1 )
3966 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3968 aHue = (int)( 360.0 * rand() / RAND_MAX );
3969 //cout << "Hue = " << aHue << endl;
3971 //cout << "Auto colors : ";
3973 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3974 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3975 for( ; it != itEnd; ++it )
3977 SALOMEDS::Color anAutoColor = *it;
3978 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3981 aQColor.getHsv( &h, &s, &v );
3983 if( abs( h - aHue ) < aTolerance )
3986 //cout << "break (diff = " << abs( h - aHue ) << ")";
3996 //cout << "Hue of the returned color = " << aHue << endl;
3998 aColor.setHsv( aHue, 255, 255 );
4000 SALOMEDS::Color aSColor;
4001 aSColor.R = (double)aColor.red() / 255.0;
4002 aSColor.G = (double)aColor.green() / 255.0;
4003 aSColor.B = (double)aColor.blue() / 255.0;
4008 const char gSeparator = '_'; // character used to separate parameter names
4009 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4012 * \brief Store visual parameters
4014 * This method is called just before the study document is saved.
4015 * Store visual parameters in AttributeParameter attribue(s)
4017 void SMESHGUI::storeVisualParameters (int savePoint)
4019 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4020 if (!appStudy || !appStudy->studyDS())
4022 _PTR(Study) studyDS = appStudy->studyDS();
4024 // componentName is used for encoding of entries when storing them in IParameters
4025 std::string componentName = myComponentSMESH->ComponentDataType();
4026 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4027 //if (!aSComponent) return;
4030 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4031 componentName.c_str(),
4033 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4035 // viewers counters are used for storing view_numbers in IParameters
4038 // main cycle to store parameters of displayed objects
4039 QList<SUIT_ViewManager*> lst;
4040 QList<SUIT_ViewManager*>::Iterator it;
4041 getApp()->viewManagers(lst);
4042 for (it = lst.begin(); it != lst.end(); it++)
4044 SUIT_ViewManager* vman = *it;
4045 QString vType = vman->getType();
4047 // saving VTK actors properties
4048 if (vType == SVTK_Viewer::Type())
4050 QVector<SUIT_ViewWindow*> views = vman->getViews();
4051 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4053 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4055 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4056 vtkActorCollection* allActors = aCopy.GetActors();
4057 allActors->InitTraversal();
4058 while (vtkActor* actor = allActors->GetNextActor())
4060 if (actor->GetVisibility()) // store only visible actors
4062 SMESH_Actor* aSmeshActor = 0;
4063 if (actor->IsA("SMESH_Actor"))
4064 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4065 if (aSmeshActor && aSmeshActor->hasIO())
4067 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4070 // entry is "encoded" = it does NOT contain component adress,
4071 // since it is a subject to change on next component loading
4072 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4074 std::string param, vtkParam = vType.toLatin1().data();
4075 vtkParam += gSeparator;
4076 vtkParam += QString::number(vtkViewers).toLatin1().data();
4077 vtkParam += gSeparator;
4080 param = vtkParam + "Visibility";
4081 ip->setParameter(entry, param, "On");
4084 param = vtkParam + "Representation";
4085 ip->setParameter(entry, param, QString::number
4086 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4089 param = vtkParam + "IsShrunk";
4090 ip->setParameter(entry, param, QString::number
4091 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4093 // Displayed entities
4094 unsigned int aMode = aSmeshActor->GetEntityMode();
4095 bool isE = aMode & SMESH_Actor::eEdges;
4096 bool isF = aMode & SMESH_Actor::eFaces;
4097 bool isV = aMode & SMESH_Actor::eVolumes;
4099 QString modeStr ("e");
4100 modeStr += gDigitsSep; modeStr += QString::number(isE);
4101 modeStr += gDigitsSep; modeStr += "f";
4102 modeStr += gDigitsSep; modeStr += QString::number(isF);
4103 modeStr += gDigitsSep; modeStr += "v";
4104 modeStr += gDigitsSep; modeStr += QString::number(isV);
4106 param = vtkParam + "Entities";
4107 ip->setParameter(entry, param, modeStr.toLatin1().data());
4109 // Colors (surface:edge:)
4110 vtkFloatingPointType r, g, b;
4112 aSmeshActor->GetSufaceColor(r, g, b);
4113 QString colorStr ("surface");
4114 colorStr += gDigitsSep; colorStr += QString::number(r);
4115 colorStr += gDigitsSep; colorStr += QString::number(g);
4116 colorStr += gDigitsSep; colorStr += QString::number(b);
4118 aSmeshActor->GetBackSufaceColor(r, g, b);
4119 colorStr += gDigitsSep; colorStr += "backsurface";
4120 colorStr += gDigitsSep; colorStr += QString::number(r);
4121 colorStr += gDigitsSep; colorStr += QString::number(g);
4122 colorStr += gDigitsSep; colorStr += QString::number(b);
4124 aSmeshActor->GetEdgeColor(r, g, b);
4125 colorStr += gDigitsSep; colorStr += "edge";
4126 colorStr += gDigitsSep; colorStr += QString::number(r);
4127 colorStr += gDigitsSep; colorStr += QString::number(g);
4128 colorStr += gDigitsSep; colorStr += QString::number(b);
4130 aSmeshActor->GetNodeColor(r, g, b);
4131 colorStr += gDigitsSep; colorStr += "node";
4132 colorStr += gDigitsSep; colorStr += QString::number(r);
4133 colorStr += gDigitsSep; colorStr += QString::number(g);
4134 colorStr += gDigitsSep; colorStr += QString::number(b);
4136 param = vtkParam + "Colors";
4137 ip->setParameter(entry, param, colorStr.toLatin1().data());
4139 // Sizes of lines and points
4140 QString sizeStr ("line");
4141 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4142 sizeStr += gDigitsSep; sizeStr += "node";
4143 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4144 sizeStr += gDigitsSep; sizeStr += "shrink";
4145 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4147 param = vtkParam + "Sizes";
4148 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4151 param = vtkParam + "Opacity";
4152 ip->setParameter(entry, param,
4153 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4156 param = vtkParam + "ClippingPlane";
4157 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4159 ip->setParameter(entry, param, "Off");
4160 for (int ipl = 0; ipl < nPlanes; ipl++) {
4161 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4162 SMESH::Orientation anOrientation;
4164 vtkFloatingPointType anAngle[2];
4165 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4166 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4167 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4168 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4169 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4171 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4173 } // if (io->hasEntry())
4174 } // SMESH_Actor && hasIO
4176 } // while.. actors traversal
4180 } // if (SVTK view model)
4181 } // for (viewManagers)
4185 * \brief Restore visual parameters
4187 * This method is called after the study document is opened.
4188 * Restore visual parameters from AttributeParameter attribue(s)
4190 void SMESHGUI::restoreVisualParameters (int savePoint)
4192 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4193 if (!appStudy || !appStudy->studyDS())
4195 _PTR(Study) studyDS = appStudy->studyDS();
4197 // componentName is used for encoding of entries when storing them in IParameters
4198 std::string componentName = myComponentSMESH->ComponentDataType();
4199 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4200 //if (!aSComponent) return;
4203 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4204 componentName.c_str(),
4206 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4208 std::vector<std::string> entries = ip->getEntries();
4210 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4212 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4213 QString entry (ip->decodeEntry(*entIt).c_str());
4215 // Check that the entry corresponds to a real object in the Study
4216 // as the object may be deleted or modified after the visual state is saved.
4217 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4218 if (!so) continue; //Skip the not existent entry
4220 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4221 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4223 std::vector<std::string>::iterator namesIt = paramNames.begin();
4224 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4226 // actors are stored in a map after displaying of them for
4227 // quicker access in the future: map < viewID to actor >
4228 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4230 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4232 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4233 // '_' is used as separator and should not be used in viewer type or parameter names.
4234 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4235 if (lst.size() != 3)
4238 QString viewerTypStr = lst[0];
4239 QString viewIndexStr = lst[1];
4240 QString paramNameStr = lst[2];
4243 int viewIndex = viewIndexStr.toUInt(&ok);
4244 if (!ok) // bad conversion of view index to integer
4248 if (viewerTypStr == SVTK_Viewer::Type())
4250 SMESH_Actor* aSmeshActor = 0;
4251 if (vtkActors.IsBound(viewIndex))
4252 aSmeshActor = vtkActors.Find(viewIndex);
4254 if (paramNameStr == "Visibility")
4256 if (!aSmeshActor && displayer())
4258 QList<SUIT_ViewManager*> lst;
4259 getApp()->viewManagers(viewerTypStr, lst);
4261 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4262 if (viewIndex >= 0 && viewIndex < lst.count()) {
4263 SUIT_ViewManager* vman = lst.at(viewIndex);
4264 SUIT_ViewModel* vmodel = vman->getViewModel();
4265 // SVTK view model can be casted to SALOME_View
4266 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4268 // store displayed actor in a temporary map for quicker
4269 // access later when restoring other parameters
4270 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4271 vtkRenderer* Renderer = vtkView->getRenderer();
4272 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4273 vtkActorCollection* theActors = aCopy.GetActors();
4274 theActors->InitTraversal();
4275 bool isFound = false;
4276 vtkActor *ac = theActors->GetNextActor();
4277 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4278 if (ac->IsA("SMESH_Actor")) {
4279 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4280 if (aGeomAc->hasIO()) {
4281 Handle(SALOME_InteractiveObject) io =
4282 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4283 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4285 vtkActors.Bind(viewIndex, aGeomAc);
4292 } // if (paramNameStr == "Visibility")
4295 // the rest properties "work" with SMESH_Actor
4298 QString val ((*valuesIt).c_str());
4301 if (paramNameStr == "Representation") {
4302 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4305 else if (paramNameStr == "IsShrunk") {
4307 if (!aSmeshActor->IsShrunk())
4308 aSmeshActor->SetShrink();
4311 if (aSmeshActor->IsShrunk())
4312 aSmeshActor->UnShrink();
4315 // Displayed entities
4316 else if (paramNameStr == "Entities") {
4317 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4318 if (mode.count() == 6) {
4319 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4320 MESSAGE("Invalid order of data in Entities, must be: "
4321 "e:0/1:f:0/1:v:0/1");
4324 unsigned int aMode = aSmeshActor->GetEntityMode();
4325 unsigned int aNewMode =
4326 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4327 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4328 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4329 if (aNewMode != aMode)
4330 aSmeshActor->SetEntityMode(aNewMode);
4335 else if (paramNameStr == "Colors") {
4336 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4337 if (colors.count() == 16) {
4338 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4339 colors[8] != "edge" || colors[12] != "node") {
4340 MESSAGE("Invalid order of data in Colors, must be: "
4341 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4344 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4345 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4346 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4347 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4351 // Sizes of lines and points
4352 else if (paramNameStr == "Sizes") {
4353 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4354 if (sizes.count() == 6) {
4355 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4356 MESSAGE("Invalid order of data in Sizes, must be: "
4357 "line:int:node:int:shrink:float");
4360 aSmeshActor->SetLineWidth(sizes[1].toInt());
4361 aSmeshActor->SetNodeSize(sizes[3].toInt());
4362 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4367 else if (paramNameStr == "Opacity") {
4368 aSmeshActor->SetOpacity(val.toFloat());
4371 else if (paramNameStr.startsWith("ClippingPlane")) {
4372 cout << "$$$ ClippingPlane 1" << endl;
4373 if (paramNameStr == "ClippingPlane1" || val == "Off")
4374 aSmeshActor->RemoveAllClippingPlanes();
4376 cout << "$$$ ClippingPlane 2" << endl;
4377 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4378 if (vals.count() == 4) { // format check: 4 values
4379 cout << "$$$ ClippingPlane 3" << endl;
4380 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4381 double aDistance = vals[1].toFloat();
4382 vtkFloatingPointType anAngle[2];
4383 anAngle[0] = vals[2].toFloat();
4384 anAngle[1] = vals[3].toFloat();
4386 QList<SUIT_ViewManager*> lst;
4387 getApp()->viewManagers(viewerTypStr, lst);
4388 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4389 if (viewIndex >= 0 && viewIndex < lst.count()) {
4390 SUIT_ViewManager* vman = lst.at(viewIndex);
4391 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4392 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4393 anOrientation, aDistance, anAngle);
4398 } // if (aSmeshActor)
4399 } // other parameters than Visibility
4401 } // for names/parameters iterator
4402 } // for entries iterator
4404 // update all VTK views
4405 QList<SUIT_ViewManager*> lst;
4406 getApp()->viewManagers(lst);
4407 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4408 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4409 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4410 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4411 vtkView->getRenderer()->ResetCameraClippingRange();
4418 \brief Adds preferences for dfont of VTK viewer
4420 \param pIf group identifier
4421 \param param parameter
4422 \return identifier of preferences
4424 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4426 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4428 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4431 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4432 fam.append( tr( "SMESH_FONT_COURIER" ) );
4433 fam.append( tr( "SMESH_FONT_TIMES" ) );
4435 setPreferenceProperty( tfont, "fonts", fam );
4437 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4438 setPreferenceProperty( tfont, "features", f );
4444 \brief Actions after hypothesis edition
4445 Updates object browser after hypothesis edition
4447 void SMESHGUI::onHypothesisEdit( int result )
4449 updateObjBrowser( true );