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.
28 #include "SMESHGUI_AddMeshElementDlg.h"
29 #include "SMESHGUI_AddQuadraticElementDlg.h"
30 #include "SMESHGUI_BuildCompoundDlg.h"
31 #include "SMESHGUI_ClippingDlg.h"
32 #include "SMESHGUI_ComputeDlg.h"
33 #include "SMESHGUI_ConvToQuadOp.h"
34 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
35 #include "SMESHGUI_DeleteGroupDlg.h"
36 #include "SMESHGUI_Displayer.h"
37 #include "SMESHGUI_MergeDlg.h"
38 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
39 #include "SMESHGUI_ExtrusionDlg.h"
40 #include "SMESHGUI_FileInfoDlg.h"
41 #include "SMESHGUI_FileValidator.h"
42 #include "SMESHGUI_FilterDlg.h"
43 #include "SMESHGUI_FilterLibraryDlg.h"
44 #include "SMESHGUI_FindElemByPointDlg.h"
45 #include "SMESHGUI_GroupDlg.h"
46 #include "SMESHGUI_GroupOnShapeDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_Hypotheses.h"
49 #include "SMESHGUI_Make2DFrom3DOp.h"
50 #include "SMESHGUI_MakeNodeAtPointDlg.h"
51 //#include "SMESHGUI_MeshInfosDlg.h"
52 #include "SMESHGUI_MeshInfo.h"
53 #include "SMESHGUI_MeshOp.h"
54 #include "SMESHGUI_MeshOrderOp.h"
55 #include "SMESHGUI_MeshPatternDlg.h"
56 #include "SMESHGUI_MultiEditDlg.h"
57 #include "SMESHGUI_NodesDlg.h"
58 #include "SMESHGUI_Preferences_ColorDlg.h"
59 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
60 #include "SMESHGUI_RemoveElementsDlg.h"
61 #include "SMESHGUI_RemoveNodesDlg.h"
62 #include "SMESHGUI_RenumberingDlg.h"
63 #include "SMESHGUI_RevolutionDlg.h"
64 #include "SMESHGUI_RotationDlg.h"
65 #include "SMESHGUI_Selection.h"
66 #include "SMESHGUI_SewingDlg.h"
67 #include "SMESHGUI_SingleEditDlg.h"
68 #include "SMESHGUI_SmoothingDlg.h"
69 //#include "SMESHGUI_StandardMeshInfosDlg.h"
70 #include "SMESHGUI_SymmetryDlg.h"
71 #include "SMESHGUI_TranslationDlg.h"
72 #include "SMESHGUI_ScaleDlg.h"
73 #include "SMESHGUI_TransparencyDlg.h"
74 //#include "SMESHGUI_WhatIsDlg.h"
75 #include "SMESHGUI_DuplicateNodesDlg.h"
77 #include "SMESHGUI_Utils.h"
78 #include "SMESHGUI_MeshUtils.h"
79 #include "SMESHGUI_GroupUtils.h"
80 #include "SMESHGUI_FilterUtils.h"
81 #include "SMESHGUI_PatternUtils.h"
82 #include "SMESHGUI_VTKUtils.h"
83 #include "SMESHGUI_HypothesesUtils.h"
85 #include <SMESH_Client.hxx>
86 #include <SMESH_Actor.h>
87 #include <SMESH_TypeFilter.hxx>
88 #include "SMESH_ControlsDef.hxx"
90 // SALOME GUI includes
91 #include <SalomeApp_Tools.h>
92 #include <SalomeApp_Study.h>
93 #include <SalomeApp_Application.h>
94 #include <SalomeApp_CheckFileDlg.h>
96 #include <LightApp_DataOwner.h>
97 #include <LightApp_Preferences.h>
98 #include <LightApp_SelectionMgr.h>
99 #include <LightApp_UpdateFlags.h>
100 #include <LightApp_NameDlg.h>
102 #include <SVTK_ViewWindow.h>
103 #include <SVTK_ViewModel.h>
104 #include <SVTK_ViewManager.h>
106 #include <VTKViewer_Algorithm.h>
108 #include <SUIT_MessageBox.h>
109 #include <SUIT_ResourceMgr.h>
110 #include <SUIT_FileDlg.h>
111 #include <SUIT_Desktop.h>
112 #include <SUIT_OverrideCursor.h>
113 #include <SUIT_Session.h>
115 #include <QtxPopupMgr.h>
116 #include <QtxFontEdit.h>
118 #include <SALOME_ListIO.hxx>
119 #include <SALOME_ListIteratorOfListIO.hxx>
122 #include <SALOMEconfig.h>
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
125 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
128 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
130 #include <QTextStream>
133 #include <boost/shared_ptr.hpp>
136 #include <vtkScalarBarActor.h>
137 #include <vtkCamera.h>
138 #include <vtkRenderer.h>
139 #include <vtkPlane.h>
140 #include <vtkCallbackCommand.h>
142 // SALOME KERNEL includes
143 #include <SALOMEDS_Study.hxx>
144 #include <SALOMEDSClient_StudyBuilder.hxx>
145 #include <SALOMEDSClient_SComponent.hxx>
146 #include <SALOMEDSClient_ClientFactory.hxx>
147 #include <SALOMEDSClient_IParameters.hxx>
150 #include <Standard_ErrorHandler.hxx>
151 #include <NCollection_DataMap.hxx>
153 //To disable automatic genericobj management, the following line should be commented.
154 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
155 #define WITHGENERICOBJ
159 //=============================================================
160 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
163 void ExportMeshToFile(int theCommandID);
165 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
167 void SetDisplayEntity(int theCommandID);
169 void Control( int theCommandID );
173 //=============================================================
174 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
178 std::string myExtension;
180 if ( theCommandID == 113 ) {
181 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
182 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
184 else if ( theCommandID == 112 ) {
185 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
187 else if ( theCommandID == 111 ) {
188 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
191 QString anInitialPath = "";
192 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
193 anInitialPath = QDir::currentPath();
195 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
198 QObject::tr( "SMESH_IMPORT_MESH" ) );
199 if ( filenames.count() > 0 ) {
200 SUIT_OverrideCursor wc;
201 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
204 bool isEmpty = false;
205 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
206 QString filename = *it;
207 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
209 switch ( theCommandID ) {
212 // DAT format (currently unsupported)
213 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
214 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
220 aMeshes->length( 1 );
221 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
222 if ( aMeshes[0]->_is_nil() )
223 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
224 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
230 SMESH::DriverMED_ReadStatus res;
231 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
232 if ( res != SMESH::DRS_OK ) {
233 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
234 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
240 catch ( const SALOME::SALOME_Exception& S_ex ) {
241 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
242 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
245 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
246 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
248 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
249 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
250 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
251 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
252 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
254 #ifdef WITHGENERICOBJ
255 // obj has been published in study. Its refcount has been incremented.
256 // It is safe to decrement its refcount
257 // so that it will be destroyed when the entry in study will be removed
258 aMeshes[i]->Destroy();
267 // update Object browser
268 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
270 // show Error message box if there were errors
271 if ( errors.count() > 0 ) {
272 SUIT_MessageBox::critical( SMESHGUI::desktop(),
273 QObject::tr( "SMESH_ERROR" ),
274 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
277 // show warning message box, if some imported mesh is empty
279 SUIT_MessageBox::warning( SMESHGUI::desktop(),
280 QObject::tr( "SMESH_WRN_WARNING" ),
281 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
286 void ExportMeshToFile( int theCommandID )
288 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
289 SALOME_ListIO selected;
291 aSel->selectedObjects( selected );
293 // actually, the following condition can't be met (added for insurance)
294 if( selected.Extent() == 0 ||
295 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
298 bool hasDuplicatedMeshNames = false;
299 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
300 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
301 SALOME_ListIteratorOfListIO It( selected );
302 for( ; It.More(); It.Next() ) {
303 Handle(SALOME_InteractiveObject) anIObject = It.Value();
304 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
305 if ( aMeshItem->_is_nil() ) {
306 SUIT_MessageBox::warning( SMESHGUI::desktop(),
307 QObject::tr( "SMESH_WRN_WARNING" ),
308 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
312 QString aMeshName = anIObject->getName();
314 // check for duplications
315 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
316 if( aMeshName == (*aMeshIter).second ) {
317 hasDuplicatedMeshNames = true;
322 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
325 if( hasDuplicatedMeshNames ) {
326 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
327 QObject::tr("SMESH_WRN_WARNING"),
328 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
329 QObject::tr("SMESH_BUT_YES"),
330 QObject::tr("SMESH_BUT_NO"), 0, 1);
335 aMeshIter = aMeshList.begin();
336 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
337 QString aMeshName = (*aMeshIter).second;
339 QList<SALOMEDS::Color> aReservedColors;
341 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
342 QMap<QString, SMESH::MED_VERSION> aFilterMap;
343 QMap<QString, int> aFilterMapSTL;
344 switch ( theCommandID ) {
348 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
349 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
350 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
351 int aRet = SUIT_MessageBox::warning
352 (SMESHGUI::desktop(),
353 QObject::tr("SMESH_WRN_WARNING"),
354 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
355 QObject::tr("SMESH_BUT_YES"),
356 QObject::tr("SMESH_BUT_NO"), 0, 1);
362 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
363 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
364 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
365 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
370 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
375 if (aMesh->NbPyramids()) {
376 int aRet = SUIT_MessageBox::warning
377 (SMESHGUI::desktop(),
378 QObject::tr("SMESH_WRN_WARNING"),
379 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
380 QObject::tr("SMESH_BUT_YES"),
381 QObject::tr("SMESH_BUT_NO"), 0, 1);
385 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
393 there must be check on others mesh elements not equal triangles
395 if (aMesh->NbTriangles() < 1) {
396 SUIT_MessageBox::warning
397 (SMESHGUI::desktop(),
398 QObject::tr("SMESH_WRN_WARNING"),
399 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
402 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
403 int aRet = SUIT_MessageBox::warning
404 (SMESHGUI::desktop(),
405 QObject::tr("SMESH_WRN_WARNING"),
406 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
407 QObject::tr("SMESH_BUT_YES"),
408 QObject::tr("SMESH_BUT_NO"), 0, 1);
413 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
414 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
422 SMESH::MED_VERSION aFormat;
423 // Init the parameter with the default value
424 bool aIsASCII_STL = true;
425 bool toCreateGroups = false;
426 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
428 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
429 bool toOverwrite = true;
431 QString anInitialPath = "";
432 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
433 anInitialPath = QDir::currentPath();
435 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
436 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
437 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
438 aFilter, aTitle, false);
440 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
442 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
443 for ( ; it != aFilterMapSTL.end(); ++it )
444 filters.push_back( it.key() );
446 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
447 fd->setWindowTitle( aTitle );
448 fd->setNameFilters( filters );
449 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
450 if ( !anInitialPath.isEmpty() )
451 fd->setDirectory( anInitialPath );
452 fd->selectFile(aMeshName);
456 aFilename = fd->selectedFile();
457 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
462 else { // Export to MED
464 QString aDefaultFilter;
465 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
466 for ( ; it != aFilterMap.end(); ++it ) {
467 filters.push_back( it.key() );
468 if (it.value() == SMESH::MED_V2_2)
469 aDefaultFilter = it.key();
472 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
473 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
474 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
475 fd->setWindowTitle( aTitle );
476 fd->setNameFilters( filters );
477 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
478 fd->selectNameFilter(aDefaultFilter);
479 fd->SetChecked(toCreateGroups);
480 if ( !anInitialPath.isEmpty() )
481 fd->setDirectory( anInitialPath );
482 fd->selectFile(aMeshName);
484 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
485 fd->setValidator( fv );
490 aFilename = fd->selectedFile();
492 aFilename = QString::null;
495 aFormat = aFilterMap[fd->selectedNameFilter()];
496 toOverwrite = fv->isOverwrite();
498 if ( !aFilename.isEmpty() ) {
499 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
500 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
501 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
502 && aFormat==SMESH::MED_V2_1) {
503 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
504 QObject::tr("SMESH_WRN_WARNING"),
505 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
506 QObject::tr("SMESH_BUT_YES"),
507 QObject::tr("SMESH_BUT_NO"), 0, 1);
515 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
516 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
517 if( !isVersionOk || aVersion != aFormat ) {
518 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
519 QObject::tr("SMESH_WRN_WARNING"),
520 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
521 QObject::tr("SMESH_BUT_YES"),
522 QObject::tr("SMESH_BUT_NO"), 0, 1);
529 QStringList aMeshNamesCollisionList;
530 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
531 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
532 QString anExistingMeshName( aMeshNames[ i ] );
533 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
534 QString anExportMeshName = (*aMeshIter).second;
535 if( anExportMeshName == anExistingMeshName ) {
536 aMeshNamesCollisionList.append( anExportMeshName );
542 if( !aMeshNamesCollisionList.isEmpty() ) {
543 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
544 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
545 QObject::tr("SMESH_WRN_WARNING"),
546 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
547 QObject::tr("SMESH_BUT_YES"),
548 QObject::tr("SMESH_BUT_NO"),
549 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
558 toCreateGroups = fd->IsChecked();
561 if ( !aFilename.isEmpty() ) {
562 // Check whether the file already exists and delete it if yes
563 QFile aFile( aFilename );
564 if ( aFile.exists() && toOverwrite )
566 SUIT_OverrideCursor wc;
569 bool Renumber = false;
570 // PAL 14172 : Check of we have to renumber or not from the preferences before export
572 Renumber= resMgr->booleanValue("SMESH","renumbering");
574 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
575 aMeshEditor->RenumberNodes();
576 aMeshEditor->RenumberElements();
577 if ( SMESHGUI::automaticUpdate() )
580 switch ( theCommandID ) {
584 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
585 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
586 if( !aMeshItem->_is_nil() )
587 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
593 aMesh->ExportDAT( aFilename.toLatin1().data() );
597 aMesh->ExportUNV( aFilename.toLatin1().data() );
601 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
607 catch (const SALOME::SALOME_Exception& S_ex){
609 SUIT_MessageBox::warning(SMESHGUI::desktop(),
610 QObject::tr("SMESH_WRN_WARNING"),
611 QObject::tr("SMESH_EXPORT_FAILED"));
617 inline void InverseEntityMode(unsigned int& theOutputMode,
618 unsigned int theMode)
620 bool anIsNotPresent = ~theOutputMode & theMode;
622 theOutputMode |= theMode;
624 theOutputMode &= ~theMode;
627 void SetDisplayEntity(int theCommandID){
628 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
629 SALOME_ListIO selected;
631 aSel->selectedObjects( selected );
633 if(selected.Extent() >= 1){
634 SALOME_ListIteratorOfListIO It( selected );
635 for( ; It.More(); It.Next()){
636 Handle(SALOME_InteractiveObject) IObject = It.Value();
637 if(IObject->hasEntry()){
638 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
639 unsigned int aMode = anActor->GetEntityMode();
640 switch(theCommandID){
642 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
645 InverseEntityMode(aMode,SMESH_Actor::eEdges);
648 InverseEntityMode(aMode,SMESH_Actor::eFaces);
651 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
654 aMode = SMESH_Actor::eAllEntity;
658 anActor->SetEntityMode(aMode);
666 SALOME_ListIO selected;
667 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
671 LightApp_SelectionMgr* aSel = app->selectionMgr();
672 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
673 if( !aSel || !appStudy )
676 aSel->selectedObjects( selected );
677 if( selected.IsEmpty() )
680 Handle(SALOME_InteractiveObject) anIObject = selected.First();
682 _PTR(Study) aStudy = appStudy->studyDS();
683 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
684 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
685 if( aMainObject->_is_nil() )
688 aMainObject->SetAutoColor( true );
690 QList<SALOMEDS::Color> aReservedColors;
692 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
693 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
695 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
696 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
698 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
699 aGroupObject->SetColor( aColor );
700 aReservedColors.append( aColor );
702 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
704 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
705 if( aGroupObject->GetType() == SMESH::NODE )
706 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
707 else if( aGroupObject->GetType() == SMESH::EDGE )
708 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
709 else if( aGroupObject->GetType() == SMESH::ELEM0D )
710 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
712 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
717 SMESH::RepaintCurrentView();
720 QString functorToString( SMESH::Controls::FunctorPtr f )
722 QString type = QObject::tr( "UNKNOWN_CONTROL" );
723 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
724 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
725 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
726 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
727 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
728 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
729 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
730 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
731 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
732 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
733 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
734 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
735 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
736 type = QObject::tr( "WARP_ELEMENTS" );
737 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
738 type = QObject::tr( "TAPER_ELEMENTS" );
739 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
740 type = QObject::tr( "SKEW_ELEMENTS" );
741 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
742 type = QObject::tr( "AREA_ELEMENTS" );
743 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
744 type = QObject::tr( "LENGTH_EDGES" );
745 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
746 type = QObject::tr( "LENGTH2D_EDGES" );
747 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
748 type = QObject::tr( "MULTI_BORDERS" );
749 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
750 type = QObject::tr( "MULTI2D_BORDERS" );
751 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
752 type = QObject::tr( "FREE_NODES" );
753 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
754 type = QObject::tr( "FREE_EDGES" );
755 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
756 type = QObject::tr( "FREE_BORDERS" );
757 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
758 type = QObject::tr( "FREE_FACES" );
762 void SaveDistribution()
764 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
765 SALOME_ListIO selected;
767 aSel->selectedObjects( selected );
769 if ( selected.Extent() == 1 ) {
770 Handle(SALOME_InteractiveObject) anIO = selected.First();
771 if ( anIO->hasEntry() ) {
772 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
773 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
774 vtkScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
775 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
776 if ( aScalarBarActor && aFunctor ) {
777 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
779 int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
780 std::vector<int> nbEvents;
781 std::vector<double> funValues;
782 aNumFun->GetHistogram( nbRanges, nbEvents, funValues );
783 QString anInitialPath = "";
784 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
785 anInitialPath = QDir::currentPath();
786 QString aMeshName = anIO->getName();
788 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
789 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
790 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
791 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
792 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
795 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
797 if ( !aFilename.isEmpty() ) {
798 QFile f( aFilename );
799 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
800 QTextStream out( &f );
801 out << "# Mesh: " << aMeshName << endl;
802 out << "# Control: " << functorToString( aFunctor ) << endl;
804 out.setFieldWidth( 10 );
805 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
806 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
817 void DisableAutoColor(){
818 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
819 SALOME_ListIO selected;
821 aSel->selectedObjects( selected );
823 if(selected.Extent()){
824 Handle(SALOME_InteractiveObject) anIObject = selected.First();
825 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
826 if ( !aMesh->_is_nil() ) {
827 aMesh->SetAutoColor( false );
832 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
833 SALOME_ListIO selected;
834 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
838 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
839 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
840 if( !aSel || !appStudy )
843 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
844 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
845 aModule->EmitSignalDeactivateDialog();
846 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
847 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
852 _PTR(Study) aStudy = appStudy->studyDS();
854 aSel->selectedObjects( selected );
856 if(selected.Extent() >= 1){
857 switch(theCommandID){
859 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
860 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
864 QColor c, e, b, n, c0D, o;
867 vtkFloatingPointType Shrink = 0.0;
868 vtkFloatingPointType faces_orientation_scale = 0.0;
869 bool faces_orientation_3dvectors = false;
871 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
872 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
873 int aMarkerTextureCurrent = 0;
875 SALOME_ListIteratorOfListIO It( selected );
876 for( ; It.More(); It.Next()){
877 Handle(SALOME_InteractiveObject) IObject = It.Value();
878 if(IObject->hasEntry()){
879 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
880 vtkFloatingPointType color[3];
881 anActor->GetSufaceColor(color[0], color[1], color[2]);
882 int c0 = int (color[0] * 255);
883 int c1 = int (color[1] * 255);
884 int c2 = int (color[2] * 255);
885 c.setRgb(c0, c1, c2);
887 vtkFloatingPointType edgecolor[3];
888 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
889 c0 = int (edgecolor[0] * 255);
890 c1 = int (edgecolor[1] * 255);
891 c2 = int (edgecolor[2] * 255);
892 e.setRgb(c0, c1, c2);
894 vtkFloatingPointType backfacecolor[3];
895 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
896 c0 = int (backfacecolor[0] * 255);
897 c1 = int (backfacecolor[1] * 255);
898 c2 = int (backfacecolor[2] * 255);
899 b.setRgb(c0, c1, c2);
901 vtkFloatingPointType nodecolor[3];
902 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
903 c0 = int (nodecolor[0] * 255);
904 c1 = int (nodecolor[1] * 255);
905 c2 = int (nodecolor[2] * 255);
906 n.setRgb(c0, c1, c2);
908 vtkFloatingPointType color0D[3];
909 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
910 c0 = int (color0D[0] * 255);
911 c1 = int (color0D[1] * 255);
912 c2 = int (color0D[2] * 255);
913 c0D.setRgb(c0, c1, c2);
915 size0D = (int)anActor->Get0DSize();
918 Edgewidth = (int)anActor->GetLineWidth();
921 Shrink = anActor->GetShrinkFactor();
923 vtkFloatingPointType faces_orientation_color[3];
924 anActor->GetFacesOrientationColor(faces_orientation_color);
925 c0 = int (faces_orientation_color[0] * 255);
926 c1 = int (faces_orientation_color[1] * 255);
927 c2 = int (faces_orientation_color[2] * 255);
928 o.setRgb(c0, c1, c2);
930 faces_orientation_scale = anActor->GetFacesOrientationScale();
931 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
933 aMarkerTypeCurrent = anActor->GetMarkerType();
934 aMarkerScaleCurrent = anActor->GetMarkerScale();
935 aMarkerTextureCurrent = anActor->GetMarkerTexture();
937 // even if there are multiple objects in the selection,
938 // we need only the first one to get values for the dialog
944 SMESHGUI_Preferences_ColorDlg *aDlg =
945 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
946 aDlg->SetColor(1, c);
947 aDlg->SetColor(2, e);
948 aDlg->SetColor(3, n);
949 aDlg->SetColor(4, b);
950 aDlg->SetColor(5, c0D);
951 aDlg->SetColor(6, o);
952 aDlg->SetIntValue(1, Edgewidth);
953 aDlg->SetIntValue(2, int(Shrink*100.));
954 aDlg->SetIntValue(3, size0D);
955 aDlg->SetDoubleValue(1, faces_orientation_scale);
956 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
958 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
960 if( aMarkerTypeCurrent != VTK::MT_USER )
961 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
963 aDlg->setCustomMarker( aMarkerTextureCurrent );
966 QColor color = aDlg->GetColor(1);
967 QColor edgecolor = aDlg->GetColor(2);
968 QColor nodecolor = aDlg->GetColor(3);
969 QColor backfacecolor = aDlg->GetColor(4);
970 QColor color0D = aDlg->GetColor(5);
971 QColor faces_orientation_color = aDlg->GetColor(6);
974 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
976 SALOME_ListIteratorOfListIO It( selected );
977 for( ; It.More(); It.Next()){
978 Handle(SALOME_InteractiveObject) IObject = It.Value();
979 if(IObject->hasEntry()){
980 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
981 /* actor color and backface color */
982 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
983 vtkFloatingPointType (color.green()) / 255.,
984 vtkFloatingPointType (color.blue()) / 255.);
985 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
986 vtkFloatingPointType (backfacecolor.green()) / 255.,
987 vtkFloatingPointType (backfacecolor.blue()) / 255.);
990 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
991 vtkFloatingPointType (edgecolor.green()) / 255.,
992 vtkFloatingPointType (edgecolor.blue()) / 255.);
994 /* Shrink factor and size edges */
995 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
996 anActor->SetLineWidth(aDlg->GetIntValue(1));
998 /* Nodes color and size */
999 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1000 vtkFloatingPointType (nodecolor.green()) / 255.,
1001 vtkFloatingPointType (nodecolor.blue()) / 255.);
1004 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1005 vtkFloatingPointType (color0D.green()) / 255.,
1006 vtkFloatingPointType (color0D.blue()) / 255.);
1007 anActor->Set0DSize(aDlg->GetIntValue(3));
1009 /* Faces orientation */
1010 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1011 vtkFloatingPointType(faces_orientation_color.greenF()),
1012 vtkFloatingPointType(faces_orientation_color.blueF())};
1013 anActor->SetFacesOrientationColor(c);
1014 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1015 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1017 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1018 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1019 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1020 if( aMarkerTypeNew != VTK::MT_USER )
1021 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1023 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1024 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1025 if( anIter != aMarkerMap.end() )
1026 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1029 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1030 if( !aGroupObject->_is_nil() )
1032 SMESH::ElementType anElementType = aGroupObject->GetType();
1034 switch( anElementType )
1036 case SMESH::NODE: aColor = nodecolor; break;
1037 case SMESH::EDGE: aColor = edgecolor; break;
1038 default: aColor = color; break;
1041 SALOMEDS::Color aGroupColor;
1042 aGroupColor.R = (float)aColor.red() / 255.0;
1043 aGroupColor.G = (float)aColor.green() / 255.0;
1044 aGroupColor.B = (float)aColor.blue() / 255.0;
1045 aGroupObject->SetColor( aGroupColor );
1050 SMESH::RepaintCurrentView();
1056 SALOME_ListIteratorOfListIO It( selected );
1057 for( ; It.More(); It.Next()){
1058 Handle(SALOME_InteractiveObject) IObject = It.Value();
1059 if(IObject->hasEntry()){
1060 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1061 switch(theCommandID){
1063 anActor->SetRepresentation(SMESH_Actor::eEdge);
1066 anActor->SetRepresentation(SMESH_Actor::eSurface);
1069 if(anActor->IsShrunk())
1070 anActor->UnShrink();
1072 anActor->SetShrink();
1075 anActor->SetRepresentation(SMESH_Actor::ePoint);
1078 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1079 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1082 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1083 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1089 SMESH::RepaintCurrentView();
1093 void Control( int theCommandID )
1095 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1096 SALOME_ListIO selected;
1098 aSel->selectedObjects( selected );
1100 if( !selected.IsEmpty() ){
1101 Handle(SALOME_InteractiveObject) anIO = selected.First();
1103 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1104 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1105 switch ( theCommandID ){
1107 aControl = SMESH_Actor::eLength;
1110 aControl = SMESH_Actor::eLength2D;
1113 aControl = SMESH_Actor::eFreeEdges;
1116 aControl = SMESH_Actor::eFreeBorders;
1119 aControl = SMESH_Actor::eMultiConnection;
1122 aControl = SMESH_Actor::eFreeNodes;
1125 aControl = SMESH_Actor::eMultiConnection2D;
1128 aControl = SMESH_Actor::eArea;
1131 aControl = SMESH_Actor::eTaper;
1134 aControl = SMESH_Actor::eAspectRatio;
1137 aControl = SMESH_Actor::eAspectRatio3D;
1140 aControl = SMESH_Actor::eMinimumAngle;
1143 aControl = SMESH_Actor::eWarping;
1146 aControl = SMESH_Actor::eSkew;
1149 aControl = SMESH_Actor::eVolume3D;
1152 aControl = SMESH_Actor::eFreeFaces;
1155 aControl = SMESH_Actor::eMaxElementLength2D;
1158 aControl = SMESH_Actor::eMaxElementLength3D;
1161 anActor->SetControlMode(aControl);
1162 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1163 SMESH::RepaintCurrentView();
1170 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1171 MeshObjectType theType,
1172 const QString theInTypeName,
1173 QString & theOutTypeName)
1175 SMESH_TypeFilter aTypeFilter( theType );
1177 if( !theIO.IsNull() )
1179 entry = theIO->getEntry();
1180 LightApp_DataOwner owner( entry );
1181 if ( aTypeFilter.isOk( &owner )) {
1182 theOutTypeName = theInTypeName;
1190 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1192 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1193 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1195 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1196 CORBA::String_var anID = aSComp->GetID().c_str();
1197 if (!strcmp(anID.in(),theIO->getEntry()))
1203 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1204 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1205 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1206 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1207 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1215 QString CheckHomogeneousSelection()
1217 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1218 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1219 SALOME_ListIO selected;
1221 aSel->selectedObjects( selected );
1223 QString RefType = CheckTypeObject(selected.First());
1224 SALOME_ListIteratorOfListIO It(selected);
1225 for ( ; It.More(); It.Next())
1227 Handle(SALOME_InteractiveObject) IObject = It.Value();
1228 QString Type = CheckTypeObject(IObject);
1229 if (Type.compare(RefType) != 0)
1230 return "Heterogeneous Selection";
1237 void SMESHGUI::OnEditDelete()
1239 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1240 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1241 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1243 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1244 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1245 _PTR(GenericAttribute) anAttr;
1246 _PTR(AttributeIOR) anIOR;
1248 int objectCount = 0;
1250 QString aParentComponent = QString::null;
1251 Handle(SALOME_InteractiveObject) anIO;
1252 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1254 anIO = anIt.Value();
1255 QString cur = anIO->getComponentDataType();
1256 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1258 // check if object is reference
1259 _PTR(SObject) aRefSObj;
1260 aNameList.append("\n - ");
1261 if ( aSO->ReferencedObject( aRefSObj ) ) {
1262 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1263 aNameList.append( aRefName );
1264 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1267 aNameList.append(anIO->getName());
1271 if( aParentComponent.isNull() )
1272 aParentComponent = cur;
1273 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1274 aParentComponent = "";
1277 if ( objectCount == 0 )
1278 return; // No Valid Objects Selected
1280 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1281 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1282 QObject::tr("ERR_ERROR"),
1283 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1286 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1287 if (SUIT_MessageBox::warning
1288 (SMESHGUI::desktop(),
1289 QObject::tr("SMESH_WRN_WARNING"),
1290 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1291 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1292 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1295 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1296 SUIT_ViewManager* vm = anApp->activeViewManager();
1297 int nbSf = vm->getViewsCount();
1299 SALOME_ListIteratorOfListIO It(selected);
1301 aStudyBuilder->NewCommand(); // There is a transaction
1302 for( ; It.More(); It.Next()){ // loop on selected IO's
1303 Handle(SALOME_InteractiveObject) IObject = It.Value();
1304 if(IObject->hasEntry()) {
1305 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1307 // disable removal of "SMESH" component object
1308 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1310 if ( engineIOR() == anIOR->Value().c_str() )
1313 //Check the referenced object
1314 _PTR(SObject) aRefSObject;
1315 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1316 aSO = aRefSObject; // Delete main Object instead of reference
1318 // put the whole hierarchy of sub-objects of the selected SO into a list and
1319 // then treat them all starting from the deepest objects (at list back)
1321 std::list< _PTR(SObject) > listSO;
1322 listSO.push_back( aSO );
1323 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1324 for ( ; itSO != listSO.end(); ++itSO ) {
1325 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1326 for (it->InitEx(false); it->More(); it->Next())
1327 listSO.push_back( it->Value() );
1330 // treat SO's in the list starting from the back
1332 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1333 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1334 _PTR(SObject) SO = *ritSO;
1335 if ( !SO ) continue;
1336 std::string anEntry = SO->GetID();
1338 /** Erase graphical object **/
1339 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1340 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1341 for(int i = 0; i < nbSf; i++){
1342 SUIT_ViewWindow *sf = aViews[i];
1343 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1344 SMESH::RemoveActor(sf,anActor);
1349 /** Remove an object from data structures **/
1350 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1351 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1352 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1353 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1354 aMesh->RemoveGroup( aGroup );
1356 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1357 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1358 aMesh->RemoveSubMesh( aSubMesh );
1360 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1362 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1365 IObject = new SALOME_InteractiveObject
1366 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1367 QString objType = CheckTypeObject(IObject);
1368 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1369 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1370 aStudyBuilder->RemoveObjectWithChildren( SO );
1372 else {// default action: remove SObject from the study
1373 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1374 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1376 aStudyBuilder->RemoveObjectWithChildren( SO );
1380 } /* listSO back loop */
1381 } /* IObject->hasEntry() */
1383 aStudyBuilder->CommitCommand();
1385 /* Clear any previous selection */
1387 aSel->setSelectedObjects( l1 );
1389 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1394 SMESHGUI_EXPORT CAM_Module* createModule()
1396 return new SMESHGUI();
1400 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1402 //=============================================================================
1406 //=============================================================================
1407 SMESHGUI::SMESHGUI() :
1408 SalomeApp_Module( "SMESH" ),
1409 LightApp_Module( "SMESH" )
1411 if ( CORBA::is_nil( myComponentSMESH ) )
1413 CORBA::Boolean anIsEmbeddedMode;
1414 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1416 // 0019923: EDF 765 SMESH : default values of hypothesis
1417 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1418 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1419 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1420 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1421 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1424 myActiveDialogBox = 0;
1425 myFilterLibraryDlg = 0;
1429 myEventCallbackCommand = vtkCallbackCommand::New();
1430 myEventCallbackCommand->Delete();
1431 myEventCallbackCommand->SetClientData( this );
1432 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1435 SMESH::GetFilterManager();
1436 SMESH::GetPattern();
1437 SMESH::GetMeasurements();
1439 /* load resources for all available meshers */
1440 SMESH::InitAvailableHypotheses();
1443 //=============================================================================
1447 //=============================================================================
1448 SMESHGUI::~SMESHGUI()
1450 #ifdef WITHGENERICOBJ
1451 SMESH::GetFilterManager()->Destroy();
1452 SMESH::GetMeasurements()->Destroy();
1454 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1455 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1458 //=============================================================================
1462 //=============================================================================
1463 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1465 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1467 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1472 bool SMESHGUI::automaticUpdate()
1474 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1478 return resMgr->booleanValue( "SMESH", "auto_update", false );
1481 //=============================================================================
1485 //=============================================================================
1486 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1488 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1491 //=============================================================================
1495 //=============================================================================
1496 SMESHGUI* SMESHGUI::GetSMESHGUI()
1498 SMESHGUI* smeshMod = 0;
1499 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1502 CAM_Module* module = app->module( "Mesh" );
1503 smeshMod = dynamic_cast<SMESHGUI*>( module );
1506 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1508 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1511 _PTR(Study) aStudy = study->studyDS();
1513 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1522 Standard_EXPORT SMESHGUI* GetComponentGUI()
1524 return SMESHGUI::GetSMESHGUI();
1528 //=============================================================================
1532 //=============================================================================
1533 void SMESHGUI::SetState(int aState)
1538 //=============================================================================
1542 //=============================================================================
1543 void SMESHGUI::ResetState()
1548 //=============================================================================
1552 //=============================================================================
1553 void SMESHGUI::EmitSignalDeactivateDialog()
1555 emit SignalDeactivateActiveDialog();
1558 //=============================================================================
1562 //=============================================================================
1563 void SMESHGUI::EmitSignalStudyFrameChanged()
1565 emit SignalStudyFrameChanged();
1568 //=============================================================================
1572 //=============================================================================
1573 void SMESHGUI::EmitSignalCloseAllDialogs()
1575 emit SignalCloseAllDialogs();
1578 //=============================================================================
1582 //=============================================================================
1583 void SMESHGUI::EmitSignalVisibilityChanged()
1585 emit SignalVisibilityChanged();
1588 //=============================================================================
1592 //=============================================================================
1593 QDialog *SMESHGUI::GetActiveDialogBox()
1595 return myActiveDialogBox;
1598 //=============================================================================
1602 //=============================================================================
1603 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1605 myActiveDialogBox = (QDialog *) aDlg;
1609 //=============================================================================
1613 //=============================================================================
1614 SUIT_Desktop* SMESHGUI::desktop()
1616 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1618 return app->desktop();
1623 //=============================================================================
1627 //=============================================================================
1628 SalomeApp_Study* SMESHGUI::activeStudy()
1630 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1632 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1637 //=============================================================================
1641 //=============================================================================
1642 void SMESHGUI::Modified( bool theIsUpdateActions )
1644 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1645 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1646 appStudy->Modified();
1647 if( theIsUpdateActions )
1648 app->updateActions();
1653 //=============================================================================
1657 //=============================================================================
1658 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1660 /* Here the position is on the bottom right corner - 10 */
1661 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1663 SUIT_Desktop *PP = desktop();
1664 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1665 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1669 //=============================================================================
1673 //=============================================================================
1674 static int isStudyLocked(_PTR(Study) theStudy){
1675 return theStudy->GetProperties()->IsLocked();
1678 static bool checkLock(_PTR(Study) theStudy) {
1679 if (isStudyLocked(theStudy)) {
1680 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1681 QObject::tr("WRN_WARNING"),
1682 QObject::tr("WRN_STUDY_LOCKED") );
1688 //=======================================================================
1689 //function : CheckActiveStudyLocked
1691 //=======================================================================
1693 bool SMESHGUI::isActiveStudyLocked()
1695 _PTR(Study) aStudy = activeStudy()->studyDS();
1696 return checkLock( aStudy );
1699 //=============================================================================
1703 //=============================================================================
1704 bool SMESHGUI::OnGUIEvent( int theCommandID )
1706 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1710 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1711 SUIT_ResourceMgr* mgr = resourceMgr();
1715 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1716 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1719 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1720 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1722 //QAction* act = action( theCommandID );
1724 switch (theCommandID) {
1726 if(checkLock(aStudy)) break;
1734 if(checkLock(aStudy)) break;
1735 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1739 case 150: //MED FILE INFORMATION
1741 SALOME_ListIO selected;
1742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1744 aSel->selectedObjects( selected );
1745 if( selected.Extent() )
1747 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1748 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1749 if ( !aMesh->_is_nil() )
1751 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1758 case 122: // EXPORT MED
1767 ::ExportMeshToFile(theCommandID);
1771 case 200: // SCALAR BAR
1773 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1774 SALOME_ListIO selected;
1776 aSel->selectedObjects( selected );
1778 if( selected.Extent() ) {
1779 Handle(SALOME_InteractiveObject) anIO = selected.First();
1780 if( anIO->hasEntry() ) {
1781 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1782 anActor->SetControlMode( SMESH_Actor::eNone );
1790 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1795 // dump control distribution data to the text file
1796 ::SaveDistribution();
1806 ::DisableAutoColor();
1809 case 1134: // Clipping
1810 case 1133: // Tranparency
1811 case 1132: // Colors / Size
1818 ::SetDisplayMode(theCommandID, myMarkerMap);
1821 //2D quadratic representation
1824 ::SetDisplayMode(theCommandID, myMarkerMap);
1828 case 216: // 0D elements
1831 case 219: // Volumes
1832 case 220: // All Entity
1833 ::SetDisplayEntity(theCommandID);
1836 case 221: // Orientation of faces
1838 LightApp_SelectionMgr* mgr = selectionMgr();
1839 SALOME_ListIO selected; mgr->selectedObjects( selected );
1841 SALOME_ListIteratorOfListIO it(selected);
1842 for( ; it.More(); it.Next()) {
1843 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1844 if(anIObject->hasEntry()) {
1845 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1846 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1855 if(checkLock(aStudy)) break;
1857 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1860 SMESH::UpdateView();
1862 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1863 SMESH::OnVisuException();
1865 catch (...) { // PAL16774 (Crash after display of many groups)
1866 SMESH::OnVisuException();
1870 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1871 aSel->selectedObjects( l );
1872 aSel->setSelectedObjects( l );
1877 case 301: // DISPLAY
1878 case 302: // DISPLAY ONLY
1880 SMESH::EDisplaing anAction;
1881 switch (theCommandID) {
1882 case 300: anAction = SMESH::eErase; break;
1883 case 301: anAction = SMESH::eDisplay; break;
1884 case 302: anAction = SMESH::eDisplayOnly; break;
1887 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1888 SALOME_ListIO sel_objects, to_process;
1890 aSel->selectedObjects( sel_objects );
1892 if( theCommandID==302 )
1893 startOperation( myEraseAll );
1895 extractContainers( sel_objects, to_process );
1898 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1902 SALOME_ListIteratorOfListIO It( to_process );
1903 for ( ; It.More(); It.Next()) {
1904 Handle(SALOME_InteractiveObject) IOS = It.Value();
1905 if (IOS->hasEntry()) {
1906 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1907 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1908 break; // PAL16774 (Crash after display of many groups)
1910 if (anAction == SMESH::eDisplayOnly)
1911 anAction = SMESH::eDisplay;
1916 // PAL13338 + PAL15161 -->
1917 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1918 SMESH::UpdateView();
1919 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1921 // PAL13338 + PAL15161 <--
1923 catch (...) { // PAL16774 (Crash after display of many groups)
1924 SMESH::OnVisuException();
1927 if (anAction == SMESH::eErase) {
1929 aSel->setSelectedObjects( l1 );
1932 aSel->setSelectedObjects( to_process );
1939 if(checkLock(aStudy)) break;
1942 EmitSignalDeactivateDialog();
1944 ( new SMESHGUI_NodesDlg( this ) )->show();
1947 SUIT_MessageBox::warning(desktop(),
1948 tr("SMESH_WRN_WARNING"),
1949 tr("SMESH_WRN_VIEWER_VTK"));
1954 case 2151: // FILTER
1958 EmitSignalDeactivateDialog();
1959 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1964 case 701: // COMPUTE MESH
1965 case 711: // PRECOMPUTE MESH
1966 case 712: // EVALUATE MESH
1967 case 713: // MESH ORDER
1969 if (checkLock(aStudy)) break;
1970 startOperation( theCommandID );
1974 case 702: // Create mesh
1975 case 703: // Create sub-mesh
1976 case 704: // Edit mesh/sub-mesh
1977 startOperation( theCommandID );
1979 case 710: // Build compound mesh
1981 if (checkLock(aStudy)) break;
1982 EmitSignalDeactivateDialog();
1983 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1987 case 407: // DIAGONAL INVERSION
1988 case 408: // Delete diagonal
1992 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1993 tr( "NOT_A_VTK_VIEWER" ) );
1997 if ( checkLock( aStudy ) )
2000 /*Standard_Boolean aRes;
2001 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2002 if ( aMesh->_is_nil() )
2004 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2005 tr( "SMESH_BAD_SELECTION" ) );
2009 EmitSignalDeactivateDialog();
2010 if ( theCommandID == 407 )
2011 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2013 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2016 case 409: // Change orientation
2017 case 410: // Union of triangles
2018 case 411: // Cutting of quadrangles
2019 case 419: // Splitting volumes into tetrahedra
2023 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2024 tr( "NOT_A_VTK_VIEWER" ) );
2028 if ( checkLock( aStudy ) )
2031 EmitSignalDeactivateDialog();
2032 SMESHGUI_MultiEditDlg* aDlg = NULL;
2033 if ( theCommandID == 409 )
2034 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2035 else if ( theCommandID == 410 )
2036 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2037 else if ( theCommandID == 419 )
2038 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2040 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2045 case 412: // Smoothing
2047 if(checkLock(aStudy)) break;
2049 EmitSignalDeactivateDialog();
2050 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2053 SUIT_MessageBox::warning(desktop(),
2054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2058 case 413: // Extrusion
2060 if (checkLock(aStudy)) break;
2062 EmitSignalDeactivateDialog();
2063 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2065 SUIT_MessageBox::warning(desktop(),
2066 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2070 case 414: // Revolution
2072 if(checkLock(aStudy)) break;
2074 EmitSignalDeactivateDialog();
2075 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2078 SUIT_MessageBox::warning(desktop(),
2079 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2083 case 415: // Pattern mapping
2085 if ( checkLock( aStudy ) )
2089 EmitSignalDeactivateDialog();
2090 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2093 SUIT_MessageBox::warning(desktop(),
2094 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2098 case 416: // Extrusion along a path
2100 if (checkLock(aStudy)) break;
2102 EmitSignalDeactivateDialog();
2103 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2105 SUIT_MessageBox::warning(desktop(),
2106 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2110 case 417: // Convert mesh to quadratic
2112 startOperation( 417 );
2113 /* if (checkLock(aStudy)) break;
2115 EmitSignalDeactivateDialog();
2116 new SMESHGUI_ConvToQuadDlg();
2118 SUIT_MessageBox::warning(desktop(),
2119 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2123 case 418: // create 2D mesh from 3D
2125 startOperation( 418 );
2128 case 806: // CREATE GEO GROUP
2130 startOperation( 806 );
2133 case 801: // CREATE GROUP
2137 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2138 tr( "NOT_A_VTK_VIEWER" ) );
2142 if(checkLock(aStudy)) break;
2143 EmitSignalDeactivateDialog();
2144 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2146 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2147 SALOME_ListIO selected;
2149 aSel->selectedObjects( selected );
2151 int nbSel = selected.Extent();
2153 // check if mesh is selected
2154 aMesh = SMESH::GetMeshByIO( selected.First() );
2156 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2161 case 802: // CONSTRUCT GROUP
2165 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2166 tr( "NOT_A_VTK_VIEWER" ) );
2170 if(checkLock(aStudy)) break;
2171 EmitSignalDeactivateDialog();
2173 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2174 SALOME_ListIO selected;
2176 aSel->selectedObjects( selected );
2178 int nbSel = selected.Extent();
2180 // check if submesh is selected
2181 Handle(SALOME_InteractiveObject) IObject = selected.First();
2182 if (IObject->hasEntry()) {
2183 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2185 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2186 if (!aSubMesh->_is_nil()) {
2188 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2189 // get submesh elements list by types
2190 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2191 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2192 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2193 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2194 // create group for each type o elements
2195 QString aName = IObject->getName();
2196 if (aNodes->length() > 0) {
2197 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2198 aGroup->Add(aNodes.inout());
2200 if (aEdges->length() > 0) {
2201 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2202 aGroup->Add(aEdges.inout());
2204 if (aFaces->length() > 0) {
2205 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2206 aGroup->Add(aFaces.inout());
2208 if (aVolumes->length() > 0) {
2209 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2210 aGroup->Add(aVolumes.inout());
2215 catch(const SALOME::SALOME_Exception & S_ex){
2216 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2223 SUIT_MessageBox::warning(desktop(),
2224 tr("SMESH_WRN_WARNING"),
2225 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2230 case 803: // EDIT GROUP
2234 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2235 tr( "NOT_A_VTK_VIEWER" ) );
2239 if(checkLock(aStudy)) break;
2240 EmitSignalDeactivateDialog();
2242 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2243 SALOME_ListIO selected;
2245 aSel->selectedObjects( selected );
2247 SALOME_ListIteratorOfListIO It (selected);
2248 int nbSelectedGroups = 0;
2249 for ( ; It.More(); It.Next() )
2251 SMESH::SMESH_GroupBase_var aGroup =
2252 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2253 if (!aGroup->_is_nil()) {
2255 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2259 if (nbSelectedGroups == 0)
2261 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2267 case 804: // Add elements to group
2269 if(checkLock(aStudy)) break;
2270 if (myState == 800) {
2271 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2272 if (aDlg) aDlg->onAdd();
2277 case 805: // Remove elements from group
2279 if(checkLock(aStudy)) break;
2280 if (myState == 800) {
2281 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2282 if (aDlg) aDlg->onRemove();
2287 case 815: // Edit GEOM GROUP as standalone
2291 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2292 tr( "NOT_A_VTK_VIEWER" ) );
2296 if(checkLock(aStudy)) break;
2297 EmitSignalDeactivateDialog();
2299 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2300 SALOME_ListIO selected;
2302 aSel->selectedObjects( selected );
2304 SALOME_ListIteratorOfListIO It (selected);
2305 for ( ; It.More(); It.Next() )
2307 SMESH::SMESH_GroupOnGeom_var aGroup =
2308 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2309 if (!aGroup->_is_nil()) {
2310 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2317 case 810: // Union Groups
2318 case 811: // Intersect groups
2319 case 812: // Cut groups
2323 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2324 tr( "NOT_A_VTK_VIEWER" ) );
2328 if ( checkLock( aStudy ) )
2331 EmitSignalDeactivateDialog();
2333 SMESHGUI_GroupOpDlg* aDlg = 0;
2334 if ( theCommandID == 810 )
2335 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2336 else if ( theCommandID == 811 )
2337 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2339 aDlg = new SMESHGUI_CutGroupsDlg( this );
2346 case 814: // Create groups of entities from existing groups of superior dimensions
2348 if ( checkLock( aStudy ) )
2351 EmitSignalDeactivateDialog();
2352 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2358 case 813: // Delete groups with their contents
2362 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2363 tr( "NOT_A_VTK_VIEWER" ) );
2367 if ( checkLock( aStudy ) )
2370 EmitSignalDeactivateDialog();
2372 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2376 case 900: // MESH INFOS
2377 case 903: // WHAT IS
2379 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2380 EmitSignalDeactivateDialog();
2381 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2382 SALOME_ListIO selected;
2384 aSel->selectedObjects( selected );
2386 if ( selected.Extent() > 1 ) { // a dlg for each IO
2387 SALOME_ListIteratorOfListIO It( selected );
2388 for ( ; It.More(); It.Next() ) {
2389 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2390 dlg->showInfo( It.Value() );
2395 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2401 case 902: // STANDARD MESH INFOS
2403 EmitSignalDeactivateDialog();
2404 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2405 SALOME_ListIO selected;
2407 aSel->selectedObjects( selected );
2409 if ( selected.Extent() > 1 ) { // a dlg for each IO
2411 SALOME_ListIteratorOfListIO It (selected);
2412 for ( ; It.More(); It.Next() ) {
2414 IOs.Append( It.Value() );
2415 aSel->setSelectedObjects( IOs );
2416 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2418 // restore selection
2419 aSel->setSelectedObjects( selected );
2422 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2425 case 903: // WHAT IS
2427 EmitSignalDeactivateDialog();
2428 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2433 case 904: // FIND ELEM
2435 startOperation( theCommandID );
2439 case 1100: // EDIT HYPOTHESIS
2441 if(checkLock(aStudy)) break;
2443 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2444 SALOME_ListIO selected;
2446 aSel->selectedObjects( selected );
2448 int nbSel = selected.Extent();
2451 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2452 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2454 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2455 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2456 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2457 if ( !aHypothesis->_is_nil() )
2460 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2461 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2463 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2474 case 1101: // RENAME
2476 if ( checkLock( aStudy ) )
2479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2480 SALOME_ListIO selected;
2482 aSel->selectedObjects( selected );
2484 bool isAny = false; // is there any appropriate object selected
2486 SALOME_ListIteratorOfListIO It( selected );
2487 for ( ; It.More(); It.Next() )
2489 Handle(SALOME_InteractiveObject) IObject = It.Value();
2490 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2491 _PTR(GenericAttribute) anAttr;
2492 _PTR(AttributeName) aName;
2495 if ( obj->FindAttribute(anAttr, "AttributeName") )
2498 QString newName = QString(aName->Value().c_str());
2500 // check type to prevent renaming of inappropriate objects
2501 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2502 if (aType == MESH || aType == GROUP ||
2503 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2504 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2505 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2506 aType == HYPOTHESIS || aType == ALGORITHM)
2509 newName = LightApp_NameDlg::getName(desktop(), newName);
2510 if ( !newName.isEmpty() )
2512 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2514 // update name of group object and its actor
2515 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2516 if( !aGroupObject->_is_nil() )
2518 aGroupObject->SetName( newName.toLatin1().data() );
2519 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2520 anActor->setName( newName.toLatin1().data() );
2531 SUIT_MessageBox::warning(desktop(),
2532 QObject::tr("SMESH_WRN_WARNING"),
2533 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2538 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2540 if(checkLock(aStudy)) break;
2541 SUIT_OverrideCursor wc;
2543 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2544 SALOME_ListIO selected;
2546 aSel->selectedObjects( selected, QString::null, false );
2548 SALOME_ListIteratorOfListIO It(selected);
2549 for (int i = 0; It.More(); It.Next(), i++) {
2550 Handle(SALOME_InteractiveObject) IObject = It.Value();
2551 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2554 aSel->setSelectedObjects( l1 );
2559 case 4009: // ELEM0D
2560 case 4010: // GEOM::EDGE
2561 case 4021: // TRIANGLE
2563 case 4023: // POLYGON
2567 if(checkLock(aStudy)) break;
2569 EmitSignalDeactivateDialog();
2570 SMDSAbs_ElementType type = SMDSAbs_Edge;
2572 switch (theCommandID) {
2573 case 4009: // ELEM0D
2574 type = SMDSAbs_0DElement; nbNodes = 1; break;
2575 case 4021: // TRIANGLE
2576 type = SMDSAbs_Face; nbNodes = 3; break;
2578 type = SMDSAbs_Face; nbNodes = 4; break;
2580 type = SMDSAbs_Volume; nbNodes = 4; break;
2581 case 4023: // POLYGON
2582 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2584 type = SMDSAbs_Volume; nbNodes = 8; break;
2585 case 4033: // POLYHEDRE
2586 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2589 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2592 SUIT_MessageBox::warning(desktop(),
2593 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2597 case 4033: // POLYHEDRON
2599 if(checkLock(aStudy)) break;
2601 EmitSignalDeactivateDialog();
2602 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2605 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2606 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2610 case 4034: // QUADRATIC EDGE
2611 case 4035: // QUADRATIC TRIANGLE
2612 case 4036: // QUADRATIC QUADRANGLE
2613 case 4037: // QUADRATIC TETRAHEDRON
2614 case 4038: // QUADRATIC PYRAMID
2615 case 4039: // QUADRATIC PENTAHEDRON
2616 case 4040: // QUADRATIC HEXAHEDRON
2618 if(checkLock(aStudy)) break;
2620 EmitSignalDeactivateDialog();
2623 switch (theCommandID) {
2625 type = QUAD_EDGE; break;
2627 type = QUAD_TRIANGLE; break;
2629 type = QUAD_QUADRANGLE; break;
2631 type = QUAD_TETRAHEDRON; break;
2633 type = QUAD_PYRAMID; break;
2635 type = QUAD_PENTAHEDRON; break;
2637 type = QUAD_HEXAHEDRON;
2641 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2644 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2645 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2649 case 4041: // REMOVES NODES
2651 if(checkLock(aStudy)) break;
2653 EmitSignalDeactivateDialog();
2654 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2657 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2658 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2662 case 4042: // REMOVES ELEMENTS
2664 if(checkLock(aStudy)) break;
2666 EmitSignalDeactivateDialog();
2667 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2671 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2672 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2676 case 4043: { // CLEAR_MESH
2678 if(checkLock(aStudy)) break;
2680 SALOME_ListIO selected;
2681 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2682 aSel->selectedObjects( selected );
2684 SUIT_OverrideCursor wc;
2685 SALOME_ListIteratorOfListIO It (selected);
2686 for ( ; It.More(); It.Next() )
2688 Handle(SALOME_InteractiveObject) IOS = It.Value();
2689 SMESH::SMESH_Mesh_var aMesh =
2690 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2691 if ( aMesh->_is_nil()) continue;
2693 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2695 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2696 SMESH::ModifiedMesh( aMeshSObj, false, true);
2697 // hide groups and submeshes
2698 _PTR(ChildIterator) anIter =
2699 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2700 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2702 _PTR(SObject) so = anIter->Value();
2703 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2706 catch (const SALOME::SALOME_Exception& S_ex){
2708 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2712 SMESH::UpdateView();
2716 case 4044: // REMOVE ORPHAN NODES
2718 if(checkLock(aStudy)) break;
2719 SALOME_ListIO selected;
2720 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2721 aSel->selectedObjects( selected );
2722 if ( selected.Extent() == 1 ) {
2723 Handle(SALOME_InteractiveObject) anIO = selected.First();
2724 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2725 if ( !aMesh->_is_nil() ) {
2726 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2727 tr( "SMESH_WARNING" ),
2728 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2729 SUIT_MessageBox::Yes |
2730 SUIT_MessageBox::No,
2731 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2734 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2735 int removed = aMeshEditor->RemoveOrphanNodes();
2736 SUIT_MessageBox::information(SMESHGUI::desktop(),
2737 tr("SMESH_INFORMATION"),
2738 tr("NB_NODES_REMOVED").arg(removed));
2739 if ( removed > 0 ) {
2740 SMESH::UpdateView();
2741 SMESHGUI::Modified();
2744 catch (const SALOME::SALOME_Exception& S_ex) {
2745 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2754 case 4051: // RENUMBERING NODES
2756 if(checkLock(aStudy)) break;
2758 EmitSignalDeactivateDialog();
2759 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2763 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2764 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2768 case 4052: // RENUMBERING ELEMENTS
2770 if(checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2773 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2777 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2778 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2782 case 4061: // TRANSLATION
2784 if(checkLock(aStudy)) break;
2786 EmitSignalDeactivateDialog();
2787 ( new SMESHGUI_TranslationDlg( this ) )->show();
2790 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2791 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2795 case 4062: // ROTATION
2797 if(checkLock(aStudy)) break;
2799 EmitSignalDeactivateDialog();
2800 ( new SMESHGUI_RotationDlg( this ) )->show();
2803 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2804 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2808 case 4063: // SYMMETRY
2810 if(checkLock(aStudy)) break;
2812 EmitSignalDeactivateDialog();
2813 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2816 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2817 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2821 case 4064: // SEWING
2823 if(checkLock(aStudy)) break;
2825 EmitSignalDeactivateDialog();
2826 ( new SMESHGUI_SewingDlg( this ) )->show();
2829 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2830 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2834 case 4065: // MERGE NODES
2836 if(checkLock(aStudy)) break;
2838 EmitSignalDeactivateDialog();
2839 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2842 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2843 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2847 case 4066: // MERGE EQUAL ELEMENTS
2849 if (checkLock(aStudy)) break;
2851 EmitSignalDeactivateDialog();
2852 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2854 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2855 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2860 case 4067: // MAKE MESH PASS THROUGH POINT
2861 startOperation( 4067 );
2866 if(checkLock(aStudy)) break;
2868 EmitSignalDeactivateDialog();
2869 ( new SMESHGUI_ScaleDlg( this ) )->show();
2872 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2873 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2878 case 4069: // DUPLICATE NODES
2880 if(checkLock(aStudy)) break;
2882 EmitSignalDeactivateDialog();
2883 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2886 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2887 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2892 case 5105: // Library of selection filters
2894 static QList<int> aTypes;
2895 if ( aTypes.isEmpty() )
2897 aTypes.append( SMESH::NODE );
2898 aTypes.append( SMESH::EDGE );
2899 aTypes.append( SMESH::FACE );
2900 aTypes.append( SMESH::VOLUME );
2902 if (!myFilterLibraryDlg)
2903 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2904 else if (myFilterLibraryDlg->isHidden())
2905 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2906 myFilterLibraryDlg->raise();
2910 case 6017: // CONTROLS
2930 LightApp_SelectionMgr* mgr = selectionMgr();
2931 SALOME_ListIO selected; mgr->selectedObjects( selected );
2933 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2934 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2936 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2937 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2938 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2939 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2940 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2941 ::Control( theCommandID );
2946 SUIT_MessageBox::warning(desktop(),
2947 tr( "SMESH_WRN_WARNING" ),
2948 tr( "SMESH_BAD_SELECTION" ) );
2952 SUIT_MessageBox::warning(desktop(),
2953 tr( "SMESH_WRN_WARNING" ),
2954 tr( "NOT_A_VTK_VIEWER" ) );
2959 LightApp_SelectionMgr* mgr = selectionMgr();
2960 SALOME_ListIO selected; mgr->selectedObjects( selected );
2962 SALOME_ListIteratorOfListIO it(selected);
2963 for( ; it.More(); it.Next()) {
2964 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2965 if(anIObject->hasEntry()) {
2966 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2967 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2975 LightApp_SelectionMgr* mgr = selectionMgr();
2976 SALOME_ListIO selected; mgr->selectedObjects( selected );
2978 SALOME_ListIteratorOfListIO it(selected);
2979 for( ; it.More(); it.Next()) {
2980 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2981 if(anIObject->hasEntry())
2982 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2983 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2990 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2991 //updateObjBrowser();
2995 //=============================================================================
2999 //=============================================================================
3000 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3005 //=============================================================================
3009 //=============================================================================
3010 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3015 //=============================================================================
3019 //=============================================================================
3020 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3025 //=============================================================================
3026 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3027 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3029 //=============================================================================
3030 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3031 SUIT_ViewWindow* wnd )
3033 if(theIO->hasEntry()){
3034 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3035 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3039 //=======================================================================
3040 // function : createSMESHAction
3042 //=======================================================================
3043 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3044 const int key, const bool toggle, const QString& shortcutAction )
3047 QWidget* parent = application()->desktop();
3048 SUIT_ResourceMgr* resMgr = resourceMgr();
3050 if ( !icon_id.isEmpty() )
3051 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3053 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3054 if ( !pix.isNull() )
3055 icon = QIcon( pix );
3057 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3058 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3059 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3061 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3062 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3065 //=======================================================================
3066 // function : createPopupItem
3068 //=======================================================================
3069 void SMESHGUI::createPopupItem( const int id,
3070 const QString& clients,
3071 const QString& types,
3072 const QString& theRule,
3077 parentId = popupMgr()->actionId( action( pId ) );
3079 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3080 popupMgr()->insert( action( id ), parentId, 0 );
3082 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3083 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3084 QString rule = "(%1) and (%2) and (%3)";
3085 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3086 if( clients.isEmpty() )
3087 rule = rule.arg( QString( "true" ) );
3089 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3090 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3093 bool cont = myRules.contains( id );
3095 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3097 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3098 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3101 //=======================================================================
3102 // function : initialize
3104 //=======================================================================
3105 void SMESHGUI::initialize( CAM_Application* app )
3107 SalomeApp_Module::initialize( app );
3109 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3111 /* Automatic Update flag */
3112 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3114 // ----- create actions --------------
3116 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3117 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3118 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3119 createSMESHAction( 114, "NUM" );
3120 createSMESHAction( 121, "DAT" );
3121 createSMESHAction( 122, "MED" );
3122 createSMESHAction( 123, "UNV" );
3123 createSMESHAction( 140, "STL" );
3124 createSMESHAction( 124, "EXPORT_DAT" );
3125 createSMESHAction( 125, "EXPORT_MED" );
3126 createSMESHAction( 126, "EXPORT_UNV" );
3127 createSMESHAction( 141, "EXPORT_STL" );
3128 createSMESHAction( 150, "FILE_INFO" );
3129 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3130 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3131 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3132 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3133 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3134 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3135 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3136 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3137 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3138 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3139 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3140 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3141 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3142 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3143 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3144 createSMESHAction( 804, "ADD" );
3145 createSMESHAction( 805, "REMOVE" );
3146 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3147 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3148 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3149 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3150 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3151 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3152 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3153 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3154 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3155 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3156 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3157 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3158 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3159 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3160 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3161 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3162 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3163 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3164 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3165 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3166 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3167 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3168 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3169 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3170 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3171 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3172 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3173 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3174 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3175 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3176 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3177 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3178 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3179 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3180 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3181 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3182 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3183 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3184 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3185 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3186 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3187 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3188 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3189 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3190 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3191 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3192 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3193 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3194 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3195 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3196 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3197 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3198 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3199 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3200 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3201 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3202 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3203 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3204 createSMESHAction( 415, "MAP", "ICON_MAP" );
3205 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3206 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3207 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3208 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3209 createSMESHAction( 200, "RESET" );
3210 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3211 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3212 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3213 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3214 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3215 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3216 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3217 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3218 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3219 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3220 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3221 createSMESHAction( 220, "ALL" );
3222 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3224 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3225 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3227 createSMESHAction( 1100, "EDIT_HYPO" );
3228 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3229 createSMESHAction( 1102, "UNASSIGN" );
3230 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3231 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3232 createSMESHAction( 1131, "DISPMODE" );
3233 createSMESHAction( 1132, "COLORS" );
3234 createSMESHAction( 1133, "TRANSP" );
3235 createSMESHAction( 1134, "CLIP" );
3236 createSMESHAction( 1135, "DISP_ENT" );
3237 createSMESHAction( 1136, "AUTO_COLOR" );
3238 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3239 createSMESHAction( 2000, "CTRL" );
3241 createSMESHAction( 300, "ERASE" );
3242 createSMESHAction( 301, "DISPLAY" );
3243 createSMESHAction( 302, "DISPLAY_ONLY" );
3244 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3245 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3246 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3247 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3248 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3249 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3250 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3251 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3253 // ----- create menu --------------
3254 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3255 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3256 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3257 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3258 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3259 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3260 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3262 createMenu( separator(), fileId );
3264 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3265 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3266 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3267 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3268 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3269 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3270 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3271 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3272 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3273 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3275 createMenu( 111, importId, -1 );
3276 createMenu( 112, importId, -1 );
3277 createMenu( 113, importId, -1 );
3279 createMenu( 121, exportId, -1 );
3280 createMenu( 122, exportId, -1 );
3281 createMenu( 123, exportId, -1 );
3282 createMenu( 140, exportId, -1 ); // export to stl STL
3284 createMenu( separator(), fileId, 10 );
3286 createMenu( 33, editId, -1 );
3288 createMenu( 5105, toolsId, -1 );
3290 createMenu( 702, meshId, -1 ); // "Mesh" menu
3291 createMenu( 703, meshId, -1 );
3292 createMenu( 704, meshId, -1 );
3293 createMenu( 710, meshId, -1 );
3294 createMenu( separator(), meshId, -1 );
3295 createMenu( 701, meshId, -1 );
3296 createMenu( 711, meshId, -1 );
3297 createMenu( 712, meshId, -1 );
3298 createMenu( 713, meshId, -1 );
3299 createMenu( separator(), meshId, -1 );
3300 createMenu( 801, meshId, -1 );
3301 createMenu( 806, meshId, -1 );
3302 createMenu( 802, meshId, -1 );
3303 createMenu( 803, meshId, -1 );
3304 createMenu( 815, meshId, -1 );
3305 createMenu( separator(), meshId, -1 );
3306 createMenu( 810, meshId, -1 );
3307 createMenu( 811, meshId, -1 );
3308 createMenu( 812, meshId, -1 );
3309 createMenu( separator(), meshId, -1 );
3310 createMenu( 814, meshId, -1 );
3311 createMenu( separator(), meshId, -1 );
3312 createMenu( 813, meshId, -1 );
3313 createMenu( separator(), meshId, -1 );
3314 createMenu( 900, meshId, -1 );
3315 //createMenu( 902, meshId, -1 );
3316 createMenu( 903, meshId, -1 );
3317 createMenu( 904, meshId, -1 );
3318 createMenu( separator(), meshId, -1 );
3320 createMenu( 6005, nodeId, -1 );
3321 createMenu( 6002, edgeId, -1 );
3322 createMenu( 6003, edgeId, -1 );
3323 createMenu( 6001, edgeId, -1 );
3324 createMenu( 6004, edgeId, -1 );
3325 createMenu( 6021, faceId, -1 );
3326 createMenu( 6018, faceId, -1 );
3327 createMenu( 6019, faceId, -1 );
3328 createMenu( 6011, faceId, -1 );
3329 createMenu( 6012, faceId, -1 );
3330 createMenu( 6013, faceId, -1 );
3331 createMenu( 6014, faceId, -1 );
3332 createMenu( 6015, faceId, -1 );
3333 createMenu( 6016, faceId, -1 );
3334 createMenu( 6022, faceId, -1 );
3335 createMenu( 6017, volumeId, -1 );
3336 createMenu( 6009, volumeId, -1 );
3337 createMenu( 6023, volumeId, -1 );
3339 createMenu( 4000, addId, -1 );
3340 createMenu( 4009, addId, -1 );
3341 createMenu( 4010, addId, -1 );
3342 createMenu( 4021, addId, -1 );
3343 createMenu( 4022, addId, -1 );
3344 createMenu( 4023, addId, -1 );
3345 createMenu( 4031, addId, -1 );
3346 createMenu( 4032, addId, -1 );
3347 createMenu( 4033, addId, -1 );
3348 createMenu( separator(), addId, -1 );
3349 createMenu( 4034, addId, -1 );
3350 createMenu( 4035, addId, -1 );
3351 createMenu( 4036, addId, -1 );
3352 createMenu( 4037, addId, -1 );
3353 createMenu( 4038, addId, -1 );
3354 createMenu( 4039, addId, -1 );
3355 createMenu( 4040, addId, -1 );
3357 createMenu( 4041, removeId, -1 );
3358 createMenu( 4042, removeId, -1 );
3359 createMenu( 4044, removeId, -1 );
3360 createMenu( separator(), removeId, -1 );
3361 createMenu( 4043, removeId, -1 );
3363 createMenu( 4051, renumId, -1 );
3364 createMenu( 4052, renumId, -1 );
3366 createMenu( 4061, transfId, -1 );
3367 createMenu( 4062, transfId, -1 );
3368 createMenu( 4063, transfId, -1 );
3369 createMenu( 4064, transfId, -1 );
3370 createMenu( 4065, transfId, -1 );
3371 createMenu( 4066, transfId, -1 );
3372 createMenu( 4068, transfId, -1 );
3373 createMenu( 4069, transfId, -1 );
3375 createMenu( 4067,modifyId, -1 );
3376 createMenu( 407, modifyId, -1 );
3377 createMenu( 408, modifyId, -1 );
3378 createMenu( 409, modifyId, -1 );
3379 createMenu( 410, modifyId, -1 );
3380 createMenu( 411, modifyId, -1 );
3381 createMenu( 419, modifyId, -1 );
3382 createMenu( 412, modifyId, -1 );
3383 createMenu( 413, modifyId, -1 );
3384 createMenu( 416, modifyId, -1 );
3385 createMenu( 414, modifyId, -1 );
3386 createMenu( 415, modifyId, -1 );
3387 createMenu( 417, modifyId, -1 );
3388 createMenu( 418, modifyId, -1 );
3390 createMenu( 214, viewId, -1 );
3392 // ----- create toolbars --------------
3393 int meshTb = createTool( tr( "TB_MESH" ) ),
3394 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3395 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3396 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3397 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3399 createTool( 702, meshTb );
3400 createTool( 703, meshTb );
3401 createTool( 704, meshTb );
3402 createTool( 710, meshTb );
3403 createTool( separator(), meshTb );
3404 createTool( 701, meshTb );
3405 createTool( 711, meshTb );
3406 createTool( 712, meshTb );
3407 createTool( 713, meshTb );
3408 createTool( separator(), meshTb );
3409 createTool( 801, meshTb );
3410 createTool( 806, meshTb );
3411 createTool( 802, meshTb );
3412 createTool( 803, meshTb );
3413 //createTool( 815, meshTb );
3414 createTool( separator(), meshTb );
3415 createTool( 900, meshTb );
3416 //createTool( 902, meshTb );
3417 createTool( 903, meshTb );
3418 createTool( 904, meshTb );
3419 createTool( separator(), meshTb );
3421 createTool( 6005, ctrlTb );
3422 createTool( separator(), ctrlTb );
3423 createTool( 6002, ctrlTb );
3424 createTool( 6003, ctrlTb );
3425 createTool( 6001, ctrlTb );
3426 createTool( 6004, ctrlTb );
3427 createTool( separator(), ctrlTb );
3428 createTool( 6021, ctrlTb );
3429 createTool( 6018, ctrlTb );
3430 createTool( 6019, ctrlTb );
3431 createTool( 6011, ctrlTb );
3432 createTool( 6012, ctrlTb );
3433 createTool( 6013, ctrlTb );
3434 createTool( 6014, ctrlTb );
3435 createTool( 6015, ctrlTb );
3436 createTool( 6016, ctrlTb );
3437 createTool( 6022, ctrlTb );
3438 createTool( separator(), ctrlTb );
3439 createTool( 6017, ctrlTb );
3440 createTool( 6009, ctrlTb );
3441 createTool( 6023, ctrlTb );
3442 createTool( separator(), ctrlTb );
3444 createTool( 4000, addRemTb );
3445 createTool( 4009, addRemTb );
3446 createTool( 4010, addRemTb );
3447 createTool( 4021, addRemTb );
3448 createTool( 4022, addRemTb );
3449 createTool( 4023, addRemTb );
3450 createTool( 4031, addRemTb );
3451 createTool( 4032, addRemTb );
3452 createTool( 4033, addRemTb );
3453 createTool( separator(), addRemTb );
3454 createTool( 4034, addRemTb );
3455 createTool( 4035, addRemTb );
3456 createTool( 4036, addRemTb );
3457 createTool( 4037, addRemTb );
3458 createTool( 4038, addRemTb );
3459 createTool( 4039, addRemTb );
3460 createTool( 4040, addRemTb );
3461 createTool( separator(), addRemTb );
3462 createTool( 4041, addRemTb );
3463 createTool( 4042, addRemTb );
3464 createTool( 4044, addRemTb );
3465 createTool( 4043, addRemTb );
3466 createTool( separator(), addRemTb );
3467 createTool( 4051, addRemTb );
3468 createTool( 4052, addRemTb );
3469 createTool( separator(), addRemTb );
3470 createTool( 4061, addRemTb );
3471 createTool( 4062, addRemTb );
3472 createTool( 4063, addRemTb );
3473 createTool( 4064, addRemTb );
3474 createTool( 4065, addRemTb );
3475 createTool( 4066, addRemTb );
3476 createTool( 4068, addRemTb );
3477 createTool( 4069, addRemTb );
3478 createTool( separator(), addRemTb );
3480 createTool( 4067,modifyTb );
3481 createTool( 407, modifyTb );
3482 createTool( 408, modifyTb );
3483 createTool( 409, modifyTb );
3484 createTool( 410, modifyTb );
3485 createTool( 411, modifyTb );
3486 createTool( 419, modifyTb );
3487 createTool( 412, modifyTb );
3488 createTool( 413, modifyTb );
3489 createTool( 416, modifyTb );
3490 createTool( 414, modifyTb );
3491 createTool( 415, modifyTb );
3492 createTool( 417, modifyTb );
3493 createTool( 418, modifyTb );
3495 createTool( 214, dispModeTb );
3497 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3498 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3501 QString OB = "'ObjectBrowser'",
3502 View = "'" + SVTK_Viewer::Type() + "'",
3504 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3505 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3506 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3507 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3508 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3509 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3510 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3511 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3512 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3513 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3514 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3516 mesh_group = mesh + " " + subMesh + " " + group,
3517 hyp_alg = hypo + " " + algo;
3519 // popup for object browser
3521 isInvisible("not( isVisible )"),
3522 isEmpty("numberOfNodes = 0"),
3523 isNotEmpty("numberOfNodes <> 0"),
3525 // has nodes, edges, etc in VISIBLE! actor
3526 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3527 hasElems("(count( elemTypes ) > 0)"),
3528 hasDifferentElems("(count( elemTypes ) > 1)"),
3529 hasElems0d("({'Elem0d'} in elemTypes)"),
3530 hasEdges("({'Edge'} in elemTypes)"),
3531 hasFaces("({'Face'} in elemTypes)"),
3532 hasVolumes("({'Volume'} in elemTypes)");
3534 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3535 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3536 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3537 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3538 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3539 createPopupItem( 803, OB, group ); // EDIT_GROUP
3540 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3542 popupMgr()->insert( separator(), -1, 0 );
3543 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3544 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3545 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3546 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3547 createPopupItem( 214, OB, mesh_group ); // UPDATE
3548 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3549 //createPopupItem( 902, OB, mesh ); // STD_INFO
3550 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3551 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3552 popupMgr()->insert( separator(), -1, 0 );
3553 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3554 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3555 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3556 popupMgr()->insert( separator(), -1, 0 );
3557 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3558 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3559 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3560 popupMgr()->insert( separator(), -1, 0 );
3561 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3562 popupMgr()->insert( separator(), -1, 0 );
3563 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3564 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3565 popupMgr()->insert( separator(), -1, 0 );
3567 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3568 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3570 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3571 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3572 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3573 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3574 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3575 popupMgr()->insert( separator(), -1, 0 );
3578 createPopupItem( 803, View, group ); // EDIT_GROUP
3579 createPopupItem( 804, View, elems ); // ADD
3580 createPopupItem( 805, View, elems ); // REMOVE
3582 popupMgr()->insert( separator(), -1, 0 );
3583 createPopupItem( 214, View, mesh_group ); // UPDATE
3584 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3585 //createPopupItem( 902, View, mesh ); // STD_INFO
3586 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3587 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3588 popupMgr()->insert( separator(), -1, 0 );
3590 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3591 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3592 popupMgr()->insert( separator(), -1, 0 );
3595 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3596 QString aType = QString( "%1type in {%2}" ).arg( lc );
3597 aType = aType.arg( mesh_group );
3598 QString aMeshInVTK = aClient + "&&" + aType;
3600 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3601 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3602 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3604 //-------------------------------------------------
3606 //-------------------------------------------------
3607 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3609 popupMgr()->insert( action( 9010 ), anId, -1 );
3610 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3611 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3613 popupMgr()->insert( action( 9011 ), anId, -1 );
3614 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3615 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3617 popupMgr()->insert( separator(), -1, -1 );
3619 //-------------------------------------------------
3621 //-------------------------------------------------
3622 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3624 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3625 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3626 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3628 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3629 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3630 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3632 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3633 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3634 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3636 popupMgr()->insert( separator(), anId, -1 );
3638 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3639 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3640 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3642 //-------------------------------------------------
3644 //-------------------------------------------------
3645 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3647 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3649 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3650 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3651 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3653 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3654 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3655 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3657 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3658 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3659 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3661 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3662 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3663 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3665 popupMgr()->insert( separator(), anId, -1 );
3667 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3668 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3671 //-------------------------------------------------
3672 // Representation of the 2D Quadratic elements
3673 //-------------------------------------------------
3674 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3675 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3676 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3677 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3679 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3680 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3681 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3683 //-------------------------------------------------
3684 // Orientation of faces
3685 //-------------------------------------------------
3686 popupMgr()->insert( action( 221 ), -1, -1 );
3687 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3688 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3690 //-------------------------------------------------
3692 //-------------------------------------------------
3693 popupMgr()->insert( action( 1132 ), -1, -1 );
3694 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3696 //-------------------------------------------------
3698 //-------------------------------------------------
3699 popupMgr()->insert( action( 1133 ), -1, -1 );
3700 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3702 //-------------------------------------------------
3704 //-------------------------------------------------
3706 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3707 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3708 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3709 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3711 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3713 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3714 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3716 popupMgr()->insert( separator(), anId, -1 );
3718 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3720 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3721 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3722 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3724 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3726 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3727 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3728 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3730 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3731 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3732 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3734 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3735 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3736 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3738 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3739 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3740 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3742 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3744 popupMgr()->insert( action( 6021 ), aSubId, -1 ); // FREE_FACE
3745 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3746 QtxPopupMgr::VisibleRule );
3747 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3749 popupMgr()->insert( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3750 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3751 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3753 popupMgr()->insert( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3754 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3755 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3757 popupMgr()->insert( action( 6011 ), aSubId, -1 ); // AREA
3758 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3759 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3761 popupMgr()->insert( action( 6012 ), aSubId, -1 ); // TAPER
3762 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3763 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3765 popupMgr()->insert( action( 6013 ), aSubId, -1 ); // ASPECT
3766 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3767 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3769 popupMgr()->insert( action( 6014 ), aSubId, -1 ); // MIN_ANG
3770 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3771 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3773 popupMgr()->insert( action( 6015 ), aSubId, -1 ); // WARP
3774 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3775 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3777 popupMgr()->insert( action( 6016 ), aSubId, -1 ); // SKEW
3778 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3779 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3781 popupMgr()->insert( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3782 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3783 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3785 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3787 popupMgr()->insert( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3788 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3789 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3791 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3792 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3793 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3795 popupMgr()->insert( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3796 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3797 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3799 popupMgr()->insert( separator(), anId, -1 );
3801 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3802 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3804 popupMgr()->insert( separator(), anId, -1 );
3806 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3807 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3809 popupMgr()->insert( separator(), -1, -1 );
3811 //-------------------------------------------------
3813 //-------------------------------------------------
3814 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3815 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3816 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3817 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3819 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3820 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3822 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3823 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3825 popupMgr()->insert( separator(), -1, -1 );
3827 //-------------------------------------------------
3829 //-------------------------------------------------
3830 popupMgr()->insert( action( 1134 ), -1, -1 );
3831 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3833 popupMgr()->insert( separator(), -1, -1 );
3835 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3836 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3838 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3839 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3842 //================================================================================
3844 * \brief Return true if SMESH or GEOM objects are selected.
3845 * Is called form LightApp_Module::activateModule() which clear selection if
3846 * not isSelectionCompatible()
3848 //================================================================================
3850 bool SMESHGUI::isSelectionCompatible()
3852 bool isCompatible = true;
3853 SALOME_ListIO selected;
3854 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3855 Sel->selectedObjects( selected );
3857 SALOME_ListIteratorOfListIO It( selected );
3858 for ( ; isCompatible && It.More(); It.Next())
3860 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3861 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3863 return isCompatible;
3867 bool SMESHGUI::reusableOperation( const int id )
3869 // compute, evaluate and precompute are not reusable operations
3870 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3873 bool SMESHGUI::activateModule( SUIT_Study* study )
3875 bool res = SalomeApp_Module::activateModule( study );
3877 setMenuShown( true );
3878 setToolShown( true );
3880 // Reset actions accelerator keys
3881 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3882 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3883 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3885 action( 33)->setEnabled(true); // Delete: Key_Delete
3886 action(1101)->setEnabled(true); // Rename: Key_F2
3888 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3889 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3890 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3891 if ( _PTR(Study) aStudy = s->studyDS()) {
3892 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3893 updateObjBrowser(); // objects can be removed
3899 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3901 setMenuShown( false );
3902 setToolShown( false );
3904 EmitSignalCloseAllDialogs();
3906 // Unset actions accelerator keys
3907 action(111)->setShortcut(QKeySequence()); // Import DAT
3908 action(112)->setShortcut(QKeySequence()); // Import UNV
3909 action(113)->setShortcut(QKeySequence()); // Import MED
3911 action( 33)->setEnabled(false); // Delete: Key_Delete
3912 action(1101)->setEnabled(false); // Rename: Key_F2
3914 return SalomeApp_Module::deactivateModule( study );
3917 void SMESHGUI::studyClosed( SUIT_Study* s )
3919 SMESH::RemoveVisuData( s->id() );
3920 SalomeApp_Module::studyClosed( s );
3923 void SMESHGUI::OnGUIEvent()
3925 const QObject* obj = sender();
3926 if ( !obj || !obj->inherits( "QAction" ) )
3928 int id = actionId((QAction*)obj);
3933 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3935 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3936 if ( CORBA::is_nil( myComponentSMESH ) )
3938 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3940 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3941 return aGUI.myComponentSMESH;
3944 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3945 return myComponentSMESH;
3948 QString SMESHGUI::engineIOR() const
3950 CORBA::ORB_var anORB = getApp()->orb();
3951 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3952 return QString( anIOR.in() );
3955 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3957 SalomeApp_Module::contextMenuPopup( client, menu, title );
3959 selectionMgr()->selectedObjects( lst );
3960 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3961 Handle(SALOME_InteractiveObject) io = lst.First();
3962 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3963 _PTR(Study) study = appStudy->studyDS();
3964 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3966 QString aName = QString( obj->GetName().c_str() );
3967 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3968 aName.remove( (aName.length() - 1), 1 );
3974 LightApp_Selection* SMESHGUI::createSelection() const
3976 return new SMESHGUI_Selection();
3979 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3981 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3982 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3985 void SMESHGUI::viewManagers( QStringList& list ) const
3987 list.append( SVTK_Viewer::Type() );
3990 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3992 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3993 SMESH::UpdateSelectionProp( this );
3996 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
3998 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
3999 myClippingPlaneInfoMap.erase( theViewManager );
4002 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4004 theActor->AddObserver( SMESH::DeleteActorEvent,
4005 myEventCallbackCommand.GetPointer(),
4009 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4010 unsigned long theEvent,
4011 void* theClientData,
4014 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4015 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4016 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4017 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4018 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4019 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4020 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4021 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4022 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4023 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4024 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4025 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4026 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4027 if( anActor == *anIter3 ) {
4028 anActorList.erase( anIter3 );
4039 void SMESHGUI::createPreferences()
4041 // General tab ------------------------------------------------------------------------
4042 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4044 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
4045 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
4047 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4048 setPreferenceProperty( qaGroup, "columns", 2 );
4049 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4050 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4051 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4052 setPreferenceProperty( prec, "min", 0 );
4053 setPreferenceProperty( prec, "max", 16 );
4055 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4056 setPreferenceProperty( dispgroup, "columns", 2 );
4057 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4059 modes.append( "Wireframe" );
4060 modes.append( "Shading" );
4061 modes.append( "Nodes" );
4062 modes.append( "Shrink" );
4063 QList<QVariant> indices;
4064 indices.append( 0 );
4065 indices.append( 1 );
4066 indices.append( 2 );
4067 indices.append( 3 );
4068 setPreferenceProperty( dispmode, "strings", modes );
4069 setPreferenceProperty( dispmode, "indexes", indices );
4071 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4072 setPreferenceProperty( arcgroup, "columns", 2 );
4073 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4074 QStringList quadraticModes;
4075 quadraticModes.append("Lines");
4076 quadraticModes.append("Arcs");
4078 indices.append( 0 );
4079 indices.append( 1 );
4080 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4081 setPreferenceProperty( quadraticmode, "indexes", indices );
4083 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4084 "SMESH", "max_angle" );
4085 setPreferenceProperty( maxAngle, "min", 1 );
4086 setPreferenceProperty( maxAngle, "max", 90 );
4090 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4091 setPreferenceProperty( exportgroup, "columns", 2 );
4092 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4093 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4095 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4096 setPreferenceProperty( computeGroup, "columns", 2 );
4097 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4099 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4100 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4101 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4103 indices.append( 0 );
4104 indices.append( 1 );
4105 indices.append( 2 );
4106 setPreferenceProperty( notifyMode, "strings", modes );
4107 setPreferenceProperty( notifyMode, "indexes", indices );
4109 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4110 setPreferenceProperty( computeGroup, "columns", 2 );
4111 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4113 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4114 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4116 indices.append( 0 );
4117 indices.append( 1 );
4118 setPreferenceProperty( elemInfo, "strings", modes );
4119 setPreferenceProperty( elemInfo, "indexes", indices );
4121 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4122 setPreferenceProperty( segGroup, "columns", 2 );
4123 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4124 "SMESH", "segmentation" );
4125 setPreferenceProperty( segLen, "min", 1 );
4126 setPreferenceProperty( segLen, "max", 10000000 );
4127 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4128 "SMESH", "nb_segments_per_edge" );
4129 setPreferenceProperty( nbSeg, "min", 1 );
4130 setPreferenceProperty( nbSeg, "max", 10000000 );
4132 // Quantities with individual precision settings
4133 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4134 setPreferenceProperty( precGroup, "columns", 2 );
4136 const int nbQuantities = 6;
4137 int precs[nbQuantities], ii = 0;
4138 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4139 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4140 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4141 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4142 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4143 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4144 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4145 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4146 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4147 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4148 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4149 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4151 // Set property for precision value for spinboxes
4152 for ( ii = 0; ii < nbQuantities; ii++ ){
4153 setPreferenceProperty( precs[ii], "min", -14 );
4154 setPreferenceProperty( precs[ii], "max", 14 );
4155 setPreferenceProperty( precs[ii], "precision", 2 );
4158 // Mesh tab ------------------------------------------------------------------------
4159 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4160 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4161 setPreferenceProperty( nodeGroup, "columns", 3 );
4163 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4165 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4167 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4168 QList<QVariant> aMarkerTypeIndicesList;
4169 QList<QVariant> aMarkerTypeIconsList;
4170 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4171 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4172 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4173 aMarkerTypeIndicesList << i;
4174 aMarkerTypeIconsList << pixmap;
4176 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4177 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4179 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4181 QList<QVariant> aMarkerScaleIndicesList;
4182 QStringList aMarkerScaleValuesList;
4183 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4184 aMarkerScaleIndicesList << i;
4185 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4187 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4188 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4190 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4191 setPreferenceProperty( elemGroup, "columns", 2 );
4193 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4194 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4195 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4196 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4198 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4199 setPreferenceProperty( grpGroup, "columns", 2 );
4201 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4203 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4204 //setPreferenceProperty( sp, "hstretch", 0 );
4205 //setPreferenceProperty( sp, "vstretch", 0 );
4207 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4208 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4209 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4210 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4211 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4212 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4213 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4215 setPreferenceProperty( size0d, "min", 1 );
4216 setPreferenceProperty( size0d, "max", 10 );
4218 setPreferenceProperty( sp, "hstretch", 0 );
4219 setPreferenceProperty( sp, "vstretch", 0 );
4221 setPreferenceProperty( elemW, "min", 1 );
4222 setPreferenceProperty( elemW, "max", 5 );
4224 setPreferenceProperty( shrink, "min", 0 );
4225 setPreferenceProperty( shrink, "max", 100 );
4227 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4228 setPreferenceProperty( orientGroup, "columns", 1 );
4230 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4231 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4233 setPreferenceProperty( orientScale, "min", 0.05 );
4234 setPreferenceProperty( orientScale, "max", 0.5 );
4235 setPreferenceProperty( orientScale, "step", 0.05 );
4237 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4239 // Selection tab ------------------------------------------------------------------------
4240 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4242 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4243 setPreferenceProperty( selGroup, "columns", 2 );
4245 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4246 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4247 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4249 setPreferenceProperty( selW, "min", 1 );
4250 setPreferenceProperty( selW, "max", 5 );
4252 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4253 setPreferenceProperty( preGroup, "columns", 2 );
4255 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4256 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4258 setPreferenceProperty( preW, "min", 1 );
4259 setPreferenceProperty( preW, "max", 5 );
4261 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4262 setPreferenceProperty( precSelGroup, "columns", 2 );
4264 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4265 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4266 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4268 // Scalar Bar tab ------------------------------------------------------------------------
4269 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4270 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4271 setPreferenceProperty( fontGr, "columns", 2 );
4273 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4274 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4276 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4277 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4279 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4280 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4282 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4283 setPreferenceProperty( numcol, "min", 2 );
4284 setPreferenceProperty( numcol, "max", 256 );
4286 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4287 setPreferenceProperty( numlab, "min", 2 );
4288 setPreferenceProperty( numlab, "max", 65 );
4290 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4291 setPreferenceProperty( orientGr, "columns", 2 );
4292 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4293 QStringList orients;
4294 orients.append( tr( "SMESH_VERTICAL" ) );
4295 orients.append( tr( "SMESH_HORIZONTAL" ) );
4296 indices.clear(); indices.append( 0 ); indices.append( 1 );
4297 setPreferenceProperty( orient, "strings", orients );
4298 setPreferenceProperty( orient, "indexes", indices );
4300 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4301 setPreferenceProperty( posVSizeGr, "columns", 2 );
4302 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4303 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4304 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4305 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4306 setPreferenceProperty( xv, "step", 0.1 );
4307 setPreferenceProperty( xv, "min", 0.0 );
4308 setPreferenceProperty( xv, "max", 1.0 );
4309 setPreferenceProperty( yv, "step", 0.1 );
4310 setPreferenceProperty( yv, "min", 0.0 );
4311 setPreferenceProperty( yv, "max", 1.0 );
4312 setPreferenceProperty( wv, "step", 0.1 );
4313 setPreferenceProperty( wv, "min", 0.0 );
4314 setPreferenceProperty( wv, "max", 1.0 );
4315 setPreferenceProperty( hv, "min", 0.0 );
4316 setPreferenceProperty( hv, "max", 1.0 );
4317 setPreferenceProperty( hv, "step", 0.1 );
4319 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4320 setPreferenceProperty( posHSizeGr, "columns", 2 );
4321 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4322 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4323 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4324 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4325 setPreferenceProperty( xv, "min", 0.0 );
4326 setPreferenceProperty( xv, "max", 1.0 );
4327 setPreferenceProperty( xv, "step", 0.1 );
4328 setPreferenceProperty( xh, "min", 0.0 );
4329 setPreferenceProperty( xh, "max", 1.0 );
4330 setPreferenceProperty( xh, "step", 0.1 );
4331 setPreferenceProperty( yh, "min", 0.0 );
4332 setPreferenceProperty( yh, "max", 1.0 );
4333 setPreferenceProperty( yh, "step", 0.1 );
4334 setPreferenceProperty( wh, "min", 0.0 );
4335 setPreferenceProperty( wh, "max", 1.0 );
4336 setPreferenceProperty( wh, "step", 0.1 );
4337 setPreferenceProperty( hh, "min", 0.0 );
4338 setPreferenceProperty( hh, "max", 1.0 );
4339 setPreferenceProperty( hh, "step", 0.1 );
4342 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4344 if( sect=="SMESH" ) {
4345 float sbX1,sbY1,sbW,sbH;
4346 float aTol = 1.00000009999999;
4347 std::string aWarning;
4348 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4349 if( name=="selection_object_color" || name=="selection_element_color" ||
4350 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4351 name=="selection_precision_node" || name=="selection_precision_element" ||
4352 name=="selection_precision_object")
4353 SMESH::UpdateSelectionProp( this );
4354 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4355 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4356 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4357 if(sbX1+sbW > aTol){
4358 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4361 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4362 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4365 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4366 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4367 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4368 if(sbY1+sbH > aTol){
4369 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4370 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4371 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4374 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4375 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4376 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4377 if(sbX1+sbW > aTol){
4378 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4381 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4382 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4385 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4386 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4387 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4388 if(sbY1+sbH > aTol){
4389 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4392 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4393 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4396 else if ( name == "segmentation" ) {
4397 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4398 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4400 else if ( name == "nb_segments_per_edge" ) {
4401 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4402 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4405 if(aWarning.size() != 0){
4406 aWarning += "The default values are applied instead.";
4407 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4408 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4409 QObject::tr(aWarning.c_str()));
4414 //================================================================================
4416 * \brief Update something in accordance with update flags
4417 * \param theFlags - update flags
4419 * Update viewer or/and object browser etc. in accordance with update flags ( see
4420 * LightApp_UpdateFlags enumeration ).
4422 //================================================================================
4423 void SMESHGUI::update( const int flags )
4425 if ( flags & UF_Viewer | flags & UF_Forced )
4426 SMESH::UpdateView();
4428 SalomeApp_Module::update( flags );
4431 //================================================================================
4433 * \brief Set default selection mode
4435 * SLOT called when operation commited. Sets default selection mode
4437 //================================================================================
4438 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4440 SVTK_ViewWindow* vtkWnd =
4441 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4443 vtkWnd->SetSelectionMode( ActorSelection );
4446 //================================================================================
4448 * \brief Set default selection mode
4450 * SLOT called when operation aborted. Sets default selection mode
4452 //================================================================================
4453 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4455 SVTK_ViewWindow* vtkWnd =
4456 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4458 vtkWnd->SetSelectionMode( ActorSelection );
4461 //================================================================================
4463 * \brief Creates operation with given identifier
4464 * \param id - identifier of operation to be started
4465 * \return Pointer on created operation or NULL if operation is not created
4467 * Virtual method redefined from the base class creates operation with given id.
4468 * It is called called automatically from startOperation method of base class.
4470 //================================================================================
4471 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4473 LightApp_Operation* op = 0;
4474 // to do : create operation here
4477 case 417: //convert to quadratic
4478 op = new SMESHGUI_ConvToQuadOp();
4480 case 418: // create 2D mesh as boundary on 3D
4481 op = new SMESHGUI_Make2DFrom3DOp();
4483 case 701: // Compute mesh
4484 op = new SMESHGUI_ComputeOp();
4486 case 702: // Create mesh
4487 op = new SMESHGUI_MeshOp( true, true );
4489 case 703: // Create sub-mesh
4490 op = new SMESHGUI_MeshOp( true, false );
4492 case 704: // Edit mesh/sub-mesh
4493 op = new SMESHGUI_MeshOp( false );
4495 case 711: // Precompute mesh
4496 op = new SMESHGUI_PrecomputeOp();
4498 case 712: // Evaluate mesh
4499 op = new SMESHGUI_EvaluateOp();
4501 case 713: // Evaluate mesh
4502 op = new SMESHGUI_MeshOrderOp();
4504 case 806: // Create group on geom
4505 op = new SMESHGUI_GroupOnShapeOp();
4507 case 904: // Find element
4508 op = new SMESHGUI_FindElemByPointOp();
4510 case 4067: // make mesh pass through point
4511 op = new SMESHGUI_MakeNodeAtPointOp();
4518 op = SalomeApp_Module::createOperation( id );
4522 //================================================================================
4524 * \brief Stops current operations and starts a given one
4525 * \param id - The id of the operation to start
4527 //================================================================================
4529 void SMESHGUI::switchToOperation(int id)
4531 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4532 activeStudy()->abortAllOperations();
4533 startOperation( id );
4536 LightApp_Displayer* SMESHGUI::displayer()
4539 myDisplayer = new SMESHGUI_Displayer( getApp() );
4543 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4546 int aTolerance = 64;
4547 int anIterations = 0;
4553 if( anIterations % aPeriod == 0 )
4556 if( aTolerance < 1 )
4560 aHue = (int)( 360.0 * rand() / RAND_MAX );
4563 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4564 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4565 for( ; it != itEnd; ++it )
4567 SALOMEDS::Color anAutoColor = *it;
4568 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4571 aQColor.getHsv( &h, &s, &v );
4572 if( abs( h - aHue ) < aTolerance )
4584 aColor.setHsv( aHue, 255, 255 );
4586 SALOMEDS::Color aSColor;
4587 aSColor.R = (double)aColor.red() / 255.0;
4588 aSColor.G = (double)aColor.green() / 255.0;
4589 aSColor.B = (double)aColor.blue() / 255.0;
4594 const char gSeparator = '_'; // character used to separate parameter names
4595 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4596 const char gPathSep = '|'; // character used to separate paths
4599 * \brief Store visual parameters
4601 * This method is called just before the study document is saved.
4602 * Store visual parameters in AttributeParameter attribue(s)
4604 void SMESHGUI::storeVisualParameters (int savePoint)
4606 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4607 if (!appStudy || !appStudy->studyDS())
4609 _PTR(Study) studyDS = appStudy->studyDS();
4611 // componentName is used for encoding of entries when storing them in IParameters
4612 std::string componentName = myComponentSMESH->ComponentDataType();
4613 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4614 //if (!aSComponent) return;
4617 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4618 componentName.c_str(),
4620 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4622 // store map of custom markers
4623 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4624 if( !aMarkerMap.empty() )
4626 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4627 for( ; anIter != aMarkerMap.end(); anIter++ )
4629 int anId = anIter->first;
4630 VTK::MarkerData aMarkerData = anIter->second;
4631 std::string aMarkerFileName = aMarkerData.first;
4632 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4633 if( aMarkerTexture.size() < 3 )
4634 continue; // should contain at least width, height and the first value
4636 QString aPropertyName( "texture" );
4637 aPropertyName += gSeparator;
4638 aPropertyName += QString::number( anId );
4640 QString aPropertyValue = aMarkerFileName.c_str();
4641 aPropertyValue += gPathSep;
4643 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4644 ushort aWidth = *aTextureIter++;
4645 ushort aHeight = *aTextureIter++;
4646 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4647 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4648 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4649 aPropertyValue += QString::number( *aTextureIter );
4651 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4655 // viewers counters are used for storing view_numbers in IParameters
4658 // main cycle to store parameters of displayed objects
4659 QList<SUIT_ViewManager*> lst;
4660 QList<SUIT_ViewManager*>::Iterator it;
4661 getApp()->viewManagers(lst);
4662 for (it = lst.begin(); it != lst.end(); it++)
4664 SUIT_ViewManager* vman = *it;
4665 QString vType = vman->getType();
4667 // saving VTK actors properties
4668 if (vType == SVTK_Viewer::Type())
4670 // store the clipping planes attached to the view manager
4671 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4672 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4673 if( anIter != myClippingPlaneInfoMap.end() )
4674 aClippingPlaneInfoList = anIter->second;
4676 if( !aClippingPlaneInfoList.empty() ) {
4677 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4678 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4680 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4681 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4683 QString aPropertyName( "ClippingPlane" );
4684 aPropertyName += gSeparator;
4685 aPropertyName += QString::number( vtkViewers );
4686 aPropertyName += gSeparator;
4687 aPropertyName += QString::number( anId );
4689 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4690 aPropertyValue += gDigitsSep;
4691 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4692 aPropertyValue += gDigitsSep;
4693 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4694 aPropertyValue += gDigitsSep;
4695 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4697 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4701 QVector<SUIT_ViewWindow*> views = vman->getViews();
4702 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4704 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4706 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4707 vtkActorCollection* allActors = aCopy.GetActors();
4708 allActors->InitTraversal();
4709 while (vtkActor* actor = allActors->GetNextActor())
4711 if (actor->GetVisibility()) // store only visible actors
4713 SMESH_Actor* aSmeshActor = 0;
4714 if (actor->IsA("SMESH_Actor"))
4715 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4716 if (aSmeshActor && aSmeshActor->hasIO())
4718 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4721 // entry is "encoded" = it does NOT contain component adress,
4722 // since it is a subject to change on next component loading
4723 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4725 std::string param, vtkParam = vType.toLatin1().data();
4726 vtkParam += gSeparator;
4727 vtkParam += QString::number(vtkViewers).toLatin1().data();
4728 vtkParam += gSeparator;
4731 param = vtkParam + "Visibility";
4732 ip->setParameter(entry, param, "On");
4735 param = vtkParam + "Representation";
4736 ip->setParameter(entry, param, QString::number
4737 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4740 param = vtkParam + "IsShrunk";
4741 ip->setParameter(entry, param, QString::number
4742 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4744 // Displayed entities
4745 unsigned int aMode = aSmeshActor->GetEntityMode();
4746 bool isE = aMode & SMESH_Actor::eEdges;
4747 bool isF = aMode & SMESH_Actor::eFaces;
4748 bool isV = aMode & SMESH_Actor::eVolumes;
4750 QString modeStr ("e");
4751 modeStr += gDigitsSep; modeStr += QString::number(isE);
4752 modeStr += gDigitsSep; modeStr += "f";
4753 modeStr += gDigitsSep; modeStr += QString::number(isF);
4754 modeStr += gDigitsSep; modeStr += "v";
4755 modeStr += gDigitsSep; modeStr += QString::number(isV);
4757 param = vtkParam + "Entities";
4758 ip->setParameter(entry, param, modeStr.toLatin1().data());
4760 // Colors (surface:edge:)
4761 vtkFloatingPointType r, g, b;
4763 aSmeshActor->GetSufaceColor(r, g, b);
4764 QString colorStr ("surface");
4765 colorStr += gDigitsSep; colorStr += QString::number(r);
4766 colorStr += gDigitsSep; colorStr += QString::number(g);
4767 colorStr += gDigitsSep; colorStr += QString::number(b);
4769 aSmeshActor->GetBackSufaceColor(r, g, b);
4770 colorStr += gDigitsSep; colorStr += "backsurface";
4771 colorStr += gDigitsSep; colorStr += QString::number(r);
4772 colorStr += gDigitsSep; colorStr += QString::number(g);
4773 colorStr += gDigitsSep; colorStr += QString::number(b);
4775 aSmeshActor->GetEdgeColor(r, g, b);
4776 colorStr += gDigitsSep; colorStr += "edge";
4777 colorStr += gDigitsSep; colorStr += QString::number(r);
4778 colorStr += gDigitsSep; colorStr += QString::number(g);
4779 colorStr += gDigitsSep; colorStr += QString::number(b);
4781 aSmeshActor->GetNodeColor(r, g, b);
4782 colorStr += gDigitsSep; colorStr += "node";
4783 colorStr += gDigitsSep; colorStr += QString::number(r);
4784 colorStr += gDigitsSep; colorStr += QString::number(g);
4785 colorStr += gDigitsSep; colorStr += QString::number(b);
4787 param = vtkParam + "Colors";
4788 ip->setParameter(entry, param, colorStr.toLatin1().data());
4790 // Sizes of lines and points
4791 QString sizeStr ("line");
4792 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4793 sizeStr += gDigitsSep; sizeStr += "shrink";
4794 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4796 param = vtkParam + "Sizes";
4797 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4802 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4803 if( aMarkerType == VTK::MT_USER ) {
4804 markerStr += "custom";
4805 markerStr += gDigitsSep;
4806 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4810 markerStr += gDigitsSep;
4811 markerStr += QString::number( (int)aMarkerType );
4812 markerStr += gDigitsSep;
4813 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4816 param = vtkParam + "PointMarker";
4817 ip->setParameter(entry, param, markerStr.toLatin1().data());
4820 param = vtkParam + "Opacity";
4821 ip->setParameter(entry, param,
4822 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4825 param = vtkParam + "ClippingPlane";
4827 if( !aClippingPlaneInfoList.empty() ) {
4828 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4829 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
4831 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
4832 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
4833 SMESH::TActorList::iterator anIter2 = anActorList.begin();
4834 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
4835 if( aSmeshActor == *anIter2 ) {
4836 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
4837 QString::number( anId ).toLatin1().constData() );
4844 ip->setParameter( entry, param, "Off" );
4845 } // if (io->hasEntry())
4846 } // SMESH_Actor && hasIO
4848 } // while.. actors traversal
4852 } // if (SVTK view model)
4853 } // for (viewManagers)
4856 // data structures for clipping planes processing
4859 vtkIdType Orientation;
4860 vtkFloatingPointType Distance;
4861 vtkFloatingPointType Angle[2];
4863 typedef std::list<TPlaneData> TPlaneDataList;
4864 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
4866 typedef std::list<vtkActor*> TActorList;
4869 TActorList ActorList;
4870 SUIT_ViewManager* ViewManager;
4872 typedef std::list<TPlaneInfo> TPlaneInfoList;
4873 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
4876 * \brief Restore visual parameters
4878 * This method is called after the study document is opened.
4879 * Restore visual parameters from AttributeParameter attribue(s)
4881 void SMESHGUI::restoreVisualParameters (int savePoint)
4883 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4884 if (!appStudy || !appStudy->studyDS())
4886 _PTR(Study) studyDS = appStudy->studyDS();
4888 // componentName is used for encoding of entries when storing them in IParameters
4889 std::string componentName = myComponentSMESH->ComponentDataType();
4890 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4891 //if (!aSComponent) return;
4894 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4895 componentName.c_str(),
4897 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4899 // restore map of custom markers and map of clipping planes
4900 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4901 TPlaneDataMap aPlaneDataMap;
4903 std::vector<std::string> properties = ip->getProperties();
4904 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4906 std::string property = *propIt;
4907 QString aPropertyName( property.c_str() );
4908 QString aPropertyValue( ip->getProperty( property ).c_str() );
4910 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4911 if( aPropertyNameList.isEmpty() )
4914 QString aPropertyType = aPropertyNameList[0];
4915 if( aPropertyType == "texture" )
4917 if( aPropertyNameList.size() != 2 )
4921 int anId = aPropertyNameList[1].toInt( &ok );
4922 if( !ok || anId < 1 )
4925 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4926 if( aPropertyValueList.size() != 2 )
4929 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4930 QString aMarkerTextureString = aPropertyValueList[1];
4931 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4932 if( aMarkerTextureStringList.size() != 3 )
4936 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4941 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4945 VTK::MarkerTexture aMarkerTexture;
4946 aMarkerTexture.push_back( aWidth );
4947 aMarkerTexture.push_back( aHeight );
4949 QString aMarkerTextureData = aMarkerTextureStringList[2];
4950 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4952 QChar aChar = aMarkerTextureData.at( i );
4953 if( aChar.isDigit() )
4954 aMarkerTexture.push_back( aChar.digitValue() );
4957 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4959 else if( aPropertyType == "ClippingPlane" )
4961 if( aPropertyNameList.size() != 3 )
4965 int aViewId = aPropertyNameList[1].toInt( &ok );
4966 if( !ok || aViewId < 0 )
4970 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
4971 if( !ok || aClippingPlaneId < 0 )
4974 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
4975 if( aPropertyValueList.size() != 4 )
4978 TPlaneData aPlaneData;
4979 aPlaneData.Id = aClippingPlaneId;
4982 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
4987 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
4992 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
4997 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5001 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5002 aPlaneDataList.push_back( aPlaneData );
5006 TPlaneInfoMap aPlaneInfoMap;
5008 std::vector<std::string> entries = ip->getEntries();
5010 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5012 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5013 QString entry (ip->decodeEntry(*entIt).c_str());
5015 // Check that the entry corresponds to a real object in the Study
5016 // as the object may be deleted or modified after the visual state is saved.
5017 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5018 if (!so) continue; //Skip the not existent entry
5020 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5021 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5023 std::vector<std::string>::iterator namesIt = paramNames.begin();
5024 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5026 // actors are stored in a map after displaying of them for
5027 // quicker access in the future: map < viewID to actor >
5028 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5030 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5032 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5033 // '_' is used as separator and should not be used in viewer type or parameter names.
5034 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5035 if (lst.size() != 3)
5038 QString viewerTypStr = lst[0];
5039 QString viewIndexStr = lst[1];
5040 QString paramNameStr = lst[2];
5043 int viewIndex = viewIndexStr.toUInt(&ok);
5044 if (!ok) // bad conversion of view index to integer
5048 if (viewerTypStr == SVTK_Viewer::Type())
5050 SMESH_Actor* aSmeshActor = 0;
5051 if (vtkActors.IsBound(viewIndex))
5052 aSmeshActor = vtkActors.Find(viewIndex);
5054 QList<SUIT_ViewManager*> lst;
5055 getApp()->viewManagers(viewerTypStr, lst);
5057 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5058 SUIT_ViewManager* vman = NULL;
5059 if (viewIndex >= 0 && viewIndex < lst.count())
5060 vman = lst.at(viewIndex);
5062 if (paramNameStr == "Visibility")
5064 if (!aSmeshActor && displayer() && vman)
5066 SUIT_ViewModel* vmodel = vman->getViewModel();
5067 // SVTK view model can be casted to SALOME_View
5068 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5070 // store displayed actor in a temporary map for quicker
5071 // access later when restoring other parameters
5072 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5073 vtkRenderer* Renderer = vtkView->getRenderer();
5074 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5075 vtkActorCollection* theActors = aCopy.GetActors();
5076 theActors->InitTraversal();
5077 bool isFound = false;
5078 vtkActor *ac = theActors->GetNextActor();
5079 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5080 if (ac->IsA("SMESH_Actor")) {
5081 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5082 if (aGeomAc->hasIO()) {
5083 Handle(SALOME_InteractiveObject) io =
5084 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5085 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5087 vtkActors.Bind(viewIndex, aGeomAc);
5093 } // if (paramNameStr == "Visibility")
5096 // the rest properties "work" with SMESH_Actor
5099 QString val ((*valuesIt).c_str());
5102 if (paramNameStr == "Representation") {
5103 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5106 else if (paramNameStr == "IsShrunk") {
5108 if (!aSmeshActor->IsShrunk())
5109 aSmeshActor->SetShrink();
5112 if (aSmeshActor->IsShrunk())
5113 aSmeshActor->UnShrink();
5116 // Displayed entities
5117 else if (paramNameStr == "Entities") {
5118 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5119 if (mode.count() == 6) {
5120 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5121 MESSAGE("Invalid order of data in Entities, must be: "
5122 "e:0/1:f:0/1:v:0/1");
5125 unsigned int aMode = aSmeshActor->GetEntityMode();
5126 unsigned int aNewMode =
5127 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5128 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5129 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5130 if (aNewMode != aMode)
5131 aSmeshActor->SetEntityMode(aNewMode);
5136 else if (paramNameStr == "Colors") {
5137 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5138 if (colors.count() == 16) {
5139 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5140 colors[8] != "edge" || colors[12] != "node") {
5141 MESSAGE("Invalid order of data in Colors, must be: "
5142 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5145 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5146 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5147 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5148 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5152 // Sizes of lines and points
5153 else if (paramNameStr == "Sizes") {
5154 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5155 if (sizes.count() == 4) {
5156 if (sizes[0] != "line" || sizes[2] != "shrink") {
5157 MESSAGE("Invalid order of data in Sizes, must be: "
5158 "line:int:shrink:float");
5161 aSmeshActor->SetLineWidth(sizes[1].toInt());
5162 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5165 else if (sizes.count() == 6) { // just to support old format
5166 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5167 MESSAGE("Invalid order of data in Sizes, must be: "
5168 "line:int:node:int:shrink:float");
5171 aSmeshActor->SetLineWidth(sizes[1].toInt());
5172 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5173 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5178 else if (paramNameStr == "PointMarker") {
5179 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5180 if( data.count() >= 2 ) {
5182 int aParam1 = data[1].toInt( &ok );
5184 if( data[0] == "std" && data.count() == 3 ) {
5185 int aParam2 = data[2].toInt( &ok );
5186 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5188 else if( data[0] == "custom" ) {
5189 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5190 if( markerIt != aMarkerMap.end() ) {
5191 VTK::MarkerData aMarkerData = markerIt->second;
5192 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5199 else if (paramNameStr == "Opacity") {
5200 aSmeshActor->SetOpacity(val.toFloat());
5203 else if (paramNameStr.startsWith("ClippingPlane")) {
5204 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5205 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5206 // new format - val looks like "Off" or "0" (plane id)
5207 // (note: in new format "Off" value is used only for consistency,
5208 // so it is processed together with values in old format)
5209 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5210 if( anIsOldFormat ) {
5211 if (paramNameStr == "ClippingPlane1" || val == "Off")
5212 aSmeshActor->RemoveAllClippingPlanes();
5214 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5215 double aDistance = vals[1].toFloat();
5216 vtkFloatingPointType anAngle[2];
5217 anAngle[0] = vals[2].toFloat();
5218 anAngle[1] = vals[3].toFloat();
5220 QList<SUIT_ViewManager*> lst;
5221 getApp()->viewManagers(viewerTypStr, lst);
5222 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5223 if (viewIndex >= 0 && viewIndex < lst.count()) {
5224 SUIT_ViewManager* vman = lst.at(viewIndex);
5225 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5227 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5229 SMESH::TActorList anActorList;
5230 anActorList.push_back( aSmeshActor );
5231 SMESH::OrientedPlane* aPlane =
5232 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5234 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5235 aClippingPlaneInfo.Plane = aPlane;
5236 aClippingPlaneInfo.ActorList = anActorList;
5237 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5244 int aPlaneId = val.toInt( &ok );
5245 if( ok && aPlaneId >= 0 ) {
5246 bool anIsDefinedPlane = false;
5247 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5248 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5249 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5250 TPlaneInfo& aPlaneInfo = *anIter;
5251 if( aPlaneInfo.PlaneId == aPlaneId ) {
5252 aPlaneInfo.ActorList.push_back( aSmeshActor );
5253 anIsDefinedPlane = true;
5257 if( !anIsDefinedPlane ) {
5258 TPlaneInfo aPlaneInfo;
5259 aPlaneInfo.PlaneId = aPlaneId;
5260 aPlaneInfo.ActorList.push_back( aSmeshActor );
5261 aPlaneInfo.ViewManager = vman;
5262 aPlaneInfoList.push_back( aPlaneInfo );
5267 } // if (aSmeshActor)
5268 } // other parameters than Visibility
5270 } // for names/parameters iterator
5271 } // for entries iterator
5273 // add clipping planes to actors according to the restored parameters
5274 // and update the clipping plane map
5275 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5276 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5277 int aViewId = anIter1->first;
5278 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5280 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5281 if( anIter2 == aPlaneDataMap.end() )
5283 const TPlaneDataList& aPlaneDataList = anIter2->second;
5285 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5286 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5287 const TPlaneInfo& aPlaneInfo = *anIter3;
5288 int aPlaneId = aPlaneInfo.PlaneId;
5289 const TActorList& anActorList = aPlaneInfo.ActorList;
5290 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5294 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5298 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5300 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5301 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5302 const TPlaneData& aPlaneData = *anIter4;
5303 if( aPlaneData.Id == aPlaneId ) {
5304 SMESH::OrientedPlane* aPlane =
5305 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5307 (SMESH::Orientation)aPlaneData.Orientation,
5308 aPlaneData.Distance,
5311 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5312 aClippingPlaneInfo.Plane = aPlane;
5313 aClippingPlaneInfo.ActorList = anActorList;
5314 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5322 // update all VTK views
5323 QList<SUIT_ViewManager*> lst;
5324 getApp()->viewManagers(lst);
5325 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5326 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5327 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5328 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5329 vtkView->getRenderer()->ResetCameraClippingRange();
5336 \brief Adds preferences for dfont of VTK viewer
5338 \param pIf group identifier
5339 \param param parameter
5340 \return identifier of preferences
5342 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5344 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5346 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5349 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5350 fam.append( tr( "SMESH_FONT_COURIER" ) );
5351 fam.append( tr( "SMESH_FONT_TIMES" ) );
5353 setPreferenceProperty( tfont, "fonts", fam );
5355 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5356 setPreferenceProperty( tfont, "features", f );
5362 \brief Actions after hypothesis edition
5363 Updates object browser after hypothesis edition
5365 void SMESHGUI::onHypothesisEdit( int result )
5368 SMESHGUI::Modified();
5369 updateObjBrowser( true );