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);
1437 // 0019923: EDF 765 SMESH : default values of hypothesis
1438 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1439 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1440 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1441 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1442 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1445 myActiveDialogBox = 0;
1446 myFilterLibraryDlg = 0;
1450 myEventCallbackCommand = vtkCallbackCommand::New();
1451 myEventCallbackCommand->Delete();
1452 myEventCallbackCommand->SetClientData( this );
1453 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1456 SMESH::GetFilterManager();
1457 SMESH::GetPattern();
1458 SMESH::GetMeasurements();
1460 /* load resources for all available meshers */
1461 SMESH::InitAvailableHypotheses();
1464 //=============================================================================
1468 //=============================================================================
1469 SMESHGUI::~SMESHGUI()
1471 #ifdef WITHGENERICOBJ
1472 SMESH::GetFilterManager()->Destroy();
1473 SMESH::GetMeasurements()->Destroy();
1475 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1476 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1479 //=============================================================================
1483 //=============================================================================
1484 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1486 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1488 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1493 //=============================================================================
1497 //=============================================================================
1498 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1500 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1504 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1505 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1506 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1507 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1508 return autoUpdate && !exceeded;
1511 //=============================================================================
1515 //=============================================================================
1516 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1518 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1521 //=============================================================================
1525 //=============================================================================
1526 SMESHGUI* SMESHGUI::GetSMESHGUI()
1528 SMESHGUI* smeshMod = 0;
1529 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1532 CAM_Module* module = app->module( "Mesh" );
1533 smeshMod = dynamic_cast<SMESHGUI*>( module );
1536 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1538 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1541 _PTR(Study) aStudy = study->studyDS();
1543 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1552 Standard_EXPORT SMESHGUI* GetComponentGUI()
1554 return SMESHGUI::GetSMESHGUI();
1558 //=============================================================================
1562 //=============================================================================
1563 void SMESHGUI::SetState(int aState)
1568 //=============================================================================
1572 //=============================================================================
1573 void SMESHGUI::ResetState()
1578 //=============================================================================
1582 //=============================================================================
1583 void SMESHGUI::EmitSignalDeactivateDialog()
1585 emit SignalDeactivateActiveDialog();
1588 //=============================================================================
1592 //=============================================================================
1593 void SMESHGUI::EmitSignalStudyFrameChanged()
1595 emit SignalStudyFrameChanged();
1598 //=============================================================================
1602 //=============================================================================
1603 void SMESHGUI::EmitSignalCloseAllDialogs()
1605 emit SignalCloseAllDialogs();
1608 //=============================================================================
1612 //=============================================================================
1613 void SMESHGUI::EmitSignalVisibilityChanged()
1615 emit SignalVisibilityChanged();
1618 //=============================================================================
1622 //=============================================================================
1623 QDialog *SMESHGUI::GetActiveDialogBox()
1625 return myActiveDialogBox;
1628 //=============================================================================
1632 //=============================================================================
1633 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1635 myActiveDialogBox = (QDialog *) aDlg;
1639 //=============================================================================
1643 //=============================================================================
1644 SUIT_Desktop* SMESHGUI::desktop()
1646 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1648 return app->desktop();
1653 //=============================================================================
1657 //=============================================================================
1658 SalomeApp_Study* SMESHGUI::activeStudy()
1660 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1662 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1667 //=============================================================================
1671 //=============================================================================
1672 void SMESHGUI::Modified( bool theIsUpdateActions )
1674 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1675 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1676 appStudy->Modified();
1677 if( theIsUpdateActions )
1678 app->updateActions();
1683 //=============================================================================
1687 //=============================================================================
1688 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1690 /* Here the position is on the bottom right corner - 10 */
1691 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1693 SUIT_Desktop *PP = desktop();
1694 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1695 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1699 //=============================================================================
1703 //=============================================================================
1704 static int isStudyLocked(_PTR(Study) theStudy){
1705 return theStudy->GetProperties()->IsLocked();
1708 static bool checkLock(_PTR(Study) theStudy) {
1709 if (isStudyLocked(theStudy)) {
1710 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1711 QObject::tr("WRN_WARNING"),
1712 QObject::tr("WRN_STUDY_LOCKED") );
1718 //=======================================================================
1719 //function : CheckActiveStudyLocked
1721 //=======================================================================
1723 bool SMESHGUI::isActiveStudyLocked()
1725 _PTR(Study) aStudy = activeStudy()->studyDS();
1726 return checkLock( aStudy );
1729 //=============================================================================
1733 //=============================================================================
1734 bool SMESHGUI::OnGUIEvent( int theCommandID )
1736 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1740 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1741 SUIT_ResourceMgr* mgr = resourceMgr();
1745 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1746 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1749 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1750 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1752 //QAction* act = action( theCommandID );
1754 switch (theCommandID) {
1756 if(checkLock(aStudy)) break;
1764 if(checkLock(aStudy)) break;
1765 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1769 case 150: //MED FILE INFORMATION
1771 SALOME_ListIO selected;
1772 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1774 aSel->selectedObjects( selected );
1775 if( selected.Extent() )
1777 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1778 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1779 if ( !aMesh->_is_nil() )
1781 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1788 case 122: // EXPORT MED
1797 ::ExportMeshToFile(theCommandID);
1801 case 200: // SCALAR BAR
1803 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1804 SALOME_ListIO selected;
1806 aSel->selectedObjects( selected );
1808 if( selected.Extent() ) {
1809 Handle(SALOME_InteractiveObject) anIO = selected.First();
1810 if( anIO->hasEntry() ) {
1811 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1812 anActor->SetControlMode( SMESH_Actor::eNone );
1820 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1825 // dump control distribution data to the text file
1826 ::SaveDistribution();
1832 // show/ distribution
1833 ::ShowDistribution();
1843 ::DisableAutoColor();
1846 case 1134: // Clipping
1847 case 1133: // Tranparency
1848 case 1132: // Colors / Size
1855 ::SetDisplayMode(theCommandID, myMarkerMap);
1858 //2D quadratic representation
1861 ::SetDisplayMode(theCommandID, myMarkerMap);
1865 case 216: // 0D elements
1868 case 219: // Volumes
1869 case 220: // All Entity
1870 ::SetDisplayEntity(theCommandID);
1873 case 221: // Orientation of faces
1875 LightApp_SelectionMgr* mgr = selectionMgr();
1876 SALOME_ListIO selected; mgr->selectedObjects( selected );
1878 SALOME_ListIteratorOfListIO it(selected);
1879 for( ; it.More(); it.Next()) {
1880 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1881 if(anIObject->hasEntry()) {
1882 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1883 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1892 if(checkLock(aStudy)) break;
1894 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1897 SMESH::UpdateView();
1899 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1900 SMESH::OnVisuException();
1902 catch (...) { // PAL16774 (Crash after display of many groups)
1903 SMESH::OnVisuException();
1907 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1908 aSel->selectedObjects( l );
1909 aSel->setSelectedObjects( l );
1914 case 301: // DISPLAY
1915 case 302: // DISPLAY ONLY
1917 SMESH::EDisplaing anAction;
1918 switch (theCommandID) {
1919 case 300: anAction = SMESH::eErase; break;
1920 case 301: anAction = SMESH::eDisplay; break;
1921 case 302: anAction = SMESH::eDisplayOnly; break;
1924 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1925 SALOME_ListIO sel_objects, to_process;
1927 aSel->selectedObjects( sel_objects );
1929 if( theCommandID==302 )
1930 startOperation( myEraseAll );
1932 extractContainers( sel_objects, to_process );
1935 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1939 SALOME_ListIteratorOfListIO It( to_process );
1940 for ( ; It.More(); It.Next()) {
1941 Handle(SALOME_InteractiveObject) IOS = It.Value();
1942 if (IOS->hasEntry()) {
1943 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1944 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1945 break; // PAL16774 (Crash after display of many groups)
1947 if (anAction == SMESH::eDisplayOnly)
1948 anAction = SMESH::eDisplay;
1953 // PAL13338 + PAL15161 -->
1954 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1955 SMESH::UpdateView();
1956 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1958 // PAL13338 + PAL15161 <--
1960 catch (...) { // PAL16774 (Crash after display of many groups)
1961 SMESH::OnVisuException();
1964 if (anAction == SMESH::eErase) {
1966 aSel->setSelectedObjects( l1 );
1969 aSel->setSelectedObjects( to_process );
1976 if(checkLock(aStudy)) break;
1979 EmitSignalDeactivateDialog();
1981 ( new SMESHGUI_NodesDlg( this ) )->show();
1984 SUIT_MessageBox::warning(desktop(),
1985 tr("SMESH_WRN_WARNING"),
1986 tr("SMESH_WRN_VIEWER_VTK"));
1991 case 2151: // FILTER
1995 EmitSignalDeactivateDialog();
1996 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2001 case 701: // COMPUTE MESH
2002 case 711: // PRECOMPUTE MESH
2003 case 712: // EVALUATE MESH
2004 case 713: // MESH ORDER
2006 if (checkLock(aStudy)) break;
2007 startOperation( theCommandID );
2011 case 702: // Create mesh
2012 case 703: // Create sub-mesh
2013 case 704: // Edit mesh/sub-mesh
2014 startOperation( theCommandID );
2016 case 710: // Build compound mesh
2018 if (checkLock(aStudy)) break;
2019 EmitSignalDeactivateDialog();
2020 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2024 case 407: // DIAGONAL INVERSION
2025 case 408: // Delete diagonal
2029 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2030 tr( "NOT_A_VTK_VIEWER" ) );
2034 if ( checkLock( aStudy ) )
2037 /*Standard_Boolean aRes;
2038 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2039 if ( aMesh->_is_nil() )
2041 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2042 tr( "SMESH_BAD_SELECTION" ) );
2046 EmitSignalDeactivateDialog();
2047 if ( theCommandID == 407 )
2048 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2050 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2053 case 409: // Change orientation
2054 case 410: // Union of triangles
2055 case 411: // Cutting of quadrangles
2056 case 419: // Splitting volumes into tetrahedra
2060 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2061 tr( "NOT_A_VTK_VIEWER" ) );
2065 if ( checkLock( aStudy ) )
2068 EmitSignalDeactivateDialog();
2069 SMESHGUI_MultiEditDlg* aDlg = NULL;
2070 if ( theCommandID == 409 )
2071 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2072 else if ( theCommandID == 410 )
2073 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2074 else if ( theCommandID == 419 )
2075 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2077 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2082 case 412: // Smoothing
2084 if(checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2090 SUIT_MessageBox::warning(desktop(),
2091 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2095 case 413: // Extrusion
2097 if (checkLock(aStudy)) break;
2099 EmitSignalDeactivateDialog();
2100 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2102 SUIT_MessageBox::warning(desktop(),
2103 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2107 case 414: // Revolution
2109 if(checkLock(aStudy)) break;
2111 EmitSignalDeactivateDialog();
2112 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2115 SUIT_MessageBox::warning(desktop(),
2116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2120 case 415: // Pattern mapping
2122 if ( checkLock( aStudy ) )
2126 EmitSignalDeactivateDialog();
2127 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2130 SUIT_MessageBox::warning(desktop(),
2131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2135 case 416: // Extrusion along a path
2137 if (checkLock(aStudy)) break;
2139 EmitSignalDeactivateDialog();
2140 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2142 SUIT_MessageBox::warning(desktop(),
2143 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2147 case 417: // Convert mesh to quadratic
2149 startOperation( 417 );
2150 /* if (checkLock(aStudy)) break;
2152 EmitSignalDeactivateDialog();
2153 new SMESHGUI_ConvToQuadDlg();
2155 SUIT_MessageBox::warning(desktop(),
2156 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2160 case 418: // create 2D mesh from 3D
2162 startOperation( 418 );
2165 case 806: // CREATE GEO GROUP
2167 startOperation( 806 );
2170 case 801: // CREATE GROUP
2174 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2175 tr( "NOT_A_VTK_VIEWER" ) );
2179 if(checkLock(aStudy)) break;
2180 EmitSignalDeactivateDialog();
2181 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2183 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2184 SALOME_ListIO selected;
2186 aSel->selectedObjects( selected );
2188 int nbSel = selected.Extent();
2190 // check if mesh is selected
2191 aMesh = SMESH::GetMeshByIO( selected.First() );
2193 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2198 case 802: // CONSTRUCT GROUP
2202 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2203 tr( "NOT_A_VTK_VIEWER" ) );
2207 if(checkLock(aStudy)) break;
2208 EmitSignalDeactivateDialog();
2210 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2211 SALOME_ListIO selected;
2213 aSel->selectedObjects( selected );
2215 int nbSel = selected.Extent();
2217 // check if submesh is selected
2218 Handle(SALOME_InteractiveObject) IObject = selected.First();
2219 if (IObject->hasEntry()) {
2220 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2222 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2223 if (!aSubMesh->_is_nil()) {
2225 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2226 // get submesh elements list by types
2227 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2228 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2229 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2230 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2231 // create group for each type o elements
2232 QString aName = IObject->getName();
2233 if (aNodes->length() > 0) {
2234 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2235 aGroup->Add(aNodes.inout());
2237 if (aEdges->length() > 0) {
2238 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2239 aGroup->Add(aEdges.inout());
2241 if (aFaces->length() > 0) {
2242 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2243 aGroup->Add(aFaces.inout());
2245 if (aVolumes->length() > 0) {
2246 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2247 aGroup->Add(aVolumes.inout());
2252 catch(const SALOME::SALOME_Exception & S_ex){
2253 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2260 SUIT_MessageBox::warning(desktop(),
2261 tr("SMESH_WRN_WARNING"),
2262 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2267 case 803: // EDIT GROUP
2271 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2272 tr( "NOT_A_VTK_VIEWER" ) );
2276 if(checkLock(aStudy)) break;
2277 EmitSignalDeactivateDialog();
2279 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2280 SALOME_ListIO selected;
2282 aSel->selectedObjects( selected );
2284 SALOME_ListIteratorOfListIO It (selected);
2285 int nbSelectedGroups = 0;
2286 for ( ; It.More(); It.Next() )
2288 SMESH::SMESH_GroupBase_var aGroup =
2289 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2290 if (!aGroup->_is_nil()) {
2292 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2296 if (nbSelectedGroups == 0)
2298 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2304 case 804: // Add elements to group
2306 if(checkLock(aStudy)) break;
2307 if (myState == 800) {
2308 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2309 if (aDlg) aDlg->onAdd();
2314 case 805: // Remove elements from group
2316 if(checkLock(aStudy)) break;
2317 if (myState == 800) {
2318 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2319 if (aDlg) aDlg->onRemove();
2324 case 815: // Edit GEOM GROUP as standalone
2328 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2329 tr( "NOT_A_VTK_VIEWER" ) );
2333 if(checkLock(aStudy)) break;
2334 EmitSignalDeactivateDialog();
2336 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2337 SALOME_ListIO selected;
2339 aSel->selectedObjects( selected );
2341 SALOME_ListIteratorOfListIO It (selected);
2342 for ( ; It.More(); It.Next() )
2344 SMESH::SMESH_GroupOnGeom_var aGroup =
2345 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2346 if (!aGroup->_is_nil()) {
2347 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2354 case 810: // Union Groups
2355 case 811: // Intersect groups
2356 case 812: // Cut groups
2360 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2361 tr( "NOT_A_VTK_VIEWER" ) );
2365 if ( checkLock( aStudy ) )
2368 EmitSignalDeactivateDialog();
2370 SMESHGUI_GroupOpDlg* aDlg = 0;
2371 if ( theCommandID == 810 )
2372 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2373 else if ( theCommandID == 811 )
2374 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2376 aDlg = new SMESHGUI_CutGroupsDlg( this );
2383 case 814: // Create groups of entities from existing groups of superior dimensions
2385 if ( checkLock( aStudy ) )
2388 EmitSignalDeactivateDialog();
2389 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2395 case 813: // Delete groups with their contents
2399 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2400 tr( "NOT_A_VTK_VIEWER" ) );
2404 if ( checkLock( aStudy ) )
2407 EmitSignalDeactivateDialog();
2409 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2413 case 900: // MESH INFOS
2414 case 903: // WHAT IS
2416 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2417 EmitSignalDeactivateDialog();
2418 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2419 SALOME_ListIO selected;
2421 aSel->selectedObjects( selected );
2423 if ( selected.Extent() > 1 ) { // a dlg for each IO
2424 SALOME_ListIteratorOfListIO It( selected );
2425 for ( ; It.More(); It.Next() ) {
2426 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2427 dlg->showInfo( It.Value() );
2432 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2438 case 902: // STANDARD MESH INFOS
2440 EmitSignalDeactivateDialog();
2441 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2442 SALOME_ListIO selected;
2444 aSel->selectedObjects( selected );
2446 if ( selected.Extent() > 1 ) { // a dlg for each IO
2448 SALOME_ListIteratorOfListIO It (selected);
2449 for ( ; It.More(); It.Next() ) {
2451 IOs.Append( It.Value() );
2452 aSel->setSelectedObjects( IOs );
2453 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2455 // restore selection
2456 aSel->setSelectedObjects( selected );
2459 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2462 case 903: // WHAT IS
2464 EmitSignalDeactivateDialog();
2465 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2470 case 904: // FIND ELEM
2472 startOperation( theCommandID );
2476 case 1100: // EDIT HYPOTHESIS
2478 if(checkLock(aStudy)) break;
2480 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2481 SALOME_ListIO selected;
2483 aSel->selectedObjects( selected );
2485 int nbSel = selected.Extent();
2488 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2489 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2491 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2492 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2493 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2494 if ( !aHypothesis->_is_nil() )
2497 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2498 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2500 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2511 case 1101: // RENAME
2513 if ( checkLock( aStudy ) )
2516 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2517 SALOME_ListIO selected;
2519 aSel->selectedObjects( selected );
2521 bool isAny = false; // is there any appropriate object selected
2523 SALOME_ListIteratorOfListIO It( selected );
2524 for ( ; It.More(); It.Next() )
2526 Handle(SALOME_InteractiveObject) IObject = It.Value();
2527 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2528 _PTR(GenericAttribute) anAttr;
2529 _PTR(AttributeName) aName;
2532 if ( obj->FindAttribute(anAttr, "AttributeName") )
2535 QString newName = QString(aName->Value().c_str());
2537 // check type to prevent renaming of inappropriate objects
2538 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2539 if (aType == MESH || aType == GROUP ||
2540 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2541 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2542 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2543 aType == HYPOTHESIS || aType == ALGORITHM)
2546 newName = LightApp_NameDlg::getName(desktop(), newName);
2547 if ( !newName.isEmpty() )
2549 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2551 // update name of group object and its actor
2552 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2553 if( !aGroupObject->_is_nil() )
2555 aGroupObject->SetName( newName.toLatin1().data() );
2556 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2557 anActor->setName( newName.toLatin1().data() );
2568 SUIT_MessageBox::warning(desktop(),
2569 QObject::tr("SMESH_WRN_WARNING"),
2570 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2575 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2577 if(checkLock(aStudy)) break;
2578 SUIT_OverrideCursor wc;
2580 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2581 SALOME_ListIO selected;
2583 aSel->selectedObjects( selected, QString::null, false );
2585 SALOME_ListIteratorOfListIO It(selected);
2586 for (int i = 0; It.More(); It.Next(), i++) {
2587 Handle(SALOME_InteractiveObject) IObject = It.Value();
2588 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2591 aSel->setSelectedObjects( l1 );
2596 case 4009: // ELEM0D
2597 case 4010: // GEOM::EDGE
2598 case 4021: // TRIANGLE
2600 case 4023: // POLYGON
2604 if(checkLock(aStudy)) break;
2606 EmitSignalDeactivateDialog();
2607 SMDSAbs_ElementType type = SMDSAbs_Edge;
2609 switch (theCommandID) {
2610 case 4009: // ELEM0D
2611 type = SMDSAbs_0DElement; nbNodes = 1; break;
2612 case 4021: // TRIANGLE
2613 type = SMDSAbs_Face; nbNodes = 3; break;
2615 type = SMDSAbs_Face; nbNodes = 4; break;
2617 type = SMDSAbs_Volume; nbNodes = 4; break;
2618 case 4023: // POLYGON
2619 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2621 type = SMDSAbs_Volume; nbNodes = 8; break;
2622 case 4033: // POLYHEDRE
2623 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2626 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2629 SUIT_MessageBox::warning(desktop(),
2630 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2634 case 4033: // POLYHEDRON
2636 if(checkLock(aStudy)) break;
2638 EmitSignalDeactivateDialog();
2639 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2642 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2643 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2647 case 4034: // QUADRATIC EDGE
2648 case 4035: // QUADRATIC TRIANGLE
2649 case 4036: // QUADRATIC QUADRANGLE
2650 case 4037: // QUADRATIC TETRAHEDRON
2651 case 4038: // QUADRATIC PYRAMID
2652 case 4039: // QUADRATIC PENTAHEDRON
2653 case 4040: // QUADRATIC HEXAHEDRON
2655 if(checkLock(aStudy)) break;
2657 EmitSignalDeactivateDialog();
2660 switch (theCommandID) {
2662 type = QUAD_EDGE; break;
2664 type = QUAD_TRIANGLE; break;
2666 type = QUAD_QUADRANGLE; break;
2668 type = QUAD_TETRAHEDRON; break;
2670 type = QUAD_PYRAMID; break;
2672 type = QUAD_PENTAHEDRON; break;
2674 type = QUAD_HEXAHEDRON;
2678 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2681 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2682 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2686 case 4041: // REMOVES NODES
2688 if(checkLock(aStudy)) break;
2690 EmitSignalDeactivateDialog();
2691 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2694 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2695 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2699 case 4042: // REMOVES ELEMENTS
2701 if(checkLock(aStudy)) break;
2703 EmitSignalDeactivateDialog();
2704 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2708 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2709 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2713 case 4043: { // CLEAR_MESH
2715 if(checkLock(aStudy)) break;
2717 SALOME_ListIO selected;
2718 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2719 aSel->selectedObjects( selected );
2721 SUIT_OverrideCursor wc;
2722 SALOME_ListIteratorOfListIO It (selected);
2723 for ( ; It.More(); It.Next() )
2725 Handle(SALOME_InteractiveObject) IOS = It.Value();
2726 SMESH::SMESH_Mesh_var aMesh =
2727 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2728 if ( aMesh->_is_nil()) continue;
2730 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2732 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2733 SMESH::ModifiedMesh( aMeshSObj, false, true);
2734 // hide groups and submeshes
2735 _PTR(ChildIterator) anIter =
2736 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2737 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2739 _PTR(SObject) so = anIter->Value();
2740 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2743 catch (const SALOME::SALOME_Exception& S_ex){
2745 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2749 SMESH::UpdateView();
2753 case 4044: // REMOVE ORPHAN NODES
2755 if(checkLock(aStudy)) break;
2756 SALOME_ListIO selected;
2757 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2758 aSel->selectedObjects( selected );
2759 if ( selected.Extent() == 1 ) {
2760 Handle(SALOME_InteractiveObject) anIO = selected.First();
2761 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2762 if ( !aMesh->_is_nil() ) {
2763 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2764 tr( "SMESH_WARNING" ),
2765 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2766 SUIT_MessageBox::Yes |
2767 SUIT_MessageBox::No,
2768 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2771 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2772 int removed = aMeshEditor->RemoveOrphanNodes();
2773 SUIT_MessageBox::information(SMESHGUI::desktop(),
2774 tr("SMESH_INFORMATION"),
2775 tr("NB_NODES_REMOVED").arg(removed));
2776 if ( removed > 0 ) {
2777 SMESH::UpdateView();
2778 SMESHGUI::Modified();
2781 catch (const SALOME::SALOME_Exception& S_ex) {
2782 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2791 case 4051: // RENUMBERING NODES
2793 if(checkLock(aStudy)) break;
2795 EmitSignalDeactivateDialog();
2796 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2800 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2801 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2805 case 4052: // RENUMBERING ELEMENTS
2807 if(checkLock(aStudy)) break;
2809 EmitSignalDeactivateDialog();
2810 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2814 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2815 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2819 case 4061: // TRANSLATION
2821 if(checkLock(aStudy)) break;
2823 EmitSignalDeactivateDialog();
2824 ( new SMESHGUI_TranslationDlg( this ) )->show();
2827 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2828 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2832 case 4062: // ROTATION
2834 if(checkLock(aStudy)) break;
2836 EmitSignalDeactivateDialog();
2837 ( new SMESHGUI_RotationDlg( this ) )->show();
2840 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2841 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2845 case 4063: // SYMMETRY
2847 if(checkLock(aStudy)) break;
2849 EmitSignalDeactivateDialog();
2850 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2853 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2854 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2858 case 4064: // SEWING
2860 if(checkLock(aStudy)) break;
2862 EmitSignalDeactivateDialog();
2863 ( new SMESHGUI_SewingDlg( this ) )->show();
2866 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2867 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2871 case 4065: // MERGE NODES
2873 if(checkLock(aStudy)) break;
2875 EmitSignalDeactivateDialog();
2876 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2879 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2880 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2884 case 4066: // MERGE EQUAL ELEMENTS
2886 if (checkLock(aStudy)) break;
2888 EmitSignalDeactivateDialog();
2889 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2891 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2892 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2897 case 4067: // MAKE MESH PASS THROUGH POINT
2898 startOperation( 4067 );
2903 if(checkLock(aStudy)) break;
2905 EmitSignalDeactivateDialog();
2906 ( new SMESHGUI_ScaleDlg( this ) )->show();
2909 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2910 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2915 case 4069: // DUPLICATE NODES
2917 if(checkLock(aStudy)) break;
2919 EmitSignalDeactivateDialog();
2920 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2923 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2924 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2929 case 5105: // Library of selection filters
2931 static QList<int> aTypes;
2932 if ( aTypes.isEmpty() )
2934 aTypes.append( SMESH::NODE );
2935 aTypes.append( SMESH::EDGE );
2936 aTypes.append( SMESH::FACE );
2937 aTypes.append( SMESH::VOLUME );
2939 if (!myFilterLibraryDlg)
2940 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2941 else if (myFilterLibraryDlg->isHidden())
2942 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2943 myFilterLibraryDlg->raise();
2947 case 6017: // CONTROLS
2967 LightApp_SelectionMgr* mgr = selectionMgr();
2968 SALOME_ListIO selected; mgr->selectedObjects( selected );
2970 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2971 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2973 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2974 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2975 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2976 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2977 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2978 ::Control( theCommandID );
2983 SUIT_MessageBox::warning(desktop(),
2984 tr( "SMESH_WRN_WARNING" ),
2985 tr( "SMESH_BAD_SELECTION" ) );
2989 SUIT_MessageBox::warning(desktop(),
2990 tr( "SMESH_WRN_WARNING" ),
2991 tr( "NOT_A_VTK_VIEWER" ) );
2996 LightApp_SelectionMgr* mgr = selectionMgr();
2997 SALOME_ListIO selected; mgr->selectedObjects( selected );
2999 SALOME_ListIteratorOfListIO it(selected);
3000 for( ; it.More(); it.Next()) {
3001 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3002 if(anIObject->hasEntry()) {
3003 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3004 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3012 LightApp_SelectionMgr* mgr = selectionMgr();
3013 SALOME_ListIO selected; mgr->selectedObjects( selected );
3015 SALOME_ListIteratorOfListIO it(selected);
3016 for( ; it.More(); it.Next()) {
3017 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3018 if(anIObject->hasEntry())
3019 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3020 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3028 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3029 EmitSignalDeactivateDialog();
3030 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3036 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3037 //updateObjBrowser();
3041 //=============================================================================
3045 //=============================================================================
3046 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3051 //=============================================================================
3055 //=============================================================================
3056 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3061 //=============================================================================
3065 //=============================================================================
3066 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3071 //=============================================================================
3072 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3073 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3075 //=============================================================================
3076 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3077 SUIT_ViewWindow* wnd )
3079 if(theIO->hasEntry()){
3080 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3081 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3085 //=======================================================================
3086 // function : createSMESHAction
3088 //=======================================================================
3089 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3090 const int key, const bool toggle, const QString& shortcutAction )
3093 QWidget* parent = application()->desktop();
3094 SUIT_ResourceMgr* resMgr = resourceMgr();
3096 if ( !icon_id.isEmpty() )
3097 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3099 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3100 if ( !pix.isNull() )
3101 icon = QIcon( pix );
3103 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3104 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3105 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3107 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3108 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3111 //=======================================================================
3112 // function : createPopupItem
3114 //=======================================================================
3115 void SMESHGUI::createPopupItem( const int id,
3116 const QString& clients,
3117 const QString& types,
3118 const QString& theRule,
3123 parentId = popupMgr()->actionId( action( pId ) );
3125 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3126 popupMgr()->insert( action( id ), parentId, 0 );
3128 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3129 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3130 QString rule = "(%1) and (%2) and (%3)";
3131 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3132 if( clients.isEmpty() )
3133 rule = rule.arg( QString( "true" ) );
3135 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3136 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3139 bool cont = myRules.contains( id );
3141 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3143 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3144 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3147 //=======================================================================
3148 // function : initialize
3150 //=======================================================================
3151 void SMESHGUI::initialize( CAM_Application* app )
3153 SalomeApp_Module::initialize( app );
3155 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3157 /* Automatic Update flag */
3158 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3160 // ----- create actions --------------
3162 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3163 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3164 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3165 createSMESHAction( 114, "NUM" );
3166 createSMESHAction( 121, "DAT" );
3167 createSMESHAction( 122, "MED" );
3168 createSMESHAction( 123, "UNV" );
3169 createSMESHAction( 140, "STL" );
3170 createSMESHAction( 124, "EXPORT_DAT" );
3171 createSMESHAction( 125, "EXPORT_MED" );
3172 createSMESHAction( 126, "EXPORT_UNV" );
3173 createSMESHAction( 141, "EXPORT_STL" );
3174 createSMESHAction( 150, "FILE_INFO" );
3175 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3176 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3177 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3178 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3179 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3180 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3181 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3182 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3183 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3184 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3185 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3186 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3187 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3188 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3189 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3190 createSMESHAction( 804, "ADD" );
3191 createSMESHAction( 805, "REMOVE" );
3192 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3193 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3194 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3195 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3196 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3197 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3198 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3199 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3200 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3201 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3202 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3203 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3204 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3205 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3206 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3207 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3208 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3209 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3210 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3211 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3212 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3213 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3214 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3215 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3216 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3217 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3218 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3219 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3220 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3221 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3222 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3223 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3224 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3225 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3226 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3227 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3228 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3229 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3230 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3231 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3232 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3233 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3234 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3235 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3236 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3237 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3238 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3239 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3240 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3241 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3242 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3243 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3244 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3245 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3246 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3247 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3248 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3249 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3250 createSMESHAction( 415, "MAP", "ICON_MAP" );
3251 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3252 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3253 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3254 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3255 createSMESHAction( 200, "RESET" );
3256 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3257 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3258 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3259 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3260 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3261 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3262 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3263 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3264 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3265 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3266 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3267 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3268 createSMESHAction( 220, "ALL" );
3269 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3271 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3272 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3274 createSMESHAction( 1100, "EDIT_HYPO" );
3275 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3276 createSMESHAction( 1102, "UNASSIGN" );
3277 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3278 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3279 createSMESHAction( 1131, "DISPMODE" );
3280 createSMESHAction( 1132, "COLORS" );
3281 createSMESHAction( 1133, "TRANSP" );
3282 createSMESHAction( 1134, "CLIP" );
3283 createSMESHAction( 1135, "DISP_ENT" );
3284 createSMESHAction( 1136, "AUTO_COLOR" );
3285 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3286 createSMESHAction( 2000, "CTRL" );
3288 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3289 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3291 createSMESHAction( 300, "ERASE" );
3292 createSMESHAction( 301, "DISPLAY" );
3293 createSMESHAction( 302, "DISPLAY_ONLY" );
3294 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3295 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3296 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3297 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3298 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3299 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3300 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3301 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3303 // ----- create menu --------------
3304 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3305 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3306 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3307 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3308 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3309 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3310 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3311 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3313 createMenu( separator(), fileId );
3315 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3316 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3317 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3318 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3319 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3320 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3321 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3322 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3323 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3324 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3326 createMenu( 111, importId, -1 );
3327 createMenu( 112, importId, -1 );
3328 createMenu( 113, importId, -1 );
3330 createMenu( 121, exportId, -1 );
3331 createMenu( 122, exportId, -1 );
3332 createMenu( 123, exportId, -1 );
3333 createMenu( 140, exportId, -1 ); // export to stl STL
3335 createMenu( separator(), fileId, 10 );
3337 createMenu( 33, editId, -1 );
3339 createMenu( 5105, toolsId, -1 );
3341 createMenu( 702, meshId, -1 ); // "Mesh" menu
3342 createMenu( 703, meshId, -1 );
3343 createMenu( 704, meshId, -1 );
3344 createMenu( 710, meshId, -1 );
3345 createMenu( separator(), meshId, -1 );
3346 createMenu( 701, meshId, -1 );
3347 createMenu( 711, meshId, -1 );
3348 createMenu( 712, meshId, -1 );
3349 createMenu( 713, meshId, -1 );
3350 createMenu( separator(), meshId, -1 );
3351 createMenu( 801, meshId, -1 );
3352 createMenu( 806, meshId, -1 );
3353 createMenu( 802, meshId, -1 );
3354 createMenu( 803, meshId, -1 );
3355 createMenu( 815, meshId, -1 );
3356 createMenu( separator(), meshId, -1 );
3357 createMenu( 810, meshId, -1 );
3358 createMenu( 811, meshId, -1 );
3359 createMenu( 812, meshId, -1 );
3360 createMenu( separator(), meshId, -1 );
3361 createMenu( 814, meshId, -1 );
3362 createMenu( separator(), meshId, -1 );
3363 createMenu( 813, meshId, -1 );
3364 createMenu( separator(), meshId, -1 );
3365 createMenu( 900, meshId, -1 );
3366 //createMenu( 902, meshId, -1 );
3367 createMenu( 903, meshId, -1 );
3368 createMenu( 904, meshId, -1 );
3369 createMenu( separator(), meshId, -1 );
3371 createMenu( 6005, nodeId, -1 );
3372 createMenu( 6002, edgeId, -1 );
3373 createMenu( 6003, edgeId, -1 );
3374 createMenu( 6001, edgeId, -1 );
3375 createMenu( 6004, edgeId, -1 );
3376 createMenu( 6021, faceId, -1 );
3377 createMenu( 6018, faceId, -1 );
3378 createMenu( 6019, faceId, -1 );
3379 createMenu( 6011, faceId, -1 );
3380 createMenu( 6012, faceId, -1 );
3381 createMenu( 6013, faceId, -1 );
3382 createMenu( 6014, faceId, -1 );
3383 createMenu( 6015, faceId, -1 );
3384 createMenu( 6016, faceId, -1 );
3385 createMenu( 6022, faceId, -1 );
3386 createMenu( 6017, volumeId, -1 );
3387 createMenu( 6009, volumeId, -1 );
3388 createMenu( 6023, volumeId, -1 );
3390 createMenu( 4000, addId, -1 );
3391 createMenu( 4009, addId, -1 );
3392 createMenu( 4010, addId, -1 );
3393 createMenu( 4021, addId, -1 );
3394 createMenu( 4022, addId, -1 );
3395 createMenu( 4023, addId, -1 );
3396 createMenu( 4031, addId, -1 );
3397 createMenu( 4032, addId, -1 );
3398 createMenu( 4033, addId, -1 );
3399 createMenu( separator(), addId, -1 );
3400 createMenu( 4034, addId, -1 );
3401 createMenu( 4035, addId, -1 );
3402 createMenu( 4036, addId, -1 );
3403 createMenu( 4037, addId, -1 );
3404 createMenu( 4038, addId, -1 );
3405 createMenu( 4039, addId, -1 );
3406 createMenu( 4040, addId, -1 );
3408 createMenu( 4041, removeId, -1 );
3409 createMenu( 4042, removeId, -1 );
3410 createMenu( 4044, removeId, -1 );
3411 createMenu( separator(), removeId, -1 );
3412 createMenu( 4043, removeId, -1 );
3414 createMenu( 4051, renumId, -1 );
3415 createMenu( 4052, renumId, -1 );
3417 createMenu( 4061, transfId, -1 );
3418 createMenu( 4062, transfId, -1 );
3419 createMenu( 4063, transfId, -1 );
3420 createMenu( 4064, transfId, -1 );
3421 createMenu( 4065, transfId, -1 );
3422 createMenu( 4066, transfId, -1 );
3423 createMenu( 4068, transfId, -1 );
3424 createMenu( 4069, transfId, -1 );
3426 createMenu( 4067,modifyId, -1 );
3427 createMenu( 407, modifyId, -1 );
3428 createMenu( 408, modifyId, -1 );
3429 createMenu( 409, modifyId, -1 );
3430 createMenu( 410, modifyId, -1 );
3431 createMenu( 411, modifyId, -1 );
3432 createMenu( 419, modifyId, -1 );
3433 createMenu( 412, modifyId, -1 );
3434 createMenu( 413, modifyId, -1 );
3435 createMenu( 416, modifyId, -1 );
3436 createMenu( 414, modifyId, -1 );
3437 createMenu( 415, modifyId, -1 );
3438 createMenu( 417, modifyId, -1 );
3439 createMenu( 418, modifyId, -1 );
3441 createMenu( 501, measureId, -1 );
3442 createMenu( 502, measureId, -1 );
3443 createMenu( 214, viewId, -1 );
3445 // ----- create toolbars --------------
3446 int meshTb = createTool( tr( "TB_MESH" ) ),
3447 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3448 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3449 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3450 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3452 createTool( 702, meshTb );
3453 createTool( 703, meshTb );
3454 createTool( 704, meshTb );
3455 createTool( 710, meshTb );
3456 createTool( separator(), meshTb );
3457 createTool( 701, meshTb );
3458 createTool( 711, meshTb );
3459 createTool( 712, meshTb );
3460 createTool( 713, meshTb );
3461 createTool( separator(), meshTb );
3462 createTool( 801, meshTb );
3463 createTool( 806, meshTb );
3464 createTool( 802, meshTb );
3465 createTool( 803, meshTb );
3466 //createTool( 815, meshTb );
3467 createTool( separator(), meshTb );
3468 createTool( 900, meshTb );
3469 //createTool( 902, meshTb );
3470 createTool( 903, meshTb );
3471 createTool( 904, meshTb );
3472 createTool( separator(), meshTb );
3474 createTool( 6005, ctrlTb );
3475 createTool( separator(), ctrlTb );
3476 createTool( 6002, ctrlTb );
3477 createTool( 6003, ctrlTb );
3478 createTool( 6001, ctrlTb );
3479 createTool( 6004, ctrlTb );
3480 createTool( separator(), ctrlTb );
3481 createTool( 6021, ctrlTb );
3482 createTool( 6018, ctrlTb );
3483 createTool( 6019, ctrlTb );
3484 createTool( 6011, ctrlTb );
3485 createTool( 6012, ctrlTb );
3486 createTool( 6013, ctrlTb );
3487 createTool( 6014, ctrlTb );
3488 createTool( 6015, ctrlTb );
3489 createTool( 6016, ctrlTb );
3490 createTool( 6022, ctrlTb );
3491 createTool( separator(), ctrlTb );
3492 createTool( 6017, ctrlTb );
3493 createTool( 6009, ctrlTb );
3494 createTool( 6023, ctrlTb );
3495 createTool( separator(), ctrlTb );
3497 createTool( 4000, addRemTb );
3498 createTool( 4009, addRemTb );
3499 createTool( 4010, addRemTb );
3500 createTool( 4021, addRemTb );
3501 createTool( 4022, addRemTb );
3502 createTool( 4023, addRemTb );
3503 createTool( 4031, addRemTb );
3504 createTool( 4032, addRemTb );
3505 createTool( 4033, addRemTb );
3506 createTool( separator(), addRemTb );
3507 createTool( 4034, addRemTb );
3508 createTool( 4035, addRemTb );
3509 createTool( 4036, addRemTb );
3510 createTool( 4037, addRemTb );
3511 createTool( 4038, addRemTb );
3512 createTool( 4039, addRemTb );
3513 createTool( 4040, addRemTb );
3514 createTool( separator(), addRemTb );
3515 createTool( 4041, addRemTb );
3516 createTool( 4042, addRemTb );
3517 createTool( 4044, addRemTb );
3518 createTool( 4043, addRemTb );
3519 createTool( separator(), addRemTb );
3520 createTool( 4051, addRemTb );
3521 createTool( 4052, addRemTb );
3522 createTool( separator(), addRemTb );
3523 createTool( 4061, addRemTb );
3524 createTool( 4062, addRemTb );
3525 createTool( 4063, addRemTb );
3526 createTool( 4064, addRemTb );
3527 createTool( 4065, addRemTb );
3528 createTool( 4066, addRemTb );
3529 createTool( 4068, addRemTb );
3530 createTool( 4069, addRemTb );
3531 createTool( separator(), addRemTb );
3533 createTool( 4067,modifyTb );
3534 createTool( 407, modifyTb );
3535 createTool( 408, modifyTb );
3536 createTool( 409, modifyTb );
3537 createTool( 410, modifyTb );
3538 createTool( 411, modifyTb );
3539 createTool( 419, modifyTb );
3540 createTool( 412, modifyTb );
3541 createTool( 413, modifyTb );
3542 createTool( 416, modifyTb );
3543 createTool( 414, modifyTb );
3544 createTool( 415, modifyTb );
3545 createTool( 417, modifyTb );
3546 createTool( 418, modifyTb );
3548 createTool( 214, dispModeTb );
3550 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3551 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3554 QString OB = "'ObjectBrowser'",
3555 View = "'" + SVTK_Viewer::Type() + "'",
3557 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3558 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3559 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3560 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3561 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3562 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3563 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3564 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3565 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3566 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3567 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3569 mesh_group = mesh + " " + subMesh + " " + group,
3570 hyp_alg = hypo + " " + algo;
3572 // popup for object browser
3574 isInvisible("not( isVisible )"),
3575 isEmpty("numberOfNodes = 0"),
3576 isNotEmpty("numberOfNodes <> 0"),
3578 // has nodes, edges, etc in VISIBLE! actor
3579 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3580 hasElems("(count( elemTypes ) > 0)"),
3581 hasDifferentElems("(count( elemTypes ) > 1)"),
3582 hasElems0d("({'Elem0d'} in elemTypes)"),
3583 hasEdges("({'Edge'} in elemTypes)"),
3584 hasFaces("({'Face'} in elemTypes)"),
3585 hasVolumes("({'Volume'} in elemTypes)");
3587 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3588 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3589 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3590 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3591 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3592 createPopupItem( 803, OB, group ); // EDIT_GROUP
3593 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3595 popupMgr()->insert( separator(), -1, 0 );
3596 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3597 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3598 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3599 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3600 createPopupItem( 214, OB, mesh_group ); // UPDATE
3601 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3602 //createPopupItem( 902, OB, mesh ); // STD_INFO
3603 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3604 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3605 popupMgr()->insert( separator(), -1, 0 );
3606 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3607 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3608 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3609 popupMgr()->insert( separator(), -1, 0 );
3610 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3611 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3612 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3613 popupMgr()->insert( separator(), -1, 0 );
3614 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3615 popupMgr()->insert( separator(), -1, 0 );
3616 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3617 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3618 popupMgr()->insert( separator(), -1, 0 );
3620 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3621 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3623 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3624 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3625 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3626 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3627 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3628 popupMgr()->insert( separator(), -1, 0 );
3631 createPopupItem( 803, View, group ); // EDIT_GROUP
3632 createPopupItem( 804, View, elems ); // ADD
3633 createPopupItem( 805, View, elems ); // REMOVE
3635 popupMgr()->insert( separator(), -1, 0 );
3636 createPopupItem( 214, View, mesh_group ); // UPDATE
3637 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3638 //createPopupItem( 902, View, mesh ); // STD_INFO
3639 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3640 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3641 popupMgr()->insert( separator(), -1, 0 );
3643 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3644 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3645 popupMgr()->insert( separator(), -1, 0 );
3648 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3649 QString aType = QString( "%1type in {%2}" ).arg( lc );
3650 aType = aType.arg( mesh_group );
3651 QString aMeshInVTK = aClient + "&&" + aType;
3653 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3654 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3655 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3657 //-------------------------------------------------
3659 //-------------------------------------------------
3660 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3662 popupMgr()->insert( action( 9010 ), anId, -1 );
3663 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3664 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3666 popupMgr()->insert( action( 9011 ), anId, -1 );
3667 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3668 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3670 popupMgr()->insert( separator(), -1, -1 );
3672 //-------------------------------------------------
3674 //-------------------------------------------------
3675 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3677 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3678 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3679 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3681 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3682 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3683 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3685 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3686 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3687 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3689 popupMgr()->insert( separator(), anId, -1 );
3691 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3692 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3693 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3695 //-------------------------------------------------
3697 //-------------------------------------------------
3698 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3700 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3702 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3703 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3704 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3706 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3707 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3708 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3710 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3711 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3712 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3714 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3715 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3716 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3718 popupMgr()->insert( separator(), anId, -1 );
3720 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3721 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3724 //-------------------------------------------------
3725 // Representation of the 2D Quadratic elements
3726 //-------------------------------------------------
3727 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3728 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3729 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3730 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3732 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3733 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3734 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3736 //-------------------------------------------------
3737 // Orientation of faces
3738 //-------------------------------------------------
3739 popupMgr()->insert( action( 221 ), -1, -1 );
3740 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3741 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3743 //-------------------------------------------------
3745 //-------------------------------------------------
3746 popupMgr()->insert( action( 1132 ), -1, -1 );
3747 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3749 //-------------------------------------------------
3751 //-------------------------------------------------
3752 popupMgr()->insert( action( 1133 ), -1, -1 );
3753 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3755 //-------------------------------------------------
3757 //-------------------------------------------------
3759 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3760 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3761 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3762 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3764 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3766 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3767 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3769 popupMgr()->insert( separator(), anId, -1 );
3771 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3773 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3774 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3775 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3777 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3779 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3780 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3781 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3783 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3784 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3785 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3787 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3788 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3789 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3791 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3792 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3793 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3795 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3797 popupMgr()->insert( action( 6021 ), aSubId, -1 ); // FREE_FACE
3798 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3799 QtxPopupMgr::VisibleRule );
3800 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3802 popupMgr()->insert( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3803 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3804 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3806 popupMgr()->insert( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3807 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3808 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3810 popupMgr()->insert( action( 6011 ), aSubId, -1 ); // AREA
3811 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3812 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3814 popupMgr()->insert( action( 6012 ), aSubId, -1 ); // TAPER
3815 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3816 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3818 popupMgr()->insert( action( 6013 ), aSubId, -1 ); // ASPECT
3819 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3820 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3822 popupMgr()->insert( action( 6014 ), aSubId, -1 ); // MIN_ANG
3823 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3824 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3826 popupMgr()->insert( action( 6015 ), aSubId, -1 ); // WARP
3827 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3828 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3830 popupMgr()->insert( action( 6016 ), aSubId, -1 ); // SKEW
3831 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3832 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3834 popupMgr()->insert( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3835 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3836 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3838 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3840 popupMgr()->insert( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3841 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3842 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3844 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3845 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3846 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3848 popupMgr()->insert( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3849 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3850 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3852 popupMgr()->insert( separator(), anId, -1 );
3854 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3855 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3857 popupMgr()->insert( separator(), anId, -1 );
3859 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3860 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3862 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3863 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3864 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3867 popupMgr()->insert( separator(), -1, -1 );
3869 //-------------------------------------------------
3871 //-------------------------------------------------
3872 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3873 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3874 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3875 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3877 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3878 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3880 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3881 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3883 popupMgr()->insert( separator(), -1, -1 );
3885 //-------------------------------------------------
3887 //-------------------------------------------------
3888 popupMgr()->insert( action( 1134 ), -1, -1 );
3889 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3891 popupMgr()->insert( separator(), -1, -1 );
3893 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3894 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3896 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3897 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3900 //================================================================================
3902 * \brief Return true if SMESH or GEOM objects are selected.
3903 * Is called form LightApp_Module::activateModule() which clear selection if
3904 * not isSelectionCompatible()
3906 //================================================================================
3908 bool SMESHGUI::isSelectionCompatible()
3910 bool isCompatible = true;
3911 SALOME_ListIO selected;
3912 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3913 Sel->selectedObjects( selected );
3915 SALOME_ListIteratorOfListIO It( selected );
3916 for ( ; isCompatible && It.More(); It.Next())
3918 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3919 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3921 return isCompatible;
3925 bool SMESHGUI::reusableOperation( const int id )
3927 // compute, evaluate and precompute are not reusable operations
3928 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3931 bool SMESHGUI::activateModule( SUIT_Study* study )
3933 bool res = SalomeApp_Module::activateModule( study );
3935 setMenuShown( true );
3936 setToolShown( true );
3938 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
3939 PyGILState_STATE gstate = PyGILState_Ensure();
3940 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
3941 if(pluginsmanager==NULL)
3945 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
3950 PyGILState_Release(gstate);
3951 // end of GEOM plugins loading
3953 // Reset actions accelerator keys
3954 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3955 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3956 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3958 action( 33)->setEnabled(true); // Delete: Key_Delete
3959 action(1101)->setEnabled(true); // Rename: Key_F2
3961 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3962 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3963 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3964 if ( _PTR(Study) aStudy = s->studyDS()) {
3965 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3966 updateObjBrowser(); // objects can be removed
3972 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3974 setMenuShown( false );
3975 setToolShown( false );
3977 EmitSignalCloseAllDialogs();
3979 // Unset actions accelerator keys
3980 action(111)->setShortcut(QKeySequence()); // Import DAT
3981 action(112)->setShortcut(QKeySequence()); // Import UNV
3982 action(113)->setShortcut(QKeySequence()); // Import MED
3984 action( 33)->setEnabled(false); // Delete: Key_Delete
3985 action(1101)->setEnabled(false); // Rename: Key_F2
3987 return SalomeApp_Module::deactivateModule( study );
3990 void SMESHGUI::studyClosed( SUIT_Study* s )
3992 SMESH::RemoveVisuData( s->id() );
3993 SalomeApp_Module::studyClosed( s );
3996 void SMESHGUI::OnGUIEvent()
3998 const QObject* obj = sender();
3999 if ( !obj || !obj->inherits( "QAction" ) )
4001 int id = actionId((QAction*)obj);
4006 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4008 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4009 if ( CORBA::is_nil( myComponentSMESH ) )
4011 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4013 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4014 return aGUI.myComponentSMESH;
4017 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4018 return myComponentSMESH;
4021 QString SMESHGUI::engineIOR() const
4023 CORBA::ORB_var anORB = getApp()->orb();
4024 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4025 return QString( anIOR.in() );
4028 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4030 SalomeApp_Module::contextMenuPopup( client, menu, title );
4032 selectionMgr()->selectedObjects( lst );
4033 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4034 Handle(SALOME_InteractiveObject) io = lst.First();
4035 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4036 _PTR(Study) study = appStudy->studyDS();
4037 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4039 QString aName = QString( obj->GetName().c_str() );
4040 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4041 aName.remove( (aName.length() - 1), 1 );
4047 LightApp_Selection* SMESHGUI::createSelection() const
4049 return new SMESHGUI_Selection();
4052 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4054 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4055 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4058 void SMESHGUI::viewManagers( QStringList& list ) const
4060 list.append( SVTK_Viewer::Type() );
4063 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4065 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4066 SMESH::UpdateSelectionProp( this );
4069 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4071 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4072 myClippingPlaneInfoMap.erase( theViewManager );
4075 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4077 theActor->AddObserver( SMESH::DeleteActorEvent,
4078 myEventCallbackCommand.GetPointer(),
4082 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4083 unsigned long theEvent,
4084 void* theClientData,
4087 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4088 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4089 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4090 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4091 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4092 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4093 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4094 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4095 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4096 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4097 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4098 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4099 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4100 if( anActor == *anIter3 ) {
4101 anActorList.erase( anIter3 );
4112 void SMESHGUI::createPreferences()
4114 // General tab ------------------------------------------------------------------------
4115 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4117 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4118 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4119 setPreferenceProperty( lim, "min", 0 );
4120 setPreferenceProperty( lim, "max", 100000000 );
4121 setPreferenceProperty( lim, "step", 1000 );
4122 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4124 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4125 setPreferenceProperty( qaGroup, "columns", 2 );
4126 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4127 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4128 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4129 setPreferenceProperty( prec, "min", 0 );
4130 setPreferenceProperty( prec, "max", 16 );
4132 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4133 setPreferenceProperty( dispgroup, "columns", 2 );
4134 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4136 modes.append( "Wireframe" );
4137 modes.append( "Shading" );
4138 modes.append( "Nodes" );
4139 modes.append( "Shrink" );
4140 QList<QVariant> indices;
4141 indices.append( 0 );
4142 indices.append( 1 );
4143 indices.append( 2 );
4144 indices.append( 3 );
4145 setPreferenceProperty( dispmode, "strings", modes );
4146 setPreferenceProperty( dispmode, "indexes", indices );
4148 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4149 setPreferenceProperty( arcgroup, "columns", 2 );
4150 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4151 QStringList quadraticModes;
4152 quadraticModes.append("Lines");
4153 quadraticModes.append("Arcs");
4155 indices.append( 0 );
4156 indices.append( 1 );
4157 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4158 setPreferenceProperty( quadraticmode, "indexes", indices );
4160 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4161 "SMESH", "max_angle" );
4162 setPreferenceProperty( maxAngle, "min", 1 );
4163 setPreferenceProperty( maxAngle, "max", 90 );
4167 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4168 setPreferenceProperty( exportgroup, "columns", 2 );
4169 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4170 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4172 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4173 setPreferenceProperty( computeGroup, "columns", 2 );
4174 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4176 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4177 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4178 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4180 indices.append( 0 );
4181 indices.append( 1 );
4182 indices.append( 2 );
4183 setPreferenceProperty( notifyMode, "strings", modes );
4184 setPreferenceProperty( notifyMode, "indexes", indices );
4186 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4187 setPreferenceProperty( computeGroup, "columns", 2 );
4188 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4190 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4191 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4193 indices.append( 0 );
4194 indices.append( 1 );
4195 setPreferenceProperty( elemInfo, "strings", modes );
4196 setPreferenceProperty( elemInfo, "indexes", indices );
4198 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4199 setPreferenceProperty( segGroup, "columns", 2 );
4200 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4201 "SMESH", "segmentation" );
4202 setPreferenceProperty( segLen, "min", 1 );
4203 setPreferenceProperty( segLen, "max", 10000000 );
4204 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4205 "SMESH", "nb_segments_per_edge" );
4206 setPreferenceProperty( nbSeg, "min", 1 );
4207 setPreferenceProperty( nbSeg, "max", 10000000 );
4209 // Quantities with individual precision settings
4210 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4211 setPreferenceProperty( precGroup, "columns", 2 );
4213 const int nbQuantities = 6;
4214 int precs[nbQuantities], ii = 0;
4215 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4216 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4217 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4218 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4219 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4220 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4221 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4222 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4223 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4224 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4225 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4226 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4228 // Set property for precision value for spinboxes
4229 for ( ii = 0; ii < nbQuantities; ii++ ){
4230 setPreferenceProperty( precs[ii], "min", -14 );
4231 setPreferenceProperty( precs[ii], "max", 14 );
4232 setPreferenceProperty( precs[ii], "precision", 2 );
4235 // Mesh tab ------------------------------------------------------------------------
4236 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4237 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4238 setPreferenceProperty( nodeGroup, "columns", 3 );
4240 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4242 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4244 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4245 QList<QVariant> aMarkerTypeIndicesList;
4246 QList<QVariant> aMarkerTypeIconsList;
4247 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4248 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4249 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4250 aMarkerTypeIndicesList << i;
4251 aMarkerTypeIconsList << pixmap;
4253 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4254 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4256 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4258 QList<QVariant> aMarkerScaleIndicesList;
4259 QStringList aMarkerScaleValuesList;
4260 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4261 aMarkerScaleIndicesList << i;
4262 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4264 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4265 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4267 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4268 setPreferenceProperty( elemGroup, "columns", 2 );
4270 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4271 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4272 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4273 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4275 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4276 setPreferenceProperty( grpGroup, "columns", 2 );
4278 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4280 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4281 //setPreferenceProperty( sp, "hstretch", 0 );
4282 //setPreferenceProperty( sp, "vstretch", 0 );
4284 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4285 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4286 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4287 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4288 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4289 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4290 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4292 setPreferenceProperty( size0d, "min", 1 );
4293 setPreferenceProperty( size0d, "max", 10 );
4295 setPreferenceProperty( sp, "hstretch", 0 );
4296 setPreferenceProperty( sp, "vstretch", 0 );
4298 setPreferenceProperty( elemW, "min", 1 );
4299 setPreferenceProperty( elemW, "max", 5 );
4301 setPreferenceProperty( shrink, "min", 0 );
4302 setPreferenceProperty( shrink, "max", 100 );
4304 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4305 setPreferenceProperty( orientGroup, "columns", 1 );
4307 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4308 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4310 setPreferenceProperty( orientScale, "min", 0.05 );
4311 setPreferenceProperty( orientScale, "max", 0.5 );
4312 setPreferenceProperty( orientScale, "step", 0.05 );
4314 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4316 // Selection tab ------------------------------------------------------------------------
4317 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4319 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4320 setPreferenceProperty( selGroup, "columns", 2 );
4322 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4323 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4324 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4326 setPreferenceProperty( selW, "min", 1 );
4327 setPreferenceProperty( selW, "max", 5 );
4329 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4330 setPreferenceProperty( preGroup, "columns", 2 );
4332 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4333 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4335 setPreferenceProperty( preW, "min", 1 );
4336 setPreferenceProperty( preW, "max", 5 );
4338 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4339 setPreferenceProperty( precSelGroup, "columns", 2 );
4341 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4342 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4343 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4345 // Scalar Bar tab ------------------------------------------------------------------------
4346 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4347 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4348 setPreferenceProperty( fontGr, "columns", 2 );
4350 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4351 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4353 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4354 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4356 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4357 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4359 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4360 setPreferenceProperty( numcol, "min", 2 );
4361 setPreferenceProperty( numcol, "max", 256 );
4363 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4364 setPreferenceProperty( numlab, "min", 2 );
4365 setPreferenceProperty( numlab, "max", 65 );
4367 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4368 setPreferenceProperty( orientGr, "columns", 2 );
4369 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4370 QStringList orients;
4371 orients.append( tr( "SMESH_VERTICAL" ) );
4372 orients.append( tr( "SMESH_HORIZONTAL" ) );
4373 indices.clear(); indices.append( 0 ); indices.append( 1 );
4374 setPreferenceProperty( orient, "strings", orients );
4375 setPreferenceProperty( orient, "indexes", indices );
4377 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4378 setPreferenceProperty( posVSizeGr, "columns", 2 );
4379 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4380 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4381 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4382 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4383 setPreferenceProperty( xv, "step", 0.1 );
4384 setPreferenceProperty( xv, "min", 0.0 );
4385 setPreferenceProperty( xv, "max", 1.0 );
4386 setPreferenceProperty( yv, "step", 0.1 );
4387 setPreferenceProperty( yv, "min", 0.0 );
4388 setPreferenceProperty( yv, "max", 1.0 );
4389 setPreferenceProperty( wv, "step", 0.1 );
4390 setPreferenceProperty( wv, "min", 0.0 );
4391 setPreferenceProperty( wv, "max", 1.0 );
4392 setPreferenceProperty( hv, "min", 0.0 );
4393 setPreferenceProperty( hv, "max", 1.0 );
4394 setPreferenceProperty( hv, "step", 0.1 );
4396 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4397 setPreferenceProperty( posHSizeGr, "columns", 2 );
4398 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4399 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4400 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4401 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4402 setPreferenceProperty( xv, "min", 0.0 );
4403 setPreferenceProperty( xv, "max", 1.0 );
4404 setPreferenceProperty( xv, "step", 0.1 );
4405 setPreferenceProperty( xh, "min", 0.0 );
4406 setPreferenceProperty( xh, "max", 1.0 );
4407 setPreferenceProperty( xh, "step", 0.1 );
4408 setPreferenceProperty( yh, "min", 0.0 );
4409 setPreferenceProperty( yh, "max", 1.0 );
4410 setPreferenceProperty( yh, "step", 0.1 );
4411 setPreferenceProperty( wh, "min", 0.0 );
4412 setPreferenceProperty( wh, "max", 1.0 );
4413 setPreferenceProperty( wh, "step", 0.1 );
4414 setPreferenceProperty( hh, "min", 0.0 );
4415 setPreferenceProperty( hh, "max", 1.0 );
4416 setPreferenceProperty( hh, "step", 0.1 );
4418 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4419 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4420 setPreferenceProperty( distributionGr, "columns", 3 );
4422 types.append( tr( "SMESH_MONOCOLOR" ) );
4423 types.append( tr( "SMESH_MULTICOLOR" ) );
4424 indices.clear(); indices.append( 0 ); indices.append( 1 );
4425 setPreferenceProperty( coloringType, "strings", types );
4426 setPreferenceProperty( coloringType, "indexes", indices );
4427 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4431 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4433 if( sect=="SMESH" ) {
4434 float sbX1,sbY1,sbW,sbH;
4435 float aTol = 1.00000009999999;
4436 std::string aWarning;
4437 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4438 if( name=="selection_object_color" || name=="selection_element_color" ||
4439 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4440 name=="selection_precision_node" || name=="selection_precision_element" ||
4441 name=="selection_precision_object")
4442 SMESH::UpdateSelectionProp( this );
4443 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4444 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4445 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4446 if(sbX1+sbW > aTol){
4447 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4450 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4451 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4454 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4455 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4456 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4457 if(sbY1+sbH > aTol){
4458 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4459 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4460 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4463 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4464 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4465 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4466 if(sbX1+sbW > aTol){
4467 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4470 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4471 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4474 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4475 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4476 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4477 if(sbY1+sbH > aTol){
4478 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4481 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4482 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4485 else if ( name == "segmentation" ) {
4486 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4487 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4489 else if ( name == "nb_segments_per_edge" ) {
4490 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4491 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4494 if(aWarning.size() != 0){
4495 aWarning += "The default values are applied instead.";
4496 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4497 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4498 QObject::tr(aWarning.c_str()));
4503 //================================================================================
4505 * \brief Update something in accordance with update flags
4506 * \param theFlags - update flags
4508 * Update viewer or/and object browser etc. in accordance with update flags ( see
4509 * LightApp_UpdateFlags enumeration ).
4511 //================================================================================
4512 void SMESHGUI::update( const int flags )
4514 if ( flags & UF_Viewer | flags & UF_Forced )
4515 SMESH::UpdateView();
4517 SalomeApp_Module::update( flags );
4520 //================================================================================
4522 * \brief Set default selection mode
4524 * SLOT called when operation commited. Sets default selection mode
4526 //================================================================================
4527 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4529 SVTK_ViewWindow* vtkWnd =
4530 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4532 vtkWnd->SetSelectionMode( ActorSelection );
4535 //================================================================================
4537 * \brief Set default selection mode
4539 * SLOT called when operation aborted. Sets default selection mode
4541 //================================================================================
4542 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4544 SVTK_ViewWindow* vtkWnd =
4545 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4547 vtkWnd->SetSelectionMode( ActorSelection );
4550 //================================================================================
4552 * \brief Creates operation with given identifier
4553 * \param id - identifier of operation to be started
4554 * \return Pointer on created operation or NULL if operation is not created
4556 * Virtual method redefined from the base class creates operation with given id.
4557 * It is called called automatically from startOperation method of base class.
4559 //================================================================================
4560 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4562 LightApp_Operation* op = 0;
4563 // to do : create operation here
4566 case 417: //convert to quadratic
4567 op = new SMESHGUI_ConvToQuadOp();
4569 case 418: // create 2D mesh as boundary on 3D
4570 op = new SMESHGUI_Make2DFrom3DOp();
4572 case 701: // Compute mesh
4573 op = new SMESHGUI_ComputeOp();
4575 case 702: // Create mesh
4576 op = new SMESHGUI_MeshOp( true, true );
4578 case 703: // Create sub-mesh
4579 op = new SMESHGUI_MeshOp( true, false );
4581 case 704: // Edit mesh/sub-mesh
4582 op = new SMESHGUI_MeshOp( false );
4584 case 711: // Precompute mesh
4585 op = new SMESHGUI_PrecomputeOp();
4587 case 712: // Evaluate mesh
4588 op = new SMESHGUI_EvaluateOp();
4590 case 713: // Evaluate mesh
4591 op = new SMESHGUI_MeshOrderOp();
4593 case 806: // Create group on geom
4594 op = new SMESHGUI_GroupOnShapeOp();
4596 case 904: // Find element
4597 op = new SMESHGUI_FindElemByPointOp();
4599 case 4067: // make mesh pass through point
4600 op = new SMESHGUI_MakeNodeAtPointOp();
4607 op = SalomeApp_Module::createOperation( id );
4611 //================================================================================
4613 * \brief Stops current operations and starts a given one
4614 * \param id - The id of the operation to start
4616 //================================================================================
4618 void SMESHGUI::switchToOperation(int id)
4620 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4621 activeStudy()->abortAllOperations();
4622 startOperation( id );
4625 LightApp_Displayer* SMESHGUI::displayer()
4628 myDisplayer = new SMESHGUI_Displayer( getApp() );
4632 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4635 int aTolerance = 64;
4636 int anIterations = 0;
4642 if( anIterations % aPeriod == 0 )
4645 if( aTolerance < 1 )
4649 aHue = (int)( 360.0 * rand() / RAND_MAX );
4652 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4653 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4654 for( ; it != itEnd; ++it )
4656 SALOMEDS::Color anAutoColor = *it;
4657 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4660 aQColor.getHsv( &h, &s, &v );
4661 if( abs( h - aHue ) < aTolerance )
4673 aColor.setHsv( aHue, 255, 255 );
4675 SALOMEDS::Color aSColor;
4676 aSColor.R = (double)aColor.red() / 255.0;
4677 aSColor.G = (double)aColor.green() / 255.0;
4678 aSColor.B = (double)aColor.blue() / 255.0;
4683 const char gSeparator = '_'; // character used to separate parameter names
4684 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4685 const char gPathSep = '|'; // character used to separate paths
4688 * \brief Store visual parameters
4690 * This method is called just before the study document is saved.
4691 * Store visual parameters in AttributeParameter attribue(s)
4693 void SMESHGUI::storeVisualParameters (int savePoint)
4695 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4696 if (!appStudy || !appStudy->studyDS())
4698 _PTR(Study) studyDS = appStudy->studyDS();
4700 // componentName is used for encoding of entries when storing them in IParameters
4701 std::string componentName = myComponentSMESH->ComponentDataType();
4702 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4703 //if (!aSComponent) return;
4706 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4707 componentName.c_str(),
4709 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4711 // store map of custom markers
4712 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4713 if( !aMarkerMap.empty() )
4715 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4716 for( ; anIter != aMarkerMap.end(); anIter++ )
4718 int anId = anIter->first;
4719 VTK::MarkerData aMarkerData = anIter->second;
4720 std::string aMarkerFileName = aMarkerData.first;
4721 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4722 if( aMarkerTexture.size() < 3 )
4723 continue; // should contain at least width, height and the first value
4725 QString aPropertyName( "texture" );
4726 aPropertyName += gSeparator;
4727 aPropertyName += QString::number( anId );
4729 QString aPropertyValue = aMarkerFileName.c_str();
4730 aPropertyValue += gPathSep;
4732 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4733 ushort aWidth = *aTextureIter++;
4734 ushort aHeight = *aTextureIter++;
4735 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4736 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4737 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4738 aPropertyValue += QString::number( *aTextureIter );
4740 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4744 // viewers counters are used for storing view_numbers in IParameters
4747 // main cycle to store parameters of displayed objects
4748 QList<SUIT_ViewManager*> lst;
4749 QList<SUIT_ViewManager*>::Iterator it;
4750 getApp()->viewManagers(lst);
4751 for (it = lst.begin(); it != lst.end(); it++)
4753 SUIT_ViewManager* vman = *it;
4754 QString vType = vman->getType();
4756 // saving VTK actors properties
4757 if (vType == SVTK_Viewer::Type())
4759 // store the clipping planes attached to the view manager
4760 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4761 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4762 if( anIter != myClippingPlaneInfoMap.end() )
4763 aClippingPlaneInfoList = anIter->second;
4765 if( !aClippingPlaneInfoList.empty() ) {
4766 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4767 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4769 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4770 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4772 QString aPropertyName( "ClippingPlane" );
4773 aPropertyName += gSeparator;
4774 aPropertyName += QString::number( vtkViewers );
4775 aPropertyName += gSeparator;
4776 aPropertyName += QString::number( anId );
4778 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4779 aPropertyValue += gDigitsSep;
4780 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4781 aPropertyValue += gDigitsSep;
4782 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4783 aPropertyValue += gDigitsSep;
4784 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4786 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4790 QVector<SUIT_ViewWindow*> views = vman->getViews();
4791 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4793 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4795 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4796 vtkActorCollection* allActors = aCopy.GetActors();
4797 allActors->InitTraversal();
4798 while (vtkActor* actor = allActors->GetNextActor())
4800 if (actor->GetVisibility()) // store only visible actors
4802 SMESH_Actor* aSmeshActor = 0;
4803 if (actor->IsA("SMESH_Actor"))
4804 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4805 if (aSmeshActor && aSmeshActor->hasIO())
4807 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4810 // entry is "encoded" = it does NOT contain component adress,
4811 // since it is a subject to change on next component loading
4812 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4814 std::string param, vtkParam = vType.toLatin1().data();
4815 vtkParam += gSeparator;
4816 vtkParam += QString::number(vtkViewers).toLatin1().data();
4817 vtkParam += gSeparator;
4820 param = vtkParam + "Visibility";
4821 ip->setParameter(entry, param, "On");
4824 param = vtkParam + "Representation";
4825 ip->setParameter(entry, param, QString::number
4826 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4829 param = vtkParam + "IsShrunk";
4830 ip->setParameter(entry, param, QString::number
4831 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4833 // Displayed entities
4834 unsigned int aMode = aSmeshActor->GetEntityMode();
4835 bool isE = aMode & SMESH_Actor::eEdges;
4836 bool isF = aMode & SMESH_Actor::eFaces;
4837 bool isV = aMode & SMESH_Actor::eVolumes;
4839 QString modeStr ("e");
4840 modeStr += gDigitsSep; modeStr += QString::number(isE);
4841 modeStr += gDigitsSep; modeStr += "f";
4842 modeStr += gDigitsSep; modeStr += QString::number(isF);
4843 modeStr += gDigitsSep; modeStr += "v";
4844 modeStr += gDigitsSep; modeStr += QString::number(isV);
4846 param = vtkParam + "Entities";
4847 ip->setParameter(entry, param, modeStr.toLatin1().data());
4849 // Colors (surface:edge:)
4850 vtkFloatingPointType r, g, b;
4852 aSmeshActor->GetSufaceColor(r, g, b);
4853 QString colorStr ("surface");
4854 colorStr += gDigitsSep; colorStr += QString::number(r);
4855 colorStr += gDigitsSep; colorStr += QString::number(g);
4856 colorStr += gDigitsSep; colorStr += QString::number(b);
4858 aSmeshActor->GetBackSufaceColor(r, g, b);
4859 colorStr += gDigitsSep; colorStr += "backsurface";
4860 colorStr += gDigitsSep; colorStr += QString::number(r);
4861 colorStr += gDigitsSep; colorStr += QString::number(g);
4862 colorStr += gDigitsSep; colorStr += QString::number(b);
4864 aSmeshActor->GetEdgeColor(r, g, b);
4865 colorStr += gDigitsSep; colorStr += "edge";
4866 colorStr += gDigitsSep; colorStr += QString::number(r);
4867 colorStr += gDigitsSep; colorStr += QString::number(g);
4868 colorStr += gDigitsSep; colorStr += QString::number(b);
4870 aSmeshActor->GetNodeColor(r, g, b);
4871 colorStr += gDigitsSep; colorStr += "node";
4872 colorStr += gDigitsSep; colorStr += QString::number(r);
4873 colorStr += gDigitsSep; colorStr += QString::number(g);
4874 colorStr += gDigitsSep; colorStr += QString::number(b);
4876 param = vtkParam + "Colors";
4877 ip->setParameter(entry, param, colorStr.toLatin1().data());
4879 // Sizes of lines and points
4880 QString sizeStr ("line");
4881 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4882 sizeStr += gDigitsSep; sizeStr += "shrink";
4883 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4885 param = vtkParam + "Sizes";
4886 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4891 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4892 if( aMarkerType == VTK::MT_USER ) {
4893 markerStr += "custom";
4894 markerStr += gDigitsSep;
4895 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4899 markerStr += gDigitsSep;
4900 markerStr += QString::number( (int)aMarkerType );
4901 markerStr += gDigitsSep;
4902 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4905 param = vtkParam + "PointMarker";
4906 ip->setParameter(entry, param, markerStr.toLatin1().data());
4909 param = vtkParam + "Opacity";
4910 ip->setParameter(entry, param,
4911 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4914 param = vtkParam + "ClippingPlane";
4916 if( !aClippingPlaneInfoList.empty() ) {
4917 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4918 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
4920 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
4921 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
4922 SMESH::TActorList::iterator anIter2 = anActorList.begin();
4923 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
4924 if( aSmeshActor == *anIter2 ) {
4925 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
4926 QString::number( anId ).toLatin1().constData() );
4933 ip->setParameter( entry, param, "Off" );
4934 } // if (io->hasEntry())
4935 } // SMESH_Actor && hasIO
4937 } // while.. actors traversal
4941 } // if (SVTK view model)
4942 } // for (viewManagers)
4945 // data structures for clipping planes processing
4948 vtkIdType Orientation;
4949 vtkFloatingPointType Distance;
4950 vtkFloatingPointType Angle[2];
4952 typedef std::list<TPlaneData> TPlaneDataList;
4953 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
4955 typedef std::list<vtkActor*> TActorList;
4958 TActorList ActorList;
4959 SUIT_ViewManager* ViewManager;
4961 typedef std::list<TPlaneInfo> TPlaneInfoList;
4962 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
4965 * \brief Restore visual parameters
4967 * This method is called after the study document is opened.
4968 * Restore visual parameters from AttributeParameter attribue(s)
4970 void SMESHGUI::restoreVisualParameters (int savePoint)
4972 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4973 if (!appStudy || !appStudy->studyDS())
4975 _PTR(Study) studyDS = appStudy->studyDS();
4977 // componentName is used for encoding of entries when storing them in IParameters
4978 std::string componentName = myComponentSMESH->ComponentDataType();
4979 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4980 //if (!aSComponent) return;
4983 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4984 componentName.c_str(),
4986 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4988 // restore map of custom markers and map of clipping planes
4989 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4990 TPlaneDataMap aPlaneDataMap;
4992 std::vector<std::string> properties = ip->getProperties();
4993 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4995 std::string property = *propIt;
4996 QString aPropertyName( property.c_str() );
4997 QString aPropertyValue( ip->getProperty( property ).c_str() );
4999 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5000 if( aPropertyNameList.isEmpty() )
5003 QString aPropertyType = aPropertyNameList[0];
5004 if( aPropertyType == "texture" )
5006 if( aPropertyNameList.size() != 2 )
5010 int anId = aPropertyNameList[1].toInt( &ok );
5011 if( !ok || anId < 1 )
5014 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5015 if( aPropertyValueList.size() != 2 )
5018 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5019 QString aMarkerTextureString = aPropertyValueList[1];
5020 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5021 if( aMarkerTextureStringList.size() != 3 )
5025 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5030 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5034 VTK::MarkerTexture aMarkerTexture;
5035 aMarkerTexture.push_back( aWidth );
5036 aMarkerTexture.push_back( aHeight );
5038 QString aMarkerTextureData = aMarkerTextureStringList[2];
5039 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5041 QChar aChar = aMarkerTextureData.at( i );
5042 if( aChar.isDigit() )
5043 aMarkerTexture.push_back( aChar.digitValue() );
5046 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5048 else if( aPropertyType == "ClippingPlane" )
5050 if( aPropertyNameList.size() != 3 )
5054 int aViewId = aPropertyNameList[1].toInt( &ok );
5055 if( !ok || aViewId < 0 )
5059 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5060 if( !ok || aClippingPlaneId < 0 )
5063 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5064 if( aPropertyValueList.size() != 4 )
5067 TPlaneData aPlaneData;
5068 aPlaneData.Id = aClippingPlaneId;
5071 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5076 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5081 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5086 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5090 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5091 aPlaneDataList.push_back( aPlaneData );
5095 TPlaneInfoMap aPlaneInfoMap;
5097 std::vector<std::string> entries = ip->getEntries();
5099 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5101 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5102 QString entry (ip->decodeEntry(*entIt).c_str());
5104 // Check that the entry corresponds to a real object in the Study
5105 // as the object may be deleted or modified after the visual state is saved.
5106 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5107 if (!so) continue; //Skip the not existent entry
5109 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5110 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5112 std::vector<std::string>::iterator namesIt = paramNames.begin();
5113 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5115 // actors are stored in a map after displaying of them for
5116 // quicker access in the future: map < viewID to actor >
5117 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5119 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5121 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5122 // '_' is used as separator and should not be used in viewer type or parameter names.
5123 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5124 if (lst.size() != 3)
5127 QString viewerTypStr = lst[0];
5128 QString viewIndexStr = lst[1];
5129 QString paramNameStr = lst[2];
5132 int viewIndex = viewIndexStr.toUInt(&ok);
5133 if (!ok) // bad conversion of view index to integer
5137 if (viewerTypStr == SVTK_Viewer::Type())
5139 SMESH_Actor* aSmeshActor = 0;
5140 if (vtkActors.IsBound(viewIndex))
5141 aSmeshActor = vtkActors.Find(viewIndex);
5143 QList<SUIT_ViewManager*> lst;
5144 getApp()->viewManagers(viewerTypStr, lst);
5146 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5147 SUIT_ViewManager* vman = NULL;
5148 if (viewIndex >= 0 && viewIndex < lst.count())
5149 vman = lst.at(viewIndex);
5151 if (paramNameStr == "Visibility")
5153 if (!aSmeshActor && displayer() && vman)
5155 SUIT_ViewModel* vmodel = vman->getViewModel();
5156 // SVTK view model can be casted to SALOME_View
5157 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5159 // store displayed actor in a temporary map for quicker
5160 // access later when restoring other parameters
5161 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5162 vtkRenderer* Renderer = vtkView->getRenderer();
5163 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5164 vtkActorCollection* theActors = aCopy.GetActors();
5165 theActors->InitTraversal();
5166 bool isFound = false;
5167 vtkActor *ac = theActors->GetNextActor();
5168 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5169 if (ac->IsA("SMESH_Actor")) {
5170 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5171 if (aGeomAc->hasIO()) {
5172 Handle(SALOME_InteractiveObject) io =
5173 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5174 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5176 vtkActors.Bind(viewIndex, aGeomAc);
5182 } // if (paramNameStr == "Visibility")
5185 // the rest properties "work" with SMESH_Actor
5188 QString val ((*valuesIt).c_str());
5191 if (paramNameStr == "Representation") {
5192 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5195 else if (paramNameStr == "IsShrunk") {
5197 if (!aSmeshActor->IsShrunk())
5198 aSmeshActor->SetShrink();
5201 if (aSmeshActor->IsShrunk())
5202 aSmeshActor->UnShrink();
5205 // Displayed entities
5206 else if (paramNameStr == "Entities") {
5207 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5208 if (mode.count() == 6) {
5209 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5210 MESSAGE("Invalid order of data in Entities, must be: "
5211 "e:0/1:f:0/1:v:0/1");
5214 unsigned int aMode = aSmeshActor->GetEntityMode();
5215 unsigned int aNewMode =
5216 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5217 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5218 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5219 if (aNewMode != aMode)
5220 aSmeshActor->SetEntityMode(aNewMode);
5225 else if (paramNameStr == "Colors") {
5226 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5227 if (colors.count() == 16) {
5228 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5229 colors[8] != "edge" || colors[12] != "node") {
5230 MESSAGE("Invalid order of data in Colors, must be: "
5231 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5234 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5235 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5236 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5237 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5241 // Sizes of lines and points
5242 else if (paramNameStr == "Sizes") {
5243 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5244 if (sizes.count() == 4) {
5245 if (sizes[0] != "line" || sizes[2] != "shrink") {
5246 MESSAGE("Invalid order of data in Sizes, must be: "
5247 "line:int:shrink:float");
5250 aSmeshActor->SetLineWidth(sizes[1].toInt());
5251 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5254 else if (sizes.count() == 6) { // just to support old format
5255 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5256 MESSAGE("Invalid order of data in Sizes, must be: "
5257 "line:int:node:int:shrink:float");
5260 aSmeshActor->SetLineWidth(sizes[1].toInt());
5261 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5262 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5267 else if (paramNameStr == "PointMarker") {
5268 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5269 if( data.count() >= 2 ) {
5271 int aParam1 = data[1].toInt( &ok );
5273 if( data[0] == "std" && data.count() == 3 ) {
5274 int aParam2 = data[2].toInt( &ok );
5275 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5277 else if( data[0] == "custom" ) {
5278 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5279 if( markerIt != aMarkerMap.end() ) {
5280 VTK::MarkerData aMarkerData = markerIt->second;
5281 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5288 else if (paramNameStr == "Opacity") {
5289 aSmeshActor->SetOpacity(val.toFloat());
5292 else if (paramNameStr.startsWith("ClippingPlane")) {
5293 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5294 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5295 // new format - val looks like "Off" or "0" (plane id)
5296 // (note: in new format "Off" value is used only for consistency,
5297 // so it is processed together with values in old format)
5298 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5299 if( anIsOldFormat ) {
5300 if (paramNameStr == "ClippingPlane1" || val == "Off")
5301 aSmeshActor->RemoveAllClippingPlanes();
5303 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5304 double aDistance = vals[1].toFloat();
5305 vtkFloatingPointType anAngle[2];
5306 anAngle[0] = vals[2].toFloat();
5307 anAngle[1] = vals[3].toFloat();
5309 QList<SUIT_ViewManager*> lst;
5310 getApp()->viewManagers(viewerTypStr, lst);
5311 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5312 if (viewIndex >= 0 && viewIndex < lst.count()) {
5313 SUIT_ViewManager* vman = lst.at(viewIndex);
5314 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5316 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5318 SMESH::TActorList anActorList;
5319 anActorList.push_back( aSmeshActor );
5320 SMESH::OrientedPlane* aPlane =
5321 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5323 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5324 aClippingPlaneInfo.Plane = aPlane;
5325 aClippingPlaneInfo.ActorList = anActorList;
5326 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5333 int aPlaneId = val.toInt( &ok );
5334 if( ok && aPlaneId >= 0 ) {
5335 bool anIsDefinedPlane = false;
5336 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5337 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5338 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5339 TPlaneInfo& aPlaneInfo = *anIter;
5340 if( aPlaneInfo.PlaneId == aPlaneId ) {
5341 aPlaneInfo.ActorList.push_back( aSmeshActor );
5342 anIsDefinedPlane = true;
5346 if( !anIsDefinedPlane ) {
5347 TPlaneInfo aPlaneInfo;
5348 aPlaneInfo.PlaneId = aPlaneId;
5349 aPlaneInfo.ActorList.push_back( aSmeshActor );
5350 aPlaneInfo.ViewManager = vman;
5351 aPlaneInfoList.push_back( aPlaneInfo );
5356 } // if (aSmeshActor)
5357 } // other parameters than Visibility
5359 } // for names/parameters iterator
5360 } // for entries iterator
5362 // add clipping planes to actors according to the restored parameters
5363 // and update the clipping plane map
5364 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5365 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5366 int aViewId = anIter1->first;
5367 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5369 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5370 if( anIter2 == aPlaneDataMap.end() )
5372 const TPlaneDataList& aPlaneDataList = anIter2->second;
5374 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5375 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5376 const TPlaneInfo& aPlaneInfo = *anIter3;
5377 int aPlaneId = aPlaneInfo.PlaneId;
5378 const TActorList& anActorList = aPlaneInfo.ActorList;
5379 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5383 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5387 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5389 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5390 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5391 const TPlaneData& aPlaneData = *anIter4;
5392 if( aPlaneData.Id == aPlaneId ) {
5393 SMESH::OrientedPlane* aPlane =
5394 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5396 (SMESH::Orientation)aPlaneData.Orientation,
5397 aPlaneData.Distance,
5400 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5401 aClippingPlaneInfo.Plane = aPlane;
5402 aClippingPlaneInfo.ActorList = anActorList;
5403 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5411 // update all VTK views
5412 QList<SUIT_ViewManager*> lst;
5413 getApp()->viewManagers(lst);
5414 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5415 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5416 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5417 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5418 vtkView->getRenderer()->ResetCameraClippingRange();
5425 \brief Adds preferences for dfont of VTK viewer
5427 \param pIf group identifier
5428 \param param parameter
5429 \return identifier of preferences
5431 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5433 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5435 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5438 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5439 fam.append( tr( "SMESH_FONT_COURIER" ) );
5440 fam.append( tr( "SMESH_FONT_TIMES" ) );
5442 setPreferenceProperty( tfont, "fonts", fam );
5444 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5445 setPreferenceProperty( tfont, "features", f );
5451 \brief Actions after hypothesis edition
5452 Updates object browser after hypothesis edition
5454 void SMESHGUI::onHypothesisEdit( int result )
5457 SMESHGUI::Modified();
5458 updateObjBrowser( true );