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"
80 #include "SMESHGUI_Utils.h"
81 #include "SMESHGUI_MeshUtils.h"
82 #include "SMESHGUI_GroupUtils.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_PatternUtils.h"
85 #include "SMESHGUI_VTKUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
88 #include <SMESH_Client.hxx>
89 #include <SMESH_Actor.h>
90 #include <SMESH_ScalarBarActor.h>
91 #include <SMESH_TypeFilter.hxx>
92 #include "SMESH_ControlsDef.hxx"
94 // SALOME GUI includes
95 #include <SalomeApp_Tools.h>
96 #include <SalomeApp_Study.h>
97 #include <SalomeApp_Application.h>
98 #include <SalomeApp_CheckFileDlg.h>
100 #include <LightApp_DataOwner.h>
101 #include <LightApp_Preferences.h>
102 #include <LightApp_SelectionMgr.h>
103 #include <LightApp_UpdateFlags.h>
104 #include <LightApp_NameDlg.h>
106 #include <SVTK_ViewWindow.h>
107 #include <SVTK_ViewModel.h>
108 #include <SVTK_ViewManager.h>
110 #include <VTKViewer_Algorithm.h>
112 #include <SUIT_MessageBox.h>
113 #include <SUIT_ResourceMgr.h>
114 #include <SUIT_FileDlg.h>
115 #include <SUIT_Desktop.h>
116 #include <SUIT_OverrideCursor.h>
117 #include <SUIT_Session.h>
119 #include <QtxPopupMgr.h>
120 #include <QtxFontEdit.h>
122 #include <SALOME_ListIO.hxx>
123 #include <SALOME_ListIteratorOfListIO.hxx>
126 #include <SALOMEconfig.h>
127 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
128 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
129 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
132 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
134 #include <QTextStream>
137 #include <boost/shared_ptr.hpp>
140 #include <vtkCamera.h>
141 #include <vtkRenderer.h>
142 #include <vtkPlane.h>
143 #include <vtkCallbackCommand.h>
145 // SALOME KERNEL includes
146 #include <SALOMEDS_Study.hxx>
147 #include <SALOMEDSClient_StudyBuilder.hxx>
148 #include <SALOMEDSClient_SComponent.hxx>
149 #include <SALOMEDSClient_ClientFactory.hxx>
150 #include <SALOMEDSClient_IParameters.hxx>
153 #include <Standard_ErrorHandler.hxx>
154 #include <NCollection_DataMap.hxx>
156 //To disable automatic genericobj management, the following line should be commented.
157 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
158 #define WITHGENERICOBJ
162 //=============================================================
163 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
166 void ExportMeshToFile(int theCommandID);
168 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
170 void SetDisplayEntity(int theCommandID);
172 void Control( int theCommandID );
176 //=============================================================
177 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
181 std::string myExtension;
183 if ( theCommandID == 113 ) {
184 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
185 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
187 else if ( theCommandID == 112 ) {
188 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
190 else if ( theCommandID == 111 ) {
191 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
194 QString anInitialPath = "";
195 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
196 anInitialPath = QDir::currentPath();
198 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
201 QObject::tr( "SMESH_IMPORT_MESH" ) );
202 if ( filenames.count() > 0 ) {
203 SUIT_OverrideCursor wc;
204 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
207 bool isEmpty = false;
208 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
209 QString filename = *it;
210 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
212 switch ( theCommandID ) {
215 // DAT format (currently unsupported)
216 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
217 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
223 aMeshes->length( 1 );
224 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
225 if ( aMeshes[0]->_is_nil() )
226 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
227 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
233 SMESH::DriverMED_ReadStatus res;
234 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
235 if ( res != SMESH::DRS_OK ) {
236 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
237 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
243 catch ( const SALOME::SALOME_Exception& S_ex ) {
244 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
245 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
248 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
249 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
251 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
252 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
253 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
254 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
255 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
257 #ifdef WITHGENERICOBJ
258 // obj has been published in study. Its refcount has been incremented.
259 // It is safe to decrement its refcount
260 // so that it will be destroyed when the entry in study will be removed
261 aMeshes[i]->Destroy();
270 // update Object browser
271 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
273 // show Error message box if there were errors
274 if ( errors.count() > 0 ) {
275 SUIT_MessageBox::critical( SMESHGUI::desktop(),
276 QObject::tr( "SMESH_ERROR" ),
277 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
280 // show warning message box, if some imported mesh is empty
282 SUIT_MessageBox::warning( SMESHGUI::desktop(),
283 QObject::tr( "SMESH_WRN_WARNING" ),
284 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
289 void ExportMeshToFile( int theCommandID )
291 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
292 SALOME_ListIO selected;
294 aSel->selectedObjects( selected );
296 // actually, the following condition can't be met (added for insurance)
297 if( selected.Extent() == 0 ||
298 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
301 bool hasDuplicatedMeshNames = false;
302 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
303 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
304 SALOME_ListIteratorOfListIO It( selected );
305 for( ; It.More(); It.Next() ) {
306 Handle(SALOME_InteractiveObject) anIObject = It.Value();
307 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
308 if ( aMeshItem->_is_nil() ) {
309 SUIT_MessageBox::warning( SMESHGUI::desktop(),
310 QObject::tr( "SMESH_WRN_WARNING" ),
311 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
315 QString aMeshName = anIObject->getName();
317 // check for duplications
318 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
319 if( aMeshName == (*aMeshIter).second ) {
320 hasDuplicatedMeshNames = true;
325 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
328 if( hasDuplicatedMeshNames ) {
329 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
330 QObject::tr("SMESH_WRN_WARNING"),
331 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
332 QObject::tr("SMESH_BUT_YES"),
333 QObject::tr("SMESH_BUT_NO"), 0, 1);
338 aMeshIter = aMeshList.begin();
339 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
340 QString aMeshName = (*aMeshIter).second;
342 QList<SALOMEDS::Color> aReservedColors;
344 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
345 QMap<QString, SMESH::MED_VERSION> aFilterMap;
346 QMap<QString, int> aFilterMapSTL;
347 switch ( theCommandID ) {
351 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
352 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
353 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
354 int aRet = SUIT_MessageBox::warning
355 (SMESHGUI::desktop(),
356 QObject::tr("SMESH_WRN_WARNING"),
357 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
358 QObject::tr("SMESH_BUT_YES"),
359 QObject::tr("SMESH_BUT_NO"), 0, 1);
365 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
366 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
367 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
368 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
373 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
378 if (aMesh->NbPyramids()) {
379 int aRet = SUIT_MessageBox::warning
380 (SMESHGUI::desktop(),
381 QObject::tr("SMESH_WRN_WARNING"),
382 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
383 QObject::tr("SMESH_BUT_YES"),
384 QObject::tr("SMESH_BUT_NO"), 0, 1);
388 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
396 there must be check on others mesh elements not equal triangles
398 if (aMesh->NbTriangles() < 1) {
399 SUIT_MessageBox::warning
400 (SMESHGUI::desktop(),
401 QObject::tr("SMESH_WRN_WARNING"),
402 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
405 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
406 int aRet = SUIT_MessageBox::warning
407 (SMESHGUI::desktop(),
408 QObject::tr("SMESH_WRN_WARNING"),
409 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
410 QObject::tr("SMESH_BUT_YES"),
411 QObject::tr("SMESH_BUT_NO"), 0, 1);
416 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
417 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
425 SMESH::MED_VERSION aFormat;
426 // Init the parameter with the default value
427 bool aIsASCII_STL = true;
428 bool toCreateGroups = false;
429 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
431 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
432 bool toOverwrite = true;
434 QString anInitialPath = "";
435 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
436 anInitialPath = QDir::currentPath();
438 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
439 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
440 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
441 aFilter, aTitle, false);
443 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
445 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
446 for ( ; it != aFilterMapSTL.end(); ++it )
447 filters.push_back( it.key() );
449 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
450 fd->setWindowTitle( aTitle );
451 fd->setNameFilters( filters );
452 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
453 if ( !anInitialPath.isEmpty() )
454 fd->setDirectory( anInitialPath );
455 fd->selectFile(aMeshName);
459 aFilename = fd->selectedFile();
460 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
465 else { // Export to MED
467 QString aDefaultFilter;
468 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
469 for ( ; it != aFilterMap.end(); ++it ) {
470 filters.push_back( it.key() );
471 if (it.value() == SMESH::MED_V2_2)
472 aDefaultFilter = it.key();
475 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
476 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
477 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
478 fd->setWindowTitle( aTitle );
479 fd->setNameFilters( filters );
480 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
481 fd->selectNameFilter(aDefaultFilter);
482 fd->SetChecked(toCreateGroups);
483 if ( !anInitialPath.isEmpty() )
484 fd->setDirectory( anInitialPath );
485 fd->selectFile(aMeshName);
487 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
488 fd->setValidator( fv );
493 aFilename = fd->selectedFile();
495 aFilename = QString::null;
498 aFormat = aFilterMap[fd->selectedNameFilter()];
499 toOverwrite = fv->isOverwrite();
501 if ( !aFilename.isEmpty() ) {
502 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
503 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
504 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
505 && aFormat==SMESH::MED_V2_1) {
506 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
507 QObject::tr("SMESH_WRN_WARNING"),
508 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
509 QObject::tr("SMESH_BUT_YES"),
510 QObject::tr("SMESH_BUT_NO"), 0, 1);
518 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
519 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
520 if( !isVersionOk || aVersion != aFormat ) {
521 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
522 QObject::tr("SMESH_WRN_WARNING"),
523 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
524 QObject::tr("SMESH_BUT_YES"),
525 QObject::tr("SMESH_BUT_NO"), 0, 1);
532 QStringList aMeshNamesCollisionList;
533 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
534 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
535 QString anExistingMeshName( aMeshNames[ i ] );
536 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
537 QString anExportMeshName = (*aMeshIter).second;
538 if( anExportMeshName == anExistingMeshName ) {
539 aMeshNamesCollisionList.append( anExportMeshName );
545 if( !aMeshNamesCollisionList.isEmpty() ) {
546 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
547 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
548 QObject::tr("SMESH_WRN_WARNING"),
549 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
550 QObject::tr("SMESH_BUT_YES"),
551 QObject::tr("SMESH_BUT_NO"),
552 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
561 toCreateGroups = fd->IsChecked();
564 if ( !aFilename.isEmpty() ) {
565 // Check whether the file already exists and delete it if yes
566 QFile aFile( aFilename );
567 if ( aFile.exists() && toOverwrite )
569 SUIT_OverrideCursor wc;
572 bool Renumber = false;
573 // PAL 14172 : Check of we have to renumber or not from the preferences before export
575 Renumber= resMgr->booleanValue("SMESH","renumbering");
577 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
578 aMeshEditor->RenumberNodes();
579 aMeshEditor->RenumberElements();
580 if ( SMESHGUI::automaticUpdate() )
583 switch ( theCommandID ) {
587 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
588 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
589 if( !aMeshItem->_is_nil() )
590 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
596 aMesh->ExportDAT( aFilename.toLatin1().data() );
600 aMesh->ExportUNV( aFilename.toLatin1().data() );
604 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
610 catch (const SALOME::SALOME_Exception& S_ex){
612 SUIT_MessageBox::warning(SMESHGUI::desktop(),
613 QObject::tr("SMESH_WRN_WARNING"),
614 QObject::tr("SMESH_EXPORT_FAILED"));
620 inline void InverseEntityMode(unsigned int& theOutputMode,
621 unsigned int theMode)
623 bool anIsNotPresent = ~theOutputMode & theMode;
625 theOutputMode |= theMode;
627 theOutputMode &= ~theMode;
630 void SetDisplayEntity(int theCommandID){
631 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
632 SALOME_ListIO selected;
634 aSel->selectedObjects( selected );
636 if(selected.Extent() >= 1){
637 SALOME_ListIteratorOfListIO It( selected );
638 for( ; It.More(); It.Next()){
639 Handle(SALOME_InteractiveObject) IObject = It.Value();
640 if(IObject->hasEntry()){
641 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
642 unsigned int aMode = anActor->GetEntityMode();
643 switch(theCommandID){
645 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
648 InverseEntityMode(aMode,SMESH_Actor::eEdges);
651 InverseEntityMode(aMode,SMESH_Actor::eFaces);
654 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
657 aMode = SMESH_Actor::eAllEntity;
661 anActor->SetEntityMode(aMode);
669 SALOME_ListIO selected;
670 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
674 LightApp_SelectionMgr* aSel = app->selectionMgr();
675 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
676 if( !aSel || !appStudy )
679 aSel->selectedObjects( selected );
680 if( selected.IsEmpty() )
683 Handle(SALOME_InteractiveObject) anIObject = selected.First();
685 _PTR(Study) aStudy = appStudy->studyDS();
686 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
687 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
688 if( aMainObject->_is_nil() )
691 aMainObject->SetAutoColor( true );
693 QList<SALOMEDS::Color> aReservedColors;
695 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
696 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
698 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
699 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
701 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
702 aGroupObject->SetColor( aColor );
703 aReservedColors.append( aColor );
705 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
707 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
708 if( aGroupObject->GetType() == SMESH::NODE )
709 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
710 else if( aGroupObject->GetType() == SMESH::EDGE )
711 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
712 else if( aGroupObject->GetType() == SMESH::ELEM0D )
713 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
715 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
720 SMESH::RepaintCurrentView();
723 QString functorToString( SMESH::Controls::FunctorPtr f )
725 QString type = QObject::tr( "UNKNOWN_CONTROL" );
726 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
727 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
728 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
729 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
730 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
731 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
732 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
733 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
734 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
735 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
736 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
737 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
738 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
739 type = QObject::tr( "WARP_ELEMENTS" );
740 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
741 type = QObject::tr( "TAPER_ELEMENTS" );
742 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
743 type = QObject::tr( "SKEW_ELEMENTS" );
744 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
745 type = QObject::tr( "AREA_ELEMENTS" );
746 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
747 type = QObject::tr( "LENGTH_EDGES" );
748 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
749 type = QObject::tr( "LENGTH2D_EDGES" );
750 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
751 type = QObject::tr( "MULTI_BORDERS" );
752 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
753 type = QObject::tr( "MULTI2D_BORDERS" );
754 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
755 type = QObject::tr( "FREE_NODES" );
756 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
757 type = QObject::tr( "FREE_EDGES" );
758 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
759 type = QObject::tr( "FREE_BORDERS" );
760 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
761 type = QObject::tr( "FREE_FACES" );
765 void SaveDistribution()
767 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
768 SALOME_ListIO selected;
770 aSel->selectedObjects( selected );
772 if ( selected.Extent() == 1 ) {
773 Handle(SALOME_InteractiveObject) anIO = selected.First();
774 if ( anIO->hasEntry() ) {
775 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
776 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
777 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
778 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
779 if ( aScalarBarActor && aFunctor ) {
780 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
782 int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
783 std::vector<int> nbEvents;
784 std::vector<double> funValues;
785 aNumFun->GetHistogram( nbRanges, nbEvents, funValues );
786 QString anInitialPath = "";
787 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
788 anInitialPath = QDir::currentPath();
789 QString aMeshName = anIO->getName();
791 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
792 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
793 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
794 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
795 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
798 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
800 if ( !aFilename.isEmpty() ) {
801 QFile f( aFilename );
802 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
803 QTextStream out( &f );
804 out << "# Mesh: " << aMeshName << endl;
805 out << "# Control: " << functorToString( aFunctor ) << endl;
807 out.setFieldWidth( 10 );
808 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
809 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
820 void ShowDistribution() {
821 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
822 SALOME_ListIO selected;
824 aSel->selectedObjects( selected );
826 if ( selected.Extent() == 1 ) {
827 Handle(SALOME_InteractiveObject) anIO = selected.First();
828 if ( anIO->hasEntry() ) {
829 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
830 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
831 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
832 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
838 void DisableAutoColor(){
839 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
840 SALOME_ListIO selected;
842 aSel->selectedObjects( selected );
844 if(selected.Extent()){
845 Handle(SALOME_InteractiveObject) anIObject = selected.First();
846 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
847 if ( !aMesh->_is_nil() ) {
848 aMesh->SetAutoColor( false );
853 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
854 SALOME_ListIO selected;
855 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
859 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
860 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
861 if( !aSel || !appStudy )
864 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
865 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
866 aModule->EmitSignalDeactivateDialog();
867 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
868 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
873 _PTR(Study) aStudy = appStudy->studyDS();
875 aSel->selectedObjects( selected );
877 if(selected.Extent() >= 1){
878 switch(theCommandID){
880 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
881 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
885 QColor c, e, b, n, c0D, o;
888 vtkFloatingPointType Shrink = 0.0;
889 vtkFloatingPointType faces_orientation_scale = 0.0;
890 bool faces_orientation_3dvectors = false;
892 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
893 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
894 int aMarkerTextureCurrent = 0;
896 SALOME_ListIteratorOfListIO It( selected );
897 for( ; It.More(); It.Next()){
898 Handle(SALOME_InteractiveObject) IObject = It.Value();
899 if(IObject->hasEntry()){
900 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
901 vtkFloatingPointType color[3];
902 anActor->GetSufaceColor(color[0], color[1], color[2]);
903 int c0 = int (color[0] * 255);
904 int c1 = int (color[1] * 255);
905 int c2 = int (color[2] * 255);
906 c.setRgb(c0, c1, c2);
908 vtkFloatingPointType edgecolor[3];
909 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
910 c0 = int (edgecolor[0] * 255);
911 c1 = int (edgecolor[1] * 255);
912 c2 = int (edgecolor[2] * 255);
913 e.setRgb(c0, c1, c2);
915 vtkFloatingPointType backfacecolor[3];
916 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
917 c0 = int (backfacecolor[0] * 255);
918 c1 = int (backfacecolor[1] * 255);
919 c2 = int (backfacecolor[2] * 255);
920 b.setRgb(c0, c1, c2);
922 vtkFloatingPointType nodecolor[3];
923 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
924 c0 = int (nodecolor[0] * 255);
925 c1 = int (nodecolor[1] * 255);
926 c2 = int (nodecolor[2] * 255);
927 n.setRgb(c0, c1, c2);
929 vtkFloatingPointType color0D[3];
930 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
931 c0 = int (color0D[0] * 255);
932 c1 = int (color0D[1] * 255);
933 c2 = int (color0D[2] * 255);
934 c0D.setRgb(c0, c1, c2);
936 size0D = (int)anActor->Get0DSize();
939 Edgewidth = (int)anActor->GetLineWidth();
942 Shrink = anActor->GetShrinkFactor();
944 vtkFloatingPointType faces_orientation_color[3];
945 anActor->GetFacesOrientationColor(faces_orientation_color);
946 c0 = int (faces_orientation_color[0] * 255);
947 c1 = int (faces_orientation_color[1] * 255);
948 c2 = int (faces_orientation_color[2] * 255);
949 o.setRgb(c0, c1, c2);
951 faces_orientation_scale = anActor->GetFacesOrientationScale();
952 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
954 aMarkerTypeCurrent = anActor->GetMarkerType();
955 aMarkerScaleCurrent = anActor->GetMarkerScale();
956 aMarkerTextureCurrent = anActor->GetMarkerTexture();
958 // even if there are multiple objects in the selection,
959 // we need only the first one to get values for the dialog
965 SMESHGUI_Preferences_ColorDlg *aDlg =
966 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
967 aDlg->SetColor(1, c);
968 aDlg->SetColor(2, e);
969 aDlg->SetColor(3, n);
970 aDlg->SetColor(4, b);
971 aDlg->SetColor(5, c0D);
972 aDlg->SetColor(6, o);
973 aDlg->SetIntValue(1, Edgewidth);
974 aDlg->SetIntValue(2, int(Shrink*100.));
975 aDlg->SetIntValue(3, size0D);
976 aDlg->SetDoubleValue(1, faces_orientation_scale);
977 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
979 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
981 if( aMarkerTypeCurrent != VTK::MT_USER )
982 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
984 aDlg->setCustomMarker( aMarkerTextureCurrent );
987 QColor color = aDlg->GetColor(1);
988 QColor edgecolor = aDlg->GetColor(2);
989 QColor nodecolor = aDlg->GetColor(3);
990 QColor backfacecolor = aDlg->GetColor(4);
991 QColor color0D = aDlg->GetColor(5);
992 QColor faces_orientation_color = aDlg->GetColor(6);
995 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
997 SALOME_ListIteratorOfListIO It( selected );
998 for( ; It.More(); It.Next()){
999 Handle(SALOME_InteractiveObject) IObject = It.Value();
1000 if(IObject->hasEntry()){
1001 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1002 /* actor color and backface color */
1003 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1004 vtkFloatingPointType (color.green()) / 255.,
1005 vtkFloatingPointType (color.blue()) / 255.);
1006 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1007 vtkFloatingPointType (backfacecolor.green()) / 255.,
1008 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1011 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1012 vtkFloatingPointType (edgecolor.green()) / 255.,
1013 vtkFloatingPointType (edgecolor.blue()) / 255.);
1015 /* Shrink factor and size edges */
1016 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1017 anActor->SetLineWidth(aDlg->GetIntValue(1));
1019 /* Nodes color and size */
1020 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1021 vtkFloatingPointType (nodecolor.green()) / 255.,
1022 vtkFloatingPointType (nodecolor.blue()) / 255.);
1025 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1026 vtkFloatingPointType (color0D.green()) / 255.,
1027 vtkFloatingPointType (color0D.blue()) / 255.);
1028 anActor->Set0DSize(aDlg->GetIntValue(3));
1030 /* Faces orientation */
1031 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1032 vtkFloatingPointType(faces_orientation_color.greenF()),
1033 vtkFloatingPointType(faces_orientation_color.blueF())};
1034 anActor->SetFacesOrientationColor(c);
1035 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1036 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1038 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1039 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1040 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1041 if( aMarkerTypeNew != VTK::MT_USER )
1042 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1044 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1045 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1046 if( anIter != aMarkerMap.end() )
1047 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1050 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1051 if( !aGroupObject->_is_nil() )
1053 SMESH::ElementType anElementType = aGroupObject->GetType();
1055 switch( anElementType )
1057 case SMESH::NODE: aColor = nodecolor; break;
1058 case SMESH::EDGE: aColor = edgecolor; break;
1059 default: aColor = color; break;
1062 SALOMEDS::Color aGroupColor;
1063 aGroupColor.R = (float)aColor.red() / 255.0;
1064 aGroupColor.G = (float)aColor.green() / 255.0;
1065 aGroupColor.B = (float)aColor.blue() / 255.0;
1066 aGroupObject->SetColor( aGroupColor );
1071 SMESH::RepaintCurrentView();
1077 SALOME_ListIteratorOfListIO It( selected );
1078 for( ; It.More(); It.Next()){
1079 Handle(SALOME_InteractiveObject) IObject = It.Value();
1080 if(IObject->hasEntry()){
1081 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1082 switch(theCommandID){
1084 anActor->SetRepresentation(SMESH_Actor::eEdge);
1087 anActor->SetRepresentation(SMESH_Actor::eSurface);
1090 if(anActor->IsShrunk())
1091 anActor->UnShrink();
1093 anActor->SetShrink();
1096 anActor->SetRepresentation(SMESH_Actor::ePoint);
1099 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1100 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1103 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1104 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1110 SMESH::RepaintCurrentView();
1114 void Control( int theCommandID )
1116 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1117 SALOME_ListIO selected;
1119 aSel->selectedObjects( selected );
1121 if( !selected.IsEmpty() ){
1122 Handle(SALOME_InteractiveObject) anIO = selected.First();
1124 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1125 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1126 switch ( theCommandID ){
1128 aControl = SMESH_Actor::eLength;
1131 aControl = SMESH_Actor::eLength2D;
1134 aControl = SMESH_Actor::eFreeEdges;
1137 aControl = SMESH_Actor::eFreeBorders;
1140 aControl = SMESH_Actor::eMultiConnection;
1143 aControl = SMESH_Actor::eFreeNodes;
1146 aControl = SMESH_Actor::eMultiConnection2D;
1149 aControl = SMESH_Actor::eArea;
1152 aControl = SMESH_Actor::eTaper;
1155 aControl = SMESH_Actor::eAspectRatio;
1158 aControl = SMESH_Actor::eAspectRatio3D;
1161 aControl = SMESH_Actor::eMinimumAngle;
1164 aControl = SMESH_Actor::eWarping;
1167 aControl = SMESH_Actor::eSkew;
1170 aControl = SMESH_Actor::eVolume3D;
1173 aControl = SMESH_Actor::eFreeFaces;
1176 aControl = SMESH_Actor::eMaxElementLength2D;
1179 aControl = SMESH_Actor::eMaxElementLength3D;
1182 anActor->SetControlMode(aControl);
1183 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1184 SMESH::RepaintCurrentView();
1191 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1192 MeshObjectType theType,
1193 const QString theInTypeName,
1194 QString & theOutTypeName)
1196 SMESH_TypeFilter aTypeFilter( theType );
1198 if( !theIO.IsNull() )
1200 entry = theIO->getEntry();
1201 LightApp_DataOwner owner( entry );
1202 if ( aTypeFilter.isOk( &owner )) {
1203 theOutTypeName = theInTypeName;
1211 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1213 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1214 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1216 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1217 CORBA::String_var anID = aSComp->GetID().c_str();
1218 if (!strcmp(anID.in(),theIO->getEntry()))
1224 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1225 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1226 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1227 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1228 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1236 QString CheckHomogeneousSelection()
1238 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1239 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1240 SALOME_ListIO selected;
1242 aSel->selectedObjects( selected );
1244 QString RefType = CheckTypeObject(selected.First());
1245 SALOME_ListIteratorOfListIO It(selected);
1246 for ( ; It.More(); It.Next())
1248 Handle(SALOME_InteractiveObject) IObject = It.Value();
1249 QString Type = CheckTypeObject(IObject);
1250 if (Type.compare(RefType) != 0)
1251 return "Heterogeneous Selection";
1258 void SMESHGUI::OnEditDelete()
1260 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1261 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1262 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1264 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1265 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1266 _PTR(GenericAttribute) anAttr;
1267 _PTR(AttributeIOR) anIOR;
1269 int objectCount = 0;
1271 QString aParentComponent = QString::null;
1272 Handle(SALOME_InteractiveObject) anIO;
1273 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1275 anIO = anIt.Value();
1276 QString cur = anIO->getComponentDataType();
1277 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1279 // check if object is reference
1280 _PTR(SObject) aRefSObj;
1281 aNameList.append("\n - ");
1282 if ( aSO->ReferencedObject( aRefSObj ) ) {
1283 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1284 aNameList.append( aRefName );
1285 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1288 aNameList.append(anIO->getName());
1292 if( aParentComponent.isNull() )
1293 aParentComponent = cur;
1294 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1295 aParentComponent = "";
1298 if ( objectCount == 0 )
1299 return; // No Valid Objects Selected
1301 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1302 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1303 QObject::tr("ERR_ERROR"),
1304 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1307 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1308 if (SUIT_MessageBox::warning
1309 (SMESHGUI::desktop(),
1310 QObject::tr("SMESH_WRN_WARNING"),
1311 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1312 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1313 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1316 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1317 SUIT_ViewManager* vm = anApp->activeViewManager();
1318 int nbSf = vm ? vm->getViewsCount() : 0;
1320 SALOME_ListIteratorOfListIO It(selected);
1322 aStudyBuilder->NewCommand(); // There is a transaction
1323 for( ; It.More(); It.Next()){ // loop on selected IO's
1324 Handle(SALOME_InteractiveObject) IObject = It.Value();
1325 if(IObject->hasEntry()) {
1326 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1328 // disable removal of "SMESH" component object
1329 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1331 if ( engineIOR() == anIOR->Value().c_str() )
1334 //Check the referenced object
1335 _PTR(SObject) aRefSObject;
1336 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1337 aSO = aRefSObject; // Delete main Object instead of reference
1339 // put the whole hierarchy of sub-objects of the selected SO into a list and
1340 // then treat them all starting from the deepest objects (at list back)
1342 std::list< _PTR(SObject) > listSO;
1343 listSO.push_back( aSO );
1344 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1345 for ( ; itSO != listSO.end(); ++itSO ) {
1346 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1347 for (it->InitEx(false); it->More(); it->Next())
1348 listSO.push_back( it->Value() );
1351 // treat SO's in the list starting from the back
1353 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1354 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1355 _PTR(SObject) SO = *ritSO;
1356 if ( !SO ) continue;
1357 std::string anEntry = SO->GetID();
1359 /** Erase graphical object **/
1360 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1361 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1362 for(int i = 0; i < nbSf; i++){
1363 SUIT_ViewWindow *sf = aViews[i];
1364 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1365 SMESH::RemoveActor(sf,anActor);
1370 /** Remove an object from data structures **/
1371 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1372 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1373 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1374 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1375 aMesh->RemoveGroup( aGroup );
1377 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1378 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1379 aMesh->RemoveSubMesh( aSubMesh );
1381 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1383 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1386 IObject = new SALOME_InteractiveObject
1387 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1388 QString objType = CheckTypeObject(IObject);
1389 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1390 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1391 aStudyBuilder->RemoveObjectWithChildren( SO );
1393 else {// default action: remove SObject from the study
1394 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1395 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1397 aStudyBuilder->RemoveObjectWithChildren( SO );
1401 } /* listSO back loop */
1402 } /* IObject->hasEntry() */
1404 aStudyBuilder->CommitCommand();
1406 /* Clear any previous selection */
1408 aSel->setSelectedObjects( l1 );
1410 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1415 SMESHGUI_EXPORT CAM_Module* createModule()
1417 return new SMESHGUI();
1421 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1423 //=============================================================================
1427 //=============================================================================
1428 SMESHGUI::SMESHGUI() :
1429 SalomeApp_Module( "SMESH" ),
1430 LightApp_Module( "SMESH" )
1432 if ( CORBA::is_nil( myComponentSMESH ) )
1434 CORBA::Boolean anIsEmbeddedMode;
1435 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1436 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1438 // 0019923: EDF 765 SMESH : default values of hypothesis
1439 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1440 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1441 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1442 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1443 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1446 myActiveDialogBox = 0;
1447 myFilterLibraryDlg = 0;
1451 myEventCallbackCommand = vtkCallbackCommand::New();
1452 myEventCallbackCommand->Delete();
1453 myEventCallbackCommand->SetClientData( this );
1454 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1457 SMESH::GetFilterManager();
1458 SMESH::GetPattern();
1459 SMESH::GetMeasurements();
1461 /* load resources for all available meshers */
1462 SMESH::InitAvailableHypotheses();
1465 //=============================================================================
1469 //=============================================================================
1470 SMESHGUI::~SMESHGUI()
1472 #ifdef WITHGENERICOBJ
1473 SMESH::GetFilterManager()->Destroy();
1474 SMESH::GetMeasurements()->Destroy();
1476 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1477 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1480 //=============================================================================
1484 //=============================================================================
1485 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1487 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1489 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1494 //=============================================================================
1498 //=============================================================================
1499 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1501 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1505 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1506 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1507 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1508 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1509 return autoUpdate && !exceeded;
1512 //=============================================================================
1516 //=============================================================================
1517 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1519 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1522 //=============================================================================
1526 //=============================================================================
1527 SMESHGUI* SMESHGUI::GetSMESHGUI()
1529 SMESHGUI* smeshMod = 0;
1530 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1533 CAM_Module* module = app->module( "Mesh" );
1534 smeshMod = dynamic_cast<SMESHGUI*>( module );
1537 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1539 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1542 _PTR(Study) aStudy = study->studyDS();
1544 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1553 Standard_EXPORT SMESHGUI* GetComponentGUI()
1555 return SMESHGUI::GetSMESHGUI();
1559 //=============================================================================
1563 //=============================================================================
1564 void SMESHGUI::SetState(int aState)
1569 //=============================================================================
1573 //=============================================================================
1574 void SMESHGUI::ResetState()
1579 //=============================================================================
1583 //=============================================================================
1584 void SMESHGUI::EmitSignalDeactivateDialog()
1586 emit SignalDeactivateActiveDialog();
1589 //=============================================================================
1593 //=============================================================================
1594 void SMESHGUI::EmitSignalStudyFrameChanged()
1596 emit SignalStudyFrameChanged();
1599 //=============================================================================
1603 //=============================================================================
1604 void SMESHGUI::EmitSignalCloseAllDialogs()
1606 emit SignalCloseAllDialogs();
1609 //=============================================================================
1613 //=============================================================================
1614 void SMESHGUI::EmitSignalVisibilityChanged()
1616 emit SignalVisibilityChanged();
1619 //=============================================================================
1623 //=============================================================================
1624 QDialog *SMESHGUI::GetActiveDialogBox()
1626 return myActiveDialogBox;
1629 //=============================================================================
1633 //=============================================================================
1634 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1636 myActiveDialogBox = (QDialog *) aDlg;
1640 //=============================================================================
1644 //=============================================================================
1645 SUIT_Desktop* SMESHGUI::desktop()
1647 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1649 return app->desktop();
1654 //=============================================================================
1658 //=============================================================================
1659 SalomeApp_Study* SMESHGUI::activeStudy()
1661 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1663 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1668 //=============================================================================
1672 //=============================================================================
1673 void SMESHGUI::Modified( bool theIsUpdateActions )
1675 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1676 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1677 appStudy->Modified();
1678 if( theIsUpdateActions )
1679 app->updateActions();
1684 //=============================================================================
1688 //=============================================================================
1689 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1691 /* Here the position is on the bottom right corner - 10 */
1692 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1694 SUIT_Desktop *PP = desktop();
1695 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1696 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1700 //=============================================================================
1704 //=============================================================================
1705 static int isStudyLocked(_PTR(Study) theStudy){
1706 return theStudy->GetProperties()->IsLocked();
1709 static bool checkLock(_PTR(Study) theStudy) {
1710 if (isStudyLocked(theStudy)) {
1711 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1712 QObject::tr("WRN_WARNING"),
1713 QObject::tr("WRN_STUDY_LOCKED") );
1719 //=======================================================================
1720 //function : CheckActiveStudyLocked
1722 //=======================================================================
1724 bool SMESHGUI::isActiveStudyLocked()
1726 _PTR(Study) aStudy = activeStudy()->studyDS();
1727 return checkLock( aStudy );
1730 //=============================================================================
1734 //=============================================================================
1735 bool SMESHGUI::OnGUIEvent( int theCommandID )
1737 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1741 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1742 SUIT_ResourceMgr* mgr = resourceMgr();
1746 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1747 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1750 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1751 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1753 //QAction* act = action( theCommandID );
1755 switch (theCommandID) {
1757 if(checkLock(aStudy)) break;
1765 if(checkLock(aStudy)) break;
1766 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1770 case 150: //MED FILE INFORMATION
1772 SALOME_ListIO selected;
1773 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1775 aSel->selectedObjects( selected );
1776 if( selected.Extent() )
1778 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1779 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1780 if ( !aMesh->_is_nil() )
1782 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1789 case 122: // EXPORT MED
1798 ::ExportMeshToFile(theCommandID);
1802 case 200: // SCALAR BAR
1804 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1805 SALOME_ListIO selected;
1807 aSel->selectedObjects( selected );
1809 if( selected.Extent() ) {
1810 Handle(SALOME_InteractiveObject) anIO = selected.First();
1811 if( anIO->hasEntry() ) {
1812 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1813 anActor->SetControlMode( SMESH_Actor::eNone );
1821 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1826 // dump control distribution data to the text file
1827 ::SaveDistribution();
1833 // show/ distribution
1834 ::ShowDistribution();
1844 ::DisableAutoColor();
1847 case 1134: // Clipping
1848 case 1133: // Tranparency
1849 case 1132: // Colors / Size
1856 ::SetDisplayMode(theCommandID, myMarkerMap);
1859 //2D quadratic representation
1862 ::SetDisplayMode(theCommandID, myMarkerMap);
1866 case 216: // 0D elements
1869 case 219: // Volumes
1870 case 220: // All Entity
1871 ::SetDisplayEntity(theCommandID);
1874 case 221: // Orientation of faces
1876 LightApp_SelectionMgr* mgr = selectionMgr();
1877 SALOME_ListIO selected; mgr->selectedObjects( selected );
1879 SALOME_ListIteratorOfListIO it(selected);
1880 for( ; it.More(); it.Next()) {
1881 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1882 if(anIObject->hasEntry()) {
1883 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1884 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1893 if(checkLock(aStudy)) break;
1895 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1898 SMESH::UpdateView();
1900 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1901 SMESH::OnVisuException();
1903 catch (...) { // PAL16774 (Crash after display of many groups)
1904 SMESH::OnVisuException();
1908 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1909 aSel->selectedObjects( l );
1910 aSel->setSelectedObjects( l );
1915 case 301: // DISPLAY
1916 case 302: // DISPLAY ONLY
1918 SMESH::EDisplaing anAction;
1919 switch (theCommandID) {
1920 case 300: anAction = SMESH::eErase; break;
1921 case 301: anAction = SMESH::eDisplay; break;
1922 case 302: anAction = SMESH::eDisplayOnly; break;
1925 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1926 SALOME_ListIO sel_objects, to_process;
1928 aSel->selectedObjects( sel_objects );
1930 if( theCommandID==302 )
1932 MESSAGE("anAction = SMESH::eDisplayOnly");
1933 startOperation( myEraseAll );
1936 extractContainers( sel_objects, to_process );
1939 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1943 SALOME_ListIteratorOfListIO It( to_process );
1944 for ( ; It.More(); It.Next()) {
1946 Handle(SALOME_InteractiveObject) IOS = It.Value();
1947 if (IOS->hasEntry()) {
1949 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1950 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1951 break; // PAL16774 (Crash after display of many groups)
1953 if (anAction == SMESH::eDisplayOnly)
1955 MESSAGE("anAction = SMESH::eDisplayOnly");
1956 anAction = SMESH::eDisplay;
1962 // PAL13338 + PAL15161 -->
1963 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1964 MESSAGE("anAction = SMESH::eDisplayOnly");
1965 SMESH::UpdateView();
1966 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1968 // PAL13338 + PAL15161 <--
1970 catch (...) { // PAL16774 (Crash after display of many groups)
1971 SMESH::OnVisuException();
1974 if (anAction == SMESH::eErase) {
1975 MESSAGE("anAction == SMESH::eErase");
1977 aSel->setSelectedObjects( l1 );
1980 aSel->setSelectedObjects( to_process );
1987 if(checkLock(aStudy)) break;
1990 EmitSignalDeactivateDialog();
1992 ( new SMESHGUI_NodesDlg( this ) )->show();
1995 SUIT_MessageBox::warning(desktop(),
1996 tr("SMESH_WRN_WARNING"),
1997 tr("SMESH_WRN_VIEWER_VTK"));
2002 case 2151: // FILTER
2006 EmitSignalDeactivateDialog();
2007 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2012 case 701: // COMPUTE MESH
2013 case 711: // PRECOMPUTE MESH
2014 case 712: // EVALUATE MESH
2015 case 713: // MESH ORDER
2017 if (checkLock(aStudy)) break;
2018 startOperation( theCommandID );
2022 case 702: // Create mesh
2023 case 703: // Create sub-mesh
2024 case 704: // Edit mesh/sub-mesh
2025 startOperation( theCommandID );
2027 case 710: // Build compound mesh
2029 if (checkLock(aStudy)) break;
2030 EmitSignalDeactivateDialog();
2031 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2035 case 407: // DIAGONAL INVERSION
2036 case 408: // Delete diagonal
2040 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2041 tr( "NOT_A_VTK_VIEWER" ) );
2045 if ( checkLock( aStudy ) )
2048 /*Standard_Boolean aRes;
2049 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2050 if ( aMesh->_is_nil() )
2052 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2053 tr( "SMESH_BAD_SELECTION" ) );
2057 EmitSignalDeactivateDialog();
2058 if ( theCommandID == 407 )
2059 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2061 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2064 case 409: // Change orientation
2065 case 410: // Union of triangles
2066 case 411: // Cutting of quadrangles
2067 case 419: // Splitting volumes into tetrahedra
2071 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2072 tr( "NOT_A_VTK_VIEWER" ) );
2076 if ( checkLock( aStudy ) )
2079 EmitSignalDeactivateDialog();
2080 SMESHGUI_MultiEditDlg* aDlg = NULL;
2081 if ( theCommandID == 409 )
2082 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2083 else if ( theCommandID == 410 )
2084 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2085 else if ( theCommandID == 419 )
2086 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2088 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2093 case 412: // Smoothing
2095 if(checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2101 SUIT_MessageBox::warning(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2106 case 413: // Extrusion
2108 if (checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2113 SUIT_MessageBox::warning(desktop(),
2114 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2118 case 414: // Revolution
2120 if(checkLock(aStudy)) break;
2122 EmitSignalDeactivateDialog();
2123 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2126 SUIT_MessageBox::warning(desktop(),
2127 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2131 case 415: // Pattern mapping
2133 if ( checkLock( aStudy ) )
2137 EmitSignalDeactivateDialog();
2138 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2141 SUIT_MessageBox::warning(desktop(),
2142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2146 case 416: // Extrusion along a path
2148 if (checkLock(aStudy)) break;
2150 EmitSignalDeactivateDialog();
2151 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2153 SUIT_MessageBox::warning(desktop(),
2154 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2158 case 417: // Convert mesh to quadratic
2160 startOperation( 417 );
2161 /* if (checkLock(aStudy)) break;
2163 EmitSignalDeactivateDialog();
2164 new SMESHGUI_ConvToQuadDlg();
2166 SUIT_MessageBox::warning(desktop(),
2167 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2171 case 418: // create 2D mesh from 3D
2173 startOperation( 418 );
2176 case 806: // CREATE GEO GROUP
2178 startOperation( 806 );
2181 case 801: // CREATE GROUP
2185 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2186 tr( "NOT_A_VTK_VIEWER" ) );
2190 if(checkLock(aStudy)) break;
2191 EmitSignalDeactivateDialog();
2192 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2194 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2195 SALOME_ListIO selected;
2197 aSel->selectedObjects( selected );
2199 int nbSel = selected.Extent();
2201 // check if mesh is selected
2202 aMesh = SMESH::GetMeshByIO( selected.First() );
2204 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2209 case 802: // CONSTRUCT GROUP
2213 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2214 tr( "NOT_A_VTK_VIEWER" ) );
2218 if(checkLock(aStudy)) break;
2219 EmitSignalDeactivateDialog();
2221 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2222 SALOME_ListIO selected;
2224 aSel->selectedObjects( selected );
2226 int nbSel = selected.Extent();
2228 // check if submesh is selected
2229 Handle(SALOME_InteractiveObject) IObject = selected.First();
2230 if (IObject->hasEntry()) {
2231 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2233 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2234 if (!aSubMesh->_is_nil()) {
2236 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2237 // get submesh elements list by types
2238 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2239 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2240 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2241 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2242 // create group for each type o elements
2243 QString aName = IObject->getName();
2244 if (aNodes->length() > 0) {
2245 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2246 aGroup->Add(aNodes.inout());
2248 if (aEdges->length() > 0) {
2249 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2250 aGroup->Add(aEdges.inout());
2252 if (aFaces->length() > 0) {
2253 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2254 aGroup->Add(aFaces.inout());
2256 if (aVolumes->length() > 0) {
2257 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2258 aGroup->Add(aVolumes.inout());
2263 catch(const SALOME::SALOME_Exception & S_ex){
2264 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2271 SUIT_MessageBox::warning(desktop(),
2272 tr("SMESH_WRN_WARNING"),
2273 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2278 case 803: // EDIT GROUP
2282 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2283 tr( "NOT_A_VTK_VIEWER" ) );
2287 if(checkLock(aStudy)) break;
2288 EmitSignalDeactivateDialog();
2290 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2291 SALOME_ListIO selected;
2293 aSel->selectedObjects( selected );
2295 SALOME_ListIteratorOfListIO It (selected);
2296 int nbSelectedGroups = 0;
2297 for ( ; It.More(); It.Next() )
2299 SMESH::SMESH_GroupBase_var aGroup =
2300 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2301 if (!aGroup->_is_nil()) {
2303 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2307 if (nbSelectedGroups == 0)
2309 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2315 case 804: // Add elements to group
2317 if(checkLock(aStudy)) break;
2318 if (myState == 800) {
2319 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2320 if (aDlg) aDlg->onAdd();
2325 case 805: // Remove elements from group
2327 if(checkLock(aStudy)) break;
2328 if (myState == 800) {
2329 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2330 if (aDlg) aDlg->onRemove();
2335 case 815: // Edit GEOM GROUP as standalone
2339 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2340 tr( "NOT_A_VTK_VIEWER" ) );
2344 if(checkLock(aStudy)) break;
2345 EmitSignalDeactivateDialog();
2347 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2348 SALOME_ListIO selected;
2350 aSel->selectedObjects( selected );
2352 SALOME_ListIteratorOfListIO It (selected);
2353 for ( ; It.More(); It.Next() )
2355 SMESH::SMESH_GroupOnGeom_var aGroup =
2356 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2357 if (!aGroup->_is_nil()) {
2358 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2365 case 810: // Union Groups
2366 case 811: // Intersect groups
2367 case 812: // Cut groups
2371 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2372 tr( "NOT_A_VTK_VIEWER" ) );
2376 if ( checkLock( aStudy ) )
2379 EmitSignalDeactivateDialog();
2381 SMESHGUI_GroupOpDlg* aDlg = 0;
2382 if ( theCommandID == 810 )
2383 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2384 else if ( theCommandID == 811 )
2385 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2387 aDlg = new SMESHGUI_CutGroupsDlg( this );
2394 case 814: // Create groups of entities from existing groups of superior dimensions
2396 if ( checkLock( aStudy ) )
2399 EmitSignalDeactivateDialog();
2400 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2406 case 813: // Delete groups with their contents
2410 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2411 tr( "NOT_A_VTK_VIEWER" ) );
2415 if ( checkLock( aStudy ) )
2418 EmitSignalDeactivateDialog();
2420 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2424 case 900: // MESH INFOS
2425 case 903: // WHAT IS
2427 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2428 EmitSignalDeactivateDialog();
2429 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2430 SALOME_ListIO selected;
2432 aSel->selectedObjects( selected );
2434 if ( selected.Extent() > 1 ) { // a dlg for each IO
2435 SALOME_ListIteratorOfListIO It( selected );
2436 for ( ; It.More(); It.Next() ) {
2437 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2438 dlg->showInfo( It.Value() );
2443 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2449 case 902: // STANDARD MESH INFOS
2451 EmitSignalDeactivateDialog();
2452 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2453 SALOME_ListIO selected;
2455 aSel->selectedObjects( selected );
2457 if ( selected.Extent() > 1 ) { // a dlg for each IO
2459 SALOME_ListIteratorOfListIO It (selected);
2460 for ( ; It.More(); It.Next() ) {
2462 IOs.Append( It.Value() );
2463 aSel->setSelectedObjects( IOs );
2464 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2466 // restore selection
2467 aSel->setSelectedObjects( selected );
2470 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2473 case 903: // WHAT IS
2475 EmitSignalDeactivateDialog();
2476 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2481 case 904: // FIND ELEM
2483 startOperation( theCommandID );
2487 case 1100: // EDIT HYPOTHESIS
2489 if(checkLock(aStudy)) break;
2491 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2492 SALOME_ListIO selected;
2494 aSel->selectedObjects( selected );
2496 int nbSel = selected.Extent();
2499 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2500 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2502 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2503 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2504 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2505 if ( !aHypothesis->_is_nil() )
2508 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2509 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2511 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2522 case 1101: // RENAME
2524 if ( checkLock( aStudy ) )
2527 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2528 SALOME_ListIO selected;
2530 aSel->selectedObjects( selected );
2532 bool isAny = false; // is there any appropriate object selected
2534 SALOME_ListIteratorOfListIO It( selected );
2535 for ( ; It.More(); It.Next() )
2537 Handle(SALOME_InteractiveObject) IObject = It.Value();
2538 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2539 _PTR(GenericAttribute) anAttr;
2540 _PTR(AttributeName) aName;
2543 if ( obj->FindAttribute(anAttr, "AttributeName") )
2546 QString newName = QString(aName->Value().c_str());
2548 // check type to prevent renaming of inappropriate objects
2549 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2550 if (aType == MESH || aType == GROUP ||
2551 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2552 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2553 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2554 aType == HYPOTHESIS || aType == ALGORITHM)
2557 newName = LightApp_NameDlg::getName(desktop(), newName);
2558 if ( !newName.isEmpty() )
2560 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2562 // update name of group object and its actor
2563 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2564 if( !aGroupObject->_is_nil() )
2566 aGroupObject->SetName( newName.toLatin1().data() );
2567 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2568 anActor->setName( newName.toLatin1().data() );
2579 SUIT_MessageBox::warning(desktop(),
2580 QObject::tr("SMESH_WRN_WARNING"),
2581 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2586 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2588 if(checkLock(aStudy)) break;
2589 SUIT_OverrideCursor wc;
2591 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2592 SALOME_ListIO selected;
2594 aSel->selectedObjects( selected, QString::null, false );
2596 SALOME_ListIteratorOfListIO It(selected);
2597 for (int i = 0; It.More(); It.Next(), i++) {
2598 Handle(SALOME_InteractiveObject) IObject = It.Value();
2599 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2602 aSel->setSelectedObjects( l1 );
2607 case 4009: // ELEM0D
2608 case 4010: // GEOM::EDGE
2609 case 4021: // TRIANGLE
2611 case 4023: // POLYGON
2615 if(checkLock(aStudy)) break;
2617 EmitSignalDeactivateDialog();
2618 SMDSAbs_ElementType type = SMDSAbs_Edge;
2620 switch (theCommandID) {
2621 case 4009: // ELEM0D
2622 type = SMDSAbs_0DElement; nbNodes = 1; break;
2623 case 4021: // TRIANGLE
2624 type = SMDSAbs_Face; nbNodes = 3; break;
2626 type = SMDSAbs_Face; nbNodes = 4; break;
2628 type = SMDSAbs_Volume; nbNodes = 4; break;
2629 case 4023: // POLYGON
2630 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2632 type = SMDSAbs_Volume; nbNodes = 8; break;
2633 case 4033: // POLYHEDRE
2634 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2637 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2640 SUIT_MessageBox::warning(desktop(),
2641 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2645 case 4033: // POLYHEDRON
2647 if(checkLock(aStudy)) break;
2649 EmitSignalDeactivateDialog();
2650 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2653 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2654 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2658 case 4034: // QUADRATIC EDGE
2659 case 4035: // QUADRATIC TRIANGLE
2660 case 4036: // QUADRATIC QUADRANGLE
2661 case 4037: // QUADRATIC TETRAHEDRON
2662 case 4038: // QUADRATIC PYRAMID
2663 case 4039: // QUADRATIC PENTAHEDRON
2664 case 4040: // QUADRATIC HEXAHEDRON
2666 if(checkLock(aStudy)) break;
2668 EmitSignalDeactivateDialog();
2671 switch (theCommandID) {
2673 type = QUAD_EDGE; break;
2675 type = QUAD_TRIANGLE; break;
2677 type = QUAD_QUADRANGLE; break;
2679 type = QUAD_TETRAHEDRON; break;
2681 type = QUAD_PYRAMID; break;
2683 type = QUAD_PENTAHEDRON; break;
2685 type = QUAD_HEXAHEDRON;
2689 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2692 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2693 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2697 case 4041: // REMOVES NODES
2699 if(checkLock(aStudy)) break;
2701 EmitSignalDeactivateDialog();
2702 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2705 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2706 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2710 case 4042: // REMOVES ELEMENTS
2712 if(checkLock(aStudy)) break;
2714 EmitSignalDeactivateDialog();
2715 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2719 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2720 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2724 case 4043: { // CLEAR_MESH
2726 if(checkLock(aStudy)) break;
2728 SALOME_ListIO selected;
2729 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2730 aSel->selectedObjects( selected );
2732 SUIT_OverrideCursor wc;
2733 SALOME_ListIteratorOfListIO It (selected);
2734 for ( ; It.More(); It.Next() )
2736 Handle(SALOME_InteractiveObject) IOS = It.Value();
2737 SMESH::SMESH_Mesh_var aMesh =
2738 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2739 if ( aMesh->_is_nil()) continue;
2741 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2743 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2744 SMESH::ModifiedMesh( aMeshSObj, false, true);
2745 // hide groups and submeshes
2746 _PTR(ChildIterator) anIter =
2747 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2748 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2750 _PTR(SObject) so = anIter->Value();
2751 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2754 catch (const SALOME::SALOME_Exception& S_ex){
2756 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2760 SMESH::UpdateView();
2764 case 4044: // REMOVE ORPHAN NODES
2766 if(checkLock(aStudy)) break;
2767 SALOME_ListIO selected;
2768 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2769 aSel->selectedObjects( selected );
2770 if ( selected.Extent() == 1 ) {
2771 Handle(SALOME_InteractiveObject) anIO = selected.First();
2772 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2773 if ( !aMesh->_is_nil() ) {
2774 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2775 tr( "SMESH_WARNING" ),
2776 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2777 SUIT_MessageBox::Yes |
2778 SUIT_MessageBox::No,
2779 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2782 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2783 int removed = aMeshEditor->RemoveOrphanNodes();
2784 SUIT_MessageBox::information(SMESHGUI::desktop(),
2785 tr("SMESH_INFORMATION"),
2786 tr("NB_NODES_REMOVED").arg(removed));
2787 if ( removed > 0 ) {
2788 SMESH::UpdateView();
2789 SMESHGUI::Modified();
2792 catch (const SALOME::SALOME_Exception& S_ex) {
2793 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2802 case 4051: // RENUMBERING NODES
2804 if(checkLock(aStudy)) break;
2806 EmitSignalDeactivateDialog();
2807 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2811 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2812 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2816 case 4052: // RENUMBERING ELEMENTS
2818 if(checkLock(aStudy)) break;
2820 EmitSignalDeactivateDialog();
2821 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2825 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2826 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2830 case 4061: // TRANSLATION
2832 if(checkLock(aStudy)) break;
2834 EmitSignalDeactivateDialog();
2835 ( new SMESHGUI_TranslationDlg( this ) )->show();
2838 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2839 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2843 case 4062: // ROTATION
2845 if(checkLock(aStudy)) break;
2847 EmitSignalDeactivateDialog();
2848 ( new SMESHGUI_RotationDlg( this ) )->show();
2851 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2852 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2856 case 4063: // SYMMETRY
2858 if(checkLock(aStudy)) break;
2860 EmitSignalDeactivateDialog();
2861 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2864 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2865 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2869 case 4064: // SEWING
2871 if(checkLock(aStudy)) break;
2873 EmitSignalDeactivateDialog();
2874 ( new SMESHGUI_SewingDlg( this ) )->show();
2877 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2878 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2882 case 4065: // MERGE NODES
2884 if(checkLock(aStudy)) break;
2886 EmitSignalDeactivateDialog();
2887 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2890 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2891 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2895 case 4066: // MERGE EQUAL ELEMENTS
2897 if (checkLock(aStudy)) break;
2899 EmitSignalDeactivateDialog();
2900 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2902 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2903 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2908 case 4067: // MAKE MESH PASS THROUGH POINT
2909 startOperation( 4067 );
2914 if(checkLock(aStudy)) break;
2916 EmitSignalDeactivateDialog();
2917 ( new SMESHGUI_ScaleDlg( this ) )->show();
2920 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2926 case 4069: // DUPLICATE NODES
2928 if(checkLock(aStudy)) break;
2930 EmitSignalDeactivateDialog();
2931 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2934 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2940 case 5105: // Library of selection filters
2942 static QList<int> aTypes;
2943 if ( aTypes.isEmpty() )
2945 aTypes.append( SMESH::NODE );
2946 aTypes.append( SMESH::EDGE );
2947 aTypes.append( SMESH::FACE );
2948 aTypes.append( SMESH::VOLUME );
2950 if (!myFilterLibraryDlg)
2951 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2952 else if (myFilterLibraryDlg->isHidden())
2953 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2954 myFilterLibraryDlg->raise();
2958 case 6017: // CONTROLS
2978 LightApp_SelectionMgr* mgr = selectionMgr();
2979 SALOME_ListIO selected; mgr->selectedObjects( selected );
2981 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2982 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2984 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2985 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2986 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2987 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2988 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2989 ::Control( theCommandID );
2994 SUIT_MessageBox::warning(desktop(),
2995 tr( "SMESH_WRN_WARNING" ),
2996 tr( "SMESH_BAD_SELECTION" ) );
3000 SUIT_MessageBox::warning(desktop(),
3001 tr( "SMESH_WRN_WARNING" ),
3002 tr( "NOT_A_VTK_VIEWER" ) );
3007 LightApp_SelectionMgr* mgr = selectionMgr();
3008 SALOME_ListIO selected; mgr->selectedObjects( selected );
3010 SALOME_ListIteratorOfListIO it(selected);
3011 for( ; it.More(); it.Next()) {
3012 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3013 if(anIObject->hasEntry()) {
3014 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3015 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3023 LightApp_SelectionMgr* mgr = selectionMgr();
3024 SALOME_ListIO selected; mgr->selectedObjects( selected );
3026 SALOME_ListIteratorOfListIO it(selected);
3027 for( ; it.More(); it.Next()) {
3028 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3029 if(anIObject->hasEntry())
3030 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3031 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3039 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3040 EmitSignalDeactivateDialog();
3041 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3047 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3048 //updateObjBrowser();
3052 //=============================================================================
3056 //=============================================================================
3057 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3062 //=============================================================================
3066 //=============================================================================
3067 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3072 //=============================================================================
3076 //=============================================================================
3077 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3082 //=============================================================================
3083 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3084 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3086 //=============================================================================
3087 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3088 SUIT_ViewWindow* wnd )
3090 if(theIO->hasEntry()){
3091 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3092 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3096 //=======================================================================
3097 // function : createSMESHAction
3099 //=======================================================================
3100 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3101 const int key, const bool toggle, const QString& shortcutAction )
3104 QWidget* parent = application()->desktop();
3105 SUIT_ResourceMgr* resMgr = resourceMgr();
3107 if ( !icon_id.isEmpty() )
3108 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3110 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3111 if ( !pix.isNull() )
3112 icon = QIcon( pix );
3114 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3115 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3116 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3118 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3119 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3122 //=======================================================================
3123 // function : createPopupItem
3125 //=======================================================================
3126 void SMESHGUI::createPopupItem( const int id,
3127 const QString& clients,
3128 const QString& types,
3129 const QString& theRule,
3134 parentId = popupMgr()->actionId( action( pId ) );
3136 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3137 popupMgr()->insert( action( id ), parentId, 0 );
3139 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3140 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3141 QString rule = "(%1) and (%2) and (%3)";
3142 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3143 if( clients.isEmpty() )
3144 rule = rule.arg( QString( "true" ) );
3146 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3147 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3150 bool cont = myRules.contains( id );
3152 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3154 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3155 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3158 //=======================================================================
3159 // function : initialize
3161 //=======================================================================
3162 void SMESHGUI::initialize( CAM_Application* app )
3164 SalomeApp_Module::initialize( app );
3166 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3168 /* Automatic Update flag */
3169 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3171 // ----- create actions --------------
3173 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3174 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3175 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3176 createSMESHAction( 114, "NUM" );
3177 createSMESHAction( 121, "DAT" );
3178 createSMESHAction( 122, "MED" );
3179 createSMESHAction( 123, "UNV" );
3180 createSMESHAction( 140, "STL" );
3181 createSMESHAction( 124, "EXPORT_DAT" );
3182 createSMESHAction( 125, "EXPORT_MED" );
3183 createSMESHAction( 126, "EXPORT_UNV" );
3184 createSMESHAction( 141, "EXPORT_STL" );
3185 createSMESHAction( 150, "FILE_INFO" );
3186 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3187 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3188 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3189 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3190 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3191 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3192 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3193 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3194 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3195 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3196 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3197 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3198 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3199 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3200 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3201 createSMESHAction( 804, "ADD" );
3202 createSMESHAction( 805, "REMOVE" );
3203 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3204 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3205 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3206 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3207 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3208 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3209 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3210 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3211 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3212 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3213 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3214 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3215 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3216 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3217 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3218 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3219 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3220 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3221 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3222 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3223 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3224 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3225 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3226 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3227 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3228 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3229 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3230 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3231 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3232 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3233 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3234 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3235 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3236 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3237 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3238 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3239 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3240 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3241 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3242 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3243 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3244 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3245 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3246 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3247 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3248 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3249 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3250 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3251 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3252 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3253 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3254 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3255 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3256 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3257 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3258 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3259 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3260 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3261 createSMESHAction( 415, "MAP", "ICON_MAP" );
3262 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3263 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3264 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3265 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3266 createSMESHAction( 200, "RESET" );
3267 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3268 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3269 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3270 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3271 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3272 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3273 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3274 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3275 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3276 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3277 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3278 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3279 createSMESHAction( 220, "ALL" );
3280 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3282 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3283 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3285 createSMESHAction( 1100, "EDIT_HYPO" );
3286 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3287 createSMESHAction( 1102, "UNASSIGN" );
3288 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3289 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3290 createSMESHAction( 1131, "DISPMODE" );
3291 createSMESHAction( 1132, "COLORS" );
3292 createSMESHAction( 1133, "TRANSP" );
3293 createSMESHAction( 1134, "CLIP" );
3294 createSMESHAction( 1135, "DISP_ENT" );
3295 createSMESHAction( 1136, "AUTO_COLOR" );
3296 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3297 createSMESHAction( 2000, "CTRL" );
3299 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3300 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3302 createSMESHAction( 300, "ERASE" );
3303 createSMESHAction( 301, "DISPLAY" );
3304 createSMESHAction( 302, "DISPLAY_ONLY" );
3305 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3306 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3307 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3308 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3309 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3310 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3311 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3312 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3314 // ----- create menu --------------
3315 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3316 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3317 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3318 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3319 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3320 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3321 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3322 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3324 createMenu( separator(), fileId );
3326 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3327 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3328 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3329 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3330 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3331 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3332 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3333 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3334 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3335 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3337 createMenu( 111, importId, -1 );
3338 createMenu( 112, importId, -1 );
3339 createMenu( 113, importId, -1 );
3341 createMenu( 121, exportId, -1 );
3342 createMenu( 122, exportId, -1 );
3343 createMenu( 123, exportId, -1 );
3344 createMenu( 140, exportId, -1 ); // export to stl STL
3346 createMenu( separator(), fileId, 10 );
3348 createMenu( 33, editId, -1 );
3350 createMenu( 5105, toolsId, -1 );
3352 createMenu( 702, meshId, -1 ); // "Mesh" menu
3353 createMenu( 703, meshId, -1 );
3354 createMenu( 704, meshId, -1 );
3355 createMenu( 710, meshId, -1 );
3356 createMenu( separator(), meshId, -1 );
3357 createMenu( 701, meshId, -1 );
3358 createMenu( 711, meshId, -1 );
3359 createMenu( 712, meshId, -1 );
3360 createMenu( 713, meshId, -1 );
3361 createMenu( separator(), meshId, -1 );
3362 createMenu( 801, meshId, -1 );
3363 createMenu( 806, meshId, -1 );
3364 createMenu( 802, meshId, -1 );
3365 createMenu( 803, meshId, -1 );
3366 createMenu( 815, meshId, -1 );
3367 createMenu( separator(), meshId, -1 );
3368 createMenu( 810, meshId, -1 );
3369 createMenu( 811, meshId, -1 );
3370 createMenu( 812, meshId, -1 );
3371 createMenu( separator(), meshId, -1 );
3372 createMenu( 814, meshId, -1 );
3373 createMenu( separator(), meshId, -1 );
3374 createMenu( 813, meshId, -1 );
3375 createMenu( separator(), meshId, -1 );
3376 createMenu( 900, meshId, -1 );
3377 //createMenu( 902, meshId, -1 );
3378 createMenu( 903, meshId, -1 );
3379 createMenu( 904, meshId, -1 );
3380 createMenu( separator(), meshId, -1 );
3382 createMenu( 6005, nodeId, -1 );
3383 createMenu( 6002, edgeId, -1 );
3384 createMenu( 6003, edgeId, -1 );
3385 createMenu( 6001, edgeId, -1 );
3386 createMenu( 6004, edgeId, -1 );
3387 createMenu( 6021, faceId, -1 );
3388 createMenu( 6018, faceId, -1 );
3389 createMenu( 6019, faceId, -1 );
3390 createMenu( 6011, faceId, -1 );
3391 createMenu( 6012, faceId, -1 );
3392 createMenu( 6013, faceId, -1 );
3393 createMenu( 6014, faceId, -1 );
3394 createMenu( 6015, faceId, -1 );
3395 createMenu( 6016, faceId, -1 );
3396 createMenu( 6022, faceId, -1 );
3397 createMenu( 6017, volumeId, -1 );
3398 createMenu( 6009, volumeId, -1 );
3399 createMenu( 6023, volumeId, -1 );
3401 createMenu( 4000, addId, -1 );
3402 createMenu( 4009, addId, -1 );
3403 createMenu( 4010, addId, -1 );
3404 createMenu( 4021, addId, -1 );
3405 createMenu( 4022, addId, -1 );
3406 createMenu( 4023, addId, -1 );
3407 createMenu( 4031, addId, -1 );
3408 createMenu( 4032, addId, -1 );
3409 createMenu( 4033, addId, -1 );
3410 createMenu( separator(), addId, -1 );
3411 createMenu( 4034, addId, -1 );
3412 createMenu( 4035, addId, -1 );
3413 createMenu( 4036, addId, -1 );
3414 createMenu( 4037, addId, -1 );
3415 createMenu( 4038, addId, -1 );
3416 createMenu( 4039, addId, -1 );
3417 createMenu( 4040, addId, -1 );
3419 createMenu( 4041, removeId, -1 );
3420 createMenu( 4042, removeId, -1 );
3421 createMenu( 4044, removeId, -1 );
3422 createMenu( separator(), removeId, -1 );
3423 createMenu( 4043, removeId, -1 );
3425 createMenu( 4051, renumId, -1 );
3426 createMenu( 4052, renumId, -1 );
3428 createMenu( 4061, transfId, -1 );
3429 createMenu( 4062, transfId, -1 );
3430 createMenu( 4063, transfId, -1 );
3431 createMenu( 4064, transfId, -1 );
3432 createMenu( 4065, transfId, -1 );
3433 createMenu( 4066, transfId, -1 );
3434 createMenu( 4068, transfId, -1 );
3435 createMenu( 4069, transfId, -1 );
3437 createMenu( 4067,modifyId, -1 );
3438 createMenu( 407, modifyId, -1 );
3439 createMenu( 408, modifyId, -1 );
3440 createMenu( 409, modifyId, -1 );
3441 createMenu( 410, modifyId, -1 );
3442 createMenu( 411, modifyId, -1 );
3443 createMenu( 419, modifyId, -1 );
3444 createMenu( 412, modifyId, -1 );
3445 createMenu( 413, modifyId, -1 );
3446 createMenu( 416, modifyId, -1 );
3447 createMenu( 414, modifyId, -1 );
3448 createMenu( 415, modifyId, -1 );
3449 createMenu( 417, modifyId, -1 );
3450 createMenu( 418, modifyId, -1 );
3452 createMenu( 501, measureId, -1 );
3453 createMenu( 502, measureId, -1 );
3454 createMenu( 214, viewId, -1 );
3456 // ----- create toolbars --------------
3457 int meshTb = createTool( tr( "TB_MESH" ) ),
3458 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3459 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3460 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3461 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3463 createTool( 702, meshTb );
3464 createTool( 703, meshTb );
3465 createTool( 704, meshTb );
3466 createTool( 710, meshTb );
3467 createTool( separator(), meshTb );
3468 createTool( 701, meshTb );
3469 createTool( 711, meshTb );
3470 createTool( 712, meshTb );
3471 createTool( 713, meshTb );
3472 createTool( separator(), meshTb );
3473 createTool( 801, meshTb );
3474 createTool( 806, meshTb );
3475 createTool( 802, meshTb );
3476 createTool( 803, meshTb );
3477 //createTool( 815, meshTb );
3478 createTool( separator(), meshTb );
3479 createTool( 900, meshTb );
3480 //createTool( 902, meshTb );
3481 createTool( 903, meshTb );
3482 createTool( 904, meshTb );
3483 createTool( separator(), meshTb );
3485 createTool( 6005, ctrlTb );
3486 createTool( separator(), ctrlTb );
3487 createTool( 6002, ctrlTb );
3488 createTool( 6003, ctrlTb );
3489 createTool( 6001, ctrlTb );
3490 createTool( 6004, ctrlTb );
3491 createTool( separator(), ctrlTb );
3492 createTool( 6021, ctrlTb );
3493 createTool( 6018, ctrlTb );
3494 createTool( 6019, ctrlTb );
3495 createTool( 6011, ctrlTb );
3496 createTool( 6012, ctrlTb );
3497 createTool( 6013, ctrlTb );
3498 createTool( 6014, ctrlTb );
3499 createTool( 6015, ctrlTb );
3500 createTool( 6016, ctrlTb );
3501 createTool( 6022, ctrlTb );
3502 createTool( separator(), ctrlTb );
3503 createTool( 6017, ctrlTb );
3504 createTool( 6009, ctrlTb );
3505 createTool( 6023, ctrlTb );
3506 createTool( separator(), ctrlTb );
3508 createTool( 4000, addRemTb );
3509 createTool( 4009, addRemTb );
3510 createTool( 4010, addRemTb );
3511 createTool( 4021, addRemTb );
3512 createTool( 4022, addRemTb );
3513 createTool( 4023, addRemTb );
3514 createTool( 4031, addRemTb );
3515 createTool( 4032, addRemTb );
3516 createTool( 4033, addRemTb );
3517 createTool( separator(), addRemTb );
3518 createTool( 4034, addRemTb );
3519 createTool( 4035, addRemTb );
3520 createTool( 4036, addRemTb );
3521 createTool( 4037, addRemTb );
3522 createTool( 4038, addRemTb );
3523 createTool( 4039, addRemTb );
3524 createTool( 4040, addRemTb );
3525 createTool( separator(), addRemTb );
3526 createTool( 4041, addRemTb );
3527 createTool( 4042, addRemTb );
3528 createTool( 4044, addRemTb );
3529 createTool( 4043, addRemTb );
3530 createTool( separator(), addRemTb );
3531 createTool( 4051, addRemTb );
3532 createTool( 4052, addRemTb );
3533 createTool( separator(), addRemTb );
3534 createTool( 4061, addRemTb );
3535 createTool( 4062, addRemTb );
3536 createTool( 4063, addRemTb );
3537 createTool( 4064, addRemTb );
3538 createTool( 4065, addRemTb );
3539 createTool( 4066, addRemTb );
3540 createTool( 4068, addRemTb );
3541 createTool( 4069, addRemTb );
3542 createTool( separator(), addRemTb );
3544 createTool( 4067,modifyTb );
3545 createTool( 407, modifyTb );
3546 createTool( 408, modifyTb );
3547 createTool( 409, modifyTb );
3548 createTool( 410, modifyTb );
3549 createTool( 411, modifyTb );
3550 createTool( 419, modifyTb );
3551 createTool( 412, modifyTb );
3552 createTool( 413, modifyTb );
3553 createTool( 416, modifyTb );
3554 createTool( 414, modifyTb );
3555 createTool( 415, modifyTb );
3556 createTool( 417, modifyTb );
3557 createTool( 418, modifyTb );
3559 createTool( 214, dispModeTb );
3561 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3562 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3565 QString OB = "'ObjectBrowser'",
3566 View = "'" + SVTK_Viewer::Type() + "'",
3568 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3569 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3570 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3571 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3572 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3573 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3574 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3575 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3576 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3577 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3578 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3580 mesh_group = mesh + " " + subMesh + " " + group,
3581 hyp_alg = hypo + " " + algo;
3583 // popup for object browser
3585 isInvisible("not( isVisible )"),
3586 isEmpty("numberOfNodes = 0"),
3587 isNotEmpty("numberOfNodes <> 0"),
3589 // has nodes, edges, etc in VISIBLE! actor
3590 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3591 hasElems("(count( elemTypes ) > 0)"),
3592 hasDifferentElems("(count( elemTypes ) > 1)"),
3593 hasElems0d("({'Elem0d'} in elemTypes)"),
3594 hasEdges("({'Edge'} in elemTypes)"),
3595 hasFaces("({'Face'} in elemTypes)"),
3596 hasVolumes("({'Volume'} in elemTypes)");
3598 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3599 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3600 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3601 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3602 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3603 createPopupItem( 803, OB, group ); // EDIT_GROUP
3604 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3606 popupMgr()->insert( separator(), -1, 0 );
3607 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3608 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3609 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3610 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3611 createPopupItem( 214, OB, mesh_group ); // UPDATE
3612 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3613 //createPopupItem( 902, OB, mesh ); // STD_INFO
3614 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3615 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3616 popupMgr()->insert( separator(), -1, 0 );
3617 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3618 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3619 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3620 popupMgr()->insert( separator(), -1, 0 );
3621 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3622 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3623 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3624 popupMgr()->insert( separator(), -1, 0 );
3625 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3626 popupMgr()->insert( separator(), -1, 0 );
3627 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3628 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3629 popupMgr()->insert( separator(), -1, 0 );
3631 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3632 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3634 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3635 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3636 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3637 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3638 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3639 popupMgr()->insert( separator(), -1, 0 );
3642 createPopupItem( 803, View, group ); // EDIT_GROUP
3643 createPopupItem( 804, View, elems ); // ADD
3644 createPopupItem( 805, View, elems ); // REMOVE
3646 popupMgr()->insert( separator(), -1, 0 );
3647 createPopupItem( 214, View, mesh_group ); // UPDATE
3648 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3649 //createPopupItem( 902, View, mesh ); // STD_INFO
3650 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3651 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3652 popupMgr()->insert( separator(), -1, 0 );
3654 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3655 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3656 popupMgr()->insert( separator(), -1, 0 );
3659 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3660 QString aType = QString( "%1type in {%2}" ).arg( lc );
3661 aType = aType.arg( mesh_group );
3662 QString aMeshInVTK = aClient + "&&" + aType;
3664 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3665 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3666 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3668 //-------------------------------------------------
3670 //-------------------------------------------------
3671 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3673 popupMgr()->insert( action( 9010 ), anId, -1 );
3674 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3675 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3677 popupMgr()->insert( action( 9011 ), anId, -1 );
3678 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3679 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3681 popupMgr()->insert( separator(), -1, -1 );
3683 //-------------------------------------------------
3685 //-------------------------------------------------
3686 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3688 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3689 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3690 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3692 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3693 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3694 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3696 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3697 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3698 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3700 popupMgr()->insert( separator(), anId, -1 );
3702 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3703 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3704 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3706 //-------------------------------------------------
3708 //-------------------------------------------------
3709 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3711 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3713 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3714 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3715 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3717 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3718 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3719 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3721 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3722 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3723 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3725 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3726 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3727 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3729 popupMgr()->insert( separator(), anId, -1 );
3731 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3732 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3735 //-------------------------------------------------
3736 // Representation of the 2D Quadratic elements
3737 //-------------------------------------------------
3738 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3739 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3740 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3741 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3743 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3744 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3745 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3747 //-------------------------------------------------
3748 // Orientation of faces
3749 //-------------------------------------------------
3750 popupMgr()->insert( action( 221 ), -1, -1 );
3751 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3752 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3754 //-------------------------------------------------
3756 //-------------------------------------------------
3757 popupMgr()->insert( action( 1132 ), -1, -1 );
3758 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3760 //-------------------------------------------------
3762 //-------------------------------------------------
3763 popupMgr()->insert( action( 1133 ), -1, -1 );
3764 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3766 //-------------------------------------------------
3768 //-------------------------------------------------
3770 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3771 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3772 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3773 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3775 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3777 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3778 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3780 popupMgr()->insert( separator(), anId, -1 );
3782 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3784 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3785 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3786 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3788 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3790 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3791 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3792 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3794 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3795 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3796 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3798 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3799 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3800 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3802 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3803 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3804 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3806 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3808 popupMgr()->insert( action( 6021 ), aSubId, -1 ); // FREE_FACE
3809 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3810 QtxPopupMgr::VisibleRule );
3811 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3813 popupMgr()->insert( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3814 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3815 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3817 popupMgr()->insert( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3818 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3819 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3821 popupMgr()->insert( action( 6011 ), aSubId, -1 ); // AREA
3822 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3823 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3825 popupMgr()->insert( action( 6012 ), aSubId, -1 ); // TAPER
3826 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3827 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3829 popupMgr()->insert( action( 6013 ), aSubId, -1 ); // ASPECT
3830 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3831 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3833 popupMgr()->insert( action( 6014 ), aSubId, -1 ); // MIN_ANG
3834 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3835 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3837 popupMgr()->insert( action( 6015 ), aSubId, -1 ); // WARP
3838 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3839 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3841 popupMgr()->insert( action( 6016 ), aSubId, -1 ); // SKEW
3842 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3843 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3845 popupMgr()->insert( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3846 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3847 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3849 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3851 popupMgr()->insert( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3852 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3856 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3857 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3859 popupMgr()->insert( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3860 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3861 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3863 popupMgr()->insert( separator(), anId, -1 );
3865 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3866 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3868 popupMgr()->insert( separator(), anId, -1 );
3870 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3871 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3873 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3874 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3875 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3878 popupMgr()->insert( separator(), -1, -1 );
3880 //-------------------------------------------------
3882 //-------------------------------------------------
3883 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3884 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3885 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3886 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3888 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3889 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3891 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3892 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3894 popupMgr()->insert( separator(), -1, -1 );
3896 //-------------------------------------------------
3898 //-------------------------------------------------
3899 popupMgr()->insert( action( 1134 ), -1, -1 );
3900 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3902 popupMgr()->insert( separator(), -1, -1 );
3904 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3905 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3907 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3908 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3911 //================================================================================
3913 * \brief Return true if SMESH or GEOM objects are selected.
3914 * Is called form LightApp_Module::activateModule() which clear selection if
3915 * not isSelectionCompatible()
3917 //================================================================================
3919 bool SMESHGUI::isSelectionCompatible()
3921 bool isCompatible = true;
3922 SALOME_ListIO selected;
3923 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3924 Sel->selectedObjects( selected );
3926 SALOME_ListIteratorOfListIO It( selected );
3927 for ( ; isCompatible && It.More(); It.Next())
3929 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3930 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3932 return isCompatible;
3936 bool SMESHGUI::reusableOperation( const int id )
3938 // compute, evaluate and precompute are not reusable operations
3939 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3942 bool SMESHGUI::activateModule( SUIT_Study* study )
3944 bool res = SalomeApp_Module::activateModule( study );
3946 setMenuShown( true );
3947 setToolShown( true );
3949 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
3950 PyGILState_STATE gstate = PyGILState_Ensure();
3951 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
3952 if(pluginsmanager==NULL)
3956 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
3961 PyGILState_Release(gstate);
3962 // end of GEOM plugins loading
3964 // Reset actions accelerator keys
3965 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3966 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3967 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3969 action( 33)->setEnabled(true); // Delete: Key_Delete
3970 action(1101)->setEnabled(true); // Rename: Key_F2
3972 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3973 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3974 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3975 if ( _PTR(Study) aStudy = s->studyDS()) {
3976 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3977 updateObjBrowser(); // objects can be removed
3983 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3985 setMenuShown( false );
3986 setToolShown( false );
3988 EmitSignalCloseAllDialogs();
3990 // Unset actions accelerator keys
3991 action(111)->setShortcut(QKeySequence()); // Import DAT
3992 action(112)->setShortcut(QKeySequence()); // Import UNV
3993 action(113)->setShortcut(QKeySequence()); // Import MED
3995 action( 33)->setEnabled(false); // Delete: Key_Delete
3996 action(1101)->setEnabled(false); // Rename: Key_F2
3998 return SalomeApp_Module::deactivateModule( study );
4001 void SMESHGUI::studyClosed( SUIT_Study* s )
4003 SMESH::RemoveVisuData( s->id() );
4004 SalomeApp_Module::studyClosed( s );
4007 void SMESHGUI::OnGUIEvent()
4009 const QObject* obj = sender();
4010 if ( !obj || !obj->inherits( "QAction" ) )
4012 int id = actionId((QAction*)obj);
4017 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4019 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4020 if ( CORBA::is_nil( myComponentSMESH ) )
4022 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4024 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4025 return aGUI.myComponentSMESH;
4028 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4029 return myComponentSMESH;
4032 QString SMESHGUI::engineIOR() const
4034 CORBA::ORB_var anORB = getApp()->orb();
4035 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4036 return QString( anIOR.in() );
4039 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4041 SalomeApp_Module::contextMenuPopup( client, menu, title );
4043 selectionMgr()->selectedObjects( lst );
4044 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4045 Handle(SALOME_InteractiveObject) io = lst.First();
4046 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4047 _PTR(Study) study = appStudy->studyDS();
4048 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4050 QString aName = QString( obj->GetName().c_str() );
4051 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4052 aName.remove( (aName.length() - 1), 1 );
4058 LightApp_Selection* SMESHGUI::createSelection() const
4060 return new SMESHGUI_Selection();
4063 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4065 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4066 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4069 void SMESHGUI::viewManagers( QStringList& list ) const
4071 list.append( SVTK_Viewer::Type() );
4074 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4076 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4077 SMESH::UpdateSelectionProp( this );
4080 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4082 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4083 myClippingPlaneInfoMap.erase( theViewManager );
4086 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4088 theActor->AddObserver( SMESH::DeleteActorEvent,
4089 myEventCallbackCommand.GetPointer(),
4093 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4094 unsigned long theEvent,
4095 void* theClientData,
4098 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4099 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4100 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4101 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4102 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4103 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4104 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4105 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4106 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4107 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4108 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4109 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4110 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4111 if( anActor == *anIter3 ) {
4112 anActorList.erase( anIter3 );
4123 void SMESHGUI::createPreferences()
4125 // General tab ------------------------------------------------------------------------
4126 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4128 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4129 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4130 setPreferenceProperty( lim, "min", 0 );
4131 setPreferenceProperty( lim, "max", 100000000 );
4132 setPreferenceProperty( lim, "step", 1000 );
4133 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4135 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4136 setPreferenceProperty( qaGroup, "columns", 2 );
4137 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4138 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4139 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4140 setPreferenceProperty( prec, "min", 0 );
4141 setPreferenceProperty( prec, "max", 16 );
4143 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4144 setPreferenceProperty( dispgroup, "columns", 2 );
4145 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4147 modes.append( "Wireframe" );
4148 modes.append( "Shading" );
4149 modes.append( "Nodes" );
4150 modes.append( "Shrink" );
4151 QList<QVariant> indices;
4152 indices.append( 0 );
4153 indices.append( 1 );
4154 indices.append( 2 );
4155 indices.append( 3 );
4156 setPreferenceProperty( dispmode, "strings", modes );
4157 setPreferenceProperty( dispmode, "indexes", indices );
4159 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4160 setPreferenceProperty( arcgroup, "columns", 2 );
4161 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4162 QStringList quadraticModes;
4163 quadraticModes.append("Lines");
4164 quadraticModes.append("Arcs");
4166 indices.append( 0 );
4167 indices.append( 1 );
4168 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4169 setPreferenceProperty( quadraticmode, "indexes", indices );
4171 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4172 "SMESH", "max_angle" );
4173 setPreferenceProperty( maxAngle, "min", 1 );
4174 setPreferenceProperty( maxAngle, "max", 90 );
4178 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4179 setPreferenceProperty( exportgroup, "columns", 2 );
4180 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4181 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4183 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4184 setPreferenceProperty( computeGroup, "columns", 2 );
4185 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4187 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4188 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4189 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4191 indices.append( 0 );
4192 indices.append( 1 );
4193 indices.append( 2 );
4194 setPreferenceProperty( notifyMode, "strings", modes );
4195 setPreferenceProperty( notifyMode, "indexes", indices );
4197 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4198 setPreferenceProperty( computeGroup, "columns", 2 );
4199 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4201 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4202 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4204 indices.append( 0 );
4205 indices.append( 1 );
4206 setPreferenceProperty( elemInfo, "strings", modes );
4207 setPreferenceProperty( elemInfo, "indexes", indices );
4209 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4210 setPreferenceProperty( segGroup, "columns", 2 );
4211 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4212 "SMESH", "segmentation" );
4213 setPreferenceProperty( segLen, "min", 1 );
4214 setPreferenceProperty( segLen, "max", 10000000 );
4215 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4216 "SMESH", "nb_segments_per_edge" );
4217 setPreferenceProperty( nbSeg, "min", 1 );
4218 setPreferenceProperty( nbSeg, "max", 10000000 );
4220 // Quantities with individual precision settings
4221 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4222 setPreferenceProperty( precGroup, "columns", 2 );
4224 const int nbQuantities = 6;
4225 int precs[nbQuantities], ii = 0;
4226 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4227 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4228 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4229 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4230 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4231 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4232 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4233 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4234 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4235 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4236 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4237 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4239 // Set property for precision value for spinboxes
4240 for ( ii = 0; ii < nbQuantities; ii++ ){
4241 setPreferenceProperty( precs[ii], "min", -14 );
4242 setPreferenceProperty( precs[ii], "max", 14 );
4243 setPreferenceProperty( precs[ii], "precision", 2 );
4246 // Mesh tab ------------------------------------------------------------------------
4247 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4248 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4249 setPreferenceProperty( nodeGroup, "columns", 3 );
4251 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4253 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4255 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4256 QList<QVariant> aMarkerTypeIndicesList;
4257 QList<QVariant> aMarkerTypeIconsList;
4258 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4259 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4260 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4261 aMarkerTypeIndicesList << i;
4262 aMarkerTypeIconsList << pixmap;
4264 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4265 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4267 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4269 QList<QVariant> aMarkerScaleIndicesList;
4270 QStringList aMarkerScaleValuesList;
4271 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4272 aMarkerScaleIndicesList << i;
4273 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4275 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4276 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4278 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4279 setPreferenceProperty( elemGroup, "columns", 2 );
4281 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4282 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4283 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4284 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4286 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4287 setPreferenceProperty( grpGroup, "columns", 2 );
4289 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4291 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4292 //setPreferenceProperty( sp, "hstretch", 0 );
4293 //setPreferenceProperty( sp, "vstretch", 0 );
4295 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4296 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4297 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4298 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4299 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4300 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4301 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4303 setPreferenceProperty( size0d, "min", 1 );
4304 setPreferenceProperty( size0d, "max", 10 );
4306 setPreferenceProperty( sp, "hstretch", 0 );
4307 setPreferenceProperty( sp, "vstretch", 0 );
4309 setPreferenceProperty( elemW, "min", 1 );
4310 setPreferenceProperty( elemW, "max", 5 );
4312 setPreferenceProperty( shrink, "min", 0 );
4313 setPreferenceProperty( shrink, "max", 100 );
4315 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4316 setPreferenceProperty( orientGroup, "columns", 1 );
4318 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4319 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4321 setPreferenceProperty( orientScale, "min", 0.05 );
4322 setPreferenceProperty( orientScale, "max", 0.5 );
4323 setPreferenceProperty( orientScale, "step", 0.05 );
4325 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4327 // Selection tab ------------------------------------------------------------------------
4328 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4330 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4331 setPreferenceProperty( selGroup, "columns", 2 );
4333 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4334 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4335 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4337 setPreferenceProperty( selW, "min", 1 );
4338 setPreferenceProperty( selW, "max", 5 );
4340 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4341 setPreferenceProperty( preGroup, "columns", 2 );
4343 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4344 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4346 setPreferenceProperty( preW, "min", 1 );
4347 setPreferenceProperty( preW, "max", 5 );
4349 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4350 setPreferenceProperty( precSelGroup, "columns", 2 );
4352 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4353 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4354 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4356 // Scalar Bar tab ------------------------------------------------------------------------
4357 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4358 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4359 setPreferenceProperty( fontGr, "columns", 2 );
4361 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4362 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4364 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4365 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4367 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4368 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4370 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4371 setPreferenceProperty( numcol, "min", 2 );
4372 setPreferenceProperty( numcol, "max", 256 );
4374 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4375 setPreferenceProperty( numlab, "min", 2 );
4376 setPreferenceProperty( numlab, "max", 65 );
4378 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4379 setPreferenceProperty( orientGr, "columns", 2 );
4380 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4381 QStringList orients;
4382 orients.append( tr( "SMESH_VERTICAL" ) );
4383 orients.append( tr( "SMESH_HORIZONTAL" ) );
4384 indices.clear(); indices.append( 0 ); indices.append( 1 );
4385 setPreferenceProperty( orient, "strings", orients );
4386 setPreferenceProperty( orient, "indexes", indices );
4388 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4389 setPreferenceProperty( posVSizeGr, "columns", 2 );
4390 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4391 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4392 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4393 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4394 setPreferenceProperty( xv, "step", 0.1 );
4395 setPreferenceProperty( xv, "min", 0.0 );
4396 setPreferenceProperty( xv, "max", 1.0 );
4397 setPreferenceProperty( yv, "step", 0.1 );
4398 setPreferenceProperty( yv, "min", 0.0 );
4399 setPreferenceProperty( yv, "max", 1.0 );
4400 setPreferenceProperty( wv, "step", 0.1 );
4401 setPreferenceProperty( wv, "min", 0.0 );
4402 setPreferenceProperty( wv, "max", 1.0 );
4403 setPreferenceProperty( hv, "min", 0.0 );
4404 setPreferenceProperty( hv, "max", 1.0 );
4405 setPreferenceProperty( hv, "step", 0.1 );
4407 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4408 setPreferenceProperty( posHSizeGr, "columns", 2 );
4409 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4410 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4411 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4412 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4413 setPreferenceProperty( xv, "min", 0.0 );
4414 setPreferenceProperty( xv, "max", 1.0 );
4415 setPreferenceProperty( xv, "step", 0.1 );
4416 setPreferenceProperty( xh, "min", 0.0 );
4417 setPreferenceProperty( xh, "max", 1.0 );
4418 setPreferenceProperty( xh, "step", 0.1 );
4419 setPreferenceProperty( yh, "min", 0.0 );
4420 setPreferenceProperty( yh, "max", 1.0 );
4421 setPreferenceProperty( yh, "step", 0.1 );
4422 setPreferenceProperty( wh, "min", 0.0 );
4423 setPreferenceProperty( wh, "max", 1.0 );
4424 setPreferenceProperty( wh, "step", 0.1 );
4425 setPreferenceProperty( hh, "min", 0.0 );
4426 setPreferenceProperty( hh, "max", 1.0 );
4427 setPreferenceProperty( hh, "step", 0.1 );
4429 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4430 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4431 setPreferenceProperty( distributionGr, "columns", 3 );
4433 types.append( tr( "SMESH_MONOCOLOR" ) );
4434 types.append( tr( "SMESH_MULTICOLOR" ) );
4435 indices.clear(); indices.append( 0 ); indices.append( 1 );
4436 setPreferenceProperty( coloringType, "strings", types );
4437 setPreferenceProperty( coloringType, "indexes", indices );
4438 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4442 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4444 if( sect=="SMESH" ) {
4445 float sbX1,sbY1,sbW,sbH;
4446 float aTol = 1.00000009999999;
4447 std::string aWarning;
4448 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4449 if( name=="selection_object_color" || name=="selection_element_color" ||
4450 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4451 name=="selection_precision_node" || name=="selection_precision_element" ||
4452 name=="selection_precision_object")
4453 SMESH::UpdateSelectionProp( this );
4454 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4455 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4456 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4457 if(sbX1+sbW > aTol){
4458 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4461 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4462 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4465 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4466 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4467 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4468 if(sbY1+sbH > aTol){
4469 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4470 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4471 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4474 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4475 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4476 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4477 if(sbX1+sbW > aTol){
4478 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4481 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4482 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4485 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4486 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4487 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4488 if(sbY1+sbH > aTol){
4489 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4492 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4493 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4496 else if ( name == "segmentation" ) {
4497 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4498 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4500 else if ( name == "nb_segments_per_edge" ) {
4501 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4502 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4505 if(aWarning.size() != 0){
4506 aWarning += "The default values are applied instead.";
4507 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4508 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4509 QObject::tr(aWarning.c_str()));
4514 //================================================================================
4516 * \brief Update something in accordance with update flags
4517 * \param theFlags - update flags
4519 * Update viewer or/and object browser etc. in accordance with update flags ( see
4520 * LightApp_UpdateFlags enumeration ).
4522 //================================================================================
4523 void SMESHGUI::update( const int flags )
4525 if ( flags & UF_Viewer | flags & UF_Forced )
4526 SMESH::UpdateView();
4528 SalomeApp_Module::update( flags );
4531 //================================================================================
4533 * \brief Set default selection mode
4535 * SLOT called when operation commited. Sets default selection mode
4537 //================================================================================
4538 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4540 SVTK_ViewWindow* vtkWnd =
4541 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4543 vtkWnd->SetSelectionMode( ActorSelection );
4546 //================================================================================
4548 * \brief Set default selection mode
4550 * SLOT called when operation aborted. Sets default selection mode
4552 //================================================================================
4553 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4555 SVTK_ViewWindow* vtkWnd =
4556 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4558 vtkWnd->SetSelectionMode( ActorSelection );
4561 //================================================================================
4563 * \brief Creates operation with given identifier
4564 * \param id - identifier of operation to be started
4565 * \return Pointer on created operation or NULL if operation is not created
4567 * Virtual method redefined from the base class creates operation with given id.
4568 * It is called called automatically from startOperation method of base class.
4570 //================================================================================
4571 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4573 LightApp_Operation* op = 0;
4574 // to do : create operation here
4577 case 417: //convert to quadratic
4578 op = new SMESHGUI_ConvToQuadOp();
4580 case 418: // create 2D mesh as boundary on 3D
4581 op = new SMESHGUI_Make2DFrom3DOp();
4583 case 701: // Compute mesh
4584 op = new SMESHGUI_ComputeOp();
4586 case 702: // Create mesh
4587 op = new SMESHGUI_MeshOp( true, true );
4589 case 703: // Create sub-mesh
4590 op = new SMESHGUI_MeshOp( true, false );
4592 case 704: // Edit mesh/sub-mesh
4593 op = new SMESHGUI_MeshOp( false );
4595 case 711: // Precompute mesh
4596 op = new SMESHGUI_PrecomputeOp();
4598 case 712: // Evaluate mesh
4599 op = new SMESHGUI_EvaluateOp();
4601 case 713: // Evaluate mesh
4602 op = new SMESHGUI_MeshOrderOp();
4604 case 806: // Create group on geom
4605 op = new SMESHGUI_GroupOnShapeOp();
4607 case 904: // Find element
4608 op = new SMESHGUI_FindElemByPointOp();
4610 case 4067: // make mesh pass through point
4611 op = new SMESHGUI_MakeNodeAtPointOp();
4618 op = SalomeApp_Module::createOperation( id );
4622 //================================================================================
4624 * \brief Stops current operations and starts a given one
4625 * \param id - The id of the operation to start
4627 //================================================================================
4629 void SMESHGUI::switchToOperation(int id)
4631 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4632 activeStudy()->abortAllOperations();
4633 startOperation( id );
4636 LightApp_Displayer* SMESHGUI::displayer()
4639 myDisplayer = new SMESHGUI_Displayer( getApp() );
4643 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4646 int aTolerance = 64;
4647 int anIterations = 0;
4653 if( anIterations % aPeriod == 0 )
4656 if( aTolerance < 1 )
4660 aHue = (int)( 360.0 * rand() / RAND_MAX );
4663 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4664 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4665 for( ; it != itEnd; ++it )
4667 SALOMEDS::Color anAutoColor = *it;
4668 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4671 aQColor.getHsv( &h, &s, &v );
4672 if( abs( h - aHue ) < aTolerance )
4684 aColor.setHsv( aHue, 255, 255 );
4686 SALOMEDS::Color aSColor;
4687 aSColor.R = (double)aColor.red() / 255.0;
4688 aSColor.G = (double)aColor.green() / 255.0;
4689 aSColor.B = (double)aColor.blue() / 255.0;
4694 const char gSeparator = '_'; // character used to separate parameter names
4695 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4696 const char gPathSep = '|'; // character used to separate paths
4699 * \brief Store visual parameters
4701 * This method is called just before the study document is saved.
4702 * Store visual parameters in AttributeParameter attribue(s)
4704 void SMESHGUI::storeVisualParameters (int savePoint)
4706 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4707 if (!appStudy || !appStudy->studyDS())
4709 _PTR(Study) studyDS = appStudy->studyDS();
4711 // componentName is used for encoding of entries when storing them in IParameters
4712 std::string componentName = myComponentSMESH->ComponentDataType();
4713 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4714 //if (!aSComponent) return;
4717 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4718 componentName.c_str(),
4720 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4722 // store map of custom markers
4723 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4724 if( !aMarkerMap.empty() )
4726 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4727 for( ; anIter != aMarkerMap.end(); anIter++ )
4729 int anId = anIter->first;
4730 VTK::MarkerData aMarkerData = anIter->second;
4731 std::string aMarkerFileName = aMarkerData.first;
4732 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4733 if( aMarkerTexture.size() < 3 )
4734 continue; // should contain at least width, height and the first value
4736 QString aPropertyName( "texture" );
4737 aPropertyName += gSeparator;
4738 aPropertyName += QString::number( anId );
4740 QString aPropertyValue = aMarkerFileName.c_str();
4741 aPropertyValue += gPathSep;
4743 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4744 ushort aWidth = *aTextureIter++;
4745 ushort aHeight = *aTextureIter++;
4746 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4747 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4748 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4749 aPropertyValue += QString::number( *aTextureIter );
4751 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4755 // viewers counters are used for storing view_numbers in IParameters
4758 // main cycle to store parameters of displayed objects
4759 QList<SUIT_ViewManager*> lst;
4760 QList<SUIT_ViewManager*>::Iterator it;
4761 getApp()->viewManagers(lst);
4762 for (it = lst.begin(); it != lst.end(); it++)
4764 SUIT_ViewManager* vman = *it;
4765 QString vType = vman->getType();
4767 // saving VTK actors properties
4768 if (vType == SVTK_Viewer::Type())
4770 // store the clipping planes attached to the view manager
4771 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4772 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4773 if( anIter != myClippingPlaneInfoMap.end() )
4774 aClippingPlaneInfoList = anIter->second;
4776 if( !aClippingPlaneInfoList.empty() ) {
4777 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4778 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4780 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4781 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4783 QString aPropertyName( "ClippingPlane" );
4784 aPropertyName += gSeparator;
4785 aPropertyName += QString::number( vtkViewers );
4786 aPropertyName += gSeparator;
4787 aPropertyName += QString::number( anId );
4789 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4790 aPropertyValue += gDigitsSep;
4791 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4792 aPropertyValue += gDigitsSep;
4793 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4794 aPropertyValue += gDigitsSep;
4795 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4797 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4801 QVector<SUIT_ViewWindow*> views = vman->getViews();
4802 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4804 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4806 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4807 vtkActorCollection* allActors = aCopy.GetActors();
4808 allActors->InitTraversal();
4809 while (vtkActor* actor = allActors->GetNextActor())
4811 if (actor->GetVisibility()) // store only visible actors
4813 SMESH_Actor* aSmeshActor = 0;
4814 if (actor->IsA("SMESH_Actor"))
4815 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4816 if (aSmeshActor && aSmeshActor->hasIO())
4818 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4821 // entry is "encoded" = it does NOT contain component adress,
4822 // since it is a subject to change on next component loading
4823 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4825 std::string param, vtkParam = vType.toLatin1().data();
4826 vtkParam += gSeparator;
4827 vtkParam += QString::number(vtkViewers).toLatin1().data();
4828 vtkParam += gSeparator;
4831 param = vtkParam + "Visibility";
4832 ip->setParameter(entry, param, "On");
4835 param = vtkParam + "Representation";
4836 ip->setParameter(entry, param, QString::number
4837 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4840 param = vtkParam + "IsShrunk";
4841 ip->setParameter(entry, param, QString::number
4842 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4844 // Displayed entities
4845 unsigned int aMode = aSmeshActor->GetEntityMode();
4846 bool isE = aMode & SMESH_Actor::eEdges;
4847 bool isF = aMode & SMESH_Actor::eFaces;
4848 bool isV = aMode & SMESH_Actor::eVolumes;
4850 QString modeStr ("e");
4851 modeStr += gDigitsSep; modeStr += QString::number(isE);
4852 modeStr += gDigitsSep; modeStr += "f";
4853 modeStr += gDigitsSep; modeStr += QString::number(isF);
4854 modeStr += gDigitsSep; modeStr += "v";
4855 modeStr += gDigitsSep; modeStr += QString::number(isV);
4857 param = vtkParam + "Entities";
4858 ip->setParameter(entry, param, modeStr.toLatin1().data());
4860 // Colors (surface:edge:)
4861 vtkFloatingPointType r, g, b;
4863 aSmeshActor->GetSufaceColor(r, g, b);
4864 QString colorStr ("surface");
4865 colorStr += gDigitsSep; colorStr += QString::number(r);
4866 colorStr += gDigitsSep; colorStr += QString::number(g);
4867 colorStr += gDigitsSep; colorStr += QString::number(b);
4869 aSmeshActor->GetBackSufaceColor(r, g, b);
4870 colorStr += gDigitsSep; colorStr += "backsurface";
4871 colorStr += gDigitsSep; colorStr += QString::number(r);
4872 colorStr += gDigitsSep; colorStr += QString::number(g);
4873 colorStr += gDigitsSep; colorStr += QString::number(b);
4875 aSmeshActor->GetEdgeColor(r, g, b);
4876 colorStr += gDigitsSep; colorStr += "edge";
4877 colorStr += gDigitsSep; colorStr += QString::number(r);
4878 colorStr += gDigitsSep; colorStr += QString::number(g);
4879 colorStr += gDigitsSep; colorStr += QString::number(b);
4881 aSmeshActor->GetNodeColor(r, g, b);
4882 colorStr += gDigitsSep; colorStr += "node";
4883 colorStr += gDigitsSep; colorStr += QString::number(r);
4884 colorStr += gDigitsSep; colorStr += QString::number(g);
4885 colorStr += gDigitsSep; colorStr += QString::number(b);
4887 param = vtkParam + "Colors";
4888 ip->setParameter(entry, param, colorStr.toLatin1().data());
4890 // Sizes of lines and points
4891 QString sizeStr ("line");
4892 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4893 sizeStr += gDigitsSep; sizeStr += "shrink";
4894 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4896 param = vtkParam + "Sizes";
4897 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4902 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4903 if( aMarkerType == VTK::MT_USER ) {
4904 markerStr += "custom";
4905 markerStr += gDigitsSep;
4906 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4910 markerStr += gDigitsSep;
4911 markerStr += QString::number( (int)aMarkerType );
4912 markerStr += gDigitsSep;
4913 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4916 param = vtkParam + "PointMarker";
4917 ip->setParameter(entry, param, markerStr.toLatin1().data());
4920 param = vtkParam + "Opacity";
4921 ip->setParameter(entry, param,
4922 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4925 param = vtkParam + "ClippingPlane";
4927 if( !aClippingPlaneInfoList.empty() ) {
4928 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4929 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
4931 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
4932 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
4933 SMESH::TActorList::iterator anIter2 = anActorList.begin();
4934 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
4935 if( aSmeshActor == *anIter2 ) {
4936 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
4937 QString::number( anId ).toLatin1().constData() );
4944 ip->setParameter( entry, param, "Off" );
4945 } // if (io->hasEntry())
4946 } // SMESH_Actor && hasIO
4948 } // while.. actors traversal
4952 } // if (SVTK view model)
4953 } // for (viewManagers)
4956 // data structures for clipping planes processing
4959 vtkIdType Orientation;
4960 vtkFloatingPointType Distance;
4961 vtkFloatingPointType Angle[2];
4963 typedef std::list<TPlaneData> TPlaneDataList;
4964 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
4966 typedef std::list<vtkActor*> TActorList;
4969 TActorList ActorList;
4970 SUIT_ViewManager* ViewManager;
4972 typedef std::list<TPlaneInfo> TPlaneInfoList;
4973 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
4976 * \brief Restore visual parameters
4978 * This method is called after the study document is opened.
4979 * Restore visual parameters from AttributeParameter attribue(s)
4981 void SMESHGUI::restoreVisualParameters (int savePoint)
4983 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4984 if (!appStudy || !appStudy->studyDS())
4986 _PTR(Study) studyDS = appStudy->studyDS();
4988 // componentName is used for encoding of entries when storing them in IParameters
4989 std::string componentName = myComponentSMESH->ComponentDataType();
4990 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4991 //if (!aSComponent) return;
4994 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4995 componentName.c_str(),
4997 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4999 // restore map of custom markers and map of clipping planes
5000 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5001 TPlaneDataMap aPlaneDataMap;
5003 std::vector<std::string> properties = ip->getProperties();
5004 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5006 std::string property = *propIt;
5007 QString aPropertyName( property.c_str() );
5008 QString aPropertyValue( ip->getProperty( property ).c_str() );
5010 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5011 if( aPropertyNameList.isEmpty() )
5014 QString aPropertyType = aPropertyNameList[0];
5015 if( aPropertyType == "texture" )
5017 if( aPropertyNameList.size() != 2 )
5021 int anId = aPropertyNameList[1].toInt( &ok );
5022 if( !ok || anId < 1 )
5025 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5026 if( aPropertyValueList.size() != 2 )
5029 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5030 QString aMarkerTextureString = aPropertyValueList[1];
5031 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5032 if( aMarkerTextureStringList.size() != 3 )
5036 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5041 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5045 VTK::MarkerTexture aMarkerTexture;
5046 aMarkerTexture.push_back( aWidth );
5047 aMarkerTexture.push_back( aHeight );
5049 QString aMarkerTextureData = aMarkerTextureStringList[2];
5050 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5052 QChar aChar = aMarkerTextureData.at( i );
5053 if( aChar.isDigit() )
5054 aMarkerTexture.push_back( aChar.digitValue() );
5057 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5059 else if( aPropertyType == "ClippingPlane" )
5061 if( aPropertyNameList.size() != 3 )
5065 int aViewId = aPropertyNameList[1].toInt( &ok );
5066 if( !ok || aViewId < 0 )
5070 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5071 if( !ok || aClippingPlaneId < 0 )
5074 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5075 if( aPropertyValueList.size() != 4 )
5078 TPlaneData aPlaneData;
5079 aPlaneData.Id = aClippingPlaneId;
5082 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5087 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5092 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5097 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5101 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5102 aPlaneDataList.push_back( aPlaneData );
5106 TPlaneInfoMap aPlaneInfoMap;
5108 std::vector<std::string> entries = ip->getEntries();
5110 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5112 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5113 QString entry (ip->decodeEntry(*entIt).c_str());
5115 // Check that the entry corresponds to a real object in the Study
5116 // as the object may be deleted or modified after the visual state is saved.
5117 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5118 if (!so) continue; //Skip the not existent entry
5120 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5121 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5123 std::vector<std::string>::iterator namesIt = paramNames.begin();
5124 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5126 // actors are stored in a map after displaying of them for
5127 // quicker access in the future: map < viewID to actor >
5128 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5130 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5132 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5133 // '_' is used as separator and should not be used in viewer type or parameter names.
5134 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5135 if (lst.size() != 3)
5138 QString viewerTypStr = lst[0];
5139 QString viewIndexStr = lst[1];
5140 QString paramNameStr = lst[2];
5143 int viewIndex = viewIndexStr.toUInt(&ok);
5144 if (!ok) // bad conversion of view index to integer
5148 if (viewerTypStr == SVTK_Viewer::Type())
5150 SMESH_Actor* aSmeshActor = 0;
5151 if (vtkActors.IsBound(viewIndex))
5152 aSmeshActor = vtkActors.Find(viewIndex);
5154 QList<SUIT_ViewManager*> lst;
5155 getApp()->viewManagers(viewerTypStr, lst);
5157 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5158 SUIT_ViewManager* vman = NULL;
5159 if (viewIndex >= 0 && viewIndex < lst.count())
5160 vman = lst.at(viewIndex);
5162 if (paramNameStr == "Visibility")
5164 if (!aSmeshActor && displayer() && vman)
5166 SUIT_ViewModel* vmodel = vman->getViewModel();
5167 // SVTK view model can be casted to SALOME_View
5168 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5170 // store displayed actor in a temporary map for quicker
5171 // access later when restoring other parameters
5172 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5173 vtkRenderer* Renderer = vtkView->getRenderer();
5174 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5175 vtkActorCollection* theActors = aCopy.GetActors();
5176 theActors->InitTraversal();
5177 bool isFound = false;
5178 vtkActor *ac = theActors->GetNextActor();
5179 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5180 if (ac->IsA("SMESH_Actor")) {
5181 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5182 if (aGeomAc->hasIO()) {
5183 Handle(SALOME_InteractiveObject) io =
5184 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5185 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5187 vtkActors.Bind(viewIndex, aGeomAc);
5193 } // if (paramNameStr == "Visibility")
5196 // the rest properties "work" with SMESH_Actor
5199 QString val ((*valuesIt).c_str());
5202 if (paramNameStr == "Representation") {
5203 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5206 else if (paramNameStr == "IsShrunk") {
5208 if (!aSmeshActor->IsShrunk())
5209 aSmeshActor->SetShrink();
5212 if (aSmeshActor->IsShrunk())
5213 aSmeshActor->UnShrink();
5216 // Displayed entities
5217 else if (paramNameStr == "Entities") {
5218 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5219 if (mode.count() == 6) {
5220 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5221 MESSAGE("Invalid order of data in Entities, must be: "
5222 "e:0/1:f:0/1:v:0/1");
5225 unsigned int aMode = aSmeshActor->GetEntityMode();
5226 unsigned int aNewMode =
5227 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5228 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5229 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5230 if (aNewMode != aMode)
5231 aSmeshActor->SetEntityMode(aNewMode);
5236 else if (paramNameStr == "Colors") {
5237 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5238 if (colors.count() == 16) {
5239 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5240 colors[8] != "edge" || colors[12] != "node") {
5241 MESSAGE("Invalid order of data in Colors, must be: "
5242 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5245 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5246 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5247 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5248 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5252 // Sizes of lines and points
5253 else if (paramNameStr == "Sizes") {
5254 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5255 if (sizes.count() == 4) {
5256 if (sizes[0] != "line" || sizes[2] != "shrink") {
5257 MESSAGE("Invalid order of data in Sizes, must be: "
5258 "line:int:shrink:float");
5261 aSmeshActor->SetLineWidth(sizes[1].toInt());
5262 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5265 else if (sizes.count() == 6) { // just to support old format
5266 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5267 MESSAGE("Invalid order of data in Sizes, must be: "
5268 "line:int:node:int:shrink:float");
5271 aSmeshActor->SetLineWidth(sizes[1].toInt());
5272 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5273 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5278 else if (paramNameStr == "PointMarker") {
5279 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5280 if( data.count() >= 2 ) {
5282 int aParam1 = data[1].toInt( &ok );
5284 if( data[0] == "std" && data.count() == 3 ) {
5285 int aParam2 = data[2].toInt( &ok );
5286 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5288 else if( data[0] == "custom" ) {
5289 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5290 if( markerIt != aMarkerMap.end() ) {
5291 VTK::MarkerData aMarkerData = markerIt->second;
5292 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5299 else if (paramNameStr == "Opacity") {
5300 aSmeshActor->SetOpacity(val.toFloat());
5303 else if (paramNameStr.startsWith("ClippingPlane")) {
5304 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5305 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5306 // new format - val looks like "Off" or "0" (plane id)
5307 // (note: in new format "Off" value is used only for consistency,
5308 // so it is processed together with values in old format)
5309 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5310 if( anIsOldFormat ) {
5311 if (paramNameStr == "ClippingPlane1" || val == "Off")
5312 aSmeshActor->RemoveAllClippingPlanes();
5314 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5315 double aDistance = vals[1].toFloat();
5316 vtkFloatingPointType anAngle[2];
5317 anAngle[0] = vals[2].toFloat();
5318 anAngle[1] = vals[3].toFloat();
5320 QList<SUIT_ViewManager*> lst;
5321 getApp()->viewManagers(viewerTypStr, lst);
5322 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5323 if (viewIndex >= 0 && viewIndex < lst.count()) {
5324 SUIT_ViewManager* vman = lst.at(viewIndex);
5325 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5327 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5329 SMESH::TActorList anActorList;
5330 anActorList.push_back( aSmeshActor );
5331 SMESH::OrientedPlane* aPlane =
5332 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5334 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5335 aClippingPlaneInfo.Plane = aPlane;
5336 aClippingPlaneInfo.ActorList = anActorList;
5337 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5344 int aPlaneId = val.toInt( &ok );
5345 if( ok && aPlaneId >= 0 ) {
5346 bool anIsDefinedPlane = false;
5347 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5348 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5349 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5350 TPlaneInfo& aPlaneInfo = *anIter;
5351 if( aPlaneInfo.PlaneId == aPlaneId ) {
5352 aPlaneInfo.ActorList.push_back( aSmeshActor );
5353 anIsDefinedPlane = true;
5357 if( !anIsDefinedPlane ) {
5358 TPlaneInfo aPlaneInfo;
5359 aPlaneInfo.PlaneId = aPlaneId;
5360 aPlaneInfo.ActorList.push_back( aSmeshActor );
5361 aPlaneInfo.ViewManager = vman;
5362 aPlaneInfoList.push_back( aPlaneInfo );
5367 } // if (aSmeshActor)
5368 } // other parameters than Visibility
5370 } // for names/parameters iterator
5371 } // for entries iterator
5373 // add clipping planes to actors according to the restored parameters
5374 // and update the clipping plane map
5375 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5376 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5377 int aViewId = anIter1->first;
5378 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5380 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5381 if( anIter2 == aPlaneDataMap.end() )
5383 const TPlaneDataList& aPlaneDataList = anIter2->second;
5385 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5386 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5387 const TPlaneInfo& aPlaneInfo = *anIter3;
5388 int aPlaneId = aPlaneInfo.PlaneId;
5389 const TActorList& anActorList = aPlaneInfo.ActorList;
5390 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5394 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5398 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5400 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5401 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5402 const TPlaneData& aPlaneData = *anIter4;
5403 if( aPlaneData.Id == aPlaneId ) {
5404 SMESH::OrientedPlane* aPlane =
5405 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5407 (SMESH::Orientation)aPlaneData.Orientation,
5408 aPlaneData.Distance,
5411 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5412 aClippingPlaneInfo.Plane = aPlane;
5413 aClippingPlaneInfo.ActorList = anActorList;
5414 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5422 // update all VTK views
5423 QList<SUIT_ViewManager*> lst;
5424 getApp()->viewManagers(lst);
5425 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5426 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5427 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5428 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5429 vtkView->getRenderer()->ResetCameraClippingRange();
5436 \brief Adds preferences for dfont of VTK viewer
5438 \param pIf group identifier
5439 \param param parameter
5440 \return identifier of preferences
5442 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5444 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5446 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5449 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5450 fam.append( tr( "SMESH_FONT_COURIER" ) );
5451 fam.append( tr( "SMESH_FONT_TIMES" ) );
5453 setPreferenceProperty( tfont, "fonts", fam );
5455 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5456 setPreferenceProperty( tfont, "features", f );
5462 \brief Actions after hypothesis edition
5463 Updates object browser after hypothesis edition
5465 void SMESHGUI::onHypothesisEdit( int result )
5468 SMESHGUI::Modified();
5469 updateObjBrowser( true );