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 );
700 QList<SALOMEDS::Color> aReservedColors;
702 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
703 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
705 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
706 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
708 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
709 aGroupObject->SetColor( aColor );
710 aReservedColors.append( aColor );
712 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
714 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
715 if( aGroupObject->GetType() == SMESH::NODE )
716 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
717 else if( aGroupObject->GetType() == SMESH::EDGE )
718 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
719 else if( aGroupObject->GetType() == SMESH::ELEM0D )
720 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
722 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
727 SMESH::RepaintCurrentView();
730 QString functorToString( SMESH::Controls::FunctorPtr f )
732 QString type = QObject::tr( "UNKNOWN_CONTROL" );
733 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
734 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
735 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
736 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
737 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
738 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
739 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
740 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
741 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
742 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
743 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
744 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
745 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
746 type = QObject::tr( "WARP_ELEMENTS" );
747 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
748 type = QObject::tr( "TAPER_ELEMENTS" );
749 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
750 type = QObject::tr( "SKEW_ELEMENTS" );
751 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
752 type = QObject::tr( "AREA_ELEMENTS" );
753 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
754 type = QObject::tr( "LENGTH_EDGES" );
755 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
756 type = QObject::tr( "LENGTH2D_EDGES" );
757 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
758 type = QObject::tr( "MULTI_BORDERS" );
759 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
760 type = QObject::tr( "MULTI2D_BORDERS" );
761 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
762 type = QObject::tr( "FREE_NODES" );
763 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
764 type = QObject::tr( "FREE_EDGES" );
765 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
766 type = QObject::tr( "FREE_BORDERS" );
767 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
768 type = QObject::tr( "FREE_FACES" );
769 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
770 type = QObject::tr( "BARE_BORDER_VOLUME" );
771 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
772 type = QObject::tr( "BARE_BORDER_FACE" );
773 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
774 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
775 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
776 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
780 void SaveDistribution()
782 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
783 SALOME_ListIO selected;
785 aSel->selectedObjects( selected );
787 if ( selected.Extent() == 1 ) {
788 Handle(SALOME_InteractiveObject) anIO = selected.First();
789 if ( anIO->hasEntry() ) {
790 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
791 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
792 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
793 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
794 if ( aScalarBarActor && aFunctor ) {
795 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
797 std::vector<int> elements;
798 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
799 if ( mesh->_is_nil() ) {
800 SMESH::SMESH_IDSource_var idSource =
801 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
802 if ( !idSource->_is_nil() )
804 SMESH::long_array_var ids = idSource->GetIDs();
805 elements.resize( ids->length() );
806 for ( unsigned i = 0; i < elements.size(); ++i )
807 elements[i] = ids[i];
810 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
811 vtkLookupTable* lookupTable =
812 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
813 double * minmax = lookupTable->GetRange();
814 std::vector<int> nbEvents;
815 std::vector<double> funValues;
816 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
817 QString anInitialPath = "";
818 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
819 anInitialPath = QDir::currentPath();
820 QString aMeshName = anIO->getName();
822 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
823 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
824 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
825 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
826 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
829 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
831 if ( !aFilename.isEmpty() ) {
832 QFile f( aFilename );
833 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
834 QTextStream out( &f );
835 out << "# Mesh: " << aMeshName << endl;
836 out << "# Control: " << functorToString( aFunctor ) << endl;
838 out.setFieldWidth( 10 );
839 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
840 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
851 void ShowDistribution() {
852 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
853 SALOME_ListIO selected;
855 aSel->selectedObjects( selected );
857 if ( selected.Extent() == 1 ) {
858 Handle(SALOME_InteractiveObject) anIO = selected.First();
859 if ( anIO->hasEntry() ) {
860 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
861 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
862 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
863 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
869 #ifndef DISABLE_PLOT2DVIEWER
870 void PlotDistribution() {
871 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
875 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
876 SALOME_ListIO selected;
878 aSel->selectedObjects( selected );
880 if ( selected.Extent() == 1 ) {
881 Handle(SALOME_InteractiveObject) anIO = selected.First();
882 if ( anIO->hasEntry() ) {
883 //Find Actor by entry before getting Plot2d viewer,
884 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
885 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
887 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
892 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
896 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
900 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
901 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
902 QString functorName = functorToString( anActor->GetFunctor());
903 QString aHistogramName("%1 : %2");
904 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
905 aHistogram->setName(aHistogramName);
906 aHistogram->setHorTitle(functorName);
907 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
908 aPlot->displayObject(aHistogram, true);
913 #endif //DISABLE_PLOT2DVIEWER
915 void DisableAutoColor(){
916 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
917 SALOME_ListIO selected;
919 aSel->selectedObjects( selected );
921 if(selected.Extent()){
922 Handle(SALOME_InteractiveObject) anIObject = selected.First();
923 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
924 if ( !aMesh->_is_nil() ) {
925 aMesh->SetAutoColor( false );
930 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
931 SALOME_ListIO selected;
932 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
936 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
937 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
938 if( !aSel || !appStudy )
941 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
942 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
943 aModule->EmitSignalDeactivateDialog();
944 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
945 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
950 _PTR(Study) aStudy = appStudy->studyDS();
952 aSel->selectedObjects( selected );
954 if(selected.Extent() >= 1){
955 switch(theCommandID){
957 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
958 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
962 QColor c, e, b, n, c0D, o;
965 vtkFloatingPointType Shrink = 0.0;
966 vtkFloatingPointType faces_orientation_scale = 0.0;
967 bool faces_orientation_3dvectors = false;
969 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
970 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
971 int aMarkerTextureCurrent = 0;
973 SALOME_ListIteratorOfListIO It( selected );
974 for( ; It.More(); It.Next()){
975 Handle(SALOME_InteractiveObject) IObject = It.Value();
976 if(IObject->hasEntry()){
977 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
978 vtkFloatingPointType color[3];
979 anActor->GetSufaceColor(color[0], color[1], color[2]);
980 int c0 = int (color[0] * 255);
981 int c1 = int (color[1] * 255);
982 int c2 = int (color[2] * 255);
983 c.setRgb(c0, c1, c2);
985 vtkFloatingPointType edgecolor[3];
986 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
987 c0 = int (edgecolor[0] * 255);
988 c1 = int (edgecolor[1] * 255);
989 c2 = int (edgecolor[2] * 255);
990 e.setRgb(c0, c1, c2);
992 vtkFloatingPointType backfacecolor[3];
993 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
994 c0 = int (backfacecolor[0] * 255);
995 c1 = int (backfacecolor[1] * 255);
996 c2 = int (backfacecolor[2] * 255);
997 b.setRgb(c0, c1, c2);
999 vtkFloatingPointType nodecolor[3];
1000 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1001 c0 = int (nodecolor[0] * 255);
1002 c1 = int (nodecolor[1] * 255);
1003 c2 = int (nodecolor[2] * 255);
1004 n.setRgb(c0, c1, c2);
1006 vtkFloatingPointType color0D[3];
1007 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1008 c0 = int (color0D[0] * 255);
1009 c1 = int (color0D[1] * 255);
1010 c2 = int (color0D[2] * 255);
1011 c0D.setRgb(c0, c1, c2);
1013 size0D = (int)anActor->Get0DSize();
1016 Edgewidth = (int)anActor->GetLineWidth();
1019 Shrink = anActor->GetShrinkFactor();
1021 vtkFloatingPointType faces_orientation_color[3];
1022 anActor->GetFacesOrientationColor(faces_orientation_color);
1023 c0 = int (faces_orientation_color[0] * 255);
1024 c1 = int (faces_orientation_color[1] * 255);
1025 c2 = int (faces_orientation_color[2] * 255);
1026 o.setRgb(c0, c1, c2);
1028 faces_orientation_scale = anActor->GetFacesOrientationScale();
1029 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1031 aMarkerTypeCurrent = anActor->GetMarkerType();
1032 aMarkerScaleCurrent = anActor->GetMarkerScale();
1033 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1035 // even if there are multiple objects in the selection,
1036 // we need only the first one to get values for the dialog
1042 SMESHGUI_Preferences_ColorDlg *aDlg =
1043 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1044 aDlg->SetColor(1, c);
1045 aDlg->SetColor(2, e);
1046 aDlg->SetColor(3, n);
1047 aDlg->SetColor(4, b);
1048 aDlg->SetColor(5, c0D);
1049 aDlg->SetColor(6, o);
1050 aDlg->SetIntValue(1, Edgewidth);
1051 aDlg->SetIntValue(2, int(Shrink*100.));
1052 aDlg->SetIntValue(3, size0D);
1053 aDlg->SetDoubleValue(1, faces_orientation_scale);
1054 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1056 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1058 if( aMarkerTypeCurrent != VTK::MT_USER )
1059 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1061 aDlg->setCustomMarker( aMarkerTextureCurrent );
1064 QColor color = aDlg->GetColor(1);
1065 QColor edgecolor = aDlg->GetColor(2);
1066 QColor nodecolor = aDlg->GetColor(3);
1067 QColor backfacecolor = aDlg->GetColor(4);
1068 QColor color0D = aDlg->GetColor(5);
1069 QColor faces_orientation_color = aDlg->GetColor(6);
1072 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1074 SALOME_ListIteratorOfListIO It( selected );
1075 for( ; It.More(); It.Next()){
1076 Handle(SALOME_InteractiveObject) IObject = It.Value();
1077 if(IObject->hasEntry()){
1078 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1079 /* actor color and backface color */
1080 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1081 vtkFloatingPointType (color.green()) / 255.,
1082 vtkFloatingPointType (color.blue()) / 255.);
1083 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1084 vtkFloatingPointType (backfacecolor.green()) / 255.,
1085 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1088 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1089 vtkFloatingPointType (edgecolor.green()) / 255.,
1090 vtkFloatingPointType (edgecolor.blue()) / 255.);
1092 /* Shrink factor and size edges */
1093 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1094 anActor->SetLineWidth(aDlg->GetIntValue(1));
1096 /* Nodes color and size */
1097 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1098 vtkFloatingPointType (nodecolor.green()) / 255.,
1099 vtkFloatingPointType (nodecolor.blue()) / 255.);
1102 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1103 vtkFloatingPointType (color0D.green()) / 255.,
1104 vtkFloatingPointType (color0D.blue()) / 255.);
1105 anActor->Set0DSize(aDlg->GetIntValue(3));
1107 /* Faces orientation */
1108 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1109 vtkFloatingPointType(faces_orientation_color.greenF()),
1110 vtkFloatingPointType(faces_orientation_color.blueF())};
1111 anActor->SetFacesOrientationColor(c);
1112 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1113 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1115 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1116 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1117 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1118 if( aMarkerTypeNew != VTK::MT_USER )
1119 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1121 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1122 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1123 if( anIter != aMarkerMap.end() )
1124 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1127 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1128 if( !aGroupObject->_is_nil() )
1130 SMESH::ElementType anElementType = aGroupObject->GetType();
1132 switch( anElementType )
1134 case SMESH::NODE: aColor = nodecolor; break;
1135 case SMESH::EDGE: aColor = edgecolor; break;
1136 default: aColor = color; break;
1139 SALOMEDS::Color aGroupColor;
1140 aGroupColor.R = (float)aColor.red() / 255.0;
1141 aGroupColor.G = (float)aColor.green() / 255.0;
1142 aGroupColor.B = (float)aColor.blue() / 255.0;
1143 aGroupObject->SetColor( aGroupColor );
1148 SMESH::RepaintCurrentView();
1154 SALOME_ListIteratorOfListIO It( selected );
1155 for( ; It.More(); It.Next()){
1156 Handle(SALOME_InteractiveObject) IObject = It.Value();
1157 if(IObject->hasEntry()){
1158 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1159 switch(theCommandID){
1161 anActor->SetRepresentation(SMESH_Actor::eEdge);
1164 anActor->SetRepresentation(SMESH_Actor::eSurface);
1167 if(anActor->IsShrunk())
1168 anActor->UnShrink();
1170 anActor->SetShrink();
1173 anActor->SetRepresentation(SMESH_Actor::ePoint);
1176 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1177 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1180 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1181 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1187 SMESH::RepaintCurrentView();
1191 void Control( int theCommandID )
1193 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1194 SALOME_ListIO selected;
1196 aSel->selectedObjects( selected );
1198 if( !selected.IsEmpty() ){
1199 Handle(SALOME_InteractiveObject) anIO = selected.First();
1201 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1202 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1203 switch ( theCommandID ){
1205 aControl = SMESH_Actor::eLength;
1208 aControl = SMESH_Actor::eLength2D;
1211 aControl = SMESH_Actor::eFreeEdges;
1214 aControl = SMESH_Actor::eFreeBorders;
1217 aControl = SMESH_Actor::eMultiConnection;
1220 aControl = SMESH_Actor::eFreeNodes;
1223 aControl = SMESH_Actor::eMultiConnection2D;
1226 aControl = SMESH_Actor::eArea;
1229 aControl = SMESH_Actor::eTaper;
1232 aControl = SMESH_Actor::eAspectRatio;
1235 aControl = SMESH_Actor::eAspectRatio3D;
1238 aControl = SMESH_Actor::eMinimumAngle;
1241 aControl = SMESH_Actor::eWarping;
1244 aControl = SMESH_Actor::eSkew;
1247 aControl = SMESH_Actor::eVolume3D;
1250 aControl = SMESH_Actor::eFreeFaces;
1253 aControl = SMESH_Actor::eMaxElementLength2D;
1256 aControl = SMESH_Actor::eMaxElementLength3D;
1259 aControl = SMESH_Actor::eBareBorderVolume;
1262 aControl = SMESH_Actor::eBareBorderFace;
1265 aControl = SMESH_Actor::eOverConstrainedVolume;
1268 aControl = SMESH_Actor::eOverConstrainedFace;
1271 anActor->SetControlMode(aControl);
1272 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1273 SMESH::RepaintCurrentView();
1274 #ifndef DISABLE_PLOT2DVIEWER
1275 if(anActor->GetPlot2Histogram()) {
1276 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1277 QString functorName = functorToString( anActor->GetFunctor());
1278 QString aHistogramName("%1 : %2");
1279 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1280 aHistogram->setName(aHistogramName);
1281 aHistogram->setHorTitle(functorName);
1282 SMESH::ProcessIn2DViewers(anActor);
1291 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1292 MeshObjectType theType,
1293 const QString theInTypeName,
1294 QString & theOutTypeName)
1296 SMESH_TypeFilter aTypeFilter( theType );
1298 if( !theIO.IsNull() )
1300 entry = theIO->getEntry();
1301 LightApp_DataOwner owner( entry );
1302 if ( aTypeFilter.isOk( &owner )) {
1303 theOutTypeName = theInTypeName;
1311 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1313 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1314 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1316 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1317 CORBA::String_var anID = aSComp->GetID().c_str();
1318 if (!strcmp(anID.in(),theIO->getEntry()))
1324 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1325 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1326 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1327 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1328 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1336 QString CheckHomogeneousSelection()
1338 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1339 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1340 SALOME_ListIO selected;
1342 aSel->selectedObjects( selected );
1344 QString RefType = CheckTypeObject(selected.First());
1345 SALOME_ListIteratorOfListIO It(selected);
1346 for ( ; It.More(); It.Next())
1348 Handle(SALOME_InteractiveObject) IObject = It.Value();
1349 QString Type = CheckTypeObject(IObject);
1350 if (Type.compare(RefType) != 0)
1351 return "Heterogeneous Selection";
1358 void SMESHGUI::OnEditDelete()
1360 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1361 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1362 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1364 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1365 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1366 _PTR(GenericAttribute) anAttr;
1367 _PTR(AttributeIOR) anIOR;
1369 int objectCount = 0;
1371 QString aParentComponent = QString::null;
1372 Handle(SALOME_InteractiveObject) anIO;
1373 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1375 anIO = anIt.Value();
1376 QString cur = anIO->getComponentDataType();
1377 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1379 // check if object is reference
1380 _PTR(SObject) aRefSObj;
1381 aNameList.append("\n - ");
1382 if ( aSO->ReferencedObject( aRefSObj ) ) {
1383 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1384 aNameList.append( aRefName );
1385 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1388 aNameList.append(anIO->getName());
1392 if( aParentComponent.isNull() )
1393 aParentComponent = cur;
1394 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1395 aParentComponent = "";
1398 if ( objectCount == 0 )
1399 return; // No Valid Objects Selected
1401 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1402 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1403 QObject::tr("ERR_ERROR"),
1404 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1407 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1408 if (SUIT_MessageBox::warning
1409 (SMESHGUI::desktop(),
1410 QObject::tr("SMESH_WRN_WARNING"),
1411 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1412 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1413 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1416 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1417 SUIT_ViewManager* vm = anApp->activeViewManager();
1418 int nbSf = vm ? vm->getViewsCount() : 0;
1420 SALOME_ListIteratorOfListIO It(selected);
1422 aStudyBuilder->NewCommand(); // There is a transaction
1423 for( ; It.More(); It.Next()){ // loop on selected IO's
1424 Handle(SALOME_InteractiveObject) IObject = It.Value();
1425 if(IObject->hasEntry()) {
1426 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1428 // disable removal of "SMESH" component object
1429 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1431 if ( engineIOR() == anIOR->Value().c_str() )
1434 //Check the referenced object
1435 _PTR(SObject) aRefSObject;
1436 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1437 aSO = aRefSObject; // Delete main Object instead of reference
1439 // put the whole hierarchy of sub-objects of the selected SO into a list and
1440 // then treat them all starting from the deepest objects (at list back)
1442 std::list< _PTR(SObject) > listSO;
1443 listSO.push_back( aSO );
1444 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1445 for ( ; itSO != listSO.end(); ++itSO ) {
1446 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1447 for (it->InitEx(false); it->More(); it->Next())
1448 listSO.push_back( it->Value() );
1451 // treat SO's in the list starting from the back
1453 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1454 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1455 _PTR(SObject) SO = *ritSO;
1456 if ( !SO ) continue;
1457 std::string anEntry = SO->GetID();
1459 /** Erase graphical object **/
1460 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1461 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1462 for(int i = 0; i < nbSf; i++){
1463 SUIT_ViewWindow *sf = aViews[i];
1464 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1465 SMESH::RemoveActor(sf,anActor);
1470 /** Remove an object from data structures **/
1471 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1472 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1473 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1474 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1475 aMesh->RemoveGroup( aGroup );
1477 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1478 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1479 aMesh->RemoveSubMesh( aSubMesh );
1481 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1483 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1486 IObject = new SALOME_InteractiveObject
1487 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1488 QString objType = CheckTypeObject(IObject);
1489 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1490 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1491 aStudyBuilder->RemoveObjectWithChildren( SO );
1493 else {// default action: remove SObject from the study
1494 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1495 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1497 aStudyBuilder->RemoveObjectWithChildren( SO );
1501 } /* listSO back loop */
1502 } /* IObject->hasEntry() */
1504 aStudyBuilder->CommitCommand();
1506 /* Clear any previous selection */
1508 aSel->setSelectedObjects( l1 );
1510 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1515 SMESHGUI_EXPORT CAM_Module* createModule()
1517 return new SMESHGUI();
1521 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1523 //=============================================================================
1527 //=============================================================================
1528 SMESHGUI::SMESHGUI() :
1529 SalomeApp_Module( "SMESH" ),
1530 LightApp_Module( "SMESH" )
1532 if ( CORBA::is_nil( myComponentSMESH ) )
1534 CORBA::Boolean anIsEmbeddedMode;
1535 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1536 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1538 // 0019923: EDF 765 SMESH : default values of hypothesis
1539 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1540 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1541 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1542 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1543 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1546 myActiveDialogBox = 0;
1547 myFilterLibraryDlg = 0;
1551 myEventCallbackCommand = vtkCallbackCommand::New();
1552 myEventCallbackCommand->Delete();
1553 myEventCallbackCommand->SetClientData( this );
1554 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1557 SMESH::GetFilterManager();
1558 SMESH::GetPattern();
1559 SMESH::GetMeasurements();
1561 /* load resources for all available meshers */
1562 SMESH::InitAvailableHypotheses();
1565 //=============================================================================
1569 //=============================================================================
1570 SMESHGUI::~SMESHGUI()
1572 #ifdef WITHGENERICOBJ
1573 SMESH::GetFilterManager()->Destroy();
1574 SMESH::GetMeasurements()->Destroy();
1576 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1577 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1580 //=============================================================================
1584 //=============================================================================
1585 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1587 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1589 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1594 //=============================================================================
1598 //=============================================================================
1599 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1601 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1605 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1606 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1607 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1608 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1609 return autoUpdate && !exceeded;
1612 //=============================================================================
1616 //=============================================================================
1617 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1619 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1622 //=============================================================================
1626 //=============================================================================
1627 SMESHGUI* SMESHGUI::GetSMESHGUI()
1629 SMESHGUI* smeshMod = 0;
1630 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1633 CAM_Module* module = app->module( "Mesh" );
1634 smeshMod = dynamic_cast<SMESHGUI*>( module );
1637 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1639 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1642 _PTR(Study) aStudy = study->studyDS();
1644 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1653 Standard_EXPORT SMESHGUI* GetComponentGUI()
1655 return SMESHGUI::GetSMESHGUI();
1659 //=============================================================================
1663 //=============================================================================
1664 void SMESHGUI::SetState(int aState)
1669 //=============================================================================
1673 //=============================================================================
1674 void SMESHGUI::ResetState()
1679 //=============================================================================
1683 //=============================================================================
1684 void SMESHGUI::EmitSignalDeactivateDialog()
1686 emit SignalDeactivateActiveDialog();
1689 //=============================================================================
1693 //=============================================================================
1694 void SMESHGUI::EmitSignalStudyFrameChanged()
1696 emit SignalStudyFrameChanged();
1699 //=============================================================================
1703 //=============================================================================
1704 void SMESHGUI::EmitSignalCloseAllDialogs()
1706 emit SignalCloseAllDialogs();
1709 //=============================================================================
1713 //=============================================================================
1714 void SMESHGUI::EmitSignalVisibilityChanged()
1716 emit SignalVisibilityChanged();
1719 //=============================================================================
1723 //=============================================================================
1724 QDialog *SMESHGUI::GetActiveDialogBox()
1726 return myActiveDialogBox;
1729 //=============================================================================
1733 //=============================================================================
1734 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1736 myActiveDialogBox = (QDialog *) aDlg;
1740 //=============================================================================
1744 //=============================================================================
1745 SUIT_Desktop* SMESHGUI::desktop()
1747 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1749 return app->desktop();
1754 //=============================================================================
1758 //=============================================================================
1759 SalomeApp_Study* SMESHGUI::activeStudy()
1761 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1763 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1768 //=============================================================================
1772 //=============================================================================
1773 void SMESHGUI::Modified( bool theIsUpdateActions )
1775 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1776 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1777 appStudy->Modified();
1778 if( theIsUpdateActions )
1779 app->updateActions();
1784 //=============================================================================
1788 //=============================================================================
1789 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1791 /* Here the position is on the bottom right corner - 10 */
1792 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1794 SUIT_Desktop *PP = desktop();
1795 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1796 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1800 //=============================================================================
1804 //=============================================================================
1805 static int isStudyLocked(_PTR(Study) theStudy){
1806 return theStudy->GetProperties()->IsLocked();
1809 static bool checkLock(_PTR(Study) theStudy) {
1810 if (isStudyLocked(theStudy)) {
1811 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1812 QObject::tr("WRN_WARNING"),
1813 QObject::tr("WRN_STUDY_LOCKED") );
1819 //=======================================================================
1820 //function : CheckActiveStudyLocked
1822 //=======================================================================
1824 bool SMESHGUI::isActiveStudyLocked()
1826 _PTR(Study) aStudy = activeStudy()->studyDS();
1827 return checkLock( aStudy );
1830 //=============================================================================
1834 //=============================================================================
1835 bool SMESHGUI::OnGUIEvent( int theCommandID )
1837 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1841 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1842 SUIT_ResourceMgr* mgr = resourceMgr();
1846 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1847 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1850 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1851 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1853 //QAction* act = action( theCommandID );
1855 switch (theCommandID) {
1857 if(checkLock(aStudy)) break;
1865 if(checkLock(aStudy)) break;
1866 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1870 case 150: //MED FILE INFORMATION
1872 SALOME_ListIO selected;
1873 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1875 aSel->selectedObjects( selected );
1876 if( selected.Extent() )
1878 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1879 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1880 if ( !aMesh->_is_nil() )
1882 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1889 case 122: // EXPORT MED
1898 ::ExportMeshToFile(theCommandID);
1902 case 200: // SCALAR BAR
1904 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1905 SALOME_ListIO selected;
1907 aSel->selectedObjects( selected );
1909 if( selected.Extent() ) {
1910 Handle(SALOME_InteractiveObject) anIO = selected.First();
1911 if( anIO->hasEntry() ) {
1912 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1913 anActor->SetControlMode( SMESH_Actor::eNone );
1914 #ifndef DISABLE_PLOT2DVIEWER
1915 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
1924 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1929 // dump control distribution data to the text file
1930 ::SaveDistribution();
1936 // show/ distribution
1937 ::ShowDistribution();
1941 #ifndef DISABLE_PLOT2DVIEWER
1944 // plot distribution
1945 ::PlotDistribution();
1956 ::DisableAutoColor();
1959 case 1134: // Clipping
1960 case 1133: // Tranparency
1961 case 1132: // Colors / Size
1968 ::SetDisplayMode(theCommandID, myMarkerMap);
1971 //2D quadratic representation
1974 ::SetDisplayMode(theCommandID, myMarkerMap);
1978 case 216: // 0D elements
1981 case 219: // Volumes
1982 case 220: // All Entity
1983 ::SetDisplayEntity(theCommandID);
1986 case 221: // Orientation of faces
1988 LightApp_SelectionMgr* mgr = selectionMgr();
1989 SALOME_ListIO selected; mgr->selectedObjects( selected );
1991 SALOME_ListIteratorOfListIO it(selected);
1992 for( ; it.More(); it.Next()) {
1993 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1994 if(anIObject->hasEntry()) {
1995 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1996 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2005 if(checkLock(aStudy)) break;
2007 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2010 SMESH::UpdateView();
2012 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2013 SMESH::OnVisuException();
2015 catch (...) { // PAL16774 (Crash after display of many groups)
2016 SMESH::OnVisuException();
2020 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2021 aSel->selectedObjects( l );
2022 aSel->setSelectedObjects( l );
2027 case 301: // DISPLAY
2028 case 302: // DISPLAY ONLY
2030 SMESH::EDisplaing anAction;
2031 switch (theCommandID) {
2032 case 300: anAction = SMESH::eErase; break;
2033 case 301: anAction = SMESH::eDisplay; break;
2034 case 302: anAction = SMESH::eDisplayOnly; break;
2037 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2038 SALOME_ListIO sel_objects, to_process;
2040 aSel->selectedObjects( sel_objects );
2042 if( theCommandID==302 )
2044 MESSAGE("anAction = SMESH::eDisplayOnly");
2045 startOperation( myEraseAll );
2048 extractContainers( sel_objects, to_process );
2051 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2055 SALOME_ListIteratorOfListIO It( to_process );
2056 for ( ; It.More(); It.Next()) {
2058 Handle(SALOME_InteractiveObject) IOS = It.Value();
2059 if (IOS->hasEntry()) {
2061 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2062 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2063 break; // PAL16774 (Crash after display of many groups)
2065 if (anAction == SMESH::eDisplayOnly)
2067 MESSAGE("anAction = SMESH::eDisplayOnly");
2068 anAction = SMESH::eDisplay;
2074 // PAL13338 + PAL15161 -->
2075 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2076 MESSAGE("anAction = SMESH::eDisplayOnly");
2077 SMESH::UpdateView();
2078 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2080 // PAL13338 + PAL15161 <--
2082 catch (...) { // PAL16774 (Crash after display of many groups)
2083 SMESH::OnVisuException();
2086 if (anAction == SMESH::eErase) {
2087 MESSAGE("anAction == SMESH::eErase");
2089 aSel->setSelectedObjects( l1 );
2092 aSel->setSelectedObjects( to_process );
2099 if(checkLock(aStudy)) break;
2102 EmitSignalDeactivateDialog();
2104 ( new SMESHGUI_NodesDlg( this ) )->show();
2107 SUIT_MessageBox::warning(desktop(),
2108 tr("SMESH_WRN_WARNING"),
2109 tr("SMESH_WRN_VIEWER_VTK"));
2114 case 2151: // FILTER
2118 EmitSignalDeactivateDialog();
2119 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2124 case 701: // COMPUTE MESH
2125 case 711: // PRECOMPUTE MESH
2126 case 712: // EVALUATE MESH
2127 case 713: // MESH ORDER
2129 if (checkLock(aStudy)) break;
2130 startOperation( theCommandID );
2134 case 702: // Create mesh
2135 case 703: // Create sub-mesh
2136 case 704: // Edit mesh/sub-mesh
2137 startOperation( theCommandID );
2139 case 705: // copy mesh
2141 if (checkLock(aStudy)) break;
2142 EmitSignalDeactivateDialog();
2143 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2146 case 710: // Build compound mesh
2148 if (checkLock(aStudy)) break;
2149 EmitSignalDeactivateDialog();
2150 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2154 case 407: // DIAGONAL INVERSION
2155 case 408: // Delete diagonal
2159 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2160 tr( "NOT_A_VTK_VIEWER" ) );
2164 if ( checkLock( aStudy ) )
2167 /*Standard_Boolean aRes;
2168 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2169 if ( aMesh->_is_nil() )
2171 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2172 tr( "SMESH_BAD_SELECTION" ) );
2176 EmitSignalDeactivateDialog();
2177 if ( theCommandID == 407 )
2178 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2180 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2183 case 409: // Change orientation
2184 case 410: // Union of triangles
2185 case 411: // Cutting of quadrangles
2186 case 419: // Splitting volumes into tetrahedra
2190 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2191 tr( "NOT_A_VTK_VIEWER" ) );
2195 if ( checkLock( aStudy ) )
2198 EmitSignalDeactivateDialog();
2199 SMESHGUI_MultiEditDlg* aDlg = NULL;
2200 if ( theCommandID == 409 )
2201 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2202 else if ( theCommandID == 410 )
2203 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2204 else if ( theCommandID == 419 )
2205 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2207 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2212 case 412: // Smoothing
2214 if(checkLock(aStudy)) break;
2216 EmitSignalDeactivateDialog();
2217 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2220 SUIT_MessageBox::warning(desktop(),
2221 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2225 case 413: // Extrusion
2227 if (checkLock(aStudy)) break;
2229 EmitSignalDeactivateDialog();
2230 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2232 SUIT_MessageBox::warning(desktop(),
2233 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2237 case 414: // Revolution
2239 if(checkLock(aStudy)) break;
2241 EmitSignalDeactivateDialog();
2242 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2245 SUIT_MessageBox::warning(desktop(),
2246 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2250 case 415: // Pattern mapping
2252 if ( checkLock( aStudy ) )
2256 EmitSignalDeactivateDialog();
2257 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2260 SUIT_MessageBox::warning(desktop(),
2261 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2265 case 416: // Extrusion along a path
2267 if (checkLock(aStudy)) break;
2269 EmitSignalDeactivateDialog();
2270 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2272 SUIT_MessageBox::warning(desktop(),
2273 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2277 case 417: // Convert mesh to quadratic
2279 startOperation( 417 );
2280 /* if (checkLock(aStudy)) break;
2282 EmitSignalDeactivateDialog();
2283 new SMESHGUI_ConvToQuadDlg();
2285 SUIT_MessageBox::warning(desktop(),
2286 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2290 case 418: // create 2D mesh from 3D
2292 startOperation( 418 );
2295 case 806: // CREATE GEO GROUP
2297 startOperation( 806 );
2300 case 801: // CREATE GROUP
2304 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2305 tr( "NOT_A_VTK_VIEWER" ) );
2309 if(checkLock(aStudy)) break;
2310 EmitSignalDeactivateDialog();
2311 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2313 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2314 SALOME_ListIO selected;
2316 aSel->selectedObjects( selected );
2318 int nbSel = selected.Extent();
2320 // check if mesh is selected
2321 aMesh = SMESH::GetMeshByIO( selected.First() );
2323 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2328 case 802: // CONSTRUCT GROUP
2332 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2333 tr( "NOT_A_VTK_VIEWER" ) );
2337 if(checkLock(aStudy)) break;
2338 EmitSignalDeactivateDialog();
2340 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2341 SALOME_ListIO selected;
2343 aSel->selectedObjects( selected );
2345 int nbSel = selected.Extent();
2347 // check if submesh is selected
2348 Handle(SALOME_InteractiveObject) IObject = selected.First();
2349 if (IObject->hasEntry()) {
2350 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2352 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2353 if (!aSubMesh->_is_nil()) {
2355 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2356 // get submesh elements list by types
2357 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2358 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2359 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2360 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2361 // create group for each type o elements
2362 QString aName = IObject->getName();
2363 if (aNodes->length() > 0) {
2364 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2365 aGroup->Add(aNodes.inout());
2367 if (aEdges->length() > 0) {
2368 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2369 aGroup->Add(aEdges.inout());
2371 if (aFaces->length() > 0) {
2372 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2373 aGroup->Add(aFaces.inout());
2375 if (aVolumes->length() > 0) {
2376 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2377 aGroup->Add(aVolumes.inout());
2382 catch(const SALOME::SALOME_Exception & S_ex){
2383 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2390 SUIT_MessageBox::warning(desktop(),
2391 tr("SMESH_WRN_WARNING"),
2392 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2397 case 803: // EDIT GROUP
2401 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2402 tr( "NOT_A_VTK_VIEWER" ) );
2406 if(checkLock(aStudy)) break;
2407 EmitSignalDeactivateDialog();
2409 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2410 SALOME_ListIO selected;
2412 aSel->selectedObjects( selected );
2414 SALOME_ListIteratorOfListIO It (selected);
2415 int nbSelectedGroups = 0;
2416 for ( ; It.More(); It.Next() )
2418 SMESH::SMESH_GroupBase_var aGroup =
2419 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2420 if (!aGroup->_is_nil()) {
2422 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2426 if (nbSelectedGroups == 0)
2428 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2434 case 804: // Add elements to group
2436 if(checkLock(aStudy)) break;
2437 if (myState == 800) {
2438 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2439 if (aDlg) aDlg->onAdd();
2444 case 805: // Remove elements from group
2446 if(checkLock(aStudy)) break;
2447 if (myState == 800) {
2448 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2449 if (aDlg) aDlg->onRemove();
2454 case 815: // Edit GEOM GROUP as standalone
2458 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2459 tr( "NOT_A_VTK_VIEWER" ) );
2463 if(checkLock(aStudy)) break;
2464 EmitSignalDeactivateDialog();
2466 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2467 SALOME_ListIO selected;
2469 aSel->selectedObjects( selected );
2471 SALOME_ListIteratorOfListIO It (selected);
2472 for ( ; It.More(); It.Next() )
2474 SMESH::SMESH_GroupOnGeom_var aGroup =
2475 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2476 if (!aGroup->_is_nil()) {
2477 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2484 case 810: // Union Groups
2485 case 811: // Intersect groups
2486 case 812: // Cut groups
2490 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2491 tr( "NOT_A_VTK_VIEWER" ) );
2495 if ( checkLock( aStudy ) )
2498 EmitSignalDeactivateDialog();
2500 SMESHGUI_GroupOpDlg* aDlg = 0;
2501 if ( theCommandID == 810 )
2502 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2503 else if ( theCommandID == 811 )
2504 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2506 aDlg = new SMESHGUI_CutGroupsDlg( this );
2513 case 814: // Create groups of entities from existing groups of superior dimensions
2515 if ( checkLock( aStudy ) )
2518 EmitSignalDeactivateDialog();
2519 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2525 case 813: // Delete groups with their contents
2529 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2530 tr( "NOT_A_VTK_VIEWER" ) );
2534 if ( checkLock( aStudy ) )
2537 EmitSignalDeactivateDialog();
2539 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2543 case 900: // MESH INFOS
2544 case 903: // WHAT IS
2546 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2547 EmitSignalDeactivateDialog();
2548 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2549 SALOME_ListIO selected;
2551 aSel->selectedObjects( selected );
2553 if ( selected.Extent() > 1 ) { // a dlg for each IO
2554 SALOME_ListIteratorOfListIO It( selected );
2555 for ( ; It.More(); It.Next() ) {
2556 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2557 dlg->showInfo( It.Value() );
2562 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2568 case 902: // STANDARD MESH INFOS
2570 EmitSignalDeactivateDialog();
2571 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2572 SALOME_ListIO selected;
2574 aSel->selectedObjects( selected );
2576 if ( selected.Extent() > 1 ) { // a dlg for each IO
2578 SALOME_ListIteratorOfListIO It (selected);
2579 for ( ; It.More(); It.Next() ) {
2581 IOs.Append( It.Value() );
2582 aSel->setSelectedObjects( IOs );
2583 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2585 // restore selection
2586 aSel->setSelectedObjects( selected );
2589 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2592 case 903: // WHAT IS
2594 EmitSignalDeactivateDialog();
2595 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2600 case 904: // FIND ELEM
2602 startOperation( theCommandID );
2606 case 1100: // EDIT HYPOTHESIS
2608 if(checkLock(aStudy)) break;
2610 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2611 SALOME_ListIO selected;
2613 aSel->selectedObjects( selected );
2615 int nbSel = selected.Extent();
2618 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2619 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2621 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2622 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2623 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2624 if ( !aHypothesis->_is_nil() )
2627 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2628 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2630 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2641 case 1101: // RENAME
2643 if ( checkLock( aStudy ) )
2646 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2647 SALOME_ListIO selected;
2649 aSel->selectedObjects( selected );
2651 bool isAny = false; // is there any appropriate object selected
2653 SALOME_ListIteratorOfListIO It( selected );
2654 for ( ; It.More(); It.Next() )
2656 Handle(SALOME_InteractiveObject) IObject = It.Value();
2657 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2658 _PTR(GenericAttribute) anAttr;
2659 _PTR(AttributeName) aName;
2662 if ( obj->FindAttribute(anAttr, "AttributeName") )
2665 QString newName = QString(aName->Value().c_str());
2667 // check type to prevent renaming of inappropriate objects
2668 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2669 if (aType == MESH || aType == GROUP ||
2670 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2671 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2672 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2673 aType == HYPOTHESIS || aType == ALGORITHM)
2676 newName = LightApp_NameDlg::getName(desktop(), newName);
2677 if ( !newName.isEmpty() )
2679 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2681 // update name of group object and its actor
2682 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2683 if( !aGroupObject->_is_nil() )
2685 aGroupObject->SetName( newName.toLatin1().data() );
2686 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2687 anActor->setName( newName.toLatin1().data() );
2698 SUIT_MessageBox::warning(desktop(),
2699 QObject::tr("SMESH_WRN_WARNING"),
2700 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2705 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2707 if(checkLock(aStudy)) break;
2708 SUIT_OverrideCursor wc;
2710 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2711 SALOME_ListIO selected;
2713 aSel->selectedObjects( selected, QString::null, false );
2715 SALOME_ListIteratorOfListIO It(selected);
2716 for (int i = 0; It.More(); It.Next(), i++) {
2717 Handle(SALOME_InteractiveObject) IObject = It.Value();
2718 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2721 aSel->setSelectedObjects( l1 );
2726 case 4009: // ELEM0D
2727 case 4010: // GEOM::EDGE
2728 case 4021: // TRIANGLE
2730 case 4023: // POLYGON
2734 if(checkLock(aStudy)) break;
2736 EmitSignalDeactivateDialog();
2737 SMDSAbs_ElementType type = SMDSAbs_Edge;
2739 switch (theCommandID) {
2740 case 4009: // ELEM0D
2741 type = SMDSAbs_0DElement; nbNodes = 1; break;
2742 case 4021: // TRIANGLE
2743 type = SMDSAbs_Face; nbNodes = 3; break;
2745 type = SMDSAbs_Face; nbNodes = 4; break;
2747 type = SMDSAbs_Volume; nbNodes = 4; break;
2748 case 4023: // POLYGON
2749 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2751 type = SMDSAbs_Volume; nbNodes = 8; break;
2752 case 4033: // POLYHEDRE
2753 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2756 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2759 SUIT_MessageBox::warning(desktop(),
2760 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2764 case 4033: // POLYHEDRON
2766 if(checkLock(aStudy)) break;
2768 EmitSignalDeactivateDialog();
2769 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2772 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2773 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2777 case 4034: // QUADRATIC EDGE
2778 case 4035: // QUADRATIC TRIANGLE
2779 case 4036: // QUADRATIC QUADRANGLE
2780 case 4037: // QUADRATIC TETRAHEDRON
2781 case 4038: // QUADRATIC PYRAMID
2782 case 4039: // QUADRATIC PENTAHEDRON
2783 case 4040: // QUADRATIC HEXAHEDRON
2785 if(checkLock(aStudy)) break;
2787 EmitSignalDeactivateDialog();
2790 switch (theCommandID) {
2792 type = QUAD_EDGE; break;
2794 type = QUAD_TRIANGLE; break;
2796 type = QUAD_QUADRANGLE; break;
2798 type = QUAD_TETRAHEDRON; break;
2800 type = QUAD_PYRAMID; break;
2802 type = QUAD_PENTAHEDRON; break;
2804 type = QUAD_HEXAHEDRON;
2808 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2811 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2812 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2816 case 4041: // REMOVES NODES
2818 if(checkLock(aStudy)) break;
2820 EmitSignalDeactivateDialog();
2821 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2824 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2825 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2829 case 4042: // REMOVES ELEMENTS
2831 if(checkLock(aStudy)) break;
2833 EmitSignalDeactivateDialog();
2834 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2838 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2839 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2843 case 4043: { // CLEAR_MESH
2845 if(checkLock(aStudy)) break;
2847 SALOME_ListIO selected;
2848 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2849 aSel->selectedObjects( selected );
2851 SUIT_OverrideCursor wc;
2852 SALOME_ListIteratorOfListIO It (selected);
2853 for ( ; It.More(); It.Next() )
2855 Handle(SALOME_InteractiveObject) IOS = It.Value();
2856 SMESH::SMESH_Mesh_var aMesh =
2857 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2858 if ( aMesh->_is_nil()) continue;
2860 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2862 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2863 SMESH::ModifiedMesh( aMeshSObj, false, true);
2864 // hide groups and submeshes
2865 _PTR(ChildIterator) anIter =
2866 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2867 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2869 _PTR(SObject) so = anIter->Value();
2870 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2873 catch (const SALOME::SALOME_Exception& S_ex){
2875 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2879 SMESH::UpdateView();
2883 case 4044: // REMOVE ORPHAN NODES
2885 if(checkLock(aStudy)) break;
2886 SALOME_ListIO selected;
2887 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2888 aSel->selectedObjects( selected );
2889 if ( selected.Extent() == 1 ) {
2890 Handle(SALOME_InteractiveObject) anIO = selected.First();
2891 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2892 if ( !aMesh->_is_nil() ) {
2893 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2894 tr( "SMESH_WARNING" ),
2895 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2896 SUIT_MessageBox::Yes |
2897 SUIT_MessageBox::No,
2898 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2901 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2902 int removed = aMeshEditor->RemoveOrphanNodes();
2903 SUIT_MessageBox::information(SMESHGUI::desktop(),
2904 tr("SMESH_INFORMATION"),
2905 tr("NB_NODES_REMOVED").arg(removed));
2906 if ( removed > 0 ) {
2907 SMESH::UpdateView();
2908 SMESHGUI::Modified();
2911 catch (const SALOME::SALOME_Exception& S_ex) {
2912 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2921 case 4051: // RENUMBERING NODES
2923 if(checkLock(aStudy)) break;
2925 EmitSignalDeactivateDialog();
2926 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2930 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2931 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2935 case 4052: // RENUMBERING ELEMENTS
2937 if(checkLock(aStudy)) break;
2939 EmitSignalDeactivateDialog();
2940 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2944 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2945 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2949 case 4061: // TRANSLATION
2951 if(checkLock(aStudy)) break;
2953 EmitSignalDeactivateDialog();
2954 ( new SMESHGUI_TranslationDlg( this ) )->show();
2957 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2958 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2962 case 4062: // ROTATION
2964 if(checkLock(aStudy)) break;
2966 EmitSignalDeactivateDialog();
2967 ( new SMESHGUI_RotationDlg( this ) )->show();
2970 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2971 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2975 case 4063: // SYMMETRY
2977 if(checkLock(aStudy)) break;
2979 EmitSignalDeactivateDialog();
2980 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2983 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2984 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2988 case 4064: // SEWING
2990 if(checkLock(aStudy)) break;
2992 EmitSignalDeactivateDialog();
2993 ( new SMESHGUI_SewingDlg( this ) )->show();
2996 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2997 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3001 case 4065: // MERGE NODES
3003 if(checkLock(aStudy)) break;
3005 EmitSignalDeactivateDialog();
3006 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3009 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3010 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3014 case 4066: // MERGE EQUAL ELEMENTS
3016 if (checkLock(aStudy)) break;
3018 EmitSignalDeactivateDialog();
3019 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3021 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3022 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3027 case 4067: // MAKE MESH PASS THROUGH POINT
3028 startOperation( 4067 );
3033 if(checkLock(aStudy)) break;
3035 EmitSignalDeactivateDialog();
3036 ( new SMESHGUI_ScaleDlg( this ) )->show();
3039 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3045 case 4069: // DUPLICATE NODES
3047 if(checkLock(aStudy)) break;
3049 EmitSignalDeactivateDialog();
3050 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3053 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3059 case 5105: // Library of selection filters
3061 static QList<int> aTypes;
3062 if ( aTypes.isEmpty() )
3064 aTypes.append( SMESH::NODE );
3065 aTypes.append( SMESH::EDGE );
3066 aTypes.append( SMESH::FACE );
3067 aTypes.append( SMESH::VOLUME );
3069 if (!myFilterLibraryDlg)
3070 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3071 else if (myFilterLibraryDlg->isHidden())
3072 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3073 myFilterLibraryDlg->raise();
3077 case 6017: // CONTROLS
3101 LightApp_SelectionMgr* mgr = selectionMgr();
3102 SALOME_ListIO selected; mgr->selectedObjects( selected );
3104 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3105 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3107 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3108 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3109 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3110 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3111 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3112 ::Control( theCommandID );
3117 SUIT_MessageBox::warning(desktop(),
3118 tr( "SMESH_WRN_WARNING" ),
3119 tr( "SMESH_BAD_SELECTION" ) );
3123 SUIT_MessageBox::warning(desktop(),
3124 tr( "SMESH_WRN_WARNING" ),
3125 tr( "NOT_A_VTK_VIEWER" ) );
3130 LightApp_SelectionMgr* mgr = selectionMgr();
3131 SALOME_ListIO selected; mgr->selectedObjects( selected );
3133 SALOME_ListIteratorOfListIO it(selected);
3134 for( ; it.More(); it.Next()) {
3135 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3136 if(anIObject->hasEntry()) {
3137 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3138 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3146 LightApp_SelectionMgr* mgr = selectionMgr();
3147 SALOME_ListIO selected; mgr->selectedObjects( selected );
3149 SALOME_ListIteratorOfListIO it(selected);
3150 for( ; it.More(); it.Next()) {
3151 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3152 if(anIObject->hasEntry())
3153 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3154 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3162 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3163 EmitSignalDeactivateDialog();
3164 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3170 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3171 //updateObjBrowser();
3175 //=============================================================================
3179 //=============================================================================
3180 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3185 //=============================================================================
3189 //=============================================================================
3190 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3195 //=============================================================================
3199 //=============================================================================
3200 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3205 //=============================================================================
3206 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3207 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3209 //=============================================================================
3210 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3211 SUIT_ViewWindow* wnd )
3213 if(theIO->hasEntry()){
3214 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3215 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3219 //=======================================================================
3220 // function : createSMESHAction
3222 //=======================================================================
3223 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3224 const int key, const bool toggle, const QString& shortcutAction )
3227 QWidget* parent = application()->desktop();
3228 SUIT_ResourceMgr* resMgr = resourceMgr();
3230 if ( !icon_id.isEmpty() )
3231 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3233 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3234 if ( !pix.isNull() )
3235 icon = QIcon( pix );
3237 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3238 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3239 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3241 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3242 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3245 //=======================================================================
3246 // function : createPopupItem
3248 //=======================================================================
3249 void SMESHGUI::createPopupItem( const int id,
3250 const QString& clients,
3251 const QString& types,
3252 const QString& theRule,
3257 parentId = popupMgr()->actionId( action( pId ) );
3259 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3260 popupMgr()->insert( action( id ), parentId, 0 );
3262 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3263 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3264 QString rule = "(%1) and (%2) and (%3)";
3265 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3266 if( clients.isEmpty() )
3267 rule = rule.arg( QString( "true" ) );
3269 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3270 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3273 bool cont = myRules.contains( id );
3275 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3277 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3278 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3281 //=======================================================================
3282 // function : initialize
3284 //=======================================================================
3285 void SMESHGUI::initialize( CAM_Application* app )
3287 SalomeApp_Module::initialize( app );
3289 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3291 /* Automatic Update flag */
3292 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3294 // ----- create actions --------------
3296 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3297 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3298 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3299 createSMESHAction( 114, "NUM" );
3300 createSMESHAction( 121, "DAT" );
3301 createSMESHAction( 122, "MED" );
3302 createSMESHAction( 123, "UNV" );
3303 createSMESHAction( 140, "STL" );
3304 createSMESHAction( 124, "EXPORT_DAT" );
3305 createSMESHAction( 125, "EXPORT_MED" );
3306 createSMESHAction( 126, "EXPORT_UNV" );
3307 createSMESHAction( 141, "EXPORT_STL" );
3308 createSMESHAction( 150, "FILE_INFO" );
3309 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3310 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3311 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3312 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3313 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3314 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3315 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3316 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3317 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3318 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3319 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3320 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3321 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3322 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3323 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3324 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3325 createSMESHAction( 804, "ADD" );
3326 createSMESHAction( 805, "REMOVE" );
3327 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3328 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3329 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3330 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3331 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3332 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3333 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3334 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3335 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3336 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3337 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3338 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3339 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3340 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3341 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3342 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3343 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3344 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3345 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3346 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3347 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3348 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3349 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3350 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3351 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3352 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3353 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3354 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3355 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3356 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3357 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3358 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3359 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3360 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3361 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3362 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3363 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3364 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3365 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3366 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3367 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3368 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3369 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3370 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3371 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3372 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3373 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3374 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3375 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3376 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3377 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3378 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3379 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3380 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3381 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3382 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3383 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3384 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3385 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3386 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3387 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3388 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3389 createSMESHAction( 415, "MAP", "ICON_MAP" );
3390 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3391 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3392 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3393 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3394 createSMESHAction( 200, "RESET" );
3395 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3396 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3397 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3398 #ifndef DISABLE_PLOT2DVIEWER
3399 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3401 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3402 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3403 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3404 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3405 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3406 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3407 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3408 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3409 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3410 createSMESHAction( 220, "ALL" );
3411 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3413 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3414 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3416 createSMESHAction( 1100, "EDIT_HYPO" );
3417 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3418 createSMESHAction( 1102, "UNASSIGN" );
3419 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3420 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3421 createSMESHAction( 1131, "DISPMODE" );
3422 createSMESHAction( 1132, "COLORS" );
3423 createSMESHAction( 1133, "TRANSP" );
3424 createSMESHAction( 1134, "CLIP" );
3425 createSMESHAction( 1135, "DISP_ENT" );
3426 createSMESHAction( 1136, "AUTO_COLOR" );
3427 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3428 createSMESHAction( 2000, "CTRL" );
3430 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3431 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3433 createSMESHAction( 300, "ERASE" );
3434 createSMESHAction( 301, "DISPLAY" );
3435 createSMESHAction( 302, "DISPLAY_ONLY" );
3436 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3437 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3438 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3439 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3440 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3441 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3442 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3443 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3445 // ----- create menu --------------
3446 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3447 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3448 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3449 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3450 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3451 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3452 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3453 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3455 createMenu( separator(), fileId );
3457 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3458 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3459 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3460 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3461 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3462 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3463 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3464 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3465 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3466 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3468 createMenu( 111, importId, -1 );
3469 createMenu( 112, importId, -1 );
3470 createMenu( 113, importId, -1 );
3472 createMenu( 121, exportId, -1 );
3473 createMenu( 122, exportId, -1 );
3474 createMenu( 123, exportId, -1 );
3475 createMenu( 140, exportId, -1 ); // export to stl STL
3477 createMenu( separator(), fileId, 10 );
3479 createMenu( 33, editId, -1 );
3481 createMenu( 5105, toolsId, -1 );
3483 createMenu( 702, meshId, -1 ); // "Mesh" menu
3484 createMenu( 703, meshId, -1 );
3485 createMenu( 704, meshId, -1 );
3486 createMenu( 710, meshId, -1 );
3487 createMenu( 705, meshId, -1 );
3488 createMenu( separator(), meshId, -1 );
3489 createMenu( 701, meshId, -1 );
3490 createMenu( 711, meshId, -1 );
3491 createMenu( 712, meshId, -1 );
3492 createMenu( 713, meshId, -1 );
3493 createMenu( separator(), meshId, -1 );
3494 createMenu( 801, meshId, -1 );
3495 createMenu( 806, meshId, -1 );
3496 createMenu( 802, meshId, -1 );
3497 createMenu( 803, meshId, -1 );
3498 createMenu( 815, meshId, -1 );
3499 createMenu( separator(), meshId, -1 );
3500 createMenu( 810, meshId, -1 );
3501 createMenu( 811, meshId, -1 );
3502 createMenu( 812, meshId, -1 );
3503 createMenu( separator(), meshId, -1 );
3504 createMenu( 814, meshId, -1 );
3505 createMenu( separator(), meshId, -1 );
3506 createMenu( 900, meshId, -1 );
3507 //createMenu( 902, meshId, -1 );
3508 createMenu( 903, meshId, -1 );
3509 createMenu( 904, meshId, -1 );
3510 createMenu( separator(), meshId, -1 );
3512 createMenu( 6005, nodeId, -1 );
3513 createMenu( 6002, edgeId, -1 );
3514 createMenu( 6003, edgeId, -1 );
3515 createMenu( 6001, edgeId, -1 );
3516 createMenu( 6004, edgeId, -1 );
3517 createMenu( 6021, faceId, -1 );
3518 createMenu( 6025, faceId, -1 );
3519 createMenu( 6027, faceId, -1 );
3520 createMenu( 6018, faceId, -1 );
3521 createMenu( 6019, faceId, -1 );
3522 createMenu( 6011, faceId, -1 );
3523 createMenu( 6012, faceId, -1 );
3524 createMenu( 6013, faceId, -1 );
3525 createMenu( 6014, faceId, -1 );
3526 createMenu( 6015, faceId, -1 );
3527 createMenu( 6016, faceId, -1 );
3528 createMenu( 6022, faceId, -1 );
3529 createMenu( 6017, volumeId, -1 );
3530 createMenu( 6009, volumeId, -1 );
3531 createMenu( 6023, volumeId, -1 );
3532 createMenu( 6024, volumeId, -1 );
3533 createMenu( 6026, volumeId, -1 );
3535 createMenu( 4000, addId, -1 );
3536 createMenu( 4009, addId, -1 );
3537 createMenu( 4010, addId, -1 );
3538 createMenu( 4021, addId, -1 );
3539 createMenu( 4022, addId, -1 );
3540 createMenu( 4023, addId, -1 );
3541 createMenu( 4031, addId, -1 );
3542 createMenu( 4032, addId, -1 );
3543 createMenu( 4033, addId, -1 );
3544 createMenu( separator(), addId, -1 );
3545 createMenu( 4034, addId, -1 );
3546 createMenu( 4035, addId, -1 );
3547 createMenu( 4036, addId, -1 );
3548 createMenu( 4037, addId, -1 );
3549 createMenu( 4038, addId, -1 );
3550 createMenu( 4039, addId, -1 );
3551 createMenu( 4040, addId, -1 );
3553 createMenu( 4041, removeId, -1 );
3554 createMenu( 4042, removeId, -1 );
3555 createMenu( 4044, removeId, -1 );
3556 createMenu( separator(), removeId, -1 );
3557 createMenu( 813, removeId, -1 );
3558 createMenu( separator(), removeId, -1 );
3559 createMenu( 4043, removeId, -1 );
3561 createMenu( 4051, renumId, -1 );
3562 createMenu( 4052, renumId, -1 );
3564 createMenu( 4061, transfId, -1 );
3565 createMenu( 4062, transfId, -1 );
3566 createMenu( 4063, transfId, -1 );
3567 createMenu( 4064, transfId, -1 );
3568 createMenu( 4065, transfId, -1 );
3569 createMenu( 4066, transfId, -1 );
3570 createMenu( 4068, transfId, -1 );
3571 createMenu( 4069, transfId, -1 );
3573 createMenu( 4067,modifyId, -1 );
3574 createMenu( 407, modifyId, -1 );
3575 createMenu( 408, modifyId, -1 );
3576 createMenu( 409, modifyId, -1 );
3577 createMenu( 410, modifyId, -1 );
3578 createMenu( 411, modifyId, -1 );
3579 createMenu( 419, modifyId, -1 );
3580 createMenu( 412, modifyId, -1 );
3581 createMenu( 413, modifyId, -1 );
3582 createMenu( 416, modifyId, -1 );
3583 createMenu( 414, modifyId, -1 );
3584 createMenu( 415, modifyId, -1 );
3585 createMenu( 417, modifyId, -1 );
3586 createMenu( 418, modifyId, -1 );
3588 createMenu( 501, measureId, -1 );
3589 createMenu( 502, measureId, -1 );
3590 createMenu( 214, viewId, -1 );
3592 // ----- create toolbars --------------
3593 int meshTb = createTool( tr( "TB_MESH" ) ),
3594 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3595 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3596 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3597 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3599 createTool( 702, meshTb );
3600 createTool( 703, meshTb );
3601 createTool( 704, meshTb );
3602 createTool( 710, meshTb );
3603 createTool( 705, meshTb );
3604 createTool( separator(), meshTb );
3605 createTool( 701, meshTb );
3606 createTool( 711, meshTb );
3607 createTool( 712, meshTb );
3608 createTool( 713, meshTb );
3609 createTool( separator(), meshTb );
3610 createTool( 801, meshTb );
3611 createTool( 806, meshTb );
3612 createTool( 802, meshTb );
3613 createTool( 803, meshTb );
3614 //createTool( 815, meshTb );
3615 createTool( separator(), meshTb );
3616 createTool( 900, meshTb );
3617 //createTool( 902, meshTb );
3618 createTool( 903, meshTb );
3619 createTool( 904, meshTb );
3620 createTool( separator(), meshTb );
3622 createTool( 6005, ctrlTb );
3623 createTool( separator(), ctrlTb );
3624 createTool( 6002, ctrlTb );
3625 createTool( 6003, ctrlTb );
3626 createTool( 6001, ctrlTb );
3627 createTool( 6004, ctrlTb );
3628 createTool( separator(), ctrlTb );
3629 createTool( 6021, ctrlTb );
3630 createTool( 6025, ctrlTb );
3631 createTool( 6027, ctrlTb );
3632 createTool( 6018, ctrlTb );
3633 createTool( 6019, ctrlTb );
3634 createTool( 6011, ctrlTb );
3635 createTool( 6012, ctrlTb );
3636 createTool( 6013, ctrlTb );
3637 createTool( 6014, ctrlTb );
3638 createTool( 6015, ctrlTb );
3639 createTool( 6016, ctrlTb );
3640 createTool( 6022, ctrlTb );
3641 createTool( separator(), ctrlTb );
3642 createTool( 6017, ctrlTb );
3643 createTool( 6009, ctrlTb );
3644 createTool( 6023, ctrlTb );
3645 createTool( 6024, ctrlTb );
3646 createTool( 6026, ctrlTb );
3647 createTool( separator(), ctrlTb );
3649 createTool( 4000, addRemTb );
3650 createTool( 4009, addRemTb );
3651 createTool( 4010, addRemTb );
3652 createTool( 4021, addRemTb );
3653 createTool( 4022, addRemTb );
3654 createTool( 4023, addRemTb );
3655 createTool( 4031, addRemTb );
3656 createTool( 4032, addRemTb );
3657 createTool( 4033, addRemTb );
3658 createTool( separator(), addRemTb );
3659 createTool( 4034, addRemTb );
3660 createTool( 4035, addRemTb );
3661 createTool( 4036, addRemTb );
3662 createTool( 4037, addRemTb );
3663 createTool( 4038, addRemTb );
3664 createTool( 4039, addRemTb );
3665 createTool( 4040, addRemTb );
3666 createTool( separator(), addRemTb );
3667 createTool( 4041, addRemTb );
3668 createTool( 4042, addRemTb );
3669 createTool( 4044, addRemTb );
3670 createTool( 4043, addRemTb );
3671 createTool( separator(), addRemTb );
3672 createTool( 4051, addRemTb );
3673 createTool( 4052, addRemTb );
3674 createTool( separator(), addRemTb );
3675 createTool( 4061, addRemTb );
3676 createTool( 4062, addRemTb );
3677 createTool( 4063, addRemTb );
3678 createTool( 4064, addRemTb );
3679 createTool( 4065, addRemTb );
3680 createTool( 4066, addRemTb );
3681 createTool( 4068, addRemTb );
3682 createTool( 4069, addRemTb );
3683 createTool( separator(), addRemTb );
3685 createTool( 4067,modifyTb );
3686 createTool( 407, modifyTb );
3687 createTool( 408, modifyTb );
3688 createTool( 409, modifyTb );
3689 createTool( 410, modifyTb );
3690 createTool( 411, modifyTb );
3691 createTool( 419, modifyTb );
3692 createTool( 412, modifyTb );
3693 createTool( 413, modifyTb );
3694 createTool( 416, modifyTb );
3695 createTool( 414, modifyTb );
3696 createTool( 415, modifyTb );
3697 createTool( 417, modifyTb );
3698 createTool( 418, modifyTb );
3700 createTool( 214, dispModeTb );
3702 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3703 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3706 QString OB = "'ObjectBrowser'",
3707 View = "'" + SVTK_Viewer::Type() + "'",
3709 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3710 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3711 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3712 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3713 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3714 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3715 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3716 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3717 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3718 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3719 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3721 mesh_group = mesh + " " + subMesh + " " + group,
3722 hyp_alg = hypo + " " + algo;
3724 // popup for object browser
3726 isInvisible("not( isVisible )"),
3727 isEmpty("numberOfNodes = 0"),
3728 isNotEmpty("numberOfNodes <> 0"),
3730 // has nodes, edges, etc in VISIBLE! actor
3731 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3732 hasElems("(count( elemTypes ) > 0)"),
3733 hasDifferentElems("(count( elemTypes ) > 1)"),
3734 hasElems0d("({'Elem0d'} in elemTypes)"),
3735 hasEdges("({'Edge'} in elemTypes)"),
3736 hasFaces("({'Face'} in elemTypes)"),
3737 hasVolumes("({'Volume'} in elemTypes)");
3739 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3740 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3741 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3742 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3743 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3744 createPopupItem( 803, OB, group ); // EDIT_GROUP
3745 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3747 popupMgr()->insert( separator(), -1, 0 );
3748 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3749 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3750 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3751 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3752 createPopupItem( 214, OB, mesh_group ); // UPDATE
3753 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3754 //createPopupItem( 902, OB, mesh ); // STD_INFO
3755 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3756 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3757 popupMgr()->insert( separator(), -1, 0 );
3758 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3759 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3760 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3761 popupMgr()->insert( separator(), -1, 0 );
3762 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3763 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3764 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3765 popupMgr()->insert( separator(), -1, 0 );
3766 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3767 popupMgr()->insert( separator(), -1, 0 );
3768 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3769 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3770 popupMgr()->insert( separator(), -1, 0 );
3772 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3773 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3775 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3776 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3777 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3778 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3779 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3780 popupMgr()->insert( separator(), -1, 0 );
3783 createPopupItem( 803, View, group ); // EDIT_GROUP
3784 createPopupItem( 804, View, elems ); // ADD
3785 createPopupItem( 805, View, elems ); // REMOVE
3787 popupMgr()->insert( separator(), -1, 0 );
3788 createPopupItem( 214, View, mesh_group ); // UPDATE
3789 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3790 //createPopupItem( 902, View, mesh ); // STD_INFO
3791 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3792 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3793 popupMgr()->insert( separator(), -1, 0 );
3795 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3796 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3797 popupMgr()->insert( separator(), -1, 0 );
3800 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3801 QString aType = QString( "%1type in {%2}" ).arg( lc );
3802 aType = aType.arg( mesh_group );
3803 QString aMeshInVTK = aClient + "&&" + aType;
3805 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3806 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3807 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3809 //-------------------------------------------------
3811 //-------------------------------------------------
3812 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3814 popupMgr()->insert( action( 9010 ), anId, -1 );
3815 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3816 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3818 popupMgr()->insert( action( 9011 ), anId, -1 );
3819 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3820 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3822 popupMgr()->insert( separator(), -1, -1 );
3824 //-------------------------------------------------
3826 //-------------------------------------------------
3827 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3829 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3830 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3831 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3833 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3834 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3835 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3837 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3838 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3839 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3841 popupMgr()->insert( separator(), anId, -1 );
3843 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3844 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3845 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3847 //-------------------------------------------------
3849 //-------------------------------------------------
3850 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3852 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3854 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3855 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3856 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3858 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3859 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3860 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3862 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3863 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3864 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3866 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3867 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3868 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3870 popupMgr()->insert( separator(), anId, -1 );
3872 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3873 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3876 //-------------------------------------------------
3877 // Representation of the 2D Quadratic elements
3878 //-------------------------------------------------
3879 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3880 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3881 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3882 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3884 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3885 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3886 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3888 //-------------------------------------------------
3889 // Orientation of faces
3890 //-------------------------------------------------
3891 popupMgr()->insert( action( 221 ), -1, -1 );
3892 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3893 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3895 //-------------------------------------------------
3897 //-------------------------------------------------
3898 popupMgr()->insert( action( 1132 ), -1, -1 );
3899 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3901 //-------------------------------------------------
3903 //-------------------------------------------------
3904 popupMgr()->insert( action( 1133 ), -1, -1 );
3905 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3907 //-------------------------------------------------
3909 //-------------------------------------------------
3911 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3912 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3913 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3914 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3916 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3918 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3919 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3921 popupMgr()->insert( separator(), anId, -1 );
3923 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3925 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3926 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3927 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3929 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3931 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3932 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3933 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3935 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3936 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3937 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3939 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3940 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3941 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3943 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3944 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3945 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3947 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3949 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3950 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3951 QtxPopupMgr::VisibleRule );
3952 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3954 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3955 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3956 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3958 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3959 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3960 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3962 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3963 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3964 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3966 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3967 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3968 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3970 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3971 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3972 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3974 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3975 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3976 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3978 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3979 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3980 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3982 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3983 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3984 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3986 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3987 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3988 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3990 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3991 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3992 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3994 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
3995 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3996 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
3998 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4000 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4001 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4002 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4004 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4005 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4006 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4008 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4009 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4010 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4012 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4013 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4014 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4016 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4017 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4018 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4020 popupMgr()->insert( separator(), anId, -1 );
4022 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4023 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4025 popupMgr()->insert( separator(), anId, -1 );
4027 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4029 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4030 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4032 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4033 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4034 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4036 #ifndef DISABLE_PLOT2DVIEWER
4037 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4038 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4041 //-------------------------------------------------
4043 //-------------------------------------------------
4044 popupMgr()->insert( separator(), -1, -1 );
4045 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4046 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4047 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4048 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4050 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4051 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4053 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4054 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4056 popupMgr()->insert( separator(), -1, -1 );
4058 //-------------------------------------------------
4060 //-------------------------------------------------
4061 popupMgr()->insert( action( 1134 ), -1, -1 );
4062 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4064 popupMgr()->insert( separator(), -1, -1 );
4066 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4067 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4069 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4070 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4073 //================================================================================
4075 * \brief Return true if SMESH or GEOM objects are selected.
4076 * Is called form LightApp_Module::activateModule() which clear selection if
4077 * not isSelectionCompatible()
4079 //================================================================================
4081 bool SMESHGUI::isSelectionCompatible()
4083 bool isCompatible = true;
4084 SALOME_ListIO selected;
4085 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4086 Sel->selectedObjects( selected );
4088 SALOME_ListIteratorOfListIO It( selected );
4089 for ( ; isCompatible && It.More(); It.Next())
4091 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4092 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4094 return isCompatible;
4098 bool SMESHGUI::reusableOperation( const int id )
4100 // compute, evaluate and precompute are not reusable operations
4101 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4104 bool SMESHGUI::activateModule( SUIT_Study* study )
4106 bool res = SalomeApp_Module::activateModule( study );
4108 setMenuShown( true );
4109 setToolShown( true );
4111 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4112 PyGILState_STATE gstate = PyGILState_Ensure();
4113 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4114 if(pluginsmanager==NULL)
4118 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4123 PyGILState_Release(gstate);
4124 // end of GEOM plugins loading
4126 // Reset actions accelerator keys
4127 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4128 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4129 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4131 action( 33)->setEnabled(true); // Delete: Key_Delete
4132 action(1101)->setEnabled(true); // Rename: Key_F2
4134 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4135 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4136 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4137 if ( _PTR(Study) aStudy = s->studyDS()) {
4138 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4139 updateObjBrowser(); // objects can be removed
4145 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4147 setMenuShown( false );
4148 setToolShown( false );
4150 EmitSignalCloseAllDialogs();
4152 // Unset actions accelerator keys
4153 action(111)->setShortcut(QKeySequence()); // Import DAT
4154 action(112)->setShortcut(QKeySequence()); // Import UNV
4155 action(113)->setShortcut(QKeySequence()); // Import MED
4157 action( 33)->setEnabled(false); // Delete: Key_Delete
4158 action(1101)->setEnabled(false); // Rename: Key_F2
4160 return SalomeApp_Module::deactivateModule( study );
4163 void SMESHGUI::studyClosed( SUIT_Study* s )
4165 SMESH::RemoveVisuData( s->id() );
4166 SalomeApp_Module::studyClosed( s );
4169 void SMESHGUI::OnGUIEvent()
4171 const QObject* obj = sender();
4172 if ( !obj || !obj->inherits( "QAction" ) )
4174 int id = actionId((QAction*)obj);
4179 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4181 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4182 if ( CORBA::is_nil( myComponentSMESH ) )
4184 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4186 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4187 return aGUI.myComponentSMESH;
4190 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4191 return myComponentSMESH;
4194 QString SMESHGUI::engineIOR() const
4196 CORBA::ORB_var anORB = getApp()->orb();
4197 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4198 return QString( anIOR.in() );
4201 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4203 SalomeApp_Module::contextMenuPopup( client, menu, title );
4205 selectionMgr()->selectedObjects( lst );
4206 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4207 Handle(SALOME_InteractiveObject) io = lst.First();
4208 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4209 _PTR(Study) study = appStudy->studyDS();
4210 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4212 QString aName = QString( obj->GetName().c_str() );
4213 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4214 aName.remove( (aName.length() - 1), 1 );
4220 LightApp_Selection* SMESHGUI::createSelection() const
4222 return new SMESHGUI_Selection();
4225 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4227 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4228 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4231 void SMESHGUI::viewManagers( QStringList& list ) const
4233 list.append( SVTK_Viewer::Type() );
4236 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4238 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4239 SMESH::UpdateSelectionProp( this );
4242 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4244 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4245 myClippingPlaneInfoMap.erase( theViewManager );
4248 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4250 theActor->AddObserver( SMESH::DeleteActorEvent,
4251 myEventCallbackCommand.GetPointer(),
4255 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4256 unsigned long theEvent,
4257 void* theClientData,
4260 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4261 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4262 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4263 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4264 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4265 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4266 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4267 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4268 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4269 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4270 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4271 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4272 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4273 if( anActor == *anIter3 ) {
4274 anActorList.erase( anIter3 );
4285 void SMESHGUI::createPreferences()
4287 // General tab ------------------------------------------------------------------------
4288 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4290 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4291 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4292 setPreferenceProperty( lim, "min", 0 );
4293 setPreferenceProperty( lim, "max", 100000000 );
4294 setPreferenceProperty( lim, "step", 1000 );
4295 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4297 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4298 setPreferenceProperty( qaGroup, "columns", 2 );
4299 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4300 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4301 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4302 setPreferenceProperty( prec, "min", 0 );
4303 setPreferenceProperty( prec, "max", 16 );
4305 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4306 setPreferenceProperty( dispgroup, "columns", 2 );
4307 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4309 modes.append( "Wireframe" );
4310 modes.append( "Shading" );
4311 modes.append( "Nodes" );
4312 modes.append( "Shrink" );
4313 QList<QVariant> indices;
4314 indices.append( 0 );
4315 indices.append( 1 );
4316 indices.append( 2 );
4317 indices.append( 3 );
4318 setPreferenceProperty( dispmode, "strings", modes );
4319 setPreferenceProperty( dispmode, "indexes", indices );
4321 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4322 setPreferenceProperty( arcgroup, "columns", 2 );
4323 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4324 QStringList quadraticModes;
4325 quadraticModes.append("Lines");
4326 quadraticModes.append("Arcs");
4328 indices.append( 0 );
4329 indices.append( 1 );
4330 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4331 setPreferenceProperty( quadraticmode, "indexes", indices );
4333 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4334 "SMESH", "max_angle" );
4335 setPreferenceProperty( maxAngle, "min", 1 );
4336 setPreferenceProperty( maxAngle, "max", 90 );
4340 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4341 setPreferenceProperty( exportgroup, "columns", 2 );
4342 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4343 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4345 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4346 setPreferenceProperty( computeGroup, "columns", 2 );
4347 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4349 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4350 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4351 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4353 indices.append( 0 );
4354 indices.append( 1 );
4355 indices.append( 2 );
4356 setPreferenceProperty( notifyMode, "strings", modes );
4357 setPreferenceProperty( notifyMode, "indexes", indices );
4359 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4360 setPreferenceProperty( computeGroup, "columns", 2 );
4361 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4363 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4364 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4366 indices.append( 0 );
4367 indices.append( 1 );
4368 setPreferenceProperty( elemInfo, "strings", modes );
4369 setPreferenceProperty( elemInfo, "indexes", indices );
4371 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4372 setPreferenceProperty( segGroup, "columns", 2 );
4373 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4374 "SMESH", "segmentation" );
4375 setPreferenceProperty( segLen, "min", 1 );
4376 setPreferenceProperty( segLen, "max", 10000000 );
4377 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4378 "SMESH", "nb_segments_per_edge" );
4379 setPreferenceProperty( nbSeg, "min", 1 );
4380 setPreferenceProperty( nbSeg, "max", 10000000 );
4382 // Quantities with individual precision settings
4383 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4384 setPreferenceProperty( precGroup, "columns", 2 );
4386 const int nbQuantities = 6;
4387 int precs[nbQuantities], ii = 0;
4388 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4389 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4390 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4391 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4392 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4393 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4394 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4395 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4396 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4397 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4398 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4399 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4401 // Set property for precision value for spinboxes
4402 for ( ii = 0; ii < nbQuantities; ii++ ){
4403 setPreferenceProperty( precs[ii], "min", -14 );
4404 setPreferenceProperty( precs[ii], "max", 14 );
4405 setPreferenceProperty( precs[ii], "precision", 2 );
4408 // Mesh tab ------------------------------------------------------------------------
4409 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4410 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4411 setPreferenceProperty( nodeGroup, "columns", 3 );
4413 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4415 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4417 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4418 QList<QVariant> aMarkerTypeIndicesList;
4419 QList<QVariant> aMarkerTypeIconsList;
4420 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4421 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4422 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4423 aMarkerTypeIndicesList << i;
4424 aMarkerTypeIconsList << pixmap;
4426 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4427 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4429 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4431 QList<QVariant> aMarkerScaleIndicesList;
4432 QStringList aMarkerScaleValuesList;
4433 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4434 aMarkerScaleIndicesList << i;
4435 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4437 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4438 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4440 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4441 setPreferenceProperty( elemGroup, "columns", 2 );
4443 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4444 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4445 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4446 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4448 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4449 setPreferenceProperty( grpGroup, "columns", 2 );
4451 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4453 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4454 //setPreferenceProperty( sp, "hstretch", 0 );
4455 //setPreferenceProperty( sp, "vstretch", 0 );
4457 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4458 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4459 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4460 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4461 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4462 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4463 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4465 setPreferenceProperty( size0d, "min", 1 );
4466 setPreferenceProperty( size0d, "max", 10 );
4468 setPreferenceProperty( sp, "hstretch", 0 );
4469 setPreferenceProperty( sp, "vstretch", 0 );
4471 setPreferenceProperty( elemW, "min", 1 );
4472 setPreferenceProperty( elemW, "max", 5 );
4474 setPreferenceProperty( shrink, "min", 0 );
4475 setPreferenceProperty( shrink, "max", 100 );
4477 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4478 setPreferenceProperty( orientGroup, "columns", 1 );
4480 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4481 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4483 setPreferenceProperty( orientScale, "min", 0.05 );
4484 setPreferenceProperty( orientScale, "max", 0.5 );
4485 setPreferenceProperty( orientScale, "step", 0.05 );
4487 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4489 // Selection tab ------------------------------------------------------------------------
4490 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4492 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4493 setPreferenceProperty( selGroup, "columns", 2 );
4495 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4496 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4497 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4499 setPreferenceProperty( selW, "min", 1 );
4500 setPreferenceProperty( selW, "max", 5 );
4502 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4503 setPreferenceProperty( preGroup, "columns", 2 );
4505 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4506 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4508 setPreferenceProperty( preW, "min", 1 );
4509 setPreferenceProperty( preW, "max", 5 );
4511 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4512 setPreferenceProperty( precSelGroup, "columns", 2 );
4514 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4515 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4516 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4518 // Scalar Bar tab ------------------------------------------------------------------------
4519 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4520 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4521 setPreferenceProperty( fontGr, "columns", 2 );
4523 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4524 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4526 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4527 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4529 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4530 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4532 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4533 setPreferenceProperty( numcol, "min", 2 );
4534 setPreferenceProperty( numcol, "max", 256 );
4536 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4537 setPreferenceProperty( numlab, "min", 2 );
4538 setPreferenceProperty( numlab, "max", 65 );
4540 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4541 setPreferenceProperty( orientGr, "columns", 2 );
4542 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4543 QStringList orients;
4544 orients.append( tr( "SMESH_VERTICAL" ) );
4545 orients.append( tr( "SMESH_HORIZONTAL" ) );
4546 indices.clear(); indices.append( 0 ); indices.append( 1 );
4547 setPreferenceProperty( orient, "strings", orients );
4548 setPreferenceProperty( orient, "indexes", indices );
4550 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4551 setPreferenceProperty( posVSizeGr, "columns", 2 );
4552 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4553 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4554 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4555 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4556 setPreferenceProperty( xv, "step", 0.1 );
4557 setPreferenceProperty( xv, "min", 0.0 );
4558 setPreferenceProperty( xv, "max", 1.0 );
4559 setPreferenceProperty( yv, "step", 0.1 );
4560 setPreferenceProperty( yv, "min", 0.0 );
4561 setPreferenceProperty( yv, "max", 1.0 );
4562 setPreferenceProperty( wv, "step", 0.1 );
4563 setPreferenceProperty( wv, "min", 0.0 );
4564 setPreferenceProperty( wv, "max", 1.0 );
4565 setPreferenceProperty( hv, "min", 0.0 );
4566 setPreferenceProperty( hv, "max", 1.0 );
4567 setPreferenceProperty( hv, "step", 0.1 );
4569 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4570 setPreferenceProperty( posHSizeGr, "columns", 2 );
4571 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4572 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4573 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4574 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4575 setPreferenceProperty( xv, "min", 0.0 );
4576 setPreferenceProperty( xv, "max", 1.0 );
4577 setPreferenceProperty( xv, "step", 0.1 );
4578 setPreferenceProperty( xh, "min", 0.0 );
4579 setPreferenceProperty( xh, "max", 1.0 );
4580 setPreferenceProperty( xh, "step", 0.1 );
4581 setPreferenceProperty( yh, "min", 0.0 );
4582 setPreferenceProperty( yh, "max", 1.0 );
4583 setPreferenceProperty( yh, "step", 0.1 );
4584 setPreferenceProperty( wh, "min", 0.0 );
4585 setPreferenceProperty( wh, "max", 1.0 );
4586 setPreferenceProperty( wh, "step", 0.1 );
4587 setPreferenceProperty( hh, "min", 0.0 );
4588 setPreferenceProperty( hh, "max", 1.0 );
4589 setPreferenceProperty( hh, "step", 0.1 );
4591 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4592 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4593 setPreferenceProperty( distributionGr, "columns", 3 );
4595 types.append( tr( "SMESH_MONOCOLOR" ) );
4596 types.append( tr( "SMESH_MULTICOLOR" ) );
4597 indices.clear(); indices.append( 0 ); indices.append( 1 );
4598 setPreferenceProperty( coloringType, "strings", types );
4599 setPreferenceProperty( coloringType, "indexes", indices );
4600 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4604 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4606 if( sect=="SMESH" ) {
4607 float sbX1,sbY1,sbW,sbH;
4608 float aTol = 1.00000009999999;
4609 std::string aWarning;
4610 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4611 if( name=="selection_object_color" || name=="selection_element_color" ||
4612 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4613 name=="selection_precision_node" || name=="selection_precision_element" ||
4614 name=="selection_precision_object")
4615 SMESH::UpdateSelectionProp( this );
4616 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4617 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4618 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4619 if(sbX1+sbW > aTol){
4620 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4623 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4624 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4627 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4628 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4629 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4630 if(sbY1+sbH > aTol){
4631 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4632 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4633 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4636 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4637 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4638 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4639 if(sbX1+sbW > aTol){
4640 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4643 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4644 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4647 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4648 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4649 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4650 if(sbY1+sbH > aTol){
4651 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4654 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4655 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4658 else if ( name == "segmentation" ) {
4659 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4660 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4662 else if ( name == "nb_segments_per_edge" ) {
4663 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4664 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4667 if(aWarning.size() != 0){
4668 aWarning += "The default values are applied instead.";
4669 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4670 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4671 QObject::tr(aWarning.c_str()));
4676 //================================================================================
4678 * \brief Update something in accordance with update flags
4679 * \param theFlags - update flags
4681 * Update viewer or/and object browser etc. in accordance with update flags ( see
4682 * LightApp_UpdateFlags enumeration ).
4684 //================================================================================
4685 void SMESHGUI::update( const int flags )
4687 if ( flags & UF_Viewer | flags & UF_Forced )
4688 SMESH::UpdateView();
4690 SalomeApp_Module::update( flags );
4693 //================================================================================
4695 * \brief Set default selection mode
4697 * SLOT called when operation commited. Sets default selection mode
4699 //================================================================================
4700 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4702 SVTK_ViewWindow* vtkWnd =
4703 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4705 vtkWnd->SetSelectionMode( ActorSelection );
4708 //================================================================================
4710 * \brief Set default selection mode
4712 * SLOT called when operation aborted. Sets default selection mode
4714 //================================================================================
4715 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4717 SVTK_ViewWindow* vtkWnd =
4718 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4720 vtkWnd->SetSelectionMode( ActorSelection );
4723 //================================================================================
4725 * \brief Creates operation with given identifier
4726 * \param id - identifier of operation to be started
4727 * \return Pointer on created operation or NULL if operation is not created
4729 * Virtual method redefined from the base class creates operation with given id.
4730 * It is called called automatically from startOperation method of base class.
4732 //================================================================================
4733 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4735 LightApp_Operation* op = 0;
4736 // to do : create operation here
4739 case 417: //convert to quadratic
4740 op = new SMESHGUI_ConvToQuadOp();
4742 case 418: // create 2D mesh as boundary on 3D
4743 op = new SMESHGUI_Make2DFrom3DOp();
4745 case 701: // Compute mesh
4746 op = new SMESHGUI_ComputeOp();
4748 case 702: // Create mesh
4749 op = new SMESHGUI_MeshOp( true, true );
4751 case 703: // Create sub-mesh
4752 op = new SMESHGUI_MeshOp( true, false );
4754 case 704: // Edit mesh/sub-mesh
4755 op = new SMESHGUI_MeshOp( false );
4757 case 711: // Precompute mesh
4758 op = new SMESHGUI_PrecomputeOp();
4760 case 712: // Evaluate mesh
4761 op = new SMESHGUI_EvaluateOp();
4763 case 713: // Evaluate mesh
4764 op = new SMESHGUI_MeshOrderOp();
4766 case 806: // Create group on geom
4767 op = new SMESHGUI_GroupOnShapeOp();
4769 case 904: // Find element
4770 op = new SMESHGUI_FindElemByPointOp();
4772 case 4067: // make mesh pass through point
4773 op = new SMESHGUI_MakeNodeAtPointOp();
4780 op = SalomeApp_Module::createOperation( id );
4784 //================================================================================
4786 * \brief Stops current operations and starts a given one
4787 * \param id - The id of the operation to start
4789 //================================================================================
4791 void SMESHGUI::switchToOperation(int id)
4793 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4794 activeStudy()->abortAllOperations();
4795 startOperation( id );
4798 LightApp_Displayer* SMESHGUI::displayer()
4801 myDisplayer = new SMESHGUI_Displayer( getApp() );
4805 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4808 int aTolerance = 64;
4809 int anIterations = 0;
4815 if( anIterations % aPeriod == 0 )
4818 if( aTolerance < 1 )
4822 aHue = (int)( 360.0 * rand() / RAND_MAX );
4825 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4826 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4827 for( ; it != itEnd; ++it )
4829 SALOMEDS::Color anAutoColor = *it;
4830 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4833 aQColor.getHsv( &h, &s, &v );
4834 if( abs( h - aHue ) < aTolerance )
4846 aColor.setHsv( aHue, 255, 255 );
4848 SALOMEDS::Color aSColor;
4849 aSColor.R = (double)aColor.red() / 255.0;
4850 aSColor.G = (double)aColor.green() / 255.0;
4851 aSColor.B = (double)aColor.blue() / 255.0;
4856 const char gSeparator = '_'; // character used to separate parameter names
4857 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4858 const char gPathSep = '|'; // character used to separate paths
4861 * \brief Store visual parameters
4863 * This method is called just before the study document is saved.
4864 * Store visual parameters in AttributeParameter attribue(s)
4866 void SMESHGUI::storeVisualParameters (int savePoint)
4868 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4869 if (!appStudy || !appStudy->studyDS())
4871 _PTR(Study) studyDS = appStudy->studyDS();
4873 // componentName is used for encoding of entries when storing them in IParameters
4874 std::string componentName = myComponentSMESH->ComponentDataType();
4875 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4876 //if (!aSComponent) return;
4879 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4880 componentName.c_str(),
4882 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4884 // store map of custom markers
4885 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4886 if( !aMarkerMap.empty() )
4888 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4889 for( ; anIter != aMarkerMap.end(); anIter++ )
4891 int anId = anIter->first;
4892 VTK::MarkerData aMarkerData = anIter->second;
4893 std::string aMarkerFileName = aMarkerData.first;
4894 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4895 if( aMarkerTexture.size() < 3 )
4896 continue; // should contain at least width, height and the first value
4898 QString aPropertyName( "texture" );
4899 aPropertyName += gSeparator;
4900 aPropertyName += QString::number( anId );
4902 QString aPropertyValue = aMarkerFileName.c_str();
4903 aPropertyValue += gPathSep;
4905 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4906 ushort aWidth = *aTextureIter++;
4907 ushort aHeight = *aTextureIter++;
4908 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4909 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4910 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4911 aPropertyValue += QString::number( *aTextureIter );
4913 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4917 // viewers counters are used for storing view_numbers in IParameters
4920 // main cycle to store parameters of displayed objects
4921 QList<SUIT_ViewManager*> lst;
4922 QList<SUIT_ViewManager*>::Iterator it;
4923 getApp()->viewManagers(lst);
4924 for (it = lst.begin(); it != lst.end(); it++)
4926 SUIT_ViewManager* vman = *it;
4927 QString vType = vman->getType();
4929 // saving VTK actors properties
4930 if (vType == SVTK_Viewer::Type())
4932 // store the clipping planes attached to the view manager
4933 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4934 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4935 if( anIter != myClippingPlaneInfoMap.end() )
4936 aClippingPlaneInfoList = anIter->second;
4938 if( !aClippingPlaneInfoList.empty() ) {
4939 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4940 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4942 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4943 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4945 QString aPropertyName( "ClippingPlane" );
4946 aPropertyName += gSeparator;
4947 aPropertyName += QString::number( vtkViewers );
4948 aPropertyName += gSeparator;
4949 aPropertyName += QString::number( anId );
4951 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4952 aPropertyValue += gDigitsSep;
4953 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4954 aPropertyValue += gDigitsSep;
4955 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4956 aPropertyValue += gDigitsSep;
4957 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4959 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4963 QVector<SUIT_ViewWindow*> views = vman->getViews();
4964 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4966 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4968 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4969 vtkActorCollection* allActors = aCopy.GetActors();
4970 allActors->InitTraversal();
4971 while (vtkActor* actor = allActors->GetNextActor())
4973 if (actor->GetVisibility()) // store only visible actors
4975 SMESH_Actor* aSmeshActor = 0;
4976 if (actor->IsA("SMESH_Actor"))
4977 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4978 if (aSmeshActor && aSmeshActor->hasIO())
4980 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4983 // entry is "encoded" = it does NOT contain component adress,
4984 // since it is a subject to change on next component loading
4985 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4987 std::string param, vtkParam = vType.toLatin1().data();
4988 vtkParam += gSeparator;
4989 vtkParam += QString::number(vtkViewers).toLatin1().data();
4990 vtkParam += gSeparator;
4993 param = vtkParam + "Visibility";
4994 ip->setParameter(entry, param, "On");
4997 param = vtkParam + "Representation";
4998 ip->setParameter(entry, param, QString::number
4999 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5002 param = vtkParam + "IsShrunk";
5003 ip->setParameter(entry, param, QString::number
5004 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5006 // Displayed entities
5007 unsigned int aMode = aSmeshActor->GetEntityMode();
5008 bool isE = aMode & SMESH_Actor::eEdges;
5009 bool isF = aMode & SMESH_Actor::eFaces;
5010 bool isV = aMode & SMESH_Actor::eVolumes;
5012 QString modeStr ("e");
5013 modeStr += gDigitsSep; modeStr += QString::number(isE);
5014 modeStr += gDigitsSep; modeStr += "f";
5015 modeStr += gDigitsSep; modeStr += QString::number(isF);
5016 modeStr += gDigitsSep; modeStr += "v";
5017 modeStr += gDigitsSep; modeStr += QString::number(isV);
5019 param = vtkParam + "Entities";
5020 ip->setParameter(entry, param, modeStr.toLatin1().data());
5022 // Colors (surface:edge:)
5023 vtkFloatingPointType r, g, b;
5025 aSmeshActor->GetSufaceColor(r, g, b);
5026 QString colorStr ("surface");
5027 colorStr += gDigitsSep; colorStr += QString::number(r);
5028 colorStr += gDigitsSep; colorStr += QString::number(g);
5029 colorStr += gDigitsSep; colorStr += QString::number(b);
5031 aSmeshActor->GetBackSufaceColor(r, g, b);
5032 colorStr += gDigitsSep; colorStr += "backsurface";
5033 colorStr += gDigitsSep; colorStr += QString::number(r);
5034 colorStr += gDigitsSep; colorStr += QString::number(g);
5035 colorStr += gDigitsSep; colorStr += QString::number(b);
5037 aSmeshActor->GetEdgeColor(r, g, b);
5038 colorStr += gDigitsSep; colorStr += "edge";
5039 colorStr += gDigitsSep; colorStr += QString::number(r);
5040 colorStr += gDigitsSep; colorStr += QString::number(g);
5041 colorStr += gDigitsSep; colorStr += QString::number(b);
5043 aSmeshActor->GetNodeColor(r, g, b);
5044 colorStr += gDigitsSep; colorStr += "node";
5045 colorStr += gDigitsSep; colorStr += QString::number(r);
5046 colorStr += gDigitsSep; colorStr += QString::number(g);
5047 colorStr += gDigitsSep; colorStr += QString::number(b);
5049 param = vtkParam + "Colors";
5050 ip->setParameter(entry, param, colorStr.toLatin1().data());
5052 // Sizes of lines and points
5053 QString sizeStr ("line");
5054 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5055 sizeStr += gDigitsSep; sizeStr += "shrink";
5056 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5058 param = vtkParam + "Sizes";
5059 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5064 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5065 if( aMarkerType == VTK::MT_USER ) {
5066 markerStr += "custom";
5067 markerStr += gDigitsSep;
5068 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5072 markerStr += gDigitsSep;
5073 markerStr += QString::number( (int)aMarkerType );
5074 markerStr += gDigitsSep;
5075 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5078 param = vtkParam + "PointMarker";
5079 ip->setParameter(entry, param, markerStr.toLatin1().data());
5082 param = vtkParam + "Opacity";
5083 ip->setParameter(entry, param,
5084 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5087 param = vtkParam + "ClippingPlane";
5089 if( !aClippingPlaneInfoList.empty() ) {
5090 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5091 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5093 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5094 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5095 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5096 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5097 if( aSmeshActor == *anIter2 ) {
5098 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5099 QString::number( anId ).toLatin1().constData() );
5106 ip->setParameter( entry, param, "Off" );
5107 } // if (io->hasEntry())
5108 } // SMESH_Actor && hasIO
5110 } // while.. actors traversal
5114 } // if (SVTK view model)
5115 } // for (viewManagers)
5118 // data structures for clipping planes processing
5121 vtkIdType Orientation;
5122 vtkFloatingPointType Distance;
5123 vtkFloatingPointType Angle[2];
5125 typedef std::list<TPlaneData> TPlaneDataList;
5126 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5128 typedef std::list<vtkActor*> TActorList;
5131 TActorList ActorList;
5132 SUIT_ViewManager* ViewManager;
5134 typedef std::list<TPlaneInfo> TPlaneInfoList;
5135 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5138 * \brief Restore visual parameters
5140 * This method is called after the study document is opened.
5141 * Restore visual parameters from AttributeParameter attribue(s)
5143 void SMESHGUI::restoreVisualParameters (int savePoint)
5145 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5146 if (!appStudy || !appStudy->studyDS())
5148 _PTR(Study) studyDS = appStudy->studyDS();
5150 // componentName is used for encoding of entries when storing them in IParameters
5151 std::string componentName = myComponentSMESH->ComponentDataType();
5152 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5153 //if (!aSComponent) return;
5156 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5157 componentName.c_str(),
5159 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5161 // restore map of custom markers and map of clipping planes
5162 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5163 TPlaneDataMap aPlaneDataMap;
5165 std::vector<std::string> properties = ip->getProperties();
5166 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5168 std::string property = *propIt;
5169 QString aPropertyName( property.c_str() );
5170 QString aPropertyValue( ip->getProperty( property ).c_str() );
5172 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5173 if( aPropertyNameList.isEmpty() )
5176 QString aPropertyType = aPropertyNameList[0];
5177 if( aPropertyType == "texture" )
5179 if( aPropertyNameList.size() != 2 )
5183 int anId = aPropertyNameList[1].toInt( &ok );
5184 if( !ok || anId < 1 )
5187 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5188 if( aPropertyValueList.size() != 2 )
5191 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5192 QString aMarkerTextureString = aPropertyValueList[1];
5193 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5194 if( aMarkerTextureStringList.size() != 3 )
5198 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5203 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5207 VTK::MarkerTexture aMarkerTexture;
5208 aMarkerTexture.push_back( aWidth );
5209 aMarkerTexture.push_back( aHeight );
5211 QString aMarkerTextureData = aMarkerTextureStringList[2];
5212 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5214 QChar aChar = aMarkerTextureData.at( i );
5215 if( aChar.isDigit() )
5216 aMarkerTexture.push_back( aChar.digitValue() );
5219 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5221 else if( aPropertyType == "ClippingPlane" )
5223 if( aPropertyNameList.size() != 3 )
5227 int aViewId = aPropertyNameList[1].toInt( &ok );
5228 if( !ok || aViewId < 0 )
5232 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5233 if( !ok || aClippingPlaneId < 0 )
5236 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5237 if( aPropertyValueList.size() != 4 )
5240 TPlaneData aPlaneData;
5241 aPlaneData.Id = aClippingPlaneId;
5244 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5249 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5254 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5259 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5263 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5264 aPlaneDataList.push_back( aPlaneData );
5268 TPlaneInfoMap aPlaneInfoMap;
5270 std::vector<std::string> entries = ip->getEntries();
5272 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5274 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5275 QString entry (ip->decodeEntry(*entIt).c_str());
5277 // Check that the entry corresponds to a real object in the Study
5278 // as the object may be deleted or modified after the visual state is saved.
5279 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5280 if (!so) continue; //Skip the not existent entry
5282 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5283 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5285 std::vector<std::string>::iterator namesIt = paramNames.begin();
5286 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5288 // actors are stored in a map after displaying of them for
5289 // quicker access in the future: map < viewID to actor >
5290 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5292 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5294 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5295 // '_' is used as separator and should not be used in viewer type or parameter names.
5296 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5297 if (lst.size() != 3)
5300 QString viewerTypStr = lst[0];
5301 QString viewIndexStr = lst[1];
5302 QString paramNameStr = lst[2];
5305 int viewIndex = viewIndexStr.toUInt(&ok);
5306 if (!ok) // bad conversion of view index to integer
5310 if (viewerTypStr == SVTK_Viewer::Type())
5312 SMESH_Actor* aSmeshActor = 0;
5313 if (vtkActors.IsBound(viewIndex))
5314 aSmeshActor = vtkActors.Find(viewIndex);
5316 QList<SUIT_ViewManager*> lst;
5317 getApp()->viewManagers(viewerTypStr, lst);
5319 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5320 SUIT_ViewManager* vman = NULL;
5321 if (viewIndex >= 0 && viewIndex < lst.count())
5322 vman = lst.at(viewIndex);
5324 if (paramNameStr == "Visibility")
5326 if (!aSmeshActor && displayer() && vman)
5328 SUIT_ViewModel* vmodel = vman->getViewModel();
5329 // SVTK view model can be casted to SALOME_View
5330 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5332 // store displayed actor in a temporary map for quicker
5333 // access later when restoring other parameters
5334 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5335 vtkRenderer* Renderer = vtkView->getRenderer();
5336 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5337 vtkActorCollection* theActors = aCopy.GetActors();
5338 theActors->InitTraversal();
5339 bool isFound = false;
5340 vtkActor *ac = theActors->GetNextActor();
5341 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5342 if (ac->IsA("SMESH_Actor")) {
5343 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5344 if (aGeomAc->hasIO()) {
5345 Handle(SALOME_InteractiveObject) io =
5346 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5347 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5349 vtkActors.Bind(viewIndex, aGeomAc);
5355 } // if (paramNameStr == "Visibility")
5358 // the rest properties "work" with SMESH_Actor
5361 QString val ((*valuesIt).c_str());
5364 if (paramNameStr == "Representation") {
5365 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5368 else if (paramNameStr == "IsShrunk") {
5370 if (!aSmeshActor->IsShrunk())
5371 aSmeshActor->SetShrink();
5374 if (aSmeshActor->IsShrunk())
5375 aSmeshActor->UnShrink();
5378 // Displayed entities
5379 else if (paramNameStr == "Entities") {
5380 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5381 if (mode.count() == 6) {
5382 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5383 MESSAGE("Invalid order of data in Entities, must be: "
5384 "e:0/1:f:0/1:v:0/1");
5387 unsigned int aMode = aSmeshActor->GetEntityMode();
5388 unsigned int aNewMode =
5389 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5390 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5391 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5392 if (aNewMode != aMode)
5393 aSmeshActor->SetEntityMode(aNewMode);
5398 else if (paramNameStr == "Colors") {
5399 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5400 if (colors.count() == 16) {
5401 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5402 colors[8] != "edge" || colors[12] != "node") {
5403 MESSAGE("Invalid order of data in Colors, must be: "
5404 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5407 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5408 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5409 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5410 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5414 // Sizes of lines and points
5415 else if (paramNameStr == "Sizes") {
5416 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5417 if (sizes.count() == 4) {
5418 if (sizes[0] != "line" || sizes[2] != "shrink") {
5419 MESSAGE("Invalid order of data in Sizes, must be: "
5420 "line:int:shrink:float");
5423 aSmeshActor->SetLineWidth(sizes[1].toInt());
5424 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5427 else if (sizes.count() == 6) { // just to support old format
5428 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5429 MESSAGE("Invalid order of data in Sizes, must be: "
5430 "line:int:node:int:shrink:float");
5433 aSmeshActor->SetLineWidth(sizes[1].toInt());
5434 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5435 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5440 else if (paramNameStr == "PointMarker") {
5441 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5442 if( data.count() >= 2 ) {
5444 int aParam1 = data[1].toInt( &ok );
5446 if( data[0] == "std" && data.count() == 3 ) {
5447 int aParam2 = data[2].toInt( &ok );
5448 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5450 else if( data[0] == "custom" ) {
5451 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5452 if( markerIt != aMarkerMap.end() ) {
5453 VTK::MarkerData aMarkerData = markerIt->second;
5454 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5461 else if (paramNameStr == "Opacity") {
5462 aSmeshActor->SetOpacity(val.toFloat());
5465 else if (paramNameStr.startsWith("ClippingPlane")) {
5466 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5467 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5468 // new format - val looks like "Off" or "0" (plane id)
5469 // (note: in new format "Off" value is used only for consistency,
5470 // so it is processed together with values in old format)
5471 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5472 if( anIsOldFormat ) {
5473 if (paramNameStr == "ClippingPlane1" || val == "Off")
5474 aSmeshActor->RemoveAllClippingPlanes();
5476 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5477 double aDistance = vals[1].toFloat();
5478 vtkFloatingPointType anAngle[2];
5479 anAngle[0] = vals[2].toFloat();
5480 anAngle[1] = vals[3].toFloat();
5482 QList<SUIT_ViewManager*> lst;
5483 getApp()->viewManagers(viewerTypStr, lst);
5484 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5485 if (viewIndex >= 0 && viewIndex < lst.count()) {
5486 SUIT_ViewManager* vman = lst.at(viewIndex);
5487 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5489 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5491 SMESH::TActorList anActorList;
5492 anActorList.push_back( aSmeshActor );
5493 SMESH::OrientedPlane* aPlane =
5494 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5496 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5497 aClippingPlaneInfo.Plane = aPlane;
5498 aClippingPlaneInfo.ActorList = anActorList;
5499 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5506 int aPlaneId = val.toInt( &ok );
5507 if( ok && aPlaneId >= 0 ) {
5508 bool anIsDefinedPlane = false;
5509 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5510 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5511 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5512 TPlaneInfo& aPlaneInfo = *anIter;
5513 if( aPlaneInfo.PlaneId == aPlaneId ) {
5514 aPlaneInfo.ActorList.push_back( aSmeshActor );
5515 anIsDefinedPlane = true;
5519 if( !anIsDefinedPlane ) {
5520 TPlaneInfo aPlaneInfo;
5521 aPlaneInfo.PlaneId = aPlaneId;
5522 aPlaneInfo.ActorList.push_back( aSmeshActor );
5523 aPlaneInfo.ViewManager = vman;
5525 // to make the list sorted by plane id
5526 anIter = aPlaneInfoList.begin();
5527 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5528 const TPlaneInfo& aPlaneInfoRef = *anIter;
5529 if( aPlaneInfoRef.PlaneId > aPlaneId )
5532 aPlaneInfoList.insert( anIter, aPlaneInfo );
5537 } // if (aSmeshActor)
5538 } // other parameters than Visibility
5540 } // for names/parameters iterator
5541 } // for entries iterator
5543 // take into account planes with empty list of actors referred to them
5544 QList<SUIT_ViewManager*> aVMList;
5545 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5547 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5548 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5549 int aViewId = aPlaneDataIter->first;
5550 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5551 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5553 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5555 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5556 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5557 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5558 const TPlaneData& aPlaneData = *anIter2;
5559 int aPlaneId = aPlaneData.Id;
5561 bool anIsFound = false;
5562 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5563 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5564 const TPlaneInfo& aPlaneInfo = *anIter3;
5565 if( aPlaneInfo.PlaneId == aPlaneId ) {
5572 TPlaneInfo aPlaneInfo; // ActorList field is empty
5573 aPlaneInfo.PlaneId = aPlaneId;
5574 aPlaneInfo.ViewManager = aViewManager;
5576 // to make the list sorted by plane id
5577 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5578 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5579 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5580 if( aPlaneInfoRef.PlaneId > aPlaneId )
5583 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5589 // add clipping planes to actors according to the restored parameters
5590 // and update the clipping plane map
5591 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5592 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5593 int aViewId = anIter1->first;
5594 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5596 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5597 if( anIter2 == aPlaneDataMap.end() )
5599 const TPlaneDataList& aPlaneDataList = anIter2->second;
5601 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5602 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5603 const TPlaneInfo& aPlaneInfo = *anIter3;
5604 int aPlaneId = aPlaneInfo.PlaneId;
5605 const TActorList& anActorList = aPlaneInfo.ActorList;
5606 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5610 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5614 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5616 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5617 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5618 const TPlaneData& aPlaneData = *anIter4;
5619 if( aPlaneData.Id == aPlaneId ) {
5620 SMESH::OrientedPlane* aPlane =
5621 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5623 (SMESH::Orientation)aPlaneData.Orientation,
5624 aPlaneData.Distance,
5627 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5628 aClippingPlaneInfo.Plane = aPlane;
5629 aClippingPlaneInfo.ActorList = anActorList;
5630 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5638 // update all VTK views
5639 QList<SUIT_ViewManager*> lst;
5640 getApp()->viewManagers(lst);
5641 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5642 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5643 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5644 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5645 vtkView->getRenderer()->ResetCameraClippingRange();
5652 \brief Adds preferences for dfont of VTK viewer
5654 \param pIf group identifier
5655 \param param parameter
5656 \return identifier of preferences
5658 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5660 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5662 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5665 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5666 fam.append( tr( "SMESH_FONT_COURIER" ) );
5667 fam.append( tr( "SMESH_FONT_TIMES" ) );
5669 setPreferenceProperty( tfont, "fonts", fam );
5671 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5672 setPreferenceProperty( tfont, "features", f );
5678 \brief Actions after hypothesis edition
5679 Updates object browser after hypothesis edition
5681 void SMESHGUI::onHypothesisEdit( int result )
5684 SMESHGUI::Modified();
5685 updateObjBrowser( true );