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);
1475 // 0019923: EDF 765 SMESH : default values of hypothesis
1476 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1477 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1478 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1479 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1480 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1483 myActiveDialogBox = 0;
1484 myFilterLibraryDlg = 0;
1488 myEventCallbackCommand = vtkCallbackCommand::New();
1489 myEventCallbackCommand->Delete();
1490 myEventCallbackCommand->SetClientData( this );
1491 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1494 SMESH::GetFilterManager();
1495 SMESH::GetPattern();
1496 SMESH::GetMeasurements();
1498 /* load resources for all available meshers */
1499 SMESH::InitAvailableHypotheses();
1502 //=============================================================================
1506 //=============================================================================
1507 SMESHGUI::~SMESHGUI()
1509 #ifdef WITHGENERICOBJ
1510 SMESH::GetFilterManager()->Destroy();
1511 SMESH::GetMeasurements()->Destroy();
1513 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1514 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1517 //=============================================================================
1521 //=============================================================================
1522 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1524 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1526 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1531 //=============================================================================
1535 //=============================================================================
1536 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1538 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1542 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1543 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1544 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1545 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1546 return autoUpdate && !exceeded;
1549 //=============================================================================
1553 //=============================================================================
1554 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1556 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1559 //=============================================================================
1563 //=============================================================================
1564 SMESHGUI* SMESHGUI::GetSMESHGUI()
1566 SMESHGUI* smeshMod = 0;
1567 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1570 CAM_Module* module = app->module( "Mesh" );
1571 smeshMod = dynamic_cast<SMESHGUI*>( module );
1574 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1576 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1579 _PTR(Study) aStudy = study->studyDS();
1581 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1590 Standard_EXPORT SMESHGUI* GetComponentGUI()
1592 return SMESHGUI::GetSMESHGUI();
1596 //=============================================================================
1600 //=============================================================================
1601 void SMESHGUI::SetState(int aState)
1606 //=============================================================================
1610 //=============================================================================
1611 void SMESHGUI::ResetState()
1616 //=============================================================================
1620 //=============================================================================
1621 void SMESHGUI::EmitSignalDeactivateDialog()
1623 emit SignalDeactivateActiveDialog();
1626 //=============================================================================
1630 //=============================================================================
1631 void SMESHGUI::EmitSignalStudyFrameChanged()
1633 emit SignalStudyFrameChanged();
1636 //=============================================================================
1640 //=============================================================================
1641 void SMESHGUI::EmitSignalCloseAllDialogs()
1643 emit SignalCloseAllDialogs();
1646 //=============================================================================
1650 //=============================================================================
1651 void SMESHGUI::EmitSignalVisibilityChanged()
1653 emit SignalVisibilityChanged();
1656 //=============================================================================
1660 //=============================================================================
1661 QDialog *SMESHGUI::GetActiveDialogBox()
1663 return myActiveDialogBox;
1666 //=============================================================================
1670 //=============================================================================
1671 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1673 myActiveDialogBox = (QDialog *) aDlg;
1677 //=============================================================================
1681 //=============================================================================
1682 SUIT_Desktop* SMESHGUI::desktop()
1684 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1686 return app->desktop();
1691 //=============================================================================
1695 //=============================================================================
1696 SalomeApp_Study* SMESHGUI::activeStudy()
1698 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1700 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1705 //=============================================================================
1709 //=============================================================================
1710 void SMESHGUI::Modified( bool theIsUpdateActions )
1712 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1713 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1714 appStudy->Modified();
1715 if( theIsUpdateActions )
1716 app->updateActions();
1721 //=============================================================================
1725 //=============================================================================
1726 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1728 /* Here the position is on the bottom right corner - 10 */
1729 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1731 SUIT_Desktop *PP = desktop();
1732 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1733 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1737 //=============================================================================
1741 //=============================================================================
1742 static int isStudyLocked(_PTR(Study) theStudy){
1743 return theStudy->GetProperties()->IsLocked();
1746 static bool checkLock(_PTR(Study) theStudy) {
1747 if (isStudyLocked(theStudy)) {
1748 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1749 QObject::tr("WRN_WARNING"),
1750 QObject::tr("WRN_STUDY_LOCKED") );
1756 //=======================================================================
1757 //function : CheckActiveStudyLocked
1759 //=======================================================================
1761 bool SMESHGUI::isActiveStudyLocked()
1763 _PTR(Study) aStudy = activeStudy()->studyDS();
1764 return checkLock( aStudy );
1767 //=============================================================================
1771 //=============================================================================
1772 bool SMESHGUI::OnGUIEvent( int theCommandID )
1774 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1778 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1779 SUIT_ResourceMgr* mgr = resourceMgr();
1783 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1784 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1787 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1788 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1790 //QAction* act = action( theCommandID );
1792 switch (theCommandID) {
1794 if(checkLock(aStudy)) break;
1802 if(checkLock(aStudy)) break;
1803 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1807 case 150: //MED FILE INFORMATION
1809 SALOME_ListIO selected;
1810 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1812 aSel->selectedObjects( selected );
1813 if( selected.Extent() )
1815 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1816 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1817 if ( !aMesh->_is_nil() )
1819 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1826 case 122: // EXPORT MED
1835 ::ExportMeshToFile(theCommandID);
1839 case 200: // SCALAR BAR
1841 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1842 SALOME_ListIO selected;
1844 aSel->selectedObjects( selected );
1846 if( selected.Extent() ) {
1847 Handle(SALOME_InteractiveObject) anIO = selected.First();
1848 if( anIO->hasEntry() ) {
1849 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1850 anActor->SetControlMode( SMESH_Actor::eNone );
1858 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1863 // dump control distribution data to the text file
1864 ::SaveDistribution();
1870 // show/ distribution
1871 ::ShowDistribution();
1881 ::DisableAutoColor();
1884 case 1134: // Clipping
1885 case 1133: // Tranparency
1886 case 1132: // Colors / Size
1893 ::SetDisplayMode(theCommandID, myMarkerMap);
1896 //2D quadratic representation
1899 ::SetDisplayMode(theCommandID, myMarkerMap);
1903 case 216: // 0D elements
1906 case 219: // Volumes
1907 case 220: // All Entity
1908 ::SetDisplayEntity(theCommandID);
1911 case 221: // Orientation of faces
1913 LightApp_SelectionMgr* mgr = selectionMgr();
1914 SALOME_ListIO selected; mgr->selectedObjects( selected );
1916 SALOME_ListIteratorOfListIO it(selected);
1917 for( ; it.More(); it.Next()) {
1918 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1919 if(anIObject->hasEntry()) {
1920 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1921 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1930 if(checkLock(aStudy)) break;
1932 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1935 SMESH::UpdateView();
1937 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1938 SMESH::OnVisuException();
1940 catch (...) { // PAL16774 (Crash after display of many groups)
1941 SMESH::OnVisuException();
1945 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1946 aSel->selectedObjects( l );
1947 aSel->setSelectedObjects( l );
1952 case 301: // DISPLAY
1953 case 302: // DISPLAY ONLY
1955 SMESH::EDisplaing anAction;
1956 switch (theCommandID) {
1957 case 300: anAction = SMESH::eErase; break;
1958 case 301: anAction = SMESH::eDisplay; break;
1959 case 302: anAction = SMESH::eDisplayOnly; break;
1962 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1963 SALOME_ListIO sel_objects, to_process;
1965 aSel->selectedObjects( sel_objects );
1967 if( theCommandID==302 )
1968 startOperation( myEraseAll );
1970 extractContainers( sel_objects, to_process );
1973 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1977 SALOME_ListIteratorOfListIO It( to_process );
1978 for ( ; It.More(); It.Next()) {
1979 Handle(SALOME_InteractiveObject) IOS = It.Value();
1980 if (IOS->hasEntry()) {
1981 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1982 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1983 break; // PAL16774 (Crash after display of many groups)
1985 if (anAction == SMESH::eDisplayOnly)
1986 anAction = SMESH::eDisplay;
1991 // PAL13338 + PAL15161 -->
1992 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1993 SMESH::UpdateView();
1994 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1996 // PAL13338 + PAL15161 <--
1998 catch (...) { // PAL16774 (Crash after display of many groups)
1999 SMESH::OnVisuException();
2002 if (anAction == SMESH::eErase) {
2004 aSel->setSelectedObjects( l1 );
2007 aSel->setSelectedObjects( to_process );
2014 if(checkLock(aStudy)) break;
2017 EmitSignalDeactivateDialog();
2019 ( new SMESHGUI_NodesDlg( this ) )->show();
2022 SUIT_MessageBox::warning(desktop(),
2023 tr("SMESH_WRN_WARNING"),
2024 tr("SMESH_WRN_VIEWER_VTK"));
2029 case 2151: // FILTER
2033 EmitSignalDeactivateDialog();
2034 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2039 case 701: // COMPUTE MESH
2040 case 711: // PRECOMPUTE MESH
2041 case 712: // EVALUATE MESH
2042 case 713: // MESH ORDER
2044 if (checkLock(aStudy)) break;
2045 startOperation( theCommandID );
2049 case 702: // Create mesh
2050 case 703: // Create sub-mesh
2051 case 704: // Edit mesh/sub-mesh
2052 startOperation( theCommandID );
2054 case 705: // copy mesh
2056 if (checkLock(aStudy)) break;
2057 EmitSignalDeactivateDialog();
2058 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2061 case 710: // Build compound mesh
2063 if (checkLock(aStudy)) break;
2064 EmitSignalDeactivateDialog();
2065 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2069 case 407: // DIAGONAL INVERSION
2070 case 408: // Delete diagonal
2074 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2075 tr( "NOT_A_VTK_VIEWER" ) );
2079 if ( checkLock( aStudy ) )
2082 /*Standard_Boolean aRes;
2083 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2084 if ( aMesh->_is_nil() )
2086 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2087 tr( "SMESH_BAD_SELECTION" ) );
2091 EmitSignalDeactivateDialog();
2092 if ( theCommandID == 407 )
2093 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2095 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2098 case 409: // Change orientation
2099 case 410: // Union of triangles
2100 case 411: // Cutting of quadrangles
2101 case 419: // Splitting volumes into tetrahedra
2105 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2106 tr( "NOT_A_VTK_VIEWER" ) );
2110 if ( checkLock( aStudy ) )
2113 EmitSignalDeactivateDialog();
2114 SMESHGUI_MultiEditDlg* aDlg = NULL;
2115 if ( theCommandID == 409 )
2116 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2117 else if ( theCommandID == 410 )
2118 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2119 else if ( theCommandID == 419 )
2120 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2122 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2127 case 412: // Smoothing
2129 if(checkLock(aStudy)) break;
2131 EmitSignalDeactivateDialog();
2132 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2135 SUIT_MessageBox::warning(desktop(),
2136 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2140 case 413: // Extrusion
2142 if (checkLock(aStudy)) break;
2144 EmitSignalDeactivateDialog();
2145 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2147 SUIT_MessageBox::warning(desktop(),
2148 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2152 case 414: // Revolution
2154 if(checkLock(aStudy)) break;
2156 EmitSignalDeactivateDialog();
2157 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2160 SUIT_MessageBox::warning(desktop(),
2161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2165 case 415: // Pattern mapping
2167 if ( checkLock( aStudy ) )
2171 EmitSignalDeactivateDialog();
2172 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2175 SUIT_MessageBox::warning(desktop(),
2176 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2180 case 416: // Extrusion along a path
2182 if (checkLock(aStudy)) break;
2184 EmitSignalDeactivateDialog();
2185 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2187 SUIT_MessageBox::warning(desktop(),
2188 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2192 case 417: // Convert mesh to quadratic
2194 startOperation( 417 );
2195 /* if (checkLock(aStudy)) break;
2197 EmitSignalDeactivateDialog();
2198 new SMESHGUI_ConvToQuadDlg();
2200 SUIT_MessageBox::warning(desktop(),
2201 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2205 case 418: // create 2D mesh from 3D
2207 startOperation( 418 );
2210 case 806: // CREATE GEO GROUP
2212 startOperation( 806 );
2215 case 801: // CREATE GROUP
2219 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2220 tr( "NOT_A_VTK_VIEWER" ) );
2224 if(checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2228 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2229 SALOME_ListIO selected;
2231 aSel->selectedObjects( selected );
2233 int nbSel = selected.Extent();
2235 // check if mesh is selected
2236 aMesh = SMESH::GetMeshByIO( selected.First() );
2238 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2243 case 802: // CONSTRUCT GROUP
2247 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2248 tr( "NOT_A_VTK_VIEWER" ) );
2252 if(checkLock(aStudy)) break;
2253 EmitSignalDeactivateDialog();
2255 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2256 SALOME_ListIO selected;
2258 aSel->selectedObjects( selected );
2260 int nbSel = selected.Extent();
2262 // check if submesh is selected
2263 Handle(SALOME_InteractiveObject) IObject = selected.First();
2264 if (IObject->hasEntry()) {
2265 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2267 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2268 if (!aSubMesh->_is_nil()) {
2270 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2271 // get submesh elements list by types
2272 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2273 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2274 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2275 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2276 // create group for each type o elements
2277 QString aName = IObject->getName();
2278 if (aNodes->length() > 0) {
2279 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2280 aGroup->Add(aNodes.inout());
2282 if (aEdges->length() > 0) {
2283 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2284 aGroup->Add(aEdges.inout());
2286 if (aFaces->length() > 0) {
2287 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2288 aGroup->Add(aFaces.inout());
2290 if (aVolumes->length() > 0) {
2291 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2292 aGroup->Add(aVolumes.inout());
2297 catch(const SALOME::SALOME_Exception & S_ex){
2298 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2305 SUIT_MessageBox::warning(desktop(),
2306 tr("SMESH_WRN_WARNING"),
2307 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2312 case 803: // EDIT GROUP
2316 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2317 tr( "NOT_A_VTK_VIEWER" ) );
2321 if(checkLock(aStudy)) break;
2322 EmitSignalDeactivateDialog();
2324 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2325 SALOME_ListIO selected;
2327 aSel->selectedObjects( selected );
2329 SALOME_ListIteratorOfListIO It (selected);
2330 int nbSelectedGroups = 0;
2331 for ( ; It.More(); It.Next() )
2333 SMESH::SMESH_GroupBase_var aGroup =
2334 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2335 if (!aGroup->_is_nil()) {
2337 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2341 if (nbSelectedGroups == 0)
2343 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2349 case 804: // Add elements to group
2351 if(checkLock(aStudy)) break;
2352 if (myState == 800) {
2353 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2354 if (aDlg) aDlg->onAdd();
2359 case 805: // Remove elements from group
2361 if(checkLock(aStudy)) break;
2362 if (myState == 800) {
2363 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2364 if (aDlg) aDlg->onRemove();
2369 case 815: // Edit GEOM GROUP as standalone
2373 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2374 tr( "NOT_A_VTK_VIEWER" ) );
2378 if(checkLock(aStudy)) break;
2379 EmitSignalDeactivateDialog();
2381 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2382 SALOME_ListIO selected;
2384 aSel->selectedObjects( selected );
2386 SALOME_ListIteratorOfListIO It (selected);
2387 for ( ; It.More(); It.Next() )
2389 SMESH::SMESH_GroupOnGeom_var aGroup =
2390 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2391 if (!aGroup->_is_nil()) {
2392 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2399 case 810: // Union Groups
2400 case 811: // Intersect groups
2401 case 812: // Cut groups
2405 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2406 tr( "NOT_A_VTK_VIEWER" ) );
2410 if ( checkLock( aStudy ) )
2413 EmitSignalDeactivateDialog();
2415 SMESHGUI_GroupOpDlg* aDlg = 0;
2416 if ( theCommandID == 810 )
2417 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2418 else if ( theCommandID == 811 )
2419 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2421 aDlg = new SMESHGUI_CutGroupsDlg( this );
2428 case 814: // Create groups of entities from existing groups of superior dimensions
2430 if ( checkLock( aStudy ) )
2433 EmitSignalDeactivateDialog();
2434 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2440 case 813: // Delete groups with their contents
2444 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2445 tr( "NOT_A_VTK_VIEWER" ) );
2449 if ( checkLock( aStudy ) )
2452 EmitSignalDeactivateDialog();
2454 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2458 case 900: // MESH INFOS
2459 case 903: // WHAT IS
2461 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2462 EmitSignalDeactivateDialog();
2463 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2464 SALOME_ListIO selected;
2466 aSel->selectedObjects( selected );
2468 if ( selected.Extent() > 1 ) { // a dlg for each IO
2469 SALOME_ListIteratorOfListIO It( selected );
2470 for ( ; It.More(); It.Next() ) {
2471 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2472 dlg->showInfo( It.Value() );
2477 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2483 case 902: // STANDARD MESH INFOS
2485 EmitSignalDeactivateDialog();
2486 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2487 SALOME_ListIO selected;
2489 aSel->selectedObjects( selected );
2491 if ( selected.Extent() > 1 ) { // a dlg for each IO
2493 SALOME_ListIteratorOfListIO It (selected);
2494 for ( ; It.More(); It.Next() ) {
2496 IOs.Append( It.Value() );
2497 aSel->setSelectedObjects( IOs );
2498 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2500 // restore selection
2501 aSel->setSelectedObjects( selected );
2504 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2507 case 903: // WHAT IS
2509 EmitSignalDeactivateDialog();
2510 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2515 case 904: // FIND ELEM
2517 startOperation( theCommandID );
2521 case 1100: // EDIT HYPOTHESIS
2523 if(checkLock(aStudy)) break;
2525 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2526 SALOME_ListIO selected;
2528 aSel->selectedObjects( selected );
2530 int nbSel = selected.Extent();
2533 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2534 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2536 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2537 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2538 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2539 if ( !aHypothesis->_is_nil() )
2542 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2543 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2545 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2556 case 1101: // RENAME
2558 if ( checkLock( aStudy ) )
2561 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2562 SALOME_ListIO selected;
2564 aSel->selectedObjects( selected );
2566 bool isAny = false; // is there any appropriate object selected
2568 SALOME_ListIteratorOfListIO It( selected );
2569 for ( ; It.More(); It.Next() )
2571 Handle(SALOME_InteractiveObject) IObject = It.Value();
2572 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2573 _PTR(GenericAttribute) anAttr;
2574 _PTR(AttributeName) aName;
2577 if ( obj->FindAttribute(anAttr, "AttributeName") )
2580 QString newName = QString(aName->Value().c_str());
2582 // check type to prevent renaming of inappropriate objects
2583 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2584 if (aType == MESH || aType == GROUP ||
2585 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2586 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2587 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2588 aType == HYPOTHESIS || aType == ALGORITHM)
2591 newName = LightApp_NameDlg::getName(desktop(), newName);
2592 if ( !newName.isEmpty() )
2594 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2596 // update name of group object and its actor
2597 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2598 if( !aGroupObject->_is_nil() )
2600 aGroupObject->SetName( newName.toLatin1().data() );
2601 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2602 anActor->setName( newName.toLatin1().data() );
2613 SUIT_MessageBox::warning(desktop(),
2614 QObject::tr("SMESH_WRN_WARNING"),
2615 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2620 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2622 if(checkLock(aStudy)) break;
2623 SUIT_OverrideCursor wc;
2625 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2626 SALOME_ListIO selected;
2628 aSel->selectedObjects( selected, QString::null, false );
2630 SALOME_ListIteratorOfListIO It(selected);
2631 for (int i = 0; It.More(); It.Next(), i++) {
2632 Handle(SALOME_InteractiveObject) IObject = It.Value();
2633 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2636 aSel->setSelectedObjects( l1 );
2641 case 4009: // ELEM0D
2642 case 4010: // GEOM::EDGE
2643 case 4021: // TRIANGLE
2645 case 4023: // POLYGON
2649 if(checkLock(aStudy)) break;
2651 EmitSignalDeactivateDialog();
2652 SMDSAbs_ElementType type = SMDSAbs_Edge;
2654 switch (theCommandID) {
2655 case 4009: // ELEM0D
2656 type = SMDSAbs_0DElement; nbNodes = 1; break;
2657 case 4021: // TRIANGLE
2658 type = SMDSAbs_Face; nbNodes = 3; break;
2660 type = SMDSAbs_Face; nbNodes = 4; break;
2662 type = SMDSAbs_Volume; nbNodes = 4; break;
2663 case 4023: // POLYGON
2664 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2666 type = SMDSAbs_Volume; nbNodes = 8; break;
2667 case 4033: // POLYHEDRE
2668 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2671 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2674 SUIT_MessageBox::warning(desktop(),
2675 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2679 case 4033: // POLYHEDRON
2681 if(checkLock(aStudy)) break;
2683 EmitSignalDeactivateDialog();
2684 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2687 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2688 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2692 case 4034: // QUADRATIC EDGE
2693 case 4035: // QUADRATIC TRIANGLE
2694 case 4036: // QUADRATIC QUADRANGLE
2695 case 4037: // QUADRATIC TETRAHEDRON
2696 case 4038: // QUADRATIC PYRAMID
2697 case 4039: // QUADRATIC PENTAHEDRON
2698 case 4040: // QUADRATIC HEXAHEDRON
2700 if(checkLock(aStudy)) break;
2702 EmitSignalDeactivateDialog();
2705 switch (theCommandID) {
2707 type = QUAD_EDGE; break;
2709 type = QUAD_TRIANGLE; break;
2711 type = QUAD_QUADRANGLE; break;
2713 type = QUAD_TETRAHEDRON; break;
2715 type = QUAD_PYRAMID; break;
2717 type = QUAD_PENTAHEDRON; break;
2719 type = QUAD_HEXAHEDRON;
2723 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2726 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2727 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2731 case 4041: // REMOVES NODES
2733 if(checkLock(aStudy)) break;
2735 EmitSignalDeactivateDialog();
2736 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2739 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2740 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2744 case 4042: // REMOVES ELEMENTS
2746 if(checkLock(aStudy)) break;
2748 EmitSignalDeactivateDialog();
2749 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2753 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2754 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2758 case 4043: { // CLEAR_MESH
2760 if(checkLock(aStudy)) break;
2762 SALOME_ListIO selected;
2763 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2764 aSel->selectedObjects( selected );
2766 SUIT_OverrideCursor wc;
2767 SALOME_ListIteratorOfListIO It (selected);
2768 for ( ; It.More(); It.Next() )
2770 Handle(SALOME_InteractiveObject) IOS = It.Value();
2771 SMESH::SMESH_Mesh_var aMesh =
2772 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2773 if ( aMesh->_is_nil()) continue;
2775 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2777 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2778 SMESH::ModifiedMesh( aMeshSObj, false, true);
2779 // hide groups and submeshes
2780 _PTR(ChildIterator) anIter =
2781 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2782 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2784 _PTR(SObject) so = anIter->Value();
2785 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2788 catch (const SALOME::SALOME_Exception& S_ex){
2790 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2794 SMESH::UpdateView();
2798 case 4044: // REMOVE ORPHAN NODES
2800 if(checkLock(aStudy)) break;
2801 SALOME_ListIO selected;
2802 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2803 aSel->selectedObjects( selected );
2804 if ( selected.Extent() == 1 ) {
2805 Handle(SALOME_InteractiveObject) anIO = selected.First();
2806 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2807 if ( !aMesh->_is_nil() ) {
2808 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2809 tr( "SMESH_WARNING" ),
2810 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2811 SUIT_MessageBox::Yes |
2812 SUIT_MessageBox::No,
2813 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2816 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2817 int removed = aMeshEditor->RemoveOrphanNodes();
2818 SUIT_MessageBox::information(SMESHGUI::desktop(),
2819 tr("SMESH_INFORMATION"),
2820 tr("NB_NODES_REMOVED").arg(removed));
2821 if ( removed > 0 ) {
2822 SMESH::UpdateView();
2823 SMESHGUI::Modified();
2826 catch (const SALOME::SALOME_Exception& S_ex) {
2827 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2836 case 4051: // RENUMBERING NODES
2838 if(checkLock(aStudy)) break;
2840 EmitSignalDeactivateDialog();
2841 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2845 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2846 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2850 case 4052: // RENUMBERING ELEMENTS
2852 if(checkLock(aStudy)) break;
2854 EmitSignalDeactivateDialog();
2855 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2859 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2860 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2864 case 4061: // TRANSLATION
2866 if(checkLock(aStudy)) break;
2868 EmitSignalDeactivateDialog();
2869 ( new SMESHGUI_TranslationDlg( this ) )->show();
2872 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2873 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2877 case 4062: // ROTATION
2879 if(checkLock(aStudy)) break;
2881 EmitSignalDeactivateDialog();
2882 ( new SMESHGUI_RotationDlg( this ) )->show();
2885 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2886 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2890 case 4063: // SYMMETRY
2892 if(checkLock(aStudy)) break;
2894 EmitSignalDeactivateDialog();
2895 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2898 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2899 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2903 case 4064: // SEWING
2905 if(checkLock(aStudy)) break;
2907 EmitSignalDeactivateDialog();
2908 ( new SMESHGUI_SewingDlg( this ) )->show();
2911 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2912 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2916 case 4065: // MERGE NODES
2918 if(checkLock(aStudy)) break;
2920 EmitSignalDeactivateDialog();
2921 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2924 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2925 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2929 case 4066: // MERGE EQUAL ELEMENTS
2931 if (checkLock(aStudy)) break;
2933 EmitSignalDeactivateDialog();
2934 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2936 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2937 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2942 case 4067: // MAKE MESH PASS THROUGH POINT
2943 startOperation( 4067 );
2948 if(checkLock(aStudy)) break;
2950 EmitSignalDeactivateDialog();
2951 ( new SMESHGUI_ScaleDlg( this ) )->show();
2954 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2955 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2960 case 4069: // DUPLICATE NODES
2962 if(checkLock(aStudy)) break;
2964 EmitSignalDeactivateDialog();
2965 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2968 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2969 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2974 case 5105: // Library of selection filters
2976 static QList<int> aTypes;
2977 if ( aTypes.isEmpty() )
2979 aTypes.append( SMESH::NODE );
2980 aTypes.append( SMESH::EDGE );
2981 aTypes.append( SMESH::FACE );
2982 aTypes.append( SMESH::VOLUME );
2984 if (!myFilterLibraryDlg)
2985 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2986 else if (myFilterLibraryDlg->isHidden())
2987 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2988 myFilterLibraryDlg->raise();
2992 case 6017: // CONTROLS
3016 LightApp_SelectionMgr* mgr = selectionMgr();
3017 SALOME_ListIO selected; mgr->selectedObjects( selected );
3019 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3020 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3022 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3023 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3024 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3025 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3026 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3027 ::Control( theCommandID );
3032 SUIT_MessageBox::warning(desktop(),
3033 tr( "SMESH_WRN_WARNING" ),
3034 tr( "SMESH_BAD_SELECTION" ) );
3038 SUIT_MessageBox::warning(desktop(),
3039 tr( "SMESH_WRN_WARNING" ),
3040 tr( "NOT_A_VTK_VIEWER" ) );
3045 LightApp_SelectionMgr* mgr = selectionMgr();
3046 SALOME_ListIO selected; mgr->selectedObjects( selected );
3048 SALOME_ListIteratorOfListIO it(selected);
3049 for( ; it.More(); it.Next()) {
3050 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3051 if(anIObject->hasEntry()) {
3052 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3053 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3061 LightApp_SelectionMgr* mgr = selectionMgr();
3062 SALOME_ListIO selected; mgr->selectedObjects( selected );
3064 SALOME_ListIteratorOfListIO it(selected);
3065 for( ; it.More(); it.Next()) {
3066 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3067 if(anIObject->hasEntry())
3068 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3069 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3077 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3078 EmitSignalDeactivateDialog();
3079 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3085 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3086 //updateObjBrowser();
3090 //=============================================================================
3094 //=============================================================================
3095 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3100 //=============================================================================
3104 //=============================================================================
3105 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3110 //=============================================================================
3114 //=============================================================================
3115 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3120 //=============================================================================
3121 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3122 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3124 //=============================================================================
3125 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3126 SUIT_ViewWindow* wnd )
3128 if(theIO->hasEntry()){
3129 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3130 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3134 //=======================================================================
3135 // function : createSMESHAction
3137 //=======================================================================
3138 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3139 const int key, const bool toggle, const QString& shortcutAction )
3142 QWidget* parent = application()->desktop();
3143 SUIT_ResourceMgr* resMgr = resourceMgr();
3145 if ( !icon_id.isEmpty() )
3146 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3148 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3149 if ( !pix.isNull() )
3150 icon = QIcon( pix );
3152 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3153 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3154 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3156 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3157 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3160 //=======================================================================
3161 // function : createPopupItem
3163 //=======================================================================
3164 void SMESHGUI::createPopupItem( const int id,
3165 const QString& clients,
3166 const QString& types,
3167 const QString& theRule,
3172 parentId = popupMgr()->actionId( action( pId ) );
3174 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3175 popupMgr()->insert( action( id ), parentId, 0 );
3177 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3178 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3179 QString rule = "(%1) and (%2) and (%3)";
3180 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3181 if( clients.isEmpty() )
3182 rule = rule.arg( QString( "true" ) );
3184 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3185 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3188 bool cont = myRules.contains( id );
3190 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3192 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3193 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3196 //=======================================================================
3197 // function : initialize
3199 //=======================================================================
3200 void SMESHGUI::initialize( CAM_Application* app )
3202 SalomeApp_Module::initialize( app );
3204 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3206 /* Automatic Update flag */
3207 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3209 // ----- create actions --------------
3211 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3212 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3213 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3214 createSMESHAction( 114, "NUM" );
3215 createSMESHAction( 121, "DAT" );
3216 createSMESHAction( 122, "MED" );
3217 createSMESHAction( 123, "UNV" );
3218 createSMESHAction( 140, "STL" );
3219 createSMESHAction( 124, "EXPORT_DAT" );
3220 createSMESHAction( 125, "EXPORT_MED" );
3221 createSMESHAction( 126, "EXPORT_UNV" );
3222 createSMESHAction( 141, "EXPORT_STL" );
3223 createSMESHAction( 150, "FILE_INFO" );
3224 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3225 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3226 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3227 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3228 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3229 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3230 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3231 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3232 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3233 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3234 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3235 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3236 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3237 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3238 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3239 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3240 createSMESHAction( 804, "ADD" );
3241 createSMESHAction( 805, "REMOVE" );
3242 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3243 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3244 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3245 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3246 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3247 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3248 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3249 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3250 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3251 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3252 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3253 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3254 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3255 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3256 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3257 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3258 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3259 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3260 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3261 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3262 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3263 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3264 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3265 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3266 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3267 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3268 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3269 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3270 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3271 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3272 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3273 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3274 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3275 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3276 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3277 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3278 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3279 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3280 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3281 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3282 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3283 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3284 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3285 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3286 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3287 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3288 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3289 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3290 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3291 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3292 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3293 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3294 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3295 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3296 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3297 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3298 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3299 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3300 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3301 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3302 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3303 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3304 createSMESHAction( 415, "MAP", "ICON_MAP" );
3305 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3306 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3307 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3308 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3309 createSMESHAction( 200, "RESET" );
3310 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3311 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3312 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3313 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3314 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3315 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3316 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3317 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3318 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3319 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3320 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3321 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3322 createSMESHAction( 220, "ALL" );
3323 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3325 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3326 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3328 createSMESHAction( 1100, "EDIT_HYPO" );
3329 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3330 createSMESHAction( 1102, "UNASSIGN" );
3331 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3332 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3333 createSMESHAction( 1131, "DISPMODE" );
3334 createSMESHAction( 1132, "COLORS" );
3335 createSMESHAction( 1133, "TRANSP" );
3336 createSMESHAction( 1134, "CLIP" );
3337 createSMESHAction( 1135, "DISP_ENT" );
3338 createSMESHAction( 1136, "AUTO_COLOR" );
3339 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3340 createSMESHAction( 2000, "CTRL" );
3342 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3343 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3345 createSMESHAction( 300, "ERASE" );
3346 createSMESHAction( 301, "DISPLAY" );
3347 createSMESHAction( 302, "DISPLAY_ONLY" );
3348 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3349 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3350 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3351 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3352 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3353 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3354 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3355 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3357 // ----- create menu --------------
3358 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3359 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3360 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3361 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3362 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3363 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3364 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3365 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3367 createMenu( separator(), fileId );
3369 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3370 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3371 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3372 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3373 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3374 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3375 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3376 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3377 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3378 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3380 createMenu( 111, importId, -1 );
3381 createMenu( 112, importId, -1 );
3382 createMenu( 113, importId, -1 );
3384 createMenu( 121, exportId, -1 );
3385 createMenu( 122, exportId, -1 );
3386 createMenu( 123, exportId, -1 );
3387 createMenu( 140, exportId, -1 ); // export to stl STL
3389 createMenu( separator(), fileId, 10 );
3391 createMenu( 33, editId, -1 );
3393 createMenu( 5105, toolsId, -1 );
3395 createMenu( 702, meshId, -1 ); // "Mesh" menu
3396 createMenu( 703, meshId, -1 );
3397 createMenu( 704, meshId, -1 );
3398 createMenu( 710, meshId, -1 );
3399 createMenu( 705, meshId, -1 );
3400 createMenu( separator(), meshId, -1 );
3401 createMenu( 701, meshId, -1 );
3402 createMenu( 711, meshId, -1 );
3403 createMenu( 712, meshId, -1 );
3404 createMenu( 713, meshId, -1 );
3405 createMenu( separator(), meshId, -1 );
3406 createMenu( 801, meshId, -1 );
3407 createMenu( 806, meshId, -1 );
3408 createMenu( 802, meshId, -1 );
3409 createMenu( 803, meshId, -1 );
3410 createMenu( 815, meshId, -1 );
3411 createMenu( separator(), meshId, -1 );
3412 createMenu( 810, meshId, -1 );
3413 createMenu( 811, meshId, -1 );
3414 createMenu( 812, meshId, -1 );
3415 createMenu( separator(), meshId, -1 );
3416 createMenu( 814, meshId, -1 );
3417 createMenu( separator(), meshId, -1 );
3418 createMenu( 900, meshId, -1 );
3419 //createMenu( 902, meshId, -1 );
3420 createMenu( 903, meshId, -1 );
3421 createMenu( 904, meshId, -1 );
3422 createMenu( separator(), meshId, -1 );
3424 createMenu( 6005, nodeId, -1 );
3425 createMenu( 6002, edgeId, -1 );
3426 createMenu( 6003, edgeId, -1 );
3427 createMenu( 6001, edgeId, -1 );
3428 createMenu( 6004, edgeId, -1 );
3429 createMenu( 6021, faceId, -1 );
3430 createMenu( 6025, faceId, -1 );
3431 createMenu( 6027, faceId, -1 );
3432 createMenu( 6018, faceId, -1 );
3433 createMenu( 6019, faceId, -1 );
3434 createMenu( 6011, faceId, -1 );
3435 createMenu( 6012, faceId, -1 );
3436 createMenu( 6013, faceId, -1 );
3437 createMenu( 6014, faceId, -1 );
3438 createMenu( 6015, faceId, -1 );
3439 createMenu( 6016, faceId, -1 );
3440 createMenu( 6022, faceId, -1 );
3441 createMenu( 6017, volumeId, -1 );
3442 createMenu( 6009, volumeId, -1 );
3443 createMenu( 6023, volumeId, -1 );
3444 createMenu( 6024, volumeId, -1 );
3445 createMenu( 6026, volumeId, -1 );
3447 createMenu( 4000, addId, -1 );
3448 createMenu( 4009, addId, -1 );
3449 createMenu( 4010, addId, -1 );
3450 createMenu( 4021, addId, -1 );
3451 createMenu( 4022, addId, -1 );
3452 createMenu( 4023, addId, -1 );
3453 createMenu( 4031, addId, -1 );
3454 createMenu( 4032, addId, -1 );
3455 createMenu( 4033, addId, -1 );
3456 createMenu( separator(), addId, -1 );
3457 createMenu( 4034, addId, -1 );
3458 createMenu( 4035, addId, -1 );
3459 createMenu( 4036, addId, -1 );
3460 createMenu( 4037, addId, -1 );
3461 createMenu( 4038, addId, -1 );
3462 createMenu( 4039, addId, -1 );
3463 createMenu( 4040, addId, -1 );
3465 createMenu( 4041, removeId, -1 );
3466 createMenu( 4042, removeId, -1 );
3467 createMenu( 4044, removeId, -1 );
3468 createMenu( separator(), removeId, -1 );
3469 createMenu( 813, removeId, -1 );
3470 createMenu( separator(), removeId, -1 );
3471 createMenu( 4043, removeId, -1 );
3473 createMenu( 4051, renumId, -1 );
3474 createMenu( 4052, renumId, -1 );
3476 createMenu( 4061, transfId, -1 );
3477 createMenu( 4062, transfId, -1 );
3478 createMenu( 4063, transfId, -1 );
3479 createMenu( 4064, transfId, -1 );
3480 createMenu( 4065, transfId, -1 );
3481 createMenu( 4066, transfId, -1 );
3482 createMenu( 4068, transfId, -1 );
3483 createMenu( 4069, transfId, -1 );
3485 createMenu( 4067,modifyId, -1 );
3486 createMenu( 407, modifyId, -1 );
3487 createMenu( 408, modifyId, -1 );
3488 createMenu( 409, modifyId, -1 );
3489 createMenu( 410, modifyId, -1 );
3490 createMenu( 411, modifyId, -1 );
3491 createMenu( 419, modifyId, -1 );
3492 createMenu( 412, modifyId, -1 );
3493 createMenu( 413, modifyId, -1 );
3494 createMenu( 416, modifyId, -1 );
3495 createMenu( 414, modifyId, -1 );
3496 createMenu( 415, modifyId, -1 );
3497 createMenu( 417, modifyId, -1 );
3498 createMenu( 418, modifyId, -1 );
3500 createMenu( 501, measureId, -1 );
3501 createMenu( 502, measureId, -1 );
3502 createMenu( 214, viewId, -1 );
3504 // ----- create toolbars --------------
3505 int meshTb = createTool( tr( "TB_MESH" ) ),
3506 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3507 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3508 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3509 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3511 createTool( 702, meshTb );
3512 createTool( 703, meshTb );
3513 createTool( 704, meshTb );
3514 createTool( 710, meshTb );
3515 createTool( 705, meshTb );
3516 createTool( separator(), meshTb );
3517 createTool( 701, meshTb );
3518 createTool( 711, meshTb );
3519 createTool( 712, meshTb );
3520 createTool( 713, meshTb );
3521 createTool( separator(), meshTb );
3522 createTool( 801, meshTb );
3523 createTool( 806, meshTb );
3524 createTool( 802, meshTb );
3525 createTool( 803, meshTb );
3526 //createTool( 815, meshTb );
3527 createTool( separator(), meshTb );
3528 createTool( 900, meshTb );
3529 //createTool( 902, meshTb );
3530 createTool( 903, meshTb );
3531 createTool( 904, meshTb );
3532 createTool( separator(), meshTb );
3534 createTool( 6005, ctrlTb );
3535 createTool( separator(), ctrlTb );
3536 createTool( 6002, ctrlTb );
3537 createTool( 6003, ctrlTb );
3538 createTool( 6001, ctrlTb );
3539 createTool( 6004, ctrlTb );
3540 createTool( separator(), ctrlTb );
3541 createTool( 6021, ctrlTb );
3542 createTool( 6025, ctrlTb );
3543 createTool( 6027, ctrlTb );
3544 createTool( 6018, ctrlTb );
3545 createTool( 6019, ctrlTb );
3546 createTool( 6011, ctrlTb );
3547 createTool( 6012, ctrlTb );
3548 createTool( 6013, ctrlTb );
3549 createTool( 6014, ctrlTb );
3550 createTool( 6015, ctrlTb );
3551 createTool( 6016, ctrlTb );
3552 createTool( 6022, ctrlTb );
3553 createTool( separator(), ctrlTb );
3554 createTool( 6017, ctrlTb );
3555 createTool( 6009, ctrlTb );
3556 createTool( 6023, ctrlTb );
3557 createTool( 6024, ctrlTb );
3558 createTool( 6026, ctrlTb );
3559 createTool( separator(), ctrlTb );
3561 createTool( 4000, addRemTb );
3562 createTool( 4009, addRemTb );
3563 createTool( 4010, addRemTb );
3564 createTool( 4021, addRemTb );
3565 createTool( 4022, addRemTb );
3566 createTool( 4023, addRemTb );
3567 createTool( 4031, addRemTb );
3568 createTool( 4032, addRemTb );
3569 createTool( 4033, addRemTb );
3570 createTool( separator(), addRemTb );
3571 createTool( 4034, addRemTb );
3572 createTool( 4035, addRemTb );
3573 createTool( 4036, addRemTb );
3574 createTool( 4037, addRemTb );
3575 createTool( 4038, addRemTb );
3576 createTool( 4039, addRemTb );
3577 createTool( 4040, addRemTb );
3578 createTool( separator(), addRemTb );
3579 createTool( 4041, addRemTb );
3580 createTool( 4042, addRemTb );
3581 createTool( 4044, addRemTb );
3582 createTool( 4043, addRemTb );
3583 createTool( separator(), addRemTb );
3584 createTool( 4051, addRemTb );
3585 createTool( 4052, addRemTb );
3586 createTool( separator(), addRemTb );
3587 createTool( 4061, addRemTb );
3588 createTool( 4062, addRemTb );
3589 createTool( 4063, addRemTb );
3590 createTool( 4064, addRemTb );
3591 createTool( 4065, addRemTb );
3592 createTool( 4066, addRemTb );
3593 createTool( 4068, addRemTb );
3594 createTool( 4069, addRemTb );
3595 createTool( separator(), addRemTb );
3597 createTool( 4067,modifyTb );
3598 createTool( 407, modifyTb );
3599 createTool( 408, modifyTb );
3600 createTool( 409, modifyTb );
3601 createTool( 410, modifyTb );
3602 createTool( 411, modifyTb );
3603 createTool( 419, modifyTb );
3604 createTool( 412, modifyTb );
3605 createTool( 413, modifyTb );
3606 createTool( 416, modifyTb );
3607 createTool( 414, modifyTb );
3608 createTool( 415, modifyTb );
3609 createTool( 417, modifyTb );
3610 createTool( 418, modifyTb );
3612 createTool( 214, dispModeTb );
3614 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3615 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3618 QString OB = "'ObjectBrowser'",
3619 View = "'" + SVTK_Viewer::Type() + "'",
3621 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3622 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3623 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3624 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3625 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3626 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3627 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3628 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3629 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3630 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3631 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3633 mesh_group = mesh + " " + subMesh + " " + group,
3634 hyp_alg = hypo + " " + algo;
3636 // popup for object browser
3638 isInvisible("not( isVisible )"),
3639 isEmpty("numberOfNodes = 0"),
3640 isNotEmpty("numberOfNodes <> 0"),
3642 // has nodes, edges, etc in VISIBLE! actor
3643 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3644 hasElems("(count( elemTypes ) > 0)"),
3645 hasDifferentElems("(count( elemTypes ) > 1)"),
3646 hasElems0d("({'Elem0d'} in elemTypes)"),
3647 hasEdges("({'Edge'} in elemTypes)"),
3648 hasFaces("({'Face'} in elemTypes)"),
3649 hasVolumes("({'Volume'} in elemTypes)");
3651 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3652 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3653 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3654 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3655 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3656 createPopupItem( 803, OB, group ); // EDIT_GROUP
3657 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3659 popupMgr()->insert( separator(), -1, 0 );
3660 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3661 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3662 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3663 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3664 createPopupItem( 214, OB, mesh_group ); // UPDATE
3665 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3666 //createPopupItem( 902, OB, mesh ); // STD_INFO
3667 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3668 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3669 popupMgr()->insert( separator(), -1, 0 );
3670 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3671 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3672 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3673 popupMgr()->insert( separator(), -1, 0 );
3674 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3675 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3676 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3677 popupMgr()->insert( separator(), -1, 0 );
3678 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3679 popupMgr()->insert( separator(), -1, 0 );
3680 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3681 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3682 popupMgr()->insert( separator(), -1, 0 );
3684 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3685 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3687 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3688 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3689 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3690 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3691 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3692 popupMgr()->insert( separator(), -1, 0 );
3695 createPopupItem( 803, View, group ); // EDIT_GROUP
3696 createPopupItem( 804, View, elems ); // ADD
3697 createPopupItem( 805, View, elems ); // REMOVE
3699 popupMgr()->insert( separator(), -1, 0 );
3700 createPopupItem( 214, View, mesh_group ); // UPDATE
3701 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3702 //createPopupItem( 902, View, mesh ); // STD_INFO
3703 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3704 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3705 popupMgr()->insert( separator(), -1, 0 );
3707 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3708 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3709 popupMgr()->insert( separator(), -1, 0 );
3712 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3713 QString aType = QString( "%1type in {%2}" ).arg( lc );
3714 aType = aType.arg( mesh_group );
3715 QString aMeshInVTK = aClient + "&&" + aType;
3717 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3718 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3719 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3721 //-------------------------------------------------
3723 //-------------------------------------------------
3724 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3726 popupMgr()->insert( action( 9010 ), anId, -1 );
3727 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3728 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3730 popupMgr()->insert( action( 9011 ), anId, -1 );
3731 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3732 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3734 popupMgr()->insert( separator(), -1, -1 );
3736 //-------------------------------------------------
3738 //-------------------------------------------------
3739 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3741 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3742 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3743 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3745 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3746 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3747 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3749 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3750 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3751 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3753 popupMgr()->insert( separator(), anId, -1 );
3755 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3756 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3757 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3759 //-------------------------------------------------
3761 //-------------------------------------------------
3762 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3764 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3766 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3767 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3768 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3770 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3771 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3772 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3774 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3775 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3776 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3778 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3779 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3780 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3782 popupMgr()->insert( separator(), anId, -1 );
3784 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3785 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3788 //-------------------------------------------------
3789 // Representation of the 2D Quadratic elements
3790 //-------------------------------------------------
3791 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3792 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3793 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3794 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3796 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3797 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3798 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3800 //-------------------------------------------------
3801 // Orientation of faces
3802 //-------------------------------------------------
3803 popupMgr()->insert( action( 221 ), -1, -1 );
3804 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3805 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3807 //-------------------------------------------------
3809 //-------------------------------------------------
3810 popupMgr()->insert( action( 1132 ), -1, -1 );
3811 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3813 //-------------------------------------------------
3815 //-------------------------------------------------
3816 popupMgr()->insert( action( 1133 ), -1, -1 );
3817 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3819 //-------------------------------------------------
3821 //-------------------------------------------------
3823 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3824 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3825 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3826 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3828 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3830 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3831 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3833 popupMgr()->insert( separator(), anId, -1 );
3835 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3837 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3838 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3839 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3841 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3843 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3844 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3845 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3847 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3848 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3849 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3851 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3852 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3856 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3857 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3859 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3861 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3862 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3863 QtxPopupMgr::VisibleRule );
3864 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3866 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3867 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3868 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3870 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3871 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3872 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3874 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3875 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3876 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3878 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3879 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3880 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3882 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3883 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3884 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3886 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3887 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3888 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3890 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3891 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3892 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3894 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3895 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3896 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3898 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3899 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3900 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3902 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3903 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3904 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3906 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
3907 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3908 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
3910 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3912 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3913 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3914 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3916 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3917 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3918 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3920 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3921 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3922 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3924 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
3925 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3926 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
3928 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
3929 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3930 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
3932 popupMgr()->insert( separator(), anId, -1 );
3934 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3935 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3937 popupMgr()->insert( separator(), anId, -1 );
3939 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3940 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3942 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3943 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3944 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3947 popupMgr()->insert( separator(), -1, -1 );
3949 //-------------------------------------------------
3951 //-------------------------------------------------
3952 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3953 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3954 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3955 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3957 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3958 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3960 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3961 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3963 popupMgr()->insert( separator(), -1, -1 );
3965 //-------------------------------------------------
3967 //-------------------------------------------------
3968 popupMgr()->insert( action( 1134 ), -1, -1 );
3969 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3971 popupMgr()->insert( separator(), -1, -1 );
3973 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3974 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3976 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3977 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3980 //================================================================================
3982 * \brief Return true if SMESH or GEOM objects are selected.
3983 * Is called form LightApp_Module::activateModule() which clear selection if
3984 * not isSelectionCompatible()
3986 //================================================================================
3988 bool SMESHGUI::isSelectionCompatible()
3990 bool isCompatible = true;
3991 SALOME_ListIO selected;
3992 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3993 Sel->selectedObjects( selected );
3995 SALOME_ListIteratorOfListIO It( selected );
3996 for ( ; isCompatible && It.More(); It.Next())
3998 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3999 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4001 return isCompatible;
4005 bool SMESHGUI::reusableOperation( const int id )
4007 // compute, evaluate and precompute are not reusable operations
4008 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4011 bool SMESHGUI::activateModule( SUIT_Study* study )
4013 bool res = SalomeApp_Module::activateModule( study );
4015 setMenuShown( true );
4016 setToolShown( true );
4018 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4019 PyGILState_STATE gstate = PyGILState_Ensure();
4020 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
4021 if(pluginsmanager==NULL)
4025 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4030 PyGILState_Release(gstate);
4031 // end of GEOM plugins loading
4033 // Reset actions accelerator keys
4034 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4035 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4036 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4038 action( 33)->setEnabled(true); // Delete: Key_Delete
4039 action(1101)->setEnabled(true); // Rename: Key_F2
4041 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4042 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4043 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4044 if ( _PTR(Study) aStudy = s->studyDS()) {
4045 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4046 updateObjBrowser(); // objects can be removed
4052 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4054 setMenuShown( false );
4055 setToolShown( false );
4057 EmitSignalCloseAllDialogs();
4059 // Unset actions accelerator keys
4060 action(111)->setShortcut(QKeySequence()); // Import DAT
4061 action(112)->setShortcut(QKeySequence()); // Import UNV
4062 action(113)->setShortcut(QKeySequence()); // Import MED
4064 action( 33)->setEnabled(false); // Delete: Key_Delete
4065 action(1101)->setEnabled(false); // Rename: Key_F2
4067 return SalomeApp_Module::deactivateModule( study );
4070 void SMESHGUI::studyClosed( SUIT_Study* s )
4072 SMESH::RemoveVisuData( s->id() );
4073 SalomeApp_Module::studyClosed( s );
4076 void SMESHGUI::OnGUIEvent()
4078 const QObject* obj = sender();
4079 if ( !obj || !obj->inherits( "QAction" ) )
4081 int id = actionId((QAction*)obj);
4086 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4088 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4089 if ( CORBA::is_nil( myComponentSMESH ) )
4091 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4093 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4094 return aGUI.myComponentSMESH;
4097 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4098 return myComponentSMESH;
4101 QString SMESHGUI::engineIOR() const
4103 CORBA::ORB_var anORB = getApp()->orb();
4104 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4105 return QString( anIOR.in() );
4108 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4110 SalomeApp_Module::contextMenuPopup( client, menu, title );
4112 selectionMgr()->selectedObjects( lst );
4113 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4114 Handle(SALOME_InteractiveObject) io = lst.First();
4115 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4116 _PTR(Study) study = appStudy->studyDS();
4117 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4119 QString aName = QString( obj->GetName().c_str() );
4120 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4121 aName.remove( (aName.length() - 1), 1 );
4127 LightApp_Selection* SMESHGUI::createSelection() const
4129 return new SMESHGUI_Selection();
4132 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4134 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4135 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4138 void SMESHGUI::viewManagers( QStringList& list ) const
4140 list.append( SVTK_Viewer::Type() );
4143 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4145 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4146 SMESH::UpdateSelectionProp( this );
4149 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4151 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4152 myClippingPlaneInfoMap.erase( theViewManager );
4155 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4157 theActor->AddObserver( SMESH::DeleteActorEvent,
4158 myEventCallbackCommand.GetPointer(),
4162 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4163 unsigned long theEvent,
4164 void* theClientData,
4167 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4168 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4169 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4170 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4171 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4172 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4173 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4174 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4175 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4176 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4177 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4178 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4179 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4180 if( anActor == *anIter3 ) {
4181 anActorList.erase( anIter3 );
4192 void SMESHGUI::createPreferences()
4194 // General tab ------------------------------------------------------------------------
4195 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4197 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4198 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4199 setPreferenceProperty( lim, "min", 0 );
4200 setPreferenceProperty( lim, "max", 100000000 );
4201 setPreferenceProperty( lim, "step", 1000 );
4202 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4204 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4205 setPreferenceProperty( qaGroup, "columns", 2 );
4206 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4207 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4208 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4209 setPreferenceProperty( prec, "min", 0 );
4210 setPreferenceProperty( prec, "max", 16 );
4212 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4213 setPreferenceProperty( dispgroup, "columns", 2 );
4214 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4216 modes.append( "Wireframe" );
4217 modes.append( "Shading" );
4218 modes.append( "Nodes" );
4219 modes.append( "Shrink" );
4220 QList<QVariant> indices;
4221 indices.append( 0 );
4222 indices.append( 1 );
4223 indices.append( 2 );
4224 indices.append( 3 );
4225 setPreferenceProperty( dispmode, "strings", modes );
4226 setPreferenceProperty( dispmode, "indexes", indices );
4228 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4229 setPreferenceProperty( arcgroup, "columns", 2 );
4230 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4231 QStringList quadraticModes;
4232 quadraticModes.append("Lines");
4233 quadraticModes.append("Arcs");
4235 indices.append( 0 );
4236 indices.append( 1 );
4237 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4238 setPreferenceProperty( quadraticmode, "indexes", indices );
4240 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4241 "SMESH", "max_angle" );
4242 setPreferenceProperty( maxAngle, "min", 1 );
4243 setPreferenceProperty( maxAngle, "max", 90 );
4247 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4248 setPreferenceProperty( exportgroup, "columns", 2 );
4249 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4250 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4252 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4253 setPreferenceProperty( computeGroup, "columns", 2 );
4254 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4256 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4257 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4258 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4260 indices.append( 0 );
4261 indices.append( 1 );
4262 indices.append( 2 );
4263 setPreferenceProperty( notifyMode, "strings", modes );
4264 setPreferenceProperty( notifyMode, "indexes", indices );
4266 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4267 setPreferenceProperty( computeGroup, "columns", 2 );
4268 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4270 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4271 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4273 indices.append( 0 );
4274 indices.append( 1 );
4275 setPreferenceProperty( elemInfo, "strings", modes );
4276 setPreferenceProperty( elemInfo, "indexes", indices );
4278 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4279 setPreferenceProperty( segGroup, "columns", 2 );
4280 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4281 "SMESH", "segmentation" );
4282 setPreferenceProperty( segLen, "min", 1 );
4283 setPreferenceProperty( segLen, "max", 10000000 );
4284 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4285 "SMESH", "nb_segments_per_edge" );
4286 setPreferenceProperty( nbSeg, "min", 1 );
4287 setPreferenceProperty( nbSeg, "max", 10000000 );
4289 // Quantities with individual precision settings
4290 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4291 setPreferenceProperty( precGroup, "columns", 2 );
4293 const int nbQuantities = 6;
4294 int precs[nbQuantities], ii = 0;
4295 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4296 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4297 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4298 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4299 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4300 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4301 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4302 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4303 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4304 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4305 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4306 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4308 // Set property for precision value for spinboxes
4309 for ( ii = 0; ii < nbQuantities; ii++ ){
4310 setPreferenceProperty( precs[ii], "min", -14 );
4311 setPreferenceProperty( precs[ii], "max", 14 );
4312 setPreferenceProperty( precs[ii], "precision", 2 );
4315 // Mesh tab ------------------------------------------------------------------------
4316 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4317 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4318 setPreferenceProperty( nodeGroup, "columns", 3 );
4320 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4322 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4324 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4325 QList<QVariant> aMarkerTypeIndicesList;
4326 QList<QVariant> aMarkerTypeIconsList;
4327 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4328 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4329 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4330 aMarkerTypeIndicesList << i;
4331 aMarkerTypeIconsList << pixmap;
4333 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4334 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4336 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4338 QList<QVariant> aMarkerScaleIndicesList;
4339 QStringList aMarkerScaleValuesList;
4340 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4341 aMarkerScaleIndicesList << i;
4342 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4344 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4345 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4347 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4348 setPreferenceProperty( elemGroup, "columns", 2 );
4350 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4351 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4352 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4353 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4355 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4356 setPreferenceProperty( grpGroup, "columns", 2 );
4358 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4360 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4361 //setPreferenceProperty( sp, "hstretch", 0 );
4362 //setPreferenceProperty( sp, "vstretch", 0 );
4364 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4365 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4366 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4367 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4368 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4369 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4370 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4372 setPreferenceProperty( size0d, "min", 1 );
4373 setPreferenceProperty( size0d, "max", 10 );
4375 setPreferenceProperty( sp, "hstretch", 0 );
4376 setPreferenceProperty( sp, "vstretch", 0 );
4378 setPreferenceProperty( elemW, "min", 1 );
4379 setPreferenceProperty( elemW, "max", 5 );
4381 setPreferenceProperty( shrink, "min", 0 );
4382 setPreferenceProperty( shrink, "max", 100 );
4384 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4385 setPreferenceProperty( orientGroup, "columns", 1 );
4387 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4388 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4390 setPreferenceProperty( orientScale, "min", 0.05 );
4391 setPreferenceProperty( orientScale, "max", 0.5 );
4392 setPreferenceProperty( orientScale, "step", 0.05 );
4394 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4396 // Selection tab ------------------------------------------------------------------------
4397 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4399 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4400 setPreferenceProperty( selGroup, "columns", 2 );
4402 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4403 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4404 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4406 setPreferenceProperty( selW, "min", 1 );
4407 setPreferenceProperty( selW, "max", 5 );
4409 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4410 setPreferenceProperty( preGroup, "columns", 2 );
4412 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4413 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4415 setPreferenceProperty( preW, "min", 1 );
4416 setPreferenceProperty( preW, "max", 5 );
4418 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4419 setPreferenceProperty( precSelGroup, "columns", 2 );
4421 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4422 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4423 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4425 // Scalar Bar tab ------------------------------------------------------------------------
4426 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4427 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4428 setPreferenceProperty( fontGr, "columns", 2 );
4430 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4431 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4433 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4434 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4436 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4437 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4439 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4440 setPreferenceProperty( numcol, "min", 2 );
4441 setPreferenceProperty( numcol, "max", 256 );
4443 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4444 setPreferenceProperty( numlab, "min", 2 );
4445 setPreferenceProperty( numlab, "max", 65 );
4447 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4448 setPreferenceProperty( orientGr, "columns", 2 );
4449 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4450 QStringList orients;
4451 orients.append( tr( "SMESH_VERTICAL" ) );
4452 orients.append( tr( "SMESH_HORIZONTAL" ) );
4453 indices.clear(); indices.append( 0 ); indices.append( 1 );
4454 setPreferenceProperty( orient, "strings", orients );
4455 setPreferenceProperty( orient, "indexes", indices );
4457 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4458 setPreferenceProperty( posVSizeGr, "columns", 2 );
4459 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4460 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4461 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4462 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4463 setPreferenceProperty( xv, "step", 0.1 );
4464 setPreferenceProperty( xv, "min", 0.0 );
4465 setPreferenceProperty( xv, "max", 1.0 );
4466 setPreferenceProperty( yv, "step", 0.1 );
4467 setPreferenceProperty( yv, "min", 0.0 );
4468 setPreferenceProperty( yv, "max", 1.0 );
4469 setPreferenceProperty( wv, "step", 0.1 );
4470 setPreferenceProperty( wv, "min", 0.0 );
4471 setPreferenceProperty( wv, "max", 1.0 );
4472 setPreferenceProperty( hv, "min", 0.0 );
4473 setPreferenceProperty( hv, "max", 1.0 );
4474 setPreferenceProperty( hv, "step", 0.1 );
4476 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4477 setPreferenceProperty( posHSizeGr, "columns", 2 );
4478 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4479 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4480 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4481 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4482 setPreferenceProperty( xv, "min", 0.0 );
4483 setPreferenceProperty( xv, "max", 1.0 );
4484 setPreferenceProperty( xv, "step", 0.1 );
4485 setPreferenceProperty( xh, "min", 0.0 );
4486 setPreferenceProperty( xh, "max", 1.0 );
4487 setPreferenceProperty( xh, "step", 0.1 );
4488 setPreferenceProperty( yh, "min", 0.0 );
4489 setPreferenceProperty( yh, "max", 1.0 );
4490 setPreferenceProperty( yh, "step", 0.1 );
4491 setPreferenceProperty( wh, "min", 0.0 );
4492 setPreferenceProperty( wh, "max", 1.0 );
4493 setPreferenceProperty( wh, "step", 0.1 );
4494 setPreferenceProperty( hh, "min", 0.0 );
4495 setPreferenceProperty( hh, "max", 1.0 );
4496 setPreferenceProperty( hh, "step", 0.1 );
4498 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4499 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4500 setPreferenceProperty( distributionGr, "columns", 3 );
4502 types.append( tr( "SMESH_MONOCOLOR" ) );
4503 types.append( tr( "SMESH_MULTICOLOR" ) );
4504 indices.clear(); indices.append( 0 ); indices.append( 1 );
4505 setPreferenceProperty( coloringType, "strings", types );
4506 setPreferenceProperty( coloringType, "indexes", indices );
4507 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4511 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4513 if( sect=="SMESH" ) {
4514 float sbX1,sbY1,sbW,sbH;
4515 float aTol = 1.00000009999999;
4516 std::string aWarning;
4517 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4518 if( name=="selection_object_color" || name=="selection_element_color" ||
4519 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4520 name=="selection_precision_node" || name=="selection_precision_element" ||
4521 name=="selection_precision_object")
4522 SMESH::UpdateSelectionProp( this );
4523 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4524 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4525 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4526 if(sbX1+sbW > aTol){
4527 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4530 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4531 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4534 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4535 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4536 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4537 if(sbY1+sbH > aTol){
4538 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4539 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4540 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4543 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4544 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4545 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4546 if(sbX1+sbW > aTol){
4547 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4550 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4551 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4554 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4555 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4556 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4557 if(sbY1+sbH > aTol){
4558 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4561 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4562 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4565 else if ( name == "segmentation" ) {
4566 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4567 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4569 else if ( name == "nb_segments_per_edge" ) {
4570 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4571 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4574 if(aWarning.size() != 0){
4575 aWarning += "The default values are applied instead.";
4576 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4577 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4578 QObject::tr(aWarning.c_str()));
4583 //================================================================================
4585 * \brief Update something in accordance with update flags
4586 * \param theFlags - update flags
4588 * Update viewer or/and object browser etc. in accordance with update flags ( see
4589 * LightApp_UpdateFlags enumeration ).
4591 //================================================================================
4592 void SMESHGUI::update( const int flags )
4594 if ( flags & UF_Viewer | flags & UF_Forced )
4595 SMESH::UpdateView();
4597 SalomeApp_Module::update( flags );
4600 //================================================================================
4602 * \brief Set default selection mode
4604 * SLOT called when operation commited. Sets default selection mode
4606 //================================================================================
4607 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4609 SVTK_ViewWindow* vtkWnd =
4610 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4612 vtkWnd->SetSelectionMode( ActorSelection );
4615 //================================================================================
4617 * \brief Set default selection mode
4619 * SLOT called when operation aborted. Sets default selection mode
4621 //================================================================================
4622 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4624 SVTK_ViewWindow* vtkWnd =
4625 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4627 vtkWnd->SetSelectionMode( ActorSelection );
4630 //================================================================================
4632 * \brief Creates operation with given identifier
4633 * \param id - identifier of operation to be started
4634 * \return Pointer on created operation or NULL if operation is not created
4636 * Virtual method redefined from the base class creates operation with given id.
4637 * It is called called automatically from startOperation method of base class.
4639 //================================================================================
4640 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4642 LightApp_Operation* op = 0;
4643 // to do : create operation here
4646 case 417: //convert to quadratic
4647 op = new SMESHGUI_ConvToQuadOp();
4649 case 418: // create 2D mesh as boundary on 3D
4650 op = new SMESHGUI_Make2DFrom3DOp();
4652 case 701: // Compute mesh
4653 op = new SMESHGUI_ComputeOp();
4655 case 702: // Create mesh
4656 op = new SMESHGUI_MeshOp( true, true );
4658 case 703: // Create sub-mesh
4659 op = new SMESHGUI_MeshOp( true, false );
4661 case 704: // Edit mesh/sub-mesh
4662 op = new SMESHGUI_MeshOp( false );
4664 case 711: // Precompute mesh
4665 op = new SMESHGUI_PrecomputeOp();
4667 case 712: // Evaluate mesh
4668 op = new SMESHGUI_EvaluateOp();
4670 case 713: // Evaluate mesh
4671 op = new SMESHGUI_MeshOrderOp();
4673 case 806: // Create group on geom
4674 op = new SMESHGUI_GroupOnShapeOp();
4676 case 904: // Find element
4677 op = new SMESHGUI_FindElemByPointOp();
4679 case 4067: // make mesh pass through point
4680 op = new SMESHGUI_MakeNodeAtPointOp();
4687 op = SalomeApp_Module::createOperation( id );
4691 //================================================================================
4693 * \brief Stops current operations and starts a given one
4694 * \param id - The id of the operation to start
4696 //================================================================================
4698 void SMESHGUI::switchToOperation(int id)
4700 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4701 activeStudy()->abortAllOperations();
4702 startOperation( id );
4705 LightApp_Displayer* SMESHGUI::displayer()
4708 myDisplayer = new SMESHGUI_Displayer( getApp() );
4712 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4715 int aTolerance = 64;
4716 int anIterations = 0;
4722 if( anIterations % aPeriod == 0 )
4725 if( aTolerance < 1 )
4729 aHue = (int)( 360.0 * rand() / RAND_MAX );
4732 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4733 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4734 for( ; it != itEnd; ++it )
4736 SALOMEDS::Color anAutoColor = *it;
4737 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4740 aQColor.getHsv( &h, &s, &v );
4741 if( abs( h - aHue ) < aTolerance )
4753 aColor.setHsv( aHue, 255, 255 );
4755 SALOMEDS::Color aSColor;
4756 aSColor.R = (double)aColor.red() / 255.0;
4757 aSColor.G = (double)aColor.green() / 255.0;
4758 aSColor.B = (double)aColor.blue() / 255.0;
4763 const char gSeparator = '_'; // character used to separate parameter names
4764 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4765 const char gPathSep = '|'; // character used to separate paths
4768 * \brief Store visual parameters
4770 * This method is called just before the study document is saved.
4771 * Store visual parameters in AttributeParameter attribue(s)
4773 void SMESHGUI::storeVisualParameters (int savePoint)
4775 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4776 if (!appStudy || !appStudy->studyDS())
4778 _PTR(Study) studyDS = appStudy->studyDS();
4780 // componentName is used for encoding of entries when storing them in IParameters
4781 std::string componentName = myComponentSMESH->ComponentDataType();
4782 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4783 //if (!aSComponent) return;
4786 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4787 componentName.c_str(),
4789 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4791 // store map of custom markers
4792 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4793 if( !aMarkerMap.empty() )
4795 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4796 for( ; anIter != aMarkerMap.end(); anIter++ )
4798 int anId = anIter->first;
4799 VTK::MarkerData aMarkerData = anIter->second;
4800 std::string aMarkerFileName = aMarkerData.first;
4801 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4802 if( aMarkerTexture.size() < 3 )
4803 continue; // should contain at least width, height and the first value
4805 QString aPropertyName( "texture" );
4806 aPropertyName += gSeparator;
4807 aPropertyName += QString::number( anId );
4809 QString aPropertyValue = aMarkerFileName.c_str();
4810 aPropertyValue += gPathSep;
4812 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4813 ushort aWidth = *aTextureIter++;
4814 ushort aHeight = *aTextureIter++;
4815 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4816 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4817 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4818 aPropertyValue += QString::number( *aTextureIter );
4820 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4824 // viewers counters are used for storing view_numbers in IParameters
4827 // main cycle to store parameters of displayed objects
4828 QList<SUIT_ViewManager*> lst;
4829 QList<SUIT_ViewManager*>::Iterator it;
4830 getApp()->viewManagers(lst);
4831 for (it = lst.begin(); it != lst.end(); it++)
4833 SUIT_ViewManager* vman = *it;
4834 QString vType = vman->getType();
4836 // saving VTK actors properties
4837 if (vType == SVTK_Viewer::Type())
4839 // store the clipping planes attached to the view manager
4840 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4841 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4842 if( anIter != myClippingPlaneInfoMap.end() )
4843 aClippingPlaneInfoList = anIter->second;
4845 if( !aClippingPlaneInfoList.empty() ) {
4846 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4847 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4849 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4850 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4852 QString aPropertyName( "ClippingPlane" );
4853 aPropertyName += gSeparator;
4854 aPropertyName += QString::number( vtkViewers );
4855 aPropertyName += gSeparator;
4856 aPropertyName += QString::number( anId );
4858 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4859 aPropertyValue += gDigitsSep;
4860 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4861 aPropertyValue += gDigitsSep;
4862 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4863 aPropertyValue += gDigitsSep;
4864 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4866 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4870 QVector<SUIT_ViewWindow*> views = vman->getViews();
4871 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4873 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4875 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4876 vtkActorCollection* allActors = aCopy.GetActors();
4877 allActors->InitTraversal();
4878 while (vtkActor* actor = allActors->GetNextActor())
4880 if (actor->GetVisibility()) // store only visible actors
4882 SMESH_Actor* aSmeshActor = 0;
4883 if (actor->IsA("SMESH_Actor"))
4884 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4885 if (aSmeshActor && aSmeshActor->hasIO())
4887 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4890 // entry is "encoded" = it does NOT contain component adress,
4891 // since it is a subject to change on next component loading
4892 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4894 std::string param, vtkParam = vType.toLatin1().data();
4895 vtkParam += gSeparator;
4896 vtkParam += QString::number(vtkViewers).toLatin1().data();
4897 vtkParam += gSeparator;
4900 param = vtkParam + "Visibility";
4901 ip->setParameter(entry, param, "On");
4904 param = vtkParam + "Representation";
4905 ip->setParameter(entry, param, QString::number
4906 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4909 param = vtkParam + "IsShrunk";
4910 ip->setParameter(entry, param, QString::number
4911 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4913 // Displayed entities
4914 unsigned int aMode = aSmeshActor->GetEntityMode();
4915 bool isE = aMode & SMESH_Actor::eEdges;
4916 bool isF = aMode & SMESH_Actor::eFaces;
4917 bool isV = aMode & SMESH_Actor::eVolumes;
4919 QString modeStr ("e");
4920 modeStr += gDigitsSep; modeStr += QString::number(isE);
4921 modeStr += gDigitsSep; modeStr += "f";
4922 modeStr += gDigitsSep; modeStr += QString::number(isF);
4923 modeStr += gDigitsSep; modeStr += "v";
4924 modeStr += gDigitsSep; modeStr += QString::number(isV);
4926 param = vtkParam + "Entities";
4927 ip->setParameter(entry, param, modeStr.toLatin1().data());
4929 // Colors (surface:edge:)
4930 vtkFloatingPointType r, g, b;
4932 aSmeshActor->GetSufaceColor(r, g, b);
4933 QString colorStr ("surface");
4934 colorStr += gDigitsSep; colorStr += QString::number(r);
4935 colorStr += gDigitsSep; colorStr += QString::number(g);
4936 colorStr += gDigitsSep; colorStr += QString::number(b);
4938 aSmeshActor->GetBackSufaceColor(r, g, b);
4939 colorStr += gDigitsSep; colorStr += "backsurface";
4940 colorStr += gDigitsSep; colorStr += QString::number(r);
4941 colorStr += gDigitsSep; colorStr += QString::number(g);
4942 colorStr += gDigitsSep; colorStr += QString::number(b);
4944 aSmeshActor->GetEdgeColor(r, g, b);
4945 colorStr += gDigitsSep; colorStr += "edge";
4946 colorStr += gDigitsSep; colorStr += QString::number(r);
4947 colorStr += gDigitsSep; colorStr += QString::number(g);
4948 colorStr += gDigitsSep; colorStr += QString::number(b);
4950 aSmeshActor->GetNodeColor(r, g, b);
4951 colorStr += gDigitsSep; colorStr += "node";
4952 colorStr += gDigitsSep; colorStr += QString::number(r);
4953 colorStr += gDigitsSep; colorStr += QString::number(g);
4954 colorStr += gDigitsSep; colorStr += QString::number(b);
4956 param = vtkParam + "Colors";
4957 ip->setParameter(entry, param, colorStr.toLatin1().data());
4959 // Sizes of lines and points
4960 QString sizeStr ("line");
4961 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4962 sizeStr += gDigitsSep; sizeStr += "shrink";
4963 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4965 param = vtkParam + "Sizes";
4966 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4971 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4972 if( aMarkerType == VTK::MT_USER ) {
4973 markerStr += "custom";
4974 markerStr += gDigitsSep;
4975 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4979 markerStr += gDigitsSep;
4980 markerStr += QString::number( (int)aMarkerType );
4981 markerStr += gDigitsSep;
4982 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4985 param = vtkParam + "PointMarker";
4986 ip->setParameter(entry, param, markerStr.toLatin1().data());
4989 param = vtkParam + "Opacity";
4990 ip->setParameter(entry, param,
4991 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4994 param = vtkParam + "ClippingPlane";
4996 if( !aClippingPlaneInfoList.empty() ) {
4997 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4998 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5000 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5001 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5002 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5003 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5004 if( aSmeshActor == *anIter2 ) {
5005 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5006 QString::number( anId ).toLatin1().constData() );
5013 ip->setParameter( entry, param, "Off" );
5014 } // if (io->hasEntry())
5015 } // SMESH_Actor && hasIO
5017 } // while.. actors traversal
5021 } // if (SVTK view model)
5022 } // for (viewManagers)
5025 // data structures for clipping planes processing
5028 vtkIdType Orientation;
5029 vtkFloatingPointType Distance;
5030 vtkFloatingPointType Angle[2];
5032 typedef std::list<TPlaneData> TPlaneDataList;
5033 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5035 typedef std::list<vtkActor*> TActorList;
5038 TActorList ActorList;
5039 SUIT_ViewManager* ViewManager;
5041 typedef std::list<TPlaneInfo> TPlaneInfoList;
5042 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5045 * \brief Restore visual parameters
5047 * This method is called after the study document is opened.
5048 * Restore visual parameters from AttributeParameter attribue(s)
5050 void SMESHGUI::restoreVisualParameters (int savePoint)
5052 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5053 if (!appStudy || !appStudy->studyDS())
5055 _PTR(Study) studyDS = appStudy->studyDS();
5057 // componentName is used for encoding of entries when storing them in IParameters
5058 std::string componentName = myComponentSMESH->ComponentDataType();
5059 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5060 //if (!aSComponent) return;
5063 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5064 componentName.c_str(),
5066 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5068 // restore map of custom markers and map of clipping planes
5069 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5070 TPlaneDataMap aPlaneDataMap;
5072 std::vector<std::string> properties = ip->getProperties();
5073 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5075 std::string property = *propIt;
5076 QString aPropertyName( property.c_str() );
5077 QString aPropertyValue( ip->getProperty( property ).c_str() );
5079 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5080 if( aPropertyNameList.isEmpty() )
5083 QString aPropertyType = aPropertyNameList[0];
5084 if( aPropertyType == "texture" )
5086 if( aPropertyNameList.size() != 2 )
5090 int anId = aPropertyNameList[1].toInt( &ok );
5091 if( !ok || anId < 1 )
5094 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5095 if( aPropertyValueList.size() != 2 )
5098 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5099 QString aMarkerTextureString = aPropertyValueList[1];
5100 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5101 if( aMarkerTextureStringList.size() != 3 )
5105 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5110 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5114 VTK::MarkerTexture aMarkerTexture;
5115 aMarkerTexture.push_back( aWidth );
5116 aMarkerTexture.push_back( aHeight );
5118 QString aMarkerTextureData = aMarkerTextureStringList[2];
5119 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5121 QChar aChar = aMarkerTextureData.at( i );
5122 if( aChar.isDigit() )
5123 aMarkerTexture.push_back( aChar.digitValue() );
5126 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5128 else if( aPropertyType == "ClippingPlane" )
5130 if( aPropertyNameList.size() != 3 )
5134 int aViewId = aPropertyNameList[1].toInt( &ok );
5135 if( !ok || aViewId < 0 )
5139 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5140 if( !ok || aClippingPlaneId < 0 )
5143 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5144 if( aPropertyValueList.size() != 4 )
5147 TPlaneData aPlaneData;
5148 aPlaneData.Id = aClippingPlaneId;
5151 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5156 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5161 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5166 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5170 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5171 aPlaneDataList.push_back( aPlaneData );
5175 TPlaneInfoMap aPlaneInfoMap;
5177 std::vector<std::string> entries = ip->getEntries();
5179 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5181 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5182 QString entry (ip->decodeEntry(*entIt).c_str());
5184 // Check that the entry corresponds to a real object in the Study
5185 // as the object may be deleted or modified after the visual state is saved.
5186 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5187 if (!so) continue; //Skip the not existent entry
5189 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5190 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5192 std::vector<std::string>::iterator namesIt = paramNames.begin();
5193 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5195 // actors are stored in a map after displaying of them for
5196 // quicker access in the future: map < viewID to actor >
5197 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5199 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5201 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5202 // '_' is used as separator and should not be used in viewer type or parameter names.
5203 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5204 if (lst.size() != 3)
5207 QString viewerTypStr = lst[0];
5208 QString viewIndexStr = lst[1];
5209 QString paramNameStr = lst[2];
5212 int viewIndex = viewIndexStr.toUInt(&ok);
5213 if (!ok) // bad conversion of view index to integer
5217 if (viewerTypStr == SVTK_Viewer::Type())
5219 SMESH_Actor* aSmeshActor = 0;
5220 if (vtkActors.IsBound(viewIndex))
5221 aSmeshActor = vtkActors.Find(viewIndex);
5223 QList<SUIT_ViewManager*> lst;
5224 getApp()->viewManagers(viewerTypStr, lst);
5226 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5227 SUIT_ViewManager* vman = NULL;
5228 if (viewIndex >= 0 && viewIndex < lst.count())
5229 vman = lst.at(viewIndex);
5231 if (paramNameStr == "Visibility")
5233 if (!aSmeshActor && displayer() && vman)
5235 SUIT_ViewModel* vmodel = vman->getViewModel();
5236 // SVTK view model can be casted to SALOME_View
5237 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5239 // store displayed actor in a temporary map for quicker
5240 // access later when restoring other parameters
5241 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5242 vtkRenderer* Renderer = vtkView->getRenderer();
5243 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5244 vtkActorCollection* theActors = aCopy.GetActors();
5245 theActors->InitTraversal();
5246 bool isFound = false;
5247 vtkActor *ac = theActors->GetNextActor();
5248 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5249 if (ac->IsA("SMESH_Actor")) {
5250 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5251 if (aGeomAc->hasIO()) {
5252 Handle(SALOME_InteractiveObject) io =
5253 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5254 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5256 vtkActors.Bind(viewIndex, aGeomAc);
5262 } // if (paramNameStr == "Visibility")
5265 // the rest properties "work" with SMESH_Actor
5268 QString val ((*valuesIt).c_str());
5271 if (paramNameStr == "Representation") {
5272 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5275 else if (paramNameStr == "IsShrunk") {
5277 if (!aSmeshActor->IsShrunk())
5278 aSmeshActor->SetShrink();
5281 if (aSmeshActor->IsShrunk())
5282 aSmeshActor->UnShrink();
5285 // Displayed entities
5286 else if (paramNameStr == "Entities") {
5287 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5288 if (mode.count() == 6) {
5289 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5290 MESSAGE("Invalid order of data in Entities, must be: "
5291 "e:0/1:f:0/1:v:0/1");
5294 unsigned int aMode = aSmeshActor->GetEntityMode();
5295 unsigned int aNewMode =
5296 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5297 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5298 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5299 if (aNewMode != aMode)
5300 aSmeshActor->SetEntityMode(aNewMode);
5305 else if (paramNameStr == "Colors") {
5306 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5307 if (colors.count() == 16) {
5308 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5309 colors[8] != "edge" || colors[12] != "node") {
5310 MESSAGE("Invalid order of data in Colors, must be: "
5311 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5314 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5315 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5316 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5317 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5321 // Sizes of lines and points
5322 else if (paramNameStr == "Sizes") {
5323 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5324 if (sizes.count() == 4) {
5325 if (sizes[0] != "line" || sizes[2] != "shrink") {
5326 MESSAGE("Invalid order of data in Sizes, must be: "
5327 "line:int:shrink:float");
5330 aSmeshActor->SetLineWidth(sizes[1].toInt());
5331 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5334 else if (sizes.count() == 6) { // just to support old format
5335 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5336 MESSAGE("Invalid order of data in Sizes, must be: "
5337 "line:int:node:int:shrink:float");
5340 aSmeshActor->SetLineWidth(sizes[1].toInt());
5341 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5342 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5347 else if (paramNameStr == "PointMarker") {
5348 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5349 if( data.count() >= 2 ) {
5351 int aParam1 = data[1].toInt( &ok );
5353 if( data[0] == "std" && data.count() == 3 ) {
5354 int aParam2 = data[2].toInt( &ok );
5355 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5357 else if( data[0] == "custom" ) {
5358 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5359 if( markerIt != aMarkerMap.end() ) {
5360 VTK::MarkerData aMarkerData = markerIt->second;
5361 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5368 else if (paramNameStr == "Opacity") {
5369 aSmeshActor->SetOpacity(val.toFloat());
5372 else if (paramNameStr.startsWith("ClippingPlane")) {
5373 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5374 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5375 // new format - val looks like "Off" or "0" (plane id)
5376 // (note: in new format "Off" value is used only for consistency,
5377 // so it is processed together with values in old format)
5378 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5379 if( anIsOldFormat ) {
5380 if (paramNameStr == "ClippingPlane1" || val == "Off")
5381 aSmeshActor->RemoveAllClippingPlanes();
5383 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5384 double aDistance = vals[1].toFloat();
5385 vtkFloatingPointType anAngle[2];
5386 anAngle[0] = vals[2].toFloat();
5387 anAngle[1] = vals[3].toFloat();
5389 QList<SUIT_ViewManager*> lst;
5390 getApp()->viewManagers(viewerTypStr, lst);
5391 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5392 if (viewIndex >= 0 && viewIndex < lst.count()) {
5393 SUIT_ViewManager* vman = lst.at(viewIndex);
5394 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5396 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5398 SMESH::TActorList anActorList;
5399 anActorList.push_back( aSmeshActor );
5400 SMESH::OrientedPlane* aPlane =
5401 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5403 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5404 aClippingPlaneInfo.Plane = aPlane;
5405 aClippingPlaneInfo.ActorList = anActorList;
5406 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5413 int aPlaneId = val.toInt( &ok );
5414 if( ok && aPlaneId >= 0 ) {
5415 bool anIsDefinedPlane = false;
5416 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5417 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5418 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5419 TPlaneInfo& aPlaneInfo = *anIter;
5420 if( aPlaneInfo.PlaneId == aPlaneId ) {
5421 aPlaneInfo.ActorList.push_back( aSmeshActor );
5422 anIsDefinedPlane = true;
5426 if( !anIsDefinedPlane ) {
5427 TPlaneInfo aPlaneInfo;
5428 aPlaneInfo.PlaneId = aPlaneId;
5429 aPlaneInfo.ActorList.push_back( aSmeshActor );
5430 aPlaneInfo.ViewManager = vman;
5431 aPlaneInfoList.push_back( aPlaneInfo );
5436 } // if (aSmeshActor)
5437 } // other parameters than Visibility
5439 } // for names/parameters iterator
5440 } // for entries iterator
5442 // add clipping planes to actors according to the restored parameters
5443 // and update the clipping plane map
5444 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5445 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5446 int aViewId = anIter1->first;
5447 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5449 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5450 if( anIter2 == aPlaneDataMap.end() )
5452 const TPlaneDataList& aPlaneDataList = anIter2->second;
5454 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5455 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5456 const TPlaneInfo& aPlaneInfo = *anIter3;
5457 int aPlaneId = aPlaneInfo.PlaneId;
5458 const TActorList& anActorList = aPlaneInfo.ActorList;
5459 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5463 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5467 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5469 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5470 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5471 const TPlaneData& aPlaneData = *anIter4;
5472 if( aPlaneData.Id == aPlaneId ) {
5473 SMESH::OrientedPlane* aPlane =
5474 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5476 (SMESH::Orientation)aPlaneData.Orientation,
5477 aPlaneData.Distance,
5480 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5481 aClippingPlaneInfo.Plane = aPlane;
5482 aClippingPlaneInfo.ActorList = anActorList;
5483 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5491 // update all VTK views
5492 QList<SUIT_ViewManager*> lst;
5493 getApp()->viewManagers(lst);
5494 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5495 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5496 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5497 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5498 vtkView->getRenderer()->ResetCameraClippingRange();
5505 \brief Adds preferences for dfont of VTK viewer
5507 \param pIf group identifier
5508 \param param parameter
5509 \return identifier of preferences
5511 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5513 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5515 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5518 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5519 fam.append( tr( "SMESH_FONT_COURIER" ) );
5520 fam.append( tr( "SMESH_FONT_TIMES" ) );
5522 setPreferenceProperty( tfont, "fonts", fam );
5524 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5525 setPreferenceProperty( tfont, "features", f );
5531 \brief Actions after hypothesis edition
5532 Updates object browser after hypothesis edition
5534 void SMESHGUI::onHypothesisEdit( int result )
5537 SMESHGUI::Modified();
5538 updateObjBrowser( true );