1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_AddMeshElementDlg.h"
29 #include "SMESHGUI_AddQuadraticElementDlg.h"
30 #include "SMESHGUI_BuildCompoundDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_ComputeDlg.h"
33 #include "SMESHGUI_ConvToQuadOp.h"
34 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
35 #include "SMESHGUI_DeleteGroupDlg.h"
36 #include "SMESHGUI_Displayer.h"
37 #include "SMESHGUI_EditMeshDlg.h"
38 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
39 #include "SMESHGUI_ExtrusionDlg.h"
40 #include "SMESHGUI_FileInfoDlg.h"
41 #include "SMESHGUI_FileValidator.h"
42 #include "SMESHGUI_FilterDlg.h"
43 #include "SMESHGUI_FilterLibraryDlg.h"
44 #include "SMESHGUI_FindElemByPointDlg.h"
45 #include "SMESHGUI_GroupDlg.h"
46 #include "SMESHGUI_GroupOnShapeDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_Hypotheses.h"
49 #include "SMESHGUI_Make2DFrom3DOp.h"
50 #include "SMESHGUI_MakeNodeAtPointDlg.h"
51 #include "SMESHGUI_MeshInfosDlg.h"
52 #include "SMESHGUI_MeshOp.h"
53 #include "SMESHGUI_MeshOrderOp.h"
54 #include "SMESHGUI_MeshPatternDlg.h"
55 #include "SMESHGUI_MoveNodesDlg.h"
56 #include "SMESHGUI_MultiEditDlg.h"
57 #include "SMESHGUI_NodesDlg.h"
58 #include "SMESHGUI_Preferences_ColorDlg.h"
59 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
60 #include "SMESHGUI_RemoveElementsDlg.h"
61 #include "SMESHGUI_RemoveNodesDlg.h"
62 #include "SMESHGUI_RenumberingDlg.h"
63 #include "SMESHGUI_RevolutionDlg.h"
64 #include "SMESHGUI_RotationDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_SewingDlg.h"
67 #include "SMESHGUI_SingleEditDlg.h"
68 #include "SMESHGUI_SmoothingDlg.h"
69 #include "SMESHGUI_StandardMeshInfosDlg.h"
70 #include "SMESHGUI_SymmetryDlg.h"
71 #include "SMESHGUI_TranslationDlg.h"
72 #include "SMESHGUI_ScaleDlg.h"
73 #include "SMESHGUI_TransparencyDlg.h"
74 #include "SMESHGUI_WhatIsDlg.h"
76 #include "SMESHGUI_Utils.h"
77 #include "SMESHGUI_MeshUtils.h"
78 #include "SMESHGUI_GroupUtils.h"
79 #include "SMESHGUI_FilterUtils.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_VTKUtils.h"
82 #include "SMESHGUI_HypothesesUtils.h"
84 #include <SMESH_Client.hxx>
85 #include <SMESH_Actor.h>
86 #include <SMESH_TypeFilter.hxx>
88 // SALOME GUI includes
89 #include <SalomeApp_Tools.h>
90 #include <SalomeApp_Study.h>
91 #include <SalomeApp_Application.h>
92 #include <SalomeApp_CheckFileDlg.h>
94 #include <LightApp_DataOwner.h>
95 #include <LightApp_Preferences.h>
96 #include <LightApp_SelectionMgr.h>
97 #include <LightApp_UpdateFlags.h>
98 #include <LightApp_NameDlg.h>
100 #include <SVTK_ViewWindow.h>
101 #include <SVTK_ViewModel.h>
102 #include <SVTK_ViewManager.h>
104 #include <VTKViewer_Algorithm.h>
106 #include <SUIT_MessageBox.h>
107 #include <SUIT_ResourceMgr.h>
108 #include <SUIT_FileDlg.h>
109 #include <SUIT_Desktop.h>
110 #include <SUIT_OverrideCursor.h>
111 #include <SUIT_Session.h>
113 #include <QtxPopupMgr.h>
114 #include <QtxFontEdit.h>
116 #include <SALOME_ListIO.hxx>
117 #include <SALOME_ListIteratorOfListIO.hxx>
120 #include <SALOMEconfig.h>
121 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
122 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
125 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
129 #include <boost/shared_ptr.hpp>
132 #include <vtkScalarBarActor.h>
133 #include <vtkCamera.h>
134 #include <vtkRenderer.h>
135 #include <vtkPlane.h>
137 // SALOME KERNEL includes
138 #include <SALOMEDS_Study.hxx>
139 #include <SALOMEDSClient_StudyBuilder.hxx>
140 #include <SALOMEDSClient_SComponent.hxx>
141 #include <SALOMEDSClient_ClientFactory.hxx>
142 #include <SALOMEDSClient_IParameters.hxx>
145 #include <Standard_ErrorHandler.hxx>
146 #include <NCollection_DataMap.hxx>
150 //=============================================================
151 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154 void ExportMeshToFile(int theCommandID);
156 void SetDisplayMode(int theCommandID);
158 void SetDisplayEntity(int theCommandID);
160 void Control( int theCommandID );
164 //=============================================================
165 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
169 std::string myExtension;
171 if ( theCommandID == 113 ) {
172 filter.append( QObject::tr( "MED files (*.med)" ) );
173 filter.append( QObject::tr( "All files (*)" ) );
175 else if ( theCommandID == 112 ) {
176 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
178 else if ( theCommandID == 111 ) {
179 filter.append( QObject::tr( "DAT files (*.dat)" ) );
182 QString anInitialPath = "";
183 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
184 anInitialPath = QDir::currentPath();
186 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
189 QObject::tr( "SMESH_IMPORT_MESH" ) );
190 if ( filenames.count() > 0 ) {
191 SUIT_OverrideCursor wc;
192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
195 bool isEmpty = false;
196 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
197 QString filename = *it;
198 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
200 switch ( theCommandID ) {
203 // DAT format (currently unsupported)
204 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
205 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
211 aMeshes->length( 1 );
212 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
213 if ( aMeshes[0]->_is_nil() )
214 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
215 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
221 SMESH::DriverMED_ReadStatus res;
222 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
223 if ( res != SMESH::DRS_OK ) {
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
231 catch ( const SALOME::SALOME_Exception& S_ex ) {
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
236 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
237 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
239 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
240 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
241 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
242 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
243 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
251 // update Object browser
252 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
254 // show Error message box if there were errors
255 if ( errors.count() > 0 ) {
256 SUIT_MessageBox::critical( SMESHGUI::desktop(),
257 QObject::tr( "SMESH_ERROR" ),
258 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
261 // show warning message box, if some imported mesh is empty
263 SUIT_MessageBox::warning( SMESHGUI::desktop(),
264 QObject::tr( "SMESH_WRN_WARNING" ),
265 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
270 void ExportMeshToFile( int theCommandID )
272 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
273 SALOME_ListIO selected;
275 aSel->selectedObjects( selected );
277 // actually, the following condition can't be met (added for insurance)
278 if( selected.Extent() == 0 ||
279 selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 )
282 bool hasDuplicatedMeshNames = false;
283 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
284 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
285 SALOME_ListIteratorOfListIO It( selected );
286 for( ; It.More(); It.Next() ) {
287 Handle(SALOME_InteractiveObject) anIObject = It.Value();
288 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
289 if ( aMeshItem->_is_nil() ) {
290 SUIT_MessageBox::warning( SMESHGUI::desktop(),
291 QObject::tr( "SMESH_WRN_WARNING" ),
292 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
296 QString aMeshName = anIObject->getName();
298 // check for duplications
299 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
300 if( aMeshName == (*aMeshIter).second ) {
301 hasDuplicatedMeshNames = true;
306 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
309 if( hasDuplicatedMeshNames ) {
310 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
311 QObject::tr("SMESH_WRN_WARNING"),
312 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
313 QObject::tr("SMESH_BUT_YES"),
314 QObject::tr("SMESH_BUT_NO"), 0, 1);
319 aMeshIter = aMeshList.begin();
320 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
321 QString aMeshName = (*aMeshIter).second;
323 QList<SALOMEDS::Color> aReservedColors;
325 QString aFilter, aTitle = QObject::tr("Export mesh");
326 QMap<QString, SMESH::MED_VERSION> aFilterMap;
327 QMap<QString, int> aFilterMapSTL;
328 switch ( theCommandID ) {
332 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
333 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
334 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
335 int aRet = SUIT_MessageBox::warning
336 (SMESHGUI::desktop(),
337 QObject::tr("SMESH_WRN_WARNING"),
338 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
339 QObject::tr("SMESH_BUT_YES"),
340 QObject::tr("SMESH_BUT_NO"), 0, 1);
346 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
347 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
348 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
349 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
354 aFilter = QObject::tr("DAT files (*.dat)");
359 if (aMesh->NbPyramids()) {
360 int aRet = SUIT_MessageBox::warning
361 (SMESHGUI::desktop(),
362 QObject::tr("SMESH_WRN_WARNING"),
363 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
364 QObject::tr("SMESH_BUT_YES"),
365 QObject::tr("SMESH_BUT_NO"), 0, 1);
369 aFilter = QObject::tr("IDEAS files (*.unv)");
377 there must be check on others mesh elements not equal triangles
379 if (aMesh->NbTriangles() < 1) {
380 SUIT_MessageBox::warning
381 (SMESHGUI::desktop(),
382 QObject::tr("SMESH_WRN_WARNING"),
383 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
386 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
387 int aRet = SUIT_MessageBox::warning
388 (SMESHGUI::desktop(),
389 QObject::tr("SMESH_WRN_WARNING"),
390 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
391 QObject::tr("SMESH_BUT_YES"),
392 QObject::tr("SMESH_BUT_NO"), 0, 1);
397 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
398 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
406 SMESH::MED_VERSION aFormat;
407 // Init the parameter with the default value
408 bool aIsASCII_STL = true;
409 bool toCreateGroups = false;
410 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
412 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
413 bool toOverwrite = true;
415 QString anInitialPath = "";
416 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
417 anInitialPath = QDir::currentPath();
419 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
420 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
421 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
422 aFilter, aTitle, false);
424 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
426 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
427 for ( ; it != aFilterMapSTL.end(); ++it )
428 filters.push_back( it.key() );
430 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
431 fd->setWindowTitle( aTitle );
432 fd->setNameFilters( filters );
433 fd->selectNameFilter( QObject::tr("STL ASCII (*.stl)") );
434 if ( !anInitialPath.isEmpty() )
435 fd->setDirectory( anInitialPath );
436 fd->selectFile(aMeshName);
440 aFilename = fd->selectedFile();
441 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
446 else { // Export to MED
448 QString aDefaultFilter;
449 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
450 for ( ; it != aFilterMap.end(); ++it ) {
451 filters.push_back( it.key() );
452 if (it.value() == SMESH::MED_V2_2)
453 aDefaultFilter = it.key();
456 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
457 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
458 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
459 fd->setWindowTitle( aTitle );
460 fd->setNameFilters( filters );
461 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
462 fd->selectNameFilter(aDefaultFilter);
463 fd->SetChecked(toCreateGroups);
464 if ( !anInitialPath.isEmpty() )
465 fd->setDirectory( anInitialPath );
466 fd->selectFile(aMeshName);
468 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
469 fd->setValidator( fv );
474 aFilename = fd->selectedFile();
476 aFilename = QString::null;
479 aFormat = aFilterMap[fd->selectedNameFilter()];
480 toOverwrite = fv->isOverwrite();
482 if ( !aFilename.isEmpty() ) {
483 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
484 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
485 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
486 && aFormat==SMESH::MED_V2_1) {
487 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
488 QObject::tr("SMESH_WRN_WARNING"),
489 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
490 QObject::tr("SMESH_BUT_YES"),
491 QObject::tr("SMESH_BUT_NO"), 0, 1);
499 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
500 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
501 if( !isVersionOk || aVersion != aFormat ) {
502 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
503 QObject::tr("SMESH_WRN_WARNING"),
504 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
505 QObject::tr("SMESH_BUT_YES"),
506 QObject::tr("SMESH_BUT_NO"), 0, 1);
513 QStringList aMeshNamesCollisionList;
514 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
515 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
516 QString anExistingMeshName( aMeshNames[ i ] );
517 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
518 QString anExportMeshName = (*aMeshIter).second;
519 if( anExportMeshName == anExistingMeshName ) {
520 aMeshNamesCollisionList.append( anExportMeshName );
526 if( !aMeshNamesCollisionList.isEmpty() ) {
527 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
528 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
529 QObject::tr("SMESH_WRN_WARNING"),
530 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
531 QObject::tr("SMESH_BUT_YES"),
532 QObject::tr("SMESH_BUT_NO"),
533 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
542 toCreateGroups = fd->IsChecked();
545 if ( !aFilename.isEmpty() ) {
546 // Check whether the file already exists and delete it if yes
547 QFile aFile( aFilename );
548 if ( aFile.exists() && toOverwrite )
550 SUIT_OverrideCursor wc;
553 bool Renumber = false;
554 // PAL 14172 : Check of we have to renumber or not from the preferences before export
556 Renumber= resMgr->booleanValue("SMESH","renumbering");
558 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
559 aMeshEditor->RenumberNodes();
560 aMeshEditor->RenumberElements();
561 if ( SMESHGUI::automaticUpdate() )
564 switch ( theCommandID ) {
568 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
569 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
570 if( !aMeshItem->_is_nil() )
571 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
577 aMesh->ExportDAT( aFilename.toLatin1().data() );
581 aMesh->ExportUNV( aFilename.toLatin1().data() );
585 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
591 catch (const SALOME::SALOME_Exception& S_ex){
593 SUIT_MessageBox::warning(SMESHGUI::desktop(),
594 QObject::tr("SMESH_WRN_WARNING"),
595 QObject::tr("SMESH_EXPORT_FAILED"));
601 inline void InverseEntityMode(unsigned int& theOutputMode,
602 unsigned int theMode)
604 bool anIsNotPresent = ~theOutputMode & theMode;
606 theOutputMode |= theMode;
608 theOutputMode &= ~theMode;
611 void SetDisplayEntity(int theCommandID){
612 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
613 SALOME_ListIO selected;
615 aSel->selectedObjects( selected );
617 if(selected.Extent() >= 1){
618 SALOME_ListIteratorOfListIO It( selected );
619 for( ; It.More(); It.Next()){
620 Handle(SALOME_InteractiveObject) IObject = It.Value();
621 if(IObject->hasEntry()){
622 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
623 unsigned int aMode = anActor->GetEntityMode();
624 switch(theCommandID){
626 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
629 InverseEntityMode(aMode,SMESH_Actor::eEdges);
632 InverseEntityMode(aMode,SMESH_Actor::eFaces);
635 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
638 aMode = SMESH_Actor::eAllEntity;
642 anActor->SetEntityMode(aMode);
650 SALOME_ListIO selected;
651 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
655 LightApp_SelectionMgr* aSel = app->selectionMgr();
656 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
657 if( !aSel || !appStudy )
660 aSel->selectedObjects( selected );
661 if( selected.IsEmpty() )
664 Handle(SALOME_InteractiveObject) anIObject = selected.First();
666 _PTR(Study) aStudy = appStudy->studyDS();
667 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
668 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
669 if( aMainObject->_is_nil() )
672 aMainObject->SetAutoColor( true );
674 QList<SALOMEDS::Color> aReservedColors;
676 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
677 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
679 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
680 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
682 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
683 aGroupObject->SetColor( aColor );
684 aReservedColors.append( aColor );
686 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
688 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
689 if( aGroupObject->GetType() == SMESH::NODE )
690 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
691 else if( aGroupObject->GetType() == SMESH::EDGE )
692 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
693 else if( aGroupObject->GetType() == SMESH::ELEM0D )
694 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
696 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
701 SMESH::RepaintCurrentView();
704 void DisableAutoColor(){
705 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
706 SALOME_ListIO selected;
708 aSel->selectedObjects( selected );
710 if(selected.Extent()){
711 Handle(SALOME_InteractiveObject) anIObject = selected.First();
712 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
713 if ( !aMesh->_is_nil() ) {
714 aMesh->SetAutoColor( false );
719 void SetDisplayMode(int theCommandID){
720 SALOME_ListIO selected;
721 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
725 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
726 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
727 if( !aSel || !appStudy )
730 _PTR(Study) aStudy = appStudy->studyDS();
732 aSel->selectedObjects( selected );
734 if(selected.Extent() >= 1){
735 switch(theCommandID){
737 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
738 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
742 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
743 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
746 SALOME_ListIteratorOfListIO It( selected );
747 for( ; It.More(); It.Next()){
748 Handle(SALOME_InteractiveObject) IObject = It.Value();
749 if(IObject->hasEntry()){
750 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
751 switch(theCommandID){
753 anActor->SetRepresentation(SMESH_Actor::eEdge);
756 anActor->SetRepresentation(SMESH_Actor::eSurface);
759 if(anActor->IsShrunk())
762 anActor->SetShrink();
765 anActor->SetRepresentation(SMESH_Actor::ePoint);
768 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
769 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
772 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
773 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
776 vtkFloatingPointType color[3];
777 anActor->GetSufaceColor(color[0], color[1], color[2]);
778 int c0 = int (color[0] * 255);
779 int c1 = int (color[1] * 255);
780 int c2 = int (color[2] * 255);
781 QColor c(c0, c1, c2);
783 vtkFloatingPointType edgecolor[3];
784 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
785 c0 = int (edgecolor[0] * 255);
786 c1 = int (edgecolor[1] * 255);
787 c2 = int (edgecolor[2] * 255);
788 QColor e(c0, c1, c2);
790 vtkFloatingPointType backfacecolor[3];
791 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
792 c0 = int (backfacecolor[0] * 255);
793 c1 = int (backfacecolor[1] * 255);
794 c2 = int (backfacecolor[2] * 255);
795 QColor b(c0, c1, c2);
797 vtkFloatingPointType nodecolor[3];
798 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
799 c0 = int (nodecolor[0] * 255);
800 c1 = int (nodecolor[1] * 255);
801 c2 = int (nodecolor[2] * 255);
802 QColor n(c0, c1, c2);
804 vtkFloatingPointType color0D[3];
805 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
806 c0 = int (color0D[0] * 255);
807 c1 = int (color0D[1] * 255);
808 c2 = int (color0D[2] * 255);
809 QColor c0D(c0, c1, c2);
811 int size0D = (int)anActor->Get0DSize();
814 int Edgewidth = (int)anActor->GetLineWidth();
817 int intValue = int(anActor->GetNodeSize());
818 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
820 vtkFloatingPointType faces_orientation_color[3];
821 anActor->GetFacesOrientationColor(faces_orientation_color);
822 c0 = int (faces_orientation_color[0] * 255);
823 c1 = int (faces_orientation_color[1] * 255);
824 c2 = int (faces_orientation_color[2] * 255);
825 QColor o(c0, c1, c2);
827 vtkFloatingPointType faces_orientation_scale = anActor->GetFacesOrientationScale();
828 bool faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
830 SMESHGUI_Preferences_ColorDlg *aDlg =
831 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
832 aDlg->SetColor(1, c);
833 aDlg->SetColor(2, e);
834 aDlg->SetColor(3, n);
835 aDlg->SetColor(4, b);
836 aDlg->SetColor(5, c0D);
837 aDlg->SetColor(6, o);
838 aDlg->SetIntValue(1, Edgewidth);
839 aDlg->SetIntValue(2, intValue);
840 aDlg->SetIntValue(3, int(Shrink*100.));
841 aDlg->SetIntValue(4, size0D);
842 aDlg->SetDoubleValue(1, faces_orientation_scale);
843 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
845 QColor color = aDlg->GetColor(1);
846 QColor edgecolor = aDlg->GetColor(2);
847 QColor nodecolor = aDlg->GetColor(3);
848 QColor backfacecolor = aDlg->GetColor(4);
849 QColor color0D = aDlg->GetColor(5);
850 QColor faces_orientation_color = aDlg->GetColor(6);
851 /* actor color and backface color */
852 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
853 vtkFloatingPointType (color.green()) / 255.,
854 vtkFloatingPointType (color.blue()) / 255.);
855 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
856 vtkFloatingPointType (backfacecolor.green()) / 255.,
857 vtkFloatingPointType (backfacecolor.blue()) / 255.);
860 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
861 vtkFloatingPointType (edgecolor.green()) / 255.,
862 vtkFloatingPointType (edgecolor.blue()) / 255.);
864 /* Shrink factor and size edges */
865 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
866 anActor->SetLineWidth(aDlg->GetIntValue(1));
868 /* Nodes color and size */
869 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
870 vtkFloatingPointType (nodecolor.green()) / 255.,
871 vtkFloatingPointType (nodecolor.blue()) / 255.);
872 anActor->SetNodeSize(aDlg->GetIntValue(2));
875 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
876 vtkFloatingPointType (color0D.green()) / 255.,
877 vtkFloatingPointType (color0D.blue()) / 255.);
878 anActor->Set0DSize(aDlg->GetIntValue(4));
880 /* Faces orientation */
881 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
882 vtkFloatingPointType(faces_orientation_color.greenF()),
883 vtkFloatingPointType(faces_orientation_color.blueF())};
884 anActor->SetFacesOrientationColor(c);
885 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
886 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
888 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
889 if( !aGroupObject->_is_nil() )
891 SMESH::ElementType anElementType = aGroupObject->GetType();
893 switch( anElementType )
895 case SMESH::NODE: aColor = nodecolor; break;
896 case SMESH::EDGE: aColor = edgecolor; break;
897 default: aColor = color; break;
900 SALOMEDS::Color aGroupColor;
901 aGroupColor.R = (float)aColor.red() / 255.0;
902 aGroupColor.G = (float)aColor.green() / 255.0;
903 aGroupColor.B = (float)aColor.blue() / 255.0;
904 aGroupObject->SetColor( aGroupColor );
914 SMESH::RepaintCurrentView();
918 void Control( int theCommandID )
920 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
921 SALOME_ListIO selected;
923 aSel->selectedObjects( selected );
925 if( !selected.IsEmpty() ){
926 Handle(SALOME_InteractiveObject) anIO = selected.First();
929 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
930 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
931 switch ( theCommandID ){
933 aTitle = QObject::tr( "LENGTH_EDGES" );
934 aControl = SMESH_Actor::eLength;
937 aTitle = QObject::tr( "LENGTH2D_EDGES" );
938 aControl = SMESH_Actor::eLength2D;
941 aTitle = QObject::tr( "FREE_EDGES" );
942 aControl = SMESH_Actor::eFreeEdges;
945 aTitle = QObject::tr( "FREE_BORDERS" );
946 aControl = SMESH_Actor::eFreeBorders;
949 aTitle = QObject::tr( "MULTI_BORDERS" );
950 aControl = SMESH_Actor::eMultiConnection;
953 aTitle = QObject::tr( "FREE_NODES" );
954 aControl = SMESH_Actor::eFreeNodes;
957 aTitle = QObject::tr( "MULTI2D_BORDERS" );
958 aControl = SMESH_Actor::eMultiConnection2D;
961 aTitle = QObject::tr( "AREA_ELEMENTS" );
962 aControl = SMESH_Actor::eArea;
965 aTitle = QObject::tr( "TAPER_ELEMENTS" );
966 aControl = SMESH_Actor::eTaper;
969 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
970 aControl = SMESH_Actor::eAspectRatio;
973 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
974 aControl = SMESH_Actor::eAspectRatio3D;
977 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
978 aControl = SMESH_Actor::eMinimumAngle;
981 aTitle = QObject::tr( "WARP_ELEMENTS" );
982 aControl = SMESH_Actor::eWarping;
985 aTitle = QObject::tr( "SKEW_ELEMENTS" );
986 aControl = SMESH_Actor::eSkew;
989 aTitle = QObject::tr( "SMESH_VOLUME" );
990 aControl = SMESH_Actor::eVolume3D;
993 aTitle = QObject::tr( "FREE_FACES" );
994 aControl = SMESH_Actor::eFreeFaces;
997 anActor->SetControlMode(aControl);
998 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
999 SMESH::RepaintCurrentView();
1006 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1007 MeshObjectType theType,
1008 const QString theInTypeName,
1009 QString & theOutTypeName)
1011 SMESH_TypeFilter aTypeFilter( theType );
1013 if( !theIO.IsNull() )
1015 entry = theIO->getEntry();
1016 LightApp_DataOwner owner( entry );
1017 if ( aTypeFilter.isOk( &owner )) {
1018 theOutTypeName = theInTypeName;
1026 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1028 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1029 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1031 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1032 CORBA::String_var anID = aSComp->GetID().c_str();
1033 if (!strcmp(anID.in(),theIO->getEntry()))
1039 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1040 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1041 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1042 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1043 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1051 QString CheckHomogeneousSelection()
1053 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1054 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1055 SALOME_ListIO selected;
1057 aSel->selectedObjects( selected );
1059 QString RefType = CheckTypeObject(selected.First());
1060 SALOME_ListIteratorOfListIO It(selected);
1061 for ( ; It.More(); It.Next())
1063 Handle(SALOME_InteractiveObject) IObject = It.Value();
1064 QString Type = CheckTypeObject(IObject);
1065 if (Type.compare(RefType) != 0)
1066 return "Heterogeneous Selection";
1073 void SMESHGUI::OnEditDelete()
1075 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1076 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1077 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1079 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1080 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1081 _PTR(GenericAttribute) anAttr;
1082 _PTR(AttributeIOR) anIOR;
1084 int objectCount = 0;
1086 QString aParentComponent = QString::null;
1087 Handle(SALOME_InteractiveObject) anIO;
1088 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1090 anIO = anIt.Value();
1091 QString cur = anIO->getComponentDataType();
1092 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1094 // check if object is reference
1095 _PTR(SObject) aRefSObj;
1096 aNameList.append("\n - ");
1097 if ( aSO->ReferencedObject( aRefSObj ) ) {
1098 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1099 aNameList.append( aRefName );
1100 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1103 aNameList.append(anIO->getName());
1107 if( aParentComponent.isNull() )
1108 aParentComponent = cur;
1109 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1110 aParentComponent = "";
1113 if ( objectCount == 0 )
1114 return; // No Valid Objects Selected
1116 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1117 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1118 QObject::tr("ERR_ERROR"),
1119 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1122 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1123 if (SUIT_MessageBox::warning
1124 (SMESHGUI::desktop(),
1125 QObject::tr("SMESH_WRN_WARNING"),
1126 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1127 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1128 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1131 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1132 SUIT_ViewManager* vm = anApp->activeViewManager();
1133 int nbSf = vm->getViewsCount();
1135 SALOME_ListIteratorOfListIO It(selected);
1137 aStudyBuilder->NewCommand(); // There is a transaction
1138 for( ; It.More(); It.Next()){ // loop on selected IO's
1139 Handle(SALOME_InteractiveObject) IObject = It.Value();
1140 if(IObject->hasEntry()) {
1141 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1143 // disable removal of "SMESH" component object
1144 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1146 if ( engineIOR() == anIOR->Value().c_str() )
1149 //Check the referenced object
1150 _PTR(SObject) aRefSObject;
1151 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1152 aSO = aRefSObject; // Delete main Object instead of reference
1154 // put the whole hierarchy of sub-objects of the selected SO into a list and
1155 // then treat them all starting from the deepest objects (at list back)
1157 std::list< _PTR(SObject) > listSO;
1158 listSO.push_back( aSO );
1159 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1160 for ( ; itSO != listSO.end(); ++itSO ) {
1161 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1162 for (it->InitEx(false); it->More(); it->Next())
1163 listSO.push_back( it->Value() );
1166 // treat SO's in the list starting from the back
1168 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1169 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1170 _PTR(SObject) SO = *ritSO;
1171 if ( !SO ) continue;
1172 std::string anEntry = SO->GetID();
1174 /** Erase graphical object **/
1175 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1176 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1177 for(int i = 0; i < nbSf; i++){
1178 SUIT_ViewWindow *sf = aViews[i];
1179 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1180 SMESH::RemoveActor(sf,anActor);
1185 /** Remove an object from data structures **/
1186 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1187 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1188 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1189 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1190 aMesh->RemoveGroup( aGroup );
1192 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1193 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1194 aMesh->RemoveSubMesh( aSubMesh );
1196 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1198 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1201 IObject = new SALOME_InteractiveObject
1202 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1203 QString objType = CheckTypeObject(IObject);
1204 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1205 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1206 aStudyBuilder->RemoveObjectWithChildren( SO );
1208 else {// default action: remove SObject from the study
1209 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1210 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1212 aStudyBuilder->RemoveObjectWithChildren( SO );
1216 } /* listSO back loop */
1217 } /* IObject->hasEntry() */
1219 aStudyBuilder->CommitCommand();
1221 /* Clear any previous selection */
1223 aSel->setSelectedObjects( l1 );
1225 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1230 SMESHGUI_EXPORT CAM_Module* createModule()
1232 return new SMESHGUI();
1236 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1238 //=============================================================================
1242 //=============================================================================
1243 SMESHGUI::SMESHGUI() :
1244 SalomeApp_Module( "SMESH" ),
1245 LightApp_Module( "SMESH" )
1247 if ( CORBA::is_nil( myComponentSMESH ) )
1249 CORBA::Boolean anIsEmbeddedMode;
1250 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1252 // 0019923: EDF 765 SMESH : default values of hypothesis
1253 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1254 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1255 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1256 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1257 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1260 myActiveDialogBox = 0;
1261 myFilterLibraryDlg = 0;
1265 SMESH::GetFilterManager();
1266 SMESH::GetPattern();
1268 /* load resources for all available meshers */
1269 SMESH::InitAvailableHypotheses();
1272 //=============================================================================
1276 //=============================================================================
1277 SMESHGUI::~SMESHGUI()
1279 SMESH::GetFilterManager()->Destroy();
1280 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1283 //=============================================================================
1287 //=============================================================================
1288 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1290 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1292 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1297 bool SMESHGUI::automaticUpdate()
1299 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1303 return resMgr->booleanValue( "SMESH", "auto_update", false );
1306 //=============================================================================
1310 //=============================================================================
1311 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1313 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1316 //=============================================================================
1320 //=============================================================================
1321 SMESHGUI* SMESHGUI::GetSMESHGUI()
1323 SMESHGUI* smeshMod = 0;
1324 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1327 CAM_Module* module = app->module( "Mesh" );
1328 smeshMod = dynamic_cast<SMESHGUI*>( module );
1331 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1333 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1336 _PTR(Study) aStudy = study->studyDS();
1338 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1347 Standard_EXPORT SMESHGUI* GetComponentGUI()
1349 return SMESHGUI::GetSMESHGUI();
1353 //=============================================================================
1357 //=============================================================================
1358 void SMESHGUI::SetState(int aState)
1363 //=============================================================================
1367 //=============================================================================
1368 void SMESHGUI::ResetState()
1373 //=============================================================================
1377 //=============================================================================
1378 void SMESHGUI::EmitSignalDeactivateDialog()
1380 emit SignalDeactivateActiveDialog();
1383 //=============================================================================
1387 //=============================================================================
1388 void SMESHGUI::EmitSignalStudyFrameChanged()
1390 emit SignalStudyFrameChanged();
1393 //=============================================================================
1397 //=============================================================================
1398 void SMESHGUI::EmitSignalCloseAllDialogs()
1400 emit SignalCloseAllDialogs();
1403 //=============================================================================
1407 //=============================================================================
1408 void SMESHGUI::EmitSignalVisibilityChanged()
1410 emit SignalVisibilityChanged();
1413 //=============================================================================
1417 //=============================================================================
1418 QDialog *SMESHGUI::GetActiveDialogBox()
1420 return myActiveDialogBox;
1423 //=============================================================================
1427 //=============================================================================
1428 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1430 myActiveDialogBox = (QDialog *) aDlg;
1434 //=============================================================================
1438 //=============================================================================
1439 SUIT_Desktop* SMESHGUI::desktop()
1441 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1443 return app->desktop();
1448 //=============================================================================
1452 //=============================================================================
1453 SalomeApp_Study* SMESHGUI::activeStudy()
1455 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1457 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1462 //=============================================================================
1466 //=============================================================================
1467 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1469 /* Here the position is on the bottom right corner - 10 */
1470 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1472 SUIT_Desktop *PP = desktop();
1473 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1474 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1478 //=============================================================================
1482 //=============================================================================
1483 static int isStudyLocked(_PTR(Study) theStudy){
1484 return theStudy->GetProperties()->IsLocked();
1487 static bool checkLock(_PTR(Study) theStudy) {
1488 if (isStudyLocked(theStudy)) {
1489 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1490 QObject::tr("WRN_WARNING"),
1491 QObject::tr("WRN_STUDY_LOCKED") );
1497 //=======================================================================
1498 //function : CheckActiveStudyLocked
1500 //=======================================================================
1502 bool SMESHGUI::isActiveStudyLocked()
1504 _PTR(Study) aStudy = activeStudy()->studyDS();
1505 return checkLock( aStudy );
1508 //=============================================================================
1512 //=============================================================================
1513 bool SMESHGUI::OnGUIEvent( int theCommandID )
1515 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1519 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1520 SUIT_ResourceMgr* mgr = resourceMgr();
1524 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1525 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1528 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1529 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1531 //QAction* act = action( theCommandID );
1533 switch (theCommandID) {
1535 if(checkLock(aStudy)) break;
1543 if(checkLock(aStudy)) break;
1544 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1548 case 150: //MED FILE INFORMATION
1550 SALOME_ListIO selected;
1551 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1553 aSel->selectedObjects( selected );
1554 if( selected.Extent() )
1556 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1557 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1558 if ( !aMesh->_is_nil() )
1560 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1567 case 122: // EXPORT MED
1576 ::ExportMeshToFile(theCommandID);
1580 case 200: // SCALAR BAR
1582 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1583 SALOME_ListIO selected;
1585 aSel->selectedObjects( selected );
1587 if( selected.Extent() ) {
1588 Handle(SALOME_InteractiveObject) anIO = selected.First();
1589 if( anIO->hasEntry() ) {
1590 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1591 anActor->SetControlMode( SMESH_Actor::eNone );
1599 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1609 ::DisableAutoColor();
1612 case 1134: // Clipping
1613 case 1133: // Tranparency
1614 case 1132: // Colors / Size
1621 ::SetDisplayMode(theCommandID);
1624 //2D quadratic representation
1627 ::SetDisplayMode(theCommandID);
1631 case 216: // 0D elements
1634 case 219: // Volumes
1635 case 220: // All Entity
1636 ::SetDisplayEntity(theCommandID);
1639 case 221: // Orientation of faces
1641 LightApp_SelectionMgr* mgr = selectionMgr();
1642 SALOME_ListIO selected; mgr->selectedObjects( selected );
1644 SALOME_ListIteratorOfListIO it(selected);
1645 for( ; it.More(); it.Next()) {
1646 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1647 if(anIObject->hasEntry()) {
1648 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1649 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1658 if(checkLock(aStudy)) break;
1660 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1663 SMESH::UpdateView();
1665 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1666 SMESH::OnVisuException();
1668 catch (...) { // PAL16774 (Crash after display of many groups)
1669 SMESH::OnVisuException();
1673 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1674 aSel->selectedObjects( l );
1675 aSel->setSelectedObjects( l );
1680 case 301: // DISPLAY
1681 case 302: // DISPLAY ONLY
1683 SMESH::EDisplaing anAction;
1684 switch (theCommandID) {
1685 case 300: anAction = SMESH::eErase; break;
1686 case 301: anAction = SMESH::eDisplay; break;
1687 case 302: anAction = SMESH::eDisplayOnly; break;
1690 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1691 SALOME_ListIO sel_objects, to_process;
1693 aSel->selectedObjects( sel_objects );
1695 if( theCommandID==302 )
1696 startOperation( myEraseAll );
1698 extractContainers( sel_objects, to_process );
1701 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1705 SALOME_ListIteratorOfListIO It( to_process );
1706 for ( ; It.More(); It.Next()) {
1707 Handle(SALOME_InteractiveObject) IOS = It.Value();
1708 if (IOS->hasEntry()) {
1709 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1710 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1711 break; // PAL16774 (Crash after display of many groups)
1713 if (anAction == SMESH::eDisplayOnly)
1714 anAction = SMESH::eDisplay;
1719 // PAL13338 + PAL15161 -->
1720 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1721 SMESH::UpdateView();
1722 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1724 // PAL13338 + PAL15161 <--
1726 catch (...) { // PAL16774 (Crash after display of many groups)
1727 SMESH::OnVisuException();
1730 if (anAction == SMESH::eErase) {
1732 aSel->setSelectedObjects( l1 );
1735 aSel->setSelectedObjects( to_process );
1742 if(checkLock(aStudy)) break;
1745 EmitSignalDeactivateDialog();
1747 ( new SMESHGUI_NodesDlg( this ) )->show();
1750 SUIT_MessageBox::warning(desktop(),
1751 tr("SMESH_WRN_WARNING"),
1752 tr("SMESH_WRN_VIEWER_VTK"));
1757 case 2151: // FILTER
1761 EmitSignalDeactivateDialog();
1762 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1767 case 406: // MOVE NODE
1771 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1772 tr( "NOT_A_VTK_VIEWER" ) );
1776 if(checkLock(aStudy)) break;
1777 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1781 case 701: // COMPUTE MESH
1782 case 711: // PRECOMPUTE MESH
1783 case 712: // EVALUATE MESH
1784 case 713: // MESH ORDER
1786 if (checkLock(aStudy)) break;
1787 startOperation( theCommandID );
1791 case 702: // Create mesh
1792 case 703: // Create sub-mesh
1793 case 704: // Edit mesh/sub-mesh
1794 startOperation( theCommandID );
1796 case 710: // Build compound mesh
1798 if (checkLock(aStudy)) break;
1799 EmitSignalDeactivateDialog();
1800 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1804 case 407: // DIAGONAL INVERSION
1805 case 408: // Delete diagonal
1809 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1810 tr( "NOT_A_VTK_VIEWER" ) );
1814 if ( checkLock( aStudy ) )
1817 /*Standard_Boolean aRes;
1818 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1819 if ( aMesh->_is_nil() )
1821 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1822 tr( "SMESH_BAD_SELECTION" ) );
1826 EmitSignalDeactivateDialog();
1827 if ( theCommandID == 407 )
1828 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1830 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1833 case 409: // Change orientation
1834 case 410: // Union of triangles
1835 case 411: // Cutting of quadrangles
1839 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1840 tr( "NOT_A_VTK_VIEWER" ) );
1844 if ( checkLock( aStudy ) )
1847 EmitSignalDeactivateDialog();
1848 SMESHGUI_MultiEditDlg* aDlg = NULL;
1849 if ( theCommandID == 409 )
1850 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1851 else if ( theCommandID == 410 )
1852 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1854 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1859 case 412: // Smoothing
1861 if(checkLock(aStudy)) break;
1863 EmitSignalDeactivateDialog();
1864 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1867 SUIT_MessageBox::warning(desktop(),
1868 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1872 case 413: // Extrusion
1874 if (checkLock(aStudy)) break;
1876 EmitSignalDeactivateDialog();
1877 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1879 SUIT_MessageBox::warning(desktop(),
1880 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1884 case 414: // Revolution
1886 if(checkLock(aStudy)) break;
1888 EmitSignalDeactivateDialog();
1889 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1892 SUIT_MessageBox::warning(desktop(),
1893 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1897 case 415: // Pattern mapping
1899 if ( checkLock( aStudy ) )
1903 EmitSignalDeactivateDialog();
1904 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1907 SUIT_MessageBox::warning(desktop(),
1908 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1912 case 416: // Extrusion along a path
1914 if (checkLock(aStudy)) break;
1916 EmitSignalDeactivateDialog();
1917 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1919 SUIT_MessageBox::warning(desktop(),
1920 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1924 case 417: // Convert mesh to quadratic
1926 startOperation( 417 );
1927 /* if (checkLock(aStudy)) break;
1929 EmitSignalDeactivateDialog();
1930 new SMESHGUI_ConvToQuadDlg();
1932 SUIT_MessageBox::warning(desktop(),
1933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1937 case 418: // create 2D mesh from 3D
1939 startOperation( 418 );
1942 case 806: // CREATE GEO GROUP
1944 startOperation( 806 );
1947 case 801: // CREATE GROUP
1951 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1952 tr( "NOT_A_VTK_VIEWER" ) );
1956 if(checkLock(aStudy)) break;
1957 EmitSignalDeactivateDialog();
1958 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1960 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1961 SALOME_ListIO selected;
1963 aSel->selectedObjects( selected );
1965 int nbSel = selected.Extent();
1967 // check if mesh is selected
1968 aMesh = SMESH::GetMeshByIO( selected.First() );
1970 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1975 case 802: // CONSTRUCT GROUP
1979 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1980 tr( "NOT_A_VTK_VIEWER" ) );
1984 if(checkLock(aStudy)) break;
1985 EmitSignalDeactivateDialog();
1987 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1988 SALOME_ListIO selected;
1990 aSel->selectedObjects( selected );
1992 int nbSel = selected.Extent();
1994 // check if submesh is selected
1995 Handle(SALOME_InteractiveObject) IObject = selected.First();
1996 if (IObject->hasEntry()) {
1997 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1999 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2000 if (!aSubMesh->_is_nil()) {
2002 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2003 // get submesh elements list by types
2004 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2005 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2006 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2007 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2008 // create group for each type o elements
2009 QString aName = IObject->getName();
2010 if (aNodes->length() > 0) {
2011 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2012 aGroup->Add(aNodes.inout());
2014 if (aEdges->length() > 0) {
2015 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2016 aGroup->Add(aEdges.inout());
2018 if (aFaces->length() > 0) {
2019 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2020 aGroup->Add(aFaces.inout());
2022 if (aVolumes->length() > 0) {
2023 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2024 aGroup->Add(aVolumes.inout());
2029 catch(const SALOME::SALOME_Exception & S_ex){
2030 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2037 SUIT_MessageBox::warning(desktop(),
2038 tr("SMESH_WRN_WARNING"),
2039 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2044 case 803: // EDIT GROUP
2048 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2049 tr( "NOT_A_VTK_VIEWER" ) );
2053 if(checkLock(aStudy)) break;
2054 EmitSignalDeactivateDialog();
2056 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2057 SALOME_ListIO selected;
2059 aSel->selectedObjects( selected );
2061 SALOME_ListIteratorOfListIO It (selected);
2062 int nbSelectedGroups = 0;
2063 for ( ; It.More(); It.Next() )
2065 SMESH::SMESH_GroupBase_var aGroup =
2066 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2067 if (!aGroup->_is_nil()) {
2069 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2073 if (nbSelectedGroups == 0)
2075 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2081 case 804: // Add elements to group
2083 if(checkLock(aStudy)) break;
2084 if (myState == 800) {
2085 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2086 if (aDlg) aDlg->onAdd();
2091 case 805: // Remove elements from group
2093 if(checkLock(aStudy)) break;
2094 if (myState == 800) {
2095 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2096 if (aDlg) aDlg->onRemove();
2101 case 815: // Edit GEOM GROUP as standalone
2105 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2106 tr( "NOT_A_VTK_VIEWER" ) );
2110 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2113 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2114 SALOME_ListIO selected;
2116 aSel->selectedObjects( selected );
2118 SALOME_ListIteratorOfListIO It (selected);
2119 for ( ; It.More(); It.Next() )
2121 SMESH::SMESH_GroupOnGeom_var aGroup =
2122 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2123 if (!aGroup->_is_nil()) {
2124 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2131 case 810: // Union Groups
2132 case 811: // Intersect groups
2133 case 812: // Cut groups
2137 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2138 tr( "NOT_A_VTK_VIEWER" ) );
2142 if ( checkLock( aStudy ) )
2145 EmitSignalDeactivateDialog();
2147 SMESHGUI_GroupOpDlg* aDlg = 0;
2148 if ( theCommandID == 810 )
2149 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2150 else if ( theCommandID == 811 )
2151 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2153 aDlg = new SMESHGUI_CutGroupsDlg( this );
2160 case 814: // Create groups of entities from existing groups of superior dimensions
2162 if ( checkLock( aStudy ) )
2165 EmitSignalDeactivateDialog();
2166 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2172 case 813: // Delete groups with their contents
2176 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2177 tr( "NOT_A_VTK_VIEWER" ) );
2181 if ( checkLock( aStudy ) )
2184 EmitSignalDeactivateDialog();
2186 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2190 case 900: // MESH INFOS
2192 EmitSignalDeactivateDialog();
2193 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2194 SALOME_ListIO selected;
2196 aSel->selectedObjects( selected );
2198 if ( selected.Extent() > 1 ) { // a dlg for each IO
2200 SALOME_ListIteratorOfListIO It (selected);
2201 for ( ; It.More(); It.Next() ) {
2202 IOs.Clear(); IOs.Append( It.Value() );
2203 aSel->setSelectedObjects( IOs );
2204 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2206 // restore selection
2207 aSel->setSelectedObjects( selected );
2210 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2214 case 902: // STANDARD MESH INFOS
2216 EmitSignalDeactivateDialog();
2217 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2218 SALOME_ListIO selected;
2220 aSel->selectedObjects( selected );
2222 if ( selected.Extent() > 1 ) { // a dlg for each IO
2224 SALOME_ListIteratorOfListIO It (selected);
2225 for ( ; It.More(); It.Next() ) {
2227 IOs.Append( It.Value() );
2228 aSel->setSelectedObjects( IOs );
2229 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2231 // restore selection
2232 aSel->setSelectedObjects( selected );
2235 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2239 case 903: // WHAT IS
2241 EmitSignalDeactivateDialog();
2242 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2246 case 904: // FIND ELEM
2248 startOperation( theCommandID );
2252 case 1100: // EDIT HYPOTHESIS
2254 if(checkLock(aStudy)) break;
2256 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2257 SALOME_ListIO selected;
2259 aSel->selectedObjects( selected );
2261 int nbSel = selected.Extent();
2264 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2265 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2267 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2268 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2269 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2270 if ( !aHypothesis->_is_nil() )
2273 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2274 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2276 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2287 case 1101: // RENAME
2289 if ( checkLock( aStudy ) )
2292 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2293 SALOME_ListIO selected;
2295 aSel->selectedObjects( selected );
2297 bool isAny = false; // is there any appropriate object selected
2299 SALOME_ListIteratorOfListIO It( selected );
2300 for ( ; It.More(); It.Next() )
2302 Handle(SALOME_InteractiveObject) IObject = It.Value();
2303 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2304 _PTR(GenericAttribute) anAttr;
2305 _PTR(AttributeName) aName;
2308 if ( obj->FindAttribute(anAttr, "AttributeName") )
2311 QString newName = QString(aName->Value().c_str());
2313 // check type to prevent renaming of inappropriate objects
2314 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2315 if (aType == MESH || aType == GROUP ||
2316 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2317 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2318 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2319 aType == HYPOTHESIS || aType == ALGORITHM)
2322 newName = LightApp_NameDlg::getName(desktop(), newName);
2323 if ( !newName.isEmpty() )
2325 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2327 // update name of group object and its actor
2328 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2329 if( !aGroupObject->_is_nil() )
2331 aGroupObject->SetName( newName.toLatin1().data() );
2332 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2333 anActor->setName( newName.toLatin1().data() );
2344 SUIT_MessageBox::warning(desktop(),
2345 QObject::tr("SMESH_WRN_WARNING"),
2346 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2351 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2353 if(checkLock(aStudy)) break;
2354 SUIT_OverrideCursor wc;
2356 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2357 SALOME_ListIO selected;
2359 aSel->selectedObjects( selected, QString::null, false );
2361 SALOME_ListIteratorOfListIO It(selected);
2362 for (int i = 0; It.More(); It.Next(), i++) {
2363 Handle(SALOME_InteractiveObject) IObject = It.Value();
2364 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2367 aSel->setSelectedObjects( l1 );
2372 case 4009: // ELEM0D
2373 case 4010: // GEOM::EDGE
2374 case 4021: // TRIANGLE
2376 case 4023: // POLYGON
2380 if(checkLock(aStudy)) break;
2382 EmitSignalDeactivateDialog();
2383 SMDSAbs_ElementType type = SMDSAbs_Edge;
2385 switch (theCommandID) {
2386 case 4009: // ELEM0D
2387 type = SMDSAbs_0DElement; nbNodes = 1; break;
2388 case 4021: // TRIANGLE
2389 type = SMDSAbs_Face; nbNodes = 3; break;
2391 type = SMDSAbs_Face; nbNodes = 4; break;
2393 type = SMDSAbs_Volume; nbNodes = 4; break;
2394 case 4023: // POLYGON
2395 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2397 type = SMDSAbs_Volume; nbNodes = 8; break;
2398 case 4033: // POLYHEDRE
2399 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2402 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2405 SUIT_MessageBox::warning(desktop(),
2406 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2410 case 4033: // POLYHEDRON
2412 if(checkLock(aStudy)) break;
2414 EmitSignalDeactivateDialog();
2415 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2418 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2419 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2423 case 4034: // QUADRATIC EDGE
2424 case 4035: // QUADRATIC TRIANGLE
2425 case 4036: // QUADRATIC QUADRANGLE
2426 case 4037: // QUADRATIC TETRAHEDRON
2427 case 4038: // QUADRATIC PYRAMID
2428 case 4039: // QUADRATIC PENTAHEDRON
2429 case 4040: // QUADRATIC HEXAHEDRON
2431 if(checkLock(aStudy)) break;
2433 EmitSignalDeactivateDialog();
2436 switch (theCommandID) {
2438 type = QUAD_EDGE; break;
2440 type = QUAD_TRIANGLE; break;
2442 type = QUAD_QUADRANGLE; break;
2444 type = QUAD_TETRAHEDRON; break;
2446 type = QUAD_PYRAMID; break;
2448 type = QUAD_PENTAHEDRON; break;
2450 type = QUAD_HEXAHEDRON;
2454 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2457 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2458 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2462 case 4041: // REMOVES NODES
2464 if(checkLock(aStudy)) break;
2466 EmitSignalDeactivateDialog();
2467 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2470 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2471 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2475 case 4042: // REMOVES ELEMENTS
2477 if(checkLock(aStudy)) break;
2479 EmitSignalDeactivateDialog();
2480 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2484 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2485 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2489 case 4043: { // CLEAR_MESH
2491 if(checkLock(aStudy)) break;
2493 SALOME_ListIO selected;
2494 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2495 aSel->selectedObjects( selected );
2497 SUIT_OverrideCursor wc;
2498 SALOME_ListIteratorOfListIO It (selected);
2499 for ( ; It.More(); It.Next() )
2501 Handle(SALOME_InteractiveObject) IOS = It.Value();
2502 SMESH::SMESH_Mesh_var aMesh =
2503 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2504 if ( aMesh->_is_nil()) continue;
2506 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2508 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2509 SMESH::ModifiedMesh( aMeshSObj, false, true);
2510 // hide groups and submeshes
2511 _PTR(ChildIterator) anIter =
2512 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2513 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2515 _PTR(SObject) so = anIter->Value();
2516 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2519 catch (const SALOME::SALOME_Exception& S_ex){
2521 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2525 SMESH::UpdateView();
2529 case 4051: // RENUMBERING NODES
2531 if(checkLock(aStudy)) break;
2533 EmitSignalDeactivateDialog();
2534 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2538 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2539 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2543 case 4052: // RENUMBERING ELEMENTS
2545 if(checkLock(aStudy)) break;
2547 EmitSignalDeactivateDialog();
2548 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2552 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2553 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2557 case 4061: // TRANSLATION
2559 if(checkLock(aStudy)) break;
2561 EmitSignalDeactivateDialog();
2562 ( new SMESHGUI_TranslationDlg( this ) )->show();
2565 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2566 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2570 case 4062: // ROTATION
2572 if(checkLock(aStudy)) break;
2574 EmitSignalDeactivateDialog();
2575 ( new SMESHGUI_RotationDlg( this ) )->show();
2578 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2579 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2583 case 4063: // SYMMETRY
2585 if(checkLock(aStudy)) break;
2587 EmitSignalDeactivateDialog();
2588 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2591 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2592 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2596 case 4064: // SEWING
2598 if(checkLock(aStudy)) break;
2600 EmitSignalDeactivateDialog();
2601 ( new SMESHGUI_SewingDlg( this ) )->show();
2604 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2605 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2609 case 4065: // MERGE NODES
2611 if(checkLock(aStudy)) break;
2613 EmitSignalDeactivateDialog();
2614 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2617 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2618 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2622 case 4066: // MERGE EQUAL ELEMENTS
2624 if (checkLock(aStudy)) break;
2626 EmitSignalDeactivateDialog();
2627 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2629 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2630 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2635 case 4067: // MAKE MESH PASS THROUGH POINT
2636 startOperation( 4067 );
2641 if(checkLock(aStudy)) break;
2643 EmitSignalDeactivateDialog();
2644 ( new SMESHGUI_ScaleDlg( this ) )->show();
2647 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2648 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2653 case 5105: // Library of selection filters
2655 static QList<int> aTypes;
2656 if ( aTypes.isEmpty() )
2658 aTypes.append( SMESH::NODE );
2659 aTypes.append( SMESH::EDGE );
2660 aTypes.append( SMESH::FACE );
2661 aTypes.append( SMESH::VOLUME );
2663 if (!myFilterLibraryDlg)
2664 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2665 else if (myFilterLibraryDlg->isHidden())
2666 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2667 myFilterLibraryDlg->raise();
2671 case 6017: // CONTROLS
2689 LightApp_SelectionMgr* mgr = selectionMgr();
2690 SALOME_ListIO selected; mgr->selectedObjects( selected );
2692 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2693 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2695 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2696 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2697 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2698 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2699 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2700 ::Control( theCommandID );
2705 SUIT_MessageBox::warning(desktop(),
2706 tr( "SMESH_WRN_WARNING" ),
2707 tr( "SMESH_BAD_SELECTION" ) );
2711 SUIT_MessageBox::warning(desktop(),
2712 tr( "SMESH_WRN_WARNING" ),
2713 tr( "NOT_A_VTK_VIEWER" ) );
2718 LightApp_SelectionMgr* mgr = selectionMgr();
2719 SALOME_ListIO selected; mgr->selectedObjects( selected );
2721 SALOME_ListIteratorOfListIO it(selected);
2722 for( ; it.More(); it.Next()) {
2723 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2724 if(anIObject->hasEntry()) {
2725 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2726 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2734 LightApp_SelectionMgr* mgr = selectionMgr();
2735 SALOME_ListIO selected; mgr->selectedObjects( selected );
2737 if (selected.Extent() == 1) {
2738 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2739 if(anIObject->hasEntry())
2740 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2741 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2748 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2749 //updateObjBrowser();
2753 //=============================================================================
2757 //=============================================================================
2758 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2763 //=============================================================================
2767 //=============================================================================
2768 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2773 //=============================================================================
2777 //=============================================================================
2778 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2783 //=============================================================================
2784 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2785 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2787 //=============================================================================
2788 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2789 SUIT_ViewWindow* wnd )
2791 if(theIO->hasEntry()){
2792 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2793 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2797 //=======================================================================
2798 // function : createSMESHAction
2800 //=======================================================================
2801 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2804 QWidget* parent = application()->desktop();
2805 SUIT_ResourceMgr* resMgr = resourceMgr();
2807 if ( !icon_id.isEmpty() )
2808 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2810 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2811 if ( !pix.isNull() )
2812 icon = QIcon( pix );
2814 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2815 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2816 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2818 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2821 //=======================================================================
2822 // function : createPopupItem
2824 //=======================================================================
2825 void SMESHGUI::createPopupItem( const int id,
2826 const QString& clients,
2827 const QString& types,
2828 const QString& theRule,
2833 parentId = popupMgr()->actionId( action( pId ) );
2835 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2836 popupMgr()->insert( action( id ), parentId, 0 );
2838 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2839 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2840 QString rule = "(%1) and (%2) and (%3)";
2841 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2842 if( clients.isEmpty() )
2843 rule = rule.arg( QString( "true" ) );
2845 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2846 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2849 bool cont = myRules.contains( id );
2851 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2853 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2854 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2857 //=======================================================================
2858 // function : initialize
2860 //=======================================================================
2861 void SMESHGUI::initialize( CAM_Application* app )
2863 SalomeApp_Module::initialize( app );
2865 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2867 /* Automatic Update flag */
2868 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2870 // ----- create actions --------------
2872 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2873 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2874 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2875 createSMESHAction( 114, "NUM" );
2876 createSMESHAction( 121, "DAT" );
2877 createSMESHAction( 122, "MED" );
2878 createSMESHAction( 123, "UNV" );
2879 createSMESHAction( 140, "STL" );
2880 createSMESHAction( 124, "EXPORT_DAT" );
2881 createSMESHAction( 125, "EXPORT_MED" );
2882 createSMESHAction( 126, "EXPORT_UNV" );
2883 createSMESHAction( 141, "EXPORT_STL" );
2884 createSMESHAction( 150, "FILE_INFO" );
2885 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2886 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2887 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2888 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2889 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2890 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2891 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2892 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2893 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2894 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2895 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2896 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2897 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2898 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2899 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2900 createSMESHAction( 804, "ADD" );
2901 createSMESHAction( 805, "REMOVE" );
2902 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2903 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2904 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2905 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2906 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2907 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2908 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2909 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2910 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2911 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2912 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2913 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2914 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2915 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2916 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2917 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2918 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2919 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2920 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2921 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2922 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2923 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2924 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2925 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2926 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2927 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2928 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2929 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2930 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2931 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2932 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2933 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2934 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2935 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2936 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2937 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2938 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2939 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2940 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2941 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2942 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2943 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2944 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2945 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2946 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2947 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
2948 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2949 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2950 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2951 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2952 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2953 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2954 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2955 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2956 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2957 createSMESHAction( 415, "MAP", "ICON_MAP" );
2958 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2959 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2960 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
2961 createSMESHAction( 200, "RESET" );
2962 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2963 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2964 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2965 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2966 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2967 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2968 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
2969 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2970 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2971 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2972 createSMESHAction( 220, "ALL" );
2973 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2975 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
2976 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
2978 createSMESHAction( 1100, "EDIT_HYPO" );
2979 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2980 createSMESHAction( 1102, "UNASSIGN" );
2981 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2982 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2983 createSMESHAction( 1131, "DISPMODE" );
2984 createSMESHAction( 1132, "COLORS" );
2985 createSMESHAction( 1133, "TRANSP" );
2986 createSMESHAction( 1134, "CLIP" );
2987 createSMESHAction( 1135, "DISP_ENT" );
2988 createSMESHAction( 1136, "AUTO_COLOR" );
2989 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2990 createSMESHAction( 2000, "CTRL" );
2992 createSMESHAction( 300, "ERASE" );
2993 createSMESHAction( 301, "DISPLAY" );
2994 createSMESHAction( 302, "DISPLAY_ONLY" );
2995 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2996 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2997 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2998 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2999 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3000 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3001 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3002 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3004 // ----- create menu --------------
3005 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3006 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3007 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3008 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3009 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3010 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3011 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3013 createMenu( separator(), fileId );
3015 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3016 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3017 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3018 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3019 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3020 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3022 createMenu( 111, importId, -1 );
3023 createMenu( 112, importId, -1 );
3024 createMenu( 113, importId, -1 );
3026 createMenu( 121, exportId, -1 );
3027 createMenu( 122, exportId, -1 );
3028 createMenu( 123, exportId, -1 );
3029 createMenu( 140, exportId, -1 ); // export to stl STL
3031 createMenu( separator(), fileId, 10 );
3033 createMenu( 33, editId, -1 );
3035 createMenu( 5105, toolsId, -1 );
3037 createMenu( 702, meshId, -1 ); // "Mesh" menu
3038 createMenu( 703, meshId, -1 );
3039 createMenu( 704, meshId, -1 );
3040 createMenu( 710, meshId, -1 );
3041 createMenu( separator(), meshId, -1 );
3042 createMenu( 701, meshId, -1 );
3043 createMenu( 711, meshId, -1 );
3044 createMenu( 712, meshId, -1 );
3045 createMenu( 713, meshId, -1 );
3046 createMenu( separator(), meshId, -1 );
3047 createMenu( 801, meshId, -1 );
3048 createMenu( 806, meshId, -1 );
3049 createMenu( 802, meshId, -1 );
3050 createMenu( 803, meshId, -1 );
3051 createMenu( 815, meshId, -1 );
3052 createMenu( separator(), meshId, -1 );
3053 createMenu( 810, meshId, -1 );
3054 createMenu( 811, meshId, -1 );
3055 createMenu( 812, meshId, -1 );
3056 createMenu( separator(), meshId, -1 );
3057 createMenu( 814, meshId, -1 );
3058 createMenu( separator(), meshId, -1 );
3059 createMenu( 813, meshId, -1 );
3060 createMenu( separator(), meshId, -1 );
3061 createMenu( 900, meshId, -1 );
3062 createMenu( 902, meshId, -1 );
3063 createMenu( 903, meshId, -1 );
3064 createMenu( 904, meshId, -1 );
3065 createMenu( separator(), meshId, -1 );
3067 createMenu( 6003, ctrlId, -1 );
3068 createMenu( 6001, ctrlId, -1 );
3069 createMenu( 6004, ctrlId, -1 );
3070 createMenu( separator(), ctrlId, -1 );
3071 createMenu( 6005, ctrlId, -1 );
3072 createMenu( 6002, ctrlId, -1 );
3073 createMenu( 6018, ctrlId, -1 );
3074 createMenu( 6019, ctrlId, -1 );
3075 createMenu( 6011, ctrlId, -1 );
3076 createMenu( 6012, ctrlId, -1 );
3077 createMenu( 6013, ctrlId, -1 );
3078 createMenu( 6014, ctrlId, -1 );
3079 createMenu( 6015, ctrlId, -1 );
3080 createMenu( 6016, ctrlId, -1 );
3081 createMenu( separator(), ctrlId, -1 );
3082 createMenu( 6017, ctrlId, -1 );
3083 createMenu( 6009, ctrlId, -1 );
3084 createMenu( 6021, ctrlId, -1 );
3085 createMenu( separator(), ctrlId, -1 );
3087 createMenu( 4000, addId, -1 );
3088 createMenu( 4009, addId, -1 );
3089 createMenu( 4010, addId, -1 );
3090 createMenu( 4021, addId, -1 );
3091 createMenu( 4022, addId, -1 );
3092 createMenu( 4023, addId, -1 );
3093 createMenu( 4031, addId, -1 );
3094 createMenu( 4032, addId, -1 );
3095 createMenu( 4033, addId, -1 );
3096 createMenu( separator(), addId, -1 );
3097 createMenu( 4034, addId, -1 );
3098 createMenu( 4035, addId, -1 );
3099 createMenu( 4036, addId, -1 );
3100 createMenu( 4037, addId, -1 );
3101 createMenu( 4038, addId, -1 );
3102 createMenu( 4039, addId, -1 );
3103 createMenu( 4040, addId, -1 );
3105 createMenu( 4041, removeId, -1 );
3106 createMenu( 4042, removeId, -1 );
3107 createMenu( 4043, removeId, -1 );
3109 createMenu( 4051, renumId, -1 );
3110 createMenu( 4052, renumId, -1 );
3112 createMenu( 4061, transfId, -1 );
3113 createMenu( 4062, transfId, -1 );
3114 createMenu( 4063, transfId, -1 );
3115 createMenu( 4064, transfId, -1 );
3116 createMenu( 4065, transfId, -1 );
3117 createMenu( 4066, transfId, -1 );
3118 createMenu( 4068, transfId, -1 );
3120 createMenu( 406, modifyId, -1 );
3121 createMenu( 4067,modifyId, -1 );
3122 createMenu( 407, modifyId, -1 );
3123 createMenu( 408, modifyId, -1 );
3124 createMenu( 409, modifyId, -1 );
3125 createMenu( 410, modifyId, -1 );
3126 createMenu( 411, modifyId, -1 );
3127 createMenu( 412, modifyId, -1 );
3128 createMenu( 413, modifyId, -1 );
3129 createMenu( 416, modifyId, -1 );
3130 createMenu( 414, modifyId, -1 );
3131 createMenu( 415, modifyId, -1 );
3132 createMenu( 417, modifyId, -1 );
3133 createMenu( 418, modifyId, -1 );
3135 createMenu( 214, viewId, -1 );
3137 // ----- create toolbars --------------
3138 int meshTb = createTool( tr( "TB_MESH" ) ),
3139 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3140 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3141 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3142 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3144 createTool( 702, meshTb );
3145 createTool( 703, meshTb );
3146 createTool( 704, meshTb );
3147 createTool( 710, meshTb );
3148 createTool( separator(), meshTb );
3149 createTool( 701, meshTb );
3150 createTool( 711, meshTb );
3151 createTool( 712, meshTb );
3152 createTool( 713, meshTb );
3153 createTool( separator(), meshTb );
3154 createTool( 801, meshTb );
3155 createTool( 806, meshTb );
3156 createTool( 802, meshTb );
3157 createTool( 803, meshTb );
3158 //createTool( 815, meshTb );
3159 createTool( separator(), meshTb );
3160 createTool( 900, meshTb );
3161 createTool( 902, meshTb );
3162 createTool( 903, meshTb );
3163 createTool( 904, meshTb );
3164 createTool( separator(), meshTb );
3166 createTool( 6001, ctrlTb );
3167 createTool( 6003, ctrlTb );
3168 createTool( 6004, ctrlTb );
3169 createTool( separator(), ctrlTb );
3170 createTool( 6005, ctrlTb );
3171 createTool( 6002, ctrlTb );
3172 createTool( 6018, ctrlTb );
3173 createTool( 6019, ctrlTb );
3174 createTool( 6011, ctrlTb );
3175 createTool( 6012, ctrlTb );
3176 createTool( 6013, ctrlTb );
3177 createTool( 6014, ctrlTb );
3178 createTool( 6015, ctrlTb );
3179 createTool( 6016, ctrlTb );
3180 createTool( separator(), ctrlTb );
3181 createTool( 6017, ctrlTb );
3182 createTool( 6009, ctrlTb );
3183 createTool( 6021, ctrlTb );
3184 createTool( separator(), ctrlTb );
3186 createTool( 4000, addRemTb );
3187 createTool( 4009, addRemTb );
3188 createTool( 4010, addRemTb );
3189 createTool( 4021, addRemTb );
3190 createTool( 4022, addRemTb );
3191 createTool( 4023, addRemTb );
3192 createTool( 4031, addRemTb );
3193 createTool( 4032, addRemTb );
3194 createTool( 4033, addRemTb );
3195 createTool( separator(), addRemTb );
3196 createTool( 4034, addRemTb );
3197 createTool( 4035, addRemTb );
3198 createTool( 4036, addRemTb );
3199 createTool( 4037, addRemTb );
3200 createTool( 4038, addRemTb );
3201 createTool( 4039, addRemTb );
3202 createTool( 4040, addRemTb );
3203 createTool( separator(), addRemTb );
3204 createTool( 4041, addRemTb );
3205 createTool( 4042, addRemTb );
3206 createTool( 4043, addRemTb );
3207 createTool( separator(), addRemTb );
3208 createTool( 4051, addRemTb );
3209 createTool( 4052, addRemTb );
3210 createTool( separator(), addRemTb );
3211 createTool( 4061, addRemTb );
3212 createTool( 4062, addRemTb );
3213 createTool( 4063, addRemTb );
3214 createTool( 4064, addRemTb );
3215 createTool( 4065, addRemTb );
3216 createTool( 4066, addRemTb );
3217 createTool( 4068, addRemTb );
3218 createTool( separator(), addRemTb );
3220 createTool( 406, modifyTb );
3221 createTool( 4067,modifyTb );
3222 createTool( 407, modifyTb );
3223 createTool( 408, modifyTb );
3224 createTool( 409, modifyTb );
3225 createTool( 410, modifyTb );
3226 createTool( 411, modifyTb );
3227 createTool( 412, modifyTb );
3228 createTool( 413, modifyTb );
3229 createTool( 416, modifyTb );
3230 createTool( 414, modifyTb );
3231 createTool( 415, modifyTb );
3232 createTool( 417, modifyTb );
3233 createTool( 418, modifyTb );
3235 createTool( 214, dispModeTb );
3237 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3238 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3241 QString OB = "'ObjectBrowser'",
3242 View = "'" + SVTK_Viewer::Type() + "'",
3244 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3245 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3246 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3247 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3248 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3249 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3250 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3251 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3252 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3253 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3254 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3256 mesh_group = mesh + " " + subMesh + " " + group,
3257 hyp_alg = hypo + " " + algo;
3259 // popup for object browser
3261 isInvisible("not( isVisible )"),
3262 isEmpty("numberOfNodes = 0"),
3263 isNotEmpty("numberOfNodes <> 0"),
3265 // has nodes, edges, etc in VISIBLE! actor
3266 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3267 hasElems("(count( elemTypes ) > 0)"),
3268 hasDifferentElems("(count( elemTypes ) > 1)"),
3269 hasElems0d("({'Elem0d'} in elemTypes)"),
3270 hasEdges("({'Edge'} in elemTypes)"),
3271 hasFaces("({'Face'} in elemTypes)"),
3272 hasVolumes("({'Volume'} in elemTypes)");
3274 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3275 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3276 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3277 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3278 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3279 createPopupItem( 803, OB, group ); // EDIT_GROUP
3280 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3282 popupMgr()->insert( separator(), -1, 0 );
3283 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3284 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3285 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3286 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3287 createPopupItem( 214, OB, mesh_group ); // UPDATE
3288 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3289 createPopupItem( 902, OB, mesh ); // STD_INFO
3290 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3291 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3292 popupMgr()->insert( separator(), -1, 0 );
3293 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3294 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3295 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3296 popupMgr()->insert( separator(), -1, 0 );
3297 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3298 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3299 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3300 popupMgr()->insert( separator(), -1, 0 );
3301 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3302 popupMgr()->insert( separator(), -1, 0 );
3303 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3304 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3305 popupMgr()->insert( separator(), -1, 0 );
3307 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3308 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3310 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3311 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3312 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3313 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3314 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3315 popupMgr()->insert( separator(), -1, 0 );
3318 createPopupItem( 803, View, group ); // EDIT_GROUP
3319 createPopupItem( 804, View, elems ); // ADD
3320 createPopupItem( 805, View, elems ); // REMOVE
3322 popupMgr()->insert( separator(), -1, 0 );
3323 createPopupItem( 214, View, mesh_group ); // UPDATE
3324 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3325 createPopupItem( 902, View, mesh ); // STD_INFO
3326 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3327 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3328 popupMgr()->insert( separator(), -1, 0 );
3330 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3331 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3332 popupMgr()->insert( separator(), -1, 0 );
3335 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3336 QString aType = QString( "%1type in {%2}" ).arg( lc );
3337 aType = aType.arg( mesh_group );
3338 QString aMeshInVTK = aClient + "&&" + aType;
3340 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3341 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3342 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3344 //-------------------------------------------------
3346 //-------------------------------------------------
3347 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3349 popupMgr()->insert( action( 9010 ), anId, -1 );
3350 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3351 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3353 popupMgr()->insert( action( 9011 ), anId, -1 );
3354 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3355 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3357 popupMgr()->insert( separator(), -1, -1 );
3359 //-------------------------------------------------
3361 //-------------------------------------------------
3362 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3364 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3365 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3366 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3368 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3369 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3370 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3372 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3373 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3374 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3376 popupMgr()->insert( separator(), anId, -1 );
3378 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3379 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3380 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3382 //-------------------------------------------------
3384 //-------------------------------------------------
3385 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3387 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3389 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3390 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3391 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3393 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3394 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3395 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3397 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3398 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3399 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3401 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3402 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3403 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3405 popupMgr()->insert( separator(), anId, -1 );
3407 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3408 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3411 //-------------------------------------------------
3412 // Representation of the 2D Quadratic elements
3413 //-------------------------------------------------
3414 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3415 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3416 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3417 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3419 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3420 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3421 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3423 //-------------------------------------------------
3424 // Orientation of faces
3425 //-------------------------------------------------
3426 popupMgr()->insert( action( 221 ), -1, -1 );
3427 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3428 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3430 //-------------------------------------------------
3432 //-------------------------------------------------
3433 popupMgr()->insert( action( 1132 ), -1, -1 );
3434 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3436 //-------------------------------------------------
3438 //-------------------------------------------------
3439 popupMgr()->insert( action( 1133 ), -1, -1 );
3440 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3442 //-------------------------------------------------
3444 //-------------------------------------------------
3445 popupMgr()->insert( action( 1134 ), -1, -1 );
3446 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3448 popupMgr()->insert( separator(), -1, -1 );
3450 //-------------------------------------------------
3452 //-------------------------------------------------
3454 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3455 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3456 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3457 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3459 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3461 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3462 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3464 popupMgr()->insert( separator(), anId, -1 );
3466 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3467 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3468 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3470 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3471 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3472 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3474 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3475 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3476 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3478 popupMgr()->insert( separator(), anId, -1 );
3480 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3481 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3482 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3484 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3485 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3486 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3488 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3489 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3490 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3492 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3493 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3494 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3496 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3497 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3498 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3500 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3501 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3502 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3504 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3505 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3506 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3508 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3509 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3510 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3512 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3513 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3514 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3516 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3517 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3518 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3520 popupMgr()->insert( separator(), anId, -1 );
3522 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3523 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3524 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3526 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3527 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3528 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3530 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3531 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3532 QtxPopupMgr::VisibleRule );
3533 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3535 popupMgr()->insert( separator(), anId, -1 );
3537 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3538 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3540 popupMgr()->insert( separator(), -1, -1 );
3542 //-------------------------------------------------
3544 //-------------------------------------------------
3545 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3546 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3547 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3548 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3550 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3551 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3553 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3554 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3556 popupMgr()->insert( separator(), -1, -1 );
3558 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3559 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3562 //================================================================================
3564 * \brief Return true if SMESH or GEOM objects are selected.
3565 * Is called form LightApp_Module::activateModule() which clear selection if
3566 * not isSelectionCompatible()
3568 //================================================================================
3570 bool SMESHGUI::isSelectionCompatible()
3572 bool isCompatible = true;
3573 SALOME_ListIO selected;
3574 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3575 Sel->selectedObjects( selected );
3577 SALOME_ListIteratorOfListIO It( selected );
3578 for ( ; isCompatible && It.More(); It.Next())
3580 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3581 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3583 return isCompatible;
3587 bool SMESHGUI::reusableOperation( const int id )
3589 // compute, evaluate and precompute are not reusable operations
3590 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3593 bool SMESHGUI::activateModule( SUIT_Study* study )
3595 bool res = SalomeApp_Module::activateModule( study );
3597 setMenuShown( true );
3598 setToolShown( true );
3600 // Reset actions accelerator keys
3601 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3602 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3603 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3605 action( 33)->setEnabled(true); // Delete: Key_Delete
3606 action(1101)->setEnabled(true); // Rename: Key_F2
3608 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3609 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3610 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3611 if ( _PTR(Study) aStudy = s->studyDS()) {
3612 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3613 updateObjBrowser(); // objects can be removed
3619 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3621 setMenuShown( false );
3622 setToolShown( false );
3624 EmitSignalCloseAllDialogs();
3626 // Unset actions accelerator keys
3627 action(111)->setShortcut(QKeySequence()); // Import DAT
3628 action(112)->setShortcut(QKeySequence()); // Import UNV
3629 action(113)->setShortcut(QKeySequence()); // Import MED
3631 action( 33)->setEnabled(false); // Delete: Key_Delete
3632 action(1101)->setEnabled(false); // Rename: Key_F2
3634 return SalomeApp_Module::deactivateModule( study );
3637 void SMESHGUI::studyClosed( SUIT_Study* s )
3639 SMESH::RemoveVisuData( s->id() );
3640 SalomeApp_Module::studyClosed( s );
3643 void SMESHGUI::OnGUIEvent()
3645 const QObject* obj = sender();
3646 if ( !obj || !obj->inherits( "QAction" ) )
3648 int id = actionId((QAction*)obj);
3653 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3655 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3656 if ( CORBA::is_nil( myComponentSMESH ) )
3658 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3660 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3661 return aGUI.myComponentSMESH;
3664 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3665 return myComponentSMESH;
3668 QString SMESHGUI::engineIOR() const
3670 CORBA::ORB_var anORB = getApp()->orb();
3671 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3672 return QString( anIOR.in() );
3675 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3677 SalomeApp_Module::contextMenuPopup( client, menu, title );
3679 selectionMgr()->selectedObjects( lst );
3680 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3681 Handle(SALOME_InteractiveObject) io = lst.First();
3682 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3683 _PTR(Study) study = appStudy->studyDS();
3684 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3686 QString aName = QString( obj->GetName().c_str() );
3687 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3688 aName.remove( (aName.length() - 1), 1 );
3694 LightApp_Selection* SMESHGUI::createSelection() const
3696 return new SMESHGUI_Selection();
3699 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3701 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3702 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3705 void SMESHGUI::viewManagers( QStringList& list ) const
3707 list.append( SVTK_Viewer::Type() );
3710 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3712 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3713 SMESH::UpdateSelectionProp( this );
3716 void SMESHGUI::createPreferences()
3718 // General tab ------------------------------------------------------------------------
3719 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3721 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3722 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3724 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3725 setPreferenceProperty( qaGroup, "columns", 2 );
3726 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3727 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3728 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3729 setPreferenceProperty( prec, "min", 0 );
3730 setPreferenceProperty( prec, "max", 16 );
3732 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3733 setPreferenceProperty( dispgroup, "columns", 2 );
3734 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3736 modes.append( "Wireframe" );
3737 modes.append( "Shading" );
3738 modes.append( "Nodes" );
3739 modes.append( "Shrink" );
3740 QList<QVariant> indices;
3741 indices.append( 0 );
3742 indices.append( 1 );
3743 indices.append( 2 );
3744 indices.append( 3 );
3745 setPreferenceProperty( dispmode, "strings", modes );
3746 setPreferenceProperty( dispmode, "indexes", indices );
3748 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3749 setPreferenceProperty( arcgroup, "columns", 2 );
3750 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3751 QStringList quadraticModes;
3752 quadraticModes.append("Lines");
3753 quadraticModes.append("Arcs");
3755 indices.append( 0 );
3756 indices.append( 1 );
3757 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3758 setPreferenceProperty( quadraticmode, "indexes", indices );
3760 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3761 "SMESH", "max_angle" );
3762 setPreferenceProperty( maxAngle, "min", 1 );
3763 setPreferenceProperty( maxAngle, "max", 90 );
3767 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3768 setPreferenceProperty( exportgroup, "columns", 2 );
3769 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3770 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3772 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3773 setPreferenceProperty( computeGroup, "columns", 2 );
3774 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3776 modes.append( "Never" );
3777 modes.append( "Errors only" );
3778 modes.append( "Always" );
3780 indices.append( 0 );
3781 indices.append( 1 );
3782 indices.append( 2 );
3783 setPreferenceProperty( notifyMode, "strings", modes );
3784 setPreferenceProperty( notifyMode, "indexes", indices );
3786 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3787 setPreferenceProperty( segGroup, "columns", 2 );
3788 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3789 "SMESH", "segmentation" );
3790 setPreferenceProperty( segLen, "min", 1 );
3791 setPreferenceProperty( segLen, "max", 10000000 );
3792 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3793 "SMESH", "nb_segments_per_edge" );
3794 setPreferenceProperty( nbSeg, "min", 1 );
3795 setPreferenceProperty( nbSeg, "max", 10000000 );
3797 // Mesh tab ------------------------------------------------------------------------
3798 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3799 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3800 setPreferenceProperty( nodeGroup, "columns", 2 );
3802 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3803 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3805 setPreferenceProperty( nodeSz, "min", 1 );
3806 setPreferenceProperty( nodeSz, "max", 5 );
3808 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3809 setPreferenceProperty( elemGroup, "columns", 2 );
3811 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3812 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3813 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3814 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3816 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3817 //setPreferenceProperty( sp, "hstretch", 0 );
3818 //setPreferenceProperty( sp, "vstretch", 0 );
3820 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3821 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3822 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3823 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3824 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3825 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3826 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3828 setPreferenceProperty( size0d, "min", 1 );
3829 setPreferenceProperty( size0d, "max", 10 );
3831 setPreferenceProperty( sp, "hstretch", 0 );
3832 setPreferenceProperty( sp, "vstretch", 0 );
3834 setPreferenceProperty( elemW, "min", 1 );
3835 setPreferenceProperty( elemW, "max", 5 );
3837 setPreferenceProperty( shrink, "min", 0 );
3838 setPreferenceProperty( shrink, "max", 100 );
3840 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3841 setPreferenceProperty( orientGroup, "columns", 1 );
3843 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3844 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3846 setPreferenceProperty( orientScale, "min", 0.05 );
3847 setPreferenceProperty( orientScale, "max", 0.5 );
3848 setPreferenceProperty( orientScale, "step", 0.05 );
3850 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3852 // Selection tab ------------------------------------------------------------------------
3853 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3855 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3856 setPreferenceProperty( selGroup, "columns", 2 );
3858 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3859 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3860 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3862 setPreferenceProperty( selW, "min", 1 );
3863 setPreferenceProperty( selW, "max", 5 );
3865 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3866 setPreferenceProperty( preGroup, "columns", 2 );
3868 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3869 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3871 setPreferenceProperty( preW, "min", 1 );
3872 setPreferenceProperty( preW, "max", 5 );
3874 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3875 setPreferenceProperty( precSelGroup, "columns", 2 );
3877 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3878 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3879 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3881 // Scalar Bar tab ------------------------------------------------------------------------
3882 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3883 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3884 setPreferenceProperty( fontGr, "columns", 2 );
3886 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3887 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3889 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3890 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3892 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3893 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3895 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3896 setPreferenceProperty( numcol, "min", 2 );
3897 setPreferenceProperty( numcol, "max", 256 );
3899 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3900 setPreferenceProperty( numlab, "min", 2 );
3901 setPreferenceProperty( numlab, "max", 65 );
3903 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3904 setPreferenceProperty( orientGr, "columns", 2 );
3905 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3906 QStringList orients;
3907 orients.append( tr( "SMESH_VERTICAL" ) );
3908 orients.append( tr( "SMESH_HORIZONTAL" ) );
3909 indices.clear(); indices.append( 0 ); indices.append( 1 );
3910 setPreferenceProperty( orient, "strings", orients );
3911 setPreferenceProperty( orient, "indexes", indices );
3913 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3914 setPreferenceProperty( posVSizeGr, "columns", 2 );
3915 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3916 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3917 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3918 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3919 setPreferenceProperty( xv, "step", 0.1 );
3920 setPreferenceProperty( xv, "min", 0.0 );
3921 setPreferenceProperty( xv, "max", 1.0 );
3922 setPreferenceProperty( yv, "step", 0.1 );
3923 setPreferenceProperty( yv, "min", 0.0 );
3924 setPreferenceProperty( yv, "max", 1.0 );
3925 setPreferenceProperty( wv, "step", 0.1 );
3926 setPreferenceProperty( wv, "min", 0.0 );
3927 setPreferenceProperty( wv, "max", 1.0 );
3928 setPreferenceProperty( hv, "min", 0.0 );
3929 setPreferenceProperty( hv, "max", 1.0 );
3930 setPreferenceProperty( hv, "step", 0.1 );
3932 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3933 setPreferenceProperty( posHSizeGr, "columns", 2 );
3934 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3935 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3936 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3937 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3938 setPreferenceProperty( xv, "min", 0.0 );
3939 setPreferenceProperty( xv, "max", 1.0 );
3940 setPreferenceProperty( xv, "step", 0.1 );
3941 setPreferenceProperty( xh, "min", 0.0 );
3942 setPreferenceProperty( xh, "max", 1.0 );
3943 setPreferenceProperty( xh, "step", 0.1 );
3944 setPreferenceProperty( yh, "min", 0.0 );
3945 setPreferenceProperty( yh, "max", 1.0 );
3946 setPreferenceProperty( yh, "step", 0.1 );
3947 setPreferenceProperty( wh, "min", 0.0 );
3948 setPreferenceProperty( wh, "max", 1.0 );
3949 setPreferenceProperty( wh, "step", 0.1 );
3950 setPreferenceProperty( hh, "min", 0.0 );
3951 setPreferenceProperty( hh, "max", 1.0 );
3952 setPreferenceProperty( hh, "step", 0.1 );
3955 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3957 if( sect=="SMESH" ) {
3958 float sbX1,sbY1,sbW,sbH;
3959 float aTol = 1.00000009999999;
3960 std::string aWarning;
3961 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3962 if( name=="selection_object_color" || name=="selection_element_color" ||
3963 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3964 name=="selection_precision_node" || name=="selection_precision_element" ||
3965 name=="selection_precision_object")
3966 SMESH::UpdateSelectionProp( this );
3967 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3968 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3969 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3970 if(sbX1+sbW > aTol){
3971 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3974 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3975 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3978 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3979 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3980 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3981 if(sbY1+sbH > aTol){
3982 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3983 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3984 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3987 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3988 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3989 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3990 if(sbX1+sbW > aTol){
3991 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3994 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3995 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3998 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3999 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4000 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4001 if(sbY1+sbH > aTol){
4002 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4005 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4006 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4009 else if ( name == "segmentation" ) {
4010 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4011 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4013 else if ( name == "nb_segments_per_edge" ) {
4014 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4015 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4018 if(aWarning.size() != 0){
4019 aWarning += "The default values are applied instead.";
4020 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4021 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4022 QObject::tr(aWarning.c_str()));
4027 //================================================================================
4029 * \brief Update something in accordance with update flags
4030 * \param theFlags - update flags
4032 * Update viewer or/and object browser etc. in accordance with update flags ( see
4033 * LightApp_UpdateFlags enumeration ).
4035 //================================================================================
4036 void SMESHGUI::update( const int flags )
4038 if ( flags & UF_Viewer | flags & UF_Forced )
4039 SMESH::UpdateView();
4041 SalomeApp_Module::update( flags );
4044 //================================================================================
4046 * \brief Set default selection mode
4048 * SLOT called when operation commited. Sets default selection mode
4050 //================================================================================
4051 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4053 SVTK_ViewWindow* vtkWnd =
4054 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4056 vtkWnd->SetSelectionMode( ActorSelection );
4059 //================================================================================
4061 * \brief Set default selection mode
4063 * SLOT called when operation aborted. Sets default selection mode
4065 //================================================================================
4066 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4068 SVTK_ViewWindow* vtkWnd =
4069 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4071 vtkWnd->SetSelectionMode( ActorSelection );
4074 //================================================================================
4076 * \brief Creates operation with given identifier
4077 * \param id - identifier of operation to be started
4078 * \return Pointer on created operation or NULL if operation is not created
4080 * Virtual method redefined from the base class creates operation with given id.
4081 * It is called called automatically from startOperation method of base class.
4083 //================================================================================
4084 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4086 LightApp_Operation* op = 0;
4087 // to do : create operation here
4090 case 417: //convert to quadratic
4091 op = new SMESHGUI_ConvToQuadOp();
4093 case 418: // create 2D mesh as boundary on 3D
4094 op = new SMESHGUI_Make2DFrom3DOp();
4096 case 701: // Compute mesh
4097 op = new SMESHGUI_ComputeOp();
4099 case 702: // Create mesh
4100 op = new SMESHGUI_MeshOp( true, true );
4102 case 703: // Create sub-mesh
4103 op = new SMESHGUI_MeshOp( true, false );
4105 case 704: // Edit mesh/sub-mesh
4106 op = new SMESHGUI_MeshOp( false );
4108 case 711: // Precompute mesh
4109 op = new SMESHGUI_PrecomputeOp();
4111 case 712: // Evaluate mesh
4112 op = new SMESHGUI_EvaluateOp();
4114 case 713: // Evaluate mesh
4115 op = new SMESHGUI_MeshOrderOp();
4117 case 806: // Create group on geom
4118 op = new SMESHGUI_GroupOnShapeOp();
4120 case 904: // Find element
4121 op = new SMESHGUI_FindElemByPointOp();
4123 case 4067: // make mesh pass through point
4124 op = new SMESHGUI_MakeNodeAtPointOp();
4131 op = SalomeApp_Module::createOperation( id );
4135 //================================================================================
4137 * \brief Stops current operations and starts a given one
4138 * \param id - The id of the operation to start
4140 //================================================================================
4142 void SMESHGUI::switchToOperation(int id)
4144 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4145 activeStudy()->abortAllOperations();
4146 startOperation( id );
4149 LightApp_Displayer* SMESHGUI::displayer()
4152 myDisplayer = new SMESHGUI_Displayer( getApp() );
4156 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4159 int aTolerance = 64;
4160 int anIterations = 0;
4166 if( anIterations % aPeriod == 0 )
4169 if( aTolerance < 1 )
4172 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4174 aHue = (int)( 360.0 * rand() / RAND_MAX );
4175 //cout << "Hue = " << aHue << endl;
4177 //cout << "Auto colors : ";
4179 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4180 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4181 for( ; it != itEnd; ++it )
4183 SALOMEDS::Color anAutoColor = *it;
4184 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4187 aQColor.getHsv( &h, &s, &v );
4189 if( abs( h - aHue ) < aTolerance )
4192 //cout << "break (diff = " << abs( h - aHue ) << ")";
4202 //cout << "Hue of the returned color = " << aHue << endl;
4204 aColor.setHsv( aHue, 255, 255 );
4206 SALOMEDS::Color aSColor;
4207 aSColor.R = (double)aColor.red() / 255.0;
4208 aSColor.G = (double)aColor.green() / 255.0;
4209 aSColor.B = (double)aColor.blue() / 255.0;
4214 const char gSeparator = '_'; // character used to separate parameter names
4215 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4218 * \brief Store visual parameters
4220 * This method is called just before the study document is saved.
4221 * Store visual parameters in AttributeParameter attribue(s)
4223 void SMESHGUI::storeVisualParameters (int savePoint)
4225 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4226 if (!appStudy || !appStudy->studyDS())
4228 _PTR(Study) studyDS = appStudy->studyDS();
4230 // componentName is used for encoding of entries when storing them in IParameters
4231 std::string componentName = myComponentSMESH->ComponentDataType();
4232 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4233 //if (!aSComponent) return;
4236 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4237 componentName.c_str(),
4239 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4241 // viewers counters are used for storing view_numbers in IParameters
4244 // main cycle to store parameters of displayed objects
4245 QList<SUIT_ViewManager*> lst;
4246 QList<SUIT_ViewManager*>::Iterator it;
4247 getApp()->viewManagers(lst);
4248 for (it = lst.begin(); it != lst.end(); it++)
4250 SUIT_ViewManager* vman = *it;
4251 QString vType = vman->getType();
4253 // saving VTK actors properties
4254 if (vType == SVTK_Viewer::Type())
4256 QVector<SUIT_ViewWindow*> views = vman->getViews();
4257 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4259 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4261 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4262 vtkActorCollection* allActors = aCopy.GetActors();
4263 allActors->InitTraversal();
4264 while (vtkActor* actor = allActors->GetNextActor())
4266 if (actor->GetVisibility()) // store only visible actors
4268 SMESH_Actor* aSmeshActor = 0;
4269 if (actor->IsA("SMESH_Actor"))
4270 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4271 if (aSmeshActor && aSmeshActor->hasIO())
4273 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4276 // entry is "encoded" = it does NOT contain component adress,
4277 // since it is a subject to change on next component loading
4278 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4280 std::string param, vtkParam = vType.toLatin1().data();
4281 vtkParam += gSeparator;
4282 vtkParam += QString::number(vtkViewers).toLatin1().data();
4283 vtkParam += gSeparator;
4286 param = vtkParam + "Visibility";
4287 ip->setParameter(entry, param, "On");
4290 param = vtkParam + "Representation";
4291 ip->setParameter(entry, param, QString::number
4292 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4295 param = vtkParam + "IsShrunk";
4296 ip->setParameter(entry, param, QString::number
4297 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4299 // Displayed entities
4300 unsigned int aMode = aSmeshActor->GetEntityMode();
4301 bool isE = aMode & SMESH_Actor::eEdges;
4302 bool isF = aMode & SMESH_Actor::eFaces;
4303 bool isV = aMode & SMESH_Actor::eVolumes;
4305 QString modeStr ("e");
4306 modeStr += gDigitsSep; modeStr += QString::number(isE);
4307 modeStr += gDigitsSep; modeStr += "f";
4308 modeStr += gDigitsSep; modeStr += QString::number(isF);
4309 modeStr += gDigitsSep; modeStr += "v";
4310 modeStr += gDigitsSep; modeStr += QString::number(isV);
4312 param = vtkParam + "Entities";
4313 ip->setParameter(entry, param, modeStr.toLatin1().data());
4315 // Colors (surface:edge:)
4316 vtkFloatingPointType r, g, b;
4318 aSmeshActor->GetSufaceColor(r, g, b);
4319 QString colorStr ("surface");
4320 colorStr += gDigitsSep; colorStr += QString::number(r);
4321 colorStr += gDigitsSep; colorStr += QString::number(g);
4322 colorStr += gDigitsSep; colorStr += QString::number(b);
4324 aSmeshActor->GetBackSufaceColor(r, g, b);
4325 colorStr += gDigitsSep; colorStr += "backsurface";
4326 colorStr += gDigitsSep; colorStr += QString::number(r);
4327 colorStr += gDigitsSep; colorStr += QString::number(g);
4328 colorStr += gDigitsSep; colorStr += QString::number(b);
4330 aSmeshActor->GetEdgeColor(r, g, b);
4331 colorStr += gDigitsSep; colorStr += "edge";
4332 colorStr += gDigitsSep; colorStr += QString::number(r);
4333 colorStr += gDigitsSep; colorStr += QString::number(g);
4334 colorStr += gDigitsSep; colorStr += QString::number(b);
4336 aSmeshActor->GetNodeColor(r, g, b);
4337 colorStr += gDigitsSep; colorStr += "node";
4338 colorStr += gDigitsSep; colorStr += QString::number(r);
4339 colorStr += gDigitsSep; colorStr += QString::number(g);
4340 colorStr += gDigitsSep; colorStr += QString::number(b);
4342 param = vtkParam + "Colors";
4343 ip->setParameter(entry, param, colorStr.toLatin1().data());
4345 // Sizes of lines and points
4346 QString sizeStr ("line");
4347 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4348 sizeStr += gDigitsSep; sizeStr += "node";
4349 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
4350 sizeStr += gDigitsSep; sizeStr += "shrink";
4351 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4353 param = vtkParam + "Sizes";
4354 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4357 param = vtkParam + "Opacity";
4358 ip->setParameter(entry, param,
4359 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4362 param = vtkParam + "ClippingPlane";
4363 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4365 ip->setParameter(entry, param, "Off");
4366 for (int ipl = 0; ipl < nPlanes; ipl++) {
4367 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4368 SMESH::Orientation anOrientation;
4370 vtkFloatingPointType anAngle[2];
4371 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4372 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4373 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4374 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4375 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4377 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4379 } // if (io->hasEntry())
4380 } // SMESH_Actor && hasIO
4382 } // while.. actors traversal
4386 } // if (SVTK view model)
4387 } // for (viewManagers)
4391 * \brief Restore visual parameters
4393 * This method is called after the study document is opened.
4394 * Restore visual parameters from AttributeParameter attribue(s)
4396 void SMESHGUI::restoreVisualParameters (int savePoint)
4398 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4399 if (!appStudy || !appStudy->studyDS())
4401 _PTR(Study) studyDS = appStudy->studyDS();
4403 // componentName is used for encoding of entries when storing them in IParameters
4404 std::string componentName = myComponentSMESH->ComponentDataType();
4405 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4406 //if (!aSComponent) return;
4409 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4410 componentName.c_str(),
4412 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4414 std::vector<std::string> entries = ip->getEntries();
4416 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4418 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4419 QString entry (ip->decodeEntry(*entIt).c_str());
4421 // Check that the entry corresponds to a real object in the Study
4422 // as the object may be deleted or modified after the visual state is saved.
4423 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4424 if (!so) continue; //Skip the not existent entry
4426 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4427 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4429 std::vector<std::string>::iterator namesIt = paramNames.begin();
4430 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4432 // actors are stored in a map after displaying of them for
4433 // quicker access in the future: map < viewID to actor >
4434 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4436 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4438 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4439 // '_' is used as separator and should not be used in viewer type or parameter names.
4440 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4441 if (lst.size() != 3)
4444 QString viewerTypStr = lst[0];
4445 QString viewIndexStr = lst[1];
4446 QString paramNameStr = lst[2];
4449 int viewIndex = viewIndexStr.toUInt(&ok);
4450 if (!ok) // bad conversion of view index to integer
4454 if (viewerTypStr == SVTK_Viewer::Type())
4456 SMESH_Actor* aSmeshActor = 0;
4457 if (vtkActors.IsBound(viewIndex))
4458 aSmeshActor = vtkActors.Find(viewIndex);
4460 if (paramNameStr == "Visibility")
4462 if (!aSmeshActor && displayer())
4464 QList<SUIT_ViewManager*> lst;
4465 getApp()->viewManagers(viewerTypStr, lst);
4467 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4468 if (viewIndex >= 0 && viewIndex < lst.count()) {
4469 SUIT_ViewManager* vman = lst.at(viewIndex);
4470 SUIT_ViewModel* vmodel = vman->getViewModel();
4471 // SVTK view model can be casted to SALOME_View
4472 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4474 // store displayed actor in a temporary map for quicker
4475 // access later when restoring other parameters
4476 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4477 vtkRenderer* Renderer = vtkView->getRenderer();
4478 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4479 vtkActorCollection* theActors = aCopy.GetActors();
4480 theActors->InitTraversal();
4481 bool isFound = false;
4482 vtkActor *ac = theActors->GetNextActor();
4483 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4484 if (ac->IsA("SMESH_Actor")) {
4485 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4486 if (aGeomAc->hasIO()) {
4487 Handle(SALOME_InteractiveObject) io =
4488 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4489 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4491 vtkActors.Bind(viewIndex, aGeomAc);
4498 } // if (paramNameStr == "Visibility")
4501 // the rest properties "work" with SMESH_Actor
4504 QString val ((*valuesIt).c_str());
4507 if (paramNameStr == "Representation") {
4508 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4511 else if (paramNameStr == "IsShrunk") {
4513 if (!aSmeshActor->IsShrunk())
4514 aSmeshActor->SetShrink();
4517 if (aSmeshActor->IsShrunk())
4518 aSmeshActor->UnShrink();
4521 // Displayed entities
4522 else if (paramNameStr == "Entities") {
4523 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4524 if (mode.count() == 6) {
4525 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4526 MESSAGE("Invalid order of data in Entities, must be: "
4527 "e:0/1:f:0/1:v:0/1");
4530 unsigned int aMode = aSmeshActor->GetEntityMode();
4531 unsigned int aNewMode =
4532 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4533 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4534 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4535 if (aNewMode != aMode)
4536 aSmeshActor->SetEntityMode(aNewMode);
4541 else if (paramNameStr == "Colors") {
4542 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4543 if (colors.count() == 16) {
4544 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4545 colors[8] != "edge" || colors[12] != "node") {
4546 MESSAGE("Invalid order of data in Colors, must be: "
4547 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4550 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4551 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4552 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4553 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4557 // Sizes of lines and points
4558 else if (paramNameStr == "Sizes") {
4559 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4560 if (sizes.count() == 6) {
4561 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4562 MESSAGE("Invalid order of data in Sizes, must be: "
4563 "line:int:node:int:shrink:float");
4566 aSmeshActor->SetLineWidth(sizes[1].toInt());
4567 aSmeshActor->SetNodeSize(sizes[3].toInt());
4568 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4573 else if (paramNameStr == "Opacity") {
4574 aSmeshActor->SetOpacity(val.toFloat());
4577 else if (paramNameStr.startsWith("ClippingPlane")) {
4578 cout << "$$$ ClippingPlane 1" << endl;
4579 if (paramNameStr == "ClippingPlane1" || val == "Off")
4580 aSmeshActor->RemoveAllClippingPlanes();
4582 cout << "$$$ ClippingPlane 2" << endl;
4583 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4584 if (vals.count() == 4) { // format check: 4 values
4585 cout << "$$$ ClippingPlane 3" << endl;
4586 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4587 double aDistance = vals[1].toFloat();
4588 vtkFloatingPointType anAngle[2];
4589 anAngle[0] = vals[2].toFloat();
4590 anAngle[1] = vals[3].toFloat();
4592 QList<SUIT_ViewManager*> lst;
4593 getApp()->viewManagers(viewerTypStr, lst);
4594 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4595 if (viewIndex >= 0 && viewIndex < lst.count()) {
4596 SUIT_ViewManager* vman = lst.at(viewIndex);
4597 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4598 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4599 anOrientation, aDistance, anAngle);
4604 } // if (aSmeshActor)
4605 } // other parameters than Visibility
4607 } // for names/parameters iterator
4608 } // for entries iterator
4610 // update all VTK views
4611 QList<SUIT_ViewManager*> lst;
4612 getApp()->viewManagers(lst);
4613 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4614 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4615 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4616 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4617 vtkView->getRenderer()->ResetCameraClippingRange();
4624 \brief Adds preferences for dfont of VTK viewer
4626 \param pIf group identifier
4627 \param param parameter
4628 \return identifier of preferences
4630 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4632 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4634 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4637 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4638 fam.append( tr( "SMESH_FONT_COURIER" ) );
4639 fam.append( tr( "SMESH_FONT_TIMES" ) );
4641 setPreferenceProperty( tfont, "fonts", fam );
4643 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4644 setPreferenceProperty( tfont, "features", f );
4650 \brief Actions after hypothesis edition
4651 Updates object browser after hypothesis edition
4653 void SMESHGUI::onHypothesisEdit( int result )
4655 updateObjBrowser( true );