1 // Copyright (C) 2007-2010 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
29 #include "SMESHGUI_AddMeshElementDlg.h"
30 #include "SMESHGUI_AddQuadraticElementDlg.h"
31 #include "SMESHGUI_BuildCompoundDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_ComputeDlg.h"
34 #include "SMESHGUI_ConvToQuadOp.h"
35 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
36 #include "SMESHGUI_DeleteGroupDlg.h"
37 #include "SMESHGUI_Displayer.h"
38 #include "SMESHGUI_EditMeshDlg.h"
39 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
40 #include "SMESHGUI_ExtrusionDlg.h"
41 #include "SMESHGUI_FileInfoDlg.h"
42 #include "SMESHGUI_FileValidator.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_FindElemByPointDlg.h"
46 #include "SMESHGUI_GroupDlg.h"
47 #include "SMESHGUI_GroupOnShapeDlg.h"
48 #include "SMESHGUI_GroupOpDlg.h"
49 #include "SMESHGUI_Hypotheses.h"
50 #include "SMESHGUI_Make2DFrom3DOp.h"
51 #include "SMESHGUI_MakeNodeAtPointDlg.h"
52 #include "SMESHGUI_MeshInfosDlg.h"
53 #include "SMESHGUI_MeshOp.h"
54 #include "SMESHGUI_MeshOrderOp.h"
55 #include "SMESHGUI_MeshPatternDlg.h"
56 #include "SMESHGUI_MoveNodesDlg.h"
57 #include "SMESHGUI_MultiEditDlg.h"
58 #include "SMESHGUI_NodesDlg.h"
59 #include "SMESHGUI_Preferences_ColorDlg.h"
60 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
61 #include "SMESHGUI_RemoveElementsDlg.h"
62 #include "SMESHGUI_RemoveNodesDlg.h"
63 #include "SMESHGUI_RenumberingDlg.h"
64 #include "SMESHGUI_RevolutionDlg.h"
65 #include "SMESHGUI_RotationDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_SewingDlg.h"
68 #include "SMESHGUI_SingleEditDlg.h"
69 #include "SMESHGUI_SmoothingDlg.h"
70 #include "SMESHGUI_StandardMeshInfosDlg.h"
71 #include "SMESHGUI_SymmetryDlg.h"
72 #include "SMESHGUI_TranslationDlg.h"
73 #include "SMESHGUI_ScaleDlg.h"
74 #include "SMESHGUI_TransparencyDlg.h"
75 #include "SMESHGUI_WhatIsDlg.h"
77 #include "SMESHGUI_Utils.h"
78 #include "SMESHGUI_MeshUtils.h"
79 #include "SMESHGUI_GroupUtils.h"
80 #include "SMESHGUI_FilterUtils.h"
81 #include "SMESHGUI_PatternUtils.h"
82 #include "SMESHGUI_VTKUtils.h"
83 #include "SMESHGUI_HypothesesUtils.h"
85 #include <SMESH_Client.hxx>
86 #include <SMESH_Actor.h>
87 #include <SMESH_TypeFilter.hxx>
89 // SALOME GUI includes
90 #include <SalomeApp_Tools.h>
91 #include <SalomeApp_Study.h>
92 #include <SalomeApp_Application.h>
93 #include <SalomeApp_CheckFileDlg.h>
95 #include <LightApp_DataOwner.h>
96 #include <LightApp_Preferences.h>
97 #include <LightApp_SelectionMgr.h>
98 #include <LightApp_UpdateFlags.h>
99 #include <LightApp_NameDlg.h>
101 #include <SVTK_ViewWindow.h>
102 #include <SVTK_ViewModel.h>
103 #include <SVTK_ViewManager.h>
105 #include <VTKViewer_Algorithm.h>
107 #include <SUIT_MessageBox.h>
108 #include <SUIT_ResourceMgr.h>
109 #include <SUIT_FileDlg.h>
110 #include <SUIT_Desktop.h>
111 #include <SUIT_OverrideCursor.h>
112 #include <SUIT_Session.h>
114 #include <QtxPopupMgr.h>
115 #include <QtxFontEdit.h>
117 #include <SALOME_ListIO.hxx>
118 #include <SALOME_ListIteratorOfListIO.hxx>
121 #include <SALOMEconfig.h>
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
126 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
130 #include <boost/shared_ptr.hpp>
133 #include <vtkScalarBarActor.h>
134 #include <vtkCamera.h>
135 #include <vtkRenderer.h>
136 #include <vtkPlane.h>
138 // SALOME KERNEL includes
139 #include <SALOMEDS_Study.hxx>
140 #include <SALOMEDSClient_StudyBuilder.hxx>
141 #include <SALOMEDSClient_SComponent.hxx>
142 #include <SALOMEDSClient_ClientFactory.hxx>
143 #include <SALOMEDSClient_IParameters.hxx>
146 #include <Standard_ErrorHandler.hxx>
147 #include <NCollection_DataMap.hxx>
151 //=============================================================
152 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
155 void ExportMeshToFile(int theCommandID);
157 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
159 void SetDisplayEntity(int theCommandID);
161 void Control( int theCommandID );
165 //=============================================================
166 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
170 std::string myExtension;
172 if ( theCommandID == 113 ) {
173 filter.append( QObject::tr( "MED files (*.med)" ) );
174 filter.append( QObject::tr( "All files (*)" ) );
176 else if ( theCommandID == 112 ) {
177 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
179 else if ( theCommandID == 111 ) {
180 filter.append( QObject::tr( "DAT files (*.dat)" ) );
183 QString anInitialPath = "";
184 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
185 anInitialPath = QDir::currentPath();
187 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
190 QObject::tr( "SMESH_IMPORT_MESH" ) );
191 if ( filenames.count() > 0 ) {
192 SUIT_OverrideCursor wc;
193 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
196 bool isEmpty = false;
197 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
198 QString filename = *it;
199 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
201 switch ( theCommandID ) {
204 // DAT format (currently unsupported)
205 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
206 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
212 aMeshes->length( 1 );
213 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
214 if ( aMeshes[0]->_is_nil() )
215 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
216 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
222 SMESH::DriverMED_ReadStatus res;
223 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
224 if ( res != SMESH::DRS_OK ) {
225 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
226 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
232 catch ( const SALOME::SALOME_Exception& S_ex ) {
233 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
234 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
237 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
238 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
240 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
241 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
242 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
243 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
244 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
252 // update Object browser
253 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
255 // show Error message box if there were errors
256 if ( errors.count() > 0 ) {
257 SUIT_MessageBox::critical( SMESHGUI::desktop(),
258 QObject::tr( "SMESH_ERROR" ),
259 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
262 // show warning message box, if some imported mesh is empty
264 SUIT_MessageBox::warning( SMESHGUI::desktop(),
265 QObject::tr( "SMESH_WRN_WARNING" ),
266 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
271 void ExportMeshToFile( int theCommandID )
273 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
274 SALOME_ListIO selected;
276 aSel->selectedObjects( selected );
278 // actually, the following condition can't be met (added for insurance)
279 if( selected.Extent() == 0 ||
280 selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 )
283 bool hasDuplicatedMeshNames = false;
284 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
285 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
286 SALOME_ListIteratorOfListIO It( selected );
287 for( ; It.More(); It.Next() ) {
288 Handle(SALOME_InteractiveObject) anIObject = It.Value();
289 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
290 if ( aMeshItem->_is_nil() ) {
291 SUIT_MessageBox::warning( SMESHGUI::desktop(),
292 QObject::tr( "SMESH_WRN_WARNING" ),
293 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
297 QString aMeshName = anIObject->getName();
299 // check for duplications
300 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
301 if( aMeshName == (*aMeshIter).second ) {
302 hasDuplicatedMeshNames = true;
307 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
310 if( hasDuplicatedMeshNames ) {
311 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
312 QObject::tr("SMESH_WRN_WARNING"),
313 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
314 QObject::tr("SMESH_BUT_YES"),
315 QObject::tr("SMESH_BUT_NO"), 0, 1);
320 aMeshIter = aMeshList.begin();
321 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
322 QString aMeshName = (*aMeshIter).second;
324 QList<SALOMEDS::Color> aReservedColors;
326 QString aFilter, aTitle = QObject::tr("Export mesh");
327 QMap<QString, SMESH::MED_VERSION> aFilterMap;
328 QMap<QString, int> aFilterMapSTL;
329 switch ( theCommandID ) {
333 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
334 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
335 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
336 int aRet = SUIT_MessageBox::warning
337 (SMESHGUI::desktop(),
338 QObject::tr("SMESH_WRN_WARNING"),
339 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
340 QObject::tr("SMESH_BUT_YES"),
341 QObject::tr("SMESH_BUT_NO"), 0, 1);
347 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
348 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
349 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
350 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
355 aFilter = QObject::tr("DAT files (*.dat)");
360 if (aMesh->NbPyramids()) {
361 int aRet = SUIT_MessageBox::warning
362 (SMESHGUI::desktop(),
363 QObject::tr("SMESH_WRN_WARNING"),
364 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
365 QObject::tr("SMESH_BUT_YES"),
366 QObject::tr("SMESH_BUT_NO"), 0, 1);
370 aFilter = QObject::tr("IDEAS files (*.unv)");
378 there must be check on others mesh elements not equal triangles
380 if (aMesh->NbTriangles() < 1) {
381 SUIT_MessageBox::warning
382 (SMESHGUI::desktop(),
383 QObject::tr("SMESH_WRN_WARNING"),
384 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
387 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
388 int aRet = SUIT_MessageBox::warning
389 (SMESHGUI::desktop(),
390 QObject::tr("SMESH_WRN_WARNING"),
391 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
392 QObject::tr("SMESH_BUT_YES"),
393 QObject::tr("SMESH_BUT_NO"), 0, 1);
398 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
399 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
407 SMESH::MED_VERSION aFormat;
408 // Init the parameter with the default value
409 bool aIsASCII_STL = true;
410 bool toCreateGroups = false;
411 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
413 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
414 bool toOverwrite = true;
416 QString anInitialPath = "";
417 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
418 anInitialPath = QDir::currentPath();
420 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
421 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
422 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
423 aFilter, aTitle, false);
425 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
427 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
428 for ( ; it != aFilterMapSTL.end(); ++it )
429 filters.push_back( it.key() );
431 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
432 fd->setWindowTitle( aTitle );
433 fd->setNameFilters( filters );
434 fd->selectNameFilter( QObject::tr("STL ASCII (*.stl)") );
435 if ( !anInitialPath.isEmpty() )
436 fd->setDirectory( anInitialPath );
437 fd->selectFile(aMeshName);
441 aFilename = fd->selectedFile();
442 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
447 else { // Export to MED
449 QString aDefaultFilter;
450 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
451 for ( ; it != aFilterMap.end(); ++it ) {
452 filters.push_back( it.key() );
453 if (it.value() == SMESH::MED_V2_2)
454 aDefaultFilter = it.key();
457 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
458 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
459 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
460 fd->setWindowTitle( aTitle );
461 fd->setNameFilters( filters );
462 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
463 fd->selectNameFilter(aDefaultFilter);
464 fd->SetChecked(toCreateGroups);
465 if ( !anInitialPath.isEmpty() )
466 fd->setDirectory( anInitialPath );
467 fd->selectFile(aMeshName);
469 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
470 fd->setValidator( fv );
475 aFilename = fd->selectedFile();
477 aFilename = QString::null;
480 aFormat = aFilterMap[fd->selectedNameFilter()];
481 toOverwrite = fv->isOverwrite();
483 if ( !aFilename.isEmpty() ) {
484 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
485 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
486 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
487 && aFormat==SMESH::MED_V2_1) {
488 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
489 QObject::tr("SMESH_WRN_WARNING"),
490 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
491 QObject::tr("SMESH_BUT_YES"),
492 QObject::tr("SMESH_BUT_NO"), 0, 1);
500 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
501 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
502 if( !isVersionOk || aVersion != aFormat ) {
503 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
504 QObject::tr("SMESH_WRN_WARNING"),
505 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
506 QObject::tr("SMESH_BUT_YES"),
507 QObject::tr("SMESH_BUT_NO"), 0, 1);
514 QStringList aMeshNamesCollisionList;
515 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
516 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
517 QString anExistingMeshName( aMeshNames[ i ] );
518 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
519 QString anExportMeshName = (*aMeshIter).second;
520 if( anExportMeshName == anExistingMeshName ) {
521 aMeshNamesCollisionList.append( anExportMeshName );
527 if( !aMeshNamesCollisionList.isEmpty() ) {
528 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
529 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
530 QObject::tr("SMESH_WRN_WARNING"),
531 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
532 QObject::tr("SMESH_BUT_YES"),
533 QObject::tr("SMESH_BUT_NO"),
534 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
543 toCreateGroups = fd->IsChecked();
546 if ( !aFilename.isEmpty() ) {
547 // Check whether the file already exists and delete it if yes
548 QFile aFile( aFilename );
549 if ( aFile.exists() && toOverwrite )
551 SUIT_OverrideCursor wc;
554 bool Renumber = false;
555 // PAL 14172 : Check of we have to renumber or not from the preferences before export
557 Renumber= resMgr->booleanValue("SMESH","renumbering");
559 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
560 aMeshEditor->RenumberNodes();
561 aMeshEditor->RenumberElements();
562 if ( SMESHGUI::automaticUpdate() )
565 switch ( theCommandID ) {
569 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
570 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
571 if( !aMeshItem->_is_nil() )
572 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
578 aMesh->ExportDAT( aFilename.toLatin1().data() );
582 aMesh->ExportUNV( aFilename.toLatin1().data() );
586 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
592 catch (const SALOME::SALOME_Exception& S_ex){
594 SUIT_MessageBox::warning(SMESHGUI::desktop(),
595 QObject::tr("SMESH_WRN_WARNING"),
596 QObject::tr("SMESH_EXPORT_FAILED"));
602 inline void InverseEntityMode(unsigned int& theOutputMode,
603 unsigned int theMode)
605 bool anIsNotPresent = ~theOutputMode & theMode;
607 theOutputMode |= theMode;
609 theOutputMode &= ~theMode;
612 void SetDisplayEntity(int theCommandID){
613 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
614 SALOME_ListIO selected;
616 aSel->selectedObjects( selected );
618 if(selected.Extent() >= 1){
619 SALOME_ListIteratorOfListIO It( selected );
620 for( ; It.More(); It.Next()){
621 Handle(SALOME_InteractiveObject) IObject = It.Value();
622 if(IObject->hasEntry()){
623 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
624 unsigned int aMode = anActor->GetEntityMode();
625 switch(theCommandID){
627 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
630 InverseEntityMode(aMode,SMESH_Actor::eEdges);
633 InverseEntityMode(aMode,SMESH_Actor::eFaces);
636 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
639 aMode = SMESH_Actor::eAllEntity;
643 anActor->SetEntityMode(aMode);
651 SALOME_ListIO selected;
652 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
656 LightApp_SelectionMgr* aSel = app->selectionMgr();
657 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
658 if( !aSel || !appStudy )
661 aSel->selectedObjects( selected );
662 if( selected.IsEmpty() )
665 Handle(SALOME_InteractiveObject) anIObject = selected.First();
667 _PTR(Study) aStudy = appStudy->studyDS();
668 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
669 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
670 if( aMainObject->_is_nil() )
673 aMainObject->SetAutoColor( true );
675 QList<SALOMEDS::Color> aReservedColors;
677 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
678 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
680 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
681 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
683 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
684 aGroupObject->SetColor( aColor );
685 aReservedColors.append( aColor );
687 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
689 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
690 if( aGroupObject->GetType() == SMESH::NODE )
691 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
692 else if( aGroupObject->GetType() == SMESH::EDGE )
693 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
694 else if( aGroupObject->GetType() == SMESH::ELEM0D )
695 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
697 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
702 SMESH::RepaintCurrentView();
705 void DisableAutoColor(){
706 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
707 SALOME_ListIO selected;
709 aSel->selectedObjects( selected );
711 if(selected.Extent()){
712 Handle(SALOME_InteractiveObject) anIObject = selected.First();
713 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
714 if ( !aMesh->_is_nil() ) {
715 aMesh->SetAutoColor( false );
720 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
721 SALOME_ListIO selected;
722 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
726 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
727 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
728 if( !aSel || !appStudy )
731 _PTR(Study) aStudy = appStudy->studyDS();
733 aSel->selectedObjects( selected );
735 if(selected.Extent() >= 1){
736 switch(theCommandID){
738 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
739 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
743 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
744 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
747 SALOME_ListIteratorOfListIO It( selected );
748 for( ; It.More(); It.Next()){
749 Handle(SALOME_InteractiveObject) IObject = It.Value();
750 if(IObject->hasEntry()){
751 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
752 switch(theCommandID){
754 anActor->SetRepresentation(SMESH_Actor::eEdge);
757 anActor->SetRepresentation(SMESH_Actor::eSurface);
760 if(anActor->IsShrunk())
763 anActor->SetShrink();
766 anActor->SetRepresentation(SMESH_Actor::ePoint);
769 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
770 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
773 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
774 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
777 vtkFloatingPointType color[3];
778 anActor->GetSufaceColor(color[0], color[1], color[2]);
779 int c0 = int (color[0] * 255);
780 int c1 = int (color[1] * 255);
781 int c2 = int (color[2] * 255);
782 QColor c(c0, c1, c2);
784 vtkFloatingPointType edgecolor[3];
785 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
786 c0 = int (edgecolor[0] * 255);
787 c1 = int (edgecolor[1] * 255);
788 c2 = int (edgecolor[2] * 255);
789 QColor e(c0, c1, c2);
791 vtkFloatingPointType backfacecolor[3];
792 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
793 c0 = int (backfacecolor[0] * 255);
794 c1 = int (backfacecolor[1] * 255);
795 c2 = int (backfacecolor[2] * 255);
796 QColor b(c0, c1, c2);
798 vtkFloatingPointType nodecolor[3];
799 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
800 c0 = int (nodecolor[0] * 255);
801 c1 = int (nodecolor[1] * 255);
802 c2 = int (nodecolor[2] * 255);
803 QColor n(c0, c1, c2);
805 vtkFloatingPointType color0D[3];
806 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
807 c0 = int (color0D[0] * 255);
808 c1 = int (color0D[1] * 255);
809 c2 = int (color0D[2] * 255);
810 QColor c0D(c0, c1, c2);
812 int size0D = (int)anActor->Get0DSize();
815 int Edgewidth = (int)anActor->GetLineWidth();
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, int(Shrink*100.));
840 aDlg->SetIntValue(3, size0D);
841 aDlg->SetDoubleValue(1, faces_orientation_scale);
842 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
844 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
846 VTK::MarkerType aMarkerTypeCurrent = anActor->GetMarkerType();
847 VTK::MarkerScale aMarkerScaleCurrent = anActor->GetMarkerScale();
848 int aMarkerTextureCurrent = anActor->GetMarkerTexture();
849 if( aMarkerTypeCurrent != VTK::MT_USER )
850 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
852 aDlg->setCustomMarker( aMarkerTextureCurrent );
855 QColor color = aDlg->GetColor(1);
856 QColor edgecolor = aDlg->GetColor(2);
857 QColor nodecolor = aDlg->GetColor(3);
858 QColor backfacecolor = aDlg->GetColor(4);
859 QColor color0D = aDlg->GetColor(5);
860 QColor faces_orientation_color = aDlg->GetColor(6);
861 /* actor color and backface color */
862 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
863 vtkFloatingPointType (color.green()) / 255.,
864 vtkFloatingPointType (color.blue()) / 255.);
865 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
866 vtkFloatingPointType (backfacecolor.green()) / 255.,
867 vtkFloatingPointType (backfacecolor.blue()) / 255.);
870 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
871 vtkFloatingPointType (edgecolor.green()) / 255.,
872 vtkFloatingPointType (edgecolor.blue()) / 255.);
874 /* Shrink factor and size edges */
875 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
876 anActor->SetLineWidth(aDlg->GetIntValue(1));
878 /* Nodes color and size */
879 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
880 vtkFloatingPointType (nodecolor.green()) / 255.,
881 vtkFloatingPointType (nodecolor.blue()) / 255.);
884 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
885 vtkFloatingPointType (color0D.green()) / 255.,
886 vtkFloatingPointType (color0D.blue()) / 255.);
887 anActor->Set0DSize(aDlg->GetIntValue(3));
889 /* Faces orientation */
890 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
891 vtkFloatingPointType(faces_orientation_color.greenF()),
892 vtkFloatingPointType(faces_orientation_color.blueF())};
893 anActor->SetFacesOrientationColor(c);
894 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
895 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
898 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
900 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
901 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
902 int aMarkerTextureNew = aDlg->getCustomMarkerID();
903 if( aMarkerTypeNew != VTK::MT_USER )
904 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
906 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
907 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
908 if( anIter != aMarkerMap.end() )
909 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
912 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
913 if( !aGroupObject->_is_nil() )
915 SMESH::ElementType anElementType = aGroupObject->GetType();
917 switch( anElementType )
919 case SMESH::NODE: aColor = nodecolor; break;
920 case SMESH::EDGE: aColor = edgecolor; break;
921 default: aColor = color; break;
924 SALOMEDS::Color aGroupColor;
925 aGroupColor.R = (float)aColor.red() / 255.0;
926 aGroupColor.G = (float)aColor.green() / 255.0;
927 aGroupColor.B = (float)aColor.blue() / 255.0;
928 aGroupObject->SetColor( aGroupColor );
938 SMESH::RepaintCurrentView();
942 void Control( int theCommandID )
944 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
945 SALOME_ListIO selected;
947 aSel->selectedObjects( selected );
949 if( !selected.IsEmpty() ){
950 Handle(SALOME_InteractiveObject) anIO = selected.First();
953 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
954 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
955 switch ( theCommandID ){
957 aTitle = QObject::tr( "LENGTH_EDGES" );
958 aControl = SMESH_Actor::eLength;
961 aTitle = QObject::tr( "LENGTH2D_EDGES" );
962 aControl = SMESH_Actor::eLength2D;
965 aTitle = QObject::tr( "FREE_EDGES" );
966 aControl = SMESH_Actor::eFreeEdges;
969 aTitle = QObject::tr( "FREE_BORDERS" );
970 aControl = SMESH_Actor::eFreeBorders;
973 aTitle = QObject::tr( "MULTI_BORDERS" );
974 aControl = SMESH_Actor::eMultiConnection;
977 aTitle = QObject::tr( "FREE_NODES" );
978 aControl = SMESH_Actor::eFreeNodes;
981 aTitle = QObject::tr( "MULTI2D_BORDERS" );
982 aControl = SMESH_Actor::eMultiConnection2D;
985 aTitle = QObject::tr( "AREA_ELEMENTS" );
986 aControl = SMESH_Actor::eArea;
989 aTitle = QObject::tr( "TAPER_ELEMENTS" );
990 aControl = SMESH_Actor::eTaper;
993 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
994 aControl = SMESH_Actor::eAspectRatio;
997 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
998 aControl = SMESH_Actor::eAspectRatio3D;
1001 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1002 aControl = SMESH_Actor::eMinimumAngle;
1005 aTitle = QObject::tr( "WARP_ELEMENTS" );
1006 aControl = SMESH_Actor::eWarping;
1009 aTitle = QObject::tr( "SKEW_ELEMENTS" );
1010 aControl = SMESH_Actor::eSkew;
1013 aTitle = QObject::tr( "SMESH_VOLUME" );
1014 aControl = SMESH_Actor::eVolume3D;
1017 aTitle = QObject::tr( "FREE_FACES" );
1018 aControl = SMESH_Actor::eFreeFaces;
1021 anActor->SetControlMode(aControl);
1022 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
1023 SMESH::RepaintCurrentView();
1030 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1031 MeshObjectType theType,
1032 const QString theInTypeName,
1033 QString & theOutTypeName)
1035 SMESH_TypeFilter aTypeFilter( theType );
1037 if( !theIO.IsNull() )
1039 entry = theIO->getEntry();
1040 LightApp_DataOwner owner( entry );
1041 if ( aTypeFilter.isOk( &owner )) {
1042 theOutTypeName = theInTypeName;
1050 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1052 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1053 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1055 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1056 CORBA::String_var anID = aSComp->GetID().c_str();
1057 if (!strcmp(anID.in(),theIO->getEntry()))
1063 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1064 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1065 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1066 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1067 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1075 QString CheckHomogeneousSelection()
1077 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1078 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1079 SALOME_ListIO selected;
1081 aSel->selectedObjects( selected );
1083 QString RefType = CheckTypeObject(selected.First());
1084 SALOME_ListIteratorOfListIO It(selected);
1085 for ( ; It.More(); It.Next())
1087 Handle(SALOME_InteractiveObject) IObject = It.Value();
1088 QString Type = CheckTypeObject(IObject);
1089 if (Type.compare(RefType) != 0)
1090 return "Heterogeneous Selection";
1097 void SMESHGUI::OnEditDelete()
1099 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1100 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1101 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1103 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1104 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1105 _PTR(GenericAttribute) anAttr;
1106 _PTR(AttributeIOR) anIOR;
1108 int objectCount = 0;
1110 QString aParentComponent = QString::null;
1111 Handle(SALOME_InteractiveObject) anIO;
1112 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1114 anIO = anIt.Value();
1115 QString cur = anIO->getComponentDataType();
1116 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1118 // check if object is reference
1119 _PTR(SObject) aRefSObj;
1120 aNameList.append("\n - ");
1121 if ( aSO->ReferencedObject( aRefSObj ) ) {
1122 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1123 aNameList.append( aRefName );
1124 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1127 aNameList.append(anIO->getName());
1131 if( aParentComponent.isNull() )
1132 aParentComponent = cur;
1133 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1134 aParentComponent = "";
1137 if ( objectCount == 0 )
1138 return; // No Valid Objects Selected
1140 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1141 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1142 QObject::tr("ERR_ERROR"),
1143 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1146 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1147 if (SUIT_MessageBox::warning
1148 (SMESHGUI::desktop(),
1149 QObject::tr("SMESH_WRN_WARNING"),
1150 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1151 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1152 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1155 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1156 SUIT_ViewManager* vm = anApp->activeViewManager();
1157 int nbSf = vm->getViewsCount();
1159 SALOME_ListIteratorOfListIO It(selected);
1161 aStudyBuilder->NewCommand(); // There is a transaction
1162 for( ; It.More(); It.Next()){ // loop on selected IO's
1163 Handle(SALOME_InteractiveObject) IObject = It.Value();
1164 if(IObject->hasEntry()) {
1165 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1167 // disable removal of "SMESH" component object
1168 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1170 if ( engineIOR() == anIOR->Value().c_str() )
1173 //Check the referenced object
1174 _PTR(SObject) aRefSObject;
1175 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1176 aSO = aRefSObject; // Delete main Object instead of reference
1178 // put the whole hierarchy of sub-objects of the selected SO into a list and
1179 // then treat them all starting from the deepest objects (at list back)
1181 std::list< _PTR(SObject) > listSO;
1182 listSO.push_back( aSO );
1183 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1184 for ( ; itSO != listSO.end(); ++itSO ) {
1185 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1186 for (it->InitEx(false); it->More(); it->Next())
1187 listSO.push_back( it->Value() );
1190 // treat SO's in the list starting from the back
1192 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1193 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1194 _PTR(SObject) SO = *ritSO;
1195 if ( !SO ) continue;
1196 std::string anEntry = SO->GetID();
1198 /** Erase graphical object **/
1199 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1200 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1201 for(int i = 0; i < nbSf; i++){
1202 SUIT_ViewWindow *sf = aViews[i];
1203 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1204 SMESH::RemoveActor(sf,anActor);
1209 /** Remove an object from data structures **/
1210 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1211 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1212 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1213 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1214 aMesh->RemoveGroup( aGroup );
1216 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1217 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1218 aMesh->RemoveSubMesh( aSubMesh );
1220 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1222 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1225 IObject = new SALOME_InteractiveObject
1226 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1227 QString objType = CheckTypeObject(IObject);
1228 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1229 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1230 aStudyBuilder->RemoveObjectWithChildren( SO );
1232 else {// default action: remove SObject from the study
1233 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1234 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1236 aStudyBuilder->RemoveObjectWithChildren( SO );
1240 } /* listSO back loop */
1241 } /* IObject->hasEntry() */
1243 aStudyBuilder->CommitCommand();
1245 /* Clear any previous selection */
1247 aSel->setSelectedObjects( l1 );
1249 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1254 SMESHGUI_EXPORT CAM_Module* createModule()
1256 return new SMESHGUI();
1260 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1262 //=============================================================================
1266 //=============================================================================
1267 SMESHGUI::SMESHGUI() :
1268 SalomeApp_Module( "SMESH" ),
1269 LightApp_Module( "SMESH" )
1271 if ( CORBA::is_nil( myComponentSMESH ) )
1273 CORBA::Boolean anIsEmbeddedMode;
1274 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1276 // 0019923: EDF 765 SMESH : default values of hypothesis
1277 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1278 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1279 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1280 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1281 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1284 myActiveDialogBox = 0;
1285 myFilterLibraryDlg = 0;
1289 SMESH::GetFilterManager();
1290 SMESH::GetPattern();
1292 /* load resources for all available meshers */
1293 SMESH::InitAvailableHypotheses();
1296 //=============================================================================
1300 //=============================================================================
1301 SMESHGUI::~SMESHGUI()
1303 SMESH::GetFilterManager()->Destroy();
1304 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1307 //=============================================================================
1311 //=============================================================================
1312 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1314 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1316 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1321 bool SMESHGUI::automaticUpdate()
1323 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1327 return resMgr->booleanValue( "SMESH", "auto_update", false );
1330 //=============================================================================
1334 //=============================================================================
1335 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1337 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1340 //=============================================================================
1344 //=============================================================================
1345 SMESHGUI* SMESHGUI::GetSMESHGUI()
1347 SMESHGUI* smeshMod = 0;
1348 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1351 CAM_Module* module = app->module( "Mesh" );
1352 smeshMod = dynamic_cast<SMESHGUI*>( module );
1355 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1357 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1360 _PTR(Study) aStudy = study->studyDS();
1362 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1371 Standard_EXPORT SMESHGUI* GetComponentGUI()
1373 return SMESHGUI::GetSMESHGUI();
1377 //=============================================================================
1381 //=============================================================================
1382 void SMESHGUI::SetState(int aState)
1387 //=============================================================================
1391 //=============================================================================
1392 void SMESHGUI::ResetState()
1397 //=============================================================================
1401 //=============================================================================
1402 void SMESHGUI::EmitSignalDeactivateDialog()
1404 emit SignalDeactivateActiveDialog();
1407 //=============================================================================
1411 //=============================================================================
1412 void SMESHGUI::EmitSignalStudyFrameChanged()
1414 emit SignalStudyFrameChanged();
1417 //=============================================================================
1421 //=============================================================================
1422 void SMESHGUI::EmitSignalCloseAllDialogs()
1424 emit SignalCloseAllDialogs();
1427 //=============================================================================
1431 //=============================================================================
1432 void SMESHGUI::EmitSignalVisibilityChanged()
1434 emit SignalVisibilityChanged();
1437 //=============================================================================
1441 //=============================================================================
1442 QDialog *SMESHGUI::GetActiveDialogBox()
1444 return myActiveDialogBox;
1447 //=============================================================================
1451 //=============================================================================
1452 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1454 myActiveDialogBox = (QDialog *) aDlg;
1458 //=============================================================================
1462 //=============================================================================
1463 SUIT_Desktop* SMESHGUI::desktop()
1465 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1467 return app->desktop();
1472 //=============================================================================
1476 //=============================================================================
1477 SalomeApp_Study* SMESHGUI::activeStudy()
1479 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1481 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1486 //=============================================================================
1490 //=============================================================================
1491 void SMESHGUI::Modified( bool theIsUpdateActions )
1493 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1494 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1495 appStudy->Modified();
1496 if( theIsUpdateActions )
1497 app->updateActions();
1502 //=============================================================================
1506 //=============================================================================
1507 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1509 /* Here the position is on the bottom right corner - 10 */
1510 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1512 SUIT_Desktop *PP = desktop();
1513 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1514 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1518 //=============================================================================
1522 //=============================================================================
1523 static int isStudyLocked(_PTR(Study) theStudy){
1524 return theStudy->GetProperties()->IsLocked();
1527 static bool checkLock(_PTR(Study) theStudy) {
1528 if (isStudyLocked(theStudy)) {
1529 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1530 QObject::tr("WRN_WARNING"),
1531 QObject::tr("WRN_STUDY_LOCKED") );
1537 //=======================================================================
1538 //function : CheckActiveStudyLocked
1540 //=======================================================================
1542 bool SMESHGUI::isActiveStudyLocked()
1544 _PTR(Study) aStudy = activeStudy()->studyDS();
1545 return checkLock( aStudy );
1548 //=============================================================================
1552 //=============================================================================
1553 bool SMESHGUI::OnGUIEvent( int theCommandID )
1555 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1559 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1560 SUIT_ResourceMgr* mgr = resourceMgr();
1564 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1565 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1568 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1569 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1571 //QAction* act = action( theCommandID );
1573 switch (theCommandID) {
1575 if(checkLock(aStudy)) break;
1583 if(checkLock(aStudy)) break;
1584 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1588 case 150: //MED FILE INFORMATION
1590 SALOME_ListIO selected;
1591 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1593 aSel->selectedObjects( selected );
1594 if( selected.Extent() )
1596 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1597 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1598 if ( !aMesh->_is_nil() )
1600 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1607 case 122: // EXPORT MED
1616 ::ExportMeshToFile(theCommandID);
1620 case 200: // SCALAR BAR
1622 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1623 SALOME_ListIO selected;
1625 aSel->selectedObjects( selected );
1627 if( selected.Extent() ) {
1628 Handle(SALOME_InteractiveObject) anIO = selected.First();
1629 if( anIO->hasEntry() ) {
1630 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1631 anActor->SetControlMode( SMESH_Actor::eNone );
1639 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1649 ::DisableAutoColor();
1652 case 1134: // Clipping
1653 case 1133: // Tranparency
1654 case 1132: // Colors / Size
1661 ::SetDisplayMode(theCommandID, myMarkerMap);
1664 //2D quadratic representation
1667 ::SetDisplayMode(theCommandID, myMarkerMap);
1671 case 216: // 0D elements
1674 case 219: // Volumes
1675 case 220: // All Entity
1676 ::SetDisplayEntity(theCommandID);
1679 case 221: // Orientation of faces
1681 LightApp_SelectionMgr* mgr = selectionMgr();
1682 SALOME_ListIO selected; mgr->selectedObjects( selected );
1684 SALOME_ListIteratorOfListIO it(selected);
1685 for( ; it.More(); it.Next()) {
1686 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1687 if(anIObject->hasEntry()) {
1688 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1689 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1698 if(checkLock(aStudy)) break;
1700 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1703 SMESH::UpdateView();
1705 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1706 SMESH::OnVisuException();
1708 catch (...) { // PAL16774 (Crash after display of many groups)
1709 SMESH::OnVisuException();
1713 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1714 aSel->selectedObjects( l );
1715 aSel->setSelectedObjects( l );
1720 case 301: // DISPLAY
1721 case 302: // DISPLAY ONLY
1723 SMESH::EDisplaing anAction;
1724 switch (theCommandID) {
1725 case 300: anAction = SMESH::eErase; break;
1726 case 301: anAction = SMESH::eDisplay; break;
1727 case 302: anAction = SMESH::eDisplayOnly; break;
1730 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1731 SALOME_ListIO sel_objects, to_process;
1733 aSel->selectedObjects( sel_objects );
1735 if( theCommandID==302 )
1736 startOperation( myEraseAll );
1738 extractContainers( sel_objects, to_process );
1741 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1745 SALOME_ListIteratorOfListIO It( to_process );
1746 for ( ; It.More(); It.Next()) {
1747 Handle(SALOME_InteractiveObject) IOS = It.Value();
1748 if (IOS->hasEntry()) {
1749 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1750 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1751 break; // PAL16774 (Crash after display of many groups)
1753 if (anAction == SMESH::eDisplayOnly)
1754 anAction = SMESH::eDisplay;
1759 // PAL13338 + PAL15161 -->
1760 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1761 SMESH::UpdateView();
1762 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1764 // PAL13338 + PAL15161 <--
1766 catch (...) { // PAL16774 (Crash after display of many groups)
1767 SMESH::OnVisuException();
1770 if (anAction == SMESH::eErase) {
1772 aSel->setSelectedObjects( l1 );
1775 aSel->setSelectedObjects( to_process );
1782 if(checkLock(aStudy)) break;
1785 EmitSignalDeactivateDialog();
1787 ( new SMESHGUI_NodesDlg( this ) )->show();
1790 SUIT_MessageBox::warning(desktop(),
1791 tr("SMESH_WRN_WARNING"),
1792 tr("SMESH_WRN_VIEWER_VTK"));
1797 case 2151: // FILTER
1801 EmitSignalDeactivateDialog();
1802 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1807 case 406: // MOVE NODE
1811 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1812 tr( "NOT_A_VTK_VIEWER" ) );
1816 if(checkLock(aStudy)) break;
1817 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1821 case 701: // COMPUTE MESH
1822 case 711: // PRECOMPUTE MESH
1823 case 712: // EVALUATE MESH
1824 case 713: // MESH ORDER
1826 if (checkLock(aStudy)) break;
1827 startOperation( theCommandID );
1831 case 702: // Create mesh
1832 case 703: // Create sub-mesh
1833 case 704: // Edit mesh/sub-mesh
1834 startOperation( theCommandID );
1836 case 710: // Build compound mesh
1838 if (checkLock(aStudy)) break;
1839 EmitSignalDeactivateDialog();
1840 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1844 case 407: // DIAGONAL INVERSION
1845 case 408: // Delete diagonal
1849 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1850 tr( "NOT_A_VTK_VIEWER" ) );
1854 if ( checkLock( aStudy ) )
1857 /*Standard_Boolean aRes;
1858 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1859 if ( aMesh->_is_nil() )
1861 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1862 tr( "SMESH_BAD_SELECTION" ) );
1866 EmitSignalDeactivateDialog();
1867 if ( theCommandID == 407 )
1868 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1870 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1873 case 409: // Change orientation
1874 case 410: // Union of triangles
1875 case 411: // Cutting of quadrangles
1876 case 419: // Splitting volumes into tetrahedra
1880 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1881 tr( "NOT_A_VTK_VIEWER" ) );
1885 if ( checkLock( aStudy ) )
1888 EmitSignalDeactivateDialog();
1889 SMESHGUI_MultiEditDlg* aDlg = NULL;
1890 if ( theCommandID == 409 )
1891 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1892 else if ( theCommandID == 410 )
1893 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1894 else if ( theCommandID == 419 )
1895 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
1897 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1902 case 412: // Smoothing
1904 if(checkLock(aStudy)) break;
1906 EmitSignalDeactivateDialog();
1907 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1910 SUIT_MessageBox::warning(desktop(),
1911 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1915 case 413: // Extrusion
1917 if (checkLock(aStudy)) break;
1919 EmitSignalDeactivateDialog();
1920 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1922 SUIT_MessageBox::warning(desktop(),
1923 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1927 case 414: // Revolution
1929 if(checkLock(aStudy)) break;
1931 EmitSignalDeactivateDialog();
1932 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1935 SUIT_MessageBox::warning(desktop(),
1936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1940 case 415: // Pattern mapping
1942 if ( checkLock( aStudy ) )
1946 EmitSignalDeactivateDialog();
1947 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1950 SUIT_MessageBox::warning(desktop(),
1951 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1955 case 416: // Extrusion along a path
1957 if (checkLock(aStudy)) break;
1959 EmitSignalDeactivateDialog();
1960 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1962 SUIT_MessageBox::warning(desktop(),
1963 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1967 case 417: // Convert mesh to quadratic
1969 startOperation( 417 );
1970 /* if (checkLock(aStudy)) break;
1972 EmitSignalDeactivateDialog();
1973 new SMESHGUI_ConvToQuadDlg();
1975 SUIT_MessageBox::warning(desktop(),
1976 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1980 case 418: // create 2D mesh from 3D
1982 startOperation( 418 );
1985 case 806: // CREATE GEO GROUP
1987 startOperation( 806 );
1990 case 801: // CREATE GROUP
1994 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1995 tr( "NOT_A_VTK_VIEWER" ) );
1999 if(checkLock(aStudy)) break;
2000 EmitSignalDeactivateDialog();
2001 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2003 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2004 SALOME_ListIO selected;
2006 aSel->selectedObjects( selected );
2008 int nbSel = selected.Extent();
2010 // check if mesh is selected
2011 aMesh = SMESH::GetMeshByIO( selected.First() );
2013 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2018 case 802: // CONSTRUCT GROUP
2022 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2023 tr( "NOT_A_VTK_VIEWER" ) );
2027 if(checkLock(aStudy)) break;
2028 EmitSignalDeactivateDialog();
2030 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2031 SALOME_ListIO selected;
2033 aSel->selectedObjects( selected );
2035 int nbSel = selected.Extent();
2037 // check if submesh is selected
2038 Handle(SALOME_InteractiveObject) IObject = selected.First();
2039 if (IObject->hasEntry()) {
2040 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2042 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2043 if (!aSubMesh->_is_nil()) {
2045 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2046 // get submesh elements list by types
2047 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2048 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2049 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2050 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2051 // create group for each type o elements
2052 QString aName = IObject->getName();
2053 if (aNodes->length() > 0) {
2054 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2055 aGroup->Add(aNodes.inout());
2057 if (aEdges->length() > 0) {
2058 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2059 aGroup->Add(aEdges.inout());
2061 if (aFaces->length() > 0) {
2062 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2063 aGroup->Add(aFaces.inout());
2065 if (aVolumes->length() > 0) {
2066 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2067 aGroup->Add(aVolumes.inout());
2072 catch(const SALOME::SALOME_Exception & S_ex){
2073 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2080 SUIT_MessageBox::warning(desktop(),
2081 tr("SMESH_WRN_WARNING"),
2082 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2087 case 803: // EDIT GROUP
2091 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2092 tr( "NOT_A_VTK_VIEWER" ) );
2096 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2099 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2100 SALOME_ListIO selected;
2102 aSel->selectedObjects( selected );
2104 SALOME_ListIteratorOfListIO It (selected);
2105 int nbSelectedGroups = 0;
2106 for ( ; It.More(); It.Next() )
2108 SMESH::SMESH_GroupBase_var aGroup =
2109 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2110 if (!aGroup->_is_nil()) {
2112 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2116 if (nbSelectedGroups == 0)
2118 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2124 case 804: // Add elements to group
2126 if(checkLock(aStudy)) break;
2127 if (myState == 800) {
2128 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2129 if (aDlg) aDlg->onAdd();
2134 case 805: // Remove elements from group
2136 if(checkLock(aStudy)) break;
2137 if (myState == 800) {
2138 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2139 if (aDlg) aDlg->onRemove();
2144 case 815: // Edit GEOM GROUP as standalone
2148 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2149 tr( "NOT_A_VTK_VIEWER" ) );
2153 if(checkLock(aStudy)) break;
2154 EmitSignalDeactivateDialog();
2156 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2157 SALOME_ListIO selected;
2159 aSel->selectedObjects( selected );
2161 SALOME_ListIteratorOfListIO It (selected);
2162 for ( ; It.More(); It.Next() )
2164 SMESH::SMESH_GroupOnGeom_var aGroup =
2165 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2166 if (!aGroup->_is_nil()) {
2167 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2174 case 810: // Union Groups
2175 case 811: // Intersect groups
2176 case 812: // Cut groups
2180 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2181 tr( "NOT_A_VTK_VIEWER" ) );
2185 if ( checkLock( aStudy ) )
2188 EmitSignalDeactivateDialog();
2190 SMESHGUI_GroupOpDlg* aDlg = 0;
2191 if ( theCommandID == 810 )
2192 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2193 else if ( theCommandID == 811 )
2194 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2196 aDlg = new SMESHGUI_CutGroupsDlg( this );
2203 case 814: // Create groups of entities from existing groups of superior dimensions
2205 if ( checkLock( aStudy ) )
2208 EmitSignalDeactivateDialog();
2209 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2215 case 813: // Delete groups with their contents
2219 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2220 tr( "NOT_A_VTK_VIEWER" ) );
2224 if ( checkLock( aStudy ) )
2227 EmitSignalDeactivateDialog();
2229 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2233 case 900: // MESH INFOS
2235 EmitSignalDeactivateDialog();
2236 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2237 SALOME_ListIO selected;
2239 aSel->selectedObjects( selected );
2241 if ( selected.Extent() > 1 ) { // a dlg for each IO
2243 SALOME_ListIteratorOfListIO It (selected);
2244 for ( ; It.More(); It.Next() ) {
2245 IOs.Clear(); IOs.Append( It.Value() );
2246 aSel->setSelectedObjects( IOs );
2247 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2249 // restore selection
2250 aSel->setSelectedObjects( selected );
2253 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2257 case 902: // STANDARD MESH INFOS
2259 EmitSignalDeactivateDialog();
2260 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2261 SALOME_ListIO selected;
2263 aSel->selectedObjects( selected );
2265 if ( selected.Extent() > 1 ) { // a dlg for each IO
2267 SALOME_ListIteratorOfListIO It (selected);
2268 for ( ; It.More(); It.Next() ) {
2270 IOs.Append( It.Value() );
2271 aSel->setSelectedObjects( IOs );
2272 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2274 // restore selection
2275 aSel->setSelectedObjects( selected );
2278 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2282 case 903: // WHAT IS
2284 EmitSignalDeactivateDialog();
2285 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2289 case 904: // FIND ELEM
2291 startOperation( theCommandID );
2295 case 1100: // EDIT HYPOTHESIS
2297 if(checkLock(aStudy)) break;
2299 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2300 SALOME_ListIO selected;
2302 aSel->selectedObjects( selected );
2304 int nbSel = selected.Extent();
2307 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2308 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2310 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2311 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2312 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2313 if ( !aHypothesis->_is_nil() )
2316 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2317 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2319 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2330 case 1101: // RENAME
2332 if ( checkLock( aStudy ) )
2335 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2336 SALOME_ListIO selected;
2338 aSel->selectedObjects( selected );
2340 bool isAny = false; // is there any appropriate object selected
2342 SALOME_ListIteratorOfListIO It( selected );
2343 for ( ; It.More(); It.Next() )
2345 Handle(SALOME_InteractiveObject) IObject = It.Value();
2346 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2347 _PTR(GenericAttribute) anAttr;
2348 _PTR(AttributeName) aName;
2351 if ( obj->FindAttribute(anAttr, "AttributeName") )
2354 QString newName = QString(aName->Value().c_str());
2356 // check type to prevent renaming of inappropriate objects
2357 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2358 if (aType == MESH || aType == GROUP ||
2359 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2360 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2361 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2362 aType == HYPOTHESIS || aType == ALGORITHM)
2365 newName = LightApp_NameDlg::getName(desktop(), newName);
2366 if ( !newName.isEmpty() )
2368 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2370 // update name of group object and its actor
2371 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2372 if( !aGroupObject->_is_nil() )
2374 aGroupObject->SetName( newName.toLatin1().data() );
2375 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2376 anActor->setName( newName.toLatin1().data() );
2387 SUIT_MessageBox::warning(desktop(),
2388 QObject::tr("SMESH_WRN_WARNING"),
2389 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2394 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2396 if(checkLock(aStudy)) break;
2397 SUIT_OverrideCursor wc;
2399 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2400 SALOME_ListIO selected;
2402 aSel->selectedObjects( selected, QString::null, false );
2404 SALOME_ListIteratorOfListIO It(selected);
2405 for (int i = 0; It.More(); It.Next(), i++) {
2406 Handle(SALOME_InteractiveObject) IObject = It.Value();
2407 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2410 aSel->setSelectedObjects( l1 );
2415 case 4009: // ELEM0D
2416 case 4010: // GEOM::EDGE
2417 case 4021: // TRIANGLE
2419 case 4023: // POLYGON
2423 if(checkLock(aStudy)) break;
2425 EmitSignalDeactivateDialog();
2426 SMDSAbs_ElementType type = SMDSAbs_Edge;
2428 switch (theCommandID) {
2429 case 4009: // ELEM0D
2430 type = SMDSAbs_0DElement; nbNodes = 1; break;
2431 case 4021: // TRIANGLE
2432 type = SMDSAbs_Face; nbNodes = 3; break;
2434 type = SMDSAbs_Face; nbNodes = 4; break;
2436 type = SMDSAbs_Volume; nbNodes = 4; break;
2437 case 4023: // POLYGON
2438 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2440 type = SMDSAbs_Volume; nbNodes = 8; break;
2441 case 4033: // POLYHEDRE
2442 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2445 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2448 SUIT_MessageBox::warning(desktop(),
2449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2453 case 4033: // POLYHEDRON
2455 if(checkLock(aStudy)) break;
2457 EmitSignalDeactivateDialog();
2458 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2461 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2462 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2466 case 4034: // QUADRATIC EDGE
2467 case 4035: // QUADRATIC TRIANGLE
2468 case 4036: // QUADRATIC QUADRANGLE
2469 case 4037: // QUADRATIC TETRAHEDRON
2470 case 4038: // QUADRATIC PYRAMID
2471 case 4039: // QUADRATIC PENTAHEDRON
2472 case 4040: // QUADRATIC HEXAHEDRON
2474 if(checkLock(aStudy)) break;
2476 EmitSignalDeactivateDialog();
2479 switch (theCommandID) {
2481 type = QUAD_EDGE; break;
2483 type = QUAD_TRIANGLE; break;
2485 type = QUAD_QUADRANGLE; break;
2487 type = QUAD_TETRAHEDRON; break;
2489 type = QUAD_PYRAMID; break;
2491 type = QUAD_PENTAHEDRON; break;
2493 type = QUAD_HEXAHEDRON;
2497 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2500 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2505 case 4041: // REMOVES NODES
2507 if(checkLock(aStudy)) break;
2509 EmitSignalDeactivateDialog();
2510 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2513 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2514 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2518 case 4042: // REMOVES ELEMENTS
2520 if(checkLock(aStudy)) break;
2522 EmitSignalDeactivateDialog();
2523 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2527 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2528 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2532 case 4043: { // CLEAR_MESH
2534 if(checkLock(aStudy)) break;
2536 SALOME_ListIO selected;
2537 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2538 aSel->selectedObjects( selected );
2540 SUIT_OverrideCursor wc;
2541 SALOME_ListIteratorOfListIO It (selected);
2542 for ( ; It.More(); It.Next() )
2544 Handle(SALOME_InteractiveObject) IOS = It.Value();
2545 SMESH::SMESH_Mesh_var aMesh =
2546 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2547 if ( aMesh->_is_nil()) continue;
2549 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2551 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2552 SMESH::ModifiedMesh( aMeshSObj, false, true);
2553 // hide groups and submeshes
2554 _PTR(ChildIterator) anIter =
2555 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2556 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2558 _PTR(SObject) so = anIter->Value();
2559 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2562 catch (const SALOME::SALOME_Exception& S_ex){
2564 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2568 SMESH::UpdateView();
2572 case 4051: // RENUMBERING NODES
2574 if(checkLock(aStudy)) break;
2576 EmitSignalDeactivateDialog();
2577 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2581 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2582 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2586 case 4052: // RENUMBERING ELEMENTS
2588 if(checkLock(aStudy)) break;
2590 EmitSignalDeactivateDialog();
2591 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2595 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2596 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2600 case 4061: // TRANSLATION
2602 if(checkLock(aStudy)) break;
2604 EmitSignalDeactivateDialog();
2605 ( new SMESHGUI_TranslationDlg( this ) )->show();
2608 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2609 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2613 case 4062: // ROTATION
2615 if(checkLock(aStudy)) break;
2617 EmitSignalDeactivateDialog();
2618 ( new SMESHGUI_RotationDlg( this ) )->show();
2621 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2622 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2626 case 4063: // SYMMETRY
2628 if(checkLock(aStudy)) break;
2630 EmitSignalDeactivateDialog();
2631 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2634 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2635 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2639 case 4064: // SEWING
2641 if(checkLock(aStudy)) break;
2643 EmitSignalDeactivateDialog();
2644 ( new SMESHGUI_SewingDlg( this ) )->show();
2647 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2648 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2652 case 4065: // MERGE NODES
2654 if(checkLock(aStudy)) break;
2656 EmitSignalDeactivateDialog();
2657 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2660 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2661 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2665 case 4066: // MERGE EQUAL ELEMENTS
2667 if (checkLock(aStudy)) break;
2669 EmitSignalDeactivateDialog();
2670 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2672 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2673 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2678 case 4067: // MAKE MESH PASS THROUGH POINT
2679 startOperation( 4067 );
2684 if(checkLock(aStudy)) break;
2686 EmitSignalDeactivateDialog();
2687 ( new SMESHGUI_ScaleDlg( this ) )->show();
2690 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2696 case 5105: // Library of selection filters
2698 static QList<int> aTypes;
2699 if ( aTypes.isEmpty() )
2701 aTypes.append( SMESH::NODE );
2702 aTypes.append( SMESH::EDGE );
2703 aTypes.append( SMESH::FACE );
2704 aTypes.append( SMESH::VOLUME );
2706 if (!myFilterLibraryDlg)
2707 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2708 else if (myFilterLibraryDlg->isHidden())
2709 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2710 myFilterLibraryDlg->raise();
2714 case 6017: // CONTROLS
2732 LightApp_SelectionMgr* mgr = selectionMgr();
2733 SALOME_ListIO selected; mgr->selectedObjects( selected );
2735 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2736 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2738 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2739 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2740 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2741 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2742 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2743 ::Control( theCommandID );
2748 SUIT_MessageBox::warning(desktop(),
2749 tr( "SMESH_WRN_WARNING" ),
2750 tr( "SMESH_BAD_SELECTION" ) );
2754 SUIT_MessageBox::warning(desktop(),
2755 tr( "SMESH_WRN_WARNING" ),
2756 tr( "NOT_A_VTK_VIEWER" ) );
2761 LightApp_SelectionMgr* mgr = selectionMgr();
2762 SALOME_ListIO selected; mgr->selectedObjects( selected );
2764 SALOME_ListIteratorOfListIO it(selected);
2765 for( ; it.More(); it.Next()) {
2766 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2767 if(anIObject->hasEntry()) {
2768 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2769 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2777 LightApp_SelectionMgr* mgr = selectionMgr();
2778 SALOME_ListIO selected; mgr->selectedObjects( selected );
2780 if (selected.Extent() == 1) {
2781 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2782 if(anIObject->hasEntry())
2783 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2784 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2791 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2792 //updateObjBrowser();
2796 //=============================================================================
2800 //=============================================================================
2801 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2806 //=============================================================================
2810 //=============================================================================
2811 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2816 //=============================================================================
2820 //=============================================================================
2821 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2826 //=============================================================================
2827 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2828 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2830 //=============================================================================
2831 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2832 SUIT_ViewWindow* wnd )
2834 if(theIO->hasEntry()){
2835 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2836 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2840 //=======================================================================
2841 // function : createSMESHAction
2843 //=======================================================================
2844 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2847 QWidget* parent = application()->desktop();
2848 SUIT_ResourceMgr* resMgr = resourceMgr();
2850 if ( !icon_id.isEmpty() )
2851 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2853 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2854 if ( !pix.isNull() )
2855 icon = QIcon( pix );
2857 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2858 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2859 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2861 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2864 //=======================================================================
2865 // function : createPopupItem
2867 //=======================================================================
2868 void SMESHGUI::createPopupItem( const int id,
2869 const QString& clients,
2870 const QString& types,
2871 const QString& theRule,
2876 parentId = popupMgr()->actionId( action( pId ) );
2878 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2879 popupMgr()->insert( action( id ), parentId, 0 );
2881 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2882 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2883 QString rule = "(%1) and (%2) and (%3)";
2884 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2885 if( clients.isEmpty() )
2886 rule = rule.arg( QString( "true" ) );
2888 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2889 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2892 bool cont = myRules.contains( id );
2894 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2896 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2897 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2900 //=======================================================================
2901 // function : initialize
2903 //=======================================================================
2904 void SMESHGUI::initialize( CAM_Application* app )
2906 SalomeApp_Module::initialize( app );
2908 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2910 /* Automatic Update flag */
2911 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2913 // ----- create actions --------------
2915 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2916 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2917 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2918 createSMESHAction( 114, "NUM" );
2919 createSMESHAction( 121, "DAT" );
2920 createSMESHAction( 122, "MED" );
2921 createSMESHAction( 123, "UNV" );
2922 createSMESHAction( 140, "STL" );
2923 createSMESHAction( 124, "EXPORT_DAT" );
2924 createSMESHAction( 125, "EXPORT_MED" );
2925 createSMESHAction( 126, "EXPORT_UNV" );
2926 createSMESHAction( 141, "EXPORT_STL" );
2927 createSMESHAction( 150, "FILE_INFO" );
2928 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2929 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2930 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2931 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2932 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2933 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2934 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2935 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2936 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
2937 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
2938 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2939 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2940 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2941 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2942 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
2943 createSMESHAction( 804, "ADD" );
2944 createSMESHAction( 805, "REMOVE" );
2945 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2946 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2947 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2948 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2949 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2950 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2951 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2952 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2953 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
2954 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2955 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2956 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
2957 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2958 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2959 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
2960 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2961 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2962 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2963 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2964 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2965 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2966 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2967 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2968 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2969 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2970 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
2971 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
2972 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
2973 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2974 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2975 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2976 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2977 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2978 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2979 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2980 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2981 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2982 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2983 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2984 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2985 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2986 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2987 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2988 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2989 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2990 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
2991 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2992 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2993 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2994 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2995 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2996 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2997 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2998 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2999 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3000 createSMESHAction( 415, "MAP", "ICON_MAP" );
3001 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3002 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3003 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3004 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3005 createSMESHAction( 200, "RESET" );
3006 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3007 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3008 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3009 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3010 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3011 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3012 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3013 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3014 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3015 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3016 createSMESHAction( 220, "ALL" );
3017 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3019 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3020 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3022 createSMESHAction( 1100, "EDIT_HYPO" );
3023 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3024 createSMESHAction( 1102, "UNASSIGN" );
3025 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3026 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3027 createSMESHAction( 1131, "DISPMODE" );
3028 createSMESHAction( 1132, "COLORS" );
3029 createSMESHAction( 1133, "TRANSP" );
3030 createSMESHAction( 1134, "CLIP" );
3031 createSMESHAction( 1135, "DISP_ENT" );
3032 createSMESHAction( 1136, "AUTO_COLOR" );
3033 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3034 createSMESHAction( 2000, "CTRL" );
3036 createSMESHAction( 300, "ERASE" );
3037 createSMESHAction( 301, "DISPLAY" );
3038 createSMESHAction( 302, "DISPLAY_ONLY" );
3039 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3040 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3041 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3042 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3043 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3044 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3045 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3046 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3048 // ----- create menu --------------
3049 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3050 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3051 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3052 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3053 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3054 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3055 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3057 createMenu( separator(), fileId );
3059 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3060 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3061 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3062 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3063 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3064 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3066 createMenu( 111, importId, -1 );
3067 createMenu( 112, importId, -1 );
3068 createMenu( 113, importId, -1 );
3070 createMenu( 121, exportId, -1 );
3071 createMenu( 122, exportId, -1 );
3072 createMenu( 123, exportId, -1 );
3073 createMenu( 140, exportId, -1 ); // export to stl STL
3075 createMenu( separator(), fileId, 10 );
3077 createMenu( 33, editId, -1 );
3079 createMenu( 5105, toolsId, -1 );
3081 createMenu( 702, meshId, -1 ); // "Mesh" menu
3082 createMenu( 703, meshId, -1 );
3083 createMenu( 704, meshId, -1 );
3084 createMenu( 710, meshId, -1 );
3085 createMenu( separator(), meshId, -1 );
3086 createMenu( 701, meshId, -1 );
3087 createMenu( 711, meshId, -1 );
3088 createMenu( 712, meshId, -1 );
3089 createMenu( 713, meshId, -1 );
3090 createMenu( separator(), meshId, -1 );
3091 createMenu( 801, meshId, -1 );
3092 createMenu( 806, meshId, -1 );
3093 createMenu( 802, meshId, -1 );
3094 createMenu( 803, meshId, -1 );
3095 createMenu( 815, meshId, -1 );
3096 createMenu( separator(), meshId, -1 );
3097 createMenu( 810, meshId, -1 );
3098 createMenu( 811, meshId, -1 );
3099 createMenu( 812, meshId, -1 );
3100 createMenu( separator(), meshId, -1 );
3101 createMenu( 814, meshId, -1 );
3102 createMenu( separator(), meshId, -1 );
3103 createMenu( 813, meshId, -1 );
3104 createMenu( separator(), meshId, -1 );
3105 createMenu( 900, meshId, -1 );
3106 createMenu( 902, meshId, -1 );
3107 createMenu( 903, meshId, -1 );
3108 createMenu( 904, meshId, -1 );
3109 createMenu( separator(), meshId, -1 );
3111 createMenu( 6003, ctrlId, -1 );
3112 createMenu( 6001, ctrlId, -1 );
3113 createMenu( 6004, ctrlId, -1 );
3114 createMenu( separator(), ctrlId, -1 );
3115 createMenu( 6005, ctrlId, -1 );
3116 createMenu( 6002, ctrlId, -1 );
3117 createMenu( 6018, ctrlId, -1 );
3118 createMenu( 6019, ctrlId, -1 );
3119 createMenu( 6011, ctrlId, -1 );
3120 createMenu( 6012, ctrlId, -1 );
3121 createMenu( 6013, ctrlId, -1 );
3122 createMenu( 6014, ctrlId, -1 );
3123 createMenu( 6015, ctrlId, -1 );
3124 createMenu( 6016, ctrlId, -1 );
3125 createMenu( separator(), ctrlId, -1 );
3126 createMenu( 6017, ctrlId, -1 );
3127 createMenu( 6009, ctrlId, -1 );
3128 createMenu( 6021, ctrlId, -1 );
3129 createMenu( separator(), ctrlId, -1 );
3131 createMenu( 4000, addId, -1 );
3132 createMenu( 4009, addId, -1 );
3133 createMenu( 4010, addId, -1 );
3134 createMenu( 4021, addId, -1 );
3135 createMenu( 4022, addId, -1 );
3136 createMenu( 4023, addId, -1 );
3137 createMenu( 4031, addId, -1 );
3138 createMenu( 4032, addId, -1 );
3139 createMenu( 4033, addId, -1 );
3140 createMenu( separator(), addId, -1 );
3141 createMenu( 4034, addId, -1 );
3142 createMenu( 4035, addId, -1 );
3143 createMenu( 4036, addId, -1 );
3144 createMenu( 4037, addId, -1 );
3145 createMenu( 4038, addId, -1 );
3146 createMenu( 4039, addId, -1 );
3147 createMenu( 4040, addId, -1 );
3149 createMenu( 4041, removeId, -1 );
3150 createMenu( 4042, removeId, -1 );
3151 createMenu( 4043, removeId, -1 );
3153 createMenu( 4051, renumId, -1 );
3154 createMenu( 4052, renumId, -1 );
3156 createMenu( 4061, transfId, -1 );
3157 createMenu( 4062, transfId, -1 );
3158 createMenu( 4063, transfId, -1 );
3159 createMenu( 4064, transfId, -1 );
3160 createMenu( 4065, transfId, -1 );
3161 createMenu( 4066, transfId, -1 );
3162 createMenu( 4068, transfId, -1 );
3164 createMenu( 406, modifyId, -1 );
3165 createMenu( 4067,modifyId, -1 );
3166 createMenu( 407, modifyId, -1 );
3167 createMenu( 408, modifyId, -1 );
3168 createMenu( 409, modifyId, -1 );
3169 createMenu( 410, modifyId, -1 );
3170 createMenu( 411, modifyId, -1 );
3171 createMenu( 419, modifyId, -1 );
3172 createMenu( 412, modifyId, -1 );
3173 createMenu( 413, modifyId, -1 );
3174 createMenu( 416, modifyId, -1 );
3175 createMenu( 414, modifyId, -1 );
3176 createMenu( 415, modifyId, -1 );
3177 createMenu( 417, modifyId, -1 );
3178 createMenu( 418, modifyId, -1 );
3180 createMenu( 214, viewId, -1 );
3182 // ----- create toolbars --------------
3183 int meshTb = createTool( tr( "TB_MESH" ) ),
3184 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3185 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3186 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3187 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3189 createTool( 702, meshTb );
3190 createTool( 703, meshTb );
3191 createTool( 704, meshTb );
3192 createTool( 710, meshTb );
3193 createTool( separator(), meshTb );
3194 createTool( 701, meshTb );
3195 createTool( 711, meshTb );
3196 createTool( 712, meshTb );
3197 createTool( 713, meshTb );
3198 createTool( separator(), meshTb );
3199 createTool( 801, meshTb );
3200 createTool( 806, meshTb );
3201 createTool( 802, meshTb );
3202 createTool( 803, meshTb );
3203 //createTool( 815, meshTb );
3204 createTool( separator(), meshTb );
3205 createTool( 900, meshTb );
3206 createTool( 902, meshTb );
3207 createTool( 903, meshTb );
3208 createTool( 904, meshTb );
3209 createTool( separator(), meshTb );
3211 createTool( 6001, ctrlTb );
3212 createTool( 6003, ctrlTb );
3213 createTool( 6004, ctrlTb );
3214 createTool( separator(), ctrlTb );
3215 createTool( 6005, ctrlTb );
3216 createTool( 6002, ctrlTb );
3217 createTool( 6018, ctrlTb );
3218 createTool( 6019, ctrlTb );
3219 createTool( 6011, ctrlTb );
3220 createTool( 6012, ctrlTb );
3221 createTool( 6013, ctrlTb );
3222 createTool( 6014, ctrlTb );
3223 createTool( 6015, ctrlTb );
3224 createTool( 6016, ctrlTb );
3225 createTool( separator(), ctrlTb );
3226 createTool( 6017, ctrlTb );
3227 createTool( 6009, ctrlTb );
3228 createTool( 6021, ctrlTb );
3229 createTool( separator(), ctrlTb );
3231 createTool( 4000, addRemTb );
3232 createTool( 4009, addRemTb );
3233 createTool( 4010, addRemTb );
3234 createTool( 4021, addRemTb );
3235 createTool( 4022, addRemTb );
3236 createTool( 4023, addRemTb );
3237 createTool( 4031, addRemTb );
3238 createTool( 4032, addRemTb );
3239 createTool( 4033, addRemTb );
3240 createTool( separator(), addRemTb );
3241 createTool( 4034, addRemTb );
3242 createTool( 4035, addRemTb );
3243 createTool( 4036, addRemTb );
3244 createTool( 4037, addRemTb );
3245 createTool( 4038, addRemTb );
3246 createTool( 4039, addRemTb );
3247 createTool( 4040, addRemTb );
3248 createTool( separator(), addRemTb );
3249 createTool( 4041, addRemTb );
3250 createTool( 4042, addRemTb );
3251 createTool( 4043, addRemTb );
3252 createTool( separator(), addRemTb );
3253 createTool( 4051, addRemTb );
3254 createTool( 4052, addRemTb );
3255 createTool( separator(), addRemTb );
3256 createTool( 4061, addRemTb );
3257 createTool( 4062, addRemTb );
3258 createTool( 4063, addRemTb );
3259 createTool( 4064, addRemTb );
3260 createTool( 4065, addRemTb );
3261 createTool( 4066, addRemTb );
3262 createTool( 4068, addRemTb );
3263 createTool( separator(), addRemTb );
3265 createTool( 406, modifyTb );
3266 createTool( 4067,modifyTb );
3267 createTool( 407, modifyTb );
3268 createTool( 408, modifyTb );
3269 createTool( 409, modifyTb );
3270 createTool( 410, modifyTb );
3271 createTool( 411, modifyTb );
3272 createTool( 419, modifyTb );
3273 createTool( 412, modifyTb );
3274 createTool( 413, modifyTb );
3275 createTool( 416, modifyTb );
3276 createTool( 414, modifyTb );
3277 createTool( 415, modifyTb );
3278 createTool( 417, modifyTb );
3279 createTool( 418, modifyTb );
3281 createTool( 214, dispModeTb );
3283 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3284 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3287 QString OB = "'ObjectBrowser'",
3288 View = "'" + SVTK_Viewer::Type() + "'",
3290 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3291 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3292 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3293 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3294 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3295 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3296 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3297 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3298 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3299 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3300 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3302 mesh_group = mesh + " " + subMesh + " " + group,
3303 hyp_alg = hypo + " " + algo;
3305 // popup for object browser
3307 isInvisible("not( isVisible )"),
3308 isEmpty("numberOfNodes = 0"),
3309 isNotEmpty("numberOfNodes <> 0"),
3311 // has nodes, edges, etc in VISIBLE! actor
3312 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3313 hasElems("(count( elemTypes ) > 0)"),
3314 hasDifferentElems("(count( elemTypes ) > 1)"),
3315 hasElems0d("({'Elem0d'} in elemTypes)"),
3316 hasEdges("({'Edge'} in elemTypes)"),
3317 hasFaces("({'Face'} in elemTypes)"),
3318 hasVolumes("({'Volume'} in elemTypes)");
3320 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3321 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3322 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3323 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3324 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3325 createPopupItem( 803, OB, group ); // EDIT_GROUP
3326 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3328 popupMgr()->insert( separator(), -1, 0 );
3329 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3330 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3331 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3332 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3333 createPopupItem( 214, OB, mesh_group ); // UPDATE
3334 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3335 createPopupItem( 902, OB, mesh ); // STD_INFO
3336 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3337 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3338 popupMgr()->insert( separator(), -1, 0 );
3339 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3340 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3341 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3342 popupMgr()->insert( separator(), -1, 0 );
3343 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3344 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3345 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3346 popupMgr()->insert( separator(), -1, 0 );
3347 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3348 popupMgr()->insert( separator(), -1, 0 );
3349 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3350 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3351 popupMgr()->insert( separator(), -1, 0 );
3353 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3354 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3356 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3357 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3358 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3359 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3360 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3361 popupMgr()->insert( separator(), -1, 0 );
3364 createPopupItem( 803, View, group ); // EDIT_GROUP
3365 createPopupItem( 804, View, elems ); // ADD
3366 createPopupItem( 805, View, elems ); // REMOVE
3368 popupMgr()->insert( separator(), -1, 0 );
3369 createPopupItem( 214, View, mesh_group ); // UPDATE
3370 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3371 createPopupItem( 902, View, mesh ); // STD_INFO
3372 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3373 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3374 popupMgr()->insert( separator(), -1, 0 );
3376 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3377 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3378 popupMgr()->insert( separator(), -1, 0 );
3381 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3382 QString aType = QString( "%1type in {%2}" ).arg( lc );
3383 aType = aType.arg( mesh_group );
3384 QString aMeshInVTK = aClient + "&&" + aType;
3386 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3387 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3388 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3390 //-------------------------------------------------
3392 //-------------------------------------------------
3393 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3395 popupMgr()->insert( action( 9010 ), anId, -1 );
3396 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3397 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3399 popupMgr()->insert( action( 9011 ), anId, -1 );
3400 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3401 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3403 popupMgr()->insert( separator(), -1, -1 );
3405 //-------------------------------------------------
3407 //-------------------------------------------------
3408 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3410 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3411 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3412 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3414 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3415 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3416 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3418 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3419 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3420 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3422 popupMgr()->insert( separator(), anId, -1 );
3424 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3425 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3426 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3428 //-------------------------------------------------
3430 //-------------------------------------------------
3431 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3433 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3435 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3436 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3437 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3439 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3440 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3441 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3443 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3444 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3445 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3447 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3448 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3449 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3451 popupMgr()->insert( separator(), anId, -1 );
3453 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3454 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3457 //-------------------------------------------------
3458 // Representation of the 2D Quadratic elements
3459 //-------------------------------------------------
3460 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3461 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3462 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3463 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3465 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3466 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3467 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3469 //-------------------------------------------------
3470 // Orientation of faces
3471 //-------------------------------------------------
3472 popupMgr()->insert( action( 221 ), -1, -1 );
3473 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3474 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3476 //-------------------------------------------------
3478 //-------------------------------------------------
3479 popupMgr()->insert( action( 1132 ), -1, -1 );
3480 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3482 //-------------------------------------------------
3484 //-------------------------------------------------
3485 popupMgr()->insert( action( 1133 ), -1, -1 );
3486 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3488 //-------------------------------------------------
3490 //-------------------------------------------------
3491 popupMgr()->insert( action( 1134 ), -1, -1 );
3492 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3494 popupMgr()->insert( separator(), -1, -1 );
3496 //-------------------------------------------------
3498 //-------------------------------------------------
3500 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3501 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3502 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3503 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3505 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3507 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3508 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3510 popupMgr()->insert( separator(), anId, -1 );
3512 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3513 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3514 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3516 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3517 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3518 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3520 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3521 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3522 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3524 popupMgr()->insert( separator(), anId, -1 );
3526 popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
3527 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3528 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3530 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3531 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3532 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3534 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3535 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3536 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3538 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3539 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3540 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3542 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3543 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3544 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3546 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3547 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3548 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3550 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3551 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3552 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3554 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3555 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3556 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3558 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3559 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3560 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3562 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3563 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3564 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3566 popupMgr()->insert( separator(), anId, -1 );
3568 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3569 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3570 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3572 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3573 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3574 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3576 popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
3577 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3578 QtxPopupMgr::VisibleRule );
3579 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3581 popupMgr()->insert( separator(), anId, -1 );
3583 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3584 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3586 popupMgr()->insert( separator(), -1, -1 );
3588 //-------------------------------------------------
3590 //-------------------------------------------------
3591 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3592 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3593 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3594 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3596 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3597 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3599 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3600 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3602 popupMgr()->insert( separator(), -1, -1 );
3604 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3605 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3608 //================================================================================
3610 * \brief Return true if SMESH or GEOM objects are selected.
3611 * Is called form LightApp_Module::activateModule() which clear selection if
3612 * not isSelectionCompatible()
3614 //================================================================================
3616 bool SMESHGUI::isSelectionCompatible()
3618 bool isCompatible = true;
3619 SALOME_ListIO selected;
3620 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3621 Sel->selectedObjects( selected );
3623 SALOME_ListIteratorOfListIO It( selected );
3624 for ( ; isCompatible && It.More(); It.Next())
3626 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3627 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3629 return isCompatible;
3633 bool SMESHGUI::reusableOperation( const int id )
3635 // compute, evaluate and precompute are not reusable operations
3636 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3639 bool SMESHGUI::activateModule( SUIT_Study* study )
3641 bool res = SalomeApp_Module::activateModule( study );
3643 setMenuShown( true );
3644 setToolShown( true );
3646 // Reset actions accelerator keys
3647 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3648 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3649 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3651 action( 33)->setEnabled(true); // Delete: Key_Delete
3652 action(1101)->setEnabled(true); // Rename: Key_F2
3654 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3655 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3656 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3657 if ( _PTR(Study) aStudy = s->studyDS()) {
3658 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3659 updateObjBrowser(); // objects can be removed
3665 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3667 setMenuShown( false );
3668 setToolShown( false );
3670 EmitSignalCloseAllDialogs();
3672 // Unset actions accelerator keys
3673 action(111)->setShortcut(QKeySequence()); // Import DAT
3674 action(112)->setShortcut(QKeySequence()); // Import UNV
3675 action(113)->setShortcut(QKeySequence()); // Import MED
3677 action( 33)->setEnabled(false); // Delete: Key_Delete
3678 action(1101)->setEnabled(false); // Rename: Key_F2
3680 return SalomeApp_Module::deactivateModule( study );
3683 void SMESHGUI::studyClosed( SUIT_Study* s )
3685 SMESH::RemoveVisuData( s->id() );
3686 SalomeApp_Module::studyClosed( s );
3689 void SMESHGUI::OnGUIEvent()
3691 const QObject* obj = sender();
3692 if ( !obj || !obj->inherits( "QAction" ) )
3694 int id = actionId((QAction*)obj);
3699 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3701 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3702 if ( CORBA::is_nil( myComponentSMESH ) )
3704 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3706 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3707 return aGUI.myComponentSMESH;
3710 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3711 return myComponentSMESH;
3714 QString SMESHGUI::engineIOR() const
3716 CORBA::ORB_var anORB = getApp()->orb();
3717 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3718 return QString( anIOR.in() );
3721 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3723 SalomeApp_Module::contextMenuPopup( client, menu, title );
3725 selectionMgr()->selectedObjects( lst );
3726 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3727 Handle(SALOME_InteractiveObject) io = lst.First();
3728 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3729 _PTR(Study) study = appStudy->studyDS();
3730 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3732 QString aName = QString( obj->GetName().c_str() );
3733 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3734 aName.remove( (aName.length() - 1), 1 );
3740 LightApp_Selection* SMESHGUI::createSelection() const
3742 return new SMESHGUI_Selection();
3745 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3747 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3748 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3751 void SMESHGUI::viewManagers( QStringList& list ) const
3753 list.append( SVTK_Viewer::Type() );
3756 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3758 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3759 SMESH::UpdateSelectionProp( this );
3762 void SMESHGUI::createPreferences()
3764 // General tab ------------------------------------------------------------------------
3765 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3767 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3768 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3770 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3771 setPreferenceProperty( qaGroup, "columns", 2 );
3772 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3773 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3774 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3775 setPreferenceProperty( prec, "min", 0 );
3776 setPreferenceProperty( prec, "max", 16 );
3778 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3779 setPreferenceProperty( dispgroup, "columns", 2 );
3780 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3782 modes.append( "Wireframe" );
3783 modes.append( "Shading" );
3784 modes.append( "Nodes" );
3785 modes.append( "Shrink" );
3786 QList<QVariant> indices;
3787 indices.append( 0 );
3788 indices.append( 1 );
3789 indices.append( 2 );
3790 indices.append( 3 );
3791 setPreferenceProperty( dispmode, "strings", modes );
3792 setPreferenceProperty( dispmode, "indexes", indices );
3794 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
3795 setPreferenceProperty( arcgroup, "columns", 2 );
3796 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
3797 QStringList quadraticModes;
3798 quadraticModes.append("Lines");
3799 quadraticModes.append("Arcs");
3801 indices.append( 0 );
3802 indices.append( 1 );
3803 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
3804 setPreferenceProperty( quadraticmode, "indexes", indices );
3806 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
3807 "SMESH", "max_angle" );
3808 setPreferenceProperty( maxAngle, "min", 1 );
3809 setPreferenceProperty( maxAngle, "max", 90 );
3813 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3814 setPreferenceProperty( exportgroup, "columns", 2 );
3815 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3816 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3818 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3819 setPreferenceProperty( computeGroup, "columns", 2 );
3820 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3822 modes.append( "Never" );
3823 modes.append( "Errors only" );
3824 modes.append( "Always" );
3826 indices.append( 0 );
3827 indices.append( 1 );
3828 indices.append( 2 );
3829 setPreferenceProperty( notifyMode, "strings", modes );
3830 setPreferenceProperty( notifyMode, "indexes", indices );
3832 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
3833 setPreferenceProperty( segGroup, "columns", 2 );
3834 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
3835 "SMESH", "segmentation" );
3836 setPreferenceProperty( segLen, "min", 1 );
3837 setPreferenceProperty( segLen, "max", 10000000 );
3838 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
3839 "SMESH", "nb_segments_per_edge" );
3840 setPreferenceProperty( nbSeg, "min", 1 );
3841 setPreferenceProperty( nbSeg, "max", 10000000 );
3843 // Quantities with individual precision settings
3844 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
3845 setPreferenceProperty( precGroup, "columns", 2 );
3847 const int nbQuantities = 6;
3848 int precs[nbQuantities], ii = 0;
3849 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
3850 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
3851 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
3852 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
3853 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
3854 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
3855 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
3856 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
3857 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
3858 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
3859 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
3860 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
3862 // Set property for precision value for spinboxes
3863 for ( ii = 0; ii < nbQuantities; ii++ ){
3864 setPreferenceProperty( precs[ii], "min", -14 );
3865 setPreferenceProperty( precs[ii], "max", 14 );
3866 setPreferenceProperty( precs[ii], "precision", 2 );
3869 // Mesh tab ------------------------------------------------------------------------
3870 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3871 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3872 setPreferenceProperty( nodeGroup, "columns", 3 );
3874 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3876 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
3878 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3879 QList<QVariant> aMarkerTypeIndicesList;
3880 QList<QVariant> aMarkerTypeIconsList;
3881 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
3882 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
3883 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
3884 aMarkerTypeIndicesList << i;
3885 aMarkerTypeIconsList << pixmap;
3887 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
3888 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
3890 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
3892 QList<QVariant> aMarkerScaleIndicesList;
3893 QStringList aMarkerScaleValuesList;
3894 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
3895 aMarkerScaleIndicesList << i;
3896 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
3898 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
3899 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
3901 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3902 setPreferenceProperty( elemGroup, "columns", 2 );
3904 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3905 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3906 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3907 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
3909 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3910 //setPreferenceProperty( sp, "hstretch", 0 );
3911 //setPreferenceProperty( sp, "vstretch", 0 );
3913 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
3914 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
3915 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3916 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
3917 LightApp_Preferences::IntSpin, "SMESH", "element_width");
3918 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
3919 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
3921 setPreferenceProperty( size0d, "min", 1 );
3922 setPreferenceProperty( size0d, "max", 10 );
3924 setPreferenceProperty( sp, "hstretch", 0 );
3925 setPreferenceProperty( sp, "vstretch", 0 );
3927 setPreferenceProperty( elemW, "min", 1 );
3928 setPreferenceProperty( elemW, "max", 5 );
3930 setPreferenceProperty( shrink, "min", 0 );
3931 setPreferenceProperty( shrink, "max", 100 );
3933 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3934 setPreferenceProperty( orientGroup, "columns", 1 );
3936 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3937 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3939 setPreferenceProperty( orientScale, "min", 0.05 );
3940 setPreferenceProperty( orientScale, "max", 0.5 );
3941 setPreferenceProperty( orientScale, "step", 0.05 );
3943 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3945 // Selection tab ------------------------------------------------------------------------
3946 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3948 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3949 setPreferenceProperty( selGroup, "columns", 2 );
3951 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3952 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3953 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3955 setPreferenceProperty( selW, "min", 1 );
3956 setPreferenceProperty( selW, "max", 5 );
3958 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3959 setPreferenceProperty( preGroup, "columns", 2 );
3961 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3962 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3964 setPreferenceProperty( preW, "min", 1 );
3965 setPreferenceProperty( preW, "max", 5 );
3967 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3968 setPreferenceProperty( precSelGroup, "columns", 2 );
3970 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3971 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3972 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3974 // Scalar Bar tab ------------------------------------------------------------------------
3975 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3976 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3977 setPreferenceProperty( fontGr, "columns", 2 );
3979 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
3980 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3982 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
3983 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3985 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3986 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3988 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3989 setPreferenceProperty( numcol, "min", 2 );
3990 setPreferenceProperty( numcol, "max", 256 );
3992 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3993 setPreferenceProperty( numlab, "min", 2 );
3994 setPreferenceProperty( numlab, "max", 65 );
3996 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3997 setPreferenceProperty( orientGr, "columns", 2 );
3998 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3999 QStringList orients;
4000 orients.append( tr( "SMESH_VERTICAL" ) );
4001 orients.append( tr( "SMESH_HORIZONTAL" ) );
4002 indices.clear(); indices.append( 0 ); indices.append( 1 );
4003 setPreferenceProperty( orient, "strings", orients );
4004 setPreferenceProperty( orient, "indexes", indices );
4006 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4007 setPreferenceProperty( posVSizeGr, "columns", 2 );
4008 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4009 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4010 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4011 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4012 setPreferenceProperty( xv, "step", 0.1 );
4013 setPreferenceProperty( xv, "min", 0.0 );
4014 setPreferenceProperty( xv, "max", 1.0 );
4015 setPreferenceProperty( yv, "step", 0.1 );
4016 setPreferenceProperty( yv, "min", 0.0 );
4017 setPreferenceProperty( yv, "max", 1.0 );
4018 setPreferenceProperty( wv, "step", 0.1 );
4019 setPreferenceProperty( wv, "min", 0.0 );
4020 setPreferenceProperty( wv, "max", 1.0 );
4021 setPreferenceProperty( hv, "min", 0.0 );
4022 setPreferenceProperty( hv, "max", 1.0 );
4023 setPreferenceProperty( hv, "step", 0.1 );
4025 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4026 setPreferenceProperty( posHSizeGr, "columns", 2 );
4027 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4028 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4029 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4030 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4031 setPreferenceProperty( xv, "min", 0.0 );
4032 setPreferenceProperty( xv, "max", 1.0 );
4033 setPreferenceProperty( xv, "step", 0.1 );
4034 setPreferenceProperty( xh, "min", 0.0 );
4035 setPreferenceProperty( xh, "max", 1.0 );
4036 setPreferenceProperty( xh, "step", 0.1 );
4037 setPreferenceProperty( yh, "min", 0.0 );
4038 setPreferenceProperty( yh, "max", 1.0 );
4039 setPreferenceProperty( yh, "step", 0.1 );
4040 setPreferenceProperty( wh, "min", 0.0 );
4041 setPreferenceProperty( wh, "max", 1.0 );
4042 setPreferenceProperty( wh, "step", 0.1 );
4043 setPreferenceProperty( hh, "min", 0.0 );
4044 setPreferenceProperty( hh, "max", 1.0 );
4045 setPreferenceProperty( hh, "step", 0.1 );
4048 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4050 if( sect=="SMESH" ) {
4051 float sbX1,sbY1,sbW,sbH;
4052 float aTol = 1.00000009999999;
4053 std::string aWarning;
4054 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4055 if( name=="selection_object_color" || name=="selection_element_color" ||
4056 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4057 name=="selection_precision_node" || name=="selection_precision_element" ||
4058 name=="selection_precision_object")
4059 SMESH::UpdateSelectionProp( this );
4060 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4061 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4062 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4063 if(sbX1+sbW > aTol){
4064 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4067 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4068 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4071 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4072 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4073 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4074 if(sbY1+sbH > aTol){
4075 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4076 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4077 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4080 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4081 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4082 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4083 if(sbX1+sbW > aTol){
4084 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4087 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4088 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4091 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4092 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4093 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4094 if(sbY1+sbH > aTol){
4095 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4098 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4099 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4102 else if ( name == "segmentation" ) {
4103 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4104 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4106 else if ( name == "nb_segments_per_edge" ) {
4107 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4108 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4111 if(aWarning.size() != 0){
4112 aWarning += "The default values are applied instead.";
4113 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4114 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4115 QObject::tr(aWarning.c_str()));
4120 //================================================================================
4122 * \brief Update something in accordance with update flags
4123 * \param theFlags - update flags
4125 * Update viewer or/and object browser etc. in accordance with update flags ( see
4126 * LightApp_UpdateFlags enumeration ).
4128 //================================================================================
4129 void SMESHGUI::update( const int flags )
4131 if ( flags & UF_Viewer | flags & UF_Forced )
4132 SMESH::UpdateView();
4134 SalomeApp_Module::update( flags );
4137 //================================================================================
4139 * \brief Set default selection mode
4141 * SLOT called when operation commited. Sets default selection mode
4143 //================================================================================
4144 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4146 SVTK_ViewWindow* vtkWnd =
4147 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4149 vtkWnd->SetSelectionMode( ActorSelection );
4152 //================================================================================
4154 * \brief Set default selection mode
4156 * SLOT called when operation aborted. Sets default selection mode
4158 //================================================================================
4159 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4161 SVTK_ViewWindow* vtkWnd =
4162 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4164 vtkWnd->SetSelectionMode( ActorSelection );
4167 //================================================================================
4169 * \brief Creates operation with given identifier
4170 * \param id - identifier of operation to be started
4171 * \return Pointer on created operation or NULL if operation is not created
4173 * Virtual method redefined from the base class creates operation with given id.
4174 * It is called called automatically from startOperation method of base class.
4176 //================================================================================
4177 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4179 LightApp_Operation* op = 0;
4180 // to do : create operation here
4183 case 417: //convert to quadratic
4184 op = new SMESHGUI_ConvToQuadOp();
4186 case 418: // create 2D mesh as boundary on 3D
4187 op = new SMESHGUI_Make2DFrom3DOp();
4189 case 701: // Compute mesh
4190 op = new SMESHGUI_ComputeOp();
4192 case 702: // Create mesh
4193 op = new SMESHGUI_MeshOp( true, true );
4195 case 703: // Create sub-mesh
4196 op = new SMESHGUI_MeshOp( true, false );
4198 case 704: // Edit mesh/sub-mesh
4199 op = new SMESHGUI_MeshOp( false );
4201 case 711: // Precompute mesh
4202 op = new SMESHGUI_PrecomputeOp();
4204 case 712: // Evaluate mesh
4205 op = new SMESHGUI_EvaluateOp();
4207 case 713: // Evaluate mesh
4208 op = new SMESHGUI_MeshOrderOp();
4210 case 806: // Create group on geom
4211 op = new SMESHGUI_GroupOnShapeOp();
4213 case 904: // Find element
4214 op = new SMESHGUI_FindElemByPointOp();
4216 case 4067: // make mesh pass through point
4217 op = new SMESHGUI_MakeNodeAtPointOp();
4224 op = SalomeApp_Module::createOperation( id );
4228 //================================================================================
4230 * \brief Stops current operations and starts a given one
4231 * \param id - The id of the operation to start
4233 //================================================================================
4235 void SMESHGUI::switchToOperation(int id)
4237 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4238 activeStudy()->abortAllOperations();
4239 startOperation( id );
4242 LightApp_Displayer* SMESHGUI::displayer()
4245 myDisplayer = new SMESHGUI_Displayer( getApp() );
4249 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4252 int aTolerance = 64;
4253 int anIterations = 0;
4259 if( anIterations % aPeriod == 0 )
4262 if( aTolerance < 1 )
4265 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4267 aHue = (int)( 360.0 * rand() / RAND_MAX );
4268 //cout << "Hue = " << aHue << endl;
4270 //cout << "Auto colors : ";
4272 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4273 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4274 for( ; it != itEnd; ++it )
4276 SALOMEDS::Color anAutoColor = *it;
4277 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4280 aQColor.getHsv( &h, &s, &v );
4282 if( abs( h - aHue ) < aTolerance )
4285 //cout << "break (diff = " << abs( h - aHue ) << ")";
4295 //cout << "Hue of the returned color = " << aHue << endl;
4297 aColor.setHsv( aHue, 255, 255 );
4299 SALOMEDS::Color aSColor;
4300 aSColor.R = (double)aColor.red() / 255.0;
4301 aSColor.G = (double)aColor.green() / 255.0;
4302 aSColor.B = (double)aColor.blue() / 255.0;
4307 const char gSeparator = '_'; // character used to separate parameter names
4308 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4309 const char gPathSep = '|'; // character used to separate paths
4312 * \brief Store visual parameters
4314 * This method is called just before the study document is saved.
4315 * Store visual parameters in AttributeParameter attribue(s)
4317 void SMESHGUI::storeVisualParameters (int savePoint)
4319 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4320 if (!appStudy || !appStudy->studyDS())
4322 _PTR(Study) studyDS = appStudy->studyDS();
4324 // componentName is used for encoding of entries when storing them in IParameters
4325 std::string componentName = myComponentSMESH->ComponentDataType();
4326 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4327 //if (!aSComponent) return;
4330 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4331 componentName.c_str(),
4333 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4335 // store map of custom markers
4336 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4337 if( !aMarkerMap.empty() )
4339 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4340 for( ; anIter != aMarkerMap.end(); anIter++ )
4342 int anId = anIter->first;
4343 VTK::MarkerData aMarkerData = anIter->second;
4344 std::string aMarkerFileName = aMarkerData.first;
4345 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4346 if( aMarkerTexture.size() < 3 )
4347 continue; // should contain at least width, height and the first value
4349 QString aPropertyName( "texture" );
4350 aPropertyName += gSeparator;
4351 aPropertyName += QString::number( anId );
4353 QString aPropertyValue = aMarkerFileName.c_str();
4354 aPropertyValue += gPathSep;
4356 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4357 ushort aWidth = *aTextureIter++;
4358 ushort aHeight = *aTextureIter++;
4359 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4360 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4361 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4362 aPropertyValue += QString::number( *aTextureIter );
4364 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4368 // viewers counters are used for storing view_numbers in IParameters
4371 // main cycle to store parameters of displayed objects
4372 QList<SUIT_ViewManager*> lst;
4373 QList<SUIT_ViewManager*>::Iterator it;
4374 getApp()->viewManagers(lst);
4375 for (it = lst.begin(); it != lst.end(); it++)
4377 SUIT_ViewManager* vman = *it;
4378 QString vType = vman->getType();
4380 // saving VTK actors properties
4381 if (vType == SVTK_Viewer::Type())
4383 QVector<SUIT_ViewWindow*> views = vman->getViews();
4384 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4386 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4388 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4389 vtkActorCollection* allActors = aCopy.GetActors();
4390 allActors->InitTraversal();
4391 while (vtkActor* actor = allActors->GetNextActor())
4393 if (actor->GetVisibility()) // store only visible actors
4395 SMESH_Actor* aSmeshActor = 0;
4396 if (actor->IsA("SMESH_Actor"))
4397 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4398 if (aSmeshActor && aSmeshActor->hasIO())
4400 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4403 // entry is "encoded" = it does NOT contain component adress,
4404 // since it is a subject to change on next component loading
4405 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4407 std::string param, vtkParam = vType.toLatin1().data();
4408 vtkParam += gSeparator;
4409 vtkParam += QString::number(vtkViewers).toLatin1().data();
4410 vtkParam += gSeparator;
4413 param = vtkParam + "Visibility";
4414 ip->setParameter(entry, param, "On");
4417 param = vtkParam + "Representation";
4418 ip->setParameter(entry, param, QString::number
4419 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4422 param = vtkParam + "IsShrunk";
4423 ip->setParameter(entry, param, QString::number
4424 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4426 // Displayed entities
4427 unsigned int aMode = aSmeshActor->GetEntityMode();
4428 bool isE = aMode & SMESH_Actor::eEdges;
4429 bool isF = aMode & SMESH_Actor::eFaces;
4430 bool isV = aMode & SMESH_Actor::eVolumes;
4432 QString modeStr ("e");
4433 modeStr += gDigitsSep; modeStr += QString::number(isE);
4434 modeStr += gDigitsSep; modeStr += "f";
4435 modeStr += gDigitsSep; modeStr += QString::number(isF);
4436 modeStr += gDigitsSep; modeStr += "v";
4437 modeStr += gDigitsSep; modeStr += QString::number(isV);
4439 param = vtkParam + "Entities";
4440 ip->setParameter(entry, param, modeStr.toLatin1().data());
4442 // Colors (surface:edge:)
4443 vtkFloatingPointType r, g, b;
4445 aSmeshActor->GetSufaceColor(r, g, b);
4446 QString colorStr ("surface");
4447 colorStr += gDigitsSep; colorStr += QString::number(r);
4448 colorStr += gDigitsSep; colorStr += QString::number(g);
4449 colorStr += gDigitsSep; colorStr += QString::number(b);
4451 aSmeshActor->GetBackSufaceColor(r, g, b);
4452 colorStr += gDigitsSep; colorStr += "backsurface";
4453 colorStr += gDigitsSep; colorStr += QString::number(r);
4454 colorStr += gDigitsSep; colorStr += QString::number(g);
4455 colorStr += gDigitsSep; colorStr += QString::number(b);
4457 aSmeshActor->GetEdgeColor(r, g, b);
4458 colorStr += gDigitsSep; colorStr += "edge";
4459 colorStr += gDigitsSep; colorStr += QString::number(r);
4460 colorStr += gDigitsSep; colorStr += QString::number(g);
4461 colorStr += gDigitsSep; colorStr += QString::number(b);
4463 aSmeshActor->GetNodeColor(r, g, b);
4464 colorStr += gDigitsSep; colorStr += "node";
4465 colorStr += gDigitsSep; colorStr += QString::number(r);
4466 colorStr += gDigitsSep; colorStr += QString::number(g);
4467 colorStr += gDigitsSep; colorStr += QString::number(b);
4469 param = vtkParam + "Colors";
4470 ip->setParameter(entry, param, colorStr.toLatin1().data());
4472 // Sizes of lines and points
4473 QString sizeStr ("line");
4474 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4475 sizeStr += gDigitsSep; sizeStr += "shrink";
4476 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4478 param = vtkParam + "Sizes";
4479 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4484 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4485 if( aMarkerType == VTK::MT_USER ) {
4486 markerStr += "custom";
4487 markerStr += gDigitsSep;
4488 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4492 markerStr += gDigitsSep;
4493 markerStr += QString::number( (int)aMarkerType );
4494 markerStr += gDigitsSep;
4495 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4498 param = vtkParam + "PointMarker";
4499 ip->setParameter(entry, param, markerStr.toLatin1().data());
4502 param = vtkParam + "Opacity";
4503 ip->setParameter(entry, param,
4504 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4507 param = vtkParam + "ClippingPlane";
4508 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4510 ip->setParameter(entry, param, "Off");
4511 for (int ipl = 0; ipl < nPlanes; ipl++) {
4512 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4513 SMESH::Orientation anOrientation;
4515 vtkFloatingPointType anAngle[2];
4516 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4517 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4518 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4519 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4520 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4522 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4524 } // if (io->hasEntry())
4525 } // SMESH_Actor && hasIO
4527 } // while.. actors traversal
4531 } // if (SVTK view model)
4532 } // for (viewManagers)
4536 * \brief Restore visual parameters
4538 * This method is called after the study document is opened.
4539 * Restore visual parameters from AttributeParameter attribue(s)
4541 void SMESHGUI::restoreVisualParameters (int savePoint)
4543 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4544 if (!appStudy || !appStudy->studyDS())
4546 _PTR(Study) studyDS = appStudy->studyDS();
4548 // componentName is used for encoding of entries when storing them in IParameters
4549 std::string componentName = myComponentSMESH->ComponentDataType();
4550 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4551 //if (!aSComponent) return;
4554 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4555 componentName.c_str(),
4557 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4559 // restore map of custom markers
4560 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4562 std::vector<std::string> properties = ip->getProperties();
4563 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4565 std::string property = *propIt;
4566 QString aPropertyName( property.c_str() );
4567 QString aPropertyValue( ip->getProperty( property ).c_str() );
4569 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4570 if( aPropertyNameList.size() != 2 )
4575 if( aPropertyNameList[0] == "texture" )
4576 anId = aPropertyNameList[1].toInt( &ok );
4578 if( !ok || anId < 1 )
4581 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4582 if( aPropertyValueList.size() != 2 )
4585 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4586 QString aMarkerTextureString = aPropertyValueList[1];
4587 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4588 if( aMarkerTextureStringList.size() != 3 )
4592 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4597 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4601 VTK::MarkerTexture aMarkerTexture;
4602 aMarkerTexture.push_back( aWidth );
4603 aMarkerTexture.push_back( aHeight );
4605 QString aMarkerTextureData = aMarkerTextureStringList[2];
4606 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4608 QChar aChar = aMarkerTextureData.at( i );
4609 if( aChar.isDigit() )
4610 aMarkerTexture.push_back( aChar.digitValue() );
4613 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4616 std::vector<std::string> entries = ip->getEntries();
4618 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4620 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4621 QString entry (ip->decodeEntry(*entIt).c_str());
4623 // Check that the entry corresponds to a real object in the Study
4624 // as the object may be deleted or modified after the visual state is saved.
4625 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4626 if (!so) continue; //Skip the not existent entry
4628 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4629 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4631 std::vector<std::string>::iterator namesIt = paramNames.begin();
4632 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4634 // actors are stored in a map after displaying of them for
4635 // quicker access in the future: map < viewID to actor >
4636 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4638 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4640 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4641 // '_' is used as separator and should not be used in viewer type or parameter names.
4642 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4643 if (lst.size() != 3)
4646 QString viewerTypStr = lst[0];
4647 QString viewIndexStr = lst[1];
4648 QString paramNameStr = lst[2];
4651 int viewIndex = viewIndexStr.toUInt(&ok);
4652 if (!ok) // bad conversion of view index to integer
4656 if (viewerTypStr == SVTK_Viewer::Type())
4658 SMESH_Actor* aSmeshActor = 0;
4659 if (vtkActors.IsBound(viewIndex))
4660 aSmeshActor = vtkActors.Find(viewIndex);
4662 if (paramNameStr == "Visibility")
4664 if (!aSmeshActor && displayer())
4666 QList<SUIT_ViewManager*> lst;
4667 getApp()->viewManagers(viewerTypStr, lst);
4669 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4670 if (viewIndex >= 0 && viewIndex < lst.count()) {
4671 SUIT_ViewManager* vman = lst.at(viewIndex);
4672 SUIT_ViewModel* vmodel = vman->getViewModel();
4673 // SVTK view model can be casted to SALOME_View
4674 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4676 // store displayed actor in a temporary map for quicker
4677 // access later when restoring other parameters
4678 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4679 vtkRenderer* Renderer = vtkView->getRenderer();
4680 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4681 vtkActorCollection* theActors = aCopy.GetActors();
4682 theActors->InitTraversal();
4683 bool isFound = false;
4684 vtkActor *ac = theActors->GetNextActor();
4685 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4686 if (ac->IsA("SMESH_Actor")) {
4687 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4688 if (aGeomAc->hasIO()) {
4689 Handle(SALOME_InteractiveObject) io =
4690 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4691 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4693 vtkActors.Bind(viewIndex, aGeomAc);
4700 } // if (paramNameStr == "Visibility")
4703 // the rest properties "work" with SMESH_Actor
4706 QString val ((*valuesIt).c_str());
4709 if (paramNameStr == "Representation") {
4710 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4713 else if (paramNameStr == "IsShrunk") {
4715 if (!aSmeshActor->IsShrunk())
4716 aSmeshActor->SetShrink();
4719 if (aSmeshActor->IsShrunk())
4720 aSmeshActor->UnShrink();
4723 // Displayed entities
4724 else if (paramNameStr == "Entities") {
4725 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4726 if (mode.count() == 6) {
4727 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4728 MESSAGE("Invalid order of data in Entities, must be: "
4729 "e:0/1:f:0/1:v:0/1");
4732 unsigned int aMode = aSmeshActor->GetEntityMode();
4733 unsigned int aNewMode =
4734 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4735 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4736 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4737 if (aNewMode != aMode)
4738 aSmeshActor->SetEntityMode(aNewMode);
4743 else if (paramNameStr == "Colors") {
4744 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4745 if (colors.count() == 16) {
4746 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4747 colors[8] != "edge" || colors[12] != "node") {
4748 MESSAGE("Invalid order of data in Colors, must be: "
4749 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4752 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4753 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4754 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4755 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4759 // Sizes of lines and points
4760 else if (paramNameStr == "Sizes") {
4761 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4762 if (sizes.count() == 4) {
4763 if (sizes[0] != "line" || sizes[2] != "shrink") {
4764 MESSAGE("Invalid order of data in Sizes, must be: "
4765 "line:int:shrink:float");
4768 aSmeshActor->SetLineWidth(sizes[1].toInt());
4769 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4772 else if (sizes.count() == 6) { // just to support old format
4773 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4774 MESSAGE("Invalid order of data in Sizes, must be: "
4775 "line:int:node:int:shrink:float");
4778 aSmeshActor->SetLineWidth(sizes[1].toInt());
4779 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4780 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4785 else if (paramNameStr == "PointMarker") {
4786 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
4787 if( data.count() >= 2 ) {
4789 int aParam1 = data[1].toInt( &ok );
4791 if( data[0] == "std" && data.count() == 3 ) {
4792 int aParam2 = data[2].toInt( &ok );
4793 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
4795 else if( data[0] == "custom" ) {
4796 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
4797 if( markerIt != aMarkerMap.end() ) {
4798 VTK::MarkerData aMarkerData = markerIt->second;
4799 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
4806 else if (paramNameStr == "Opacity") {
4807 aSmeshActor->SetOpacity(val.toFloat());
4810 else if (paramNameStr.startsWith("ClippingPlane")) {
4811 cout << "$$$ ClippingPlane 1" << endl;
4812 if (paramNameStr == "ClippingPlane1" || val == "Off")
4813 aSmeshActor->RemoveAllClippingPlanes();
4815 cout << "$$$ ClippingPlane 2" << endl;
4816 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4817 if (vals.count() == 4) { // format check: 4 values
4818 cout << "$$$ ClippingPlane 3" << endl;
4819 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4820 double aDistance = vals[1].toFloat();
4821 vtkFloatingPointType anAngle[2];
4822 anAngle[0] = vals[2].toFloat();
4823 anAngle[1] = vals[3].toFloat();
4825 QList<SUIT_ViewManager*> lst;
4826 getApp()->viewManagers(viewerTypStr, lst);
4827 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4828 if (viewIndex >= 0 && viewIndex < lst.count()) {
4829 SUIT_ViewManager* vman = lst.at(viewIndex);
4830 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4831 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4832 anOrientation, aDistance, anAngle);
4837 } // if (aSmeshActor)
4838 } // other parameters than Visibility
4840 } // for names/parameters iterator
4841 } // for entries iterator
4843 // update all VTK views
4844 QList<SUIT_ViewManager*> lst;
4845 getApp()->viewManagers(lst);
4846 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4847 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4848 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4849 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4850 vtkView->getRenderer()->ResetCameraClippingRange();
4857 \brief Adds preferences for dfont of VTK viewer
4859 \param pIf group identifier
4860 \param param parameter
4861 \return identifier of preferences
4863 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
4865 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4867 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4870 fam.append( tr( "SMESH_FONT_ARIAL" ) );
4871 fam.append( tr( "SMESH_FONT_COURIER" ) );
4872 fam.append( tr( "SMESH_FONT_TIMES" ) );
4874 setPreferenceProperty( tfont, "fonts", fam );
4876 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4877 setPreferenceProperty( tfont, "features", f );
4883 \brief Actions after hypothesis edition
4884 Updates object browser after hypothesis edition
4886 void SMESHGUI::onHypothesisEdit( int result )
4889 SMESHGUI::Modified();
4890 updateObjBrowser( true );