1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
30 #include "SMESHGUI_AddMeshElementDlg.h"
31 #include "SMESHGUI_AddQuadraticElementDlg.h"
32 #include "SMESHGUI_BuildCompoundDlg.h"
33 #include "SMESHGUI_ClippingDlg.h"
34 #include "SMESHGUI_ComputeDlg.h"
35 #include "SMESHGUI_ConvToQuadOp.h"
36 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
37 #include "SMESHGUI_DeleteGroupDlg.h"
38 #include "SMESHGUI_Displayer.h"
39 #include "SMESHGUI_MergeDlg.h"
40 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
41 #include "SMESHGUI_ExtrusionDlg.h"
42 #include "SMESHGUI_FileInfoDlg.h"
43 #include "SMESHGUI_FileValidator.h"
44 #include "SMESHGUI_FilterDlg.h"
45 #include "SMESHGUI_FilterLibraryDlg.h"
46 #include "SMESHGUI_FindElemByPointDlg.h"
47 #include "SMESHGUI_GroupDlg.h"
48 #include "SMESHGUI_GroupOnShapeDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_Hypotheses.h"
51 #include "SMESHGUI_Make2DFrom3DOp.h"
52 #include "SMESHGUI_MakeNodeAtPointDlg.h"
53 //#include "SMESHGUI_MeshInfosDlg.h"
54 #include "SMESHGUI_Measurements.h"
55 #include "SMESHGUI_MeshInfo.h"
56 #include "SMESHGUI_MeshOp.h"
57 #include "SMESHGUI_MeshOrderOp.h"
58 #include "SMESHGUI_MeshPatternDlg.h"
59 #include "SMESHGUI_MultiEditDlg.h"
60 #include "SMESHGUI_NodesDlg.h"
61 #include "SMESHGUI_Preferences_ColorDlg.h"
62 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
63 #include "SMESHGUI_RemoveElementsDlg.h"
64 #include "SMESHGUI_RemoveNodesDlg.h"
65 #include "SMESHGUI_RenumberingDlg.h"
66 #include "SMESHGUI_RevolutionDlg.h"
67 #include "SMESHGUI_RotationDlg.h"
68 #include "SMESHGUI_Selection.h"
69 #include "SMESHGUI_SewingDlg.h"
70 #include "SMESHGUI_SingleEditDlg.h"
71 #include "SMESHGUI_SmoothingDlg.h"
72 //#include "SMESHGUI_StandardMeshInfosDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.h"
77 //#include "SMESHGUI_WhatIsDlg.h"
78 #include "SMESHGUI_DuplicateNodesDlg.h"
79 #include "SMESHGUI_CopyMeshDlg.h"
81 #include "SMESHGUI_Utils.h"
82 #include "SMESHGUI_MeshUtils.h"
83 #include "SMESHGUI_GroupUtils.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_PatternUtils.h"
86 #include "SMESHGUI_VTKUtils.h"
87 #include "SMESHGUI_HypothesesUtils.h"
89 #include <SMESH_Client.hxx>
90 #include <SMESH_Actor.h>
91 #include <SMESH_ScalarBarActor.h>
92 #include <SMESH_TypeFilter.hxx>
93 #include "SMESH_ControlsDef.hxx"
95 // SALOME GUI includes
96 #include <SalomeApp_Tools.h>
97 #include <SalomeApp_Study.h>
98 #include <SalomeApp_Application.h>
99 #include <SalomeApp_CheckFileDlg.h>
101 #include <LightApp_DataOwner.h>
102 #include <LightApp_Preferences.h>
103 #include <LightApp_SelectionMgr.h>
104 #include <LightApp_UpdateFlags.h>
105 #include <LightApp_NameDlg.h>
107 #include <SVTK_ViewWindow.h>
108 #include <SVTK_ViewModel.h>
109 #include <SVTK_ViewManager.h>
111 #include <VTKViewer_Algorithm.h>
113 #include <SUIT_MessageBox.h>
114 #include <SUIT_ResourceMgr.h>
115 #include <SUIT_FileDlg.h>
116 #include <SUIT_Desktop.h>
117 #include <SUIT_OverrideCursor.h>
118 #include <SUIT_Session.h>
120 #include <QtxPopupMgr.h>
121 #include <QtxFontEdit.h>
123 #include <SALOME_ListIO.hxx>
124 #include <SALOME_ListIteratorOfListIO.hxx>
127 #include <SALOMEconfig.h>
128 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
129 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
130 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
133 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
135 #include <QTextStream>
138 #include <boost/shared_ptr.hpp>
141 #include <vtkCamera.h>
142 #include <vtkRenderer.h>
143 #include <vtkPlane.h>
144 #include <vtkCallbackCommand.h>
145 #include <vtkLookupTable.h>
147 // SALOME KERNEL includes
148 #include <SALOMEDS_Study.hxx>
149 #include <SALOMEDSClient_StudyBuilder.hxx>
150 #include <SALOMEDSClient_SComponent.hxx>
151 #include <SALOMEDSClient_ClientFactory.hxx>
152 #include <SALOMEDSClient_IParameters.hxx>
155 #include <Standard_ErrorHandler.hxx>
156 #include <NCollection_DataMap.hxx>
158 //To disable automatic genericobj management, the following line should be commented.
159 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
160 #define WITHGENERICOBJ
164 //=============================================================
165 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
168 void ExportMeshToFile(int theCommandID);
170 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
172 void SetDisplayEntity(int theCommandID);
174 void Control( int theCommandID );
178 //=============================================================
179 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
183 std::string myExtension;
185 if ( theCommandID == 113 ) {
186 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
187 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
189 else if ( theCommandID == 112 ) {
190 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
192 else if ( theCommandID == 111 ) {
193 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
196 QString anInitialPath = "";
197 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
198 anInitialPath = QDir::currentPath();
200 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
203 QObject::tr( "SMESH_IMPORT_MESH" ) );
204 if ( filenames.count() > 0 ) {
205 SUIT_OverrideCursor wc;
206 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
209 bool isEmpty = false;
210 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
211 QString filename = *it;
212 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
214 switch ( theCommandID ) {
217 // DAT format (currently unsupported)
218 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
219 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
225 aMeshes->length( 1 );
226 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
227 if ( aMeshes[0]->_is_nil() )
228 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
229 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
235 SMESH::DriverMED_ReadStatus res;
236 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
237 if ( res != SMESH::DRS_OK ) {
238 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
239 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
245 catch ( const SALOME::SALOME_Exception& S_ex ) {
246 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
247 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
250 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
251 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
253 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
254 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
255 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
256 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
257 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
259 #ifdef WITHGENERICOBJ
260 // obj has been published in study. Its refcount has been incremented.
261 // It is safe to decrement its refcount
262 // so that it will be destroyed when the entry in study will be removed
263 aMeshes[i]->Destroy();
272 // update Object browser
273 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
275 // show Error message box if there were errors
276 if ( errors.count() > 0 ) {
277 SUIT_MessageBox::critical( SMESHGUI::desktop(),
278 QObject::tr( "SMESH_ERROR" ),
279 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
282 // show warning message box, if some imported mesh is empty
284 SUIT_MessageBox::warning( SMESHGUI::desktop(),
285 QObject::tr( "SMESH_WRN_WARNING" ),
286 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
291 void ExportMeshToFile( int theCommandID )
293 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
294 SALOME_ListIO selected;
296 aSel->selectedObjects( selected );
298 // actually, the following condition can't be met (added for insurance)
299 if( selected.Extent() == 0 ||
300 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
303 bool hasDuplicatedMeshNames = false;
304 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
305 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
306 SALOME_ListIteratorOfListIO It( selected );
307 for( ; It.More(); It.Next() ) {
308 Handle(SALOME_InteractiveObject) anIObject = It.Value();
309 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
310 if ( aMeshItem->_is_nil() ) {
311 SUIT_MessageBox::warning( SMESHGUI::desktop(),
312 QObject::tr( "SMESH_WRN_WARNING" ),
313 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
317 QString aMeshName = anIObject->getName();
319 // check for duplications
320 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
321 if( aMeshName == (*aMeshIter).second ) {
322 hasDuplicatedMeshNames = true;
327 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
330 if( hasDuplicatedMeshNames ) {
331 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
332 QObject::tr("SMESH_WRN_WARNING"),
333 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
334 QObject::tr("SMESH_BUT_YES"),
335 QObject::tr("SMESH_BUT_NO"), 0, 1);
340 aMeshIter = aMeshList.begin();
341 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
342 QString aMeshName = (*aMeshIter).second;
344 QList<SALOMEDS::Color> aReservedColors;
346 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
347 QMap<QString, SMESH::MED_VERSION> aFilterMap;
348 QMap<QString, int> aFilterMapSTL;
349 switch ( theCommandID ) {
353 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
354 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
355 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
356 int aRet = SUIT_MessageBox::warning
357 (SMESHGUI::desktop(),
358 QObject::tr("SMESH_WRN_WARNING"),
359 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
360 QObject::tr("SMESH_BUT_YES"),
361 QObject::tr("SMESH_BUT_NO"), 0, 1);
367 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
368 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
369 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
370 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
375 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
380 if (aMesh->NbPyramids()) {
381 int aRet = SUIT_MessageBox::warning
382 (SMESHGUI::desktop(),
383 QObject::tr("SMESH_WRN_WARNING"),
384 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
385 QObject::tr("SMESH_BUT_YES"),
386 QObject::tr("SMESH_BUT_NO"), 0, 1);
390 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
398 there must be check on others mesh elements not equal triangles
400 if (aMesh->NbTriangles() < 1) {
401 SUIT_MessageBox::warning
402 (SMESHGUI::desktop(),
403 QObject::tr("SMESH_WRN_WARNING"),
404 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
407 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
408 int aRet = SUIT_MessageBox::warning
409 (SMESHGUI::desktop(),
410 QObject::tr("SMESH_WRN_WARNING"),
411 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
412 QObject::tr("SMESH_BUT_YES"),
413 QObject::tr("SMESH_BUT_NO"), 0, 1);
418 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
419 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
427 SMESH::MED_VERSION aFormat;
428 // Init the parameter with the default value
429 bool aIsASCII_STL = true;
430 bool toCreateGroups = false;
431 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
433 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
434 bool toOverwrite = true;
436 QString anInitialPath = "";
437 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
438 anInitialPath = QDir::currentPath();
440 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
441 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
442 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
443 aFilter, aTitle, false);
445 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
447 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
448 for ( ; it != aFilterMapSTL.end(); ++it )
449 filters.push_back( it.key() );
451 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
452 fd->setWindowTitle( aTitle );
453 fd->setNameFilters( filters );
454 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
455 if ( !anInitialPath.isEmpty() )
456 fd->setDirectory( anInitialPath );
457 fd->selectFile(aMeshName);
461 aFilename = fd->selectedFile();
462 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
467 else { // Export to MED
469 QString aDefaultFilter;
470 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
471 for ( ; it != aFilterMap.end(); ++it ) {
472 filters.push_back( it.key() );
473 if (it.value() == SMESH::MED_V2_2)
474 aDefaultFilter = it.key();
477 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
478 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
479 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
480 fd->setWindowTitle( aTitle );
481 fd->setNameFilters( filters );
482 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
483 fd->selectNameFilter(aDefaultFilter);
484 fd->SetChecked(toCreateGroups);
485 if ( !anInitialPath.isEmpty() )
486 fd->setDirectory( anInitialPath );
487 fd->selectFile(aMeshName);
489 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
490 fd->setValidator( fv );
495 aFilename = fd->selectedFile();
497 aFilename = QString::null;
500 aFormat = aFilterMap[fd->selectedNameFilter()];
501 toOverwrite = fv->isOverwrite();
503 if ( !aFilename.isEmpty() ) {
504 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
505 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
506 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
507 && aFormat==SMESH::MED_V2_1) {
508 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
509 QObject::tr("SMESH_WRN_WARNING"),
510 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
511 QObject::tr("SMESH_BUT_YES"),
512 QObject::tr("SMESH_BUT_NO"), 0, 1);
520 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
521 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
522 if( !isVersionOk || aVersion != aFormat ) {
523 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
524 QObject::tr("SMESH_WRN_WARNING"),
525 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
526 QObject::tr("SMESH_BUT_YES"),
527 QObject::tr("SMESH_BUT_NO"), 0, 1);
534 QStringList aMeshNamesCollisionList;
535 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
536 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
537 QString anExistingMeshName( aMeshNames[ i ] );
538 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
539 QString anExportMeshName = (*aMeshIter).second;
540 if( anExportMeshName == anExistingMeshName ) {
541 aMeshNamesCollisionList.append( anExportMeshName );
547 if( !aMeshNamesCollisionList.isEmpty() ) {
548 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
549 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
550 QObject::tr("SMESH_WRN_WARNING"),
551 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
552 QObject::tr("SMESH_BUT_YES"),
553 QObject::tr("SMESH_BUT_NO"),
554 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
563 toCreateGroups = fd->IsChecked();
566 if ( !aFilename.isEmpty() ) {
567 // Check whether the file already exists and delete it if yes
568 QFile aFile( aFilename );
569 if ( aFile.exists() && toOverwrite )
571 SUIT_OverrideCursor wc;
574 bool Renumber = false;
575 // PAL 14172 : Check of we have to renumber or not from the preferences before export
577 Renumber= resMgr->booleanValue("SMESH","renumbering");
579 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
580 aMeshEditor->RenumberNodes();
581 aMeshEditor->RenumberElements();
582 if ( SMESHGUI::automaticUpdate() )
585 switch ( theCommandID ) {
589 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
590 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
591 if( !aMeshItem->_is_nil() )
592 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
598 aMesh->ExportDAT( aFilename.toLatin1().data() );
602 aMesh->ExportUNV( aFilename.toLatin1().data() );
606 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
612 catch (const SALOME::SALOME_Exception& S_ex){
614 SUIT_MessageBox::warning(SMESHGUI::desktop(),
615 QObject::tr("SMESH_WRN_WARNING"),
616 QObject::tr("SMESH_EXPORT_FAILED"));
622 inline void InverseEntityMode(unsigned int& theOutputMode,
623 unsigned int theMode)
625 bool anIsNotPresent = ~theOutputMode & theMode;
627 theOutputMode |= theMode;
629 theOutputMode &= ~theMode;
632 void SetDisplayEntity(int theCommandID){
633 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
634 SALOME_ListIO selected;
636 aSel->selectedObjects( selected );
638 if(selected.Extent() >= 1){
639 SALOME_ListIteratorOfListIO It( selected );
640 for( ; It.More(); It.Next()){
641 Handle(SALOME_InteractiveObject) IObject = It.Value();
642 if(IObject->hasEntry()){
643 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
644 unsigned int aMode = anActor->GetEntityMode();
645 switch(theCommandID){
647 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
650 InverseEntityMode(aMode,SMESH_Actor::eEdges);
653 InverseEntityMode(aMode,SMESH_Actor::eFaces);
656 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
659 aMode = SMESH_Actor::eAllEntity;
663 anActor->SetEntityMode(aMode);
671 SALOME_ListIO selected;
672 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
676 LightApp_SelectionMgr* aSel = app->selectionMgr();
677 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
678 if( !aSel || !appStudy )
681 aSel->selectedObjects( selected );
682 if( selected.IsEmpty() )
685 Handle(SALOME_InteractiveObject) anIObject = selected.First();
687 _PTR(Study) aStudy = appStudy->studyDS();
688 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
689 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
690 if( aMainObject->_is_nil() )
693 aMainObject->SetAutoColor( true );
695 QList<SALOMEDS::Color> aReservedColors;
697 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
698 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
700 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
701 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
703 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
704 aGroupObject->SetColor( aColor );
705 aReservedColors.append( aColor );
707 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
709 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
710 if( aGroupObject->GetType() == SMESH::NODE )
711 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
712 else if( aGroupObject->GetType() == SMESH::EDGE )
713 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
714 else if( aGroupObject->GetType() == SMESH::ELEM0D )
715 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
717 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
722 SMESH::RepaintCurrentView();
725 QString functorToString( SMESH::Controls::FunctorPtr f )
727 QString type = QObject::tr( "UNKNOWN_CONTROL" );
728 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
729 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
730 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
731 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
732 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
733 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
734 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
735 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
736 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
737 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
738 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
739 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
740 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
741 type = QObject::tr( "WARP_ELEMENTS" );
742 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
743 type = QObject::tr( "TAPER_ELEMENTS" );
744 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
745 type = QObject::tr( "SKEW_ELEMENTS" );
746 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
747 type = QObject::tr( "AREA_ELEMENTS" );
748 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
749 type = QObject::tr( "LENGTH_EDGES" );
750 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
751 type = QObject::tr( "LENGTH2D_EDGES" );
752 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
753 type = QObject::tr( "MULTI_BORDERS" );
754 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
755 type = QObject::tr( "MULTI2D_BORDERS" );
756 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
757 type = QObject::tr( "FREE_NODES" );
758 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
759 type = QObject::tr( "FREE_EDGES" );
760 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
761 type = QObject::tr( "FREE_BORDERS" );
762 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
763 type = QObject::tr( "FREE_FACES" );
764 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
765 type = QObject::tr( "BARE_BORDER_VOLUME" );
766 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
767 type = QObject::tr( "BARE_BORDER_FACE" );
768 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
769 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
770 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
771 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
775 void SaveDistribution()
777 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
778 SALOME_ListIO selected;
780 aSel->selectedObjects( selected );
782 if ( selected.Extent() == 1 ) {
783 Handle(SALOME_InteractiveObject) anIO = selected.First();
784 if ( anIO->hasEntry() ) {
785 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
786 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
787 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
788 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
789 if ( aScalarBarActor && aFunctor ) {
790 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
792 std::vector<int> elements;
793 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
794 if ( mesh->_is_nil() ) {
795 SMESH::SMESH_IDSource_var idSource =
796 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
797 if ( !idSource->_is_nil() )
799 SMESH::long_array_var ids = idSource->GetIDs();
800 elements.resize( ids->length() );
801 for ( unsigned i = 0; i < elements.size(); ++i )
802 elements[i] = ids[i];
805 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
806 vtkLookupTable* lookupTable =
807 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
808 double * minmax = lookupTable->GetRange();
809 std::vector<int> nbEvents;
810 std::vector<double> funValues;
811 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
812 QString anInitialPath = "";
813 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
814 anInitialPath = QDir::currentPath();
815 QString aMeshName = anIO->getName();
817 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
818 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
819 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
820 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
821 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
824 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
826 if ( !aFilename.isEmpty() ) {
827 QFile f( aFilename );
828 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
829 QTextStream out( &f );
830 out << "# Mesh: " << aMeshName << endl;
831 out << "# Control: " << functorToString( aFunctor ) << endl;
833 out.setFieldWidth( 10 );
834 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
835 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
846 void ShowDistribution() {
847 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
848 SALOME_ListIO selected;
850 aSel->selectedObjects( selected );
852 if ( selected.Extent() == 1 ) {
853 Handle(SALOME_InteractiveObject) anIO = selected.First();
854 if ( anIO->hasEntry() ) {
855 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
856 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
857 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
858 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
864 void DisableAutoColor(){
865 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
866 SALOME_ListIO selected;
868 aSel->selectedObjects( selected );
870 if(selected.Extent()){
871 Handle(SALOME_InteractiveObject) anIObject = selected.First();
872 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
873 if ( !aMesh->_is_nil() ) {
874 aMesh->SetAutoColor( false );
879 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
880 SALOME_ListIO selected;
881 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
885 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
886 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
887 if( !aSel || !appStudy )
890 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
891 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
892 aModule->EmitSignalDeactivateDialog();
893 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
894 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
899 _PTR(Study) aStudy = appStudy->studyDS();
901 aSel->selectedObjects( selected );
903 if(selected.Extent() >= 1){
904 switch(theCommandID){
906 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
907 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
911 QColor c, e, b, n, c0D, o;
914 vtkFloatingPointType Shrink = 0.0;
915 vtkFloatingPointType faces_orientation_scale = 0.0;
916 bool faces_orientation_3dvectors = false;
918 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
919 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
920 int aMarkerTextureCurrent = 0;
922 SALOME_ListIteratorOfListIO It( selected );
923 for( ; It.More(); It.Next()){
924 Handle(SALOME_InteractiveObject) IObject = It.Value();
925 if(IObject->hasEntry()){
926 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
927 vtkFloatingPointType color[3];
928 anActor->GetSufaceColor(color[0], color[1], color[2]);
929 int c0 = int (color[0] * 255);
930 int c1 = int (color[1] * 255);
931 int c2 = int (color[2] * 255);
932 c.setRgb(c0, c1, c2);
934 vtkFloatingPointType edgecolor[3];
935 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
936 c0 = int (edgecolor[0] * 255);
937 c1 = int (edgecolor[1] * 255);
938 c2 = int (edgecolor[2] * 255);
939 e.setRgb(c0, c1, c2);
941 vtkFloatingPointType backfacecolor[3];
942 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
943 c0 = int (backfacecolor[0] * 255);
944 c1 = int (backfacecolor[1] * 255);
945 c2 = int (backfacecolor[2] * 255);
946 b.setRgb(c0, c1, c2);
948 vtkFloatingPointType nodecolor[3];
949 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
950 c0 = int (nodecolor[0] * 255);
951 c1 = int (nodecolor[1] * 255);
952 c2 = int (nodecolor[2] * 255);
953 n.setRgb(c0, c1, c2);
955 vtkFloatingPointType color0D[3];
956 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
957 c0 = int (color0D[0] * 255);
958 c1 = int (color0D[1] * 255);
959 c2 = int (color0D[2] * 255);
960 c0D.setRgb(c0, c1, c2);
962 size0D = (int)anActor->Get0DSize();
965 Edgewidth = (int)anActor->GetLineWidth();
968 Shrink = anActor->GetShrinkFactor();
970 vtkFloatingPointType faces_orientation_color[3];
971 anActor->GetFacesOrientationColor(faces_orientation_color);
972 c0 = int (faces_orientation_color[0] * 255);
973 c1 = int (faces_orientation_color[1] * 255);
974 c2 = int (faces_orientation_color[2] * 255);
975 o.setRgb(c0, c1, c2);
977 faces_orientation_scale = anActor->GetFacesOrientationScale();
978 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
980 aMarkerTypeCurrent = anActor->GetMarkerType();
981 aMarkerScaleCurrent = anActor->GetMarkerScale();
982 aMarkerTextureCurrent = anActor->GetMarkerTexture();
984 // even if there are multiple objects in the selection,
985 // we need only the first one to get values for the dialog
991 SMESHGUI_Preferences_ColorDlg *aDlg =
992 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
993 aDlg->SetColor(1, c);
994 aDlg->SetColor(2, e);
995 aDlg->SetColor(3, n);
996 aDlg->SetColor(4, b);
997 aDlg->SetColor(5, c0D);
998 aDlg->SetColor(6, o);
999 aDlg->SetIntValue(1, Edgewidth);
1000 aDlg->SetIntValue(2, int(Shrink*100.));
1001 aDlg->SetIntValue(3, size0D);
1002 aDlg->SetDoubleValue(1, faces_orientation_scale);
1003 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1005 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1007 if( aMarkerTypeCurrent != VTK::MT_USER )
1008 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1010 aDlg->setCustomMarker( aMarkerTextureCurrent );
1013 QColor color = aDlg->GetColor(1);
1014 QColor edgecolor = aDlg->GetColor(2);
1015 QColor nodecolor = aDlg->GetColor(3);
1016 QColor backfacecolor = aDlg->GetColor(4);
1017 QColor color0D = aDlg->GetColor(5);
1018 QColor faces_orientation_color = aDlg->GetColor(6);
1021 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1023 SALOME_ListIteratorOfListIO It( selected );
1024 for( ; It.More(); It.Next()){
1025 Handle(SALOME_InteractiveObject) IObject = It.Value();
1026 if(IObject->hasEntry()){
1027 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1028 /* actor color and backface color */
1029 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1030 vtkFloatingPointType (color.green()) / 255.,
1031 vtkFloatingPointType (color.blue()) / 255.);
1032 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1033 vtkFloatingPointType (backfacecolor.green()) / 255.,
1034 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1037 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1038 vtkFloatingPointType (edgecolor.green()) / 255.,
1039 vtkFloatingPointType (edgecolor.blue()) / 255.);
1041 /* Shrink factor and size edges */
1042 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1043 anActor->SetLineWidth(aDlg->GetIntValue(1));
1045 /* Nodes color and size */
1046 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1047 vtkFloatingPointType (nodecolor.green()) / 255.,
1048 vtkFloatingPointType (nodecolor.blue()) / 255.);
1051 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1052 vtkFloatingPointType (color0D.green()) / 255.,
1053 vtkFloatingPointType (color0D.blue()) / 255.);
1054 anActor->Set0DSize(aDlg->GetIntValue(3));
1056 /* Faces orientation */
1057 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1058 vtkFloatingPointType(faces_orientation_color.greenF()),
1059 vtkFloatingPointType(faces_orientation_color.blueF())};
1060 anActor->SetFacesOrientationColor(c);
1061 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1062 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1064 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1065 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1066 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1067 if( aMarkerTypeNew != VTK::MT_USER )
1068 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1070 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1071 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1072 if( anIter != aMarkerMap.end() )
1073 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1076 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1077 if( !aGroupObject->_is_nil() )
1079 SMESH::ElementType anElementType = aGroupObject->GetType();
1081 switch( anElementType )
1083 case SMESH::NODE: aColor = nodecolor; break;
1084 case SMESH::EDGE: aColor = edgecolor; break;
1085 default: aColor = color; break;
1088 SALOMEDS::Color aGroupColor;
1089 aGroupColor.R = (float)aColor.red() / 255.0;
1090 aGroupColor.G = (float)aColor.green() / 255.0;
1091 aGroupColor.B = (float)aColor.blue() / 255.0;
1092 aGroupObject->SetColor( aGroupColor );
1097 SMESH::RepaintCurrentView();
1103 SALOME_ListIteratorOfListIO It( selected );
1104 for( ; It.More(); It.Next()){
1105 Handle(SALOME_InteractiveObject) IObject = It.Value();
1106 if(IObject->hasEntry()){
1107 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1108 switch(theCommandID){
1110 anActor->SetRepresentation(SMESH_Actor::eEdge);
1113 anActor->SetRepresentation(SMESH_Actor::eSurface);
1116 if(anActor->IsShrunk())
1117 anActor->UnShrink();
1119 anActor->SetShrink();
1122 anActor->SetRepresentation(SMESH_Actor::ePoint);
1125 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1126 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1129 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1130 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1136 SMESH::RepaintCurrentView();
1140 void Control( int theCommandID )
1142 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1143 SALOME_ListIO selected;
1145 aSel->selectedObjects( selected );
1147 if( !selected.IsEmpty() ){
1148 Handle(SALOME_InteractiveObject) anIO = selected.First();
1150 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1151 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1152 switch ( theCommandID ){
1154 aControl = SMESH_Actor::eLength;
1157 aControl = SMESH_Actor::eLength2D;
1160 aControl = SMESH_Actor::eFreeEdges;
1163 aControl = SMESH_Actor::eFreeBorders;
1166 aControl = SMESH_Actor::eMultiConnection;
1169 aControl = SMESH_Actor::eFreeNodes;
1172 aControl = SMESH_Actor::eMultiConnection2D;
1175 aControl = SMESH_Actor::eArea;
1178 aControl = SMESH_Actor::eTaper;
1181 aControl = SMESH_Actor::eAspectRatio;
1184 aControl = SMESH_Actor::eAspectRatio3D;
1187 aControl = SMESH_Actor::eMinimumAngle;
1190 aControl = SMESH_Actor::eWarping;
1193 aControl = SMESH_Actor::eSkew;
1196 aControl = SMESH_Actor::eVolume3D;
1199 aControl = SMESH_Actor::eFreeFaces;
1202 aControl = SMESH_Actor::eMaxElementLength2D;
1205 aControl = SMESH_Actor::eMaxElementLength3D;
1208 aControl = SMESH_Actor::eBareBorderVolume;
1211 aControl = SMESH_Actor::eBareBorderFace;
1214 aControl = SMESH_Actor::eOverConstrainedVolume;
1217 aControl = SMESH_Actor::eOverConstrainedFace;
1220 anActor->SetControlMode(aControl);
1221 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1222 SMESH::RepaintCurrentView();
1229 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1230 MeshObjectType theType,
1231 const QString theInTypeName,
1232 QString & theOutTypeName)
1234 SMESH_TypeFilter aTypeFilter( theType );
1236 if( !theIO.IsNull() )
1238 entry = theIO->getEntry();
1239 LightApp_DataOwner owner( entry );
1240 if ( aTypeFilter.isOk( &owner )) {
1241 theOutTypeName = theInTypeName;
1249 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1251 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1252 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1254 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1255 CORBA::String_var anID = aSComp->GetID().c_str();
1256 if (!strcmp(anID.in(),theIO->getEntry()))
1262 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1263 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1264 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1265 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1266 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1274 QString CheckHomogeneousSelection()
1276 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1277 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1278 SALOME_ListIO selected;
1280 aSel->selectedObjects( selected );
1282 QString RefType = CheckTypeObject(selected.First());
1283 SALOME_ListIteratorOfListIO It(selected);
1284 for ( ; It.More(); It.Next())
1286 Handle(SALOME_InteractiveObject) IObject = It.Value();
1287 QString Type = CheckTypeObject(IObject);
1288 if (Type.compare(RefType) != 0)
1289 return "Heterogeneous Selection";
1296 void SMESHGUI::OnEditDelete()
1298 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1299 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1300 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1302 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1303 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1304 _PTR(GenericAttribute) anAttr;
1305 _PTR(AttributeIOR) anIOR;
1307 int objectCount = 0;
1309 QString aParentComponent = QString::null;
1310 Handle(SALOME_InteractiveObject) anIO;
1311 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1313 anIO = anIt.Value();
1314 QString cur = anIO->getComponentDataType();
1315 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1317 // check if object is reference
1318 _PTR(SObject) aRefSObj;
1319 aNameList.append("\n - ");
1320 if ( aSO->ReferencedObject( aRefSObj ) ) {
1321 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1322 aNameList.append( aRefName );
1323 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1326 aNameList.append(anIO->getName());
1330 if( aParentComponent.isNull() )
1331 aParentComponent = cur;
1332 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1333 aParentComponent = "";
1336 if ( objectCount == 0 )
1337 return; // No Valid Objects Selected
1339 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1340 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1341 QObject::tr("ERR_ERROR"),
1342 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1345 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1346 if (SUIT_MessageBox::warning
1347 (SMESHGUI::desktop(),
1348 QObject::tr("SMESH_WRN_WARNING"),
1349 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1350 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1351 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1354 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1355 SUIT_ViewManager* vm = anApp->activeViewManager();
1356 int nbSf = vm ? vm->getViewsCount() : 0;
1358 SALOME_ListIteratorOfListIO It(selected);
1360 aStudyBuilder->NewCommand(); // There is a transaction
1361 for( ; It.More(); It.Next()){ // loop on selected IO's
1362 Handle(SALOME_InteractiveObject) IObject = It.Value();
1363 if(IObject->hasEntry()) {
1364 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1366 // disable removal of "SMESH" component object
1367 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1369 if ( engineIOR() == anIOR->Value().c_str() )
1372 //Check the referenced object
1373 _PTR(SObject) aRefSObject;
1374 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1375 aSO = aRefSObject; // Delete main Object instead of reference
1377 // put the whole hierarchy of sub-objects of the selected SO into a list and
1378 // then treat them all starting from the deepest objects (at list back)
1380 std::list< _PTR(SObject) > listSO;
1381 listSO.push_back( aSO );
1382 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1383 for ( ; itSO != listSO.end(); ++itSO ) {
1384 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1385 for (it->InitEx(false); it->More(); it->Next())
1386 listSO.push_back( it->Value() );
1389 // treat SO's in the list starting from the back
1391 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1392 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1393 _PTR(SObject) SO = *ritSO;
1394 if ( !SO ) continue;
1395 std::string anEntry = SO->GetID();
1397 /** Erase graphical object **/
1398 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1399 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1400 for(int i = 0; i < nbSf; i++){
1401 SUIT_ViewWindow *sf = aViews[i];
1402 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1403 SMESH::RemoveActor(sf,anActor);
1408 /** Remove an object from data structures **/
1409 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1410 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1411 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1412 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1413 aMesh->RemoveGroup( aGroup );
1415 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1416 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1417 aMesh->RemoveSubMesh( aSubMesh );
1419 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1421 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1424 IObject = new SALOME_InteractiveObject
1425 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1426 QString objType = CheckTypeObject(IObject);
1427 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1428 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1429 aStudyBuilder->RemoveObjectWithChildren( SO );
1431 else {// default action: remove SObject from the study
1432 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1433 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1435 aStudyBuilder->RemoveObjectWithChildren( SO );
1439 } /* listSO back loop */
1440 } /* IObject->hasEntry() */
1442 aStudyBuilder->CommitCommand();
1444 /* Clear any previous selection */
1446 aSel->setSelectedObjects( l1 );
1448 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1453 SMESHGUI_EXPORT CAM_Module* createModule()
1455 return new SMESHGUI();
1459 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1461 //=============================================================================
1465 //=============================================================================
1466 SMESHGUI::SMESHGUI() :
1467 SalomeApp_Module( "SMESH" ),
1468 LightApp_Module( "SMESH" )
1470 if ( CORBA::is_nil( myComponentSMESH ) )
1472 CORBA::Boolean anIsEmbeddedMode;
1473 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1474 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1476 // 0019923: EDF 765 SMESH : default values of hypothesis
1477 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1478 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1479 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1480 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1481 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1484 myActiveDialogBox = 0;
1485 myFilterLibraryDlg = 0;
1489 myEventCallbackCommand = vtkCallbackCommand::New();
1490 myEventCallbackCommand->Delete();
1491 myEventCallbackCommand->SetClientData( this );
1492 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1495 SMESH::GetFilterManager();
1496 SMESH::GetPattern();
1497 SMESH::GetMeasurements();
1499 /* load resources for all available meshers */
1500 SMESH::InitAvailableHypotheses();
1503 //=============================================================================
1507 //=============================================================================
1508 SMESHGUI::~SMESHGUI()
1510 #ifdef WITHGENERICOBJ
1511 SMESH::GetFilterManager()->Destroy();
1512 SMESH::GetMeasurements()->Destroy();
1514 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1515 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1518 //=============================================================================
1522 //=============================================================================
1523 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1525 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1527 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1532 //=============================================================================
1536 //=============================================================================
1537 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1539 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1543 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1544 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1545 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1546 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1547 return autoUpdate && !exceeded;
1550 //=============================================================================
1554 //=============================================================================
1555 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1557 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1560 //=============================================================================
1564 //=============================================================================
1565 SMESHGUI* SMESHGUI::GetSMESHGUI()
1567 SMESHGUI* smeshMod = 0;
1568 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1571 CAM_Module* module = app->module( "Mesh" );
1572 smeshMod = dynamic_cast<SMESHGUI*>( module );
1575 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1577 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1580 _PTR(Study) aStudy = study->studyDS();
1582 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1591 Standard_EXPORT SMESHGUI* GetComponentGUI()
1593 return SMESHGUI::GetSMESHGUI();
1597 //=============================================================================
1601 //=============================================================================
1602 void SMESHGUI::SetState(int aState)
1607 //=============================================================================
1611 //=============================================================================
1612 void SMESHGUI::ResetState()
1617 //=============================================================================
1621 //=============================================================================
1622 void SMESHGUI::EmitSignalDeactivateDialog()
1624 emit SignalDeactivateActiveDialog();
1627 //=============================================================================
1631 //=============================================================================
1632 void SMESHGUI::EmitSignalStudyFrameChanged()
1634 emit SignalStudyFrameChanged();
1637 //=============================================================================
1641 //=============================================================================
1642 void SMESHGUI::EmitSignalCloseAllDialogs()
1644 emit SignalCloseAllDialogs();
1647 //=============================================================================
1651 //=============================================================================
1652 void SMESHGUI::EmitSignalVisibilityChanged()
1654 emit SignalVisibilityChanged();
1657 //=============================================================================
1661 //=============================================================================
1662 QDialog *SMESHGUI::GetActiveDialogBox()
1664 return myActiveDialogBox;
1667 //=============================================================================
1671 //=============================================================================
1672 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1674 myActiveDialogBox = (QDialog *) aDlg;
1678 //=============================================================================
1682 //=============================================================================
1683 SUIT_Desktop* SMESHGUI::desktop()
1685 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1687 return app->desktop();
1692 //=============================================================================
1696 //=============================================================================
1697 SalomeApp_Study* SMESHGUI::activeStudy()
1699 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1701 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1706 //=============================================================================
1710 //=============================================================================
1711 void SMESHGUI::Modified( bool theIsUpdateActions )
1713 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1714 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1715 appStudy->Modified();
1716 if( theIsUpdateActions )
1717 app->updateActions();
1722 //=============================================================================
1726 //=============================================================================
1727 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1729 /* Here the position is on the bottom right corner - 10 */
1730 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1732 SUIT_Desktop *PP = desktop();
1733 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1734 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1738 //=============================================================================
1742 //=============================================================================
1743 static int isStudyLocked(_PTR(Study) theStudy){
1744 return theStudy->GetProperties()->IsLocked();
1747 static bool checkLock(_PTR(Study) theStudy) {
1748 if (isStudyLocked(theStudy)) {
1749 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1750 QObject::tr("WRN_WARNING"),
1751 QObject::tr("WRN_STUDY_LOCKED") );
1757 //=======================================================================
1758 //function : CheckActiveStudyLocked
1760 //=======================================================================
1762 bool SMESHGUI::isActiveStudyLocked()
1764 _PTR(Study) aStudy = activeStudy()->studyDS();
1765 return checkLock( aStudy );
1768 //=============================================================================
1772 //=============================================================================
1773 bool SMESHGUI::OnGUIEvent( int theCommandID )
1775 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1779 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1780 SUIT_ResourceMgr* mgr = resourceMgr();
1784 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1785 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1788 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1789 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1791 //QAction* act = action( theCommandID );
1793 switch (theCommandID) {
1795 if(checkLock(aStudy)) break;
1803 if(checkLock(aStudy)) break;
1804 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1808 case 150: //MED FILE INFORMATION
1810 SALOME_ListIO selected;
1811 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1813 aSel->selectedObjects( selected );
1814 if( selected.Extent() )
1816 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1817 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1818 if ( !aMesh->_is_nil() )
1820 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1827 case 122: // EXPORT MED
1836 ::ExportMeshToFile(theCommandID);
1840 case 200: // SCALAR BAR
1842 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1843 SALOME_ListIO selected;
1845 aSel->selectedObjects( selected );
1847 if( selected.Extent() ) {
1848 Handle(SALOME_InteractiveObject) anIO = selected.First();
1849 if( anIO->hasEntry() ) {
1850 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1851 anActor->SetControlMode( SMESH_Actor::eNone );
1859 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1864 // dump control distribution data to the text file
1865 ::SaveDistribution();
1871 // show/ distribution
1872 ::ShowDistribution();
1882 ::DisableAutoColor();
1885 case 1134: // Clipping
1886 case 1133: // Tranparency
1887 case 1132: // Colors / Size
1894 ::SetDisplayMode(theCommandID, myMarkerMap);
1897 //2D quadratic representation
1900 ::SetDisplayMode(theCommandID, myMarkerMap);
1904 case 216: // 0D elements
1907 case 219: // Volumes
1908 case 220: // All Entity
1909 ::SetDisplayEntity(theCommandID);
1912 case 221: // Orientation of faces
1914 LightApp_SelectionMgr* mgr = selectionMgr();
1915 SALOME_ListIO selected; mgr->selectedObjects( selected );
1917 SALOME_ListIteratorOfListIO it(selected);
1918 for( ; it.More(); it.Next()) {
1919 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1920 if(anIObject->hasEntry()) {
1921 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1922 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1931 if(checkLock(aStudy)) break;
1933 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1936 SMESH::UpdateView();
1938 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1939 SMESH::OnVisuException();
1941 catch (...) { // PAL16774 (Crash after display of many groups)
1942 SMESH::OnVisuException();
1946 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1947 aSel->selectedObjects( l );
1948 aSel->setSelectedObjects( l );
1953 case 301: // DISPLAY
1954 case 302: // DISPLAY ONLY
1956 SMESH::EDisplaing anAction;
1957 switch (theCommandID) {
1958 case 300: anAction = SMESH::eErase; break;
1959 case 301: anAction = SMESH::eDisplay; break;
1960 case 302: anAction = SMESH::eDisplayOnly; break;
1963 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1964 SALOME_ListIO sel_objects, to_process;
1966 aSel->selectedObjects( sel_objects );
1968 if( theCommandID==302 )
1970 MESSAGE("anAction = SMESH::eDisplayOnly");
1971 startOperation( myEraseAll );
1974 extractContainers( sel_objects, to_process );
1977 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1981 SALOME_ListIteratorOfListIO It( to_process );
1982 for ( ; It.More(); It.Next()) {
1984 Handle(SALOME_InteractiveObject) IOS = It.Value();
1985 if (IOS->hasEntry()) {
1987 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1988 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1989 break; // PAL16774 (Crash after display of many groups)
1991 if (anAction == SMESH::eDisplayOnly)
1993 MESSAGE("anAction = SMESH::eDisplayOnly");
1994 anAction = SMESH::eDisplay;
2000 // PAL13338 + PAL15161 -->
2001 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2002 MESSAGE("anAction = SMESH::eDisplayOnly");
2003 SMESH::UpdateView();
2004 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2006 // PAL13338 + PAL15161 <--
2008 catch (...) { // PAL16774 (Crash after display of many groups)
2009 SMESH::OnVisuException();
2012 if (anAction == SMESH::eErase) {
2013 MESSAGE("anAction == SMESH::eErase");
2015 aSel->setSelectedObjects( l1 );
2018 aSel->setSelectedObjects( to_process );
2025 if(checkLock(aStudy)) break;
2028 EmitSignalDeactivateDialog();
2030 ( new SMESHGUI_NodesDlg( this ) )->show();
2033 SUIT_MessageBox::warning(desktop(),
2034 tr("SMESH_WRN_WARNING"),
2035 tr("SMESH_WRN_VIEWER_VTK"));
2040 case 2151: // FILTER
2044 EmitSignalDeactivateDialog();
2045 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2050 case 701: // COMPUTE MESH
2051 case 711: // PRECOMPUTE MESH
2052 case 712: // EVALUATE MESH
2053 case 713: // MESH ORDER
2055 if (checkLock(aStudy)) break;
2056 startOperation( theCommandID );
2060 case 702: // Create mesh
2061 case 703: // Create sub-mesh
2062 case 704: // Edit mesh/sub-mesh
2063 startOperation( theCommandID );
2065 case 705: // copy mesh
2067 if (checkLock(aStudy)) break;
2068 EmitSignalDeactivateDialog();
2069 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2072 case 710: // Build compound mesh
2074 if (checkLock(aStudy)) break;
2075 EmitSignalDeactivateDialog();
2076 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2080 case 407: // DIAGONAL INVERSION
2081 case 408: // Delete diagonal
2085 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2086 tr( "NOT_A_VTK_VIEWER" ) );
2090 if ( checkLock( aStudy ) )
2093 /*Standard_Boolean aRes;
2094 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2095 if ( aMesh->_is_nil() )
2097 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2098 tr( "SMESH_BAD_SELECTION" ) );
2102 EmitSignalDeactivateDialog();
2103 if ( theCommandID == 407 )
2104 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2106 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2109 case 409: // Change orientation
2110 case 410: // Union of triangles
2111 case 411: // Cutting of quadrangles
2112 case 419: // Splitting volumes into tetrahedra
2116 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2117 tr( "NOT_A_VTK_VIEWER" ) );
2121 if ( checkLock( aStudy ) )
2124 EmitSignalDeactivateDialog();
2125 SMESHGUI_MultiEditDlg* aDlg = NULL;
2126 if ( theCommandID == 409 )
2127 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2128 else if ( theCommandID == 410 )
2129 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2130 else if ( theCommandID == 419 )
2131 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2133 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2138 case 412: // Smoothing
2140 if(checkLock(aStudy)) break;
2142 EmitSignalDeactivateDialog();
2143 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2146 SUIT_MessageBox::warning(desktop(),
2147 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2151 case 413: // Extrusion
2153 if (checkLock(aStudy)) break;
2155 EmitSignalDeactivateDialog();
2156 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2158 SUIT_MessageBox::warning(desktop(),
2159 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2163 case 414: // Revolution
2165 if(checkLock(aStudy)) break;
2167 EmitSignalDeactivateDialog();
2168 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2171 SUIT_MessageBox::warning(desktop(),
2172 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2176 case 415: // Pattern mapping
2178 if ( checkLock( aStudy ) )
2182 EmitSignalDeactivateDialog();
2183 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2186 SUIT_MessageBox::warning(desktop(),
2187 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2191 case 416: // Extrusion along a path
2193 if (checkLock(aStudy)) break;
2195 EmitSignalDeactivateDialog();
2196 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2198 SUIT_MessageBox::warning(desktop(),
2199 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2203 case 417: // Convert mesh to quadratic
2205 startOperation( 417 );
2206 /* if (checkLock(aStudy)) break;
2208 EmitSignalDeactivateDialog();
2209 new SMESHGUI_ConvToQuadDlg();
2211 SUIT_MessageBox::warning(desktop(),
2212 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2216 case 418: // create 2D mesh from 3D
2218 startOperation( 418 );
2221 case 806: // CREATE GEO GROUP
2223 startOperation( 806 );
2226 case 801: // CREATE GROUP
2230 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2231 tr( "NOT_A_VTK_VIEWER" ) );
2235 if(checkLock(aStudy)) break;
2236 EmitSignalDeactivateDialog();
2237 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2239 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2240 SALOME_ListIO selected;
2242 aSel->selectedObjects( selected );
2244 int nbSel = selected.Extent();
2246 // check if mesh is selected
2247 aMesh = SMESH::GetMeshByIO( selected.First() );
2249 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2254 case 802: // CONSTRUCT GROUP
2258 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2259 tr( "NOT_A_VTK_VIEWER" ) );
2263 if(checkLock(aStudy)) break;
2264 EmitSignalDeactivateDialog();
2266 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2267 SALOME_ListIO selected;
2269 aSel->selectedObjects( selected );
2271 int nbSel = selected.Extent();
2273 // check if submesh is selected
2274 Handle(SALOME_InteractiveObject) IObject = selected.First();
2275 if (IObject->hasEntry()) {
2276 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2278 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2279 if (!aSubMesh->_is_nil()) {
2281 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2282 // get submesh elements list by types
2283 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2284 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2285 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2286 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2287 // create group for each type o elements
2288 QString aName = IObject->getName();
2289 if (aNodes->length() > 0) {
2290 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2291 aGroup->Add(aNodes.inout());
2293 if (aEdges->length() > 0) {
2294 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2295 aGroup->Add(aEdges.inout());
2297 if (aFaces->length() > 0) {
2298 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2299 aGroup->Add(aFaces.inout());
2301 if (aVolumes->length() > 0) {
2302 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2303 aGroup->Add(aVolumes.inout());
2308 catch(const SALOME::SALOME_Exception & S_ex){
2309 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2316 SUIT_MessageBox::warning(desktop(),
2317 tr("SMESH_WRN_WARNING"),
2318 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2323 case 803: // EDIT GROUP
2327 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2328 tr( "NOT_A_VTK_VIEWER" ) );
2332 if(checkLock(aStudy)) break;
2333 EmitSignalDeactivateDialog();
2335 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2336 SALOME_ListIO selected;
2338 aSel->selectedObjects( selected );
2340 SALOME_ListIteratorOfListIO It (selected);
2341 int nbSelectedGroups = 0;
2342 for ( ; It.More(); It.Next() )
2344 SMESH::SMESH_GroupBase_var aGroup =
2345 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2346 if (!aGroup->_is_nil()) {
2348 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2352 if (nbSelectedGroups == 0)
2354 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2360 case 804: // Add elements to group
2362 if(checkLock(aStudy)) break;
2363 if (myState == 800) {
2364 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2365 if (aDlg) aDlg->onAdd();
2370 case 805: // Remove elements from group
2372 if(checkLock(aStudy)) break;
2373 if (myState == 800) {
2374 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2375 if (aDlg) aDlg->onRemove();
2380 case 815: // Edit GEOM GROUP as standalone
2384 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2385 tr( "NOT_A_VTK_VIEWER" ) );
2389 if(checkLock(aStudy)) break;
2390 EmitSignalDeactivateDialog();
2392 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2393 SALOME_ListIO selected;
2395 aSel->selectedObjects( selected );
2397 SALOME_ListIteratorOfListIO It (selected);
2398 for ( ; It.More(); It.Next() )
2400 SMESH::SMESH_GroupOnGeom_var aGroup =
2401 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2402 if (!aGroup->_is_nil()) {
2403 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2410 case 810: // Union Groups
2411 case 811: // Intersect groups
2412 case 812: // Cut groups
2416 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2417 tr( "NOT_A_VTK_VIEWER" ) );
2421 if ( checkLock( aStudy ) )
2424 EmitSignalDeactivateDialog();
2426 SMESHGUI_GroupOpDlg* aDlg = 0;
2427 if ( theCommandID == 810 )
2428 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2429 else if ( theCommandID == 811 )
2430 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2432 aDlg = new SMESHGUI_CutGroupsDlg( this );
2439 case 814: // Create groups of entities from existing groups of superior dimensions
2441 if ( checkLock( aStudy ) )
2444 EmitSignalDeactivateDialog();
2445 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2451 case 813: // Delete groups with their contents
2455 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2456 tr( "NOT_A_VTK_VIEWER" ) );
2460 if ( checkLock( aStudy ) )
2463 EmitSignalDeactivateDialog();
2465 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2469 case 900: // MESH INFOS
2470 case 903: // WHAT IS
2472 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2473 EmitSignalDeactivateDialog();
2474 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2475 SALOME_ListIO selected;
2477 aSel->selectedObjects( selected );
2479 if ( selected.Extent() > 1 ) { // a dlg for each IO
2480 SALOME_ListIteratorOfListIO It( selected );
2481 for ( ; It.More(); It.Next() ) {
2482 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2483 dlg->showInfo( It.Value() );
2488 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2494 case 902: // STANDARD MESH INFOS
2496 EmitSignalDeactivateDialog();
2497 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2498 SALOME_ListIO selected;
2500 aSel->selectedObjects( selected );
2502 if ( selected.Extent() > 1 ) { // a dlg for each IO
2504 SALOME_ListIteratorOfListIO It (selected);
2505 for ( ; It.More(); It.Next() ) {
2507 IOs.Append( It.Value() );
2508 aSel->setSelectedObjects( IOs );
2509 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2511 // restore selection
2512 aSel->setSelectedObjects( selected );
2515 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2518 case 903: // WHAT IS
2520 EmitSignalDeactivateDialog();
2521 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2526 case 904: // FIND ELEM
2528 startOperation( theCommandID );
2532 case 1100: // EDIT HYPOTHESIS
2534 if(checkLock(aStudy)) break;
2536 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2537 SALOME_ListIO selected;
2539 aSel->selectedObjects( selected );
2541 int nbSel = selected.Extent();
2544 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2545 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2547 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2548 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2549 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2550 if ( !aHypothesis->_is_nil() )
2553 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2554 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2556 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2567 case 1101: // RENAME
2569 if ( checkLock( aStudy ) )
2572 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2573 SALOME_ListIO selected;
2575 aSel->selectedObjects( selected );
2577 bool isAny = false; // is there any appropriate object selected
2579 SALOME_ListIteratorOfListIO It( selected );
2580 for ( ; It.More(); It.Next() )
2582 Handle(SALOME_InteractiveObject) IObject = It.Value();
2583 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2584 _PTR(GenericAttribute) anAttr;
2585 _PTR(AttributeName) aName;
2588 if ( obj->FindAttribute(anAttr, "AttributeName") )
2591 QString newName = QString(aName->Value().c_str());
2593 // check type to prevent renaming of inappropriate objects
2594 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2595 if (aType == MESH || aType == GROUP ||
2596 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2597 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2598 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2599 aType == HYPOTHESIS || aType == ALGORITHM)
2602 newName = LightApp_NameDlg::getName(desktop(), newName);
2603 if ( !newName.isEmpty() )
2605 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2607 // update name of group object and its actor
2608 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2609 if( !aGroupObject->_is_nil() )
2611 aGroupObject->SetName( newName.toLatin1().data() );
2612 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2613 anActor->setName( newName.toLatin1().data() );
2624 SUIT_MessageBox::warning(desktop(),
2625 QObject::tr("SMESH_WRN_WARNING"),
2626 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2631 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2633 if(checkLock(aStudy)) break;
2634 SUIT_OverrideCursor wc;
2636 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2637 SALOME_ListIO selected;
2639 aSel->selectedObjects( selected, QString::null, false );
2641 SALOME_ListIteratorOfListIO It(selected);
2642 for (int i = 0; It.More(); It.Next(), i++) {
2643 Handle(SALOME_InteractiveObject) IObject = It.Value();
2644 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2647 aSel->setSelectedObjects( l1 );
2652 case 4009: // ELEM0D
2653 case 4010: // GEOM::EDGE
2654 case 4021: // TRIANGLE
2656 case 4023: // POLYGON
2660 if(checkLock(aStudy)) break;
2662 EmitSignalDeactivateDialog();
2663 SMDSAbs_ElementType type = SMDSAbs_Edge;
2665 switch (theCommandID) {
2666 case 4009: // ELEM0D
2667 type = SMDSAbs_0DElement; nbNodes = 1; break;
2668 case 4021: // TRIANGLE
2669 type = SMDSAbs_Face; nbNodes = 3; break;
2671 type = SMDSAbs_Face; nbNodes = 4; break;
2673 type = SMDSAbs_Volume; nbNodes = 4; break;
2674 case 4023: // POLYGON
2675 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2677 type = SMDSAbs_Volume; nbNodes = 8; break;
2678 case 4033: // POLYHEDRE
2679 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2682 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2685 SUIT_MessageBox::warning(desktop(),
2686 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2690 case 4033: // POLYHEDRON
2692 if(checkLock(aStudy)) break;
2694 EmitSignalDeactivateDialog();
2695 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2698 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2699 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2703 case 4034: // QUADRATIC EDGE
2704 case 4035: // QUADRATIC TRIANGLE
2705 case 4036: // QUADRATIC QUADRANGLE
2706 case 4037: // QUADRATIC TETRAHEDRON
2707 case 4038: // QUADRATIC PYRAMID
2708 case 4039: // QUADRATIC PENTAHEDRON
2709 case 4040: // QUADRATIC HEXAHEDRON
2711 if(checkLock(aStudy)) break;
2713 EmitSignalDeactivateDialog();
2716 switch (theCommandID) {
2718 type = QUAD_EDGE; break;
2720 type = QUAD_TRIANGLE; break;
2722 type = QUAD_QUADRANGLE; break;
2724 type = QUAD_TETRAHEDRON; break;
2726 type = QUAD_PYRAMID; break;
2728 type = QUAD_PENTAHEDRON; break;
2730 type = QUAD_HEXAHEDRON;
2734 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2737 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2738 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2742 case 4041: // REMOVES NODES
2744 if(checkLock(aStudy)) break;
2746 EmitSignalDeactivateDialog();
2747 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2750 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2751 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2755 case 4042: // REMOVES ELEMENTS
2757 if(checkLock(aStudy)) break;
2759 EmitSignalDeactivateDialog();
2760 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2764 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2765 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2769 case 4043: { // CLEAR_MESH
2771 if(checkLock(aStudy)) break;
2773 SALOME_ListIO selected;
2774 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2775 aSel->selectedObjects( selected );
2777 SUIT_OverrideCursor wc;
2778 SALOME_ListIteratorOfListIO It (selected);
2779 for ( ; It.More(); It.Next() )
2781 Handle(SALOME_InteractiveObject) IOS = It.Value();
2782 SMESH::SMESH_Mesh_var aMesh =
2783 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2784 if ( aMesh->_is_nil()) continue;
2786 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2788 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2789 SMESH::ModifiedMesh( aMeshSObj, false, true);
2790 // hide groups and submeshes
2791 _PTR(ChildIterator) anIter =
2792 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2793 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2795 _PTR(SObject) so = anIter->Value();
2796 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2799 catch (const SALOME::SALOME_Exception& S_ex){
2801 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2805 SMESH::UpdateView();
2809 case 4044: // REMOVE ORPHAN NODES
2811 if(checkLock(aStudy)) break;
2812 SALOME_ListIO selected;
2813 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2814 aSel->selectedObjects( selected );
2815 if ( selected.Extent() == 1 ) {
2816 Handle(SALOME_InteractiveObject) anIO = selected.First();
2817 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2818 if ( !aMesh->_is_nil() ) {
2819 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2820 tr( "SMESH_WARNING" ),
2821 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2822 SUIT_MessageBox::Yes |
2823 SUIT_MessageBox::No,
2824 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2827 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2828 int removed = aMeshEditor->RemoveOrphanNodes();
2829 SUIT_MessageBox::information(SMESHGUI::desktop(),
2830 tr("SMESH_INFORMATION"),
2831 tr("NB_NODES_REMOVED").arg(removed));
2832 if ( removed > 0 ) {
2833 SMESH::UpdateView();
2834 SMESHGUI::Modified();
2837 catch (const SALOME::SALOME_Exception& S_ex) {
2838 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2847 case 4051: // RENUMBERING NODES
2849 if(checkLock(aStudy)) break;
2851 EmitSignalDeactivateDialog();
2852 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2856 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2857 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2861 case 4052: // RENUMBERING ELEMENTS
2863 if(checkLock(aStudy)) break;
2865 EmitSignalDeactivateDialog();
2866 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2870 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2871 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2875 case 4061: // TRANSLATION
2877 if(checkLock(aStudy)) break;
2879 EmitSignalDeactivateDialog();
2880 ( new SMESHGUI_TranslationDlg( this ) )->show();
2883 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2884 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2888 case 4062: // ROTATION
2890 if(checkLock(aStudy)) break;
2892 EmitSignalDeactivateDialog();
2893 ( new SMESHGUI_RotationDlg( this ) )->show();
2896 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2897 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2901 case 4063: // SYMMETRY
2903 if(checkLock(aStudy)) break;
2905 EmitSignalDeactivateDialog();
2906 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2909 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2910 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2914 case 4064: // SEWING
2916 if(checkLock(aStudy)) break;
2918 EmitSignalDeactivateDialog();
2919 ( new SMESHGUI_SewingDlg( this ) )->show();
2922 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2923 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2927 case 4065: // MERGE NODES
2929 if(checkLock(aStudy)) break;
2931 EmitSignalDeactivateDialog();
2932 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2935 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2940 case 4066: // MERGE EQUAL ELEMENTS
2942 if (checkLock(aStudy)) break;
2944 EmitSignalDeactivateDialog();
2945 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2947 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2948 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2953 case 4067: // MAKE MESH PASS THROUGH POINT
2954 startOperation( 4067 );
2959 if(checkLock(aStudy)) break;
2961 EmitSignalDeactivateDialog();
2962 ( new SMESHGUI_ScaleDlg( this ) )->show();
2965 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2966 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2971 case 4069: // DUPLICATE NODES
2973 if(checkLock(aStudy)) break;
2975 EmitSignalDeactivateDialog();
2976 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2979 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2980 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2985 case 5105: // Library of selection filters
2987 static QList<int> aTypes;
2988 if ( aTypes.isEmpty() )
2990 aTypes.append( SMESH::NODE );
2991 aTypes.append( SMESH::EDGE );
2992 aTypes.append( SMESH::FACE );
2993 aTypes.append( SMESH::VOLUME );
2995 if (!myFilterLibraryDlg)
2996 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2997 else if (myFilterLibraryDlg->isHidden())
2998 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2999 myFilterLibraryDlg->raise();
3003 case 6017: // CONTROLS
3027 LightApp_SelectionMgr* mgr = selectionMgr();
3028 SALOME_ListIO selected; mgr->selectedObjects( selected );
3030 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3031 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3033 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3034 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3035 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3036 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3037 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3038 ::Control( theCommandID );
3043 SUIT_MessageBox::warning(desktop(),
3044 tr( "SMESH_WRN_WARNING" ),
3045 tr( "SMESH_BAD_SELECTION" ) );
3049 SUIT_MessageBox::warning(desktop(),
3050 tr( "SMESH_WRN_WARNING" ),
3051 tr( "NOT_A_VTK_VIEWER" ) );
3056 LightApp_SelectionMgr* mgr = selectionMgr();
3057 SALOME_ListIO selected; mgr->selectedObjects( selected );
3059 SALOME_ListIteratorOfListIO it(selected);
3060 for( ; it.More(); it.Next()) {
3061 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3062 if(anIObject->hasEntry()) {
3063 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3064 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3072 LightApp_SelectionMgr* mgr = selectionMgr();
3073 SALOME_ListIO selected; mgr->selectedObjects( selected );
3075 SALOME_ListIteratorOfListIO it(selected);
3076 for( ; it.More(); it.Next()) {
3077 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3078 if(anIObject->hasEntry())
3079 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3080 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3088 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3089 EmitSignalDeactivateDialog();
3090 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3096 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3097 //updateObjBrowser();
3101 //=============================================================================
3105 //=============================================================================
3106 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3111 //=============================================================================
3115 //=============================================================================
3116 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3121 //=============================================================================
3125 //=============================================================================
3126 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3131 //=============================================================================
3132 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3133 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3135 //=============================================================================
3136 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3137 SUIT_ViewWindow* wnd )
3139 if(theIO->hasEntry()){
3140 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3141 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3145 //=======================================================================
3146 // function : createSMESHAction
3148 //=======================================================================
3149 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3150 const int key, const bool toggle, const QString& shortcutAction )
3153 QWidget* parent = application()->desktop();
3154 SUIT_ResourceMgr* resMgr = resourceMgr();
3156 if ( !icon_id.isEmpty() )
3157 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3159 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3160 if ( !pix.isNull() )
3161 icon = QIcon( pix );
3163 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3164 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3165 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3167 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3168 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3171 //=======================================================================
3172 // function : createPopupItem
3174 //=======================================================================
3175 void SMESHGUI::createPopupItem( const int id,
3176 const QString& clients,
3177 const QString& types,
3178 const QString& theRule,
3183 parentId = popupMgr()->actionId( action( pId ) );
3185 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3186 popupMgr()->insert( action( id ), parentId, 0 );
3188 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3189 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3190 QString rule = "(%1) and (%2) and (%3)";
3191 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3192 if( clients.isEmpty() )
3193 rule = rule.arg( QString( "true" ) );
3195 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3196 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3199 bool cont = myRules.contains( id );
3201 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3203 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3204 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3207 //=======================================================================
3208 // function : initialize
3210 //=======================================================================
3211 void SMESHGUI::initialize( CAM_Application* app )
3213 SalomeApp_Module::initialize( app );
3215 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3217 /* Automatic Update flag */
3218 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3220 // ----- create actions --------------
3222 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3223 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3224 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3225 createSMESHAction( 114, "NUM" );
3226 createSMESHAction( 121, "DAT" );
3227 createSMESHAction( 122, "MED" );
3228 createSMESHAction( 123, "UNV" );
3229 createSMESHAction( 140, "STL" );
3230 createSMESHAction( 124, "EXPORT_DAT" );
3231 createSMESHAction( 125, "EXPORT_MED" );
3232 createSMESHAction( 126, "EXPORT_UNV" );
3233 createSMESHAction( 141, "EXPORT_STL" );
3234 createSMESHAction( 150, "FILE_INFO" );
3235 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3236 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3237 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3238 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3239 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3240 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3241 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3242 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3243 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3244 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3245 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3246 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3247 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3248 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3249 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3250 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3251 createSMESHAction( 804, "ADD" );
3252 createSMESHAction( 805, "REMOVE" );
3253 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3254 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3255 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3256 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3257 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3258 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3259 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3260 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3261 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3262 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3263 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3264 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3265 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3266 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3267 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3268 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3269 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3270 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3271 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3272 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3273 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3274 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3275 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3276 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3277 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3278 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3279 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3280 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3281 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3282 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3283 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3284 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3285 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3286 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3287 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3288 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3289 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3290 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3291 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3292 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3293 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3294 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3295 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3296 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3297 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3298 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3299 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3300 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3301 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3302 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3303 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3304 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3305 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3306 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3307 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3308 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3309 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3310 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3311 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3312 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3313 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3314 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3315 createSMESHAction( 415, "MAP", "ICON_MAP" );
3316 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3317 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3318 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3319 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3320 createSMESHAction( 200, "RESET" );
3321 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3322 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3323 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3324 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3325 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3326 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3327 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3328 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3329 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3330 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3331 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3332 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3333 createSMESHAction( 220, "ALL" );
3334 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3336 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3337 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3339 createSMESHAction( 1100, "EDIT_HYPO" );
3340 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3341 createSMESHAction( 1102, "UNASSIGN" );
3342 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3343 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3344 createSMESHAction( 1131, "DISPMODE" );
3345 createSMESHAction( 1132, "COLORS" );
3346 createSMESHAction( 1133, "TRANSP" );
3347 createSMESHAction( 1134, "CLIP" );
3348 createSMESHAction( 1135, "DISP_ENT" );
3349 createSMESHAction( 1136, "AUTO_COLOR" );
3350 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3351 createSMESHAction( 2000, "CTRL" );
3353 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3354 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3356 createSMESHAction( 300, "ERASE" );
3357 createSMESHAction( 301, "DISPLAY" );
3358 createSMESHAction( 302, "DISPLAY_ONLY" );
3359 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3360 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3361 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3362 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3363 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3364 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3365 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3366 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3368 // ----- create menu --------------
3369 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3370 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3371 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3372 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3373 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3374 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3375 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3376 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3378 createMenu( separator(), fileId );
3380 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3381 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3382 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3383 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3384 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3385 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3386 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3387 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3388 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3389 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3391 createMenu( 111, importId, -1 );
3392 createMenu( 112, importId, -1 );
3393 createMenu( 113, importId, -1 );
3395 createMenu( 121, exportId, -1 );
3396 createMenu( 122, exportId, -1 );
3397 createMenu( 123, exportId, -1 );
3398 createMenu( 140, exportId, -1 ); // export to stl STL
3400 createMenu( separator(), fileId, 10 );
3402 createMenu( 33, editId, -1 );
3404 createMenu( 5105, toolsId, -1 );
3406 createMenu( 702, meshId, -1 ); // "Mesh" menu
3407 createMenu( 703, meshId, -1 );
3408 createMenu( 704, meshId, -1 );
3409 createMenu( 710, meshId, -1 );
3410 createMenu( 705, meshId, -1 );
3411 createMenu( separator(), meshId, -1 );
3412 createMenu( 701, meshId, -1 );
3413 createMenu( 711, meshId, -1 );
3414 createMenu( 712, meshId, -1 );
3415 createMenu( 713, meshId, -1 );
3416 createMenu( separator(), meshId, -1 );
3417 createMenu( 801, meshId, -1 );
3418 createMenu( 806, meshId, -1 );
3419 createMenu( 802, meshId, -1 );
3420 createMenu( 803, meshId, -1 );
3421 createMenu( 815, meshId, -1 );
3422 createMenu( separator(), meshId, -1 );
3423 createMenu( 810, meshId, -1 );
3424 createMenu( 811, meshId, -1 );
3425 createMenu( 812, meshId, -1 );
3426 createMenu( separator(), meshId, -1 );
3427 createMenu( 814, meshId, -1 );
3428 createMenu( separator(), meshId, -1 );
3429 createMenu( 900, meshId, -1 );
3430 //createMenu( 902, meshId, -1 );
3431 createMenu( 903, meshId, -1 );
3432 createMenu( 904, meshId, -1 );
3433 createMenu( separator(), meshId, -1 );
3435 createMenu( 6005, nodeId, -1 );
3436 createMenu( 6002, edgeId, -1 );
3437 createMenu( 6003, edgeId, -1 );
3438 createMenu( 6001, edgeId, -1 );
3439 createMenu( 6004, edgeId, -1 );
3440 createMenu( 6021, faceId, -1 );
3441 createMenu( 6025, faceId, -1 );
3442 createMenu( 6027, faceId, -1 );
3443 createMenu( 6018, faceId, -1 );
3444 createMenu( 6019, faceId, -1 );
3445 createMenu( 6011, faceId, -1 );
3446 createMenu( 6012, faceId, -1 );
3447 createMenu( 6013, faceId, -1 );
3448 createMenu( 6014, faceId, -1 );
3449 createMenu( 6015, faceId, -1 );
3450 createMenu( 6016, faceId, -1 );
3451 createMenu( 6022, faceId, -1 );
3452 createMenu( 6017, volumeId, -1 );
3453 createMenu( 6009, volumeId, -1 );
3454 createMenu( 6023, volumeId, -1 );
3455 createMenu( 6024, volumeId, -1 );
3456 createMenu( 6026, volumeId, -1 );
3458 createMenu( 4000, addId, -1 );
3459 createMenu( 4009, addId, -1 );
3460 createMenu( 4010, addId, -1 );
3461 createMenu( 4021, addId, -1 );
3462 createMenu( 4022, addId, -1 );
3463 createMenu( 4023, addId, -1 );
3464 createMenu( 4031, addId, -1 );
3465 createMenu( 4032, addId, -1 );
3466 createMenu( 4033, addId, -1 );
3467 createMenu( separator(), addId, -1 );
3468 createMenu( 4034, addId, -1 );
3469 createMenu( 4035, addId, -1 );
3470 createMenu( 4036, addId, -1 );
3471 createMenu( 4037, addId, -1 );
3472 createMenu( 4038, addId, -1 );
3473 createMenu( 4039, addId, -1 );
3474 createMenu( 4040, addId, -1 );
3476 createMenu( 4041, removeId, -1 );
3477 createMenu( 4042, removeId, -1 );
3478 createMenu( 4044, removeId, -1 );
3479 createMenu( separator(), removeId, -1 );
3480 createMenu( 813, removeId, -1 );
3481 createMenu( separator(), removeId, -1 );
3482 createMenu( 4043, removeId, -1 );
3484 createMenu( 4051, renumId, -1 );
3485 createMenu( 4052, renumId, -1 );
3487 createMenu( 4061, transfId, -1 );
3488 createMenu( 4062, transfId, -1 );
3489 createMenu( 4063, transfId, -1 );
3490 createMenu( 4064, transfId, -1 );
3491 createMenu( 4065, transfId, -1 );
3492 createMenu( 4066, transfId, -1 );
3493 createMenu( 4068, transfId, -1 );
3494 createMenu( 4069, transfId, -1 );
3496 createMenu( 4067,modifyId, -1 );
3497 createMenu( 407, modifyId, -1 );
3498 createMenu( 408, modifyId, -1 );
3499 createMenu( 409, modifyId, -1 );
3500 createMenu( 410, modifyId, -1 );
3501 createMenu( 411, modifyId, -1 );
3502 createMenu( 419, modifyId, -1 );
3503 createMenu( 412, modifyId, -1 );
3504 createMenu( 413, modifyId, -1 );
3505 createMenu( 416, modifyId, -1 );
3506 createMenu( 414, modifyId, -1 );
3507 createMenu( 415, modifyId, -1 );
3508 createMenu( 417, modifyId, -1 );
3509 createMenu( 418, modifyId, -1 );
3511 createMenu( 501, measureId, -1 );
3512 createMenu( 502, measureId, -1 );
3513 createMenu( 214, viewId, -1 );
3515 // ----- create toolbars --------------
3516 int meshTb = createTool( tr( "TB_MESH" ) ),
3517 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3518 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3519 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3520 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3522 createTool( 702, meshTb );
3523 createTool( 703, meshTb );
3524 createTool( 704, meshTb );
3525 createTool( 710, meshTb );
3526 createTool( 705, meshTb );
3527 createTool( separator(), meshTb );
3528 createTool( 701, meshTb );
3529 createTool( 711, meshTb );
3530 createTool( 712, meshTb );
3531 createTool( 713, meshTb );
3532 createTool( separator(), meshTb );
3533 createTool( 801, meshTb );
3534 createTool( 806, meshTb );
3535 createTool( 802, meshTb );
3536 createTool( 803, meshTb );
3537 //createTool( 815, meshTb );
3538 createTool( separator(), meshTb );
3539 createTool( 900, meshTb );
3540 //createTool( 902, meshTb );
3541 createTool( 903, meshTb );
3542 createTool( 904, meshTb );
3543 createTool( separator(), meshTb );
3545 createTool( 6005, ctrlTb );
3546 createTool( separator(), ctrlTb );
3547 createTool( 6002, ctrlTb );
3548 createTool( 6003, ctrlTb );
3549 createTool( 6001, ctrlTb );
3550 createTool( 6004, ctrlTb );
3551 createTool( separator(), ctrlTb );
3552 createTool( 6021, ctrlTb );
3553 createTool( 6025, ctrlTb );
3554 createTool( 6027, ctrlTb );
3555 createTool( 6018, ctrlTb );
3556 createTool( 6019, ctrlTb );
3557 createTool( 6011, ctrlTb );
3558 createTool( 6012, ctrlTb );
3559 createTool( 6013, ctrlTb );
3560 createTool( 6014, ctrlTb );
3561 createTool( 6015, ctrlTb );
3562 createTool( 6016, ctrlTb );
3563 createTool( 6022, ctrlTb );
3564 createTool( separator(), ctrlTb );
3565 createTool( 6017, ctrlTb );
3566 createTool( 6009, ctrlTb );
3567 createTool( 6023, ctrlTb );
3568 createTool( 6024, ctrlTb );
3569 createTool( 6026, ctrlTb );
3570 createTool( separator(), ctrlTb );
3572 createTool( 4000, addRemTb );
3573 createTool( 4009, addRemTb );
3574 createTool( 4010, addRemTb );
3575 createTool( 4021, addRemTb );
3576 createTool( 4022, addRemTb );
3577 createTool( 4023, addRemTb );
3578 createTool( 4031, addRemTb );
3579 createTool( 4032, addRemTb );
3580 createTool( 4033, addRemTb );
3581 createTool( separator(), addRemTb );
3582 createTool( 4034, addRemTb );
3583 createTool( 4035, addRemTb );
3584 createTool( 4036, addRemTb );
3585 createTool( 4037, addRemTb );
3586 createTool( 4038, addRemTb );
3587 createTool( 4039, addRemTb );
3588 createTool( 4040, addRemTb );
3589 createTool( separator(), addRemTb );
3590 createTool( 4041, addRemTb );
3591 createTool( 4042, addRemTb );
3592 createTool( 4044, addRemTb );
3593 createTool( 4043, addRemTb );
3594 createTool( separator(), addRemTb );
3595 createTool( 4051, addRemTb );
3596 createTool( 4052, addRemTb );
3597 createTool( separator(), addRemTb );
3598 createTool( 4061, addRemTb );
3599 createTool( 4062, addRemTb );
3600 createTool( 4063, addRemTb );
3601 createTool( 4064, addRemTb );
3602 createTool( 4065, addRemTb );
3603 createTool( 4066, addRemTb );
3604 createTool( 4068, addRemTb );
3605 createTool( 4069, addRemTb );
3606 createTool( separator(), addRemTb );
3608 createTool( 4067,modifyTb );
3609 createTool( 407, modifyTb );
3610 createTool( 408, modifyTb );
3611 createTool( 409, modifyTb );
3612 createTool( 410, modifyTb );
3613 createTool( 411, modifyTb );
3614 createTool( 419, modifyTb );
3615 createTool( 412, modifyTb );
3616 createTool( 413, modifyTb );
3617 createTool( 416, modifyTb );
3618 createTool( 414, modifyTb );
3619 createTool( 415, modifyTb );
3620 createTool( 417, modifyTb );
3621 createTool( 418, modifyTb );
3623 createTool( 214, dispModeTb );
3625 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3626 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3629 QString OB = "'ObjectBrowser'",
3630 View = "'" + SVTK_Viewer::Type() + "'",
3632 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3633 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3634 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3635 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3636 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3637 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3638 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3639 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3640 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3641 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3642 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3644 mesh_group = mesh + " " + subMesh + " " + group,
3645 hyp_alg = hypo + " " + algo;
3647 // popup for object browser
3649 isInvisible("not( isVisible )"),
3650 isEmpty("numberOfNodes = 0"),
3651 isNotEmpty("numberOfNodes <> 0"),
3653 // has nodes, edges, etc in VISIBLE! actor
3654 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3655 hasElems("(count( elemTypes ) > 0)"),
3656 hasDifferentElems("(count( elemTypes ) > 1)"),
3657 hasElems0d("({'Elem0d'} in elemTypes)"),
3658 hasEdges("({'Edge'} in elemTypes)"),
3659 hasFaces("({'Face'} in elemTypes)"),
3660 hasVolumes("({'Volume'} in elemTypes)");
3662 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3663 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3664 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3665 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3666 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3667 createPopupItem( 803, OB, group ); // EDIT_GROUP
3668 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3670 popupMgr()->insert( separator(), -1, 0 );
3671 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3672 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3673 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3674 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3675 createPopupItem( 214, OB, mesh_group ); // UPDATE
3676 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3677 //createPopupItem( 902, OB, mesh ); // STD_INFO
3678 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3679 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3680 popupMgr()->insert( separator(), -1, 0 );
3681 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3682 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3683 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3684 popupMgr()->insert( separator(), -1, 0 );
3685 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3686 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3687 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3688 popupMgr()->insert( separator(), -1, 0 );
3689 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3690 popupMgr()->insert( separator(), -1, 0 );
3691 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3692 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3693 popupMgr()->insert( separator(), -1, 0 );
3695 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3696 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3698 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3699 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3700 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3701 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3702 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3703 popupMgr()->insert( separator(), -1, 0 );
3706 createPopupItem( 803, View, group ); // EDIT_GROUP
3707 createPopupItem( 804, View, elems ); // ADD
3708 createPopupItem( 805, View, elems ); // REMOVE
3710 popupMgr()->insert( separator(), -1, 0 );
3711 createPopupItem( 214, View, mesh_group ); // UPDATE
3712 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3713 //createPopupItem( 902, View, mesh ); // STD_INFO
3714 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3715 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3716 popupMgr()->insert( separator(), -1, 0 );
3718 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3719 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3720 popupMgr()->insert( separator(), -1, 0 );
3723 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3724 QString aType = QString( "%1type in {%2}" ).arg( lc );
3725 aType = aType.arg( mesh_group );
3726 QString aMeshInVTK = aClient + "&&" + aType;
3728 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3729 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3730 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3732 //-------------------------------------------------
3734 //-------------------------------------------------
3735 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3737 popupMgr()->insert( action( 9010 ), anId, -1 );
3738 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3739 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3741 popupMgr()->insert( action( 9011 ), anId, -1 );
3742 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3743 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3745 popupMgr()->insert( separator(), -1, -1 );
3747 //-------------------------------------------------
3749 //-------------------------------------------------
3750 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3752 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3753 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3754 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3756 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3757 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3758 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3760 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3761 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3762 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3764 popupMgr()->insert( separator(), anId, -1 );
3766 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3767 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3768 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3770 //-------------------------------------------------
3772 //-------------------------------------------------
3773 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3775 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3777 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3778 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3779 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3781 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3782 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3783 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3785 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3786 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3787 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3789 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3790 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3791 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3793 popupMgr()->insert( separator(), anId, -1 );
3795 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3796 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3799 //-------------------------------------------------
3800 // Representation of the 2D Quadratic elements
3801 //-------------------------------------------------
3802 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3803 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3804 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3805 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3807 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3808 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3809 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3811 //-------------------------------------------------
3812 // Orientation of faces
3813 //-------------------------------------------------
3814 popupMgr()->insert( action( 221 ), -1, -1 );
3815 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3816 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3818 //-------------------------------------------------
3820 //-------------------------------------------------
3821 popupMgr()->insert( action( 1132 ), -1, -1 );
3822 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3824 //-------------------------------------------------
3826 //-------------------------------------------------
3827 popupMgr()->insert( action( 1133 ), -1, -1 );
3828 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3830 //-------------------------------------------------
3832 //-------------------------------------------------
3834 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3835 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3836 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3837 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3839 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3841 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3842 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3844 popupMgr()->insert( separator(), anId, -1 );
3846 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3848 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3849 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3850 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3852 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3854 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3855 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3856 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3858 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3859 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3860 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3862 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3863 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3864 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3866 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3867 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3868 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3870 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3872 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3873 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3874 QtxPopupMgr::VisibleRule );
3875 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3877 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3878 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3879 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3881 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3882 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3883 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3885 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3886 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3887 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3889 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3890 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3891 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3893 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3894 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3895 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3897 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3898 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3899 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3901 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3902 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3903 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3905 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3906 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3907 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3909 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3910 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3911 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3913 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3914 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3915 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3917 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
3918 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3919 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
3921 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3923 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3924 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3925 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3927 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3928 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3929 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3931 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3932 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3933 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3935 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
3936 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3937 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
3939 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
3940 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3941 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
3943 popupMgr()->insert( separator(), anId, -1 );
3945 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3946 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3948 popupMgr()->insert( separator(), anId, -1 );
3950 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3951 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3953 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3954 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3955 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3958 popupMgr()->insert( separator(), -1, -1 );
3960 //-------------------------------------------------
3962 //-------------------------------------------------
3963 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3964 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3965 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3966 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3968 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3969 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3971 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3972 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3974 popupMgr()->insert( separator(), -1, -1 );
3976 //-------------------------------------------------
3978 //-------------------------------------------------
3979 popupMgr()->insert( action( 1134 ), -1, -1 );
3980 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3982 popupMgr()->insert( separator(), -1, -1 );
3984 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3985 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3987 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3988 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3991 //================================================================================
3993 * \brief Return true if SMESH or GEOM objects are selected.
3994 * Is called form LightApp_Module::activateModule() which clear selection if
3995 * not isSelectionCompatible()
3997 //================================================================================
3999 bool SMESHGUI::isSelectionCompatible()
4001 bool isCompatible = true;
4002 SALOME_ListIO selected;
4003 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4004 Sel->selectedObjects( selected );
4006 SALOME_ListIteratorOfListIO It( selected );
4007 for ( ; isCompatible && It.More(); It.Next())
4009 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4010 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4012 return isCompatible;
4016 bool SMESHGUI::reusableOperation( const int id )
4018 // compute, evaluate and precompute are not reusable operations
4019 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4022 bool SMESHGUI::activateModule( SUIT_Study* study )
4024 bool res = SalomeApp_Module::activateModule( study );
4026 setMenuShown( true );
4027 setToolShown( true );
4029 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4030 PyGILState_STATE gstate = PyGILState_Ensure();
4031 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4032 if(pluginsmanager==NULL)
4036 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4041 PyGILState_Release(gstate);
4042 // end of GEOM plugins loading
4044 // Reset actions accelerator keys
4045 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4046 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4047 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4049 action( 33)->setEnabled(true); // Delete: Key_Delete
4050 action(1101)->setEnabled(true); // Rename: Key_F2
4052 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4053 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4054 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4055 if ( _PTR(Study) aStudy = s->studyDS()) {
4056 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4057 updateObjBrowser(); // objects can be removed
4063 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4065 setMenuShown( false );
4066 setToolShown( false );
4068 EmitSignalCloseAllDialogs();
4070 // Unset actions accelerator keys
4071 action(111)->setShortcut(QKeySequence()); // Import DAT
4072 action(112)->setShortcut(QKeySequence()); // Import UNV
4073 action(113)->setShortcut(QKeySequence()); // Import MED
4075 action( 33)->setEnabled(false); // Delete: Key_Delete
4076 action(1101)->setEnabled(false); // Rename: Key_F2
4078 return SalomeApp_Module::deactivateModule( study );
4081 void SMESHGUI::studyClosed( SUIT_Study* s )
4083 SMESH::RemoveVisuData( s->id() );
4084 SalomeApp_Module::studyClosed( s );
4087 void SMESHGUI::OnGUIEvent()
4089 const QObject* obj = sender();
4090 if ( !obj || !obj->inherits( "QAction" ) )
4092 int id = actionId((QAction*)obj);
4097 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4099 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4100 if ( CORBA::is_nil( myComponentSMESH ) )
4102 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4104 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4105 return aGUI.myComponentSMESH;
4108 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4109 return myComponentSMESH;
4112 QString SMESHGUI::engineIOR() const
4114 CORBA::ORB_var anORB = getApp()->orb();
4115 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4116 return QString( anIOR.in() );
4119 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4121 SalomeApp_Module::contextMenuPopup( client, menu, title );
4123 selectionMgr()->selectedObjects( lst );
4124 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4125 Handle(SALOME_InteractiveObject) io = lst.First();
4126 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4127 _PTR(Study) study = appStudy->studyDS();
4128 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4130 QString aName = QString( obj->GetName().c_str() );
4131 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4132 aName.remove( (aName.length() - 1), 1 );
4138 LightApp_Selection* SMESHGUI::createSelection() const
4140 return new SMESHGUI_Selection();
4143 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4145 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4146 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4149 void SMESHGUI::viewManagers( QStringList& list ) const
4151 list.append( SVTK_Viewer::Type() );
4154 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4156 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4157 SMESH::UpdateSelectionProp( this );
4160 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4162 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4163 myClippingPlaneInfoMap.erase( theViewManager );
4166 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4168 theActor->AddObserver( SMESH::DeleteActorEvent,
4169 myEventCallbackCommand.GetPointer(),
4173 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4174 unsigned long theEvent,
4175 void* theClientData,
4178 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4179 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4180 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4181 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4182 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4183 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4184 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4185 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4186 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4187 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4188 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4189 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4190 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4191 if( anActor == *anIter3 ) {
4192 anActorList.erase( anIter3 );
4203 void SMESHGUI::createPreferences()
4205 // General tab ------------------------------------------------------------------------
4206 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4208 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4209 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4210 setPreferenceProperty( lim, "min", 0 );
4211 setPreferenceProperty( lim, "max", 100000000 );
4212 setPreferenceProperty( lim, "step", 1000 );
4213 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4215 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4216 setPreferenceProperty( qaGroup, "columns", 2 );
4217 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4218 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4219 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4220 setPreferenceProperty( prec, "min", 0 );
4221 setPreferenceProperty( prec, "max", 16 );
4223 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4224 setPreferenceProperty( dispgroup, "columns", 2 );
4225 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4227 modes.append( "Wireframe" );
4228 modes.append( "Shading" );
4229 modes.append( "Nodes" );
4230 modes.append( "Shrink" );
4231 QList<QVariant> indices;
4232 indices.append( 0 );
4233 indices.append( 1 );
4234 indices.append( 2 );
4235 indices.append( 3 );
4236 setPreferenceProperty( dispmode, "strings", modes );
4237 setPreferenceProperty( dispmode, "indexes", indices );
4239 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4240 setPreferenceProperty( arcgroup, "columns", 2 );
4241 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4242 QStringList quadraticModes;
4243 quadraticModes.append("Lines");
4244 quadraticModes.append("Arcs");
4246 indices.append( 0 );
4247 indices.append( 1 );
4248 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4249 setPreferenceProperty( quadraticmode, "indexes", indices );
4251 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4252 "SMESH", "max_angle" );
4253 setPreferenceProperty( maxAngle, "min", 1 );
4254 setPreferenceProperty( maxAngle, "max", 90 );
4258 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4259 setPreferenceProperty( exportgroup, "columns", 2 );
4260 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4261 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4263 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4264 setPreferenceProperty( computeGroup, "columns", 2 );
4265 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4267 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4268 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4269 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4271 indices.append( 0 );
4272 indices.append( 1 );
4273 indices.append( 2 );
4274 setPreferenceProperty( notifyMode, "strings", modes );
4275 setPreferenceProperty( notifyMode, "indexes", indices );
4277 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4278 setPreferenceProperty( computeGroup, "columns", 2 );
4279 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4281 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4282 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4284 indices.append( 0 );
4285 indices.append( 1 );
4286 setPreferenceProperty( elemInfo, "strings", modes );
4287 setPreferenceProperty( elemInfo, "indexes", indices );
4289 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4290 setPreferenceProperty( segGroup, "columns", 2 );
4291 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4292 "SMESH", "segmentation" );
4293 setPreferenceProperty( segLen, "min", 1 );
4294 setPreferenceProperty( segLen, "max", 10000000 );
4295 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4296 "SMESH", "nb_segments_per_edge" );
4297 setPreferenceProperty( nbSeg, "min", 1 );
4298 setPreferenceProperty( nbSeg, "max", 10000000 );
4300 // Quantities with individual precision settings
4301 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4302 setPreferenceProperty( precGroup, "columns", 2 );
4304 const int nbQuantities = 6;
4305 int precs[nbQuantities], ii = 0;
4306 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4307 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4308 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4309 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4310 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4311 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4312 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4313 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4314 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4315 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4316 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4317 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4319 // Set property for precision value for spinboxes
4320 for ( ii = 0; ii < nbQuantities; ii++ ){
4321 setPreferenceProperty( precs[ii], "min", -14 );
4322 setPreferenceProperty( precs[ii], "max", 14 );
4323 setPreferenceProperty( precs[ii], "precision", 2 );
4326 // Mesh tab ------------------------------------------------------------------------
4327 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4328 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4329 setPreferenceProperty( nodeGroup, "columns", 3 );
4331 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4333 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4335 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4336 QList<QVariant> aMarkerTypeIndicesList;
4337 QList<QVariant> aMarkerTypeIconsList;
4338 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4339 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4340 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4341 aMarkerTypeIndicesList << i;
4342 aMarkerTypeIconsList << pixmap;
4344 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4345 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4347 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4349 QList<QVariant> aMarkerScaleIndicesList;
4350 QStringList aMarkerScaleValuesList;
4351 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4352 aMarkerScaleIndicesList << i;
4353 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4355 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4356 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4358 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4359 setPreferenceProperty( elemGroup, "columns", 2 );
4361 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4362 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4363 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4364 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4366 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4367 setPreferenceProperty( grpGroup, "columns", 2 );
4369 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4371 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4372 //setPreferenceProperty( sp, "hstretch", 0 );
4373 //setPreferenceProperty( sp, "vstretch", 0 );
4375 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4376 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4377 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4378 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4379 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4380 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4381 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4383 setPreferenceProperty( size0d, "min", 1 );
4384 setPreferenceProperty( size0d, "max", 10 );
4386 setPreferenceProperty( sp, "hstretch", 0 );
4387 setPreferenceProperty( sp, "vstretch", 0 );
4389 setPreferenceProperty( elemW, "min", 1 );
4390 setPreferenceProperty( elemW, "max", 5 );
4392 setPreferenceProperty( shrink, "min", 0 );
4393 setPreferenceProperty( shrink, "max", 100 );
4395 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4396 setPreferenceProperty( orientGroup, "columns", 1 );
4398 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4399 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4401 setPreferenceProperty( orientScale, "min", 0.05 );
4402 setPreferenceProperty( orientScale, "max", 0.5 );
4403 setPreferenceProperty( orientScale, "step", 0.05 );
4405 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4407 // Selection tab ------------------------------------------------------------------------
4408 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4410 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4411 setPreferenceProperty( selGroup, "columns", 2 );
4413 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4414 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4415 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4417 setPreferenceProperty( selW, "min", 1 );
4418 setPreferenceProperty( selW, "max", 5 );
4420 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4421 setPreferenceProperty( preGroup, "columns", 2 );
4423 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4424 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4426 setPreferenceProperty( preW, "min", 1 );
4427 setPreferenceProperty( preW, "max", 5 );
4429 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4430 setPreferenceProperty( precSelGroup, "columns", 2 );
4432 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4433 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4434 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4436 // Scalar Bar tab ------------------------------------------------------------------------
4437 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4438 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4439 setPreferenceProperty( fontGr, "columns", 2 );
4441 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4442 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4444 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4445 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4447 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4448 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4450 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4451 setPreferenceProperty( numcol, "min", 2 );
4452 setPreferenceProperty( numcol, "max", 256 );
4454 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4455 setPreferenceProperty( numlab, "min", 2 );
4456 setPreferenceProperty( numlab, "max", 65 );
4458 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4459 setPreferenceProperty( orientGr, "columns", 2 );
4460 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4461 QStringList orients;
4462 orients.append( tr( "SMESH_VERTICAL" ) );
4463 orients.append( tr( "SMESH_HORIZONTAL" ) );
4464 indices.clear(); indices.append( 0 ); indices.append( 1 );
4465 setPreferenceProperty( orient, "strings", orients );
4466 setPreferenceProperty( orient, "indexes", indices );
4468 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4469 setPreferenceProperty( posVSizeGr, "columns", 2 );
4470 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4471 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4472 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4473 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4474 setPreferenceProperty( xv, "step", 0.1 );
4475 setPreferenceProperty( xv, "min", 0.0 );
4476 setPreferenceProperty( xv, "max", 1.0 );
4477 setPreferenceProperty( yv, "step", 0.1 );
4478 setPreferenceProperty( yv, "min", 0.0 );
4479 setPreferenceProperty( yv, "max", 1.0 );
4480 setPreferenceProperty( wv, "step", 0.1 );
4481 setPreferenceProperty( wv, "min", 0.0 );
4482 setPreferenceProperty( wv, "max", 1.0 );
4483 setPreferenceProperty( hv, "min", 0.0 );
4484 setPreferenceProperty( hv, "max", 1.0 );
4485 setPreferenceProperty( hv, "step", 0.1 );
4487 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4488 setPreferenceProperty( posHSizeGr, "columns", 2 );
4489 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4490 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4491 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4492 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4493 setPreferenceProperty( xv, "min", 0.0 );
4494 setPreferenceProperty( xv, "max", 1.0 );
4495 setPreferenceProperty( xv, "step", 0.1 );
4496 setPreferenceProperty( xh, "min", 0.0 );
4497 setPreferenceProperty( xh, "max", 1.0 );
4498 setPreferenceProperty( xh, "step", 0.1 );
4499 setPreferenceProperty( yh, "min", 0.0 );
4500 setPreferenceProperty( yh, "max", 1.0 );
4501 setPreferenceProperty( yh, "step", 0.1 );
4502 setPreferenceProperty( wh, "min", 0.0 );
4503 setPreferenceProperty( wh, "max", 1.0 );
4504 setPreferenceProperty( wh, "step", 0.1 );
4505 setPreferenceProperty( hh, "min", 0.0 );
4506 setPreferenceProperty( hh, "max", 1.0 );
4507 setPreferenceProperty( hh, "step", 0.1 );
4509 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4510 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4511 setPreferenceProperty( distributionGr, "columns", 3 );
4513 types.append( tr( "SMESH_MONOCOLOR" ) );
4514 types.append( tr( "SMESH_MULTICOLOR" ) );
4515 indices.clear(); indices.append( 0 ); indices.append( 1 );
4516 setPreferenceProperty( coloringType, "strings", types );
4517 setPreferenceProperty( coloringType, "indexes", indices );
4518 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4522 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4524 if( sect=="SMESH" ) {
4525 float sbX1,sbY1,sbW,sbH;
4526 float aTol = 1.00000009999999;
4527 std::string aWarning;
4528 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4529 if( name=="selection_object_color" || name=="selection_element_color" ||
4530 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4531 name=="selection_precision_node" || name=="selection_precision_element" ||
4532 name=="selection_precision_object")
4533 SMESH::UpdateSelectionProp( this );
4534 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4535 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4536 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4537 if(sbX1+sbW > aTol){
4538 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4541 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4542 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4545 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4546 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4547 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4548 if(sbY1+sbH > aTol){
4549 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4550 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4551 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4554 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4555 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4556 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4557 if(sbX1+sbW > aTol){
4558 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4561 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4562 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4565 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4566 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4567 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4568 if(sbY1+sbH > aTol){
4569 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4572 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4573 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4576 else if ( name == "segmentation" ) {
4577 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4578 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4580 else if ( name == "nb_segments_per_edge" ) {
4581 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4582 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4585 if(aWarning.size() != 0){
4586 aWarning += "The default values are applied instead.";
4587 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4588 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4589 QObject::tr(aWarning.c_str()));
4594 //================================================================================
4596 * \brief Update something in accordance with update flags
4597 * \param theFlags - update flags
4599 * Update viewer or/and object browser etc. in accordance with update flags ( see
4600 * LightApp_UpdateFlags enumeration ).
4602 //================================================================================
4603 void SMESHGUI::update( const int flags )
4605 if ( flags & UF_Viewer | flags & UF_Forced )
4606 SMESH::UpdateView();
4608 SalomeApp_Module::update( flags );
4611 //================================================================================
4613 * \brief Set default selection mode
4615 * SLOT called when operation commited. Sets default selection mode
4617 //================================================================================
4618 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4620 SVTK_ViewWindow* vtkWnd =
4621 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4623 vtkWnd->SetSelectionMode( ActorSelection );
4626 //================================================================================
4628 * \brief Set default selection mode
4630 * SLOT called when operation aborted. Sets default selection mode
4632 //================================================================================
4633 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4635 SVTK_ViewWindow* vtkWnd =
4636 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4638 vtkWnd->SetSelectionMode( ActorSelection );
4641 //================================================================================
4643 * \brief Creates operation with given identifier
4644 * \param id - identifier of operation to be started
4645 * \return Pointer on created operation or NULL if operation is not created
4647 * Virtual method redefined from the base class creates operation with given id.
4648 * It is called called automatically from startOperation method of base class.
4650 //================================================================================
4651 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4653 LightApp_Operation* op = 0;
4654 // to do : create operation here
4657 case 417: //convert to quadratic
4658 op = new SMESHGUI_ConvToQuadOp();
4660 case 418: // create 2D mesh as boundary on 3D
4661 op = new SMESHGUI_Make2DFrom3DOp();
4663 case 701: // Compute mesh
4664 op = new SMESHGUI_ComputeOp();
4666 case 702: // Create mesh
4667 op = new SMESHGUI_MeshOp( true, true );
4669 case 703: // Create sub-mesh
4670 op = new SMESHGUI_MeshOp( true, false );
4672 case 704: // Edit mesh/sub-mesh
4673 op = new SMESHGUI_MeshOp( false );
4675 case 711: // Precompute mesh
4676 op = new SMESHGUI_PrecomputeOp();
4678 case 712: // Evaluate mesh
4679 op = new SMESHGUI_EvaluateOp();
4681 case 713: // Evaluate mesh
4682 op = new SMESHGUI_MeshOrderOp();
4684 case 806: // Create group on geom
4685 op = new SMESHGUI_GroupOnShapeOp();
4687 case 904: // Find element
4688 op = new SMESHGUI_FindElemByPointOp();
4690 case 4067: // make mesh pass through point
4691 op = new SMESHGUI_MakeNodeAtPointOp();
4698 op = SalomeApp_Module::createOperation( id );
4702 //================================================================================
4704 * \brief Stops current operations and starts a given one
4705 * \param id - The id of the operation to start
4707 //================================================================================
4709 void SMESHGUI::switchToOperation(int id)
4711 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4712 activeStudy()->abortAllOperations();
4713 startOperation( id );
4716 LightApp_Displayer* SMESHGUI::displayer()
4719 myDisplayer = new SMESHGUI_Displayer( getApp() );
4723 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4726 int aTolerance = 64;
4727 int anIterations = 0;
4733 if( anIterations % aPeriod == 0 )
4736 if( aTolerance < 1 )
4740 aHue = (int)( 360.0 * rand() / RAND_MAX );
4743 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4744 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4745 for( ; it != itEnd; ++it )
4747 SALOMEDS::Color anAutoColor = *it;
4748 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4751 aQColor.getHsv( &h, &s, &v );
4752 if( abs( h - aHue ) < aTolerance )
4764 aColor.setHsv( aHue, 255, 255 );
4766 SALOMEDS::Color aSColor;
4767 aSColor.R = (double)aColor.red() / 255.0;
4768 aSColor.G = (double)aColor.green() / 255.0;
4769 aSColor.B = (double)aColor.blue() / 255.0;
4774 const char gSeparator = '_'; // character used to separate parameter names
4775 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4776 const char gPathSep = '|'; // character used to separate paths
4779 * \brief Store visual parameters
4781 * This method is called just before the study document is saved.
4782 * Store visual parameters in AttributeParameter attribue(s)
4784 void SMESHGUI::storeVisualParameters (int savePoint)
4786 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4787 if (!appStudy || !appStudy->studyDS())
4789 _PTR(Study) studyDS = appStudy->studyDS();
4791 // componentName is used for encoding of entries when storing them in IParameters
4792 std::string componentName = myComponentSMESH->ComponentDataType();
4793 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4794 //if (!aSComponent) return;
4797 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4798 componentName.c_str(),
4800 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4802 // store map of custom markers
4803 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4804 if( !aMarkerMap.empty() )
4806 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4807 for( ; anIter != aMarkerMap.end(); anIter++ )
4809 int anId = anIter->first;
4810 VTK::MarkerData aMarkerData = anIter->second;
4811 std::string aMarkerFileName = aMarkerData.first;
4812 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4813 if( aMarkerTexture.size() < 3 )
4814 continue; // should contain at least width, height and the first value
4816 QString aPropertyName( "texture" );
4817 aPropertyName += gSeparator;
4818 aPropertyName += QString::number( anId );
4820 QString aPropertyValue = aMarkerFileName.c_str();
4821 aPropertyValue += gPathSep;
4823 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4824 ushort aWidth = *aTextureIter++;
4825 ushort aHeight = *aTextureIter++;
4826 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4827 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4828 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4829 aPropertyValue += QString::number( *aTextureIter );
4831 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4835 // viewers counters are used for storing view_numbers in IParameters
4838 // main cycle to store parameters of displayed objects
4839 QList<SUIT_ViewManager*> lst;
4840 QList<SUIT_ViewManager*>::Iterator it;
4841 getApp()->viewManagers(lst);
4842 for (it = lst.begin(); it != lst.end(); it++)
4844 SUIT_ViewManager* vman = *it;
4845 QString vType = vman->getType();
4847 // saving VTK actors properties
4848 if (vType == SVTK_Viewer::Type())
4850 // store the clipping planes attached to the view manager
4851 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4852 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4853 if( anIter != myClippingPlaneInfoMap.end() )
4854 aClippingPlaneInfoList = anIter->second;
4856 if( !aClippingPlaneInfoList.empty() ) {
4857 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4858 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4860 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4861 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4863 QString aPropertyName( "ClippingPlane" );
4864 aPropertyName += gSeparator;
4865 aPropertyName += QString::number( vtkViewers );
4866 aPropertyName += gSeparator;
4867 aPropertyName += QString::number( anId );
4869 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4870 aPropertyValue += gDigitsSep;
4871 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4872 aPropertyValue += gDigitsSep;
4873 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4874 aPropertyValue += gDigitsSep;
4875 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4877 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4881 QVector<SUIT_ViewWindow*> views = vman->getViews();
4882 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4884 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4886 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4887 vtkActorCollection* allActors = aCopy.GetActors();
4888 allActors->InitTraversal();
4889 while (vtkActor* actor = allActors->GetNextActor())
4891 if (actor->GetVisibility()) // store only visible actors
4893 SMESH_Actor* aSmeshActor = 0;
4894 if (actor->IsA("SMESH_Actor"))
4895 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4896 if (aSmeshActor && aSmeshActor->hasIO())
4898 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4901 // entry is "encoded" = it does NOT contain component adress,
4902 // since it is a subject to change on next component loading
4903 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4905 std::string param, vtkParam = vType.toLatin1().data();
4906 vtkParam += gSeparator;
4907 vtkParam += QString::number(vtkViewers).toLatin1().data();
4908 vtkParam += gSeparator;
4911 param = vtkParam + "Visibility";
4912 ip->setParameter(entry, param, "On");
4915 param = vtkParam + "Representation";
4916 ip->setParameter(entry, param, QString::number
4917 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4920 param = vtkParam + "IsShrunk";
4921 ip->setParameter(entry, param, QString::number
4922 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4924 // Displayed entities
4925 unsigned int aMode = aSmeshActor->GetEntityMode();
4926 bool isE = aMode & SMESH_Actor::eEdges;
4927 bool isF = aMode & SMESH_Actor::eFaces;
4928 bool isV = aMode & SMESH_Actor::eVolumes;
4930 QString modeStr ("e");
4931 modeStr += gDigitsSep; modeStr += QString::number(isE);
4932 modeStr += gDigitsSep; modeStr += "f";
4933 modeStr += gDigitsSep; modeStr += QString::number(isF);
4934 modeStr += gDigitsSep; modeStr += "v";
4935 modeStr += gDigitsSep; modeStr += QString::number(isV);
4937 param = vtkParam + "Entities";
4938 ip->setParameter(entry, param, modeStr.toLatin1().data());
4940 // Colors (surface:edge:)
4941 vtkFloatingPointType r, g, b;
4943 aSmeshActor->GetSufaceColor(r, g, b);
4944 QString colorStr ("surface");
4945 colorStr += gDigitsSep; colorStr += QString::number(r);
4946 colorStr += gDigitsSep; colorStr += QString::number(g);
4947 colorStr += gDigitsSep; colorStr += QString::number(b);
4949 aSmeshActor->GetBackSufaceColor(r, g, b);
4950 colorStr += gDigitsSep; colorStr += "backsurface";
4951 colorStr += gDigitsSep; colorStr += QString::number(r);
4952 colorStr += gDigitsSep; colorStr += QString::number(g);
4953 colorStr += gDigitsSep; colorStr += QString::number(b);
4955 aSmeshActor->GetEdgeColor(r, g, b);
4956 colorStr += gDigitsSep; colorStr += "edge";
4957 colorStr += gDigitsSep; colorStr += QString::number(r);
4958 colorStr += gDigitsSep; colorStr += QString::number(g);
4959 colorStr += gDigitsSep; colorStr += QString::number(b);
4961 aSmeshActor->GetNodeColor(r, g, b);
4962 colorStr += gDigitsSep; colorStr += "node";
4963 colorStr += gDigitsSep; colorStr += QString::number(r);
4964 colorStr += gDigitsSep; colorStr += QString::number(g);
4965 colorStr += gDigitsSep; colorStr += QString::number(b);
4967 param = vtkParam + "Colors";
4968 ip->setParameter(entry, param, colorStr.toLatin1().data());
4970 // Sizes of lines and points
4971 QString sizeStr ("line");
4972 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4973 sizeStr += gDigitsSep; sizeStr += "shrink";
4974 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4976 param = vtkParam + "Sizes";
4977 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4982 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4983 if( aMarkerType == VTK::MT_USER ) {
4984 markerStr += "custom";
4985 markerStr += gDigitsSep;
4986 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4990 markerStr += gDigitsSep;
4991 markerStr += QString::number( (int)aMarkerType );
4992 markerStr += gDigitsSep;
4993 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4996 param = vtkParam + "PointMarker";
4997 ip->setParameter(entry, param, markerStr.toLatin1().data());
5000 param = vtkParam + "Opacity";
5001 ip->setParameter(entry, param,
5002 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5005 param = vtkParam + "ClippingPlane";
5007 if( !aClippingPlaneInfoList.empty() ) {
5008 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5009 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5011 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5012 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5013 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5014 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5015 if( aSmeshActor == *anIter2 ) {
5016 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5017 QString::number( anId ).toLatin1().constData() );
5024 ip->setParameter( entry, param, "Off" );
5025 } // if (io->hasEntry())
5026 } // SMESH_Actor && hasIO
5028 } // while.. actors traversal
5032 } // if (SVTK view model)
5033 } // for (viewManagers)
5036 // data structures for clipping planes processing
5039 vtkIdType Orientation;
5040 vtkFloatingPointType Distance;
5041 vtkFloatingPointType Angle[2];
5043 typedef std::list<TPlaneData> TPlaneDataList;
5044 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5046 typedef std::list<vtkActor*> TActorList;
5049 TActorList ActorList;
5050 SUIT_ViewManager* ViewManager;
5052 typedef std::list<TPlaneInfo> TPlaneInfoList;
5053 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5056 * \brief Restore visual parameters
5058 * This method is called after the study document is opened.
5059 * Restore visual parameters from AttributeParameter attribue(s)
5061 void SMESHGUI::restoreVisualParameters (int savePoint)
5063 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5064 if (!appStudy || !appStudy->studyDS())
5066 _PTR(Study) studyDS = appStudy->studyDS();
5068 // componentName is used for encoding of entries when storing them in IParameters
5069 std::string componentName = myComponentSMESH->ComponentDataType();
5070 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5071 //if (!aSComponent) return;
5074 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5075 componentName.c_str(),
5077 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5079 // restore map of custom markers and map of clipping planes
5080 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5081 TPlaneDataMap aPlaneDataMap;
5083 std::vector<std::string> properties = ip->getProperties();
5084 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5086 std::string property = *propIt;
5087 QString aPropertyName( property.c_str() );
5088 QString aPropertyValue( ip->getProperty( property ).c_str() );
5090 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5091 if( aPropertyNameList.isEmpty() )
5094 QString aPropertyType = aPropertyNameList[0];
5095 if( aPropertyType == "texture" )
5097 if( aPropertyNameList.size() != 2 )
5101 int anId = aPropertyNameList[1].toInt( &ok );
5102 if( !ok || anId < 1 )
5105 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5106 if( aPropertyValueList.size() != 2 )
5109 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5110 QString aMarkerTextureString = aPropertyValueList[1];
5111 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5112 if( aMarkerTextureStringList.size() != 3 )
5116 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5121 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5125 VTK::MarkerTexture aMarkerTexture;
5126 aMarkerTexture.push_back( aWidth );
5127 aMarkerTexture.push_back( aHeight );
5129 QString aMarkerTextureData = aMarkerTextureStringList[2];
5130 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5132 QChar aChar = aMarkerTextureData.at( i );
5133 if( aChar.isDigit() )
5134 aMarkerTexture.push_back( aChar.digitValue() );
5137 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5139 else if( aPropertyType == "ClippingPlane" )
5141 if( aPropertyNameList.size() != 3 )
5145 int aViewId = aPropertyNameList[1].toInt( &ok );
5146 if( !ok || aViewId < 0 )
5150 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5151 if( !ok || aClippingPlaneId < 0 )
5154 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5155 if( aPropertyValueList.size() != 4 )
5158 TPlaneData aPlaneData;
5159 aPlaneData.Id = aClippingPlaneId;
5162 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5167 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5172 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5177 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5181 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5182 aPlaneDataList.push_back( aPlaneData );
5186 TPlaneInfoMap aPlaneInfoMap;
5188 std::vector<std::string> entries = ip->getEntries();
5190 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5192 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5193 QString entry (ip->decodeEntry(*entIt).c_str());
5195 // Check that the entry corresponds to a real object in the Study
5196 // as the object may be deleted or modified after the visual state is saved.
5197 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5198 if (!so) continue; //Skip the not existent entry
5200 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5201 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5203 std::vector<std::string>::iterator namesIt = paramNames.begin();
5204 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5206 // actors are stored in a map after displaying of them for
5207 // quicker access in the future: map < viewID to actor >
5208 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5210 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5212 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5213 // '_' is used as separator and should not be used in viewer type or parameter names.
5214 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5215 if (lst.size() != 3)
5218 QString viewerTypStr = lst[0];
5219 QString viewIndexStr = lst[1];
5220 QString paramNameStr = lst[2];
5223 int viewIndex = viewIndexStr.toUInt(&ok);
5224 if (!ok) // bad conversion of view index to integer
5228 if (viewerTypStr == SVTK_Viewer::Type())
5230 SMESH_Actor* aSmeshActor = 0;
5231 if (vtkActors.IsBound(viewIndex))
5232 aSmeshActor = vtkActors.Find(viewIndex);
5234 QList<SUIT_ViewManager*> lst;
5235 getApp()->viewManagers(viewerTypStr, lst);
5237 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5238 SUIT_ViewManager* vman = NULL;
5239 if (viewIndex >= 0 && viewIndex < lst.count())
5240 vman = lst.at(viewIndex);
5242 if (paramNameStr == "Visibility")
5244 if (!aSmeshActor && displayer() && vman)
5246 SUIT_ViewModel* vmodel = vman->getViewModel();
5247 // SVTK view model can be casted to SALOME_View
5248 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5250 // store displayed actor in a temporary map for quicker
5251 // access later when restoring other parameters
5252 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5253 vtkRenderer* Renderer = vtkView->getRenderer();
5254 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5255 vtkActorCollection* theActors = aCopy.GetActors();
5256 theActors->InitTraversal();
5257 bool isFound = false;
5258 vtkActor *ac = theActors->GetNextActor();
5259 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5260 if (ac->IsA("SMESH_Actor")) {
5261 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5262 if (aGeomAc->hasIO()) {
5263 Handle(SALOME_InteractiveObject) io =
5264 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5265 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5267 vtkActors.Bind(viewIndex, aGeomAc);
5273 } // if (paramNameStr == "Visibility")
5276 // the rest properties "work" with SMESH_Actor
5279 QString val ((*valuesIt).c_str());
5282 if (paramNameStr == "Representation") {
5283 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5286 else if (paramNameStr == "IsShrunk") {
5288 if (!aSmeshActor->IsShrunk())
5289 aSmeshActor->SetShrink();
5292 if (aSmeshActor->IsShrunk())
5293 aSmeshActor->UnShrink();
5296 // Displayed entities
5297 else if (paramNameStr == "Entities") {
5298 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5299 if (mode.count() == 6) {
5300 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5301 MESSAGE("Invalid order of data in Entities, must be: "
5302 "e:0/1:f:0/1:v:0/1");
5305 unsigned int aMode = aSmeshActor->GetEntityMode();
5306 unsigned int aNewMode =
5307 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5308 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5309 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5310 if (aNewMode != aMode)
5311 aSmeshActor->SetEntityMode(aNewMode);
5316 else if (paramNameStr == "Colors") {
5317 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5318 if (colors.count() == 16) {
5319 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5320 colors[8] != "edge" || colors[12] != "node") {
5321 MESSAGE("Invalid order of data in Colors, must be: "
5322 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5325 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5326 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5327 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5328 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5332 // Sizes of lines and points
5333 else if (paramNameStr == "Sizes") {
5334 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5335 if (sizes.count() == 4) {
5336 if (sizes[0] != "line" || sizes[2] != "shrink") {
5337 MESSAGE("Invalid order of data in Sizes, must be: "
5338 "line:int:shrink:float");
5341 aSmeshActor->SetLineWidth(sizes[1].toInt());
5342 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5345 else if (sizes.count() == 6) { // just to support old format
5346 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5347 MESSAGE("Invalid order of data in Sizes, must be: "
5348 "line:int:node:int:shrink:float");
5351 aSmeshActor->SetLineWidth(sizes[1].toInt());
5352 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5353 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5358 else if (paramNameStr == "PointMarker") {
5359 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5360 if( data.count() >= 2 ) {
5362 int aParam1 = data[1].toInt( &ok );
5364 if( data[0] == "std" && data.count() == 3 ) {
5365 int aParam2 = data[2].toInt( &ok );
5366 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5368 else if( data[0] == "custom" ) {
5369 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5370 if( markerIt != aMarkerMap.end() ) {
5371 VTK::MarkerData aMarkerData = markerIt->second;
5372 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5379 else if (paramNameStr == "Opacity") {
5380 aSmeshActor->SetOpacity(val.toFloat());
5383 else if (paramNameStr.startsWith("ClippingPlane")) {
5384 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5385 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5386 // new format - val looks like "Off" or "0" (plane id)
5387 // (note: in new format "Off" value is used only for consistency,
5388 // so it is processed together with values in old format)
5389 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5390 if( anIsOldFormat ) {
5391 if (paramNameStr == "ClippingPlane1" || val == "Off")
5392 aSmeshActor->RemoveAllClippingPlanes();
5394 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5395 double aDistance = vals[1].toFloat();
5396 vtkFloatingPointType anAngle[2];
5397 anAngle[0] = vals[2].toFloat();
5398 anAngle[1] = vals[3].toFloat();
5400 QList<SUIT_ViewManager*> lst;
5401 getApp()->viewManagers(viewerTypStr, lst);
5402 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5403 if (viewIndex >= 0 && viewIndex < lst.count()) {
5404 SUIT_ViewManager* vman = lst.at(viewIndex);
5405 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5407 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5409 SMESH::TActorList anActorList;
5410 anActorList.push_back( aSmeshActor );
5411 SMESH::OrientedPlane* aPlane =
5412 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5414 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5415 aClippingPlaneInfo.Plane = aPlane;
5416 aClippingPlaneInfo.ActorList = anActorList;
5417 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5424 int aPlaneId = val.toInt( &ok );
5425 if( ok && aPlaneId >= 0 ) {
5426 bool anIsDefinedPlane = false;
5427 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5428 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5429 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5430 TPlaneInfo& aPlaneInfo = *anIter;
5431 if( aPlaneInfo.PlaneId == aPlaneId ) {
5432 aPlaneInfo.ActorList.push_back( aSmeshActor );
5433 anIsDefinedPlane = true;
5437 if( !anIsDefinedPlane ) {
5438 TPlaneInfo aPlaneInfo;
5439 aPlaneInfo.PlaneId = aPlaneId;
5440 aPlaneInfo.ActorList.push_back( aSmeshActor );
5441 aPlaneInfo.ViewManager = vman;
5443 // to make the list sorted by plane id
5444 anIter = aPlaneInfoList.begin();
5445 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5446 const TPlaneInfo& aPlaneInfoRef = *anIter;
5447 if( aPlaneInfoRef.PlaneId > aPlaneId )
5450 aPlaneInfoList.insert( anIter, aPlaneInfo );
5455 } // if (aSmeshActor)
5456 } // other parameters than Visibility
5458 } // for names/parameters iterator
5459 } // for entries iterator
5461 // take into account planes with empty list of actors referred to them
5462 QList<SUIT_ViewManager*> aVMList;
5463 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5465 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5466 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5467 int aViewId = aPlaneDataIter->first;
5468 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5469 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5471 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5473 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5474 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5475 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5476 const TPlaneData& aPlaneData = *anIter2;
5477 int aPlaneId = aPlaneData.Id;
5479 bool anIsFound = false;
5480 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5481 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5482 const TPlaneInfo& aPlaneInfo = *anIter3;
5483 if( aPlaneInfo.PlaneId == aPlaneId ) {
5490 TPlaneInfo aPlaneInfo; // ActorList field is empty
5491 aPlaneInfo.PlaneId = aPlaneId;
5492 aPlaneInfo.ViewManager = aViewManager;
5494 // to make the list sorted by plane id
5495 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5496 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5497 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5498 if( aPlaneInfoRef.PlaneId > aPlaneId )
5501 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5507 // add clipping planes to actors according to the restored parameters
5508 // and update the clipping plane map
5509 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5510 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5511 int aViewId = anIter1->first;
5512 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5514 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5515 if( anIter2 == aPlaneDataMap.end() )
5517 const TPlaneDataList& aPlaneDataList = anIter2->second;
5519 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5520 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5521 const TPlaneInfo& aPlaneInfo = *anIter3;
5522 int aPlaneId = aPlaneInfo.PlaneId;
5523 const TActorList& anActorList = aPlaneInfo.ActorList;
5524 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5528 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5532 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5534 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5535 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5536 const TPlaneData& aPlaneData = *anIter4;
5537 if( aPlaneData.Id == aPlaneId ) {
5538 SMESH::OrientedPlane* aPlane =
5539 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5541 (SMESH::Orientation)aPlaneData.Orientation,
5542 aPlaneData.Distance,
5545 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5546 aClippingPlaneInfo.Plane = aPlane;
5547 aClippingPlaneInfo.ActorList = anActorList;
5548 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5556 // update all VTK views
5557 QList<SUIT_ViewManager*> lst;
5558 getApp()->viewManagers(lst);
5559 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5560 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5561 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5562 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5563 vtkView->getRenderer()->ResetCameraClippingRange();
5570 \brief Adds preferences for dfont of VTK viewer
5572 \param pIf group identifier
5573 \param param parameter
5574 \return identifier of preferences
5576 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5578 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5580 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5583 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5584 fam.append( tr( "SMESH_FONT_COURIER" ) );
5585 fam.append( tr( "SMESH_FONT_TIMES" ) );
5587 setPreferenceProperty( tfont, "fonts", fam );
5589 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5590 setPreferenceProperty( tfont, "features", f );
5596 \brief Actions after hypothesis edition
5597 Updates object browser after hypothesis edition
5599 void SMESHGUI::onHypothesisEdit( int result )
5602 SMESHGUI::Modified();
5603 updateObjBrowser( true );