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 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
649 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
652 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
653 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
656 vtkFloatingPointType color[3];
657 anActor->GetSufaceColor(color[0], color[1], color[2]);
658 int c0 = int (color[0] * 255);
659 int c1 = int (color[1] * 255);
660 int c2 = int (color[2] * 255);
661 QColor c(c0, c1, c2);
663 vtkFloatingPointType edgecolor[3];
664 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
665 c0 = int (edgecolor[0] * 255);
666 c1 = int (edgecolor[1] * 255);
667 c2 = int (edgecolor[2] * 255);
668 QColor e(c0, c1, c2);
670 vtkFloatingPointType backfacecolor[3];
671 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
672 c0 = int (backfacecolor[0] * 255);
673 c1 = int (backfacecolor[1] * 255);
674 c2 = int (backfacecolor[2] * 255);
675 QColor b(c0, c1, c2);
677 vtkFloatingPointType nodecolor[3];
678 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
679 c0 = int (nodecolor[0] * 255);
680 c1 = int (nodecolor[1] * 255);
681 c2 = int (nodecolor[2] * 255);
682 QColor n(c0, c1, c2);
684 int Edgewidth = (int)anActor->GetLineWidth();
687 int intValue = int(anActor->GetNodeSize());
688 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
690 SMESHGUI_Preferences_ColorDlg *aDlg =
691 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
692 aDlg->SetColor(1, c);
693 aDlg->SetColor(2, e);
694 aDlg->SetColor(3, n);
695 aDlg->SetColor(4, b);
696 aDlg->SetIntValue(1, Edgewidth);
697 aDlg->SetIntValue(2, intValue);
698 aDlg->SetIntValue(3, int(Shrink*100.));
700 QColor color = aDlg->GetColor(1);
701 QColor edgecolor = aDlg->GetColor(2);
702 QColor nodecolor = aDlg->GetColor(3);
703 QColor backfacecolor = aDlg->GetColor(4);
704 /* actor color and backface color */
705 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
706 vtkFloatingPointType (color.green()) / 255.,
707 vtkFloatingPointType (color.blue()) / 255.);
708 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
709 vtkFloatingPointType (backfacecolor.green()) / 255.,
710 vtkFloatingPointType (backfacecolor.blue()) / 255.);
713 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
714 vtkFloatingPointType (edgecolor.green()) / 255.,
715 vtkFloatingPointType (edgecolor.blue()) / 255.);
717 /* Shrink factor and size edges */
718 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
719 anActor->SetLineWidth(aDlg->GetIntValue(1));
721 /* Nodes color and size */
722 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
723 vtkFloatingPointType (nodecolor.green()) / 255.,
724 vtkFloatingPointType (nodecolor.blue()) / 255.);
725 anActor->SetNodeSize(aDlg->GetIntValue(2));
727 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
728 if( !aGroupObject->_is_nil() )
730 SMESH::ElementType anElementType = aGroupObject->GetType();
732 switch( anElementType )
734 case SMESH::NODE: aColor = nodecolor; break;
735 case SMESH::EDGE: aColor = edgecolor; break;
736 default: aColor = color; break;
739 SALOMEDS::Color aGroupColor;
740 aGroupColor.R = (float)aColor.red() / 255.0;
741 aGroupColor.G = (float)aColor.green() / 255.0;
742 aGroupColor.B = (float)aColor.blue() / 255.0;
743 aGroupObject->SetColor( aGroupColor );
753 SMESH::RepaintCurrentView();
757 void Control( int theCommandID )
759 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
760 SALOME_ListIO selected;
762 aSel->selectedObjects( selected );
764 if( !selected.IsEmpty() ){
765 Handle(SALOME_InteractiveObject) anIO = selected.First();
768 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
769 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
770 switch ( theCommandID ){
772 aTitle = QObject::tr( "LENGTH_EDGES" );
773 aControl = SMESH_Actor::eLength;
776 aTitle = QObject::tr( "LENGTH2D_EDGES" );
777 aControl = SMESH_Actor::eLength2D;
780 aTitle = QObject::tr( "FREE_EDGES" );
781 aControl = SMESH_Actor::eFreeEdges;
784 aTitle = QObject::tr( "FREE_BORDERS" );
785 aControl = SMESH_Actor::eFreeBorders;
788 aTitle = QObject::tr( "MULTI_BORDERS" );
789 aControl = SMESH_Actor::eMultiConnection;
792 aTitle = QObject::tr( "FREE_NODES" );
793 aControl = SMESH_Actor::eFreeNodes;
796 aTitle = QObject::tr( "MULTI2D_BORDERS" );
797 aControl = SMESH_Actor::eMultiConnection2D;
800 aTitle = QObject::tr( "AREA_ELEMENTS" );
801 aControl = SMESH_Actor::eArea;
804 aTitle = QObject::tr( "TAPER_ELEMENTS" );
805 aControl = SMESH_Actor::eTaper;
808 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
809 aControl = SMESH_Actor::eAspectRatio;
812 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
813 aControl = SMESH_Actor::eAspectRatio3D;
816 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
817 aControl = SMESH_Actor::eMinimumAngle;
820 aTitle = QObject::tr( "WARP_ELEMENTS" );
821 aControl = SMESH_Actor::eWarping;
824 aTitle = QObject::tr( "SKEW_ELEMENTS" );
825 aControl = SMESH_Actor::eSkew;
828 aTitle = QObject::tr( "SMESH_VOLUME" );
829 aControl = SMESH_Actor::eVolume3D;
832 aTitle = QObject::tr( "FREE_FACES" );
833 aControl = SMESH_Actor::eFreeFaces;
836 anActor->SetControlMode(aControl);
837 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
838 SMESH::RepaintCurrentView();
845 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
846 MeshObjectType theType,
847 const QString theInTypeName,
848 QString & theOutTypeName)
850 SMESH_TypeFilter aTypeFilter( theType );
852 if( !theIO.IsNull() )
854 entry = theIO->getEntry();
855 LightApp_DataOwner owner( entry );
856 if ( aTypeFilter.isOk( &owner )) {
857 theOutTypeName = theInTypeName;
865 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
867 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
868 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
870 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
871 CORBA::String_var anID = aSComp->GetID().c_str();
872 if (!strcmp(anID.in(),theIO->getEntry()))
878 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
879 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
880 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
881 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
882 CheckOIType ( theIO, GROUP, "Group", aTypeName )
890 QString CheckHomogeneousSelection()
892 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
893 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
894 SALOME_ListIO selected;
896 aSel->selectedObjects( selected );
898 QString RefType = CheckTypeObject(selected.First());
899 SALOME_ListIteratorOfListIO It(selected);
900 for ( ; It.More(); It.Next())
902 Handle(SALOME_InteractiveObject) IObject = It.Value();
903 QString Type = CheckTypeObject(IObject);
904 if (Type.compare(RefType) != 0)
905 return "Heterogeneous Selection";
912 void SMESHGUI::OnEditDelete()
914 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
915 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
916 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
918 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
919 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
920 _PTR(GenericAttribute) anAttr;
921 _PTR(AttributeIOR) anIOR;
925 QString aParentComponent = QString::null;
926 Handle(SALOME_InteractiveObject) anIO;
927 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
930 QString cur = anIO->getComponentDataType();
931 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
933 // check if object is reference
934 _PTR(SObject) aRefSObj;
935 aNameList.append("\n - ");
936 if ( aSO->ReferencedObject( aRefSObj ) ) {
937 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
938 aNameList.append( aRefName );
939 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
942 aNameList.append(anIO->getName());
946 if( aParentComponent.isNull() )
947 aParentComponent = cur;
948 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
949 aParentComponent = "";
952 if ( objectCount == 0 )
953 return; // No Valid Objects Selected
955 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
956 SUIT_MessageBox::warning( SMESHGUI::desktop(),
957 QObject::tr("ERR_ERROR"),
958 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
961 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
962 if (SUIT_MessageBox::warning
963 (SMESHGUI::desktop(),
964 QObject::tr("SMESH_WRN_WARNING"),
965 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
966 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
967 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
970 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
971 SUIT_ViewManager* vm = anApp->activeViewManager();
972 int nbSf = vm->getViewsCount();
974 SALOME_ListIteratorOfListIO It(selected);
976 aStudyBuilder->NewCommand(); // There is a transaction
977 for( ; It.More(); It.Next()){ // loop on selected IO's
978 Handle(SALOME_InteractiveObject) IObject = It.Value();
979 if(IObject->hasEntry()) {
980 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
982 // disable removal of "SMESH" component object
983 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
985 if ( engineIOR() == anIOR->Value().c_str() )
988 //Check the referenced object
989 _PTR(SObject) aRefSObject;
990 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
991 aSO = aRefSObject; // Delete main Object instead of reference
993 // put the whole hierarchy of sub-objects of the selected SO into a list and
994 // then treat them all starting from the deepest objects (at list back)
996 std::list< _PTR(SObject) > listSO;
997 listSO.push_back( aSO );
998 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
999 for ( ; itSO != listSO.end(); ++itSO ) {
1000 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1001 for (it->InitEx(false); it->More(); it->Next())
1002 listSO.push_back( it->Value() );
1005 // treat SO's in the list starting from the back
1007 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1008 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1009 _PTR(SObject) SO = *ritSO;
1010 if ( !SO ) continue;
1011 std::string anEntry = SO->GetID();
1013 /** Erase graphical object **/
1014 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1015 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1016 for(int i = 0; i < nbSf; i++){
1017 SUIT_ViewWindow *sf = aViews[i];
1018 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1019 SMESH::RemoveActor(sf,anActor);
1024 /** Remove an object from data structures **/
1025 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1026 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1027 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1028 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1029 aMesh->RemoveGroup( aGroup );
1031 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1032 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1033 aMesh->RemoveSubMesh( aSubMesh );
1035 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1037 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1040 IObject = new SALOME_InteractiveObject
1041 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1042 QString objType = CheckTypeObject(IObject);
1043 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1044 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1045 aStudyBuilder->RemoveObjectWithChildren( SO );
1047 else {// default action: remove SObject from the study
1048 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1049 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1051 aStudyBuilder->RemoveObjectWithChildren( SO );
1055 } /* listSO back loop */
1056 } /* IObject->hasEntry() */
1058 aStudyBuilder->CommitCommand();
1060 /* Clear any previous selection */
1062 aSel->setSelectedObjects( l1 );
1064 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1069 SMESHGUI_EXPORT CAM_Module* createModule()
1071 return new SMESHGUI();
1075 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1077 //=============================================================================
1081 //=============================================================================
1082 SMESHGUI::SMESHGUI() :
1083 SalomeApp_Module( "SMESH" ),
1084 LightApp_Module( "SMESH" )
1086 if ( CORBA::is_nil( myComponentSMESH ) )
1088 CORBA::Boolean anIsEmbeddedMode;
1089 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1091 // 0019923: EDF 765 SMESH : default values of hypothesis
1092 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1093 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1094 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1095 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1096 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1099 myActiveDialogBox = 0;
1100 myFilterLibraryDlg = 0;
1104 SMESH::GetFilterManager();
1105 SMESH::GetPattern();
1107 /* load resources for all available meshers */
1108 SMESH::InitAvailableHypotheses();
1111 //=============================================================================
1115 //=============================================================================
1116 SMESHGUI::~SMESHGUI()
1118 SMESH::GetFilterManager()->Destroy();
1119 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1122 //=============================================================================
1126 //=============================================================================
1127 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1129 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1131 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1136 bool SMESHGUI::automaticUpdate()
1138 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1142 return resMgr->booleanValue( "SMESH", "auto_update", false );
1145 //=============================================================================
1149 //=============================================================================
1150 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1152 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1155 //=============================================================================
1159 //=============================================================================
1160 SMESHGUI* SMESHGUI::GetSMESHGUI()
1162 SMESHGUI* smeshMod = 0;
1163 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1166 CAM_Module* module = app->module( "Mesh" );
1167 smeshMod = dynamic_cast<SMESHGUI*>( module );
1170 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1172 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1175 _PTR(Study) aStudy = study->studyDS();
1177 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1186 Standard_EXPORT SMESHGUI* GetComponentGUI()
1188 return SMESHGUI::GetSMESHGUI();
1192 //=============================================================================
1196 //=============================================================================
1197 void SMESHGUI::SetState(int aState)
1202 //=============================================================================
1206 //=============================================================================
1207 void SMESHGUI::ResetState()
1212 //=============================================================================
1216 //=============================================================================
1217 void SMESHGUI::EmitSignalDeactivateDialog()
1219 emit SignalDeactivateActiveDialog();
1222 //=============================================================================
1226 //=============================================================================
1227 void SMESHGUI::EmitSignalStudyFrameChanged()
1229 emit SignalStudyFrameChanged();
1232 //=============================================================================
1236 //=============================================================================
1237 void SMESHGUI::EmitSignalCloseAllDialogs()
1239 emit SignalCloseAllDialogs();
1242 //=============================================================================
1246 //=============================================================================
1247 QDialog *SMESHGUI::GetActiveDialogBox()
1249 return myActiveDialogBox;
1252 //=============================================================================
1256 //=============================================================================
1257 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1259 myActiveDialogBox = (QDialog *) aDlg;
1263 //=============================================================================
1267 //=============================================================================
1268 SUIT_Desktop* SMESHGUI::desktop()
1270 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1272 return app->desktop();
1277 //=============================================================================
1281 //=============================================================================
1282 SalomeApp_Study* SMESHGUI::activeStudy()
1284 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1286 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1291 //=============================================================================
1295 //=============================================================================
1296 char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList)
1298 return theParametersList.join(":").toLatin1().data();
1301 //=============================================================================
1305 //=============================================================================
1306 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1308 /* Here the position is on the bottom right corner - 10 */
1309 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1311 SUIT_Desktop *PP = desktop();
1312 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1313 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1317 //=============================================================================
1321 //=============================================================================
1322 static int isStudyLocked(_PTR(Study) theStudy){
1323 return theStudy->GetProperties()->IsLocked();
1326 static bool checkLock(_PTR(Study) theStudy) {
1327 if (isStudyLocked(theStudy)) {
1328 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1329 QObject::tr("WRN_WARNING"),
1330 QObject::tr("WRN_STUDY_LOCKED") );
1336 //=======================================================================
1337 //function : CheckActiveStudyLocked
1339 //=======================================================================
1341 bool SMESHGUI::isActiveStudyLocked()
1343 _PTR(Study) aStudy = activeStudy()->studyDS();
1344 return checkLock( aStudy );
1347 //=============================================================================
1351 //=============================================================================
1352 bool SMESHGUI::OnGUIEvent( int theCommandID )
1354 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1358 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1359 SUIT_ResourceMgr* mgr = resourceMgr();
1363 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1364 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1367 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1368 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1370 //QAction* act = action( theCommandID );
1372 switch (theCommandID) {
1374 if(checkLock(aStudy)) break;
1382 if(checkLock(aStudy)) break;
1383 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1387 case 150: //MED FILE INFORMATION
1389 SALOME_ListIO selected;
1390 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1392 aSel->selectedObjects( selected );
1393 if( selected.Extent() )
1395 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1396 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1397 if ( !aMesh->_is_nil() )
1399 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1406 case 122: // EXPORT MED
1415 ::ExportMeshToFile(theCommandID);
1419 case 200: // SCALAR BAR
1421 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1422 SALOME_ListIO selected;
1424 aSel->selectedObjects( selected );
1426 if( selected.Extent() ) {
1427 Handle(SALOME_InteractiveObject) anIO = selected.First();
1428 if( anIO->hasEntry() ) {
1429 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1430 anActor->SetControlMode( SMESH_Actor::eNone );
1438 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1448 ::DisableAutoColor();
1451 case 1134: // Clipping
1452 case 1133: // Tranparency
1453 case 1132: // Colors / Size
1460 ::SetDisplayMode(theCommandID);
1463 //2D quadratic representation
1466 ::SetDisplayMode(theCommandID);
1472 case 219: // Volumes
1473 case 220: // All Entity
1474 ::SetDisplayEntity(theCommandID);
1477 case 221: // Orientation of faces
1479 LightApp_SelectionMgr* mgr = selectionMgr();
1480 SALOME_ListIO selected; mgr->selectedObjects( selected );
1482 SALOME_ListIteratorOfListIO it(selected);
1483 for( ; it.More(); it.Next()) {
1484 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1485 if(anIObject->hasEntry()) {
1486 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1487 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1496 if(checkLock(aStudy)) break;
1498 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1501 SMESH::UpdateView();
1503 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1504 SMESH::OnVisuException();
1506 catch (...) { // PAL16774 (Crash after display of many groups)
1507 SMESH::OnVisuException();
1511 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1512 aSel->selectedObjects( l );
1513 aSel->setSelectedObjects( l );
1518 case 301: // DISPLAY
1519 case 302: // DISPLAY ONLY
1521 SMESH::EDisplaing anAction;
1522 switch (theCommandID) {
1523 case 300: anAction = SMESH::eErase; break;
1524 case 301: anAction = SMESH::eDisplay; break;
1525 case 302: anAction = SMESH::eDisplayOnly; break;
1528 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1529 SALOME_ListIO sel_objects, to_process;
1531 aSel->selectedObjects( sel_objects );
1533 if( theCommandID==302 )
1534 startOperation( myEraseAll );
1536 extractContainers( sel_objects, to_process );
1539 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1543 SALOME_ListIteratorOfListIO It( to_process );
1544 for ( ; It.More(); It.Next()) {
1545 Handle(SALOME_InteractiveObject) IOS = It.Value();
1546 if (IOS->hasEntry()) {
1547 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1548 break; // PAL16774 (Crash after display of many groups)
1549 if (anAction == SMESH::eDisplayOnly)
1550 anAction = SMESH::eDisplay;
1555 // PAL13338 + PAL15161 -->
1556 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1557 SMESH::UpdateView();
1558 // PAL13338 + PAL15161 <--
1560 catch (...) { // PAL16774 (Crash after display of many groups)
1561 SMESH::OnVisuException();
1564 if (anAction == SMESH::eErase) {
1566 aSel->setSelectedObjects( l1 );
1569 aSel->setSelectedObjects( to_process );
1576 if(checkLock(aStudy)) break;
1579 EmitSignalDeactivateDialog();
1581 ( new SMESHGUI_NodesDlg( this ) )->show();
1584 SUIT_MessageBox::warning(desktop(),
1585 tr("SMESH_WRN_WARNING"),
1586 tr("SMESH_WRN_VIEWER_VTK"));
1591 case 2151: // FILTER
1595 EmitSignalDeactivateDialog();
1596 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1601 case 406: // MOVE NODE
1605 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1606 tr( "NOT_A_VTK_VIEWER" ) );
1610 if(checkLock(aStudy)) break;
1611 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1615 case 701: // COMPUTE MESH
1616 case 711: // PRECOMPUTE MESH
1618 if (checkLock(aStudy)) break;
1619 startOperation( theCommandID );
1623 case 702: // Create mesh
1624 case 703: // Create sub-mesh
1625 case 704: // Edit mesh/sub-mesh
1626 startOperation( theCommandID );
1628 case 710: // Build compound mesh
1630 if (checkLock(aStudy)) break;
1631 EmitSignalDeactivateDialog();
1632 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1636 case 407: // DIAGONAL INVERSION
1637 case 408: // Delete diagonal
1641 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1642 tr( "NOT_A_VTK_VIEWER" ) );
1646 if ( checkLock( aStudy ) )
1649 /*Standard_Boolean aRes;
1650 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1651 if ( aMesh->_is_nil() )
1653 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1654 tr( "SMESH_BAD_SELECTION" ) );
1658 EmitSignalDeactivateDialog();
1659 if ( theCommandID == 407 )
1660 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1662 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1665 case 409: // Change orientation
1666 case 410: // Union of triangles
1667 case 411: // Cutting of quadrangles
1671 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1672 tr( "NOT_A_VTK_VIEWER" ) );
1676 if ( checkLock( aStudy ) )
1679 EmitSignalDeactivateDialog();
1680 SMESHGUI_MultiEditDlg* aDlg = NULL;
1681 if ( theCommandID == 409 )
1682 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1683 else if ( theCommandID == 410 )
1684 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1686 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1691 case 412: // Smoothing
1693 if(checkLock(aStudy)) break;
1695 EmitSignalDeactivateDialog();
1696 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1699 SUIT_MessageBox::warning(desktop(),
1700 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1704 case 413: // Extrusion
1706 if (checkLock(aStudy)) break;
1708 EmitSignalDeactivateDialog();
1709 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1711 SUIT_MessageBox::warning(desktop(),
1712 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1716 case 414: // Revolution
1718 if(checkLock(aStudy)) break;
1720 EmitSignalDeactivateDialog();
1721 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1724 SUIT_MessageBox::warning(desktop(),
1725 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1729 case 415: // Pattern mapping
1731 if ( checkLock( aStudy ) )
1735 EmitSignalDeactivateDialog();
1736 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1739 SUIT_MessageBox::warning(desktop(),
1740 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1744 case 416: // Extrusion along a path
1746 if (checkLock(aStudy)) break;
1748 EmitSignalDeactivateDialog();
1749 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1751 SUIT_MessageBox::warning(desktop(),
1752 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1756 case 417: // Convert mesh to quadratic
1758 startOperation( 417 );
1759 /* if (checkLock(aStudy)) break;
1761 EmitSignalDeactivateDialog();
1762 new SMESHGUI_ConvToQuadDlg();
1764 SUIT_MessageBox::warning(desktop(),
1765 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1769 case 806: // CREATE GEO GROUP
1771 startOperation( 806 );
1774 case 801: // CREATE GROUP
1778 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1779 tr( "NOT_A_VTK_VIEWER" ) );
1783 if(checkLock(aStudy)) break;
1784 EmitSignalDeactivateDialog();
1785 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1787 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1788 SALOME_ListIO selected;
1790 aSel->selectedObjects( selected );
1792 int nbSel = selected.Extent();
1794 // check if mesh is selected
1795 aMesh = SMESH::GetMeshByIO( selected.First() );
1797 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1802 case 802: // CONSTRUCT GROUP
1806 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1807 tr( "NOT_A_VTK_VIEWER" ) );
1811 if(checkLock(aStudy)) break;
1812 EmitSignalDeactivateDialog();
1814 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1815 SALOME_ListIO selected;
1817 aSel->selectedObjects( selected );
1819 int nbSel = selected.Extent();
1821 // check if submesh is selected
1822 Handle(SALOME_InteractiveObject) IObject = selected.First();
1823 if (IObject->hasEntry()) {
1824 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1826 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1827 if (!aSubMesh->_is_nil()) {
1829 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1830 // get submesh elements list by types
1831 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1832 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1833 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1834 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1835 // create group for each type o elements
1836 QString aName = IObject->getName();
1837 if (aNodes->length() > 0) {
1838 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1839 aGroup->Add(aNodes.inout());
1841 if (aEdges->length() > 0) {
1842 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1843 aGroup->Add(aEdges.inout());
1845 if (aFaces->length() > 0) {
1846 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1847 aGroup->Add(aFaces.inout());
1849 if (aVolumes->length() > 0) {
1850 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1851 aGroup->Add(aVolumes.inout());
1856 catch(const SALOME::SALOME_Exception & S_ex){
1857 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1864 SUIT_MessageBox::warning(desktop(),
1865 tr("SMESH_WRN_WARNING"),
1866 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1871 case 803: // EDIT GROUP
1875 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1876 tr( "NOT_A_VTK_VIEWER" ) );
1880 if(checkLock(aStudy)) break;
1881 EmitSignalDeactivateDialog();
1883 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1884 SALOME_ListIO selected;
1886 aSel->selectedObjects( selected );
1888 SALOME_ListIteratorOfListIO It (selected);
1889 int nbSelectedGroups = 0;
1890 for ( ; It.More(); It.Next() )
1892 SMESH::SMESH_GroupBase_var aGroup =
1893 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1894 if (!aGroup->_is_nil()) {
1896 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1900 if (nbSelectedGroups == 0)
1902 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1908 case 804: // Add elements to group
1910 if(checkLock(aStudy)) break;
1911 if (myState == 800) {
1912 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1913 if (aDlg) aDlg->onAdd();
1918 case 805: // Remove elements from group
1920 if(checkLock(aStudy)) break;
1921 if (myState == 800) {
1922 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1923 if (aDlg) aDlg->onRemove();
1928 case 815: // Edit GEOM GROUP as standalone
1932 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1933 tr( "NOT_A_VTK_VIEWER" ) );
1937 if(checkLock(aStudy)) break;
1938 EmitSignalDeactivateDialog();
1940 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1941 SALOME_ListIO selected;
1943 aSel->selectedObjects( selected );
1945 SALOME_ListIteratorOfListIO It (selected);
1946 for ( ; It.More(); It.Next() )
1948 SMESH::SMESH_GroupOnGeom_var aGroup =
1949 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
1950 if (!aGroup->_is_nil()) {
1951 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
1958 case 810: // Union Groups
1959 case 811: // Intersect groups
1960 case 812: // Cut groups
1964 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1965 tr( "NOT_A_VTK_VIEWER" ) );
1969 if ( checkLock( aStudy ) )
1972 EmitSignalDeactivateDialog();
1974 SMESHGUI_GroupOpDlg* aDlg = 0;
1975 if ( theCommandID == 810 )
1976 aDlg = new SMESHGUI_UnionGroupsDlg( this );
1977 else if ( theCommandID == 811 )
1978 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
1980 aDlg = new SMESHGUI_CutGroupsDlg( this );
1987 case 814: // Create groups of entities from existing groups of superior dimensions
1989 if ( checkLock( aStudy ) )
1992 EmitSignalDeactivateDialog();
1993 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
1999 case 813: // Delete groups with their contents
2003 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2004 tr( "NOT_A_VTK_VIEWER" ) );
2008 if ( checkLock( aStudy ) )
2011 EmitSignalDeactivateDialog();
2013 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2017 case 900: // MESH INFOS
2019 EmitSignalDeactivateDialog();
2020 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2021 SALOME_ListIO selected;
2023 aSel->selectedObjects( selected );
2025 if ( selected.Extent() > 1 ) { // a dlg for each IO
2027 SALOME_ListIteratorOfListIO It (selected);
2028 for ( ; It.More(); It.Next() ) {
2029 IOs.Clear(); IOs.Append( It.Value() );
2030 aSel->setSelectedObjects( IOs );
2031 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2033 // restore selection
2034 aSel->setSelectedObjects( selected );
2037 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2041 case 902: // STANDARD MESH INFOS
2043 EmitSignalDeactivateDialog();
2044 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2045 SALOME_ListIO selected;
2047 aSel->selectedObjects( selected );
2049 if ( selected.Extent() > 1 ) { // a dlg for each IO
2051 SALOME_ListIteratorOfListIO It (selected);
2052 for ( ; It.More(); It.Next() ) {
2054 IOs.Append( It.Value() );
2055 aSel->setSelectedObjects( IOs );
2056 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2058 // restore selection
2059 aSel->setSelectedObjects( selected );
2062 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2066 case 903: // WHAT IS
2068 EmitSignalDeactivateDialog();
2069 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2073 case 1100: // EDIT HYPOTHESIS
2075 if(checkLock(aStudy)) break;
2077 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2078 SALOME_ListIO selected;
2080 aSel->selectedObjects( selected );
2082 int nbSel = selected.Extent();
2085 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2086 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2088 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2089 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2090 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2091 if ( !aHypothesis->_is_nil() )
2094 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2095 SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2097 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2105 updateObjBrowser( true );
2109 case 1101: // RENAME
2111 if ( checkLock( aStudy ) )
2114 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2115 SALOME_ListIO selected;
2117 aSel->selectedObjects( selected );
2119 bool isAny = false; // is there any appropriate object selected
2121 SALOME_ListIteratorOfListIO It( selected );
2122 for ( ; It.More(); It.Next() )
2124 Handle(SALOME_InteractiveObject) IObject = It.Value();
2125 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2126 _PTR(GenericAttribute) anAttr;
2127 _PTR(AttributeName) aName;
2130 if ( obj->FindAttribute(anAttr, "AttributeName") )
2133 QString newName = QString(aName->Value().c_str());
2135 // check type to prevent renaming of inappropriate objects
2136 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2137 if (aType == MESH || aType == GROUP ||
2138 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2139 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2140 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2141 aType == HYPOTHESIS || aType == ALGORITHM)
2144 newName = LightApp_NameDlg::getName(desktop(), newName);
2145 if ( !newName.isEmpty() )
2147 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2149 // update name of group object and its actor
2150 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2151 if( !aGroupObject->_is_nil() )
2153 aGroupObject->SetName( newName.toLatin1().data() );
2154 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2155 anActor->setName( newName.toLatin1().data() );
2166 SUIT_MessageBox::warning(desktop(),
2167 QObject::tr("SMESH_WRN_WARNING"),
2168 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2173 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2175 if(checkLock(aStudy)) break;
2176 SUIT_OverrideCursor wc;
2178 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2179 SALOME_ListIO selected;
2181 aSel->selectedObjects( selected, QString::null, false );
2183 SALOME_ListIteratorOfListIO It(selected);
2184 for (int i = 0; It.More(); It.Next(), i++) {
2185 Handle(SALOME_InteractiveObject) IObject = It.Value();
2186 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2189 aSel->setSelectedObjects( l1 );
2194 case 401: // GEOM::EDGE
2195 case 4021: // TRIANGLE
2197 case 4023: // POLYGON
2201 if(checkLock(aStudy)) break;
2203 EmitSignalDeactivateDialog();
2204 SMDSAbs_ElementType type = SMDSAbs_Edge;
2206 switch (theCommandID) {
2207 case 4021: // TRIANGLE
2208 type = SMDSAbs_Face; nbNodes = 3; break;
2210 type = SMDSAbs_Face; nbNodes = 4; break;
2212 type = SMDSAbs_Volume; nbNodes = 4; break;
2213 case 4023: // POLYGON
2214 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2216 type = SMDSAbs_Volume; nbNodes = 8; break;
2217 case 4033: // POLYHEDRE
2218 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2221 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2224 SUIT_MessageBox::warning(desktop(),
2225 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2229 case 4033: // POLYHEDRON
2231 if(checkLock(aStudy)) break;
2233 EmitSignalDeactivateDialog();
2234 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2237 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2238 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2242 case 4034: // QUADRATIC EDGE
2243 case 4035: // QUADRATIC TRIANGLE
2244 case 4036: // QUADRATIC QUADRANGLE
2245 case 4037: // QUADRATIC TETRAHEDRON
2246 case 4038: // QUADRATIC PYRAMID
2247 case 4039: // QUADRATIC PENTAHEDRON
2248 case 4040: // QUADRATIC HEXAHEDRON
2250 if(checkLock(aStudy)) break;
2252 EmitSignalDeactivateDialog();
2255 switch (theCommandID) {
2257 type = QUAD_EDGE; break;
2259 type = QUAD_TRIANGLE; break;
2261 type = QUAD_QUADRANGLE; break;
2263 type = QUAD_TETRAHEDRON; break;
2265 type = QUAD_PYRAMID; break;
2267 type = QUAD_PENTAHEDRON; break;
2269 type = QUAD_HEXAHEDRON;
2273 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2276 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2277 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2281 case 4041: // REMOVES NODES
2283 if(checkLock(aStudy)) break;
2285 EmitSignalDeactivateDialog();
2286 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2289 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2290 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2294 case 4042: // REMOVES ELEMENTS
2296 if(checkLock(aStudy)) break;
2298 EmitSignalDeactivateDialog();
2299 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2303 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2304 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2308 case 4043: { // CLEAR_MESH
2310 if(checkLock(aStudy)) break;
2312 SALOME_ListIO selected;
2313 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2314 aSel->selectedObjects( selected );
2316 SUIT_OverrideCursor wc;
2317 SALOME_ListIteratorOfListIO It (selected);
2318 for ( ; It.More(); It.Next() )
2320 Handle(SALOME_InteractiveObject) IOS = It.Value();
2321 SMESH::SMESH_Mesh_var aMesh =
2322 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2323 if ( aMesh->_is_nil()) continue;
2325 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2327 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2328 SMESH::ModifiedMesh( aMeshSObj, false, true);
2329 // hide groups and submeshes
2330 _PTR(ChildIterator) anIter =
2331 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2332 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2334 _PTR(SObject) so = anIter->Value();
2335 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2338 catch (const SALOME::SALOME_Exception& S_ex){
2340 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2344 SMESH::UpdateView();
2348 case 4051: // RENUMBERING NODES
2350 if(checkLock(aStudy)) break;
2352 EmitSignalDeactivateDialog();
2353 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2357 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2358 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2362 case 4052: // RENUMBERING ELEMENTS
2364 if(checkLock(aStudy)) break;
2366 EmitSignalDeactivateDialog();
2367 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2371 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2372 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2376 case 4061: // TRANSLATION
2378 if(checkLock(aStudy)) break;
2380 EmitSignalDeactivateDialog();
2381 ( new SMESHGUI_TranslationDlg( this ) )->show();
2384 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2385 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2389 case 4062: // ROTATION
2391 if(checkLock(aStudy)) break;
2393 EmitSignalDeactivateDialog();
2394 ( new SMESHGUI_RotationDlg( this ) )->show();
2397 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2398 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2402 case 4063: // SYMMETRY
2404 if(checkLock(aStudy)) break;
2406 EmitSignalDeactivateDialog();
2407 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2410 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2411 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2415 case 4064: // SEWING
2417 if(checkLock(aStudy)) break;
2419 EmitSignalDeactivateDialog();
2420 ( new SMESHGUI_SewingDlg( this ) )->show();
2423 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2424 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2428 case 4065: // MERGE NODES
2430 if(checkLock(aStudy)) break;
2432 EmitSignalDeactivateDialog();
2433 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2436 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2437 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2441 case 4066: // MERGE EQUAL ELEMENTS
2443 if (checkLock(aStudy)) break;
2445 EmitSignalDeactivateDialog();
2446 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2448 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2454 case 4067: // MAKE MESH PASS THROUGH POINT
2455 startOperation( 4067 );
2458 case 5105: // Library of selection filters
2460 static QList<int> aTypes;
2461 if ( aTypes.isEmpty() )
2463 aTypes.append( SMESH::NODE );
2464 aTypes.append( SMESH::EDGE );
2465 aTypes.append( SMESH::FACE );
2466 aTypes.append( SMESH::VOLUME );
2468 if (!myFilterLibraryDlg)
2469 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2470 else if (myFilterLibraryDlg->isHidden())
2471 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2472 myFilterLibraryDlg->raise();
2476 case 6017: // CONTROLS
2494 LightApp_SelectionMgr* mgr = selectionMgr();
2495 SALOME_ListIO selected; mgr->selectedObjects( selected );
2497 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2498 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2500 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2501 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2502 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2503 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2504 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2505 ::Control( theCommandID );
2510 SUIT_MessageBox::warning(desktop(),
2511 tr( "SMESH_WRN_WARNING" ),
2512 tr( "SMESH_BAD_SELECTION" ) );
2516 SUIT_MessageBox::warning(desktop(),
2517 tr( "SMESH_WRN_WARNING" ),
2518 tr( "NOT_A_VTK_VIEWER" ) );
2523 LightApp_SelectionMgr* mgr = selectionMgr();
2524 SALOME_ListIO selected; mgr->selectedObjects( selected );
2526 SALOME_ListIteratorOfListIO it(selected);
2527 for( ; it.More(); it.Next()) {
2528 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2529 if(anIObject->hasEntry()) {
2530 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2531 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2539 LightApp_SelectionMgr* mgr = selectionMgr();
2540 SALOME_ListIO selected; mgr->selectedObjects( selected );
2542 if (selected.Extent() == 1) {
2543 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2544 if(anIObject->hasEntry())
2545 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2546 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2553 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2554 //updateObjBrowser();
2558 //=============================================================================
2562 //=============================================================================
2563 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2568 //=============================================================================
2572 //=============================================================================
2573 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2578 //=============================================================================
2582 //=============================================================================
2583 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2588 //=============================================================================
2589 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2590 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2592 //=============================================================================
2593 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2594 SUIT_ViewWindow* wnd )
2596 if(theIO->hasEntry()){
2597 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2598 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2602 //=======================================================================
2603 // function : createSMESHAction
2605 //=======================================================================
2606 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2609 QWidget* parent = application()->desktop();
2610 SUIT_ResourceMgr* resMgr = resourceMgr();
2612 if ( !icon_id.isEmpty() )
2613 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2615 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2616 if ( !pix.isNull() )
2617 icon = QIcon( pix );
2619 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2620 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2621 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2623 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2626 //=======================================================================
2627 // function : createPopupItem
2629 //=======================================================================
2630 void SMESHGUI::createPopupItem( const int id,
2631 const QString& clients,
2632 const QString& types,
2633 const QString& theRule,
2638 parentId = popupMgr()->actionId( action( pId ) );
2640 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2641 popupMgr()->insert( action( id ), parentId, 0 );
2643 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2644 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2645 QString rule = "(%1) and (%2) and (%3)";
2646 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2647 if( clients.isEmpty() )
2648 rule = rule.arg( QString( "true" ) );
2650 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2651 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2654 bool cont = myRules.contains( id );
2656 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2658 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2659 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2662 //=======================================================================
2663 // function : initialize
2665 //=======================================================================
2666 void SMESHGUI::initialize( CAM_Application* app )
2668 SalomeApp_Module::initialize( app );
2670 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2672 /* Automatic Update flag */
2673 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2675 // ----- create actions --------------
2677 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2678 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2679 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2680 createSMESHAction( 114, "NUM" );
2681 createSMESHAction( 121, "DAT" );
2682 createSMESHAction( 122, "MED" );
2683 createSMESHAction( 123, "UNV" );
2684 createSMESHAction( 140, "STL" );
2685 createSMESHAction( 124, "EXPORT_DAT" );
2686 createSMESHAction( 125, "EXPORT_MED" );
2687 createSMESHAction( 126, "EXPORT_UNV" );
2688 createSMESHAction( 141, "EXPORT_STL" );
2689 createSMESHAction( 150, "FILE_INFO" );
2690 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2691 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2692 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2693 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2694 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2695 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2696 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2697 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2698 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2699 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2700 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2701 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2702 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2703 createSMESHAction( 804, "ADD" );
2704 createSMESHAction( 805, "REMOVE" );
2705 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2706 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2707 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2708 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2709 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2710 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2711 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2712 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2713 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2714 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2715 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2716 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2717 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2718 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2719 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2720 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2721 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2722 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2723 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2724 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2725 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2726 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2727 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2728 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2729 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2730 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2731 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2732 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2733 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2734 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2735 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2736 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2737 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2738 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2739 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2740 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2741 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2742 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2743 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2744 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2745 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2746 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2747 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2748 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2749 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2750 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2751 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2752 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2753 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2754 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2755 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2756 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2757 createSMESHAction( 415, "MAP", "ICON_MAP" );
2758 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2759 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2760 createSMESHAction( 200, "RESET" );
2761 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2762 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2763 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2764 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2765 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2766 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2767 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2768 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2769 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2770 createSMESHAction( 220, "ALL" );
2771 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2773 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2774 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2776 createSMESHAction( 1100, "EDIT_HYPO" );
2777 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2778 createSMESHAction( 1102, "UNASSIGN" );
2779 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2780 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2781 createSMESHAction( 1131, "DISPMODE" );
2782 createSMESHAction( 1132, "COLORS" );
2783 createSMESHAction( 1133, "TRANSP" );
2784 createSMESHAction( 1134, "CLIP" );
2785 createSMESHAction( 1135, "DISP_ENT" );
2786 createSMESHAction( 1136, "AUTO_COLOR" );
2787 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2788 createSMESHAction( 2000, "CTRL" );
2790 createSMESHAction( 300, "ERASE" );
2791 createSMESHAction( 301, "DISPLAY" );
2792 createSMESHAction( 302, "DISPLAY_ONLY" );
2793 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2794 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2795 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2796 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2797 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2798 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2799 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2800 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2802 // ----- create menu --------------
2803 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2804 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2805 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2806 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2807 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2808 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2809 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2811 createMenu( separator(), fileId );
2813 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2814 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2815 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2816 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2817 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2818 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2820 createMenu( 111, importId, -1 );
2821 createMenu( 112, importId, -1 );
2822 createMenu( 113, importId, -1 );
2824 createMenu( 121, exportId, -1 );
2825 createMenu( 122, exportId, -1 );
2826 createMenu( 123, exportId, -1 );
2827 createMenu( 140, exportId, -1 ); // export to stl STL
2829 createMenu( separator(), fileId, 10 );
2831 createMenu( 33, editId, -1 );
2833 createMenu( 5105, toolsId, -1 );
2835 createMenu( 702, meshId, -1 ); // "Mesh" menu
2836 createMenu( 703, meshId, -1 );
2837 createMenu( 704, meshId, -1 );
2838 createMenu( 710, meshId, -1 );
2839 createMenu( separator(), meshId, -1 );
2840 createMenu( 701, meshId, -1 );
2841 createMenu( 711, meshId, -1 );
2842 createMenu( separator(), meshId, -1 );
2843 createMenu( 801, meshId, -1 );
2844 createMenu( 806, meshId, -1 );
2845 createMenu( 802, meshId, -1 );
2846 createMenu( 803, meshId, -1 );
2847 createMenu( 815, meshId, -1 );
2848 createMenu( separator(), meshId, -1 );
2849 createMenu( 810, meshId, -1 );
2850 createMenu( 811, meshId, -1 );
2851 createMenu( 812, meshId, -1 );
2852 createMenu( separator(), meshId, -1 );
2853 createMenu( 814, meshId, -1 );
2854 createMenu( separator(), meshId, -1 );
2855 createMenu( 813, meshId, -1 );
2856 createMenu( separator(), meshId, -1 );
2857 createMenu( 900, meshId, -1 );
2858 createMenu( 902, meshId, -1 );
2859 createMenu( 903, meshId, -1 );
2860 createMenu( separator(), meshId, -1 );
2862 createMenu( 6003, ctrlId, -1 );
2863 createMenu( 6001, ctrlId, -1 );
2864 createMenu( 6004, ctrlId, -1 );
2865 createMenu( separator(), ctrlId, -1 );
2866 createMenu( 6005, ctrlId, -1 );
2867 createMenu( 6002, ctrlId, -1 );
2868 createMenu( 6018, ctrlId, -1 );
2869 createMenu( 6019, ctrlId, -1 );
2870 createMenu( 6011, ctrlId, -1 );
2871 createMenu( 6012, ctrlId, -1 );
2872 createMenu( 6013, ctrlId, -1 );
2873 createMenu( 6014, ctrlId, -1 );
2874 createMenu( 6015, ctrlId, -1 );
2875 createMenu( 6016, ctrlId, -1 );
2876 createMenu( separator(), ctrlId, -1 );
2877 createMenu( 6017, ctrlId, -1 );
2878 createMenu( 6009, ctrlId, -1 );
2879 createMenu( 6021, ctrlId, -1 );
2880 createMenu( separator(), ctrlId, -1 );
2882 createMenu( 400, addId, -1 );
2883 createMenu( 401, addId, -1 );
2884 createMenu( 4021, addId, -1 );
2885 createMenu( 4022, addId, -1 );
2886 createMenu( 4023, addId, -1 );
2887 createMenu( 4031, addId, -1 );
2888 createMenu( 4032, addId, -1 );
2889 createMenu( 4033, addId, -1 );
2890 createMenu( separator(), addId, -1 );
2891 createMenu( 4034, addId, -1 );
2892 createMenu( 4035, addId, -1 );
2893 createMenu( 4036, addId, -1 );
2894 createMenu( 4037, addId, -1 );
2895 createMenu( 4038, addId, -1 );
2896 createMenu( 4039, addId, -1 );
2897 createMenu( 4040, addId, -1 );
2899 createMenu( 4041, removeId, -1 );
2900 createMenu( 4042, removeId, -1 );
2901 createMenu( 4043, removeId, -1 );
2903 createMenu( 4051, renumId, -1 );
2904 createMenu( 4052, renumId, -1 );
2906 createMenu( 4061, transfId, -1 );
2907 createMenu( 4062, transfId, -1 );
2908 createMenu( 4063, transfId, -1 );
2909 createMenu( 4064, transfId, -1 );
2910 createMenu( 4065, transfId, -1 );
2911 createMenu( 4066, transfId, -1 );
2913 createMenu( 406, modifyId, -1 );
2914 createMenu( 4067,modifyId, -1 );
2915 createMenu( 407, modifyId, -1 );
2916 createMenu( 408, modifyId, -1 );
2917 createMenu( 409, modifyId, -1 );
2918 createMenu( 410, modifyId, -1 );
2919 createMenu( 411, modifyId, -1 );
2920 createMenu( 412, modifyId, -1 );
2921 createMenu( 413, modifyId, -1 );
2922 createMenu( 416, modifyId, -1 );
2923 createMenu( 414, modifyId, -1 );
2924 createMenu( 415, modifyId, -1 );
2925 createMenu( 417, modifyId, -1 );
2927 createMenu( 214, viewId, -1 );
2929 // ----- create toolbars --------------
2930 int meshTb = createTool( tr( "TB_MESH" ) ),
2931 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2932 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2933 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2934 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2936 createTool( 702, meshTb );
2937 createTool( 703, meshTb );
2938 createTool( 704, meshTb );
2939 createTool( 710, meshTb );
2940 createTool( separator(), meshTb );
2941 createTool( 701, meshTb );
2942 createTool( 711, meshTb );
2943 createTool( separator(), meshTb );
2944 createTool( 801, meshTb );
2945 createTool( 806, meshTb );
2946 createTool( 802, meshTb );
2947 createTool( 803, meshTb );
2948 //createTool( 815, meshTb );
2949 createTool( separator(), meshTb );
2950 createTool( 900, meshTb );
2951 createTool( 902, meshTb );
2952 createTool( 903, meshTb );
2953 createTool( separator(), meshTb );
2955 createTool( 6001, ctrlTb );
2956 createTool( 6003, ctrlTb );
2957 createTool( 6004, ctrlTb );
2958 createTool( separator(), ctrlTb );
2959 createTool( 6005, ctrlTb );
2960 createTool( 6002, ctrlTb );
2961 createTool( 6018, ctrlTb );
2962 createTool( 6019, ctrlTb );
2963 createTool( 6011, ctrlTb );
2964 createTool( 6012, ctrlTb );
2965 createTool( 6013, ctrlTb );
2966 createTool( 6014, ctrlTb );
2967 createTool( 6015, ctrlTb );
2968 createTool( 6016, ctrlTb );
2969 createTool( separator(), ctrlTb );
2970 createTool( 6017, ctrlTb );
2971 createTool( 6009, ctrlTb );
2972 createTool( 6021, ctrlTb );
2973 createTool( separator(), ctrlTb );
2975 createTool( 400, addRemTb );
2976 createTool( 401, addRemTb );
2977 createTool( 4021, addRemTb );
2978 createTool( 4022, addRemTb );
2979 createTool( 4023, addRemTb );
2980 createTool( 4031, addRemTb );
2981 createTool( 4032, addRemTb );
2982 createTool( 4033, addRemTb );
2983 createTool( separator(), addRemTb );
2984 createTool( 4034, addRemTb );
2985 createTool( 4035, addRemTb );
2986 createTool( 4036, addRemTb );
2987 createTool( 4037, addRemTb );
2988 createTool( 4038, addRemTb );
2989 createTool( 4039, addRemTb );
2990 createTool( 4040, addRemTb );
2991 createTool( separator(), addRemTb );
2992 createTool( 4041, addRemTb );
2993 createTool( 4042, addRemTb );
2994 createTool( 4043, addRemTb );
2995 createTool( separator(), addRemTb );
2996 createTool( 4051, addRemTb );
2997 createTool( 4052, addRemTb );
2998 createTool( separator(), addRemTb );
2999 createTool( 4061, addRemTb );
3000 createTool( 4062, addRemTb );
3001 createTool( 4063, addRemTb );
3002 createTool( 4064, addRemTb );
3003 createTool( 4065, addRemTb );
3004 createTool( 4066, addRemTb );
3005 createTool( separator(), addRemTb );
3007 createTool( 406, modifyTb );
3008 createTool( 4067,modifyTb );
3009 createTool( 407, modifyTb );
3010 createTool( 408, modifyTb );
3011 createTool( 409, modifyTb );
3012 createTool( 410, modifyTb );
3013 createTool( 411, modifyTb );
3014 createTool( 412, modifyTb );
3015 createTool( 413, modifyTb );
3016 createTool( 416, modifyTb );
3017 createTool( 414, modifyTb );
3018 createTool( 415, modifyTb );
3019 createTool( 417, modifyTb );
3021 createTool( 214, dispModeTb );
3023 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3024 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3027 QString OB = "'ObjectBrowser'",
3028 View = "'" + SVTK_Viewer::Type() + "'",
3030 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3031 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3032 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3033 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3034 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3035 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3036 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3037 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3038 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3039 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3040 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3042 mesh_group = mesh + " " + subMesh + " " + group,
3043 hyp_alg = hypo + " " + algo;
3045 // popup for object browser
3047 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3048 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3049 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3050 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3051 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3052 createPopupItem( 803, OB, group ); // EDIT_GROUP
3053 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3055 popupMgr()->insert( separator(), -1, 0 );
3056 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3057 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3058 createPopupItem( 214, OB, mesh_group ); // UPDATE
3059 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3060 createPopupItem( 902, OB, mesh ); // STD_INFO
3061 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3062 popupMgr()->insert( separator(), -1, 0 );
3063 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3064 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3065 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3066 popupMgr()->insert( separator(), -1, 0 );
3067 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3068 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3069 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3070 popupMgr()->insert( separator(), -1, 0 );
3071 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3072 popupMgr()->insert( separator(), -1, 0 );
3074 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3076 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
3077 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3078 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3079 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3080 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3081 popupMgr()->insert( separator(), -1, 0 );
3084 createPopupItem( 803, View, group ); // EDIT_GROUP
3085 createPopupItem( 804, View, elems ); // ADD
3086 createPopupItem( 805, View, elems ); // REMOVE
3088 popupMgr()->insert( separator(), -1, 0 );
3089 createPopupItem( 214, View, mesh_group ); // UPDATE
3090 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3091 createPopupItem( 902, View, mesh ); // STD_INFO
3092 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3093 popupMgr()->insert( separator(), -1, 0 );
3095 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3096 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3097 popupMgr()->insert( separator(), -1, 0 );
3101 isInvisible("not( isVisible )"),
3102 isEmpty("numberOfNodes = 0"),
3103 isNotEmpty("numberOfNodes <> 0"),
3105 // has nodes, edges, etc in VISIBLE! actor
3106 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3107 hasElems("(count( elemTypes ) > 0)"),
3108 hasDifferentElems("(count( elemTypes ) > 1)"),
3109 hasEdges("({'Edge'} in elemTypes)"),
3110 hasFaces("({'Face'} in elemTypes)"),
3111 hasVolumes("({'Volume'} in elemTypes)");
3113 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3114 QString aType = QString( "%1type in {%2}" ).arg( lc );
3115 aType = aType.arg( mesh_group );
3116 QString aMeshInVTK = aClient + "&&" + aType;
3118 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3119 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3120 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3122 //-------------------------------------------------
3124 //-------------------------------------------------
3125 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3127 popupMgr()->insert( action( 9010 ), anId, -1 );
3128 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3129 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3131 popupMgr()->insert( action( 9011 ), anId, -1 );
3132 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3133 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3135 popupMgr()->insert( separator(), -1, -1 );
3137 //-------------------------------------------------
3139 //-------------------------------------------------
3140 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3142 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3143 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3144 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3146 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3147 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3148 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3150 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3151 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3152 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3154 popupMgr()->insert( separator(), anId, -1 );
3156 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3157 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3158 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3160 //-------------------------------------------------
3162 //-------------------------------------------------
3163 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3165 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3167 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3168 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3169 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3171 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3172 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3173 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3175 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3176 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3177 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3179 popupMgr()->insert( separator(), anId, -1 );
3181 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3182 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3185 //-------------------------------------------------
3186 // Representation of the 2D Quadratic elements
3187 //-------------------------------------------------
3188 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3189 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3190 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3191 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3193 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3194 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3195 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3197 //-------------------------------------------------
3198 // Orientation of faces
3199 //-------------------------------------------------
3200 popupMgr()->insert( action( 221 ), -1, -1 );
3201 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3202 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3204 //-------------------------------------------------
3206 //-------------------------------------------------
3207 popupMgr()->insert( action( 1132 ), -1, -1 );
3208 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3210 //-------------------------------------------------
3212 //-------------------------------------------------
3213 popupMgr()->insert( action( 1133 ), -1, -1 );
3214 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3216 //-------------------------------------------------
3218 //-------------------------------------------------
3219 popupMgr()->insert( action( 1134 ), -1, -1 );
3220 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3222 popupMgr()->insert( separator(), -1, -1 );
3224 //-------------------------------------------------
3226 //-------------------------------------------------
3228 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3229 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3230 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3231 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3233 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3235 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3236 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3238 popupMgr()->insert( separator(), anId, -1 );
3240 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3241 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3242 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3244 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3245 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3246 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3248 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3249 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3250 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3252 popupMgr()->insert( separator(), anId, -1 );
3254 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3255 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3256 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3258 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3259 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3260 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3262 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3263 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3264 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3266 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3267 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3268 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3270 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3271 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3272 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3274 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3275 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3276 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3278 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3279 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3280 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3282 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3283 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3284 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3286 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3287 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3288 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3290 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3291 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3292 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3294 popupMgr()->insert( separator(), anId, -1 );
3296 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3297 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3298 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3300 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3301 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3302 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3304 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3305 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3306 QtxPopupMgr::VisibleRule );
3307 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3309 popupMgr()->insert( separator(), anId, -1 );
3311 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3312 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3314 popupMgr()->insert( separator(), -1, -1 );
3316 //-------------------------------------------------
3318 //-------------------------------------------------
3319 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3320 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3321 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3322 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3324 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3325 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3327 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3328 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3330 popupMgr()->insert( separator(), -1, -1 );
3332 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3333 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3336 //================================================================================
3338 * \brief Return true if SMESH or GEOM objects are selected.
3339 * Is called form LightApp_Module::activateModule() which clear selection if
3340 * not isSelectionCompatible()
3342 //================================================================================
3344 bool SMESHGUI::isSelectionCompatible()
3346 bool isCompatible = true;
3347 SALOME_ListIO selected;
3348 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3349 Sel->selectedObjects( selected );
3351 SALOME_ListIteratorOfListIO It( selected );
3352 for ( ; isCompatible && It.More(); It.Next())
3354 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3355 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3357 return isCompatible;
3360 bool SMESHGUI::activateModule( SUIT_Study* study )
3362 bool res = SalomeApp_Module::activateModule( study );
3364 setMenuShown( true );
3365 setToolShown( true );
3367 // Reset actions accelerator keys
3368 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3369 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3370 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3372 action( 33)->setEnabled(true); // Delete: Key_Delete
3373 action(1101)->setEnabled(true); // Rename: Key_F2
3375 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3376 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3377 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3378 if ( _PTR(Study) aStudy = s->studyDS()) {
3379 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3380 updateObjBrowser(); // objects can be removed
3386 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3388 setMenuShown( false );
3389 setToolShown( false );
3391 EmitSignalCloseAllDialogs();
3393 // Unset actions accelerator keys
3394 action(111)->setShortcut(QKeySequence()); // Import DAT
3395 action(112)->setShortcut(QKeySequence()); // Import UNV
3396 action(113)->setShortcut(QKeySequence()); // Import MED
3398 action( 33)->setEnabled(false); // Delete: Key_Delete
3399 action(1101)->setEnabled(false); // Rename: Key_F2
3401 return SalomeApp_Module::deactivateModule( study );
3404 void SMESHGUI::studyClosed( SUIT_Study* s )
3406 SMESH::RemoveVisuData( s->id() );
3407 SalomeApp_Module::studyClosed( s );
3410 void SMESHGUI::OnGUIEvent()
3412 const QObject* obj = sender();
3413 if ( !obj || !obj->inherits( "QAction" ) )
3415 int id = actionId((QAction*)obj);
3420 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3422 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3423 if ( CORBA::is_nil( myComponentSMESH ) )
3425 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3427 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3428 return aGUI.myComponentSMESH;
3431 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3432 return myComponentSMESH;
3435 QString SMESHGUI::engineIOR() const
3437 CORBA::ORB_var anORB = getApp()->orb();
3438 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3439 return QString( anIOR.in() );
3442 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3444 SalomeApp_Module::contextMenuPopup( client, menu, title );
3446 selectionMgr()->selectedObjects( lst );
3447 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3448 Handle(SALOME_InteractiveObject) io = lst.First();
3449 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3450 _PTR(Study) study = appStudy->studyDS();
3451 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3453 QString aName = QString( obj->GetName().c_str() );
3454 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3455 aName.remove( (aName.length() - 1), 1 );
3461 LightApp_Selection* SMESHGUI::createSelection() const
3463 return new SMESHGUI_Selection();
3466 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3468 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3469 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3472 void SMESHGUI::viewManagers( QStringList& list ) const
3474 list.append( SVTK_Viewer::Type() );
3477 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3479 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3480 SMESH::UpdateSelectionProp( this );
3483 void SMESHGUI::createPreferences()
3485 // General tab ------------------------------------------------------------------------
3486 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3488 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3489 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3491 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3492 setPreferenceProperty( qaGroup, "columns", 2 );
3493 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3494 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3495 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3496 setPreferenceProperty( prec, "min", 0 );
3497 setPreferenceProperty( prec, "max", 16 );
3499 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3500 setPreferenceProperty( dispgroup, "columns", 2 );
3501 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3503 modes.append( "Wireframe" );
3504 modes.append( "Shading" );
3505 modes.append( "Nodes" );
3506 modes.append( "Shrink" );
3507 QList<QVariant> indices;
3508 indices.append( 0 );
3509 indices.append( 1 );
3510 indices.append( 2 );
3511 indices.append( 3 );
3512 setPreferenceProperty( dispmode, "strings", modes );
3513 setPreferenceProperty( dispmode, "indexes", indices );
3515 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3516 setPreferenceProperty( arcgroup, "columns", 2 );
3517 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3518 QStringList quadraticModes;
3519 quadraticModes.append("Lines");
3520 quadraticModes.append("Arcs");
3522 indices.append( 0 );
3523 indices.append( 1 );
3524 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3525 setPreferenceProperty( quadraticmode, "indexes", indices );
3527 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3528 "SMESH", "max_angle" );
3529 setPreferenceProperty( maxAngle, "min", 1 );
3530 setPreferenceProperty( maxAngle, "max", 90 );
3534 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3535 setPreferenceProperty( exportgroup, "columns", 2 );
3536 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3537 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3539 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3540 setPreferenceProperty( computeGroup, "columns", 2 );
3541 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3543 modes.append( "Never" );
3544 modes.append( "Errors only" );
3545 modes.append( "Always" );
3547 indices.append( 0 );
3548 indices.append( 1 );
3549 indices.append( 2 );
3550 setPreferenceProperty( notifyMode, "strings", modes );
3551 setPreferenceProperty( notifyMode, "indexes", indices );
3553 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3554 setPreferenceProperty( segGroup, "columns", 2 );
3555 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3556 "SMESH", "segmentation" );
3557 setPreferenceProperty( segLen, "min", 1 );
3558 setPreferenceProperty( segLen, "max", 10000000 );
3559 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3560 "SMESH", "nb_segments_per_edge" );
3561 setPreferenceProperty( nbSeg, "min", 1 );
3562 setPreferenceProperty( nbSeg, "max", 10000000 );
3564 // Mesh tab ------------------------------------------------------------------------
3565 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3566 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3567 setPreferenceProperty( nodeGroup, "columns", 2 );
3569 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3570 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3572 setPreferenceProperty( nodeSz, "min", 1 );
3573 setPreferenceProperty( nodeSz, "max", 5 );
3575 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3576 setPreferenceProperty( elemGroup, "columns", 2 );
3578 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3579 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3580 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3581 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3583 setPreferenceProperty( sp, "hstretch", 0 );
3584 setPreferenceProperty( sp, "vstretch", 0 );
3586 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3587 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3589 setPreferenceProperty( elemW, "min", 1 );
3590 setPreferenceProperty( elemW, "max", 5 );
3592 setPreferenceProperty( shrink, "min", 0 );
3593 setPreferenceProperty( shrink, "max", 100 );
3595 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3596 setPreferenceProperty( orientGroup, "columns", 1 );
3598 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3599 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3601 setPreferenceProperty( orientScale, "min", 0.05 );
3602 setPreferenceProperty( orientScale, "max", 0.5 );
3603 setPreferenceProperty( orientScale, "step", 0.05 );
3605 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3607 // Selection tab ------------------------------------------------------------------------
3608 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3610 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3611 setPreferenceProperty( selGroup, "columns", 2 );
3613 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3614 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3615 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3617 setPreferenceProperty( selW, "min", 1 );
3618 setPreferenceProperty( selW, "max", 5 );
3620 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3621 setPreferenceProperty( preGroup, "columns", 2 );
3623 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3624 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3626 setPreferenceProperty( preW, "min", 1 );
3627 setPreferenceProperty( preW, "max", 5 );
3629 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3630 setPreferenceProperty( precSelGroup, "columns", 2 );
3632 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3633 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3634 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3636 // Scalar Bar tab ------------------------------------------------------------------------
3637 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3638 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3639 setPreferenceProperty( fontGr, "columns", 2 );
3641 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3642 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3644 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3645 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3647 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3648 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3650 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3651 setPreferenceProperty( numcol, "min", 2 );
3652 setPreferenceProperty( numcol, "max", 256 );
3654 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3655 setPreferenceProperty( numlab, "min", 2 );
3656 setPreferenceProperty( numlab, "max", 65 );
3658 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3659 setPreferenceProperty( orientGr, "columns", 2 );
3660 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3661 QStringList orients;
3662 orients.append( tr( "SMESH_VERTICAL" ) );
3663 orients.append( tr( "SMESH_HORIZONTAL" ) );
3664 indices.clear(); indices.append( 0 ); indices.append( 1 );
3665 setPreferenceProperty( orient, "strings", orients );
3666 setPreferenceProperty( orient, "indexes", indices );
3668 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3669 setPreferenceProperty( posVSizeGr, "columns", 2 );
3670 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3671 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3672 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3673 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3674 setPreferenceProperty( xv, "step", 0.1 );
3675 setPreferenceProperty( xv, "min", 0.0 );
3676 setPreferenceProperty( xv, "max", 1.0 );
3677 setPreferenceProperty( yv, "step", 0.1 );
3678 setPreferenceProperty( yv, "min", 0.0 );
3679 setPreferenceProperty( yv, "max", 1.0 );
3680 setPreferenceProperty( wv, "step", 0.1 );
3681 setPreferenceProperty( wv, "min", 0.0 );
3682 setPreferenceProperty( wv, "max", 1.0 );
3683 setPreferenceProperty( hv, "min", 0.0 );
3684 setPreferenceProperty( hv, "max", 1.0 );
3685 setPreferenceProperty( hv, "step", 0.1 );
3687 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3688 setPreferenceProperty( posHSizeGr, "columns", 2 );
3689 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3690 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3691 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3692 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3693 setPreferenceProperty( xv, "min", 0.0 );
3694 setPreferenceProperty( xv, "max", 1.0 );
3695 setPreferenceProperty( xv, "step", 0.1 );
3696 setPreferenceProperty( xh, "min", 0.0 );
3697 setPreferenceProperty( xh, "max", 1.0 );
3698 setPreferenceProperty( xh, "step", 0.1 );
3699 setPreferenceProperty( yh, "min", 0.0 );
3700 setPreferenceProperty( yh, "max", 1.0 );
3701 setPreferenceProperty( yh, "step", 0.1 );
3702 setPreferenceProperty( wh, "min", 0.0 );
3703 setPreferenceProperty( wh, "max", 1.0 );
3704 setPreferenceProperty( wh, "step", 0.1 );
3705 setPreferenceProperty( hh, "min", 0.0 );
3706 setPreferenceProperty( hh, "max", 1.0 );
3707 setPreferenceProperty( hh, "step", 0.1 );
3710 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3712 if( sect=="SMESH" ) {
3713 float sbX1,sbY1,sbW,sbH;
3714 float aTol = 1.00000009999999;
3715 std::string aWarning;
3716 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3717 if( name=="selection_object_color" || name=="selection_element_color" ||
3718 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3719 name=="selection_precision_node" || name=="selection_precision_element" ||
3720 name=="selection_precision_object")
3721 SMESH::UpdateSelectionProp( this );
3722 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3723 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3724 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3725 if(sbX1+sbW > aTol){
3726 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3729 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3730 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3733 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3734 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3735 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3736 if(sbY1+sbH > aTol){
3737 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3738 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3739 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3742 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3743 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3744 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3745 if(sbX1+sbW > aTol){
3746 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3749 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3750 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3753 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3754 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3755 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3756 if(sbY1+sbH > aTol){
3757 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3760 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3761 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3764 else if ( name == "segmentation" ) {
3765 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
3766 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
3768 else if ( name == "nb_segments_per_edge" ) {
3769 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
3770 myComponentSMESH->SetDefaultNbSegments( nbSeg );
3773 if(aWarning.size() != 0){
3774 aWarning += "The default values are applied instead.";
3775 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3776 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3777 QObject::tr(aWarning.c_str()));
3782 //================================================================================
3784 * \brief Update something in accordance with update flags
3785 * \param theFlags - update flags
3787 * Update viewer or/and object browser etc. in accordance with update flags ( see
3788 * LightApp_UpdateFlags enumeration ).
3790 //================================================================================
3791 void SMESHGUI::update( const int flags )
3793 if ( flags & UF_Viewer | flags & UF_Forced )
3794 SMESH::UpdateView();
3796 SalomeApp_Module::update( flags );
3799 //================================================================================
3801 * \brief Set default selection mode
3803 * SLOT called when operation commited. Sets default selection mode
3805 //================================================================================
3806 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3808 SVTK_ViewWindow* vtkWnd =
3809 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3811 vtkWnd->SetSelectionMode( ActorSelection );
3814 //================================================================================
3816 * \brief Set default selection mode
3818 * SLOT called when operation aborted. Sets default selection mode
3820 //================================================================================
3821 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3823 SVTK_ViewWindow* vtkWnd =
3824 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3826 vtkWnd->SetSelectionMode( ActorSelection );
3829 //================================================================================
3831 * \brief Creates operation with given identifier
3832 * \param id - identifier of operation to be started
3833 * \return Pointer on created operation or NULL if operation is not created
3835 * Virtual method redefined from the base class creates operation with given id.
3836 * It is called called automatically from startOperation method of base class.
3838 //================================================================================
3839 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3841 LightApp_Operation* op = 0;
3842 // to do : create operation here
3845 case 701: // Compute mesh
3846 op = new SMESHGUI_ComputeOp();
3848 case 702: // Create mesh
3849 op = new SMESHGUI_MeshOp( true, true );
3851 case 703: // Create sub-mesh
3852 op = new SMESHGUI_MeshOp( true, false );
3854 case 704: // Edit mesh/sub-mesh
3855 op = new SMESHGUI_MeshOp( false );
3857 case 711: // Precompute mesh
3858 op = new SMESHGUI_PrecomputeOp();
3860 case 806: // Create group on geom
3861 op = new SMESHGUI_GroupOnShapeOp();
3863 case 417: //convert to quadratic
3864 op = new SMESHGUI_ConvToQuadOp();
3866 case 4067: // make mesh pass through point
3867 op = new SMESHGUI_MakeNodeAtPointOp();
3874 op = SalomeApp_Module::createOperation( id );
3878 //================================================================================
3880 * \brief Stops current operations and starts a given one
3881 * \param id - The id of the operation to start
3883 //================================================================================
3885 void SMESHGUI::switchToOperation(int id)
3887 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3888 activeStudy()->abortAllOperations();
3889 startOperation( id );
3892 LightApp_Displayer* SMESHGUI::displayer()
3895 myDisplayer = new SMESHGUI_Displayer( getApp() );
3899 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3902 int aTolerance = 64;
3903 int anIterations = 0;
3909 if( anIterations % aPeriod == 0 )
3912 if( aTolerance < 1 )
3915 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3917 aHue = (int)( 360.0 * rand() / RAND_MAX );
3918 //cout << "Hue = " << aHue << endl;
3920 //cout << "Auto colors : ";
3922 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3923 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3924 for( ; it != itEnd; ++it )
3926 SALOMEDS::Color anAutoColor = *it;
3927 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3930 aQColor.getHsv( &h, &s, &v );
3932 if( abs( h - aHue ) < aTolerance )
3935 //cout << "break (diff = " << abs( h - aHue ) << ")";
3945 //cout << "Hue of the returned color = " << aHue << endl;
3947 aColor.setHsv( aHue, 255, 255 );
3949 SALOMEDS::Color aSColor;
3950 aSColor.R = (double)aColor.red() / 255.0;
3951 aSColor.G = (double)aColor.green() / 255.0;
3952 aSColor.B = (double)aColor.blue() / 255.0;
3957 const char gSeparator = '_'; // character used to separate parameter names
3958 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
3961 * \brief Store visual parameters
3963 * This method is called just before the study document is saved.
3964 * Store visual parameters in AttributeParameter attribue(s)
3966 void SMESHGUI::storeVisualParameters (int savePoint)
3968 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3969 if (!appStudy || !appStudy->studyDS())
3971 _PTR(Study) studyDS = appStudy->studyDS();
3973 // componentName is used for encoding of entries when storing them in IParameters
3974 std::string componentName = myComponentSMESH->ComponentDataType();
3975 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
3976 //if (!aSComponent) return;
3979 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3980 componentName.c_str(),
3982 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3984 // viewers counters are used for storing view_numbers in IParameters
3987 // main cycle to store parameters of displayed objects
3988 QList<SUIT_ViewManager*> lst;
3989 QList<SUIT_ViewManager*>::Iterator it;
3990 getApp()->viewManagers(lst);
3991 for (it = lst.begin(); it != lst.end(); it++)
3993 SUIT_ViewManager* vman = *it;
3994 QString vType = vman->getType();
3996 // saving VTK actors properties
3997 if (vType == SVTK_Viewer::Type())
3999 QVector<SUIT_ViewWindow*> views = vman->getViews();
4000 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4002 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4004 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
4005 allActors->InitTraversal();
4006 while (vtkActor* actor = allActors->GetNextActor())
4008 if (actor->GetVisibility()) // store only visible actors
4010 SMESH_Actor* aSmeshActor = 0;
4011 if (actor->IsA("SMESH_Actor"))
4012 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4013 if (aSmeshActor && aSmeshActor->hasIO())
4015 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4018 // entry is "encoded" = it does NOT contain component adress,
4019 // since it is a subject to change on next component loading
4020 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4022 std::string param, vtkParam = vType.toLatin1().data();
4023 vtkParam += gSeparator;
4024 vtkParam += QString::number(vtkViewers).toLatin1().data();
4025 vtkParam += gSeparator;
4028 param = vtkParam + "Visibility";
4029 ip->setParameter(entry, param, "On");
4032 param = vtkParam + "Representation";
4033 ip->setParameter(entry, param, QString::number
4034 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4037 param = vtkParam + "IsShrunk";
4038 ip->setParameter(entry, param, QString::number
4039 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4041 // Displayed entities
4042 unsigned int aMode = aSmeshActor->GetEntityMode();
4043 bool isE = aMode & SMESH_Actor::eEdges;
4044 bool isF = aMode & SMESH_Actor::eFaces;
4045 bool isV = aMode & SMESH_Actor::eVolumes;
4047 QString modeStr ("e");
4048 modeStr += gDigitsSep; modeStr += QString::number(isE);
4049 modeStr += gDigitsSep; modeStr += "f";
4050 modeStr += gDigitsSep; modeStr += QString::number(isF);
4051 modeStr += gDigitsSep; modeStr += "v";
4052 modeStr += gDigitsSep; modeStr += QString::number(isV);
4054 param = vtkParam + "Entities";
4055 ip->setParameter(entry, param, modeStr.toLatin1().data());
4057 // Colors (surface:edge:)
4058 vtkFloatingPointType r, g, b;
4060 aSmeshActor->GetSufaceColor(r, g, b);
4061 QString colorStr ("surface");
4062 colorStr += gDigitsSep; colorStr += QString::number(r);
4063 colorStr += gDigitsSep; colorStr += QString::number(g);
4064 colorStr += gDigitsSep; colorStr += QString::number(b);
4066 aSmeshActor->GetBackSufaceColor(r, g, b);
4067 colorStr += gDigitsSep; colorStr += "backsurface";
4068 colorStr += gDigitsSep; colorStr += QString::number(r);
4069 colorStr += gDigitsSep; colorStr += QString::number(g);
4070 colorStr += gDigitsSep; colorStr += QString::number(b);
4072 aSmeshActor->GetEdgeColor(r, g, b);
4073 colorStr += gDigitsSep; colorStr += "edge";
4074 colorStr += gDigitsSep; colorStr += QString::number(r);
4075 colorStr += gDigitsSep; colorStr += QString::number(g);
4076 colorStr += gDigitsSep; colorStr += QString::number(b);
4078 aSmeshActor->GetNodeColor(r, g, b);
4079 colorStr += gDigitsSep; colorStr += "node";
4080 colorStr += gDigitsSep; colorStr += QString::number(r);
4081 colorStr += gDigitsSep; colorStr += QString::number(g);
4082 colorStr += gDigitsSep; colorStr += QString::number(b);
4084 param = vtkParam + "Colors";
4085 ip->setParameter(entry, param, colorStr.toLatin1().data());
4087 // Sizes of lines and points
4088 QString sizeStr ("line");
4089 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4090 sizeStr += gDigitsSep; sizeStr += "node";
4091 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4092 sizeStr += gDigitsSep; sizeStr += "shrink";
4093 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4095 param = vtkParam + "Sizes";
4096 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4099 param = vtkParam + "Opacity";
4100 ip->setParameter(entry, param,
4101 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4104 param = vtkParam + "ClippingPlane";
4105 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4107 ip->setParameter(entry, param, "Off");
4108 for (int ipl = 0; ipl < nPlanes; ipl++) {
4109 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4110 SMESH::Orientation anOrientation;
4112 vtkFloatingPointType anAngle[2];
4113 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4114 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4115 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4116 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4117 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4119 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4121 } // if (io->hasEntry())
4122 } // SMESH_Actor && hasIO
4124 } // while.. actors traversal
4128 } // if (SVTK view model)
4129 } // for (viewManagers)
4133 * \brief Restore visual parameters
4135 * This method is called after the study document is opened.
4136 * Restore visual parameters from AttributeParameter attribue(s)
4138 void SMESHGUI::restoreVisualParameters (int savePoint)
4140 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4141 if (!appStudy || !appStudy->studyDS())
4143 _PTR(Study) studyDS = appStudy->studyDS();
4145 // componentName is used for encoding of entries when storing them in IParameters
4146 std::string componentName = myComponentSMESH->ComponentDataType();
4147 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4148 //if (!aSComponent) return;
4151 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4152 componentName.c_str(),
4154 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4156 std::vector<std::string> entries = ip->getEntries();
4158 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4160 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4161 QString entry (ip->decodeEntry(*entIt).c_str());
4163 // Check that the entry corresponds to a real object in the Study
4164 // as the object may be deleted or modified after the visual state is saved.
4165 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4166 if (!so) continue; //Skip the not existent entry
4168 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4169 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4171 std::vector<std::string>::iterator namesIt = paramNames.begin();
4172 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4174 // actors are stored in a map after displaying of them for
4175 // quicker access in the future: map < viewID to actor >
4176 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4178 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4180 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4181 // '_' is used as separator and should not be used in viewer type or parameter names.
4182 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4183 if (lst.size() != 3)
4186 QString viewerTypStr = lst[0];
4187 QString viewIndexStr = lst[1];
4188 QString paramNameStr = lst[2];
4191 int viewIndex = viewIndexStr.toUInt(&ok);
4192 if (!ok) // bad conversion of view index to integer
4196 if (viewerTypStr == SVTK_Viewer::Type())
4198 SMESH_Actor* aSmeshActor = 0;
4199 if (vtkActors.IsBound(viewIndex))
4200 aSmeshActor = vtkActors.Find(viewIndex);
4202 if (paramNameStr == "Visibility")
4204 if (!aSmeshActor && displayer())
4206 QList<SUIT_ViewManager*> lst;
4207 getApp()->viewManagers(viewerTypStr, lst);
4209 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4210 if (viewIndex >= 0 && viewIndex < lst.count()) {
4211 SUIT_ViewManager* vman = lst.at(viewIndex);
4212 SUIT_ViewModel* vmodel = vman->getViewModel();
4213 // SVTK view model can be casted to SALOME_View
4214 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4216 // store displayed actor in a temporary map for quicker
4217 // access later when restoring other parameters
4218 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4219 vtkRenderer* Renderer = vtkView->getRenderer();
4220 vtkActorCollection* theActors = Renderer->GetActors();
4221 theActors->InitTraversal();
4222 bool isFound = false;
4223 vtkActor *ac = theActors->GetNextActor();
4224 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4225 if (ac->IsA("SMESH_Actor")) {
4226 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4227 if (aGeomAc->hasIO()) {
4228 Handle(SALOME_InteractiveObject) io =
4229 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4230 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4232 vtkActors.Bind(viewIndex, aGeomAc);
4239 } // if (paramNameStr == "Visibility")
4242 // the rest properties "work" with SMESH_Actor
4245 QString val ((*valuesIt).c_str());
4248 if (paramNameStr == "Representation") {
4249 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4252 else if (paramNameStr == "IsShrunk") {
4254 if (!aSmeshActor->IsShrunk())
4255 aSmeshActor->SetShrink();
4258 if (aSmeshActor->IsShrunk())
4259 aSmeshActor->UnShrink();
4262 // Displayed entities
4263 else if (paramNameStr == "Entities") {
4264 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4265 if (mode.count() == 6) {
4266 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4267 MESSAGE("Invalid order of data in Entities, must be: "
4268 "e:0/1:f:0/1:v:0/1");
4271 unsigned int aMode = aSmeshActor->GetEntityMode();
4272 unsigned int aNewMode =
4273 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4274 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4275 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4276 if (aNewMode != aMode)
4277 aSmeshActor->SetEntityMode(aNewMode);
4282 else if (paramNameStr == "Colors") {
4283 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4284 if (colors.count() == 16) {
4285 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4286 colors[8] != "edge" || colors[12] != "node") {
4287 MESSAGE("Invalid order of data in Colors, must be: "
4288 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4291 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4292 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4293 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4294 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4298 // Sizes of lines and points
4299 else if (paramNameStr == "Sizes") {
4300 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4301 if (sizes.count() == 6) {
4302 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4303 MESSAGE("Invalid order of data in Sizes, must be: "
4304 "line:int:node:int:shrink:float");
4307 aSmeshActor->SetLineWidth(sizes[1].toInt());
4308 aSmeshActor->SetNodeSize(sizes[3].toInt());
4309 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4314 else if (paramNameStr == "Opacity") {
4315 aSmeshActor->SetOpacity(val.toFloat());
4318 else if (paramNameStr.startsWith("ClippingPlane")) {
4319 cout << "$$$ ClippingPlane 1" << endl;
4320 if (paramNameStr == "ClippingPlane1" || val == "Off")
4321 aSmeshActor->RemoveAllClippingPlanes();
4323 cout << "$$$ ClippingPlane 2" << endl;
4324 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4325 if (vals.count() == 4) { // format check: 4 values
4326 cout << "$$$ ClippingPlane 3" << endl;
4327 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4328 double aDistance = vals[1].toFloat();
4329 vtkFloatingPointType anAngle[2];
4330 anAngle[0] = vals[2].toFloat();
4331 anAngle[1] = vals[3].toFloat();
4333 QList<SUIT_ViewManager*> lst;
4334 getApp()->viewManagers(viewerTypStr, lst);
4335 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4336 if (viewIndex >= 0 && viewIndex < lst.count()) {
4337 SUIT_ViewManager* vman = lst.at(viewIndex);
4338 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4339 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4340 anOrientation, aDistance, anAngle);
4345 } // if (aSmeshActor)
4346 } // other parameters than Visibility
4348 } // for names/parameters iterator
4349 } // for entries iterator
4351 // update all VTK views
4352 QList<SUIT_ViewManager*> lst;
4353 getApp()->viewManagers(lst);
4354 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4355 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4356 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4357 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4358 vtkView->getRenderer()->ResetCameraClippingRange();
4365 \brief Adds preferences for dfont of VTK viewer
4367 \param pIf group identifier
4368 \param param parameter
4369 \return identifier of preferences
4371 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4373 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4375 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4378 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4379 fam.append( tr( "SMESH_FONT_COURIER" ) );
4380 fam.append( tr( "SMESH_FONT_TIMES" ) );
4382 setPreferenceProperty( tfont, "fonts", fam );
4384 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4385 setPreferenceProperty( tfont, "features", f );