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
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
30 #include "SMESHGUI_AddMeshElementDlg.h"
31 #include "SMESHGUI_AddQuadraticElementDlg.h"
32 #include "SMESHGUI_BuildCompoundDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_ComputeDlg.h"
35 #include "SMESHGUI_ConvToQuadOp.h"
36 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
37 #include "SMESHGUI_DeleteGroupDlg.h"
38 #include "SMESHGUI_Displayer.h"
39 #include "SMESHGUI_MergeDlg.h"
40 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
41 #include "SMESHGUI_ExtrusionDlg.h"
42 #include "SMESHGUI_FileInfoDlg.h"
43 #include "SMESHGUI_FileValidator.h"
44 #include "SMESHGUI_FilterDlg.h"
45 #include "SMESHGUI_FilterLibraryDlg.h"
46 #include "SMESHGUI_FindElemByPointDlg.h"
47 #include "SMESHGUI_GroupDlg.h"
48 #include "SMESHGUI_GroupOnShapeDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_Hypotheses.h"
51 #include "SMESHGUI_Make2DFrom3DOp.h"
52 #include "SMESHGUI_MakeNodeAtPointDlg.h"
53 //#include "SMESHGUI_MeshInfosDlg.h"
54 #include "SMESHGUI_Measurements.h"
55 #include "SMESHGUI_MeshInfo.h"
56 #include "SMESHGUI_MeshOp.h"
57 #include "SMESHGUI_MeshOrderOp.h"
58 #include "SMESHGUI_MeshPatternDlg.h"
59 #include "SMESHGUI_MultiEditDlg.h"
60 #include "SMESHGUI_NodesDlg.h"
61 #include "SMESHGUI_Preferences_ColorDlg.h"
62 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
63 #include "SMESHGUI_RemoveElementsDlg.h"
64 #include "SMESHGUI_RemoveNodesDlg.h"
65 #include "SMESHGUI_RenumberingDlg.h"
66 #include "SMESHGUI_RevolutionDlg.h"
67 #include "SMESHGUI_RotationDlg.h"
68 #include "SMESHGUI_Selection.h"
69 #include "SMESHGUI_SewingDlg.h"
70 #include "SMESHGUI_SingleEditDlg.h"
71 #include "SMESHGUI_SmoothingDlg.h"
72 //#include "SMESHGUI_StandardMeshInfosDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.h"
77 //#include "SMESHGUI_WhatIsDlg.h"
78 #include "SMESHGUI_DuplicateNodesDlg.h"
79 #include "SMESHGUI_CopyMeshDlg.h"
81 #include "SMESHGUI_Utils.h"
82 #include "SMESHGUI_MeshUtils.h"
83 #include "SMESHGUI_GroupUtils.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_PatternUtils.h"
86 #include "SMESHGUI_VTKUtils.h"
87 #include "SMESHGUI_HypothesesUtils.h"
89 #include <SMESH_Client.hxx>
90 #include <SMESH_Actor.h>
91 #include <SMESH_ScalarBarActor.h>
92 #include <SMESH_TypeFilter.hxx>
93 #include "SMESH_ControlsDef.hxx"
95 // SALOME GUI includes
96 #include <SalomeApp_Tools.h>
97 #include <SalomeApp_Study.h>
98 #include <SalomeApp_Application.h>
99 #include <SalomeApp_CheckFileDlg.h>
101 #include <LightApp_DataOwner.h>
102 #include <LightApp_Preferences.h>
103 #include <LightApp_SelectionMgr.h>
104 #include <LightApp_UpdateFlags.h>
105 #include <LightApp_NameDlg.h>
107 #include <SVTK_ViewWindow.h>
108 #include <SVTK_ViewModel.h>
109 #include <SVTK_ViewManager.h>
111 #include <VTKViewer_Algorithm.h>
113 #include <SUIT_MessageBox.h>
114 #include <SUIT_ResourceMgr.h>
115 #include <SUIT_FileDlg.h>
116 #include <SUIT_Desktop.h>
117 #include <SUIT_OverrideCursor.h>
118 #include <SUIT_Session.h>
120 #include <QtxPopupMgr.h>
121 #include <QtxFontEdit.h>
123 #include <SALOME_ListIO.hxx>
124 #include <SALOME_ListIteratorOfListIO.hxx>
126 #ifndef DISABLE_PLOT2DVIEWER
127 #include <SPlot2d_ViewModel.h>
128 #include <SPlot2d_Histogram.h>
132 #include <SALOMEconfig.h>
133 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
134 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
135 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
138 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
140 #include <QTextStream>
143 #include <boost/shared_ptr.hpp>
146 #include <vtkCamera.h>
147 #include <vtkRenderer.h>
148 #include <vtkPlane.h>
149 #include <vtkCallbackCommand.h>
150 #include <vtkLookupTable.h>
152 // SALOME KERNEL includes
153 #include <SALOMEDS_Study.hxx>
154 #include <SALOMEDSClient_StudyBuilder.hxx>
155 #include <SALOMEDSClient_SComponent.hxx>
156 #include <SALOMEDSClient_ClientFactory.hxx>
157 #include <SALOMEDSClient_IParameters.hxx>
160 #include <Standard_ErrorHandler.hxx>
161 #include <NCollection_DataMap.hxx>
163 //To disable automatic genericobj management, the following line should be commented.
164 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
165 #define WITHGENERICOBJ
169 //=============================================================
170 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
173 void ExportMeshToFile(int theCommandID);
175 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
177 void SetDisplayEntity(int theCommandID);
179 void Control( int theCommandID );
183 //=============================================================
184 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
188 std::string myExtension;
190 if ( theCommandID == 113 ) {
191 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
192 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
194 else if ( theCommandID == 112 ) {
195 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
197 else if ( theCommandID == 111 ) {
198 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
201 QString anInitialPath = "";
202 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
203 anInitialPath = QDir::currentPath();
205 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
208 QObject::tr( "SMESH_IMPORT_MESH" ) );
209 if ( filenames.count() > 0 ) {
210 SUIT_OverrideCursor wc;
211 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
214 bool isEmpty = false;
215 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
216 QString filename = *it;
217 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
219 switch ( theCommandID ) {
222 // DAT format (currently unsupported)
223 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
224 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
230 aMeshes->length( 1 );
231 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
232 if ( aMeshes[0]->_is_nil() )
233 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
234 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
240 SMESH::DriverMED_ReadStatus res;
241 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
242 if ( res != SMESH::DRS_OK ) {
243 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
244 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
250 catch ( const SALOME::SALOME_Exception& S_ex ) {
251 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
252 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
255 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
256 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
258 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
259 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
260 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
261 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
262 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
264 #ifdef WITHGENERICOBJ
265 // obj has been published in study. Its refcount has been incremented.
266 // It is safe to decrement its refcount
267 // so that it will be destroyed when the entry in study will be removed
268 aMeshes[i]->Destroy();
277 // update Object browser
278 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
280 // show Error message box if there were errors
281 if ( errors.count() > 0 ) {
282 SUIT_MessageBox::critical( SMESHGUI::desktop(),
283 QObject::tr( "SMESH_ERROR" ),
284 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
287 // show warning message box, if some imported mesh is empty
289 SUIT_MessageBox::warning( SMESHGUI::desktop(),
290 QObject::tr( "SMESH_WRN_WARNING" ),
291 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
296 void ExportMeshToFile( int theCommandID )
298 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
299 SALOME_ListIO selected;
301 aSel->selectedObjects( selected );
303 // actually, the following condition can't be met (added for insurance)
304 if( selected.Extent() == 0 ||
305 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
308 bool hasDuplicatedMeshNames = false;
309 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
310 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
311 SALOME_ListIteratorOfListIO It( selected );
312 for( ; It.More(); It.Next() ) {
313 Handle(SALOME_InteractiveObject) anIObject = It.Value();
314 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
315 if ( aMeshItem->_is_nil() ) {
316 SUIT_MessageBox::warning( SMESHGUI::desktop(),
317 QObject::tr( "SMESH_WRN_WARNING" ),
318 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
322 QString aMeshName = anIObject->getName();
324 // check for duplications
325 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
326 if( aMeshName == (*aMeshIter).second ) {
327 hasDuplicatedMeshNames = true;
332 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
335 if( hasDuplicatedMeshNames ) {
336 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
337 QObject::tr("SMESH_WRN_WARNING"),
338 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
339 QObject::tr("SMESH_BUT_YES"),
340 QObject::tr("SMESH_BUT_NO"), 0, 1);
345 aMeshIter = aMeshList.begin();
346 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
347 QString aMeshName = (*aMeshIter).second;
349 QList<SALOMEDS::Color> aReservedColors;
351 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
352 QMap<QString, SMESH::MED_VERSION> aFilterMap;
353 QMap<QString, int> aFilterMapSTL;
354 switch ( theCommandID ) {
358 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
359 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
360 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
361 int aRet = SUIT_MessageBox::warning
362 (SMESHGUI::desktop(),
363 QObject::tr("SMESH_WRN_WARNING"),
364 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
365 QObject::tr("SMESH_BUT_YES"),
366 QObject::tr("SMESH_BUT_NO"), 0, 1);
372 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
373 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
374 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
375 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
380 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
385 if (aMesh->NbPyramids()) {
386 int aRet = SUIT_MessageBox::warning
387 (SMESHGUI::desktop(),
388 QObject::tr("SMESH_WRN_WARNING"),
389 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
390 QObject::tr("SMESH_BUT_YES"),
391 QObject::tr("SMESH_BUT_NO"), 0, 1);
395 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
403 there must be check on others mesh elements not equal triangles
405 if (aMesh->NbTriangles() < 1) {
406 SUIT_MessageBox::warning
407 (SMESHGUI::desktop(),
408 QObject::tr("SMESH_WRN_WARNING"),
409 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
412 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
413 int aRet = SUIT_MessageBox::warning
414 (SMESHGUI::desktop(),
415 QObject::tr("SMESH_WRN_WARNING"),
416 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
417 QObject::tr("SMESH_BUT_YES"),
418 QObject::tr("SMESH_BUT_NO"), 0, 1);
423 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
424 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
432 SMESH::MED_VERSION aFormat;
433 // Init the parameter with the default value
434 bool aIsASCII_STL = true;
435 bool toCreateGroups = false;
436 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
438 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
439 bool toOverwrite = true;
441 QString anInitialPath = "";
442 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
443 anInitialPath = QDir::currentPath();
445 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
446 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
447 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
448 aFilter, aTitle, false);
450 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
452 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
453 for ( ; it != aFilterMapSTL.end(); ++it )
454 filters.push_back( it.key() );
456 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
457 fd->setWindowTitle( aTitle );
458 fd->setNameFilters( filters );
459 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
460 if ( !anInitialPath.isEmpty() )
461 fd->setDirectory( anInitialPath );
462 fd->selectFile(aMeshName);
466 aFilename = fd->selectedFile();
467 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
472 else { // Export to MED
474 QString aDefaultFilter;
475 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
476 for ( ; it != aFilterMap.end(); ++it ) {
477 filters.push_back( it.key() );
478 if (it.value() == SMESH::MED_V2_2)
479 aDefaultFilter = it.key();
482 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
483 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
484 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
485 fd->setWindowTitle( aTitle );
486 fd->setNameFilters( filters );
487 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
488 fd->selectNameFilter(aDefaultFilter);
489 fd->SetChecked(toCreateGroups);
490 if ( !anInitialPath.isEmpty() )
491 fd->setDirectory( anInitialPath );
492 fd->selectFile(aMeshName);
494 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
495 fd->setValidator( fv );
500 aFilename = fd->selectedFile();
502 aFilename = QString::null;
505 aFormat = aFilterMap[fd->selectedNameFilter()];
506 toOverwrite = fv->isOverwrite();
508 if ( !aFilename.isEmpty() ) {
509 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
510 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
511 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
512 && aFormat==SMESH::MED_V2_1) {
513 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
514 QObject::tr("SMESH_WRN_WARNING"),
515 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
516 QObject::tr("SMESH_BUT_YES"),
517 QObject::tr("SMESH_BUT_NO"), 0, 1);
525 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
526 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
527 if( !isVersionOk || aVersion != aFormat ) {
528 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
529 QObject::tr("SMESH_WRN_WARNING"),
530 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
531 QObject::tr("SMESH_BUT_YES"),
532 QObject::tr("SMESH_BUT_NO"), 0, 1);
539 QStringList aMeshNamesCollisionList;
540 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
541 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
542 QString anExistingMeshName( aMeshNames[ i ] );
543 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
544 QString anExportMeshName = (*aMeshIter).second;
545 if( anExportMeshName == anExistingMeshName ) {
546 aMeshNamesCollisionList.append( anExportMeshName );
552 if( !aMeshNamesCollisionList.isEmpty() ) {
553 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
554 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
555 QObject::tr("SMESH_WRN_WARNING"),
556 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
557 QObject::tr("SMESH_BUT_YES"),
558 QObject::tr("SMESH_BUT_NO"),
559 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
568 toCreateGroups = fd->IsChecked();
571 if ( !aFilename.isEmpty() ) {
572 // Check whether the file already exists and delete it if yes
573 QFile aFile( aFilename );
574 if ( aFile.exists() && toOverwrite )
576 SUIT_OverrideCursor wc;
579 bool Renumber = false;
580 // PAL 14172 : Check of we have to renumber or not from the preferences before export
582 Renumber= resMgr->booleanValue("SMESH","renumbering");
584 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
585 aMeshEditor->RenumberNodes();
586 aMeshEditor->RenumberElements();
587 if ( SMESHGUI::automaticUpdate() )
590 switch ( theCommandID ) {
594 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
595 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
596 if( !aMeshItem->_is_nil() )
597 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
603 aMesh->ExportDAT( aFilename.toLatin1().data() );
607 aMesh->ExportUNV( aFilename.toLatin1().data() );
611 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
617 catch (const SALOME::SALOME_Exception& S_ex){
619 SUIT_MessageBox::warning(SMESHGUI::desktop(),
620 QObject::tr("SMESH_WRN_WARNING"),
621 QObject::tr("SMESH_EXPORT_FAILED"));
627 inline void InverseEntityMode(unsigned int& theOutputMode,
628 unsigned int theMode)
630 bool anIsNotPresent = ~theOutputMode & theMode;
632 theOutputMode |= theMode;
634 theOutputMode &= ~theMode;
637 void SetDisplayEntity(int theCommandID){
638 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
639 SALOME_ListIO selected;
641 aSel->selectedObjects( selected );
643 if(selected.Extent() >= 1){
644 SALOME_ListIteratorOfListIO It( selected );
645 for( ; It.More(); It.Next()){
646 Handle(SALOME_InteractiveObject) IObject = It.Value();
647 if(IObject->hasEntry()){
648 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
649 unsigned int aMode = anActor->GetEntityMode();
650 switch(theCommandID){
652 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
655 InverseEntityMode(aMode,SMESH_Actor::eEdges);
658 InverseEntityMode(aMode,SMESH_Actor::eFaces);
661 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
664 aMode = SMESH_Actor::eAllEntity;
668 anActor->SetEntityMode(aMode);
676 SALOME_ListIO selected;
677 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
681 LightApp_SelectionMgr* aSel = app->selectionMgr();
682 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
683 if( !aSel || !appStudy )
686 aSel->selectedObjects( selected );
687 if( selected.IsEmpty() )
690 Handle(SALOME_InteractiveObject) anIObject = selected.First();
692 _PTR(Study) aStudy = appStudy->studyDS();
693 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
694 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
695 if( aMainObject->_is_nil() )
698 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
700 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
701 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
703 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
704 SALOMEDS::Color aColor = aGroupObject->GetColor();
705 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
707 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
708 if( aGroupObject->GetType() == SMESH::NODE )
709 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
710 else if( aGroupObject->GetType() == SMESH::EDGE )
711 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
712 else if( aGroupObject->GetType() == SMESH::ELEM0D )
713 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
715 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
720 SMESH::RepaintCurrentView();
723 QString functorToString( SMESH::Controls::FunctorPtr f )
725 QString type = QObject::tr( "UNKNOWN_CONTROL" );
726 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
727 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
728 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
729 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
730 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
731 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
732 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
733 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
734 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
735 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
736 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
737 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
738 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
739 type = QObject::tr( "WARP_ELEMENTS" );
740 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
741 type = QObject::tr( "TAPER_ELEMENTS" );
742 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
743 type = QObject::tr( "SKEW_ELEMENTS" );
744 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
745 type = QObject::tr( "AREA_ELEMENTS" );
746 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
747 type = QObject::tr( "LENGTH_EDGES" );
748 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
749 type = QObject::tr( "LENGTH2D_EDGES" );
750 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
751 type = QObject::tr( "MULTI_BORDERS" );
752 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
753 type = QObject::tr( "MULTI2D_BORDERS" );
754 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
755 type = QObject::tr( "FREE_NODES" );
756 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
757 type = QObject::tr( "FREE_EDGES" );
758 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
759 type = QObject::tr( "FREE_BORDERS" );
760 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
761 type = QObject::tr( "FREE_FACES" );
762 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
763 type = QObject::tr( "BARE_BORDER_VOLUME" );
764 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
765 type = QObject::tr( "BARE_BORDER_FACE" );
766 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
767 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
768 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
769 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
773 void SaveDistribution()
775 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
776 SALOME_ListIO selected;
778 aSel->selectedObjects( selected );
780 if ( selected.Extent() == 1 ) {
781 Handle(SALOME_InteractiveObject) anIO = selected.First();
782 if ( anIO->hasEntry() ) {
783 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
784 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
785 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
786 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
787 if ( aScalarBarActor && aFunctor ) {
788 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
790 std::vector<int> elements;
791 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
792 if ( mesh->_is_nil() ) {
793 SMESH::SMESH_IDSource_var idSource =
794 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
795 if ( !idSource->_is_nil() )
797 SMESH::long_array_var ids = idSource->GetIDs();
798 elements.resize( ids->length() );
799 for ( unsigned i = 0; i < elements.size(); ++i )
800 elements[i] = ids[i];
803 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
804 vtkLookupTable* lookupTable =
805 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
806 double * minmax = lookupTable->GetRange();
807 std::vector<int> nbEvents;
808 std::vector<double> funValues;
809 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
810 QString anInitialPath = "";
811 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
812 anInitialPath = QDir::currentPath();
813 QString aMeshName = anIO->getName();
815 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
816 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
817 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
818 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
819 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
822 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
824 if ( !aFilename.isEmpty() ) {
825 QFile f( aFilename );
826 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
827 QTextStream out( &f );
828 out << "# Mesh: " << aMeshName << endl;
829 out << "# Control: " << functorToString( aFunctor ) << endl;
831 out.setFieldWidth( 10 );
832 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
833 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
844 void ShowDistribution() {
845 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
846 SALOME_ListIO selected;
848 aSel->selectedObjects( selected );
850 if ( selected.Extent() == 1 ) {
851 Handle(SALOME_InteractiveObject) anIO = selected.First();
852 if ( anIO->hasEntry() ) {
853 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
854 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
855 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
856 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
862 #ifndef DISABLE_PLOT2DVIEWER
863 void PlotDistribution() {
864 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
868 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
869 SALOME_ListIO selected;
871 aSel->selectedObjects( selected );
873 if ( selected.Extent() == 1 ) {
874 Handle(SALOME_InteractiveObject) anIO = selected.First();
875 if ( anIO->hasEntry() ) {
876 //Find Actor by entry before getting Plot2d viewer,
877 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
878 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
880 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
885 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
889 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
893 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
894 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
895 QString functorName = functorToString( anActor->GetFunctor());
896 QString aHistogramName("%1 : %2");
897 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
898 aHistogram->setName(aHistogramName);
899 aHistogram->setHorTitle(functorName);
900 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
901 aPlot->displayObject(aHistogram, true);
906 #endif //DISABLE_PLOT2DVIEWER
908 void DisableAutoColor(){
909 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
910 SALOME_ListIO selected;
912 aSel->selectedObjects( selected );
914 if(selected.Extent()){
915 Handle(SALOME_InteractiveObject) anIObject = selected.First();
916 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
917 if ( !aMesh->_is_nil() ) {
918 aMesh->SetAutoColor( false );
923 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
924 SALOME_ListIO selected;
925 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
929 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
930 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
931 if( !aSel || !appStudy )
934 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
935 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
936 aModule->EmitSignalDeactivateDialog();
937 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
938 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
943 _PTR(Study) aStudy = appStudy->studyDS();
945 aSel->selectedObjects( selected );
947 if(selected.Extent() >= 1){
948 switch(theCommandID){
950 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
951 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
955 QColor c, e, b, n, c0D, o;
958 vtkFloatingPointType Shrink = 0.0;
959 vtkFloatingPointType faces_orientation_scale = 0.0;
960 bool faces_orientation_3dvectors = false;
962 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
963 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
964 int aMarkerTextureCurrent = 0;
966 SALOME_ListIteratorOfListIO It( selected );
967 for( ; It.More(); It.Next()){
968 Handle(SALOME_InteractiveObject) IObject = It.Value();
969 if(IObject->hasEntry()){
970 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
971 vtkFloatingPointType color[3];
972 anActor->GetSufaceColor(color[0], color[1], color[2]);
973 int c0 = int (color[0] * 255);
974 int c1 = int (color[1] * 255);
975 int c2 = int (color[2] * 255);
976 c.setRgb(c0, c1, c2);
978 vtkFloatingPointType edgecolor[3];
979 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
980 c0 = int (edgecolor[0] * 255);
981 c1 = int (edgecolor[1] * 255);
982 c2 = int (edgecolor[2] * 255);
983 e.setRgb(c0, c1, c2);
985 vtkFloatingPointType backfacecolor[3];
986 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
987 c0 = int (backfacecolor[0] * 255);
988 c1 = int (backfacecolor[1] * 255);
989 c2 = int (backfacecolor[2] * 255);
990 b.setRgb(c0, c1, c2);
992 vtkFloatingPointType nodecolor[3];
993 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
994 c0 = int (nodecolor[0] * 255);
995 c1 = int (nodecolor[1] * 255);
996 c2 = int (nodecolor[2] * 255);
997 n.setRgb(c0, c1, c2);
999 vtkFloatingPointType color0D[3];
1000 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1001 c0 = int (color0D[0] * 255);
1002 c1 = int (color0D[1] * 255);
1003 c2 = int (color0D[2] * 255);
1004 c0D.setRgb(c0, c1, c2);
1006 size0D = (int)anActor->Get0DSize();
1009 Edgewidth = (int)anActor->GetLineWidth();
1012 Shrink = anActor->GetShrinkFactor();
1014 vtkFloatingPointType faces_orientation_color[3];
1015 anActor->GetFacesOrientationColor(faces_orientation_color);
1016 c0 = int (faces_orientation_color[0] * 255);
1017 c1 = int (faces_orientation_color[1] * 255);
1018 c2 = int (faces_orientation_color[2] * 255);
1019 o.setRgb(c0, c1, c2);
1021 faces_orientation_scale = anActor->GetFacesOrientationScale();
1022 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1024 aMarkerTypeCurrent = anActor->GetMarkerType();
1025 aMarkerScaleCurrent = anActor->GetMarkerScale();
1026 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1028 // even if there are multiple objects in the selection,
1029 // we need only the first one to get values for the dialog
1035 SMESHGUI_Preferences_ColorDlg *aDlg =
1036 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1037 aDlg->SetColor(1, c);
1038 aDlg->SetColor(2, e);
1039 aDlg->SetColor(3, n);
1040 aDlg->SetColor(4, b);
1041 aDlg->SetColor(5, c0D);
1042 aDlg->SetColor(6, o);
1043 aDlg->SetIntValue(1, Edgewidth);
1044 aDlg->SetIntValue(2, int(Shrink*100.));
1045 aDlg->SetIntValue(3, size0D);
1046 aDlg->SetDoubleValue(1, faces_orientation_scale);
1047 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1049 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1051 if( aMarkerTypeCurrent != VTK::MT_USER )
1052 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1054 aDlg->setCustomMarker( aMarkerTextureCurrent );
1057 QColor color = aDlg->GetColor(1);
1058 QColor edgecolor = aDlg->GetColor(2);
1059 QColor nodecolor = aDlg->GetColor(3);
1060 QColor backfacecolor = aDlg->GetColor(4);
1061 QColor color0D = aDlg->GetColor(5);
1062 QColor faces_orientation_color = aDlg->GetColor(6);
1065 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1067 SALOME_ListIteratorOfListIO It( selected );
1068 for( ; It.More(); It.Next()){
1069 Handle(SALOME_InteractiveObject) IObject = It.Value();
1070 if(IObject->hasEntry()){
1071 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1072 /* actor color and backface color */
1073 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1074 vtkFloatingPointType (color.green()) / 255.,
1075 vtkFloatingPointType (color.blue()) / 255.);
1076 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1077 vtkFloatingPointType (backfacecolor.green()) / 255.,
1078 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1081 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1082 vtkFloatingPointType (edgecolor.green()) / 255.,
1083 vtkFloatingPointType (edgecolor.blue()) / 255.);
1085 /* Shrink factor and size edges */
1086 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1087 anActor->SetLineWidth(aDlg->GetIntValue(1));
1089 /* Nodes color and size */
1090 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1091 vtkFloatingPointType (nodecolor.green()) / 255.,
1092 vtkFloatingPointType (nodecolor.blue()) / 255.);
1095 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1096 vtkFloatingPointType (color0D.green()) / 255.,
1097 vtkFloatingPointType (color0D.blue()) / 255.);
1098 anActor->Set0DSize(aDlg->GetIntValue(3));
1100 /* Faces orientation */
1101 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1102 vtkFloatingPointType(faces_orientation_color.greenF()),
1103 vtkFloatingPointType(faces_orientation_color.blueF())};
1104 anActor->SetFacesOrientationColor(c);
1105 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1106 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1108 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1109 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1110 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1111 if( aMarkerTypeNew != VTK::MT_USER )
1112 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1114 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1115 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1116 if( anIter != aMarkerMap.end() )
1117 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1120 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1121 if( !aGroupObject->_is_nil() )
1123 SMESH::ElementType anElementType = aGroupObject->GetType();
1125 switch( anElementType )
1127 case SMESH::NODE: aColor = nodecolor; break;
1128 case SMESH::EDGE: aColor = edgecolor; break;
1129 default: aColor = color; break;
1132 SALOMEDS::Color aGroupColor;
1133 aGroupColor.R = (float)aColor.red() / 255.0;
1134 aGroupColor.G = (float)aColor.green() / 255.0;
1135 aGroupColor.B = (float)aColor.blue() / 255.0;
1136 aGroupObject->SetColor( aGroupColor );
1141 SMESH::RepaintCurrentView();
1147 SALOME_ListIteratorOfListIO It( selected );
1148 for( ; It.More(); It.Next()){
1149 Handle(SALOME_InteractiveObject) IObject = It.Value();
1150 if(IObject->hasEntry()){
1151 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1152 switch(theCommandID){
1154 anActor->SetRepresentation(SMESH_Actor::eEdge);
1157 anActor->SetRepresentation(SMESH_Actor::eSurface);
1160 if(anActor->IsShrunk())
1161 anActor->UnShrink();
1163 anActor->SetShrink();
1166 anActor->SetRepresentation(SMESH_Actor::ePoint);
1169 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1170 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1173 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1174 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1180 SMESH::RepaintCurrentView();
1184 void Control( int theCommandID )
1186 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1187 SALOME_ListIO selected;
1189 aSel->selectedObjects( selected );
1191 if( !selected.IsEmpty() ){
1192 Handle(SALOME_InteractiveObject) anIO = selected.First();
1194 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1195 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1196 switch ( theCommandID ){
1198 aControl = SMESH_Actor::eLength;
1201 aControl = SMESH_Actor::eLength2D;
1204 aControl = SMESH_Actor::eFreeEdges;
1207 aControl = SMESH_Actor::eFreeBorders;
1210 aControl = SMESH_Actor::eMultiConnection;
1213 aControl = SMESH_Actor::eFreeNodes;
1216 aControl = SMESH_Actor::eMultiConnection2D;
1219 aControl = SMESH_Actor::eArea;
1222 aControl = SMESH_Actor::eTaper;
1225 aControl = SMESH_Actor::eAspectRatio;
1228 aControl = SMESH_Actor::eAspectRatio3D;
1231 aControl = SMESH_Actor::eMinimumAngle;
1234 aControl = SMESH_Actor::eWarping;
1237 aControl = SMESH_Actor::eSkew;
1240 aControl = SMESH_Actor::eVolume3D;
1243 aControl = SMESH_Actor::eFreeFaces;
1246 aControl = SMESH_Actor::eMaxElementLength2D;
1249 aControl = SMESH_Actor::eMaxElementLength3D;
1252 aControl = SMESH_Actor::eBareBorderVolume;
1255 aControl = SMESH_Actor::eBareBorderFace;
1258 aControl = SMESH_Actor::eOverConstrainedVolume;
1261 aControl = SMESH_Actor::eOverConstrainedFace;
1264 anActor->SetControlMode(aControl);
1265 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1266 SMESH::RepaintCurrentView();
1267 #ifndef DISABLE_PLOT2DVIEWER
1268 if(anActor->GetPlot2Histogram()) {
1269 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1270 QString functorName = functorToString( anActor->GetFunctor());
1271 QString aHistogramName("%1 : %2");
1272 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1273 aHistogram->setName(aHistogramName);
1274 aHistogram->setHorTitle(functorName);
1275 SMESH::ProcessIn2DViewers(anActor);
1284 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1285 MeshObjectType theType,
1286 const QString theInTypeName,
1287 QString & theOutTypeName)
1289 SMESH_TypeFilter aTypeFilter( theType );
1291 if( !theIO.IsNull() )
1293 entry = theIO->getEntry();
1294 LightApp_DataOwner owner( entry );
1295 if ( aTypeFilter.isOk( &owner )) {
1296 theOutTypeName = theInTypeName;
1304 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1306 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1307 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1309 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1310 CORBA::String_var anID = aSComp->GetID().c_str();
1311 if (!strcmp(anID.in(),theIO->getEntry()))
1317 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1318 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1319 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1320 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1321 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1329 QString CheckHomogeneousSelection()
1331 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1332 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1333 SALOME_ListIO selected;
1335 aSel->selectedObjects( selected );
1337 QString RefType = CheckTypeObject(selected.First());
1338 SALOME_ListIteratorOfListIO It(selected);
1339 for ( ; It.More(); It.Next())
1341 Handle(SALOME_InteractiveObject) IObject = It.Value();
1342 QString Type = CheckTypeObject(IObject);
1343 if (Type.compare(RefType) != 0)
1344 return "Heterogeneous Selection";
1351 void SMESHGUI::OnEditDelete()
1353 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1354 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1355 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1357 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1358 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1359 _PTR(GenericAttribute) anAttr;
1360 _PTR(AttributeIOR) anIOR;
1362 int objectCount = 0;
1364 QString aParentComponent = QString::null;
1365 Handle(SALOME_InteractiveObject) anIO;
1366 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1368 anIO = anIt.Value();
1369 QString cur = anIO->getComponentDataType();
1370 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1372 // check if object is reference
1373 _PTR(SObject) aRefSObj;
1374 aNameList.append("\n - ");
1375 if ( aSO->ReferencedObject( aRefSObj ) ) {
1376 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1377 aNameList.append( aRefName );
1378 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1381 aNameList.append(anIO->getName());
1385 if( aParentComponent.isNull() )
1386 aParentComponent = cur;
1387 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1388 aParentComponent = "";
1391 if ( objectCount == 0 )
1392 return; // No Valid Objects Selected
1394 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1395 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1396 QObject::tr("ERR_ERROR"),
1397 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1400 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1401 if (SUIT_MessageBox::warning
1402 (SMESHGUI::desktop(),
1403 QObject::tr("SMESH_WRN_WARNING"),
1404 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1405 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1406 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1409 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1410 SUIT_ViewManager* vm = anApp->activeViewManager();
1411 int nbSf = vm ? vm->getViewsCount() : 0;
1413 SALOME_ListIteratorOfListIO It(selected);
1415 aStudyBuilder->NewCommand(); // There is a transaction
1416 for( ; It.More(); It.Next()){ // loop on selected IO's
1417 Handle(SALOME_InteractiveObject) IObject = It.Value();
1418 if(IObject->hasEntry()) {
1419 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1421 // disable removal of "SMESH" component object
1422 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1424 if ( engineIOR() == anIOR->Value().c_str() )
1427 //Check the referenced object
1428 _PTR(SObject) aRefSObject;
1429 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1430 aSO = aRefSObject; // Delete main Object instead of reference
1432 // put the whole hierarchy of sub-objects of the selected SO into a list and
1433 // then treat them all starting from the deepest objects (at list back)
1435 std::list< _PTR(SObject) > listSO;
1436 listSO.push_back( aSO );
1437 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1438 for ( ; itSO != listSO.end(); ++itSO ) {
1439 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1440 for (it->InitEx(false); it->More(); it->Next())
1441 listSO.push_back( it->Value() );
1444 // treat SO's in the list starting from the back
1446 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1447 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1448 _PTR(SObject) SO = *ritSO;
1449 if ( !SO ) continue;
1450 std::string anEntry = SO->GetID();
1452 /** Erase graphical object **/
1453 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1454 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1455 for(int i = 0; i < nbSf; i++){
1456 SUIT_ViewWindow *sf = aViews[i];
1457 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1458 SMESH::RemoveActor(sf,anActor);
1463 /** Remove an object from data structures **/
1464 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1465 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1466 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1467 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1468 aMesh->RemoveGroup( aGroup );
1470 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1471 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1472 aMesh->RemoveSubMesh( aSubMesh );
1474 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1476 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1479 IObject = new SALOME_InteractiveObject
1480 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1481 QString objType = CheckTypeObject(IObject);
1482 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1483 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1484 aStudyBuilder->RemoveObjectWithChildren( SO );
1486 else {// default action: remove SObject from the study
1487 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1488 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1490 aStudyBuilder->RemoveObjectWithChildren( SO );
1494 } /* listSO back loop */
1495 } /* IObject->hasEntry() */
1497 aStudyBuilder->CommitCommand();
1499 /* Clear any previous selection */
1501 aSel->setSelectedObjects( l1 );
1503 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1508 SMESHGUI_EXPORT CAM_Module* createModule()
1510 return new SMESHGUI();
1514 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1516 //=============================================================================
1520 //=============================================================================
1521 SMESHGUI::SMESHGUI() :
1522 SalomeApp_Module( "SMESH" ),
1523 LightApp_Module( "SMESH" )
1525 if ( CORBA::is_nil( myComponentSMESH ) )
1527 CORBA::Boolean anIsEmbeddedMode;
1528 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1529 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1531 // 0019923: EDF 765 SMESH : default values of hypothesis
1532 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1533 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1534 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1535 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1536 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1539 myActiveDialogBox = 0;
1540 myFilterLibraryDlg = 0;
1544 myEventCallbackCommand = vtkCallbackCommand::New();
1545 myEventCallbackCommand->Delete();
1546 myEventCallbackCommand->SetClientData( this );
1547 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1550 SMESH::GetFilterManager();
1551 SMESH::GetPattern();
1552 SMESH::GetMeasurements();
1554 /* load resources for all available meshers */
1555 SMESH::InitAvailableHypotheses();
1558 //=============================================================================
1562 //=============================================================================
1563 SMESHGUI::~SMESHGUI()
1565 #ifdef WITHGENERICOBJ
1566 SMESH::GetFilterManager()->Destroy();
1567 SMESH::GetMeasurements()->Destroy();
1569 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1570 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1573 //=============================================================================
1577 //=============================================================================
1578 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1580 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1582 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1587 //=============================================================================
1591 //=============================================================================
1592 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1594 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1598 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1599 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1600 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1601 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1602 return autoUpdate && !exceeded;
1605 //=============================================================================
1609 //=============================================================================
1610 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1612 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1615 //=============================================================================
1619 //=============================================================================
1620 SMESHGUI* SMESHGUI::GetSMESHGUI()
1622 SMESHGUI* smeshMod = 0;
1623 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1626 CAM_Module* module = app->module( "Mesh" );
1627 smeshMod = dynamic_cast<SMESHGUI*>( module );
1630 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1632 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1635 _PTR(Study) aStudy = study->studyDS();
1637 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1646 Standard_EXPORT SMESHGUI* GetComponentGUI()
1648 return SMESHGUI::GetSMESHGUI();
1652 //=============================================================================
1656 //=============================================================================
1657 void SMESHGUI::SetState(int aState)
1662 //=============================================================================
1666 //=============================================================================
1667 void SMESHGUI::ResetState()
1672 //=============================================================================
1676 //=============================================================================
1677 void SMESHGUI::EmitSignalDeactivateDialog()
1679 emit SignalDeactivateActiveDialog();
1682 //=============================================================================
1686 //=============================================================================
1687 void SMESHGUI::EmitSignalStudyFrameChanged()
1689 emit SignalStudyFrameChanged();
1692 //=============================================================================
1696 //=============================================================================
1697 void SMESHGUI::EmitSignalCloseAllDialogs()
1699 emit SignalCloseAllDialogs();
1702 //=============================================================================
1706 //=============================================================================
1707 void SMESHGUI::EmitSignalVisibilityChanged()
1709 emit SignalVisibilityChanged();
1712 //=============================================================================
1716 //=============================================================================
1717 QDialog *SMESHGUI::GetActiveDialogBox()
1719 return myActiveDialogBox;
1722 //=============================================================================
1726 //=============================================================================
1727 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1729 myActiveDialogBox = (QDialog *) aDlg;
1733 //=============================================================================
1737 //=============================================================================
1738 SUIT_Desktop* SMESHGUI::desktop()
1740 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1742 return app->desktop();
1747 //=============================================================================
1751 //=============================================================================
1752 SalomeApp_Study* SMESHGUI::activeStudy()
1754 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1756 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1761 //=============================================================================
1765 //=============================================================================
1766 void SMESHGUI::Modified( bool theIsUpdateActions )
1768 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1769 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1770 appStudy->Modified();
1771 if( theIsUpdateActions )
1772 app->updateActions();
1777 //=============================================================================
1781 //=============================================================================
1782 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1784 /* Here the position is on the bottom right corner - 10 */
1785 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1787 SUIT_Desktop *PP = desktop();
1788 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1789 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1793 //=============================================================================
1797 //=============================================================================
1798 static int isStudyLocked(_PTR(Study) theStudy){
1799 return theStudy->GetProperties()->IsLocked();
1802 static bool checkLock(_PTR(Study) theStudy) {
1803 if (isStudyLocked(theStudy)) {
1804 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1805 QObject::tr("WRN_WARNING"),
1806 QObject::tr("WRN_STUDY_LOCKED") );
1812 //=======================================================================
1813 //function : CheckActiveStudyLocked
1815 //=======================================================================
1817 bool SMESHGUI::isActiveStudyLocked()
1819 _PTR(Study) aStudy = activeStudy()->studyDS();
1820 return checkLock( aStudy );
1823 //=============================================================================
1827 //=============================================================================
1828 bool SMESHGUI::OnGUIEvent( int theCommandID )
1830 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1834 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1835 SUIT_ResourceMgr* mgr = resourceMgr();
1839 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1840 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1843 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1844 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1846 //QAction* act = action( theCommandID );
1848 switch (theCommandID) {
1850 if(checkLock(aStudy)) break;
1858 if(checkLock(aStudy)) break;
1859 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1863 case 150: //MED FILE INFORMATION
1865 SALOME_ListIO selected;
1866 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1868 aSel->selectedObjects( selected );
1869 if( selected.Extent() )
1871 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1872 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1873 if ( !aMesh->_is_nil() )
1875 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1882 case 122: // EXPORT MED
1891 ::ExportMeshToFile(theCommandID);
1895 case 200: // SCALAR BAR
1897 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1898 SALOME_ListIO selected;
1900 aSel->selectedObjects( selected );
1902 if( selected.Extent() ) {
1903 Handle(SALOME_InteractiveObject) anIO = selected.First();
1904 if( anIO->hasEntry() ) {
1905 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1906 anActor->SetControlMode( SMESH_Actor::eNone );
1907 #ifndef DISABLE_PLOT2DVIEWER
1908 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
1917 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1922 // dump control distribution data to the text file
1923 ::SaveDistribution();
1929 // show/ distribution
1930 ::ShowDistribution();
1934 #ifndef DISABLE_PLOT2DVIEWER
1937 // plot distribution
1938 ::PlotDistribution();
1949 ::DisableAutoColor();
1952 case 1134: // Clipping
1953 case 1133: // Tranparency
1954 case 1132: // Colors / Size
1961 ::SetDisplayMode(theCommandID, myMarkerMap);
1964 //2D quadratic representation
1967 ::SetDisplayMode(theCommandID, myMarkerMap);
1971 case 216: // 0D elements
1974 case 219: // Volumes
1975 case 220: // All Entity
1976 ::SetDisplayEntity(theCommandID);
1979 case 221: // Orientation of faces
1981 LightApp_SelectionMgr* mgr = selectionMgr();
1982 SALOME_ListIO selected; mgr->selectedObjects( selected );
1984 SALOME_ListIteratorOfListIO it(selected);
1985 for( ; it.More(); it.Next()) {
1986 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1987 if(anIObject->hasEntry()) {
1988 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1989 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1998 if(checkLock(aStudy)) break;
2000 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2003 SMESH::UpdateView();
2005 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2006 SMESH::OnVisuException();
2008 catch (...) { // PAL16774 (Crash after display of many groups)
2009 SMESH::OnVisuException();
2013 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2014 aSel->selectedObjects( l );
2015 aSel->setSelectedObjects( l );
2020 case 301: // DISPLAY
2021 case 302: // DISPLAY ONLY
2023 SMESH::EDisplaing anAction;
2024 switch (theCommandID) {
2025 case 300: anAction = SMESH::eErase; break;
2026 case 301: anAction = SMESH::eDisplay; break;
2027 case 302: anAction = SMESH::eDisplayOnly; break;
2030 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2031 SALOME_ListIO sel_objects, to_process;
2033 aSel->selectedObjects( sel_objects );
2035 if( theCommandID==302 )
2037 MESSAGE("anAction = SMESH::eDisplayOnly");
2038 startOperation( myEraseAll );
2041 extractContainers( sel_objects, to_process );
2044 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2048 SALOME_ListIteratorOfListIO It( to_process );
2049 for ( ; It.More(); It.Next()) {
2051 Handle(SALOME_InteractiveObject) IOS = It.Value();
2052 if (IOS->hasEntry()) {
2054 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2055 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2056 break; // PAL16774 (Crash after display of many groups)
2058 if (anAction == SMESH::eDisplayOnly)
2060 MESSAGE("anAction = SMESH::eDisplayOnly");
2061 anAction = SMESH::eDisplay;
2067 // PAL13338 + PAL15161 -->
2068 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2069 MESSAGE("anAction = SMESH::eDisplayOnly");
2070 SMESH::UpdateView();
2071 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2073 // PAL13338 + PAL15161 <--
2075 catch (...) { // PAL16774 (Crash after display of many groups)
2076 SMESH::OnVisuException();
2079 if (anAction == SMESH::eErase) {
2080 MESSAGE("anAction == SMESH::eErase");
2082 aSel->setSelectedObjects( l1 );
2085 aSel->setSelectedObjects( to_process );
2092 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2097 ( new SMESHGUI_NodesDlg( this ) )->show();
2100 SUIT_MessageBox::warning(desktop(),
2101 tr("SMESH_WRN_WARNING"),
2102 tr("SMESH_WRN_VIEWER_VTK"));
2107 case 2151: // FILTER
2111 EmitSignalDeactivateDialog();
2112 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2117 case 701: // COMPUTE MESH
2118 case 711: // PRECOMPUTE MESH
2119 case 712: // EVALUATE MESH
2120 case 713: // MESH ORDER
2122 if (checkLock(aStudy)) break;
2123 startOperation( theCommandID );
2127 case 702: // Create mesh
2128 case 703: // Create sub-mesh
2129 case 704: // Edit mesh/sub-mesh
2130 startOperation( theCommandID );
2132 case 705: // copy mesh
2134 if (checkLock(aStudy)) break;
2135 EmitSignalDeactivateDialog();
2136 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2139 case 710: // Build compound mesh
2141 if (checkLock(aStudy)) break;
2142 EmitSignalDeactivateDialog();
2143 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2147 case 407: // DIAGONAL INVERSION
2148 case 408: // Delete diagonal
2152 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2153 tr( "NOT_A_VTK_VIEWER" ) );
2157 if ( checkLock( aStudy ) )
2160 /*Standard_Boolean aRes;
2161 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2162 if ( aMesh->_is_nil() )
2164 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2165 tr( "SMESH_BAD_SELECTION" ) );
2169 EmitSignalDeactivateDialog();
2170 if ( theCommandID == 407 )
2171 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2173 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2176 case 409: // Change orientation
2177 case 410: // Union of triangles
2178 case 411: // Cutting of quadrangles
2179 case 419: // Splitting volumes into tetrahedra
2183 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2184 tr( "NOT_A_VTK_VIEWER" ) );
2188 if ( checkLock( aStudy ) )
2191 EmitSignalDeactivateDialog();
2192 SMESHGUI_MultiEditDlg* aDlg = NULL;
2193 if ( theCommandID == 409 )
2194 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2195 else if ( theCommandID == 410 )
2196 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2197 else if ( theCommandID == 419 )
2198 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2200 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2205 case 412: // Smoothing
2207 if(checkLock(aStudy)) break;
2209 EmitSignalDeactivateDialog();
2210 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2213 SUIT_MessageBox::warning(desktop(),
2214 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2218 case 413: // Extrusion
2220 if (checkLock(aStudy)) break;
2222 EmitSignalDeactivateDialog();
2223 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2225 SUIT_MessageBox::warning(desktop(),
2226 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2230 case 414: // Revolution
2232 if(checkLock(aStudy)) break;
2234 EmitSignalDeactivateDialog();
2235 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2238 SUIT_MessageBox::warning(desktop(),
2239 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2243 case 415: // Pattern mapping
2245 if ( checkLock( aStudy ) )
2249 EmitSignalDeactivateDialog();
2250 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2253 SUIT_MessageBox::warning(desktop(),
2254 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2258 case 416: // Extrusion along a path
2260 if (checkLock(aStudy)) break;
2262 EmitSignalDeactivateDialog();
2263 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2265 SUIT_MessageBox::warning(desktop(),
2266 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2270 case 417: // Convert mesh to quadratic
2272 startOperation( 417 );
2273 /* if (checkLock(aStudy)) break;
2275 EmitSignalDeactivateDialog();
2276 new SMESHGUI_ConvToQuadDlg();
2278 SUIT_MessageBox::warning(desktop(),
2279 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2283 case 418: // create 2D mesh from 3D
2285 startOperation( 418 );
2288 case 806: // CREATE GEO GROUP
2290 startOperation( 806 );
2293 case 801: // CREATE GROUP
2297 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2298 tr( "NOT_A_VTK_VIEWER" ) );
2302 if(checkLock(aStudy)) break;
2303 EmitSignalDeactivateDialog();
2304 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2306 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2307 SALOME_ListIO selected;
2309 aSel->selectedObjects( selected );
2311 int nbSel = selected.Extent();
2313 // check if mesh is selected
2314 aMesh = SMESH::GetMeshByIO( selected.First() );
2316 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2321 case 802: // CONSTRUCT GROUP
2325 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2326 tr( "NOT_A_VTK_VIEWER" ) );
2330 if(checkLock(aStudy)) break;
2331 EmitSignalDeactivateDialog();
2333 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2334 SALOME_ListIO selected;
2336 aSel->selectedObjects( selected );
2338 int nbSel = selected.Extent();
2340 // check if submesh is selected
2341 Handle(SALOME_InteractiveObject) IObject = selected.First();
2342 if (IObject->hasEntry()) {
2343 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2345 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2346 if (!aSubMesh->_is_nil()) {
2348 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2349 // get submesh elements list by types
2350 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2351 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2352 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2353 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2354 // create group for each type o elements
2355 QString aName = IObject->getName();
2356 if (aNodes->length() > 0) {
2357 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2358 aGroup->Add(aNodes.inout());
2360 if (aEdges->length() > 0) {
2361 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2362 aGroup->Add(aEdges.inout());
2364 if (aFaces->length() > 0) {
2365 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2366 aGroup->Add(aFaces.inout());
2368 if (aVolumes->length() > 0) {
2369 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2370 aGroup->Add(aVolumes.inout());
2375 catch(const SALOME::SALOME_Exception & S_ex){
2376 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2383 SUIT_MessageBox::warning(desktop(),
2384 tr("SMESH_WRN_WARNING"),
2385 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2390 case 803: // EDIT GROUP
2394 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2395 tr( "NOT_A_VTK_VIEWER" ) );
2399 if(checkLock(aStudy)) break;
2400 EmitSignalDeactivateDialog();
2402 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2403 SALOME_ListIO selected;
2405 aSel->selectedObjects( selected );
2407 SALOME_ListIteratorOfListIO It (selected);
2408 int nbSelectedGroups = 0;
2409 for ( ; It.More(); It.Next() )
2411 SMESH::SMESH_GroupBase_var aGroup =
2412 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2413 if (!aGroup->_is_nil()) {
2415 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2419 if (nbSelectedGroups == 0)
2421 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2427 case 804: // Add elements to group
2429 if(checkLock(aStudy)) break;
2430 if (myState == 800) {
2431 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2432 if (aDlg) aDlg->onAdd();
2437 case 805: // Remove elements from group
2439 if(checkLock(aStudy)) break;
2440 if (myState == 800) {
2441 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2442 if (aDlg) aDlg->onRemove();
2447 case 815: // Edit GEOM GROUP as standalone
2451 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2452 tr( "NOT_A_VTK_VIEWER" ) );
2456 if(checkLock(aStudy)) break;
2457 EmitSignalDeactivateDialog();
2459 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2460 SALOME_ListIO selected;
2462 aSel->selectedObjects( selected );
2464 SALOME_ListIteratorOfListIO It (selected);
2465 for ( ; It.More(); It.Next() )
2467 SMESH::SMESH_GroupOnGeom_var aGroup =
2468 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2469 if (!aGroup->_is_nil()) {
2470 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2477 case 810: // Union Groups
2478 case 811: // Intersect groups
2479 case 812: // Cut groups
2483 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2484 tr( "NOT_A_VTK_VIEWER" ) );
2488 if ( checkLock( aStudy ) )
2491 EmitSignalDeactivateDialog();
2493 SMESHGUI_GroupOpDlg* aDlg = 0;
2494 if ( theCommandID == 810 )
2495 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2496 else if ( theCommandID == 811 )
2497 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2499 aDlg = new SMESHGUI_CutGroupsDlg( this );
2506 case 814: // Create groups of entities from existing groups of superior dimensions
2508 if ( checkLock( aStudy ) )
2511 EmitSignalDeactivateDialog();
2512 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2518 case 813: // Delete groups with their contents
2522 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2523 tr( "NOT_A_VTK_VIEWER" ) );
2527 if ( checkLock( aStudy ) )
2530 EmitSignalDeactivateDialog();
2532 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2536 case 900: // MESH INFOS
2537 case 903: // WHAT IS
2539 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2540 EmitSignalDeactivateDialog();
2541 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2542 SALOME_ListIO selected;
2544 aSel->selectedObjects( selected );
2546 if ( selected.Extent() > 1 ) { // a dlg for each IO
2547 SALOME_ListIteratorOfListIO It( selected );
2548 for ( ; It.More(); It.Next() ) {
2549 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2550 dlg->showInfo( It.Value() );
2555 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2561 case 902: // STANDARD MESH INFOS
2563 EmitSignalDeactivateDialog();
2564 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2565 SALOME_ListIO selected;
2567 aSel->selectedObjects( selected );
2569 if ( selected.Extent() > 1 ) { // a dlg for each IO
2571 SALOME_ListIteratorOfListIO It (selected);
2572 for ( ; It.More(); It.Next() ) {
2574 IOs.Append( It.Value() );
2575 aSel->setSelectedObjects( IOs );
2576 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2578 // restore selection
2579 aSel->setSelectedObjects( selected );
2582 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2585 case 903: // WHAT IS
2587 EmitSignalDeactivateDialog();
2588 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2593 case 904: // FIND ELEM
2595 startOperation( theCommandID );
2599 case 1100: // EDIT HYPOTHESIS
2601 if(checkLock(aStudy)) break;
2603 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2604 SALOME_ListIO selected;
2606 aSel->selectedObjects( selected );
2608 int nbSel = selected.Extent();
2611 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2612 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2614 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2615 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2616 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2617 if ( !aHypothesis->_is_nil() )
2620 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2621 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2623 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2634 case 1101: // RENAME
2636 if ( checkLock( aStudy ) )
2639 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2640 SALOME_ListIO selected;
2642 aSel->selectedObjects( selected );
2644 bool isAny = false; // is there any appropriate object selected
2646 SALOME_ListIteratorOfListIO It( selected );
2647 for ( ; It.More(); It.Next() )
2649 Handle(SALOME_InteractiveObject) IObject = It.Value();
2650 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2651 _PTR(GenericAttribute) anAttr;
2652 _PTR(AttributeName) aName;
2655 if ( obj->FindAttribute(anAttr, "AttributeName") )
2658 QString newName = QString(aName->Value().c_str());
2660 // check type to prevent renaming of inappropriate objects
2661 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2662 if (aType == MESH || aType == GROUP ||
2663 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2664 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2665 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2666 aType == HYPOTHESIS || aType == ALGORITHM)
2669 newName = LightApp_NameDlg::getName(desktop(), newName);
2670 if ( !newName.isEmpty() )
2672 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2674 // update name of group object and its actor
2675 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2676 if( !aGroupObject->_is_nil() )
2678 aGroupObject->SetName( newName.toLatin1().data() );
2679 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2680 anActor->setName( newName.toLatin1().data() );
2691 SUIT_MessageBox::warning(desktop(),
2692 QObject::tr("SMESH_WRN_WARNING"),
2693 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2698 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2700 if(checkLock(aStudy)) break;
2701 SUIT_OverrideCursor wc;
2703 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2704 SALOME_ListIO selected;
2706 aSel->selectedObjects( selected, QString::null, false );
2708 SALOME_ListIteratorOfListIO It(selected);
2709 for (int i = 0; It.More(); It.Next(), i++) {
2710 Handle(SALOME_InteractiveObject) IObject = It.Value();
2711 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2714 aSel->setSelectedObjects( l1 );
2719 case 4009: // ELEM0D
2720 case 4010: // GEOM::EDGE
2721 case 4021: // TRIANGLE
2723 case 4023: // POLYGON
2727 if(checkLock(aStudy)) break;
2729 EmitSignalDeactivateDialog();
2730 SMDSAbs_ElementType type = SMDSAbs_Edge;
2732 switch (theCommandID) {
2733 case 4009: // ELEM0D
2734 type = SMDSAbs_0DElement; nbNodes = 1; break;
2735 case 4021: // TRIANGLE
2736 type = SMDSAbs_Face; nbNodes = 3; break;
2738 type = SMDSAbs_Face; nbNodes = 4; break;
2740 type = SMDSAbs_Volume; nbNodes = 4; break;
2741 case 4023: // POLYGON
2742 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2744 type = SMDSAbs_Volume; nbNodes = 8; break;
2745 case 4033: // POLYHEDRE
2746 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2749 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2752 SUIT_MessageBox::warning(desktop(),
2753 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2757 case 4033: // POLYHEDRON
2759 if(checkLock(aStudy)) break;
2761 EmitSignalDeactivateDialog();
2762 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2765 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2766 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2770 case 4034: // QUADRATIC EDGE
2771 case 4035: // QUADRATIC TRIANGLE
2772 case 4036: // QUADRATIC QUADRANGLE
2773 case 4037: // QUADRATIC TETRAHEDRON
2774 case 4038: // QUADRATIC PYRAMID
2775 case 4039: // QUADRATIC PENTAHEDRON
2776 case 4040: // QUADRATIC HEXAHEDRON
2778 if(checkLock(aStudy)) break;
2780 EmitSignalDeactivateDialog();
2783 switch (theCommandID) {
2785 type = QUAD_EDGE; break;
2787 type = QUAD_TRIANGLE; break;
2789 type = QUAD_QUADRANGLE; break;
2791 type = QUAD_TETRAHEDRON; break;
2793 type = QUAD_PYRAMID; break;
2795 type = QUAD_PENTAHEDRON; break;
2797 type = QUAD_HEXAHEDRON;
2801 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2804 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2805 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2809 case 4041: // REMOVES NODES
2811 if(checkLock(aStudy)) break;
2813 EmitSignalDeactivateDialog();
2814 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2817 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2818 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2822 case 4042: // REMOVES ELEMENTS
2824 if(checkLock(aStudy)) break;
2826 EmitSignalDeactivateDialog();
2827 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2831 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2832 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2836 case 4043: { // CLEAR_MESH
2838 if(checkLock(aStudy)) break;
2840 SALOME_ListIO selected;
2841 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2842 aSel->selectedObjects( selected );
2844 SUIT_OverrideCursor wc;
2845 SALOME_ListIteratorOfListIO It (selected);
2846 for ( ; It.More(); It.Next() )
2848 Handle(SALOME_InteractiveObject) IOS = It.Value();
2849 SMESH::SMESH_Mesh_var aMesh =
2850 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2851 if ( aMesh->_is_nil()) continue;
2853 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2855 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2856 SMESH::ModifiedMesh( aMeshSObj, false, true);
2857 // hide groups and submeshes
2858 _PTR(ChildIterator) anIter =
2859 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2860 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2862 _PTR(SObject) so = anIter->Value();
2863 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2866 catch (const SALOME::SALOME_Exception& S_ex){
2868 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2872 SMESH::UpdateView();
2876 case 4044: // REMOVE ORPHAN NODES
2878 if(checkLock(aStudy)) break;
2879 SALOME_ListIO selected;
2880 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2881 aSel->selectedObjects( selected );
2882 if ( selected.Extent() == 1 ) {
2883 Handle(SALOME_InteractiveObject) anIO = selected.First();
2884 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2885 if ( !aMesh->_is_nil() ) {
2886 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2887 tr( "SMESH_WARNING" ),
2888 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2889 SUIT_MessageBox::Yes |
2890 SUIT_MessageBox::No,
2891 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2894 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2895 int removed = aMeshEditor->RemoveOrphanNodes();
2896 SUIT_MessageBox::information(SMESHGUI::desktop(),
2897 tr("SMESH_INFORMATION"),
2898 tr("NB_NODES_REMOVED").arg(removed));
2899 if ( removed > 0 ) {
2900 SMESH::UpdateView();
2901 SMESHGUI::Modified();
2904 catch (const SALOME::SALOME_Exception& S_ex) {
2905 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2914 case 4051: // RENUMBERING NODES
2916 if(checkLock(aStudy)) break;
2918 EmitSignalDeactivateDialog();
2919 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2923 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2924 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2928 case 4052: // RENUMBERING ELEMENTS
2930 if(checkLock(aStudy)) break;
2932 EmitSignalDeactivateDialog();
2933 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2937 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2938 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2942 case 4061: // TRANSLATION
2944 if(checkLock(aStudy)) break;
2946 EmitSignalDeactivateDialog();
2947 ( new SMESHGUI_TranslationDlg( this ) )->show();
2950 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2951 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2955 case 4062: // ROTATION
2957 if(checkLock(aStudy)) break;
2959 EmitSignalDeactivateDialog();
2960 ( new SMESHGUI_RotationDlg( this ) )->show();
2963 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2964 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2968 case 4063: // SYMMETRY
2970 if(checkLock(aStudy)) break;
2972 EmitSignalDeactivateDialog();
2973 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2976 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2981 case 4064: // SEWING
2983 if(checkLock(aStudy)) break;
2985 EmitSignalDeactivateDialog();
2986 ( new SMESHGUI_SewingDlg( this ) )->show();
2989 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2990 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2994 case 4065: // MERGE NODES
2996 if(checkLock(aStudy)) break;
2998 EmitSignalDeactivateDialog();
2999 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3002 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3007 case 4066: // MERGE EQUAL ELEMENTS
3009 if (checkLock(aStudy)) break;
3011 EmitSignalDeactivateDialog();
3012 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3014 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3015 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3020 case 4067: // MAKE MESH PASS THROUGH POINT
3021 startOperation( 4067 );
3026 if(checkLock(aStudy)) break;
3028 EmitSignalDeactivateDialog();
3029 ( new SMESHGUI_ScaleDlg( this ) )->show();
3032 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3033 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3038 case 4069: // DUPLICATE NODES
3040 if(checkLock(aStudy)) break;
3042 EmitSignalDeactivateDialog();
3043 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3046 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3052 case 5105: // Library of selection filters
3054 static QList<int> aTypes;
3055 if ( aTypes.isEmpty() )
3057 aTypes.append( SMESH::NODE );
3058 aTypes.append( SMESH::EDGE );
3059 aTypes.append( SMESH::FACE );
3060 aTypes.append( SMESH::VOLUME );
3062 if (!myFilterLibraryDlg)
3063 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3064 else if (myFilterLibraryDlg->isHidden())
3065 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3066 myFilterLibraryDlg->raise();
3070 case 6017: // CONTROLS
3094 LightApp_SelectionMgr* mgr = selectionMgr();
3095 SALOME_ListIO selected; mgr->selectedObjects( selected );
3097 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3098 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3100 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3101 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3102 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3103 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3104 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3105 ::Control( theCommandID );
3110 SUIT_MessageBox::warning(desktop(),
3111 tr( "SMESH_WRN_WARNING" ),
3112 tr( "SMESH_BAD_SELECTION" ) );
3116 SUIT_MessageBox::warning(desktop(),
3117 tr( "SMESH_WRN_WARNING" ),
3118 tr( "NOT_A_VTK_VIEWER" ) );
3123 LightApp_SelectionMgr* mgr = selectionMgr();
3124 SALOME_ListIO selected; mgr->selectedObjects( selected );
3126 SALOME_ListIteratorOfListIO it(selected);
3127 for( ; it.More(); it.Next()) {
3128 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3129 if(anIObject->hasEntry()) {
3130 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3131 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3139 LightApp_SelectionMgr* mgr = selectionMgr();
3140 SALOME_ListIO selected; mgr->selectedObjects( selected );
3142 SALOME_ListIteratorOfListIO it(selected);
3143 for( ; it.More(); it.Next()) {
3144 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3145 if(anIObject->hasEntry())
3146 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3147 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3155 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3156 EmitSignalDeactivateDialog();
3157 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3163 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3164 //updateObjBrowser();
3168 //=============================================================================
3172 //=============================================================================
3173 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3178 //=============================================================================
3182 //=============================================================================
3183 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3188 //=============================================================================
3192 //=============================================================================
3193 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3198 //=============================================================================
3199 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3200 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3202 //=============================================================================
3203 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3204 SUIT_ViewWindow* wnd )
3206 if(theIO->hasEntry()){
3207 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3208 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3212 //=======================================================================
3213 // function : createSMESHAction
3215 //=======================================================================
3216 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3217 const int key, const bool toggle, const QString& shortcutAction )
3220 QWidget* parent = application()->desktop();
3221 SUIT_ResourceMgr* resMgr = resourceMgr();
3223 if ( !icon_id.isEmpty() )
3224 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3226 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3227 if ( !pix.isNull() )
3228 icon = QIcon( pix );
3230 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3231 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3232 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3234 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3235 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3238 //=======================================================================
3239 // function : createPopupItem
3241 //=======================================================================
3242 void SMESHGUI::createPopupItem( const int id,
3243 const QString& clients,
3244 const QString& types,
3245 const QString& theRule,
3250 parentId = popupMgr()->actionId( action( pId ) );
3252 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3253 popupMgr()->insert( action( id ), parentId, 0 );
3255 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3256 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3257 QString rule = "(%1) and (%2) and (%3)";
3258 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3259 if( clients.isEmpty() )
3260 rule = rule.arg( QString( "true" ) );
3262 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3263 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3266 bool cont = myRules.contains( id );
3268 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3270 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3271 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3274 //=======================================================================
3275 // function : initialize
3277 //=======================================================================
3278 void SMESHGUI::initialize( CAM_Application* app )
3280 SalomeApp_Module::initialize( app );
3282 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3284 /* Automatic Update flag */
3285 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3287 // ----- create actions --------------
3289 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3290 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3291 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3292 createSMESHAction( 114, "NUM" );
3293 createSMESHAction( 121, "DAT" );
3294 createSMESHAction( 122, "MED" );
3295 createSMESHAction( 123, "UNV" );
3296 createSMESHAction( 140, "STL" );
3297 createSMESHAction( 124, "EXPORT_DAT" );
3298 createSMESHAction( 125, "EXPORT_MED" );
3299 createSMESHAction( 126, "EXPORT_UNV" );
3300 createSMESHAction( 141, "EXPORT_STL" );
3301 createSMESHAction( 150, "FILE_INFO" );
3302 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3303 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3304 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3305 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3306 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3307 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3308 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3309 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3310 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3311 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3312 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3313 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3314 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3315 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3316 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3317 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3318 createSMESHAction( 804, "ADD" );
3319 createSMESHAction( 805, "REMOVE" );
3320 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3321 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3322 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3323 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3324 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3325 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3326 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3327 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3328 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3329 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3330 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3331 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3332 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3333 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3334 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3335 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3336 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3337 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3338 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3339 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3340 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3341 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3342 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3343 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3344 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3345 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3346 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3347 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3348 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3349 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3350 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3351 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3352 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3353 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3354 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3355 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3356 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3357 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3358 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3359 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3360 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3361 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3362 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3363 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3364 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3365 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3366 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3367 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3368 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3369 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3370 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3371 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3372 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3373 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3374 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3375 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3376 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3377 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3378 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3379 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3380 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3381 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3382 createSMESHAction( 415, "MAP", "ICON_MAP" );
3383 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3384 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3385 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3386 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3387 createSMESHAction( 200, "RESET" );
3388 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3389 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3390 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3391 #ifndef DISABLE_PLOT2DVIEWER
3392 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3394 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3395 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3396 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3397 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3398 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3399 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3400 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3401 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3402 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3403 createSMESHAction( 220, "ALL" );
3404 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3406 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3407 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3409 createSMESHAction( 1100, "EDIT_HYPO" );
3410 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3411 createSMESHAction( 1102, "UNASSIGN" );
3412 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3413 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3414 createSMESHAction( 1131, "DISPMODE" );
3415 createSMESHAction( 1132, "COLORS" );
3416 createSMESHAction( 1133, "TRANSP" );
3417 createSMESHAction( 1134, "CLIP" );
3418 createSMESHAction( 1135, "DISP_ENT" );
3419 createSMESHAction( 1136, "AUTO_COLOR" );
3420 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3421 createSMESHAction( 2000, "CTRL" );
3423 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3424 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3426 createSMESHAction( 300, "ERASE" );
3427 createSMESHAction( 301, "DISPLAY" );
3428 createSMESHAction( 302, "DISPLAY_ONLY" );
3429 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3430 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3431 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3432 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3433 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3434 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3435 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3436 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3438 // ----- create menu --------------
3439 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3440 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3441 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3442 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3443 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3444 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3445 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3446 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3448 createMenu( separator(), fileId );
3450 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3451 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3452 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3453 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3454 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3455 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3456 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3457 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3458 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3459 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3461 createMenu( 111, importId, -1 );
3462 createMenu( 112, importId, -1 );
3463 createMenu( 113, importId, -1 );
3465 createMenu( 121, exportId, -1 );
3466 createMenu( 122, exportId, -1 );
3467 createMenu( 123, exportId, -1 );
3468 createMenu( 140, exportId, -1 ); // export to stl STL
3470 createMenu( separator(), fileId, 10 );
3472 createMenu( 33, editId, -1 );
3474 createMenu( 5105, toolsId, -1 );
3476 createMenu( 702, meshId, -1 ); // "Mesh" menu
3477 createMenu( 703, meshId, -1 );
3478 createMenu( 704, meshId, -1 );
3479 createMenu( 710, meshId, -1 );
3480 createMenu( 705, meshId, -1 );
3481 createMenu( separator(), meshId, -1 );
3482 createMenu( 701, meshId, -1 );
3483 createMenu( 711, meshId, -1 );
3484 createMenu( 712, meshId, -1 );
3485 createMenu( 713, meshId, -1 );
3486 createMenu( separator(), meshId, -1 );
3487 createMenu( 801, meshId, -1 );
3488 createMenu( 806, meshId, -1 );
3489 createMenu( 802, meshId, -1 );
3490 createMenu( 803, meshId, -1 );
3491 createMenu( 815, meshId, -1 );
3492 createMenu( separator(), meshId, -1 );
3493 createMenu( 810, meshId, -1 );
3494 createMenu( 811, meshId, -1 );
3495 createMenu( 812, meshId, -1 );
3496 createMenu( separator(), meshId, -1 );
3497 createMenu( 814, meshId, -1 );
3498 createMenu( separator(), meshId, -1 );
3499 createMenu( 900, meshId, -1 );
3500 //createMenu( 902, meshId, -1 );
3501 createMenu( 903, meshId, -1 );
3502 createMenu( 904, meshId, -1 );
3503 createMenu( separator(), meshId, -1 );
3505 createMenu( 6005, nodeId, -1 );
3506 createMenu( 6002, edgeId, -1 );
3507 createMenu( 6003, edgeId, -1 );
3508 createMenu( 6001, edgeId, -1 );
3509 createMenu( 6004, edgeId, -1 );
3510 createMenu( 6021, faceId, -1 );
3511 createMenu( 6025, faceId, -1 );
3512 createMenu( 6027, faceId, -1 );
3513 createMenu( 6018, faceId, -1 );
3514 createMenu( 6019, faceId, -1 );
3515 createMenu( 6011, faceId, -1 );
3516 createMenu( 6012, faceId, -1 );
3517 createMenu( 6013, faceId, -1 );
3518 createMenu( 6014, faceId, -1 );
3519 createMenu( 6015, faceId, -1 );
3520 createMenu( 6016, faceId, -1 );
3521 createMenu( 6022, faceId, -1 );
3522 createMenu( 6017, volumeId, -1 );
3523 createMenu( 6009, volumeId, -1 );
3524 createMenu( 6023, volumeId, -1 );
3525 createMenu( 6024, volumeId, -1 );
3526 createMenu( 6026, volumeId, -1 );
3528 createMenu( 4000, addId, -1 );
3529 createMenu( 4009, addId, -1 );
3530 createMenu( 4010, addId, -1 );
3531 createMenu( 4021, addId, -1 );
3532 createMenu( 4022, addId, -1 );
3533 createMenu( 4023, addId, -1 );
3534 createMenu( 4031, addId, -1 );
3535 createMenu( 4032, addId, -1 );
3536 createMenu( 4033, addId, -1 );
3537 createMenu( separator(), addId, -1 );
3538 createMenu( 4034, addId, -1 );
3539 createMenu( 4035, addId, -1 );
3540 createMenu( 4036, addId, -1 );
3541 createMenu( 4037, addId, -1 );
3542 createMenu( 4038, addId, -1 );
3543 createMenu( 4039, addId, -1 );
3544 createMenu( 4040, addId, -1 );
3546 createMenu( 4041, removeId, -1 );
3547 createMenu( 4042, removeId, -1 );
3548 createMenu( 4044, removeId, -1 );
3549 createMenu( separator(), removeId, -1 );
3550 createMenu( 813, removeId, -1 );
3551 createMenu( separator(), removeId, -1 );
3552 createMenu( 4043, removeId, -1 );
3554 createMenu( 4051, renumId, -1 );
3555 createMenu( 4052, renumId, -1 );
3557 createMenu( 4061, transfId, -1 );
3558 createMenu( 4062, transfId, -1 );
3559 createMenu( 4063, transfId, -1 );
3560 createMenu( 4064, transfId, -1 );
3561 createMenu( 4065, transfId, -1 );
3562 createMenu( 4066, transfId, -1 );
3563 createMenu( 4068, transfId, -1 );
3564 createMenu( 4069, transfId, -1 );
3566 createMenu( 4067,modifyId, -1 );
3567 createMenu( 407, modifyId, -1 );
3568 createMenu( 408, modifyId, -1 );
3569 createMenu( 409, modifyId, -1 );
3570 createMenu( 410, modifyId, -1 );
3571 createMenu( 411, modifyId, -1 );
3572 createMenu( 419, modifyId, -1 );
3573 createMenu( 412, modifyId, -1 );
3574 createMenu( 413, modifyId, -1 );
3575 createMenu( 416, modifyId, -1 );
3576 createMenu( 414, modifyId, -1 );
3577 createMenu( 415, modifyId, -1 );
3578 createMenu( 417, modifyId, -1 );
3579 createMenu( 418, modifyId, -1 );
3581 createMenu( 501, measureId, -1 );
3582 createMenu( 502, measureId, -1 );
3583 createMenu( 214, viewId, -1 );
3585 // ----- create toolbars --------------
3586 int meshTb = createTool( tr( "TB_MESH" ) ),
3587 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3588 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3589 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3590 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3592 createTool( 702, meshTb );
3593 createTool( 703, meshTb );
3594 createTool( 704, meshTb );
3595 createTool( 710, meshTb );
3596 createTool( 705, meshTb );
3597 createTool( separator(), meshTb );
3598 createTool( 701, meshTb );
3599 createTool( 711, meshTb );
3600 createTool( 712, meshTb );
3601 createTool( 713, meshTb );
3602 createTool( separator(), meshTb );
3603 createTool( 801, meshTb );
3604 createTool( 806, meshTb );
3605 createTool( 802, meshTb );
3606 createTool( 803, meshTb );
3607 //createTool( 815, meshTb );
3608 createTool( separator(), meshTb );
3609 createTool( 900, meshTb );
3610 //createTool( 902, meshTb );
3611 createTool( 903, meshTb );
3612 createTool( 904, meshTb );
3613 createTool( separator(), meshTb );
3615 createTool( 6005, ctrlTb );
3616 createTool( separator(), ctrlTb );
3617 createTool( 6002, ctrlTb );
3618 createTool( 6003, ctrlTb );
3619 createTool( 6001, ctrlTb );
3620 createTool( 6004, ctrlTb );
3621 createTool( separator(), ctrlTb );
3622 createTool( 6021, ctrlTb );
3623 createTool( 6025, ctrlTb );
3624 createTool( 6027, ctrlTb );
3625 createTool( 6018, ctrlTb );
3626 createTool( 6019, ctrlTb );
3627 createTool( 6011, ctrlTb );
3628 createTool( 6012, ctrlTb );
3629 createTool( 6013, ctrlTb );
3630 createTool( 6014, ctrlTb );
3631 createTool( 6015, ctrlTb );
3632 createTool( 6016, ctrlTb );
3633 createTool( 6022, ctrlTb );
3634 createTool( separator(), ctrlTb );
3635 createTool( 6017, ctrlTb );
3636 createTool( 6009, ctrlTb );
3637 createTool( 6023, ctrlTb );
3638 createTool( 6024, ctrlTb );
3639 createTool( 6026, ctrlTb );
3640 createTool( separator(), ctrlTb );
3642 createTool( 4000, addRemTb );
3643 createTool( 4009, addRemTb );
3644 createTool( 4010, addRemTb );
3645 createTool( 4021, addRemTb );
3646 createTool( 4022, addRemTb );
3647 createTool( 4023, addRemTb );
3648 createTool( 4031, addRemTb );
3649 createTool( 4032, addRemTb );
3650 createTool( 4033, addRemTb );
3651 createTool( separator(), addRemTb );
3652 createTool( 4034, addRemTb );
3653 createTool( 4035, addRemTb );
3654 createTool( 4036, addRemTb );
3655 createTool( 4037, addRemTb );
3656 createTool( 4038, addRemTb );
3657 createTool( 4039, addRemTb );
3658 createTool( 4040, addRemTb );
3659 createTool( separator(), addRemTb );
3660 createTool( 4041, addRemTb );
3661 createTool( 4042, addRemTb );
3662 createTool( 4044, addRemTb );
3663 createTool( 4043, addRemTb );
3664 createTool( separator(), addRemTb );
3665 createTool( 4051, addRemTb );
3666 createTool( 4052, addRemTb );
3667 createTool( separator(), addRemTb );
3668 createTool( 4061, addRemTb );
3669 createTool( 4062, addRemTb );
3670 createTool( 4063, addRemTb );
3671 createTool( 4064, addRemTb );
3672 createTool( 4065, addRemTb );
3673 createTool( 4066, addRemTb );
3674 createTool( 4068, addRemTb );
3675 createTool( 4069, addRemTb );
3676 createTool( separator(), addRemTb );
3678 createTool( 4067,modifyTb );
3679 createTool( 407, modifyTb );
3680 createTool( 408, modifyTb );
3681 createTool( 409, modifyTb );
3682 createTool( 410, modifyTb );
3683 createTool( 411, modifyTb );
3684 createTool( 419, modifyTb );
3685 createTool( 412, modifyTb );
3686 createTool( 413, modifyTb );
3687 createTool( 416, modifyTb );
3688 createTool( 414, modifyTb );
3689 createTool( 415, modifyTb );
3690 createTool( 417, modifyTb );
3691 createTool( 418, modifyTb );
3693 createTool( 214, dispModeTb );
3695 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3696 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3699 QString OB = "'ObjectBrowser'",
3700 View = "'" + SVTK_Viewer::Type() + "'",
3702 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3703 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3704 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3705 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3706 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3707 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3708 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3709 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3710 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3711 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3712 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3714 mesh_group = mesh + " " + subMesh + " " + group,
3715 hyp_alg = hypo + " " + algo;
3717 // popup for object browser
3719 isInvisible("not( isVisible )"),
3720 isEmpty("numberOfNodes = 0"),
3721 isNotEmpty("numberOfNodes <> 0"),
3723 // has nodes, edges, etc in VISIBLE! actor
3724 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3725 hasElems("(count( elemTypes ) > 0)"),
3726 hasDifferentElems("(count( elemTypes ) > 1)"),
3727 hasElems0d("({'Elem0d'} in elemTypes)"),
3728 hasEdges("({'Edge'} in elemTypes)"),
3729 hasFaces("({'Face'} in elemTypes)"),
3730 hasVolumes("({'Volume'} in elemTypes)");
3732 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3733 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3734 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3735 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3736 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3737 createPopupItem( 803, OB, group ); // EDIT_GROUP
3738 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3740 popupMgr()->insert( separator(), -1, 0 );
3741 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3742 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3743 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3744 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3745 createPopupItem( 214, OB, mesh_group ); // UPDATE
3746 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3747 //createPopupItem( 902, OB, mesh ); // STD_INFO
3748 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3749 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3750 popupMgr()->insert( separator(), -1, 0 );
3751 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3752 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3753 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3754 popupMgr()->insert( separator(), -1, 0 );
3755 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3756 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3757 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3758 popupMgr()->insert( separator(), -1, 0 );
3759 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3760 popupMgr()->insert( separator(), -1, 0 );
3761 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3762 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3763 popupMgr()->insert( separator(), -1, 0 );
3765 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3766 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3768 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3769 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3770 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3771 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3772 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3773 popupMgr()->insert( separator(), -1, 0 );
3776 createPopupItem( 803, View, group ); // EDIT_GROUP
3777 createPopupItem( 804, View, elems ); // ADD
3778 createPopupItem( 805, View, elems ); // REMOVE
3780 popupMgr()->insert( separator(), -1, 0 );
3781 createPopupItem( 214, View, mesh_group ); // UPDATE
3782 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3783 //createPopupItem( 902, View, mesh ); // STD_INFO
3784 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3785 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3786 popupMgr()->insert( separator(), -1, 0 );
3788 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3789 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3790 popupMgr()->insert( separator(), -1, 0 );
3793 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3794 QString aType = QString( "%1type in {%2}" ).arg( lc );
3795 aType = aType.arg( mesh_group );
3796 QString aMeshInVTK = aClient + "&&" + aType;
3798 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3799 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3800 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3802 //-------------------------------------------------
3804 //-------------------------------------------------
3805 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3807 popupMgr()->insert( action( 9010 ), anId, -1 );
3808 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3809 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3811 popupMgr()->insert( action( 9011 ), anId, -1 );
3812 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3813 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3815 popupMgr()->insert( separator(), -1, -1 );
3817 //-------------------------------------------------
3819 //-------------------------------------------------
3820 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3822 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3823 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3824 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3826 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3827 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3828 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3830 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3831 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3832 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3834 popupMgr()->insert( separator(), anId, -1 );
3836 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3837 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3838 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3840 //-------------------------------------------------
3842 //-------------------------------------------------
3843 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3845 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3847 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3848 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3849 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3851 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3852 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3856 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3857 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3859 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3860 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3861 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3863 popupMgr()->insert( separator(), anId, -1 );
3865 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3866 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3869 //-------------------------------------------------
3870 // Representation of the 2D Quadratic elements
3871 //-------------------------------------------------
3872 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3873 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3874 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3875 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3877 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3878 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3879 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3881 //-------------------------------------------------
3882 // Orientation of faces
3883 //-------------------------------------------------
3884 popupMgr()->insert( action( 221 ), -1, -1 );
3885 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3886 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3888 //-------------------------------------------------
3890 //-------------------------------------------------
3891 popupMgr()->insert( action( 1132 ), -1, -1 );
3892 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3894 //-------------------------------------------------
3896 //-------------------------------------------------
3897 popupMgr()->insert( action( 1133 ), -1, -1 );
3898 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3900 //-------------------------------------------------
3902 //-------------------------------------------------
3904 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3905 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3906 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3907 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3909 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3911 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3912 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3914 popupMgr()->insert( separator(), anId, -1 );
3916 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3918 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3919 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3920 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3922 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3924 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3925 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3926 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3928 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3929 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3930 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3932 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3933 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3934 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3936 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3937 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3938 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3940 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3942 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3943 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3944 QtxPopupMgr::VisibleRule );
3945 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3947 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3948 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3949 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3951 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3952 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3953 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3955 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3956 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3957 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3959 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3960 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3961 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3963 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3964 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3965 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3967 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3968 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3969 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3971 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3972 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3973 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3975 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3976 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3977 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3979 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3980 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3981 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3983 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3984 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3985 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3987 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
3988 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3989 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
3991 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3993 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3994 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3995 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3997 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3998 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3999 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4001 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4002 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4003 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4005 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4006 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4007 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4009 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4010 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4011 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4013 popupMgr()->insert( separator(), anId, -1 );
4015 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4016 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4018 popupMgr()->insert( separator(), anId, -1 );
4020 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4022 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4023 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4025 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4026 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4027 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4029 #ifndef DISABLE_PLOT2DVIEWER
4030 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4031 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4034 //-------------------------------------------------
4036 //-------------------------------------------------
4037 popupMgr()->insert( separator(), -1, -1 );
4038 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4039 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4040 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4041 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4043 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4044 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4046 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4047 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4049 popupMgr()->insert( separator(), -1, -1 );
4051 //-------------------------------------------------
4053 //-------------------------------------------------
4054 popupMgr()->insert( action( 1134 ), -1, -1 );
4055 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4057 popupMgr()->insert( separator(), -1, -1 );
4059 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4060 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4062 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4063 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4066 //================================================================================
4068 * \brief Return true if SMESH or GEOM objects are selected.
4069 * Is called form LightApp_Module::activateModule() which clear selection if
4070 * not isSelectionCompatible()
4072 //================================================================================
4074 bool SMESHGUI::isSelectionCompatible()
4076 bool isCompatible = true;
4077 SALOME_ListIO selected;
4078 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4079 Sel->selectedObjects( selected );
4081 SALOME_ListIteratorOfListIO It( selected );
4082 for ( ; isCompatible && It.More(); It.Next())
4084 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4085 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4087 return isCompatible;
4091 bool SMESHGUI::reusableOperation( const int id )
4093 // compute, evaluate and precompute are not reusable operations
4094 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4097 bool SMESHGUI::activateModule( SUIT_Study* study )
4099 bool res = SalomeApp_Module::activateModule( study );
4101 setMenuShown( true );
4102 setToolShown( true );
4104 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4105 PyGILState_STATE gstate = PyGILState_Ensure();
4106 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4107 if(pluginsmanager==NULL)
4111 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4116 PyGILState_Release(gstate);
4117 // end of GEOM plugins loading
4119 // Reset actions accelerator keys
4120 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4121 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4122 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4124 action( 33)->setEnabled(true); // Delete: Key_Delete
4125 action(1101)->setEnabled(true); // Rename: Key_F2
4127 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4128 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4129 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4130 if ( _PTR(Study) aStudy = s->studyDS()) {
4131 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4132 updateObjBrowser(); // objects can be removed
4138 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4140 setMenuShown( false );
4141 setToolShown( false );
4143 EmitSignalCloseAllDialogs();
4145 // Unset actions accelerator keys
4146 action(111)->setShortcut(QKeySequence()); // Import DAT
4147 action(112)->setShortcut(QKeySequence()); // Import UNV
4148 action(113)->setShortcut(QKeySequence()); // Import MED
4150 action( 33)->setEnabled(false); // Delete: Key_Delete
4151 action(1101)->setEnabled(false); // Rename: Key_F2
4153 return SalomeApp_Module::deactivateModule( study );
4156 void SMESHGUI::studyClosed( SUIT_Study* s )
4158 SMESH::RemoveVisuData( s->id() );
4159 SalomeApp_Module::studyClosed( s );
4162 void SMESHGUI::OnGUIEvent()
4164 const QObject* obj = sender();
4165 if ( !obj || !obj->inherits( "QAction" ) )
4167 int id = actionId((QAction*)obj);
4172 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4174 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4175 if ( CORBA::is_nil( myComponentSMESH ) )
4177 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4179 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4180 return aGUI.myComponentSMESH;
4183 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4184 return myComponentSMESH;
4187 QString SMESHGUI::engineIOR() const
4189 CORBA::ORB_var anORB = getApp()->orb();
4190 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4191 return QString( anIOR.in() );
4194 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4196 SalomeApp_Module::contextMenuPopup( client, menu, title );
4198 selectionMgr()->selectedObjects( lst );
4199 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4200 Handle(SALOME_InteractiveObject) io = lst.First();
4201 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4202 _PTR(Study) study = appStudy->studyDS();
4203 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4205 QString aName = QString( obj->GetName().c_str() );
4206 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4207 aName.remove( (aName.length() - 1), 1 );
4213 LightApp_Selection* SMESHGUI::createSelection() const
4215 return new SMESHGUI_Selection();
4218 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4220 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4221 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4224 void SMESHGUI::viewManagers( QStringList& list ) const
4226 list.append( SVTK_Viewer::Type() );
4229 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4231 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4232 SMESH::UpdateSelectionProp( this );
4235 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4237 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4238 myClippingPlaneInfoMap.erase( theViewManager );
4241 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4243 theActor->AddObserver( SMESH::DeleteActorEvent,
4244 myEventCallbackCommand.GetPointer(),
4248 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4249 unsigned long theEvent,
4250 void* theClientData,
4253 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4254 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4255 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4256 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4257 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4258 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4259 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4260 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4261 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4262 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4263 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4264 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4265 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4266 if( anActor == *anIter3 ) {
4267 anActorList.erase( anIter3 );
4278 void SMESHGUI::createPreferences()
4280 // General tab ------------------------------------------------------------------------
4281 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4283 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4284 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4285 setPreferenceProperty( lim, "min", 0 );
4286 setPreferenceProperty( lim, "max", 100000000 );
4287 setPreferenceProperty( lim, "step", 1000 );
4288 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4290 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4291 setPreferenceProperty( qaGroup, "columns", 2 );
4292 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4293 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4294 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4295 setPreferenceProperty( prec, "min", 0 );
4296 setPreferenceProperty( prec, "max", 16 );
4298 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4299 setPreferenceProperty( dispgroup, "columns", 2 );
4300 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4302 modes.append( "Wireframe" );
4303 modes.append( "Shading" );
4304 modes.append( "Nodes" );
4305 modes.append( "Shrink" );
4306 QList<QVariant> indices;
4307 indices.append( 0 );
4308 indices.append( 1 );
4309 indices.append( 2 );
4310 indices.append( 3 );
4311 setPreferenceProperty( dispmode, "strings", modes );
4312 setPreferenceProperty( dispmode, "indexes", indices );
4314 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4315 setPreferenceProperty( arcgroup, "columns", 2 );
4316 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4317 QStringList quadraticModes;
4318 quadraticModes.append("Lines");
4319 quadraticModes.append("Arcs");
4321 indices.append( 0 );
4322 indices.append( 1 );
4323 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4324 setPreferenceProperty( quadraticmode, "indexes", indices );
4326 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4327 "SMESH", "max_angle" );
4328 setPreferenceProperty( maxAngle, "min", 1 );
4329 setPreferenceProperty( maxAngle, "max", 90 );
4333 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4334 setPreferenceProperty( exportgroup, "columns", 2 );
4335 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4336 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4338 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4339 setPreferenceProperty( computeGroup, "columns", 2 );
4340 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4342 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4343 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4344 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4346 indices.append( 0 );
4347 indices.append( 1 );
4348 indices.append( 2 );
4349 setPreferenceProperty( notifyMode, "strings", modes );
4350 setPreferenceProperty( notifyMode, "indexes", indices );
4352 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4353 setPreferenceProperty( computeGroup, "columns", 2 );
4354 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4356 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4357 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4359 indices.append( 0 );
4360 indices.append( 1 );
4361 setPreferenceProperty( elemInfo, "strings", modes );
4362 setPreferenceProperty( elemInfo, "indexes", indices );
4364 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4365 setPreferenceProperty( segGroup, "columns", 2 );
4366 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4367 "SMESH", "segmentation" );
4368 setPreferenceProperty( segLen, "min", 1 );
4369 setPreferenceProperty( segLen, "max", 10000000 );
4370 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4371 "SMESH", "nb_segments_per_edge" );
4372 setPreferenceProperty( nbSeg, "min", 1 );
4373 setPreferenceProperty( nbSeg, "max", 10000000 );
4375 // Quantities with individual precision settings
4376 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4377 setPreferenceProperty( precGroup, "columns", 2 );
4379 const int nbQuantities = 6;
4380 int precs[nbQuantities], ii = 0;
4381 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4382 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4383 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4384 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4385 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4386 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4387 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4388 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4389 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4390 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4391 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4392 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4394 // Set property for precision value for spinboxes
4395 for ( ii = 0; ii < nbQuantities; ii++ ){
4396 setPreferenceProperty( precs[ii], "min", -14 );
4397 setPreferenceProperty( precs[ii], "max", 14 );
4398 setPreferenceProperty( precs[ii], "precision", 2 );
4401 // Mesh tab ------------------------------------------------------------------------
4402 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4403 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4404 setPreferenceProperty( nodeGroup, "columns", 3 );
4406 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4408 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4410 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4411 QList<QVariant> aMarkerTypeIndicesList;
4412 QList<QVariant> aMarkerTypeIconsList;
4413 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4414 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4415 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4416 aMarkerTypeIndicesList << i;
4417 aMarkerTypeIconsList << pixmap;
4419 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4420 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4422 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4424 QList<QVariant> aMarkerScaleIndicesList;
4425 QStringList aMarkerScaleValuesList;
4426 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4427 aMarkerScaleIndicesList << i;
4428 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4430 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4431 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4433 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4434 setPreferenceProperty( elemGroup, "columns", 2 );
4436 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4437 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4438 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4439 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4441 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4442 setPreferenceProperty( grpGroup, "columns", 2 );
4444 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4446 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4447 //setPreferenceProperty( sp, "hstretch", 0 );
4448 //setPreferenceProperty( sp, "vstretch", 0 );
4450 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4451 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4452 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4453 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4454 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4455 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4456 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4458 setPreferenceProperty( size0d, "min", 1 );
4459 setPreferenceProperty( size0d, "max", 10 );
4461 setPreferenceProperty( sp, "hstretch", 0 );
4462 setPreferenceProperty( sp, "vstretch", 0 );
4464 setPreferenceProperty( elemW, "min", 1 );
4465 setPreferenceProperty( elemW, "max", 5 );
4467 setPreferenceProperty( shrink, "min", 0 );
4468 setPreferenceProperty( shrink, "max", 100 );
4470 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4471 setPreferenceProperty( orientGroup, "columns", 1 );
4473 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4474 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4476 setPreferenceProperty( orientScale, "min", 0.05 );
4477 setPreferenceProperty( orientScale, "max", 0.5 );
4478 setPreferenceProperty( orientScale, "step", 0.05 );
4480 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4482 // Selection tab ------------------------------------------------------------------------
4483 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4485 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4486 setPreferenceProperty( selGroup, "columns", 2 );
4488 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4489 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4490 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4492 setPreferenceProperty( selW, "min", 1 );
4493 setPreferenceProperty( selW, "max", 5 );
4495 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4496 setPreferenceProperty( preGroup, "columns", 2 );
4498 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4499 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4501 setPreferenceProperty( preW, "min", 1 );
4502 setPreferenceProperty( preW, "max", 5 );
4504 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4505 setPreferenceProperty( precSelGroup, "columns", 2 );
4507 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4508 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4509 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4511 // Scalar Bar tab ------------------------------------------------------------------------
4512 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4513 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4514 setPreferenceProperty( fontGr, "columns", 2 );
4516 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4517 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4519 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4520 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4522 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4523 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4525 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4526 setPreferenceProperty( numcol, "min", 2 );
4527 setPreferenceProperty( numcol, "max", 256 );
4529 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4530 setPreferenceProperty( numlab, "min", 2 );
4531 setPreferenceProperty( numlab, "max", 65 );
4533 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4534 setPreferenceProperty( orientGr, "columns", 2 );
4535 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4536 QStringList orients;
4537 orients.append( tr( "SMESH_VERTICAL" ) );
4538 orients.append( tr( "SMESH_HORIZONTAL" ) );
4539 indices.clear(); indices.append( 0 ); indices.append( 1 );
4540 setPreferenceProperty( orient, "strings", orients );
4541 setPreferenceProperty( orient, "indexes", indices );
4543 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4544 setPreferenceProperty( posVSizeGr, "columns", 2 );
4545 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4546 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4547 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4548 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4549 setPreferenceProperty( xv, "step", 0.1 );
4550 setPreferenceProperty( xv, "min", 0.0 );
4551 setPreferenceProperty( xv, "max", 1.0 );
4552 setPreferenceProperty( yv, "step", 0.1 );
4553 setPreferenceProperty( yv, "min", 0.0 );
4554 setPreferenceProperty( yv, "max", 1.0 );
4555 setPreferenceProperty( wv, "step", 0.1 );
4556 setPreferenceProperty( wv, "min", 0.0 );
4557 setPreferenceProperty( wv, "max", 1.0 );
4558 setPreferenceProperty( hv, "min", 0.0 );
4559 setPreferenceProperty( hv, "max", 1.0 );
4560 setPreferenceProperty( hv, "step", 0.1 );
4562 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4563 setPreferenceProperty( posHSizeGr, "columns", 2 );
4564 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4565 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4566 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4567 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4568 setPreferenceProperty( xv, "min", 0.0 );
4569 setPreferenceProperty( xv, "max", 1.0 );
4570 setPreferenceProperty( xv, "step", 0.1 );
4571 setPreferenceProperty( xh, "min", 0.0 );
4572 setPreferenceProperty( xh, "max", 1.0 );
4573 setPreferenceProperty( xh, "step", 0.1 );
4574 setPreferenceProperty( yh, "min", 0.0 );
4575 setPreferenceProperty( yh, "max", 1.0 );
4576 setPreferenceProperty( yh, "step", 0.1 );
4577 setPreferenceProperty( wh, "min", 0.0 );
4578 setPreferenceProperty( wh, "max", 1.0 );
4579 setPreferenceProperty( wh, "step", 0.1 );
4580 setPreferenceProperty( hh, "min", 0.0 );
4581 setPreferenceProperty( hh, "max", 1.0 );
4582 setPreferenceProperty( hh, "step", 0.1 );
4584 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4585 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4586 setPreferenceProperty( distributionGr, "columns", 3 );
4588 types.append( tr( "SMESH_MONOCOLOR" ) );
4589 types.append( tr( "SMESH_MULTICOLOR" ) );
4590 indices.clear(); indices.append( 0 ); indices.append( 1 );
4591 setPreferenceProperty( coloringType, "strings", types );
4592 setPreferenceProperty( coloringType, "indexes", indices );
4593 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4597 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4599 if( sect=="SMESH" ) {
4600 float sbX1,sbY1,sbW,sbH;
4601 float aTol = 1.00000009999999;
4602 std::string aWarning;
4603 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4604 if( name=="selection_object_color" || name=="selection_element_color" ||
4605 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4606 name=="selection_precision_node" || name=="selection_precision_element" ||
4607 name=="selection_precision_object")
4608 SMESH::UpdateSelectionProp( this );
4609 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4610 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4611 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4612 if(sbX1+sbW > aTol){
4613 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4616 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4617 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4620 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4621 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4622 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4623 if(sbY1+sbH > aTol){
4624 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4625 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4626 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4629 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4630 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4631 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4632 if(sbX1+sbW > aTol){
4633 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4636 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4637 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4640 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4641 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4642 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4643 if(sbY1+sbH > aTol){
4644 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4647 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4648 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4651 else if ( name == "segmentation" ) {
4652 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4653 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4655 else if ( name == "nb_segments_per_edge" ) {
4656 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4657 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4660 if(aWarning.size() != 0){
4661 aWarning += "The default values are applied instead.";
4662 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4663 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4664 QObject::tr(aWarning.c_str()));
4669 //================================================================================
4671 * \brief Update something in accordance with update flags
4672 * \param theFlags - update flags
4674 * Update viewer or/and object browser etc. in accordance with update flags ( see
4675 * LightApp_UpdateFlags enumeration ).
4677 //================================================================================
4678 void SMESHGUI::update( const int flags )
4680 if ( flags & UF_Viewer | flags & UF_Forced )
4681 SMESH::UpdateView();
4683 SalomeApp_Module::update( flags );
4686 //================================================================================
4688 * \brief Set default selection mode
4690 * SLOT called when operation commited. Sets default selection mode
4692 //================================================================================
4693 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4695 SVTK_ViewWindow* vtkWnd =
4696 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4698 vtkWnd->SetSelectionMode( ActorSelection );
4701 //================================================================================
4703 * \brief Set default selection mode
4705 * SLOT called when operation aborted. Sets default selection mode
4707 //================================================================================
4708 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4710 SVTK_ViewWindow* vtkWnd =
4711 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4713 vtkWnd->SetSelectionMode( ActorSelection );
4716 //================================================================================
4718 * \brief Creates operation with given identifier
4719 * \param id - identifier of operation to be started
4720 * \return Pointer on created operation or NULL if operation is not created
4722 * Virtual method redefined from the base class creates operation with given id.
4723 * It is called called automatically from startOperation method of base class.
4725 //================================================================================
4726 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4728 LightApp_Operation* op = 0;
4729 // to do : create operation here
4732 case 417: //convert to quadratic
4733 op = new SMESHGUI_ConvToQuadOp();
4735 case 418: // create 2D mesh as boundary on 3D
4736 op = new SMESHGUI_Make2DFrom3DOp();
4738 case 701: // Compute mesh
4739 op = new SMESHGUI_ComputeOp();
4741 case 702: // Create mesh
4742 op = new SMESHGUI_MeshOp( true, true );
4744 case 703: // Create sub-mesh
4745 op = new SMESHGUI_MeshOp( true, false );
4747 case 704: // Edit mesh/sub-mesh
4748 op = new SMESHGUI_MeshOp( false );
4750 case 711: // Precompute mesh
4751 op = new SMESHGUI_PrecomputeOp();
4753 case 712: // Evaluate mesh
4754 op = new SMESHGUI_EvaluateOp();
4756 case 713: // Evaluate mesh
4757 op = new SMESHGUI_MeshOrderOp();
4759 case 806: // Create group on geom
4760 op = new SMESHGUI_GroupOnShapeOp();
4762 case 904: // Find element
4763 op = new SMESHGUI_FindElemByPointOp();
4765 case 4067: // make mesh pass through point
4766 op = new SMESHGUI_MakeNodeAtPointOp();
4773 op = SalomeApp_Module::createOperation( id );
4777 //================================================================================
4779 * \brief Stops current operations and starts a given one
4780 * \param id - The id of the operation to start
4782 //================================================================================
4784 void SMESHGUI::switchToOperation(int id)
4786 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4787 activeStudy()->abortAllOperations();
4788 startOperation( id );
4791 LightApp_Displayer* SMESHGUI::displayer()
4794 myDisplayer = new SMESHGUI_Displayer( getApp() );
4798 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4801 int aTolerance = 64;
4802 int anIterations = 0;
4808 if( anIterations % aPeriod == 0 )
4811 if( aTolerance < 1 )
4815 aHue = (int)( 360.0 * rand() / RAND_MAX );
4818 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4819 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4820 for( ; it != itEnd; ++it )
4822 SALOMEDS::Color anAutoColor = *it;
4823 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4826 aQColor.getHsv( &h, &s, &v );
4827 if( abs( h - aHue ) < aTolerance )
4839 aColor.setHsv( aHue, 255, 255 );
4841 SALOMEDS::Color aSColor;
4842 aSColor.R = (double)aColor.red() / 255.0;
4843 aSColor.G = (double)aColor.green() / 255.0;
4844 aSColor.B = (double)aColor.blue() / 255.0;
4849 const char gSeparator = '_'; // character used to separate parameter names
4850 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4851 const char gPathSep = '|'; // character used to separate paths
4854 * \brief Store visual parameters
4856 * This method is called just before the study document is saved.
4857 * Store visual parameters in AttributeParameter attribue(s)
4859 void SMESHGUI::storeVisualParameters (int savePoint)
4861 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4862 if (!appStudy || !appStudy->studyDS())
4864 _PTR(Study) studyDS = appStudy->studyDS();
4866 // componentName is used for encoding of entries when storing them in IParameters
4867 std::string componentName = myComponentSMESH->ComponentDataType();
4868 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4869 //if (!aSComponent) return;
4872 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4873 componentName.c_str(),
4875 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4877 // store map of custom markers
4878 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4879 if( !aMarkerMap.empty() )
4881 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4882 for( ; anIter != aMarkerMap.end(); anIter++ )
4884 int anId = anIter->first;
4885 VTK::MarkerData aMarkerData = anIter->second;
4886 std::string aMarkerFileName = aMarkerData.first;
4887 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4888 if( aMarkerTexture.size() < 3 )
4889 continue; // should contain at least width, height and the first value
4891 QString aPropertyName( "texture" );
4892 aPropertyName += gSeparator;
4893 aPropertyName += QString::number( anId );
4895 QString aPropertyValue = aMarkerFileName.c_str();
4896 aPropertyValue += gPathSep;
4898 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4899 ushort aWidth = *aTextureIter++;
4900 ushort aHeight = *aTextureIter++;
4901 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4902 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4903 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4904 aPropertyValue += QString::number( *aTextureIter );
4906 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4910 // viewers counters are used for storing view_numbers in IParameters
4913 // main cycle to store parameters of displayed objects
4914 QList<SUIT_ViewManager*> lst;
4915 QList<SUIT_ViewManager*>::Iterator it;
4916 getApp()->viewManagers(lst);
4917 for (it = lst.begin(); it != lst.end(); it++)
4919 SUIT_ViewManager* vman = *it;
4920 QString vType = vman->getType();
4922 // saving VTK actors properties
4923 if (vType == SVTK_Viewer::Type())
4925 // store the clipping planes attached to the view manager
4926 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4927 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4928 if( anIter != myClippingPlaneInfoMap.end() )
4929 aClippingPlaneInfoList = anIter->second;
4931 if( !aClippingPlaneInfoList.empty() ) {
4932 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4933 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4935 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4936 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4938 QString aPropertyName( "ClippingPlane" );
4939 aPropertyName += gSeparator;
4940 aPropertyName += QString::number( vtkViewers );
4941 aPropertyName += gSeparator;
4942 aPropertyName += QString::number( anId );
4944 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4945 aPropertyValue += gDigitsSep;
4946 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4947 aPropertyValue += gDigitsSep;
4948 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4949 aPropertyValue += gDigitsSep;
4950 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4952 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4956 QVector<SUIT_ViewWindow*> views = vman->getViews();
4957 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4959 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4961 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4962 vtkActorCollection* allActors = aCopy.GetActors();
4963 allActors->InitTraversal();
4964 while (vtkActor* actor = allActors->GetNextActor())
4966 if (actor->GetVisibility()) // store only visible actors
4968 SMESH_Actor* aSmeshActor = 0;
4969 if (actor->IsA("SMESH_Actor"))
4970 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4971 if (aSmeshActor && aSmeshActor->hasIO())
4973 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4976 // entry is "encoded" = it does NOT contain component adress,
4977 // since it is a subject to change on next component loading
4978 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4980 std::string param, vtkParam = vType.toLatin1().data();
4981 vtkParam += gSeparator;
4982 vtkParam += QString::number(vtkViewers).toLatin1().data();
4983 vtkParam += gSeparator;
4986 param = vtkParam + "Visibility";
4987 ip->setParameter(entry, param, "On");
4990 param = vtkParam + "Representation";
4991 ip->setParameter(entry, param, QString::number
4992 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4995 param = vtkParam + "IsShrunk";
4996 ip->setParameter(entry, param, QString::number
4997 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4999 // Displayed entities
5000 unsigned int aMode = aSmeshActor->GetEntityMode();
5001 bool isE = aMode & SMESH_Actor::eEdges;
5002 bool isF = aMode & SMESH_Actor::eFaces;
5003 bool isV = aMode & SMESH_Actor::eVolumes;
5005 QString modeStr ("e");
5006 modeStr += gDigitsSep; modeStr += QString::number(isE);
5007 modeStr += gDigitsSep; modeStr += "f";
5008 modeStr += gDigitsSep; modeStr += QString::number(isF);
5009 modeStr += gDigitsSep; modeStr += "v";
5010 modeStr += gDigitsSep; modeStr += QString::number(isV);
5012 param = vtkParam + "Entities";
5013 ip->setParameter(entry, param, modeStr.toLatin1().data());
5015 // Colors (surface:edge:)
5016 vtkFloatingPointType r, g, b;
5018 aSmeshActor->GetSufaceColor(r, g, b);
5019 QString colorStr ("surface");
5020 colorStr += gDigitsSep; colorStr += QString::number(r);
5021 colorStr += gDigitsSep; colorStr += QString::number(g);
5022 colorStr += gDigitsSep; colorStr += QString::number(b);
5024 aSmeshActor->GetBackSufaceColor(r, g, b);
5025 colorStr += gDigitsSep; colorStr += "backsurface";
5026 colorStr += gDigitsSep; colorStr += QString::number(r);
5027 colorStr += gDigitsSep; colorStr += QString::number(g);
5028 colorStr += gDigitsSep; colorStr += QString::number(b);
5030 aSmeshActor->GetEdgeColor(r, g, b);
5031 colorStr += gDigitsSep; colorStr += "edge";
5032 colorStr += gDigitsSep; colorStr += QString::number(r);
5033 colorStr += gDigitsSep; colorStr += QString::number(g);
5034 colorStr += gDigitsSep; colorStr += QString::number(b);
5036 aSmeshActor->GetNodeColor(r, g, b);
5037 colorStr += gDigitsSep; colorStr += "node";
5038 colorStr += gDigitsSep; colorStr += QString::number(r);
5039 colorStr += gDigitsSep; colorStr += QString::number(g);
5040 colorStr += gDigitsSep; colorStr += QString::number(b);
5042 param = vtkParam + "Colors";
5043 ip->setParameter(entry, param, colorStr.toLatin1().data());
5045 // Sizes of lines and points
5046 QString sizeStr ("line");
5047 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5048 sizeStr += gDigitsSep; sizeStr += "shrink";
5049 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5051 param = vtkParam + "Sizes";
5052 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5057 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5058 if( aMarkerType == VTK::MT_USER ) {
5059 markerStr += "custom";
5060 markerStr += gDigitsSep;
5061 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5065 markerStr += gDigitsSep;
5066 markerStr += QString::number( (int)aMarkerType );
5067 markerStr += gDigitsSep;
5068 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5071 param = vtkParam + "PointMarker";
5072 ip->setParameter(entry, param, markerStr.toLatin1().data());
5075 param = vtkParam + "Opacity";
5076 ip->setParameter(entry, param,
5077 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5080 param = vtkParam + "ClippingPlane";
5082 if( !aClippingPlaneInfoList.empty() ) {
5083 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5084 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5086 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5087 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5088 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5089 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5090 if( aSmeshActor == *anIter2 ) {
5091 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5092 QString::number( anId ).toLatin1().constData() );
5099 ip->setParameter( entry, param, "Off" );
5100 } // if (io->hasEntry())
5101 } // SMESH_Actor && hasIO
5103 } // while.. actors traversal
5107 } // if (SVTK view model)
5108 } // for (viewManagers)
5111 // data structures for clipping planes processing
5114 vtkIdType Orientation;
5115 vtkFloatingPointType Distance;
5116 vtkFloatingPointType Angle[2];
5118 typedef std::list<TPlaneData> TPlaneDataList;
5119 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5121 typedef std::list<vtkActor*> TActorList;
5124 TActorList ActorList;
5125 SUIT_ViewManager* ViewManager;
5127 typedef std::list<TPlaneInfo> TPlaneInfoList;
5128 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5131 * \brief Restore visual parameters
5133 * This method is called after the study document is opened.
5134 * Restore visual parameters from AttributeParameter attribue(s)
5136 void SMESHGUI::restoreVisualParameters (int savePoint)
5138 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5139 if (!appStudy || !appStudy->studyDS())
5141 _PTR(Study) studyDS = appStudy->studyDS();
5143 // componentName is used for encoding of entries when storing them in IParameters
5144 std::string componentName = myComponentSMESH->ComponentDataType();
5145 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5146 //if (!aSComponent) return;
5149 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5150 componentName.c_str(),
5152 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5154 // restore map of custom markers and map of clipping planes
5155 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5156 TPlaneDataMap aPlaneDataMap;
5158 std::vector<std::string> properties = ip->getProperties();
5159 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5161 std::string property = *propIt;
5162 QString aPropertyName( property.c_str() );
5163 QString aPropertyValue( ip->getProperty( property ).c_str() );
5165 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5166 if( aPropertyNameList.isEmpty() )
5169 QString aPropertyType = aPropertyNameList[0];
5170 if( aPropertyType == "texture" )
5172 if( aPropertyNameList.size() != 2 )
5176 int anId = aPropertyNameList[1].toInt( &ok );
5177 if( !ok || anId < 1 )
5180 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5181 if( aPropertyValueList.size() != 2 )
5184 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5185 QString aMarkerTextureString = aPropertyValueList[1];
5186 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5187 if( aMarkerTextureStringList.size() != 3 )
5191 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5196 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5200 VTK::MarkerTexture aMarkerTexture;
5201 aMarkerTexture.push_back( aWidth );
5202 aMarkerTexture.push_back( aHeight );
5204 QString aMarkerTextureData = aMarkerTextureStringList[2];
5205 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5207 QChar aChar = aMarkerTextureData.at( i );
5208 if( aChar.isDigit() )
5209 aMarkerTexture.push_back( aChar.digitValue() );
5212 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5214 else if( aPropertyType == "ClippingPlane" )
5216 if( aPropertyNameList.size() != 3 )
5220 int aViewId = aPropertyNameList[1].toInt( &ok );
5221 if( !ok || aViewId < 0 )
5225 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5226 if( !ok || aClippingPlaneId < 0 )
5229 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5230 if( aPropertyValueList.size() != 4 )
5233 TPlaneData aPlaneData;
5234 aPlaneData.Id = aClippingPlaneId;
5237 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5242 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5247 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5252 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5256 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5257 aPlaneDataList.push_back( aPlaneData );
5261 TPlaneInfoMap aPlaneInfoMap;
5263 std::vector<std::string> entries = ip->getEntries();
5265 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5267 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5268 QString entry (ip->decodeEntry(*entIt).c_str());
5270 // Check that the entry corresponds to a real object in the Study
5271 // as the object may be deleted or modified after the visual state is saved.
5272 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5273 if (!so) continue; //Skip the not existent entry
5275 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5276 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5278 std::vector<std::string>::iterator namesIt = paramNames.begin();
5279 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5281 // actors are stored in a map after displaying of them for
5282 // quicker access in the future: map < viewID to actor >
5283 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5285 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5287 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5288 // '_' is used as separator and should not be used in viewer type or parameter names.
5289 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5290 if (lst.size() != 3)
5293 QString viewerTypStr = lst[0];
5294 QString viewIndexStr = lst[1];
5295 QString paramNameStr = lst[2];
5298 int viewIndex = viewIndexStr.toUInt(&ok);
5299 if (!ok) // bad conversion of view index to integer
5303 if (viewerTypStr == SVTK_Viewer::Type())
5305 SMESH_Actor* aSmeshActor = 0;
5306 if (vtkActors.IsBound(viewIndex))
5307 aSmeshActor = vtkActors.Find(viewIndex);
5309 QList<SUIT_ViewManager*> lst;
5310 getApp()->viewManagers(viewerTypStr, lst);
5312 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5313 SUIT_ViewManager* vman = NULL;
5314 if (viewIndex >= 0 && viewIndex < lst.count())
5315 vman = lst.at(viewIndex);
5317 if (paramNameStr == "Visibility")
5319 if (!aSmeshActor && displayer() && vman)
5321 SUIT_ViewModel* vmodel = vman->getViewModel();
5322 // SVTK view model can be casted to SALOME_View
5323 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5325 // store displayed actor in a temporary map for quicker
5326 // access later when restoring other parameters
5327 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5328 vtkRenderer* Renderer = vtkView->getRenderer();
5329 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5330 vtkActorCollection* theActors = aCopy.GetActors();
5331 theActors->InitTraversal();
5332 bool isFound = false;
5333 vtkActor *ac = theActors->GetNextActor();
5334 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5335 if (ac->IsA("SMESH_Actor")) {
5336 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5337 if (aGeomAc->hasIO()) {
5338 Handle(SALOME_InteractiveObject) io =
5339 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5340 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5342 vtkActors.Bind(viewIndex, aGeomAc);
5348 } // if (paramNameStr == "Visibility")
5351 // the rest properties "work" with SMESH_Actor
5354 QString val ((*valuesIt).c_str());
5357 if (paramNameStr == "Representation") {
5358 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5361 else if (paramNameStr == "IsShrunk") {
5363 if (!aSmeshActor->IsShrunk())
5364 aSmeshActor->SetShrink();
5367 if (aSmeshActor->IsShrunk())
5368 aSmeshActor->UnShrink();
5371 // Displayed entities
5372 else if (paramNameStr == "Entities") {
5373 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5374 if (mode.count() == 6) {
5375 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5376 MESSAGE("Invalid order of data in Entities, must be: "
5377 "e:0/1:f:0/1:v:0/1");
5380 unsigned int aMode = aSmeshActor->GetEntityMode();
5381 unsigned int aNewMode =
5382 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5383 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5384 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5385 if (aNewMode != aMode)
5386 aSmeshActor->SetEntityMode(aNewMode);
5391 else if (paramNameStr == "Colors") {
5392 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5393 if (colors.count() == 16) {
5394 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5395 colors[8] != "edge" || colors[12] != "node") {
5396 MESSAGE("Invalid order of data in Colors, must be: "
5397 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5400 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5401 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5402 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5403 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5407 // Sizes of lines and points
5408 else if (paramNameStr == "Sizes") {
5409 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5410 if (sizes.count() == 4) {
5411 if (sizes[0] != "line" || sizes[2] != "shrink") {
5412 MESSAGE("Invalid order of data in Sizes, must be: "
5413 "line:int:shrink:float");
5416 aSmeshActor->SetLineWidth(sizes[1].toInt());
5417 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5420 else if (sizes.count() == 6) { // just to support old format
5421 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5422 MESSAGE("Invalid order of data in Sizes, must be: "
5423 "line:int:node:int:shrink:float");
5426 aSmeshActor->SetLineWidth(sizes[1].toInt());
5427 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5428 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5433 else if (paramNameStr == "PointMarker") {
5434 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5435 if( data.count() >= 2 ) {
5437 int aParam1 = data[1].toInt( &ok );
5439 if( data[0] == "std" && data.count() == 3 ) {
5440 int aParam2 = data[2].toInt( &ok );
5441 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5443 else if( data[0] == "custom" ) {
5444 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5445 if( markerIt != aMarkerMap.end() ) {
5446 VTK::MarkerData aMarkerData = markerIt->second;
5447 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5454 else if (paramNameStr == "Opacity") {
5455 aSmeshActor->SetOpacity(val.toFloat());
5458 else if (paramNameStr.startsWith("ClippingPlane")) {
5459 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5460 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5461 // new format - val looks like "Off" or "0" (plane id)
5462 // (note: in new format "Off" value is used only for consistency,
5463 // so it is processed together with values in old format)
5464 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5465 if( anIsOldFormat ) {
5466 if (paramNameStr == "ClippingPlane1" || val == "Off")
5467 aSmeshActor->RemoveAllClippingPlanes();
5469 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5470 double aDistance = vals[1].toFloat();
5471 vtkFloatingPointType anAngle[2];
5472 anAngle[0] = vals[2].toFloat();
5473 anAngle[1] = vals[3].toFloat();
5475 QList<SUIT_ViewManager*> lst;
5476 getApp()->viewManagers(viewerTypStr, lst);
5477 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5478 if (viewIndex >= 0 && viewIndex < lst.count()) {
5479 SUIT_ViewManager* vman = lst.at(viewIndex);
5480 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5482 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5484 SMESH::TActorList anActorList;
5485 anActorList.push_back( aSmeshActor );
5486 SMESH::OrientedPlane* aPlane =
5487 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5489 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5490 aClippingPlaneInfo.Plane = aPlane;
5491 aClippingPlaneInfo.ActorList = anActorList;
5492 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5499 int aPlaneId = val.toInt( &ok );
5500 if( ok && aPlaneId >= 0 ) {
5501 bool anIsDefinedPlane = false;
5502 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5503 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5504 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5505 TPlaneInfo& aPlaneInfo = *anIter;
5506 if( aPlaneInfo.PlaneId == aPlaneId ) {
5507 aPlaneInfo.ActorList.push_back( aSmeshActor );
5508 anIsDefinedPlane = true;
5512 if( !anIsDefinedPlane ) {
5513 TPlaneInfo aPlaneInfo;
5514 aPlaneInfo.PlaneId = aPlaneId;
5515 aPlaneInfo.ActorList.push_back( aSmeshActor );
5516 aPlaneInfo.ViewManager = vman;
5518 // to make the list sorted by plane id
5519 anIter = aPlaneInfoList.begin();
5520 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5521 const TPlaneInfo& aPlaneInfoRef = *anIter;
5522 if( aPlaneInfoRef.PlaneId > aPlaneId )
5525 aPlaneInfoList.insert( anIter, aPlaneInfo );
5530 } // if (aSmeshActor)
5531 } // other parameters than Visibility
5533 } // for names/parameters iterator
5534 } // for entries iterator
5536 // take into account planes with empty list of actors referred to them
5537 QList<SUIT_ViewManager*> aVMList;
5538 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5540 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5541 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5542 int aViewId = aPlaneDataIter->first;
5543 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5544 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5546 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5548 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5549 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5550 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5551 const TPlaneData& aPlaneData = *anIter2;
5552 int aPlaneId = aPlaneData.Id;
5554 bool anIsFound = false;
5555 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5556 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5557 const TPlaneInfo& aPlaneInfo = *anIter3;
5558 if( aPlaneInfo.PlaneId == aPlaneId ) {
5565 TPlaneInfo aPlaneInfo; // ActorList field is empty
5566 aPlaneInfo.PlaneId = aPlaneId;
5567 aPlaneInfo.ViewManager = aViewManager;
5569 // to make the list sorted by plane id
5570 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5571 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5572 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5573 if( aPlaneInfoRef.PlaneId > aPlaneId )
5576 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5582 // add clipping planes to actors according to the restored parameters
5583 // and update the clipping plane map
5584 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5585 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5586 int aViewId = anIter1->first;
5587 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5589 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5590 if( anIter2 == aPlaneDataMap.end() )
5592 const TPlaneDataList& aPlaneDataList = anIter2->second;
5594 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5595 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5596 const TPlaneInfo& aPlaneInfo = *anIter3;
5597 int aPlaneId = aPlaneInfo.PlaneId;
5598 const TActorList& anActorList = aPlaneInfo.ActorList;
5599 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5603 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5607 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5609 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5610 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5611 const TPlaneData& aPlaneData = *anIter4;
5612 if( aPlaneData.Id == aPlaneId ) {
5613 SMESH::OrientedPlane* aPlane =
5614 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5616 (SMESH::Orientation)aPlaneData.Orientation,
5617 aPlaneData.Distance,
5620 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5621 aClippingPlaneInfo.Plane = aPlane;
5622 aClippingPlaneInfo.ActorList = anActorList;
5623 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5631 // update all VTK views
5632 QList<SUIT_ViewManager*> lst;
5633 getApp()->viewManagers(lst);
5634 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5635 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5636 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5637 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5638 vtkView->getRenderer()->ResetCameraClippingRange();
5645 \brief Adds preferences for dfont of VTK viewer
5647 \param pIf group identifier
5648 \param param parameter
5649 \return identifier of preferences
5651 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5653 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5655 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5658 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5659 fam.append( tr( "SMESH_FONT_COURIER" ) );
5660 fam.append( tr( "SMESH_FONT_TIMES" ) );
5662 setPreferenceProperty( tfont, "fonts", fam );
5664 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5665 setPreferenceProperty( tfont, "features", f );
5671 \brief Actions after hypothesis edition
5672 Updates object browser after hypothesis edition
5674 void SMESHGUI::onHypothesisEdit( int result )
5677 SMESHGUI::Modified();
5678 updateObjBrowser( true );