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"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
79 #include <SMESH_Client.hxx>
80 #include <SMESH_Actor.h>
81 #include <SMESH_TypeFilter.hxx>
83 // SALOME GUI includes
84 #include <SalomeApp_Tools.h>
85 #include <SalomeApp_Study.h>
86 #include <SalomeApp_Application.h>
87 #include <SalomeApp_CheckFileDlg.h>
89 #include <LightApp_DataOwner.h>
90 #include <LightApp_Preferences.h>
91 #include <LightApp_SelectionMgr.h>
92 #include <LightApp_UpdateFlags.h>
93 #include <LightApp_NameDlg.h>
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_ViewManager.h>
99 #include <SUIT_MessageBox.h>
100 #include <SUIT_ResourceMgr.h>
101 #include <SUIT_FileDlg.h>
102 #include <SUIT_Desktop.h>
103 #include <SUIT_OverrideCursor.h>
104 #include <SUIT_Session.h>
106 #include <QtxPopupMgr.h>
107 #include <QtxFontEdit.h>
109 #include <SALOME_ListIO.hxx>
110 #include <SALOME_ListIteratorOfListIO.hxx>
113 #include <SALOMEconfig.h>
114 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
115 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
118 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
122 #include <boost/shared_ptr.hpp>
125 #include <vtkScalarBarActor.h>
126 #include <vtkCamera.h>
127 #include <vtkRenderer.h>
128 #include <vtkPlane.h>
130 // SALOME KERNEL includes
131 #include <SALOMEDS_Study.hxx>
132 #include <SALOMEDSClient_StudyBuilder.hxx>
133 #include <SALOMEDSClient_SComponent.hxx>
134 #include <SALOMEDSClient_ClientFactory.hxx>
135 #include <SALOMEDSClient_IParameters.hxx>
138 #include <Standard_ErrorHandler.hxx>
139 #include <NCollection_DataMap.hxx>
143 //=============================================================
144 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
147 void ExportMeshToFile(int theCommandID);
149 void SetDisplayMode(int theCommandID);
151 void SetDisplayEntity(int theCommandID);
153 void Control( int theCommandID );
157 //=============================================================
158 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
162 std::string myExtension;
164 if ( theCommandID == 113 ) {
165 filter.append( QObject::tr( "MED files (*.med)" ) );
166 filter.append( QObject::tr( "All files (*)" ) );
168 else if ( theCommandID == 112 ) {
169 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
171 else if ( theCommandID == 111 ) {
172 filter.append( QObject::tr( "DAT files (*.dat)" ) );
175 QString anInitialPath = "";
176 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
177 anInitialPath = QDir::currentPath();
179 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
182 QObject::tr( "SMESH_IMPORT_MESH" ) );
183 if ( filenames.count() > 0 ) {
184 SUIT_OverrideCursor wc;
185 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
188 bool isEmpty = false;
189 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
190 QString filename = *it;
191 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 // DAT format (currently unsupported)
197 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
198 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
204 aMeshes->length( 1 );
205 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
206 if ( aMeshes[0]->_is_nil() )
207 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
208 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
214 SMESH::DriverMED_ReadStatus res;
215 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
216 if ( res != SMESH::DRS_OK ) {
217 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
218 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
224 catch ( const SALOME::SALOME_Exception& S_ex ) {
225 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
226 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
229 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
230 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
232 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
233 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
234 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
235 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
236 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
244 // update Object browser
245 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
247 // show Error message box if there were errors
248 if ( errors.count() > 0 ) {
249 SUIT_MessageBox::critical( SMESHGUI::desktop(),
250 QObject::tr( "SMESH_ERROR" ),
251 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
254 // show warning message box, if some imported mesh is empty
256 SUIT_MessageBox::warning( SMESHGUI::desktop(),
257 QObject::tr( "SMESH_WRN_WARNING" ),
258 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
263 void ExportMeshToFile( int theCommandID )
265 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
266 SALOME_ListIO selected;
268 aSel->selectedObjects( selected );
270 SMESH::SMESH_Mesh_var aMesh;
271 if(selected.Extent() == 1)
272 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
273 if ( aMesh->_is_nil() ) {
274 SUIT_MessageBox::warning( SMESHGUI::desktop(),
275 QObject::tr( "SMESH_WRN_WARNING" ),
276 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
280 Handle(SALOME_InteractiveObject) anIObject = selected.First();
281 QString aFilter, aTitle = QObject::tr("Export mesh");
282 QMap<QString, SMESH::MED_VERSION> aFilterMap;
283 QMap<QString, int> aFilterMapSTL;
284 switch ( theCommandID ) {
288 if (aMesh->HasDuplicatedGroupNamesMED()) {
289 int aRet = SUIT_MessageBox::warning
290 (SMESHGUI::desktop(),
291 QObject::tr("SMESH_WRN_WARNING"),
292 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
293 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
294 if (aRet != SUIT_MessageBox::Yes)
298 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
299 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
300 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
301 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
306 aFilter = QObject::tr("DAT files (*.dat)");
311 if (aMesh->NbPyramids()) {
312 int aRet = SUIT_MessageBox::warning
313 (SMESHGUI::desktop(),
314 QObject::tr("SMESH_WRN_WARNING"),
315 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
316 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
317 if (aRet != SUIT_MessageBox::Yes)
320 aFilter = QObject::tr("IDEAS files (*.unv)");
328 there must be check on others mesh elements not equal triangles
330 if (aMesh->NbTriangles() < 1) {
331 SUIT_MessageBox::warning
332 (SMESHGUI::desktop(),
333 QObject::tr("SMESH_WRN_WARNING"),
334 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
337 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
338 int aRet = SUIT_MessageBox::warning
339 (SMESHGUI::desktop(),
340 QObject::tr("SMESH_WRN_WARNING"),
341 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
342 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
343 if (aRet != SUIT_MessageBox::Yes)
347 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
348 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
356 SMESH::MED_VERSION aFormat;
357 // Init the parameter with the default value
358 bool aIsASCII_STL = true;
359 bool toCreateGroups = false;
360 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
362 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
364 QString anInitialPath = "";
365 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
366 anInitialPath = QDir::currentPath();
368 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
369 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
370 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
371 aFilter, aTitle, false);
373 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
375 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
376 for ( ; it != aFilterMapSTL.end(); ++it )
377 filters.push_back( it.key() );
379 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
380 fd->setWindowTitle( aTitle );
381 fd->setFilters( filters );
382 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
383 if ( !anInitialPath.isEmpty() )
384 fd->setDirectory( anInitialPath );
385 fd->selectFile(anIObject->getName());
389 aFilename = fd->selectedFile();
390 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
395 else { // Export to MED
397 QString aDefaultFilter;
398 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
399 for ( ; it != aFilterMap.end(); ++it ) {
400 filters.push_back( it.key() );
401 if (it.value() == SMESH::MED_V2_2)
402 aDefaultFilter = it.key();
405 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
406 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
407 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
408 fd->setWindowTitle( aTitle );
409 fd->setFilters( filters );
410 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
411 fd->selectFilter(aDefaultFilter);
412 fd->SetChecked(toCreateGroups);
413 if ( !anInitialPath.isEmpty() )
414 fd->setDirectory( anInitialPath );
415 fd->selectFile(anIObject->getName());
419 aFilename = fd->selectedFile();
420 aFormat = aFilterMap[fd->selectedFilter()];
422 if ( !aFilename.isEmpty()
423 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
424 && aFormat==SMESH::MED_V2_1) {
425 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
426 QObject::tr("SMESH_WRN_WARNING"),
427 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
428 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
429 if (aRet != SUIT_MessageBox::Yes) {
434 toCreateGroups = fd->IsChecked();
437 if ( !aFilename.isEmpty() ) {
438 // Check whether the file already exists and delete it if yes
439 QFile aFile( aFilename );
440 if ( aFile.exists() )
442 SUIT_OverrideCursor wc;
445 bool Renumber = false;
446 // PAL 14172 : Check of we have to renumber or not from the preferences before export
448 Renumber= resMgr->booleanValue("SMESH","renumbering");
450 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
451 aMeshEditor->RenumberNodes();
452 aMeshEditor->RenumberElements();
453 if ( SMESHGUI::automaticUpdate() )
456 switch ( theCommandID ) {
459 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
463 aMesh->ExportDAT( aFilename.toLatin1().data() );
467 aMesh->ExportUNV( aFilename.toLatin1().data() );
471 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
477 catch (const SALOME::SALOME_Exception& S_ex){
479 SUIT_MessageBox::warning(SMESHGUI::desktop(),
480 QObject::tr("SMESH_WRN_WARNING"),
481 QObject::tr("SMESH_EXPORT_FAILED"));
487 inline void InverseEntityMode(unsigned int& theOutputMode,
488 unsigned int theMode)
490 bool anIsNotPresent = ~theOutputMode & theMode;
492 theOutputMode |= theMode;
494 theOutputMode &= ~theMode;
497 void SetDisplayEntity(int theCommandID){
498 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
499 SALOME_ListIO selected;
501 aSel->selectedObjects( selected );
503 if(selected.Extent() >= 1){
504 SALOME_ListIteratorOfListIO It( selected );
505 for( ; It.More(); It.Next()){
506 Handle(SALOME_InteractiveObject) IObject = It.Value();
507 if(IObject->hasEntry()){
508 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
509 unsigned int aMode = anActor->GetEntityMode();
510 switch(theCommandID){
512 InverseEntityMode(aMode,SMESH_Actor::eEdges);
515 InverseEntityMode(aMode,SMESH_Actor::eFaces);
518 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
521 aMode = SMESH_Actor::eAllEntity;
525 anActor->SetEntityMode(aMode);
533 SALOME_ListIO selected;
534 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
538 LightApp_SelectionMgr* aSel = app->selectionMgr();
539 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
540 if( !aSel || !appStudy )
543 aSel->selectedObjects( selected );
544 if( selected.IsEmpty() )
547 Handle(SALOME_InteractiveObject) anIObject = selected.First();
549 _PTR(Study) aStudy = appStudy->studyDS();
550 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
551 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
552 if( aMainObject->_is_nil() )
555 aMainObject->SetAutoColor( true );
557 QList<SALOMEDS::Color> aReservedColors;
559 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
560 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
562 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
563 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
565 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
566 aGroupObject->SetColor( aColor );
567 aReservedColors.append( aColor );
569 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
570 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
572 if( aGroupObject->GetType() == SMESH::NODE )
573 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
574 else if( aGroupObject->GetType() == SMESH::EDGE )
575 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
577 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
581 SMESH::RepaintCurrentView();
584 void DisableAutoColor(){
585 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
586 SALOME_ListIO selected;
588 aSel->selectedObjects( selected );
590 if(selected.Extent()){
591 Handle(SALOME_InteractiveObject) anIObject = selected.First();
592 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
593 if ( !aMesh->_is_nil() ) {
594 aMesh->SetAutoColor( false );
599 void SetDisplayMode(int theCommandID){
600 SALOME_ListIO selected;
601 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
605 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
606 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
607 if( !aSel || !appStudy )
610 _PTR(Study) aStudy = appStudy->studyDS();
612 aSel->selectedObjects( selected );
614 if(selected.Extent() >= 1){
615 switch(theCommandID){
617 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
618 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
622 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
623 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
626 SALOME_ListIteratorOfListIO It( selected );
627 for( ; It.More(); It.Next()){
628 Handle(SALOME_InteractiveObject) IObject = It.Value();
629 if(IObject->hasEntry()){
630 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
631 switch(theCommandID){
633 anActor->SetRepresentation(SMESH_Actor::eEdge);
636 anActor->SetRepresentation(SMESH_Actor::eSurface);
639 if(anActor->IsShrunk())
642 anActor->SetShrink();
645 anActor->SetRepresentation(SMESH_Actor::ePoint);
648 vtkFloatingPointType color[3];
649 anActor->GetSufaceColor(color[0], color[1], color[2]);
650 int c0 = int (color[0] * 255);
651 int c1 = int (color[1] * 255);
652 int c2 = int (color[2] * 255);
653 QColor c(c0, c1, c2);
655 vtkFloatingPointType edgecolor[3];
656 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
657 c0 = int (edgecolor[0] * 255);
658 c1 = int (edgecolor[1] * 255);
659 c2 = int (edgecolor[2] * 255);
660 QColor e(c0, c1, c2);
662 vtkFloatingPointType backfacecolor[3];
663 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
664 c0 = int (backfacecolor[0] * 255);
665 c1 = int (backfacecolor[1] * 255);
666 c2 = int (backfacecolor[2] * 255);
667 QColor b(c0, c1, c2);
669 vtkFloatingPointType nodecolor[3];
670 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
671 c0 = int (nodecolor[0] * 255);
672 c1 = int (nodecolor[1] * 255);
673 c2 = int (nodecolor[2] * 255);
674 QColor n(c0, c1, c2);
676 int Edgewidth = (int)anActor->GetLineWidth();
679 int intValue = int(anActor->GetNodeSize());
680 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
682 SMESHGUI_Preferences_ColorDlg *aDlg =
683 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
684 aDlg->SetColor(1, c);
685 aDlg->SetColor(2, e);
686 aDlg->SetColor(3, n);
687 aDlg->SetColor(4, b);
688 aDlg->SetIntValue(1, Edgewidth);
689 aDlg->SetIntValue(2, intValue);
690 aDlg->SetIntValue(3, int(Shrink*100.));
692 QColor color = aDlg->GetColor(1);
693 QColor edgecolor = aDlg->GetColor(2);
694 QColor nodecolor = aDlg->GetColor(3);
695 QColor backfacecolor = aDlg->GetColor(4);
696 /* actor color and backface color */
697 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
698 vtkFloatingPointType (color.green()) / 255.,
699 vtkFloatingPointType (color.blue()) / 255.);
700 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
701 vtkFloatingPointType (backfacecolor.green()) / 255.,
702 vtkFloatingPointType (backfacecolor.blue()) / 255.);
705 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
706 vtkFloatingPointType (edgecolor.green()) / 255.,
707 vtkFloatingPointType (edgecolor.blue()) / 255.);
709 /* Shrink factor and size edges */
710 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
711 anActor->SetLineWidth(aDlg->GetIntValue(1));
713 /* Nodes color and size */
714 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
715 vtkFloatingPointType (nodecolor.green()) / 255.,
716 vtkFloatingPointType (nodecolor.blue()) / 255.);
717 anActor->SetNodeSize(aDlg->GetIntValue(2));
719 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
720 if( !aGroupObject->_is_nil() )
722 SALOMEDS::Color aColor;
723 aColor.R = (float)color.red() / 255.0;
724 aColor.G = (float)color.green() / 255.0;
725 aColor.B = (float)color.blue() / 255.0;
726 aGroupObject->SetColor( aColor );
736 SMESH::RepaintCurrentView();
740 void Control( int theCommandID )
742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
743 SALOME_ListIO selected;
745 aSel->selectedObjects( selected );
747 if( !selected.IsEmpty() ){
748 Handle(SALOME_InteractiveObject) anIO = selected.First();
751 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
752 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
753 switch ( theCommandID ){
755 aTitle = QObject::tr( "LENGTH_EDGES" );
756 aControl = SMESH_Actor::eLength;
759 aTitle = QObject::tr( "LENGTH2D_EDGES" );
760 aControl = SMESH_Actor::eLength2D;
763 aTitle = QObject::tr( "FREE_EDGES" );
764 aControl = SMESH_Actor::eFreeEdges;
767 aTitle = QObject::tr( "FREE_BORDERS" );
768 aControl = SMESH_Actor::eFreeBorders;
771 aTitle = QObject::tr( "MULTI_BORDERS" );
772 aControl = SMESH_Actor::eMultiConnection;
775 aTitle = QObject::tr( "FREE_NODES" );
776 aControl = SMESH_Actor::eFreeNodes;
779 aTitle = QObject::tr( "MULTI2D_BORDERS" );
780 aControl = SMESH_Actor::eMultiConnection2D;
783 aTitle = QObject::tr( "AREA_ELEMENTS" );
784 aControl = SMESH_Actor::eArea;
787 aTitle = QObject::tr( "TAPER_ELEMENTS" );
788 aControl = SMESH_Actor::eTaper;
791 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
792 aControl = SMESH_Actor::eAspectRatio;
795 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
796 aControl = SMESH_Actor::eAspectRatio3D;
799 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
800 aControl = SMESH_Actor::eMinimumAngle;
803 aTitle = QObject::tr( "WARP_ELEMENTS" );
804 aControl = SMESH_Actor::eWarping;
807 aTitle = QObject::tr( "SKEW_ELEMENTS" );
808 aControl = SMESH_Actor::eSkew;
811 aTitle = QObject::tr( "SMESH_VOLUME" );
812 aControl = SMESH_Actor::eVolume3D;
815 aTitle = QObject::tr( "FREE_FACES" );
816 aControl = SMESH_Actor::eFreeFaces;
819 anActor->SetControlMode(aControl);
820 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
821 SMESH::RepaintCurrentView();
828 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
829 MeshObjectType theType,
830 const QString theInTypeName,
831 QString & theOutTypeName)
833 SMESH_TypeFilter aTypeFilter( theType );
835 if( !theIO.IsNull() )
837 entry = theIO->getEntry();
838 LightApp_DataOwner owner( entry );
839 if ( aTypeFilter.isOk( &owner )) {
840 theOutTypeName = theInTypeName;
848 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
850 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
851 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
853 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
854 CORBA::String_var anID = aSComp->GetID().c_str();
855 if (!strcmp(anID.in(),theIO->getEntry()))
861 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
862 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
863 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
864 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
865 CheckOIType ( theIO, GROUP, "Group", aTypeName )
873 QString CheckHomogeneousSelection()
875 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
876 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
877 SALOME_ListIO selected;
879 aSel->selectedObjects( selected );
881 QString RefType = CheckTypeObject(selected.First());
882 SALOME_ListIteratorOfListIO It(selected);
883 for ( ; It.More(); It.Next())
885 Handle(SALOME_InteractiveObject) IObject = It.Value();
886 QString Type = CheckTypeObject(IObject);
887 if (Type.compare(RefType) != 0)
888 return "Heterogeneous Selection";
895 void SMESHGUI::OnEditDelete()
897 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
898 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
899 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
901 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
902 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
903 _PTR(GenericAttribute) anAttr;
904 _PTR(AttributeIOR) anIOR;
908 QString aParentComponent = QString::null;
909 Handle(SALOME_InteractiveObject) anIO;
910 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
913 QString cur = anIO->getComponentDataType();
914 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
916 // check if object is reference
917 _PTR(SObject) aRefSObj;
918 aNameList.append("\n - ");
919 if ( aSO->ReferencedObject( aRefSObj ) ) {
920 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
921 aNameList.append( aRefName );
922 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
925 aNameList.append(anIO->getName());
929 if( aParentComponent.isNull() )
930 aParentComponent = cur;
931 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
932 aParentComponent = "";
935 if ( objectCount == 0 )
936 return; // No Valid Objects Selected
938 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
939 SUIT_MessageBox::warning( SMESHGUI::desktop(),
940 QObject::tr("ERR_ERROR"),
941 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
944 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
945 if (SUIT_MessageBox::warning
946 (SMESHGUI::desktop(),
947 QObject::tr("SMESH_WRN_WARNING"),
948 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
949 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
950 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
953 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
954 SUIT_ViewManager* vm = anApp->activeViewManager();
955 int nbSf = vm->getViewsCount();
957 SALOME_ListIteratorOfListIO It(selected);
959 aStudyBuilder->NewCommand(); // There is a transaction
960 for( ; It.More(); It.Next()){ // loop on selected IO's
961 Handle(SALOME_InteractiveObject) IObject = It.Value();
962 if(IObject->hasEntry()) {
963 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
965 // disable removal of "SMESH" component object
966 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
968 if ( engineIOR() == anIOR->Value().c_str() )
971 //Check the referenced object
972 _PTR(SObject) aRefSObject;
973 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
974 aSO = aRefSObject; // Delete main Object instead of reference
976 // put the whole hierarchy of sub-objects of the selected SO into a list and
977 // then treat them all starting from the deepest objects (at list back)
979 std::list< _PTR(SObject) > listSO;
980 listSO.push_back( aSO );
981 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
982 for ( ; itSO != listSO.end(); ++itSO ) {
983 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
984 for (it->InitEx(false); it->More(); it->Next())
985 listSO.push_back( it->Value() );
988 // treat SO's in the list starting from the back
990 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
991 for ( ; ritSO != listSO.rend(); ++ritSO ) {
992 _PTR(SObject) SO = *ritSO;
994 std::string anEntry = SO->GetID();
996 /** Erase graphical object **/
997 if(SO->FindAttribute(anAttr, "AttributeIOR")){
998 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
999 for(int i = 0; i < nbSf; i++){
1000 SUIT_ViewWindow *sf = aViews[i];
1001 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1002 SMESH::RemoveActor(sf,anActor);
1007 /** Remove an object from data structures **/
1008 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1009 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1010 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1011 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1012 aMesh->RemoveGroup( aGroup );
1014 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1015 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1016 aMesh->RemoveSubMesh( aSubMesh );
1018 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1020 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1023 IObject = new SALOME_InteractiveObject
1024 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1025 QString objType = CheckTypeObject(IObject);
1026 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1027 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1028 aStudyBuilder->RemoveObjectWithChildren( SO );
1030 else {// default action: remove SObject from the study
1031 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1032 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1034 aStudyBuilder->RemoveObjectWithChildren( SO );
1038 } /* listSO back loop */
1039 } /* IObject->hasEntry() */
1041 aStudyBuilder->CommitCommand();
1043 /* Clear any previous selection */
1045 aSel->setSelectedObjects( l1 );
1047 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1052 SMESHGUI_EXPORT CAM_Module* createModule()
1054 return new SMESHGUI();
1058 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1060 //=============================================================================
1064 //=============================================================================
1065 SMESHGUI::SMESHGUI() :
1066 SalomeApp_Module( "SMESH" )
1068 if ( CORBA::is_nil( myComponentSMESH ) )
1070 CORBA::Boolean anIsEmbeddedMode;
1071 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1073 // 0019923: EDF 765 SMESH : default values of hypothesis
1074 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1075 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1076 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1077 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1078 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1081 myActiveDialogBox = 0;
1082 myFilterLibraryDlg = 0;
1086 SMESH::GetFilterManager();
1087 SMESH::GetPattern();
1089 /* load resources for all available meshers */
1090 SMESH::InitAvailableHypotheses();
1093 //=============================================================================
1097 //=============================================================================
1098 SMESHGUI::~SMESHGUI()
1100 SMESH::GetFilterManager()->Destroy();
1101 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1104 //=============================================================================
1108 //=============================================================================
1109 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1111 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1113 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1118 bool SMESHGUI::automaticUpdate()
1120 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1124 return resMgr->booleanValue( "SMESH", "auto_update", false );
1127 //=============================================================================
1131 //=============================================================================
1132 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1134 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1137 //=============================================================================
1141 //=============================================================================
1142 SMESHGUI* SMESHGUI::GetSMESHGUI()
1144 SMESHGUI* smeshMod = 0;
1145 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1148 CAM_Module* module = app->module( "Mesh" );
1149 smeshMod = dynamic_cast<SMESHGUI*>( module );
1152 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1154 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1157 _PTR(Study) aStudy = study->studyDS();
1159 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1168 Standard_EXPORT SMESHGUI* GetComponentGUI()
1170 return SMESHGUI::GetSMESHGUI();
1174 //=============================================================================
1178 //=============================================================================
1179 void SMESHGUI::SetState(int aState)
1184 //=============================================================================
1188 //=============================================================================
1189 void SMESHGUI::ResetState()
1194 //=============================================================================
1198 //=============================================================================
1199 void SMESHGUI::EmitSignalDeactivateDialog()
1201 emit SignalDeactivateActiveDialog();
1204 //=============================================================================
1208 //=============================================================================
1209 void SMESHGUI::EmitSignalStudyFrameChanged()
1211 emit SignalStudyFrameChanged();
1214 //=============================================================================
1218 //=============================================================================
1219 void SMESHGUI::EmitSignalCloseAllDialogs()
1221 emit SignalCloseAllDialogs();
1224 //=============================================================================
1228 //=============================================================================
1229 QDialog *SMESHGUI::GetActiveDialogBox()
1231 return myActiveDialogBox;
1234 //=============================================================================
1238 //=============================================================================
1239 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1241 myActiveDialogBox = (QDialog *) aDlg;
1245 //=============================================================================
1249 //=============================================================================
1250 SUIT_Desktop* SMESHGUI::desktop()
1252 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1254 return app->desktop();
1259 //=============================================================================
1263 //=============================================================================
1264 SalomeApp_Study* SMESHGUI::activeStudy()
1266 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1268 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1273 //=============================================================================
1277 //=============================================================================
1278 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1280 /* Here the position is on the bottom right corner - 10 */
1281 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1283 SUIT_Desktop *PP = desktop();
1284 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1285 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1289 //=============================================================================
1293 //=============================================================================
1294 static int isStudyLocked(_PTR(Study) theStudy){
1295 return theStudy->GetProperties()->IsLocked();
1298 static bool checkLock(_PTR(Study) theStudy) {
1299 if (isStudyLocked(theStudy)) {
1300 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1301 QObject::tr("WRN_WARNING"),
1302 QObject::tr("WRN_STUDY_LOCKED") );
1308 //=======================================================================
1309 //function : CheckActiveStudyLocked
1311 //=======================================================================
1313 bool SMESHGUI::isActiveStudyLocked()
1315 _PTR(Study) aStudy = activeStudy()->studyDS();
1316 return checkLock( aStudy );
1319 //=============================================================================
1323 //=============================================================================
1324 bool SMESHGUI::OnGUIEvent( int theCommandID )
1326 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1330 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1331 SUIT_ResourceMgr* mgr = resourceMgr();
1335 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1336 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1339 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1340 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1342 //QAction* act = action( theCommandID );
1344 switch (theCommandID) {
1346 if(checkLock(aStudy)) break;
1354 if(checkLock(aStudy)) break;
1355 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1359 case 150: //MED FILE INFORMATION
1361 SALOME_ListIO selected;
1362 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1364 aSel->selectedObjects( selected );
1365 if( selected.Extent() )
1367 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1368 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1369 if ( !aMesh->_is_nil() )
1371 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1378 case 122: // EXPORT MED
1387 ::ExportMeshToFile(theCommandID);
1391 case 200: // SCALAR BAR
1393 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1394 SALOME_ListIO selected;
1396 aSel->selectedObjects( selected );
1398 if( selected.Extent() ) {
1399 Handle(SALOME_InteractiveObject) anIO = selected.First();
1400 if( anIO->hasEntry() ) {
1401 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1402 anActor->SetControlMode( SMESH_Actor::eNone );
1410 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1420 ::DisableAutoColor();
1423 case 1134: // Clipping
1424 case 1133: // Tranparency
1425 case 1132: // Colors / Size
1432 ::SetDisplayMode(theCommandID);
1438 case 219: // Volumes
1439 case 220: // All Entity
1440 ::SetDisplayEntity(theCommandID);
1443 case 221: // Orientation of faces
1445 LightApp_SelectionMgr* mgr = selectionMgr();
1446 SALOME_ListIO selected; mgr->selectedObjects( selected );
1448 SALOME_ListIteratorOfListIO it(selected);
1449 for( ; it.More(); it.Next()) {
1450 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1451 if(anIObject->hasEntry()) {
1452 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1453 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1462 if(checkLock(aStudy)) break;
1464 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1467 SMESH::UpdateView();
1469 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1470 SMESH::OnVisuException();
1472 catch (...) { // PAL16774 (Crash after display of many groups)
1473 SMESH::OnVisuException();
1477 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1478 aSel->selectedObjects( l );
1479 aSel->setSelectedObjects( l );
1484 case 301: // DISPLAY
1485 case 302: // DISPLAY ONLY
1487 SMESH::EDisplaing anAction;
1488 switch (theCommandID) {
1489 case 300: anAction = SMESH::eErase; break;
1490 case 301: anAction = SMESH::eDisplay; break;
1491 case 302: anAction = SMESH::eDisplayOnly; break;
1494 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1495 SALOME_ListIO sel_objects, to_process;
1497 aSel->selectedObjects( sel_objects );
1499 if( theCommandID==302 )
1500 startOperation( myEraseAll );
1502 extractContainers( sel_objects, to_process );
1505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1509 SALOME_ListIteratorOfListIO It( to_process );
1510 for ( ; It.More(); It.Next()) {
1511 Handle(SALOME_InteractiveObject) IOS = It.Value();
1512 if (IOS->hasEntry()) {
1513 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1514 break; // PAL16774 (Crash after display of many groups)
1515 if (anAction == SMESH::eDisplayOnly)
1516 anAction = SMESH::eDisplay;
1521 // PAL13338 + PAL15161 -->
1522 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1523 SMESH::UpdateView();
1524 // PAL13338 + PAL15161 <--
1526 catch (...) { // PAL16774 (Crash after display of many groups)
1527 SMESH::OnVisuException();
1530 if (anAction == SMESH::eErase) {
1532 aSel->setSelectedObjects( l1 );
1535 aSel->setSelectedObjects( to_process );
1542 if(checkLock(aStudy)) break;
1545 EmitSignalDeactivateDialog();
1547 ( new SMESHGUI_NodesDlg( this ) )->show();
1550 SUIT_MessageBox::warning(desktop(),
1551 tr("SMESH_WRN_WARNING"),
1552 tr("SMESH_WRN_VIEWER_VTK"));
1557 case 2151: // FILTER
1561 EmitSignalDeactivateDialog();
1562 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1567 case 406: // MOVE NODE
1571 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1572 tr( "NOT_A_VTK_VIEWER" ) );
1576 if(checkLock(aStudy)) break;
1577 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1581 case 701: // COMPUTE MESH
1582 case 711: // PRECOMPUTE MESH
1584 if (checkLock(aStudy)) break;
1585 startOperation( theCommandID );
1589 case 702: // Create mesh
1590 case 703: // Create sub-mesh
1591 case 704: // Edit mesh/sub-mesh
1592 startOperation( theCommandID );
1594 case 710: // Build compound mesh
1596 if (checkLock(aStudy)) break;
1597 EmitSignalDeactivateDialog();
1598 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1602 case 407: // DIAGONAL INVERSION
1603 case 408: // Delete diagonal
1607 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1608 tr( "NOT_A_VTK_VIEWER" ) );
1612 if ( checkLock( aStudy ) )
1615 /*Standard_Boolean aRes;
1616 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1617 if ( aMesh->_is_nil() )
1619 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1620 tr( "SMESH_BAD_SELECTION" ) );
1624 EmitSignalDeactivateDialog();
1625 if ( theCommandID == 407 )
1626 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1628 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1631 case 409: // Change orientation
1632 case 410: // Union of triangles
1633 case 411: // Cutting of quadrangles
1637 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1638 tr( "NOT_A_VTK_VIEWER" ) );
1642 if ( checkLock( aStudy ) )
1645 EmitSignalDeactivateDialog();
1646 SMESHGUI_MultiEditDlg* aDlg = NULL;
1647 if ( theCommandID == 409 )
1648 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1649 else if ( theCommandID == 410 )
1650 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1652 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1657 case 412: // Smoothing
1659 if(checkLock(aStudy)) break;
1661 EmitSignalDeactivateDialog();
1662 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1665 SUIT_MessageBox::warning(desktop(),
1666 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1670 case 413: // Extrusion
1672 if (checkLock(aStudy)) break;
1674 EmitSignalDeactivateDialog();
1675 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1677 SUIT_MessageBox::warning(desktop(),
1678 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1682 case 414: // Revolution
1684 if(checkLock(aStudy)) break;
1686 EmitSignalDeactivateDialog();
1687 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1690 SUIT_MessageBox::warning(desktop(),
1691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1695 case 415: // Pattern mapping
1697 if ( checkLock( aStudy ) )
1701 EmitSignalDeactivateDialog();
1702 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1705 SUIT_MessageBox::warning(desktop(),
1706 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1710 case 416: // Extrusion along a path
1712 if (checkLock(aStudy)) break;
1714 EmitSignalDeactivateDialog();
1715 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1717 SUIT_MessageBox::warning(desktop(),
1718 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1722 case 417: // Convert mesh to quadratic
1724 startOperation( 417 );
1725 /* if (checkLock(aStudy)) break;
1727 EmitSignalDeactivateDialog();
1728 new SMESHGUI_ConvToQuadDlg();
1730 SUIT_MessageBox::warning(desktop(),
1731 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1735 case 806: // CREATE GEO GROUP
1737 startOperation( 806 );
1740 case 801: // CREATE GROUP
1744 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1745 tr( "NOT_A_VTK_VIEWER" ) );
1749 if(checkLock(aStudy)) break;
1750 EmitSignalDeactivateDialog();
1751 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1753 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1754 SALOME_ListIO selected;
1756 aSel->selectedObjects( selected );
1758 int nbSel = selected.Extent();
1760 // check if mesh is selected
1761 aMesh = SMESH::GetMeshByIO( selected.First() );
1763 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1768 case 802: // CONSTRUCT GROUP
1772 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1773 tr( "NOT_A_VTK_VIEWER" ) );
1777 if(checkLock(aStudy)) break;
1778 EmitSignalDeactivateDialog();
1780 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1781 SALOME_ListIO selected;
1783 aSel->selectedObjects( selected );
1785 int nbSel = selected.Extent();
1787 // check if submesh is selected
1788 Handle(SALOME_InteractiveObject) IObject = selected.First();
1789 if (IObject->hasEntry()) {
1790 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1792 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1793 if (!aSubMesh->_is_nil()) {
1795 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1796 // get submesh elements list by types
1797 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1798 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1799 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1800 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1801 // create group for each type o elements
1802 QString aName = IObject->getName();
1803 if (aNodes->length() > 0) {
1804 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1805 aGroup->Add(aNodes.inout());
1807 if (aEdges->length() > 0) {
1808 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1809 aGroup->Add(aEdges.inout());
1811 if (aFaces->length() > 0) {
1812 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1813 aGroup->Add(aFaces.inout());
1815 if (aVolumes->length() > 0) {
1816 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1817 aGroup->Add(aVolumes.inout());
1822 catch(const SALOME::SALOME_Exception & S_ex){
1823 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1830 SUIT_MessageBox::warning(desktop(),
1831 tr("SMESH_WRN_WARNING"),
1832 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1837 case 803: // EDIT GROUP
1841 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1842 tr( "NOT_A_VTK_VIEWER" ) );
1846 if(checkLock(aStudy)) break;
1847 EmitSignalDeactivateDialog();
1849 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1850 SALOME_ListIO selected;
1852 aSel->selectedObjects( selected );
1854 SALOME_ListIteratorOfListIO It (selected);
1855 int nbSelectedGroups = 0;
1856 for ( ; It.More(); It.Next() )
1858 SMESH::SMESH_GroupBase_var aGroup =
1859 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1860 if (!aGroup->_is_nil()) {
1862 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1866 if (nbSelectedGroups == 0)
1868 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1874 case 804: // Add elements to group
1876 if(checkLock(aStudy)) break;
1877 if (myState == 800) {
1878 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1879 if (aDlg) aDlg->onAdd();
1884 case 805: // Remove elements from group
1886 if(checkLock(aStudy)) break;
1887 if (myState == 800) {
1888 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1889 if (aDlg) aDlg->onRemove();
1894 case 815: // Edit GEOM GROUP as standalone
1898 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1899 tr( "NOT_A_VTK_VIEWER" ) );
1903 if(checkLock(aStudy)) break;
1904 EmitSignalDeactivateDialog();
1906 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1907 SALOME_ListIO selected;
1909 aSel->selectedObjects( selected );
1911 SALOME_ListIteratorOfListIO It (selected);
1912 for ( ; It.More(); It.Next() )
1914 SMESH::SMESH_GroupOnGeom_var aGroup =
1915 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
1916 if (!aGroup->_is_nil()) {
1917 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
1924 case 810: // Union Groups
1925 case 811: // Intersect groups
1926 case 812: // Cut groups
1930 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1931 tr( "NOT_A_VTK_VIEWER" ) );
1935 if ( checkLock( aStudy ) )
1938 EmitSignalDeactivateDialog();
1940 SMESHGUI_GroupOpDlg* aDlg = 0;
1941 if ( theCommandID == 810 )
1942 aDlg = new SMESHGUI_UnionGroupsDlg( this );
1943 else if ( theCommandID == 811 )
1944 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
1946 aDlg = new SMESHGUI_CutGroupsDlg( this );
1953 case 814: // Create groups of entities from existing groups of superior dimensions
1955 if ( checkLock( aStudy ) )
1958 EmitSignalDeactivateDialog();
1959 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
1965 case 813: // Delete groups with their contents
1969 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1970 tr( "NOT_A_VTK_VIEWER" ) );
1974 if ( checkLock( aStudy ) )
1977 EmitSignalDeactivateDialog();
1979 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1983 case 900: // MESH INFOS
1985 EmitSignalDeactivateDialog();
1986 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1987 SALOME_ListIO selected;
1989 aSel->selectedObjects( selected );
1991 if ( selected.Extent() > 1 ) { // a dlg for each IO
1993 SALOME_ListIteratorOfListIO It (selected);
1994 for ( ; It.More(); It.Next() ) {
1995 IOs.Clear(); IOs.Append( It.Value() );
1996 aSel->setSelectedObjects( IOs );
1997 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1999 // restore selection
2000 aSel->setSelectedObjects( selected );
2003 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2007 case 902: // STANDARD MESH INFOS
2009 EmitSignalDeactivateDialog();
2010 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2011 SALOME_ListIO selected;
2013 aSel->selectedObjects( selected );
2015 if ( selected.Extent() > 1 ) { // a dlg for each IO
2017 SALOME_ListIteratorOfListIO It (selected);
2018 for ( ; It.More(); It.Next() ) {
2020 IOs.Append( It.Value() );
2021 aSel->setSelectedObjects( IOs );
2022 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2024 // restore selection
2025 aSel->setSelectedObjects( selected );
2028 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2032 case 903: // WHAT IS
2034 EmitSignalDeactivateDialog();
2035 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2039 case 1100: // EDIT HYPOTHESIS
2041 if(checkLock(aStudy)) break;
2043 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2044 SALOME_ListIO selected;
2046 aSel->selectedObjects( selected );
2048 int nbSel = selected.Extent();
2051 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2052 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2054 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2055 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2056 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2057 if ( !aHypothesis->_is_nil() )
2059 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2061 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2068 updateObjBrowser( true );
2072 case 1101: // RENAME
2074 if ( checkLock( aStudy ) )
2077 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2078 SALOME_ListIO selected;
2080 aSel->selectedObjects( selected );
2082 bool isAny = false; // is there any appropriate object selected
2084 SALOME_ListIteratorOfListIO It( selected );
2085 for ( ; It.More(); It.Next() )
2087 Handle(SALOME_InteractiveObject) IObject = It.Value();
2088 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2089 _PTR(GenericAttribute) anAttr;
2090 _PTR(AttributeName) aName;
2093 if ( obj->FindAttribute(anAttr, "AttributeName") )
2096 QString newName = QString(aName->Value().c_str());
2098 // check type to prevent renaming of inappropriate objects
2099 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2100 if (aType == MESH || aType == GROUP ||
2101 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2102 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2103 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2104 aType == HYPOTHESIS || aType == ALGORITHM)
2107 newName = LightApp_NameDlg::getName(desktop(), newName);
2108 if ( !newName.isEmpty() )
2110 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2120 SUIT_MessageBox::warning(desktop(),
2121 QObject::tr("SMESH_WRN_WARNING"),
2122 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2127 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2129 if(checkLock(aStudy)) break;
2130 SUIT_OverrideCursor wc;
2132 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2133 SALOME_ListIO selected;
2135 aSel->selectedObjects( selected, QString::null, false );
2137 SALOME_ListIteratorOfListIO It(selected);
2138 for (int i = 0; It.More(); It.Next(), i++) {
2139 Handle(SALOME_InteractiveObject) IObject = It.Value();
2140 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2143 aSel->setSelectedObjects( l1 );
2148 case 401: // GEOM::EDGE
2149 case 4021: // TRIANGLE
2151 case 4023: // POLYGON
2155 if(checkLock(aStudy)) break;
2157 EmitSignalDeactivateDialog();
2158 SMDSAbs_ElementType type = SMDSAbs_Edge;
2160 switch (theCommandID) {
2161 case 4021: // TRIANGLE
2162 type = SMDSAbs_Face; nbNodes = 3; break;
2164 type = SMDSAbs_Face; nbNodes = 4; break;
2166 type = SMDSAbs_Volume; nbNodes = 4; break;
2167 case 4023: // POLYGON
2168 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2170 type = SMDSAbs_Volume; nbNodes = 8; break;
2171 case 4033: // POLYHEDRE
2172 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2175 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2178 SUIT_MessageBox::warning(desktop(),
2179 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2183 case 4033: // POLYHEDRON
2185 if(checkLock(aStudy)) break;
2187 EmitSignalDeactivateDialog();
2188 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2191 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2192 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2196 case 4034: // QUADRATIC EDGE
2197 case 4035: // QUADRATIC TRIANGLE
2198 case 4036: // QUADRATIC QUADRANGLE
2199 case 4037: // QUADRATIC TETRAHEDRON
2200 case 4038: // QUADRATIC PYRAMID
2201 case 4039: // QUADRATIC PENTAHEDRON
2202 case 4040: // QUADRATIC HEXAHEDRON
2204 if(checkLock(aStudy)) break;
2206 EmitSignalDeactivateDialog();
2209 switch (theCommandID) {
2211 type = QUAD_EDGE; break;
2213 type = QUAD_TRIANGLE; break;
2215 type = QUAD_QUADRANGLE; break;
2217 type = QUAD_TETRAHEDRON; break;
2219 type = QUAD_PYRAMID; break;
2221 type = QUAD_PENTAHEDRON; break;
2223 type = QUAD_HEXAHEDRON;
2227 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2230 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2231 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2235 case 4041: // REMOVES NODES
2237 if(checkLock(aStudy)) break;
2239 EmitSignalDeactivateDialog();
2240 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2243 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2244 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2248 case 4042: // REMOVES ELEMENTS
2250 if(checkLock(aStudy)) break;
2252 EmitSignalDeactivateDialog();
2253 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2257 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2258 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2262 case 4043: { // CLEAR_MESH
2264 if(checkLock(aStudy)) break;
2266 SALOME_ListIO selected;
2267 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2268 aSel->selectedObjects( selected );
2270 SUIT_OverrideCursor wc;
2271 SALOME_ListIteratorOfListIO It (selected);
2272 for ( ; It.More(); It.Next() )
2274 Handle(SALOME_InteractiveObject) IOS = It.Value();
2275 SMESH::SMESH_Mesh_var aMesh =
2276 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2277 if ( aMesh->_is_nil()) continue;
2279 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2281 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2282 SMESH::ModifiedMesh( aMeshSObj, false, true);
2283 // hide groups and submeshes
2284 _PTR(ChildIterator) anIter =
2285 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2286 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2288 _PTR(SObject) so = anIter->Value();
2289 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2292 catch (const SALOME::SALOME_Exception& S_ex){
2294 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2298 SMESH::UpdateView();
2302 case 4051: // RENUMBERING NODES
2304 if(checkLock(aStudy)) break;
2306 EmitSignalDeactivateDialog();
2307 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2311 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2316 case 4052: // RENUMBERING ELEMENTS
2318 if(checkLock(aStudy)) break;
2320 EmitSignalDeactivateDialog();
2321 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2325 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2326 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2330 case 4061: // TRANSLATION
2332 if(checkLock(aStudy)) break;
2334 EmitSignalDeactivateDialog();
2335 ( new SMESHGUI_TranslationDlg( this ) )->show();
2338 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2343 case 4062: // ROTATION
2345 if(checkLock(aStudy)) break;
2347 EmitSignalDeactivateDialog();
2348 ( new SMESHGUI_RotationDlg( this ) )->show();
2351 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2352 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2356 case 4063: // SYMMETRY
2358 if(checkLock(aStudy)) break;
2360 EmitSignalDeactivateDialog();
2361 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2364 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2365 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2369 case 4064: // SEWING
2371 if(checkLock(aStudy)) break;
2373 EmitSignalDeactivateDialog();
2374 ( new SMESHGUI_SewingDlg( this ) )->show();
2377 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2378 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2382 case 4065: // MERGE NODES
2384 if(checkLock(aStudy)) break;
2386 EmitSignalDeactivateDialog();
2387 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2390 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2391 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2395 case 4066: // MERGE EQUAL ELEMENTS
2397 if (checkLock(aStudy)) break;
2399 EmitSignalDeactivateDialog();
2400 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2402 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2403 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2408 case 4067: // MAKE MESH PASS THROUGH POINT
2409 startOperation( 4067 );
2412 case 5105: // Library of selection filters
2414 static QList<int> aTypes;
2415 if ( aTypes.isEmpty() )
2417 aTypes.append( SMESH::NODE );
2418 aTypes.append( SMESH::EDGE );
2419 aTypes.append( SMESH::FACE );
2420 aTypes.append( SMESH::VOLUME );
2422 if (!myFilterLibraryDlg)
2423 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2424 else if (myFilterLibraryDlg->isHidden())
2425 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2426 myFilterLibraryDlg->raise();
2430 case 6017: // CONTROLS
2448 LightApp_SelectionMgr* mgr = selectionMgr();
2449 SALOME_ListIO selected; mgr->selectedObjects( selected );
2451 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2452 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2454 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2455 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2456 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2457 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2458 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2459 ::Control( theCommandID );
2464 SUIT_MessageBox::warning(desktop(),
2465 tr( "SMESH_WRN_WARNING" ),
2466 tr( "SMESH_BAD_SELECTION" ) );
2470 SUIT_MessageBox::warning(desktop(),
2471 tr( "SMESH_WRN_WARNING" ),
2472 tr( "NOT_A_VTK_VIEWER" ) );
2477 LightApp_SelectionMgr* mgr = selectionMgr();
2478 SALOME_ListIO selected; mgr->selectedObjects( selected );
2480 SALOME_ListIteratorOfListIO it(selected);
2481 for( ; it.More(); it.Next()) {
2482 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2483 if(anIObject->hasEntry()) {
2484 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2485 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2493 LightApp_SelectionMgr* mgr = selectionMgr();
2494 SALOME_ListIO selected; mgr->selectedObjects( selected );
2496 if (selected.Extent() == 1) {
2497 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2498 if(anIObject->hasEntry())
2499 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2500 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2507 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2508 //updateObjBrowser();
2512 //=============================================================================
2516 //=============================================================================
2517 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2522 //=============================================================================
2526 //=============================================================================
2527 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2532 //=============================================================================
2536 //=============================================================================
2537 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2542 //=============================================================================
2543 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2544 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2546 //=============================================================================
2547 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2548 SUIT_ViewWindow* wnd )
2550 if(theIO->hasEntry()){
2551 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2552 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2556 //=======================================================================
2557 // function : createSMESHAction
2559 //=======================================================================
2560 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2563 QWidget* parent = application()->desktop();
2564 SUIT_ResourceMgr* resMgr = resourceMgr();
2566 if ( !icon_id.isEmpty() )
2567 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2569 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2570 if ( !pix.isNull() )
2571 icon = QIcon( pix );
2573 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2574 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2575 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2577 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2580 //=======================================================================
2581 // function : createPopupItem
2583 //=======================================================================
2584 void SMESHGUI::createPopupItem( const int id,
2585 const QString& clients,
2586 const QString& types,
2587 const QString& theRule,
2592 parentId = popupMgr()->actionId( action( pId ) );
2594 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2595 popupMgr()->insert( action( id ), parentId, 0 );
2597 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2598 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2599 QString rule = "(%1) and (%2) and (%3)";
2600 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2601 if( clients.isEmpty() )
2602 rule = rule.arg( QString( "true" ) );
2604 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2605 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2608 bool cont = myRules.contains( id );
2610 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2612 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2613 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2616 //=======================================================================
2617 // function : initialize
2619 //=======================================================================
2620 void SMESHGUI::initialize( CAM_Application* app )
2622 SalomeApp_Module::initialize( app );
2624 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2626 /* Automatic Update flag */
2627 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2629 // ----- create actions --------------
2631 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2632 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2633 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2634 createSMESHAction( 114, "NUM" );
2635 createSMESHAction( 121, "DAT" );
2636 createSMESHAction( 122, "MED" );
2637 createSMESHAction( 123, "UNV" );
2638 createSMESHAction( 140, "STL" );
2639 createSMESHAction( 124, "EXPORT_DAT" );
2640 createSMESHAction( 125, "EXPORT_MED" );
2641 createSMESHAction( 126, "EXPORT_UNV" );
2642 createSMESHAction( 141, "EXPORT_STL" );
2643 createSMESHAction( 150, "FILE_INFO" );
2644 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2645 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2646 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2647 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2648 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2649 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2650 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2651 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2652 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2653 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2654 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2655 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2656 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2657 createSMESHAction( 804, "ADD" );
2658 createSMESHAction( 805, "REMOVE" );
2659 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2660 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2661 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2662 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2663 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2664 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2665 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2666 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2667 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2668 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2669 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2670 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2671 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2672 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2673 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2674 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2675 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2676 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2677 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2678 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2679 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2680 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2681 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2682 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2683 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2684 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2685 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2686 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2687 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2688 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2689 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2690 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2691 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2692 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2693 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2694 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2695 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2696 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2697 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2698 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2699 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2700 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2701 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2702 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2703 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2704 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2705 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2706 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2707 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2708 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2709 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2710 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2711 createSMESHAction( 415, "MAP", "ICON_MAP" );
2712 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2713 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2714 createSMESHAction( 200, "RESET" );
2715 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2716 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2717 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2718 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2719 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2720 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2721 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2722 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2723 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2724 createSMESHAction( 220, "ALL" );
2725 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2726 createSMESHAction( 1100, "EDIT_HYPO" );
2727 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2728 createSMESHAction( 1102, "UNASSIGN" );
2729 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2730 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2731 createSMESHAction( 1131, "DISPMODE" );
2732 createSMESHAction( 1132, "COLORS" );
2733 createSMESHAction( 1133, "TRANSP" );
2734 createSMESHAction( 1134, "CLIP" );
2735 createSMESHAction( 1135, "DISP_ENT" );
2736 createSMESHAction( 1136, "AUTO_COLOR" );
2737 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2738 createSMESHAction( 2000, "CTRL" );
2740 createSMESHAction( 300, "ERASE" );
2741 createSMESHAction( 301, "DISPLAY" );
2742 createSMESHAction( 302, "DISPLAY_ONLY" );
2743 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2744 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2745 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2746 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2747 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2748 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2749 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2750 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2752 // ----- create menu --------------
2753 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2754 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2755 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2756 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2757 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2758 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2759 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2761 createMenu( separator(), fileId );
2763 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2764 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2765 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2766 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2767 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2768 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2770 createMenu( 111, importId, -1 );
2771 createMenu( 112, importId, -1 );
2772 createMenu( 113, importId, -1 );
2774 createMenu( 121, exportId, -1 );
2775 createMenu( 122, exportId, -1 );
2776 createMenu( 123, exportId, -1 );
2777 createMenu( 140, exportId, -1 ); // export to stl STL
2779 createMenu( separator(), fileId, 10 );
2781 createMenu( 33, editId, -1 );
2783 createMenu( 5105, toolsId, -1 );
2785 createMenu( 702, meshId, -1 ); // "Mesh" menu
2786 createMenu( 703, meshId, -1 );
2787 createMenu( 704, meshId, -1 );
2788 createMenu( 710, meshId, -1 );
2789 createMenu( separator(), meshId, -1 );
2790 createMenu( 701, meshId, -1 );
2791 createMenu( 711, meshId, -1 );
2792 createMenu( separator(), meshId, -1 );
2793 createMenu( 801, meshId, -1 );
2794 createMenu( 806, meshId, -1 );
2795 createMenu( 802, meshId, -1 );
2796 createMenu( 803, meshId, -1 );
2797 createMenu( 815, meshId, -1 );
2798 createMenu( separator(), meshId, -1 );
2799 createMenu( 810, meshId, -1 );
2800 createMenu( 811, meshId, -1 );
2801 createMenu( 812, meshId, -1 );
2802 createMenu( separator(), meshId, -1 );
2803 createMenu( 814, meshId, -1 );
2804 createMenu( separator(), meshId, -1 );
2805 createMenu( 813, meshId, -1 );
2806 createMenu( separator(), meshId, -1 );
2807 createMenu( 900, meshId, -1 );
2808 createMenu( 902, meshId, -1 );
2809 createMenu( 903, meshId, -1 );
2810 createMenu( separator(), meshId, -1 );
2812 createMenu( 6003, ctrlId, -1 );
2813 createMenu( 6001, ctrlId, -1 );
2814 createMenu( 6004, ctrlId, -1 );
2815 createMenu( separator(), ctrlId, -1 );
2816 createMenu( 6005, ctrlId, -1 );
2817 createMenu( 6002, ctrlId, -1 );
2818 createMenu( 6018, ctrlId, -1 );
2819 createMenu( 6019, ctrlId, -1 );
2820 createMenu( 6011, ctrlId, -1 );
2821 createMenu( 6012, ctrlId, -1 );
2822 createMenu( 6013, ctrlId, -1 );
2823 createMenu( 6014, ctrlId, -1 );
2824 createMenu( 6015, ctrlId, -1 );
2825 createMenu( 6016, ctrlId, -1 );
2826 createMenu( separator(), ctrlId, -1 );
2827 createMenu( 6017, ctrlId, -1 );
2828 createMenu( 6009, ctrlId, -1 );
2829 createMenu( 6021, ctrlId, -1 );
2830 createMenu( separator(), ctrlId, -1 );
2832 createMenu( 400, addId, -1 );
2833 createMenu( 401, addId, -1 );
2834 createMenu( 4021, addId, -1 );
2835 createMenu( 4022, addId, -1 );
2836 createMenu( 4023, addId, -1 );
2837 createMenu( 4031, addId, -1 );
2838 createMenu( 4032, addId, -1 );
2839 createMenu( 4033, addId, -1 );
2840 createMenu( separator(), addId, -1 );
2841 createMenu( 4034, addId, -1 );
2842 createMenu( 4035, addId, -1 );
2843 createMenu( 4036, addId, -1 );
2844 createMenu( 4037, addId, -1 );
2845 createMenu( 4038, addId, -1 );
2846 createMenu( 4039, addId, -1 );
2847 createMenu( 4040, addId, -1 );
2849 createMenu( 4041, removeId, -1 );
2850 createMenu( 4042, removeId, -1 );
2851 createMenu( 4043, removeId, -1 );
2853 createMenu( 4051, renumId, -1 );
2854 createMenu( 4052, renumId, -1 );
2856 createMenu( 4061, transfId, -1 );
2857 createMenu( 4062, transfId, -1 );
2858 createMenu( 4063, transfId, -1 );
2859 createMenu( 4064, transfId, -1 );
2860 createMenu( 4065, transfId, -1 );
2861 createMenu( 4066, transfId, -1 );
2863 createMenu( 406, modifyId, -1 );
2864 createMenu( 4067,modifyId, -1 );
2865 createMenu( 407, modifyId, -1 );
2866 createMenu( 408, modifyId, -1 );
2867 createMenu( 409, modifyId, -1 );
2868 createMenu( 410, modifyId, -1 );
2869 createMenu( 411, modifyId, -1 );
2870 createMenu( 412, modifyId, -1 );
2871 createMenu( 413, modifyId, -1 );
2872 createMenu( 416, modifyId, -1 );
2873 createMenu( 414, modifyId, -1 );
2874 createMenu( 415, modifyId, -1 );
2875 createMenu( 417, modifyId, -1 );
2877 createMenu( 214, viewId, -1 );
2879 // ----- create toolbars --------------
2880 int meshTb = createTool( tr( "TB_MESH" ) ),
2881 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2882 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2883 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2884 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2886 createTool( 702, meshTb );
2887 createTool( 703, meshTb );
2888 createTool( 704, meshTb );
2889 createTool( 710, meshTb );
2890 createTool( separator(), meshTb );
2891 createTool( 701, meshTb );
2892 createTool( 711, meshTb );
2893 createTool( separator(), meshTb );
2894 createTool( 801, meshTb );
2895 createTool( 806, meshTb );
2896 createTool( 802, meshTb );
2897 createTool( 803, meshTb );
2898 //createTool( 815, meshTb );
2899 createTool( separator(), meshTb );
2900 createTool( 900, meshTb );
2901 createTool( 902, meshTb );
2902 createTool( 903, meshTb );
2903 createTool( separator(), meshTb );
2905 createTool( 6001, ctrlTb );
2906 createTool( 6003, ctrlTb );
2907 createTool( 6004, ctrlTb );
2908 createTool( separator(), ctrlTb );
2909 createTool( 6005, ctrlTb );
2910 createTool( 6002, ctrlTb );
2911 createTool( 6018, ctrlTb );
2912 createTool( 6019, ctrlTb );
2913 createTool( 6011, ctrlTb );
2914 createTool( 6012, ctrlTb );
2915 createTool( 6013, ctrlTb );
2916 createTool( 6014, ctrlTb );
2917 createTool( 6015, ctrlTb );
2918 createTool( 6016, ctrlTb );
2919 createTool( separator(), ctrlTb );
2920 createTool( 6017, ctrlTb );
2921 createTool( 6009, ctrlTb );
2922 createTool( 6021, ctrlTb );
2923 createTool( separator(), ctrlTb );
2925 createTool( 400, addRemTb );
2926 createTool( 401, addRemTb );
2927 createTool( 4021, addRemTb );
2928 createTool( 4022, addRemTb );
2929 createTool( 4023, addRemTb );
2930 createTool( 4031, addRemTb );
2931 createTool( 4032, addRemTb );
2932 createTool( 4033, addRemTb );
2933 createTool( separator(), addRemTb );
2934 createTool( 4034, addRemTb );
2935 createTool( 4035, addRemTb );
2936 createTool( 4036, addRemTb );
2937 createTool( 4037, addRemTb );
2938 createTool( 4038, addRemTb );
2939 createTool( 4039, addRemTb );
2940 createTool( 4040, addRemTb );
2941 createTool( separator(), addRemTb );
2942 createTool( 4041, addRemTb );
2943 createTool( 4042, addRemTb );
2944 createTool( 4043, addRemTb );
2945 createTool( separator(), addRemTb );
2946 createTool( 4051, addRemTb );
2947 createTool( 4052, addRemTb );
2948 createTool( separator(), addRemTb );
2949 createTool( 4061, addRemTb );
2950 createTool( 4062, addRemTb );
2951 createTool( 4063, addRemTb );
2952 createTool( 4064, addRemTb );
2953 createTool( 4065, addRemTb );
2954 createTool( 4066, addRemTb );
2955 createTool( separator(), addRemTb );
2957 createTool( 406, modifyTb );
2958 createTool( 4067,modifyTb );
2959 createTool( 407, modifyTb );
2960 createTool( 408, modifyTb );
2961 createTool( 409, modifyTb );
2962 createTool( 410, modifyTb );
2963 createTool( 411, modifyTb );
2964 createTool( 412, modifyTb );
2965 createTool( 413, modifyTb );
2966 createTool( 416, modifyTb );
2967 createTool( 414, modifyTb );
2968 createTool( 415, modifyTb );
2969 createTool( 417, modifyTb );
2971 createTool( 214, dispModeTb );
2973 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2974 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
2977 QString OB = "'ObjectBrowser'",
2978 View = "'" + SVTK_Viewer::Type() + "'",
2980 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2981 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2982 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2983 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2984 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2985 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2986 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2987 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2988 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2989 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2990 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2992 mesh_group = mesh + " " + subMesh + " " + group,
2993 hyp_alg = hypo + " " + algo;
2995 // popup for object browser
2997 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2998 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
2999 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3000 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3001 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3002 createPopupItem( 803, OB, group ); // EDIT_GROUP
3003 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3005 popupMgr()->insert( separator(), -1, 0 );
3006 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3007 createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE
3008 createPopupItem( 214, OB, mesh_group ); // UPDATE
3009 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3010 createPopupItem( 902, OB, mesh ); // STD_INFO
3011 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3012 popupMgr()->insert( separator(), -1, 0 );
3013 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3014 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3015 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3016 popupMgr()->insert( separator(), -1, 0 );
3017 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3018 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3019 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3020 popupMgr()->insert( separator(), -1, 0 );
3021 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3022 popupMgr()->insert( separator(), -1, 0 );
3024 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3026 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3027 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3028 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3029 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3030 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3031 popupMgr()->insert( separator(), -1, 0 );
3034 createPopupItem( 803, View, group ); // EDIT_GROUP
3035 createPopupItem( 804, View, elems ); // ADD
3036 createPopupItem( 805, View, elems ); // REMOVE
3038 popupMgr()->insert( separator(), -1, 0 );
3039 createPopupItem( 214, View, mesh_group ); // UPDATE
3040 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3041 createPopupItem( 902, View, mesh ); // STD_INFO
3042 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3043 popupMgr()->insert( separator(), -1, 0 );
3045 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3046 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3047 popupMgr()->insert( separator(), -1, 0 );
3051 isInvisible("not( isVisible )"),
3052 isEmpty("numberOfNodes = 0"),
3053 isNotEmpty("numberOfNodes <> 0"),
3055 // has nodes, edges, etc in VISIBLE! actor
3056 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3057 hasElems("(count( elemTypes ) > 0)"),
3058 hasDifferentElems("(count( elemTypes ) > 1)"),
3059 hasEdges("({'Edge'} in elemTypes)"),
3060 hasFaces("({'Face'} in elemTypes)"),
3061 hasVolumes("({'Volume'} in elemTypes)");
3063 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3064 QString aType = QString( "%1type in {%2}" ).arg( lc );
3065 aType = aType.arg( mesh_group );
3066 QString aMeshInVTK = aClient + "&&" + aType;
3068 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3069 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3070 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3072 //-------------------------------------------------
3074 //-------------------------------------------------
3075 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3077 popupMgr()->insert( action( 9010 ), anId, -1 );
3078 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3079 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3081 popupMgr()->insert( action( 9011 ), anId, -1 );
3082 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3083 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3085 popupMgr()->insert( separator(), -1, -1 );
3087 //-------------------------------------------------
3089 //-------------------------------------------------
3090 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3092 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3093 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3094 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3096 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3097 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3098 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3100 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3101 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3102 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3104 popupMgr()->insert( separator(), anId, -1 );
3106 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3107 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3108 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3110 //-------------------------------------------------
3112 //-------------------------------------------------
3113 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3115 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3117 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3118 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3119 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3121 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3122 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3123 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3125 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3126 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3127 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3129 popupMgr()->insert( separator(), anId, -1 );
3131 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3132 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3134 //-------------------------------------------------
3135 // Orientation of faces
3136 //-------------------------------------------------
3137 popupMgr()->insert( action( 221 ), -1, -1 );
3138 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3139 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3141 //-------------------------------------------------
3143 //-------------------------------------------------
3144 popupMgr()->insert( action( 1132 ), -1, -1 );
3145 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3147 //-------------------------------------------------
3149 //-------------------------------------------------
3150 popupMgr()->insert( action( 1133 ), -1, -1 );
3151 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3153 //-------------------------------------------------
3155 //-------------------------------------------------
3156 popupMgr()->insert( action( 1134 ), -1, -1 );
3157 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3159 popupMgr()->insert( separator(), -1, -1 );
3161 //-------------------------------------------------
3163 //-------------------------------------------------
3165 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3166 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3167 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3168 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3170 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3172 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3173 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3175 popupMgr()->insert( separator(), anId, -1 );
3177 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3178 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3179 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3181 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3182 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3183 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3185 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3186 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3187 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3189 popupMgr()->insert( separator(), anId, -1 );
3191 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3192 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3193 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3195 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3196 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3197 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3199 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3200 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3201 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3203 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3204 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3205 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3207 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3208 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3209 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3211 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3212 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3213 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3215 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3216 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3217 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3219 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3220 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3221 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3223 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3224 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3225 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3227 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3228 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3229 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3231 popupMgr()->insert( separator(), anId, -1 );
3233 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3234 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3235 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3237 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3238 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3239 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3241 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3242 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3243 QtxPopupMgr::VisibleRule );
3244 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3246 popupMgr()->insert( separator(), anId, -1 );
3248 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3249 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3251 popupMgr()->insert( separator(), -1, -1 );
3253 //-------------------------------------------------
3255 //-------------------------------------------------
3256 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3257 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3258 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3259 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3261 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3262 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3264 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3265 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3267 popupMgr()->insert( separator(), -1, -1 );
3269 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3270 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3273 //================================================================================
3275 * \brief Return true if SMESH or GEOM objects are selected.
3276 * Is called form LightApp_Module::activateModule() which clear selection if
3277 * not isSelectionCompatible()
3279 //================================================================================
3281 bool SMESHGUI::isSelectionCompatible()
3283 bool isCompatible = true;
3284 SALOME_ListIO selected;
3285 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3286 Sel->selectedObjects( selected );
3288 SALOME_ListIteratorOfListIO It( selected );
3289 for ( ; isCompatible && It.More(); It.Next())
3291 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3292 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3294 return isCompatible;
3297 bool SMESHGUI::activateModule( SUIT_Study* study )
3299 bool res = SalomeApp_Module::activateModule( study );
3301 setMenuShown( true );
3302 setToolShown( true );
3304 // Reset actions accelerator keys
3305 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3306 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3307 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3309 action( 33)->setEnabled(true); // Delete: Key_Delete
3310 action(1101)->setEnabled(true); // Rename: Key_F2
3315 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3317 setMenuShown( false );
3318 setToolShown( false );
3320 EmitSignalCloseAllDialogs();
3322 // Unset actions accelerator keys
3323 action(111)->setShortcut(QKeySequence()); // Import DAT
3324 action(112)->setShortcut(QKeySequence()); // Import UNV
3325 action(113)->setShortcut(QKeySequence()); // Import MED
3327 action( 33)->setEnabled(false); // Delete: Key_Delete
3328 action(1101)->setEnabled(false); // Rename: Key_F2
3330 return SalomeApp_Module::deactivateModule( study );
3333 void SMESHGUI::studyClosed( SUIT_Study* s )
3335 SMESH::RemoveVisuData( s->id() );
3336 SalomeApp_Module::studyClosed( s );
3339 void SMESHGUI::OnGUIEvent()
3341 const QObject* obj = sender();
3342 if ( !obj || !obj->inherits( "QAction" ) )
3344 int id = actionId((QAction*)obj);
3349 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3351 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3352 if ( CORBA::is_nil( myComponentSMESH ) )
3354 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3356 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3357 return aGUI.myComponentSMESH;
3360 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3361 return myComponentSMESH;
3364 QString SMESHGUI::engineIOR() const
3366 CORBA::ORB_var anORB = getApp()->orb();
3367 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3368 return QString( anIOR.in() );
3371 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3373 SalomeApp_Module::contextMenuPopup( client, menu, title );
3375 selectionMgr()->selectedObjects( lst );
3376 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3377 Handle(SALOME_InteractiveObject) io = lst.First();
3378 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3379 _PTR(Study) study = appStudy->studyDS();
3380 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3382 QString aName = QString( obj->GetName().c_str() );
3383 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3384 aName.remove( (aName.length() - 1), 1 );
3390 LightApp_Selection* SMESHGUI::createSelection() const
3392 return new SMESHGUI_Selection();
3395 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3397 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3398 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3401 void SMESHGUI::viewManagers( QStringList& list ) const
3403 list.append( SVTK_Viewer::Type() );
3406 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3408 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3409 SMESH::UpdateSelectionProp( this );
3412 void SMESHGUI::createPreferences()
3414 // General tab ------------------------------------------------------------------------
3415 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3417 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3418 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3420 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3421 setPreferenceProperty( qaGroup, "columns", 2 );
3422 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3423 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3424 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3425 setPreferenceProperty( prec, "min", 0 );
3426 setPreferenceProperty( prec, "max", 16 );
3428 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3429 setPreferenceProperty( dispgroup, "columns", 2 );
3430 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3432 modes.append( "Wireframe" );
3433 modes.append( "Shading" );
3434 modes.append( "Nodes" );
3435 modes.append( "Shrink" );
3436 QList<QVariant> indices;
3437 indices.append( 0 );
3438 indices.append( 1 );
3439 indices.append( 2 );
3440 indices.append( 3 );
3441 setPreferenceProperty( dispmode, "strings", modes );
3442 setPreferenceProperty( dispmode, "indexes", indices );
3444 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3445 setPreferenceProperty( exportgroup, "columns", 2 );
3446 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3447 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3449 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3450 setPreferenceProperty( computeGroup, "columns", 2 );
3451 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3453 modes.append( "Never" );
3454 modes.append( "Errors only" );
3455 modes.append( "Always" );
3457 indices.append( 0 );
3458 indices.append( 1 );
3459 indices.append( 2 );
3460 setPreferenceProperty( notifyMode, "strings", modes );
3461 setPreferenceProperty( notifyMode, "indexes", indices );
3463 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3464 setPreferenceProperty( segGroup, "columns", 2 );
3465 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3466 "SMESH", "segmentation" );
3467 setPreferenceProperty( segLen, "min", 1 );
3468 setPreferenceProperty( segLen, "max", 10000000 );
3469 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3470 "SMESH", "nb_segments_per_edge" );
3471 setPreferenceProperty( nbSeg, "min", 1 );
3472 setPreferenceProperty( nbSeg, "max", 10000000 );
3474 // Mesh tab ------------------------------------------------------------------------
3475 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3476 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3477 setPreferenceProperty( nodeGroup, "columns", 2 );
3479 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3480 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3482 setPreferenceProperty( nodeSz, "min", 1 );
3483 setPreferenceProperty( nodeSz, "max", 5 );
3485 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3486 setPreferenceProperty( elemGroup, "columns", 2 );
3488 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3489 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3490 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3491 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3493 setPreferenceProperty( sp, "hstretch", 0 );
3494 setPreferenceProperty( sp, "vstretch", 0 );
3496 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3497 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3499 setPreferenceProperty( elemW, "min", 1 );
3500 setPreferenceProperty( elemW, "max", 5 );
3502 setPreferenceProperty( shrink, "min", 0 );
3503 setPreferenceProperty( shrink, "max", 100 );
3505 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3506 setPreferenceProperty( orientGroup, "columns", 1 );
3508 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3509 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3511 setPreferenceProperty( orientScale, "min", 0.05 );
3512 setPreferenceProperty( orientScale, "max", 0.5 );
3513 setPreferenceProperty( orientScale, "step", 0.05 );
3515 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3517 // Selection tab ------------------------------------------------------------------------
3518 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3520 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3521 setPreferenceProperty( selGroup, "columns", 2 );
3523 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3524 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3525 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3527 setPreferenceProperty( selW, "min", 1 );
3528 setPreferenceProperty( selW, "max", 5 );
3530 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3531 setPreferenceProperty( preGroup, "columns", 2 );
3533 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3534 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3536 setPreferenceProperty( preW, "min", 1 );
3537 setPreferenceProperty( preW, "max", 5 );
3539 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3540 setPreferenceProperty( precSelGroup, "columns", 2 );
3542 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3543 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3544 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3546 // Scalar Bar tab ------------------------------------------------------------------------
3547 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3548 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3549 setPreferenceProperty( fontGr, "columns", 2 );
3551 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3552 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3554 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3555 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3557 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3558 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3560 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3561 setPreferenceProperty( numcol, "min", 2 );
3562 setPreferenceProperty( numcol, "max", 256 );
3564 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3565 setPreferenceProperty( numlab, "min", 2 );
3566 setPreferenceProperty( numlab, "max", 65 );
3568 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3569 setPreferenceProperty( orientGr, "columns", 2 );
3570 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3571 QStringList orients;
3572 orients.append( tr( "SMESH_VERTICAL" ) );
3573 orients.append( tr( "SMESH_HORIZONTAL" ) );
3574 indices.clear(); indices.append( 0 ); indices.append( 1 );
3575 setPreferenceProperty( orient, "strings", orients );
3576 setPreferenceProperty( orient, "indexes", indices );
3578 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3579 setPreferenceProperty( posVSizeGr, "columns", 2 );
3580 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3581 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3582 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3583 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3584 setPreferenceProperty( xv, "step", 0.1 );
3585 setPreferenceProperty( xv, "min", 0.0 );
3586 setPreferenceProperty( xv, "max", 1.0 );
3587 setPreferenceProperty( yv, "step", 0.1 );
3588 setPreferenceProperty( yv, "min", 0.0 );
3589 setPreferenceProperty( yv, "max", 1.0 );
3590 setPreferenceProperty( wv, "step", 0.1 );
3591 setPreferenceProperty( wv, "min", 0.0 );
3592 setPreferenceProperty( wv, "max", 1.0 );
3593 setPreferenceProperty( hv, "min", 0.0 );
3594 setPreferenceProperty( hv, "max", 1.0 );
3595 setPreferenceProperty( hv, "step", 0.1 );
3597 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3598 setPreferenceProperty( posHSizeGr, "columns", 2 );
3599 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3600 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3601 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3602 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3603 setPreferenceProperty( xv, "min", 0.0 );
3604 setPreferenceProperty( xv, "max", 1.0 );
3605 setPreferenceProperty( xv, "step", 0.1 );
3606 setPreferenceProperty( xh, "min", 0.0 );
3607 setPreferenceProperty( xh, "max", 1.0 );
3608 setPreferenceProperty( xh, "step", 0.1 );
3609 setPreferenceProperty( yh, "min", 0.0 );
3610 setPreferenceProperty( yh, "max", 1.0 );
3611 setPreferenceProperty( yh, "step", 0.1 );
3612 setPreferenceProperty( wh, "min", 0.0 );
3613 setPreferenceProperty( wh, "max", 1.0 );
3614 setPreferenceProperty( wh, "step", 0.1 );
3615 setPreferenceProperty( hh, "min", 0.0 );
3616 setPreferenceProperty( hh, "max", 1.0 );
3617 setPreferenceProperty( hh, "step", 0.1 );
3620 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3622 if( sect=="SMESH" ) {
3623 float sbX1,sbY1,sbW,sbH;
3624 float aTol = 1.00000009999999;
3625 std::string aWarning;
3626 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3627 if( name=="selection_object_color" || name=="selection_element_color" ||
3628 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3629 name=="selection_precision_node" || name=="selection_precision_element" ||
3630 name=="selection_precision_object")
3631 SMESH::UpdateSelectionProp( this );
3632 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3633 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3634 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3635 if(sbX1+sbW > aTol){
3636 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3639 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3640 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3643 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3644 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3645 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3646 if(sbY1+sbH > aTol){
3647 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3648 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3649 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3652 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3653 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3654 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3655 if(sbX1+sbW > aTol){
3656 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3659 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3660 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3663 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3664 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3665 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3666 if(sbY1+sbH > aTol){
3667 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3670 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3671 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3674 else if ( name == "segmentation" ) {
3675 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3676 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3678 else if ( name == "nb_segments_per_edge" ) {
3679 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3680 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3683 if(aWarning.size() != 0){
3684 aWarning += "The default values are applied instead.";
3685 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3686 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3687 QObject::tr(aWarning.c_str()));
3692 //================================================================================
3694 * \brief Update something in accordance with update flags
3695 * \param theFlags - update flags
3697 * Update viewer or/and object browser etc. in accordance with update flags ( see
3698 * LightApp_UpdateFlags enumeration ).
3700 //================================================================================
3701 void SMESHGUI::update( const int flags )
3703 if ( flags & UF_Viewer | flags & UF_Forced )
3704 SMESH::UpdateView();
3706 SalomeApp_Module::update( flags );
3709 //================================================================================
3711 * \brief Set default selection mode
3713 * SLOT called when operation commited. Sets default selection mode
3715 //================================================================================
3716 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3718 SVTK_ViewWindow* vtkWnd =
3719 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3721 vtkWnd->SetSelectionMode( ActorSelection );
3724 //================================================================================
3726 * \brief Set default selection mode
3728 * SLOT called when operation aborted. Sets default selection mode
3730 //================================================================================
3731 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3733 SVTK_ViewWindow* vtkWnd =
3734 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3736 vtkWnd->SetSelectionMode( ActorSelection );
3739 //================================================================================
3741 * \brief Creates operation with given identifier
3742 * \param id - identifier of operation to be started
3743 * \return Pointer on created operation or NULL if operation is not created
3745 * Virtual method redefined from the base class creates operation with given id.
3746 * It is called called automatically from startOperation method of base class.
3748 //================================================================================
3749 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3751 LightApp_Operation* op = 0;
3752 // to do : create operation here
3755 case 701: // Compute mesh
3756 op = new SMESHGUI_ComputeOp();
3758 case 702: // Create mesh
3759 op = new SMESHGUI_MeshOp( true, true );
3761 case 703: // Create sub-mesh
3762 op = new SMESHGUI_MeshOp( true, false );
3764 case 704: // Edit mesh/sub-mesh
3765 op = new SMESHGUI_MeshOp( false );
3767 case 711: // Precompute mesh
3768 op = new SMESHGUI_PrecomputeOp();
3770 case 806: // Create group on geom
3771 op = new SMESHGUI_GroupOnShapeOp();
3773 case 417: //convert to quadratic
3774 op = new SMESHGUI_ConvToQuadOp();
3776 case 4067: // make mesh pass through point
3777 op = new SMESHGUI_MakeNodeAtPointOp();
3784 op = SalomeApp_Module::createOperation( id );
3788 //================================================================================
3790 * \brief Stops current operations and starts a given one
3791 * \param id - The id of the operation to start
3793 //================================================================================
3795 void SMESHGUI::switchToOperation(int id)
3797 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3798 activeStudy()->abortAllOperations();
3799 startOperation( id );
3802 LightApp_Displayer* SMESHGUI::displayer()
3805 myDisplayer = new SMESHGUI_Displayer( getApp() );
3809 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3812 int aTolerance = 64;
3813 int anIterations = 0;
3819 if( anIterations % aPeriod == 0 )
3822 if( aTolerance < 1 )
3825 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3827 aHue = (int)( 360.0 * rand() / RAND_MAX );
3828 //cout << "Hue = " << aHue << endl;
3830 //cout << "Auto colors : ";
3832 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3833 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3834 for( ; it != itEnd; ++it )
3836 SALOMEDS::Color anAutoColor = *it;
3837 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3840 aQColor.getHsv( &h, &s, &v );
3842 if( abs( h - aHue ) < aTolerance )
3845 //cout << "break (diff = " << abs( h - aHue ) << ")";
3855 //cout << "Hue of the returned color = " << aHue << endl;
3857 aColor.setHsv( aHue, 255, 255 );
3859 SALOMEDS::Color aSColor;
3860 aSColor.R = (double)aColor.red() / 255.0;
3861 aSColor.G = (double)aColor.green() / 255.0;
3862 aSColor.B = (double)aColor.blue() / 255.0;
3867 const char gSeparator = '_'; // character used to separate parameter names
3868 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
3871 * \brief Store visual parameters
3873 * This method is called just before the study document is saved.
3874 * Store visual parameters in AttributeParameter attribue(s)
3876 void SMESHGUI::storeVisualParameters (int savePoint)
3878 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3879 if (!appStudy || !appStudy->studyDS())
3881 _PTR(Study) studyDS = appStudy->studyDS();
3883 // componentName is used for encoding of entries when storing them in IParameters
3884 std::string componentName = myComponentSMESH->ComponentDataType();
3885 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
3886 //if (!aSComponent) return;
3889 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3890 componentName.c_str(),
3892 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3894 // viewers counters are used for storing view_numbers in IParameters
3897 // main cycle to store parameters of displayed objects
3898 QList<SUIT_ViewManager*> lst;
3899 QList<SUIT_ViewManager*>::Iterator it;
3900 getApp()->viewManagers(lst);
3901 for (it = lst.begin(); it != lst.end(); it++)
3903 SUIT_ViewManager* vman = *it;
3904 QString vType = vman->getType();
3906 // saving VTK actors properties
3907 if (vType == SVTK_Viewer::Type())
3909 QVector<SUIT_ViewWindow*> views = vman->getViews();
3910 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
3912 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
3914 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
3915 allActors->InitTraversal();
3916 while (vtkActor* actor = allActors->GetNextActor())
3918 if (actor->GetVisibility()) // store only visible actors
3920 SMESH_Actor* aSmeshActor = 0;
3921 if (actor->IsA("SMESH_Actor"))
3922 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
3923 if (aSmeshActor && aSmeshActor->hasIO())
3925 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
3928 // entry is "encoded" = it does NOT contain component adress,
3929 // since it is a subject to change on next component loading
3930 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
3932 std::string param, vtkParam = vType.toLatin1().data();
3933 vtkParam += gSeparator;
3934 vtkParam += QString::number(vtkViewers).toLatin1().data();
3935 vtkParam += gSeparator;
3938 param = vtkParam + "Visibility";
3939 ip->setParameter(entry, param, "On");
3942 param = vtkParam + "Representation";
3943 ip->setParameter(entry, param, QString::number
3944 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
3947 param = vtkParam + "IsShrunk";
3948 ip->setParameter(entry, param, QString::number
3949 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
3951 // Displayed entities
3952 unsigned int aMode = aSmeshActor->GetEntityMode();
3953 bool isE = aMode & SMESH_Actor::eEdges;
3954 bool isF = aMode & SMESH_Actor::eFaces;
3955 bool isV = aMode & SMESH_Actor::eVolumes;
3957 QString modeStr ("e");
3958 modeStr += gDigitsSep; modeStr += QString::number(isE);
3959 modeStr += gDigitsSep; modeStr += "f";
3960 modeStr += gDigitsSep; modeStr += QString::number(isF);
3961 modeStr += gDigitsSep; modeStr += "v";
3962 modeStr += gDigitsSep; modeStr += QString::number(isV);
3964 param = vtkParam + "Entities";
3965 ip->setParameter(entry, param, modeStr.toLatin1().data());
3967 // Colors (surface:edge:)
3968 vtkFloatingPointType r, g, b;
3970 aSmeshActor->GetSufaceColor(r, g, b);
3971 QString colorStr ("surface");
3972 colorStr += gDigitsSep; colorStr += QString::number(r);
3973 colorStr += gDigitsSep; colorStr += QString::number(g);
3974 colorStr += gDigitsSep; colorStr += QString::number(b);
3976 aSmeshActor->GetBackSufaceColor(r, g, b);
3977 colorStr += gDigitsSep; colorStr += "backsurface";
3978 colorStr += gDigitsSep; colorStr += QString::number(r);
3979 colorStr += gDigitsSep; colorStr += QString::number(g);
3980 colorStr += gDigitsSep; colorStr += QString::number(b);
3982 aSmeshActor->GetEdgeColor(r, g, b);
3983 colorStr += gDigitsSep; colorStr += "edge";
3984 colorStr += gDigitsSep; colorStr += QString::number(r);
3985 colorStr += gDigitsSep; colorStr += QString::number(g);
3986 colorStr += gDigitsSep; colorStr += QString::number(b);
3988 aSmeshActor->GetNodeColor(r, g, b);
3989 colorStr += gDigitsSep; colorStr += "node";
3990 colorStr += gDigitsSep; colorStr += QString::number(r);
3991 colorStr += gDigitsSep; colorStr += QString::number(g);
3992 colorStr += gDigitsSep; colorStr += QString::number(b);
3994 param = vtkParam + "Colors";
3995 ip->setParameter(entry, param, colorStr.toLatin1().data());
3997 // Sizes of lines and points
3998 QString sizeStr ("line");
3999 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4000 sizeStr += gDigitsSep; sizeStr += "node";
4001 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4002 sizeStr += gDigitsSep; sizeStr += "shrink";
4003 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4005 param = vtkParam + "Sizes";
4006 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4009 param = vtkParam + "Opacity";
4010 ip->setParameter(entry, param,
4011 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4014 param = vtkParam + "ClippingPlane";
4015 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4017 ip->setParameter(entry, param, "Off");
4018 for (int ipl = 0; ipl < nPlanes; ipl++) {
4019 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4020 SMESH::Orientation anOrientation;
4022 vtkFloatingPointType anAngle[2];
4023 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4024 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4025 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4026 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4027 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4029 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4031 } // if (io->hasEntry())
4032 } // SMESH_Actor && hasIO
4034 } // while.. actors traversal
4038 } // if (SVTK view model)
4039 } // for (viewManagers)
4043 * \brief Restore visual parameters
4045 * This method is called after the study document is opened.
4046 * Restore visual parameters from AttributeParameter attribue(s)
4048 void SMESHGUI::restoreVisualParameters (int savePoint)
4050 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4051 if (!appStudy || !appStudy->studyDS())
4053 _PTR(Study) studyDS = appStudy->studyDS();
4055 // componentName is used for encoding of entries when storing them in IParameters
4056 std::string componentName = myComponentSMESH->ComponentDataType();
4057 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4058 //if (!aSComponent) return;
4061 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4062 componentName.c_str(),
4064 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4066 std::vector<std::string> entries = ip->getEntries();
4068 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4070 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4071 QString entry (ip->decodeEntry(*entIt).c_str());
4073 // Check that the entry corresponds to a real object in the Study
4074 // as the object may be deleted or modified after the visual state is saved.
4075 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4076 if (!so) continue; //Skip the not existent entry
4078 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4079 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4081 std::vector<std::string>::iterator namesIt = paramNames.begin();
4082 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4084 // actors are stored in a map after displaying of them for
4085 // quicker access in the future: map < viewID to actor >
4086 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4088 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4090 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4091 // '_' is used as separator and should not be used in viewer type or parameter names.
4092 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4093 if (lst.size() != 3)
4096 QString viewerTypStr = lst[0];
4097 QString viewIndexStr = lst[1];
4098 QString paramNameStr = lst[2];
4101 int viewIndex = viewIndexStr.toUInt(&ok);
4102 if (!ok) // bad conversion of view index to integer
4106 if (viewerTypStr == SVTK_Viewer::Type())
4108 SMESH_Actor* aSmeshActor = 0;
4109 if (vtkActors.IsBound(viewIndex))
4110 aSmeshActor = vtkActors.Find(viewIndex);
4112 if (paramNameStr == "Visibility")
4114 if (!aSmeshActor && displayer())
4116 QList<SUIT_ViewManager*> lst;
4117 getApp()->viewManagers(viewerTypStr, lst);
4119 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4120 if (viewIndex >= 0 && viewIndex < lst.count()) {
4121 SUIT_ViewManager* vman = lst.at(viewIndex);
4122 SUIT_ViewModel* vmodel = vman->getViewModel();
4123 // SVTK view model can be casted to SALOME_View
4124 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4126 // store displayed actor in a temporary map for quicker
4127 // access later when restoring other parameters
4128 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4129 vtkRenderer* Renderer = vtkView->getRenderer();
4130 vtkActorCollection* theActors = Renderer->GetActors();
4131 theActors->InitTraversal();
4132 bool isFound = false;
4133 vtkActor *ac = theActors->GetNextActor();
4134 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4135 if (ac->IsA("SMESH_Actor")) {
4136 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4137 if (aGeomAc->hasIO()) {
4138 Handle(SALOME_InteractiveObject) io =
4139 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4140 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4142 vtkActors.Bind(viewIndex, aGeomAc);
4149 } // if (paramNameStr == "Visibility")
4152 // the rest properties "work" with SMESH_Actor
4155 QString val ((*valuesIt).c_str());
4158 if (paramNameStr == "Representation") {
4159 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4162 else if (paramNameStr == "IsShrunk") {
4164 if (!aSmeshActor->IsShrunk())
4165 aSmeshActor->SetShrink();
4168 if (aSmeshActor->IsShrunk())
4169 aSmeshActor->UnShrink();
4172 // Displayed entities
4173 else if (paramNameStr == "Entities") {
4174 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4175 if (mode.count() == 6) {
4176 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4177 MESSAGE("Invalid order of data in Entities, must be: "
4178 "e:0/1:f:0/1:v:0/1");
4181 unsigned int aMode = aSmeshActor->GetEntityMode();
4182 unsigned int aNewMode =
4183 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4184 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4185 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4186 if (aNewMode != aMode)
4187 aSmeshActor->SetEntityMode(aNewMode);
4192 else if (paramNameStr == "Colors") {
4193 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4194 if (colors.count() == 16) {
4195 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4196 colors[8] != "edge" || colors[12] != "node") {
4197 MESSAGE("Invalid order of data in Colors, must be: "
4198 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4201 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4202 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4203 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4204 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4208 // Sizes of lines and points
4209 else if (paramNameStr == "Sizes") {
4210 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4211 if (sizes.count() == 6) {
4212 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4213 MESSAGE("Invalid order of data in Sizes, must be: "
4214 "line:int:node:int:shrink:float");
4217 aSmeshActor->SetLineWidth(sizes[1].toInt());
4218 aSmeshActor->SetNodeSize(sizes[3].toInt());
4219 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4224 else if (paramNameStr == "Opacity") {
4225 aSmeshActor->SetOpacity(val.toFloat());
4228 else if (paramNameStr.startsWith("ClippingPlane")) {
4229 cout << "$$$ ClippingPlane 1" << endl;
4230 if (paramNameStr == "ClippingPlane1" || val == "Off")
4231 aSmeshActor->RemoveAllClippingPlanes();
4233 cout << "$$$ ClippingPlane 2" << endl;
4234 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4235 if (vals.count() == 4) { // format check: 4 values
4236 cout << "$$$ ClippingPlane 3" << endl;
4237 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4238 double aDistance = vals[1].toFloat();
4239 vtkFloatingPointType anAngle[2];
4240 anAngle[0] = vals[2].toFloat();
4241 anAngle[1] = vals[3].toFloat();
4243 QList<SUIT_ViewManager*> lst;
4244 getApp()->viewManagers(viewerTypStr, lst);
4245 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4246 if (viewIndex >= 0 && viewIndex < lst.count()) {
4247 SUIT_ViewManager* vman = lst.at(viewIndex);
4248 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4249 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4250 anOrientation, aDistance, anAngle);
4255 } // if (aSmeshActor)
4256 } // other parameters than Visibility
4258 } // for names/parameters iterator
4259 } // for entries iterator
4261 // update all VTK views
4262 QList<SUIT_ViewManager*> lst;
4263 getApp()->viewManagers(lst);
4264 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4265 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4266 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4267 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4268 vtkView->getRenderer()->ResetCameraClippingRange();
4275 \brief Adds preferences for dfont of VTK viewer
4277 \param pIf group identifier
4278 \param param parameter
4279 \return identifier of preferences
4281 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4283 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4285 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4288 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4289 fam.append( tr( "SMESH_FONT_COURIER" ) );
4290 fam.append( tr( "SMESH_FONT_TIMES" ) );
4292 setPreferenceProperty( tfont, "fonts", fam );
4294 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4295 setPreferenceProperty( tfont, "features", f );