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_MeshOp.h"
53 #include "SMESHGUI_MeshOrderOp.h"
54 #include "SMESHGUI_MeshPatternDlg.h"
55 #include "SMESHGUI_MultiEditDlg.h"
56 #include "SMESHGUI_NodesDlg.h"
57 #include "SMESHGUI_Preferences_ColorDlg.h"
58 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
59 #include "SMESHGUI_RemoveElementsDlg.h"
60 #include "SMESHGUI_RemoveNodesDlg.h"
61 #include "SMESHGUI_RenumberingDlg.h"
62 #include "SMESHGUI_RevolutionDlg.h"
63 #include "SMESHGUI_RotationDlg.h"
64 #include "SMESHGUI_Selection.h"
65 #include "SMESHGUI_SewingDlg.h"
66 #include "SMESHGUI_SingleEditDlg.h"
67 #include "SMESHGUI_SmoothingDlg.h"
68 #include "SMESHGUI_StandardMeshInfosDlg.h"
69 #include "SMESHGUI_SymmetryDlg.h"
70 #include "SMESHGUI_TranslationDlg.h"
71 #include "SMESHGUI_ScaleDlg.h"
72 #include "SMESHGUI_TransparencyDlg.h"
73 #include "SMESHGUI_WhatIsDlg.h"
74 #include "SMESHGUI_DuplicateNodesDlg.h"
76 #include "SMESHGUI_Utils.h"
77 #include "SMESHGUI_MeshUtils.h"
78 #include "SMESHGUI_GroupUtils.h"
79 #include "SMESHGUI_FilterUtils.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_VTKUtils.h"
82 #include "SMESHGUI_HypothesesUtils.h"
84 #include <SMESH_Client.hxx>
85 #include <SMESH_Actor.h>
86 #include <SMESH_TypeFilter.hxx>
87 #include "SMESH_ControlsDef.hxx"
89 // SALOME GUI includes
90 #include <SalomeApp_Tools.h>
91 #include <SalomeApp_Study.h>
92 #include <SalomeApp_Application.h>
93 #include <SalomeApp_CheckFileDlg.h>
95 #include <LightApp_DataOwner.h>
96 #include <LightApp_Preferences.h>
97 #include <LightApp_SelectionMgr.h>
98 #include <LightApp_UpdateFlags.h>
99 #include <LightApp_NameDlg.h>
101 #include <SVTK_ViewWindow.h>
102 #include <SVTK_ViewModel.h>
103 #include <SVTK_ViewManager.h>
105 #include <VTKViewer_Algorithm.h>
107 #include <SUIT_MessageBox.h>
108 #include <SUIT_ResourceMgr.h>
109 #include <SUIT_FileDlg.h>
110 #include <SUIT_Desktop.h>
111 #include <SUIT_OverrideCursor.h>
112 #include <SUIT_Session.h>
114 #include <QtxPopupMgr.h>
115 #include <QtxFontEdit.h>
117 #include <SALOME_ListIO.hxx>
118 #include <SALOME_ListIteratorOfListIO.hxx>
121 #include <SALOMEconfig.h>
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
126 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
128 #include <QTextStream>
131 #include <boost/shared_ptr.hpp>
134 #include <vtkScalarBarActor.h>
135 #include <vtkCamera.h>
136 #include <vtkRenderer.h>
137 #include <vtkPlane.h>
139 // SALOME KERNEL includes
140 #include <SALOMEDS_Study.hxx>
141 #include <SALOMEDSClient_StudyBuilder.hxx>
142 #include <SALOMEDSClient_SComponent.hxx>
143 #include <SALOMEDSClient_ClientFactory.hxx>
144 #include <SALOMEDSClient_IParameters.hxx>
147 #include <Standard_ErrorHandler.hxx>
148 #include <NCollection_DataMap.hxx>
150 //To disable automatic genericobj management, the following line should be commented.
151 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
152 #define WITHGENERICOBJ
156 //=============================================================
157 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
160 void ExportMeshToFile(int theCommandID);
162 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
164 void SetDisplayEntity(int theCommandID);
166 void Control( int theCommandID );
170 //=============================================================
171 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
175 std::string myExtension;
177 if ( theCommandID == 113 ) {
178 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
179 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
181 else if ( theCommandID == 112 ) {
182 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
184 else if ( theCommandID == 111 ) {
185 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
188 QString anInitialPath = "";
189 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
190 anInitialPath = QDir::currentPath();
192 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
195 QObject::tr( "SMESH_IMPORT_MESH" ) );
196 if ( filenames.count() > 0 ) {
197 SUIT_OverrideCursor wc;
198 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
201 bool isEmpty = false;
202 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
203 QString filename = *it;
204 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
206 switch ( theCommandID ) {
209 // DAT format (currently unsupported)
210 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
211 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
217 aMeshes->length( 1 );
218 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
219 if ( aMeshes[0]->_is_nil() )
220 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
221 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
227 SMESH::DriverMED_ReadStatus res;
228 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
229 if ( res != SMESH::DRS_OK ) {
230 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
231 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
237 catch ( const SALOME::SALOME_Exception& S_ex ) {
238 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
239 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
242 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
243 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
245 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
246 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
247 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
248 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
249 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
251 #ifdef WITHGENERICOBJ
252 // obj has been published in study. Its refcount has been incremented.
253 // It is safe to decrement its refcount
254 // so that it will be destroyed when the entry in study will be removed
255 aMeshes[i]->Destroy();
264 // update Object browser
265 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
267 // show Error message box if there were errors
268 if ( errors.count() > 0 ) {
269 SUIT_MessageBox::critical( SMESHGUI::desktop(),
270 QObject::tr( "SMESH_ERROR" ),
271 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
274 // show warning message box, if some imported mesh is empty
276 SUIT_MessageBox::warning( SMESHGUI::desktop(),
277 QObject::tr( "SMESH_WRN_WARNING" ),
278 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
283 void ExportMeshToFile( int theCommandID )
285 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
286 SALOME_ListIO selected;
288 aSel->selectedObjects( selected );
290 // actually, the following condition can't be met (added for insurance)
291 if( selected.Extent() == 0 ||
292 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
295 bool hasDuplicatedMeshNames = false;
296 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
297 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
298 SALOME_ListIteratorOfListIO It( selected );
299 for( ; It.More(); It.Next() ) {
300 Handle(SALOME_InteractiveObject) anIObject = It.Value();
301 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
302 if ( aMeshItem->_is_nil() ) {
303 SUIT_MessageBox::warning( SMESHGUI::desktop(),
304 QObject::tr( "SMESH_WRN_WARNING" ),
305 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
309 QString aMeshName = anIObject->getName();
311 // check for duplications
312 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
313 if( aMeshName == (*aMeshIter).second ) {
314 hasDuplicatedMeshNames = true;
319 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
322 if( hasDuplicatedMeshNames ) {
323 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
324 QObject::tr("SMESH_WRN_WARNING"),
325 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
326 QObject::tr("SMESH_BUT_YES"),
327 QObject::tr("SMESH_BUT_NO"), 0, 1);
332 aMeshIter = aMeshList.begin();
333 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
334 QString aMeshName = (*aMeshIter).second;
336 QList<SALOMEDS::Color> aReservedColors;
338 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
339 QMap<QString, SMESH::MED_VERSION> aFilterMap;
340 QMap<QString, int> aFilterMapSTL;
341 switch ( theCommandID ) {
345 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
346 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
347 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
348 int aRet = SUIT_MessageBox::warning
349 (SMESHGUI::desktop(),
350 QObject::tr("SMESH_WRN_WARNING"),
351 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
352 QObject::tr("SMESH_BUT_YES"),
353 QObject::tr("SMESH_BUT_NO"), 0, 1);
359 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
360 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
361 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
362 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
367 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
372 if (aMesh->NbPyramids()) {
373 int aRet = SUIT_MessageBox::warning
374 (SMESHGUI::desktop(),
375 QObject::tr("SMESH_WRN_WARNING"),
376 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
377 QObject::tr("SMESH_BUT_YES"),
378 QObject::tr("SMESH_BUT_NO"), 0, 1);
382 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
390 there must be check on others mesh elements not equal triangles
392 if (aMesh->NbTriangles() < 1) {
393 SUIT_MessageBox::warning
394 (SMESHGUI::desktop(),
395 QObject::tr("SMESH_WRN_WARNING"),
396 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
399 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
400 int aRet = SUIT_MessageBox::warning
401 (SMESHGUI::desktop(),
402 QObject::tr("SMESH_WRN_WARNING"),
403 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
404 QObject::tr("SMESH_BUT_YES"),
405 QObject::tr("SMESH_BUT_NO"), 0, 1);
410 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
411 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
419 SMESH::MED_VERSION aFormat;
420 // Init the parameter with the default value
421 bool aIsASCII_STL = true;
422 bool toCreateGroups = false;
423 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
425 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
426 bool toOverwrite = true;
428 QString anInitialPath = "";
429 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
430 anInitialPath = QDir::currentPath();
432 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
433 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
434 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
435 aFilter, aTitle, false);
437 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
439 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
440 for ( ; it != aFilterMapSTL.end(); ++it )
441 filters.push_back( it.key() );
443 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
444 fd->setWindowTitle( aTitle );
445 fd->setNameFilters( filters );
446 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
447 if ( !anInitialPath.isEmpty() )
448 fd->setDirectory( anInitialPath );
449 fd->selectFile(aMeshName);
453 aFilename = fd->selectedFile();
454 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
459 else { // Export to MED
461 QString aDefaultFilter;
462 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
463 for ( ; it != aFilterMap.end(); ++it ) {
464 filters.push_back( it.key() );
465 if (it.value() == SMESH::MED_V2_2)
466 aDefaultFilter = it.key();
469 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
470 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
471 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
472 fd->setWindowTitle( aTitle );
473 fd->setNameFilters( filters );
474 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
475 fd->selectNameFilter(aDefaultFilter);
476 fd->SetChecked(toCreateGroups);
477 if ( !anInitialPath.isEmpty() )
478 fd->setDirectory( anInitialPath );
479 fd->selectFile(aMeshName);
481 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
482 fd->setValidator( fv );
487 aFilename = fd->selectedFile();
489 aFilename = QString::null;
492 aFormat = aFilterMap[fd->selectedNameFilter()];
493 toOverwrite = fv->isOverwrite();
495 if ( !aFilename.isEmpty() ) {
496 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
497 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
498 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
499 && aFormat==SMESH::MED_V2_1) {
500 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
501 QObject::tr("SMESH_WRN_WARNING"),
502 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
503 QObject::tr("SMESH_BUT_YES"),
504 QObject::tr("SMESH_BUT_NO"), 0, 1);
512 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
513 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
514 if( !isVersionOk || aVersion != aFormat ) {
515 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
516 QObject::tr("SMESH_WRN_WARNING"),
517 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
518 QObject::tr("SMESH_BUT_YES"),
519 QObject::tr("SMESH_BUT_NO"), 0, 1);
526 QStringList aMeshNamesCollisionList;
527 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
528 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
529 QString anExistingMeshName( aMeshNames[ i ] );
530 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
531 QString anExportMeshName = (*aMeshIter).second;
532 if( anExportMeshName == anExistingMeshName ) {
533 aMeshNamesCollisionList.append( anExportMeshName );
539 if( !aMeshNamesCollisionList.isEmpty() ) {
540 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
541 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
542 QObject::tr("SMESH_WRN_WARNING"),
543 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
544 QObject::tr("SMESH_BUT_YES"),
545 QObject::tr("SMESH_BUT_NO"),
546 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
555 toCreateGroups = fd->IsChecked();
558 if ( !aFilename.isEmpty() ) {
559 // Check whether the file already exists and delete it if yes
560 QFile aFile( aFilename );
561 if ( aFile.exists() && toOverwrite )
563 SUIT_OverrideCursor wc;
566 bool Renumber = false;
567 // PAL 14172 : Check of we have to renumber or not from the preferences before export
569 Renumber= resMgr->booleanValue("SMESH","renumbering");
571 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
572 aMeshEditor->RenumberNodes();
573 aMeshEditor->RenumberElements();
574 if ( SMESHGUI::automaticUpdate() )
577 switch ( theCommandID ) {
581 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
582 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
583 if( !aMeshItem->_is_nil() )
584 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
590 aMesh->ExportDAT( aFilename.toLatin1().data() );
594 aMesh->ExportUNV( aFilename.toLatin1().data() );
598 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
604 catch (const SALOME::SALOME_Exception& S_ex){
606 SUIT_MessageBox::warning(SMESHGUI::desktop(),
607 QObject::tr("SMESH_WRN_WARNING"),
608 QObject::tr("SMESH_EXPORT_FAILED"));
614 inline void InverseEntityMode(unsigned int& theOutputMode,
615 unsigned int theMode)
617 bool anIsNotPresent = ~theOutputMode & theMode;
619 theOutputMode |= theMode;
621 theOutputMode &= ~theMode;
624 void SetDisplayEntity(int theCommandID){
625 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
626 SALOME_ListIO selected;
628 aSel->selectedObjects( selected );
630 if(selected.Extent() >= 1){
631 SALOME_ListIteratorOfListIO It( selected );
632 for( ; It.More(); It.Next()){
633 Handle(SALOME_InteractiveObject) IObject = It.Value();
634 if(IObject->hasEntry()){
635 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
636 unsigned int aMode = anActor->GetEntityMode();
637 switch(theCommandID){
639 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
642 InverseEntityMode(aMode,SMESH_Actor::eEdges);
645 InverseEntityMode(aMode,SMESH_Actor::eFaces);
648 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
651 aMode = SMESH_Actor::eAllEntity;
655 anActor->SetEntityMode(aMode);
663 SALOME_ListIO selected;
664 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
668 LightApp_SelectionMgr* aSel = app->selectionMgr();
669 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
670 if( !aSel || !appStudy )
673 aSel->selectedObjects( selected );
674 if( selected.IsEmpty() )
677 Handle(SALOME_InteractiveObject) anIObject = selected.First();
679 _PTR(Study) aStudy = appStudy->studyDS();
680 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
681 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
682 if( aMainObject->_is_nil() )
685 aMainObject->SetAutoColor( true );
687 QList<SALOMEDS::Color> aReservedColors;
689 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
690 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
692 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
693 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
695 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
696 aGroupObject->SetColor( aColor );
697 aReservedColors.append( aColor );
699 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
701 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
702 if( aGroupObject->GetType() == SMESH::NODE )
703 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
704 else if( aGroupObject->GetType() == SMESH::EDGE )
705 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
706 else if( aGroupObject->GetType() == SMESH::ELEM0D )
707 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
709 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
714 SMESH::RepaintCurrentView();
717 QString functorToString( SMESH::Controls::FunctorPtr f )
719 QString type = QObject::tr( "UNKNOWN_CONTROL" );
720 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
721 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
722 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
723 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
724 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
725 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
726 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
727 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
728 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
729 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
730 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
731 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
732 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
733 type = QObject::tr( "WARP_ELEMENTS" );
734 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
735 type = QObject::tr( "TAPER_ELEMENTS" );
736 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
737 type = QObject::tr( "SKEW_ELEMENTS" );
738 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
739 type = QObject::tr( "AREA_ELEMENTS" );
740 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
741 type = QObject::tr( "LENGTH_EDGES" );
742 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
743 type = QObject::tr( "LENGTH2D_EDGES" );
744 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
745 type = QObject::tr( "MULTI_BORDERS" );
746 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
747 type = QObject::tr( "MULTI2D_BORDERS" );
748 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
749 type = QObject::tr( "FREE_NODES" );
750 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
751 type = QObject::tr( "FREE_EDGES" );
752 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
753 type = QObject::tr( "FREE_BORDERS" );
754 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
755 type = QObject::tr( "FREE_FACES" );
759 void SaveDistribution()
761 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
762 SALOME_ListIO selected;
764 aSel->selectedObjects( selected );
766 if ( selected.Extent() == 1 ) {
767 Handle(SALOME_InteractiveObject) anIO = selected.First();
768 if ( anIO->hasEntry() ) {
769 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
770 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
771 vtkScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
772 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
773 if ( aScalarBarActor && aFunctor ) {
774 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
776 int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
777 std::vector<int> nbEvents;
778 std::vector<double> funValues;
779 aNumFun->GetHistogram( nbRanges, nbEvents, funValues );
780 QString anInitialPath = "";
781 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
782 anInitialPath = QDir::currentPath();
783 QString aMeshName = anIO->getName();
785 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
786 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
787 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
788 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
789 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
792 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
794 if ( !aFilename.isEmpty() ) {
795 QFile f( aFilename );
796 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
797 QTextStream out( &f );
798 out << "# Mesh: " << aMeshName << endl;
799 out << "# Control: " << functorToString( aFunctor ) << endl;
801 out.setFieldWidth( 10 );
802 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
803 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
814 void DisableAutoColor(){
815 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
816 SALOME_ListIO selected;
818 aSel->selectedObjects( selected );
820 if(selected.Extent()){
821 Handle(SALOME_InteractiveObject) anIObject = selected.First();
822 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
823 if ( !aMesh->_is_nil() ) {
824 aMesh->SetAutoColor( false );
829 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
830 SALOME_ListIO selected;
831 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
835 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
836 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
837 if( !aSel || !appStudy )
840 _PTR(Study) aStudy = appStudy->studyDS();
842 aSel->selectedObjects( selected );
844 if(selected.Extent() >= 1){
845 switch(theCommandID){
847 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
848 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
852 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
853 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
857 QColor c, e, b, n, c0D, o;
860 vtkFloatingPointType Shrink = 0.0;
861 vtkFloatingPointType faces_orientation_scale = 0.0;
862 bool faces_orientation_3dvectors = false;
864 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
865 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
866 int aMarkerTextureCurrent = 0;
868 SALOME_ListIteratorOfListIO It( selected );
869 for( ; It.More(); It.Next()){
870 Handle(SALOME_InteractiveObject) IObject = It.Value();
871 if(IObject->hasEntry()){
872 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
873 vtkFloatingPointType color[3];
874 anActor->GetSufaceColor(color[0], color[1], color[2]);
875 int c0 = int (color[0] * 255);
876 int c1 = int (color[1] * 255);
877 int c2 = int (color[2] * 255);
878 c.setRgb(c0, c1, c2);
880 vtkFloatingPointType edgecolor[3];
881 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
882 c0 = int (edgecolor[0] * 255);
883 c1 = int (edgecolor[1] * 255);
884 c2 = int (edgecolor[2] * 255);
885 e.setRgb(c0, c1, c2);
887 vtkFloatingPointType backfacecolor[3];
888 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
889 c0 = int (backfacecolor[0] * 255);
890 c1 = int (backfacecolor[1] * 255);
891 c2 = int (backfacecolor[2] * 255);
892 b.setRgb(c0, c1, c2);
894 vtkFloatingPointType nodecolor[3];
895 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
896 c0 = int (nodecolor[0] * 255);
897 c1 = int (nodecolor[1] * 255);
898 c2 = int (nodecolor[2] * 255);
899 n.setRgb(c0, c1, c2);
901 vtkFloatingPointType color0D[3];
902 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
903 c0 = int (color0D[0] * 255);
904 c1 = int (color0D[1] * 255);
905 c2 = int (color0D[2] * 255);
906 c0D.setRgb(c0, c1, c2);
908 size0D = (int)anActor->Get0DSize();
911 Edgewidth = (int)anActor->GetLineWidth();
914 Shrink = anActor->GetShrinkFactor();
916 vtkFloatingPointType faces_orientation_color[3];
917 anActor->GetFacesOrientationColor(faces_orientation_color);
918 c0 = int (faces_orientation_color[0] * 255);
919 c1 = int (faces_orientation_color[1] * 255);
920 c2 = int (faces_orientation_color[2] * 255);
921 o.setRgb(c0, c1, c2);
923 faces_orientation_scale = anActor->GetFacesOrientationScale();
924 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
926 aMarkerTypeCurrent = anActor->GetMarkerType();
927 aMarkerScaleCurrent = anActor->GetMarkerScale();
928 aMarkerTextureCurrent = anActor->GetMarkerTexture();
930 // even if there are multiple objects in the selection,
931 // we need only the first one to get values for the dialog
937 SMESHGUI_Preferences_ColorDlg *aDlg =
938 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
939 aDlg->SetColor(1, c);
940 aDlg->SetColor(2, e);
941 aDlg->SetColor(3, n);
942 aDlg->SetColor(4, b);
943 aDlg->SetColor(5, c0D);
944 aDlg->SetColor(6, o);
945 aDlg->SetIntValue(1, Edgewidth);
946 aDlg->SetIntValue(2, int(Shrink*100.));
947 aDlg->SetIntValue(3, size0D);
948 aDlg->SetDoubleValue(1, faces_orientation_scale);
949 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
951 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
953 if( aMarkerTypeCurrent != VTK::MT_USER )
954 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
956 aDlg->setCustomMarker( aMarkerTextureCurrent );
959 QColor color = aDlg->GetColor(1);
960 QColor edgecolor = aDlg->GetColor(2);
961 QColor nodecolor = aDlg->GetColor(3);
962 QColor backfacecolor = aDlg->GetColor(4);
963 QColor color0D = aDlg->GetColor(5);
964 QColor faces_orientation_color = aDlg->GetColor(6);
967 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
969 SALOME_ListIteratorOfListIO It( selected );
970 for( ; It.More(); It.Next()){
971 Handle(SALOME_InteractiveObject) IObject = It.Value();
972 if(IObject->hasEntry()){
973 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
974 /* actor color and backface color */
975 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
976 vtkFloatingPointType (color.green()) / 255.,
977 vtkFloatingPointType (color.blue()) / 255.);
978 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
979 vtkFloatingPointType (backfacecolor.green()) / 255.,
980 vtkFloatingPointType (backfacecolor.blue()) / 255.);
983 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
984 vtkFloatingPointType (edgecolor.green()) / 255.,
985 vtkFloatingPointType (edgecolor.blue()) / 255.);
987 /* Shrink factor and size edges */
988 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
989 anActor->SetLineWidth(aDlg->GetIntValue(1));
991 /* Nodes color and size */
992 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
993 vtkFloatingPointType (nodecolor.green()) / 255.,
994 vtkFloatingPointType (nodecolor.blue()) / 255.);
997 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
998 vtkFloatingPointType (color0D.green()) / 255.,
999 vtkFloatingPointType (color0D.blue()) / 255.);
1000 anActor->Set0DSize(aDlg->GetIntValue(3));
1002 /* Faces orientation */
1003 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1004 vtkFloatingPointType(faces_orientation_color.greenF()),
1005 vtkFloatingPointType(faces_orientation_color.blueF())};
1006 anActor->SetFacesOrientationColor(c);
1007 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1008 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1010 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1011 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1012 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1013 if( aMarkerTypeNew != VTK::MT_USER )
1014 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1016 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1017 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1018 if( anIter != aMarkerMap.end() )
1019 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1022 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1023 if( !aGroupObject->_is_nil() )
1025 SMESH::ElementType anElementType = aGroupObject->GetType();
1027 switch( anElementType )
1029 case SMESH::NODE: aColor = nodecolor; break;
1030 case SMESH::EDGE: aColor = edgecolor; break;
1031 default: aColor = color; break;
1034 SALOMEDS::Color aGroupColor;
1035 aGroupColor.R = (float)aColor.red() / 255.0;
1036 aGroupColor.G = (float)aColor.green() / 255.0;
1037 aGroupColor.B = (float)aColor.blue() / 255.0;
1038 aGroupObject->SetColor( aGroupColor );
1043 SMESH::RepaintCurrentView();
1049 SALOME_ListIteratorOfListIO It( selected );
1050 for( ; It.More(); It.Next()){
1051 Handle(SALOME_InteractiveObject) IObject = It.Value();
1052 if(IObject->hasEntry()){
1053 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1054 switch(theCommandID){
1056 anActor->SetRepresentation(SMESH_Actor::eEdge);
1059 anActor->SetRepresentation(SMESH_Actor::eSurface);
1062 if(anActor->IsShrunk())
1063 anActor->UnShrink();
1065 anActor->SetShrink();
1068 anActor->SetRepresentation(SMESH_Actor::ePoint);
1071 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1072 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1075 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1076 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1082 SMESH::RepaintCurrentView();
1086 void Control( int theCommandID )
1088 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1089 SALOME_ListIO selected;
1091 aSel->selectedObjects( selected );
1093 if( !selected.IsEmpty() ){
1094 Handle(SALOME_InteractiveObject) anIO = selected.First();
1096 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1097 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1098 switch ( theCommandID ){
1100 aControl = SMESH_Actor::eLength;
1103 aControl = SMESH_Actor::eLength2D;
1106 aControl = SMESH_Actor::eFreeEdges;
1109 aControl = SMESH_Actor::eFreeBorders;
1112 aControl = SMESH_Actor::eMultiConnection;
1115 aControl = SMESH_Actor::eFreeNodes;
1118 aControl = SMESH_Actor::eMultiConnection2D;
1121 aControl = SMESH_Actor::eArea;
1124 aControl = SMESH_Actor::eTaper;
1127 aControl = SMESH_Actor::eAspectRatio;
1130 aControl = SMESH_Actor::eAspectRatio3D;
1133 aControl = SMESH_Actor::eMinimumAngle;
1136 aControl = SMESH_Actor::eWarping;
1139 aControl = SMESH_Actor::eSkew;
1142 aControl = SMESH_Actor::eVolume3D;
1145 aControl = SMESH_Actor::eFreeFaces;
1148 aControl = SMESH_Actor::eMaxElementLength2D;
1151 aControl = SMESH_Actor::eMaxElementLength3D;
1154 anActor->SetControlMode(aControl);
1155 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1156 SMESH::RepaintCurrentView();
1163 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1164 MeshObjectType theType,
1165 const QString theInTypeName,
1166 QString & theOutTypeName)
1168 SMESH_TypeFilter aTypeFilter( theType );
1170 if( !theIO.IsNull() )
1172 entry = theIO->getEntry();
1173 LightApp_DataOwner owner( entry );
1174 if ( aTypeFilter.isOk( &owner )) {
1175 theOutTypeName = theInTypeName;
1183 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1185 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1186 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1188 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1189 CORBA::String_var anID = aSComp->GetID().c_str();
1190 if (!strcmp(anID.in(),theIO->getEntry()))
1196 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1197 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1198 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1199 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1200 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1208 QString CheckHomogeneousSelection()
1210 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1211 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1212 SALOME_ListIO selected;
1214 aSel->selectedObjects( selected );
1216 QString RefType = CheckTypeObject(selected.First());
1217 SALOME_ListIteratorOfListIO It(selected);
1218 for ( ; It.More(); It.Next())
1220 Handle(SALOME_InteractiveObject) IObject = It.Value();
1221 QString Type = CheckTypeObject(IObject);
1222 if (Type.compare(RefType) != 0)
1223 return "Heterogeneous Selection";
1230 void SMESHGUI::OnEditDelete()
1232 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1233 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1234 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1236 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1237 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1238 _PTR(GenericAttribute) anAttr;
1239 _PTR(AttributeIOR) anIOR;
1241 int objectCount = 0;
1243 QString aParentComponent = QString::null;
1244 Handle(SALOME_InteractiveObject) anIO;
1245 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1247 anIO = anIt.Value();
1248 QString cur = anIO->getComponentDataType();
1249 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1251 // check if object is reference
1252 _PTR(SObject) aRefSObj;
1253 aNameList.append("\n - ");
1254 if ( aSO->ReferencedObject( aRefSObj ) ) {
1255 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1256 aNameList.append( aRefName );
1257 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1260 aNameList.append(anIO->getName());
1264 if( aParentComponent.isNull() )
1265 aParentComponent = cur;
1266 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1267 aParentComponent = "";
1270 if ( objectCount == 0 )
1271 return; // No Valid Objects Selected
1273 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1274 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1275 QObject::tr("ERR_ERROR"),
1276 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1279 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1280 if (SUIT_MessageBox::warning
1281 (SMESHGUI::desktop(),
1282 QObject::tr("SMESH_WRN_WARNING"),
1283 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1284 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1285 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1288 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1289 SUIT_ViewManager* vm = anApp->activeViewManager();
1290 int nbSf = vm->getViewsCount();
1292 SALOME_ListIteratorOfListIO It(selected);
1294 aStudyBuilder->NewCommand(); // There is a transaction
1295 for( ; It.More(); It.Next()){ // loop on selected IO's
1296 Handle(SALOME_InteractiveObject) IObject = It.Value();
1297 if(IObject->hasEntry()) {
1298 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1300 // disable removal of "SMESH" component object
1301 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1303 if ( engineIOR() == anIOR->Value().c_str() )
1306 //Check the referenced object
1307 _PTR(SObject) aRefSObject;
1308 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1309 aSO = aRefSObject; // Delete main Object instead of reference
1311 // put the whole hierarchy of sub-objects of the selected SO into a list and
1312 // then treat them all starting from the deepest objects (at list back)
1314 std::list< _PTR(SObject) > listSO;
1315 listSO.push_back( aSO );
1316 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1317 for ( ; itSO != listSO.end(); ++itSO ) {
1318 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1319 for (it->InitEx(false); it->More(); it->Next())
1320 listSO.push_back( it->Value() );
1323 // treat SO's in the list starting from the back
1325 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1326 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1327 _PTR(SObject) SO = *ritSO;
1328 if ( !SO ) continue;
1329 std::string anEntry = SO->GetID();
1331 /** Erase graphical object **/
1332 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1333 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1334 for(int i = 0; i < nbSf; i++){
1335 SUIT_ViewWindow *sf = aViews[i];
1336 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1337 SMESH::RemoveActor(sf,anActor);
1342 /** Remove an object from data structures **/
1343 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1344 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1345 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1346 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1347 aMesh->RemoveGroup( aGroup );
1349 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1350 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1351 aMesh->RemoveSubMesh( aSubMesh );
1353 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1355 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1358 IObject = new SALOME_InteractiveObject
1359 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1360 QString objType = CheckTypeObject(IObject);
1361 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1362 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1363 aStudyBuilder->RemoveObjectWithChildren( SO );
1365 else {// default action: remove SObject from the study
1366 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1367 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1369 aStudyBuilder->RemoveObjectWithChildren( SO );
1373 } /* listSO back loop */
1374 } /* IObject->hasEntry() */
1376 aStudyBuilder->CommitCommand();
1378 /* Clear any previous selection */
1380 aSel->setSelectedObjects( l1 );
1382 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1387 SMESHGUI_EXPORT CAM_Module* createModule()
1389 return new SMESHGUI();
1393 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1395 //=============================================================================
1399 //=============================================================================
1400 SMESHGUI::SMESHGUI() :
1401 SalomeApp_Module( "SMESH" ),
1402 LightApp_Module( "SMESH" )
1404 if ( CORBA::is_nil( myComponentSMESH ) )
1406 CORBA::Boolean anIsEmbeddedMode;
1407 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1409 // 0019923: EDF 765 SMESH : default values of hypothesis
1410 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1411 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1412 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1413 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1414 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1417 myActiveDialogBox = 0;
1418 myFilterLibraryDlg = 0;
1422 SMESH::GetFilterManager();
1423 SMESH::GetPattern();
1425 /* load resources for all available meshers */
1426 SMESH::InitAvailableHypotheses();
1429 //=============================================================================
1433 //=============================================================================
1434 SMESHGUI::~SMESHGUI()
1436 #ifdef WITHGENERICOBJ
1437 SMESH::GetFilterManager()->Destroy();
1439 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1442 //=============================================================================
1446 //=============================================================================
1447 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1449 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1451 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1456 bool SMESHGUI::automaticUpdate()
1458 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1462 return resMgr->booleanValue( "SMESH", "auto_update", false );
1465 //=============================================================================
1469 //=============================================================================
1470 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1472 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1475 //=============================================================================
1479 //=============================================================================
1480 SMESHGUI* SMESHGUI::GetSMESHGUI()
1482 SMESHGUI* smeshMod = 0;
1483 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1486 CAM_Module* module = app->module( "Mesh" );
1487 smeshMod = dynamic_cast<SMESHGUI*>( module );
1490 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1492 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1495 _PTR(Study) aStudy = study->studyDS();
1497 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1506 Standard_EXPORT SMESHGUI* GetComponentGUI()
1508 return SMESHGUI::GetSMESHGUI();
1512 //=============================================================================
1516 //=============================================================================
1517 void SMESHGUI::SetState(int aState)
1522 //=============================================================================
1526 //=============================================================================
1527 void SMESHGUI::ResetState()
1532 //=============================================================================
1536 //=============================================================================
1537 void SMESHGUI::EmitSignalDeactivateDialog()
1539 emit SignalDeactivateActiveDialog();
1542 //=============================================================================
1546 //=============================================================================
1547 void SMESHGUI::EmitSignalStudyFrameChanged()
1549 emit SignalStudyFrameChanged();
1552 //=============================================================================
1556 //=============================================================================
1557 void SMESHGUI::EmitSignalCloseAllDialogs()
1559 emit SignalCloseAllDialogs();
1562 //=============================================================================
1566 //=============================================================================
1567 void SMESHGUI::EmitSignalVisibilityChanged()
1569 emit SignalVisibilityChanged();
1572 //=============================================================================
1576 //=============================================================================
1577 QDialog *SMESHGUI::GetActiveDialogBox()
1579 return myActiveDialogBox;
1582 //=============================================================================
1586 //=============================================================================
1587 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1589 myActiveDialogBox = (QDialog *) aDlg;
1593 //=============================================================================
1597 //=============================================================================
1598 SUIT_Desktop* SMESHGUI::desktop()
1600 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1602 return app->desktop();
1607 //=============================================================================
1611 //=============================================================================
1612 SalomeApp_Study* SMESHGUI::activeStudy()
1614 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1616 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1621 //=============================================================================
1625 //=============================================================================
1626 void SMESHGUI::Modified( bool theIsUpdateActions )
1628 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1629 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1630 appStudy->Modified();
1631 if( theIsUpdateActions )
1632 app->updateActions();
1637 //=============================================================================
1641 //=============================================================================
1642 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1644 /* Here the position is on the bottom right corner - 10 */
1645 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1647 SUIT_Desktop *PP = desktop();
1648 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1649 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1653 //=============================================================================
1657 //=============================================================================
1658 static int isStudyLocked(_PTR(Study) theStudy){
1659 return theStudy->GetProperties()->IsLocked();
1662 static bool checkLock(_PTR(Study) theStudy) {
1663 if (isStudyLocked(theStudy)) {
1664 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1665 QObject::tr("WRN_WARNING"),
1666 QObject::tr("WRN_STUDY_LOCKED") );
1672 //=======================================================================
1673 //function : CheckActiveStudyLocked
1675 //=======================================================================
1677 bool SMESHGUI::isActiveStudyLocked()
1679 _PTR(Study) aStudy = activeStudy()->studyDS();
1680 return checkLock( aStudy );
1683 //=============================================================================
1687 //=============================================================================
1688 bool SMESHGUI::OnGUIEvent( int theCommandID )
1690 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1694 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1695 SUIT_ResourceMgr* mgr = resourceMgr();
1699 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1700 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1703 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1704 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1706 //QAction* act = action( theCommandID );
1708 switch (theCommandID) {
1710 if(checkLock(aStudy)) break;
1718 if(checkLock(aStudy)) break;
1719 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1723 case 150: //MED FILE INFORMATION
1725 SALOME_ListIO selected;
1726 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1728 aSel->selectedObjects( selected );
1729 if( selected.Extent() )
1731 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1732 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1733 if ( !aMesh->_is_nil() )
1735 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1742 case 122: // EXPORT MED
1751 ::ExportMeshToFile(theCommandID);
1755 case 200: // SCALAR BAR
1757 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1758 SALOME_ListIO selected;
1760 aSel->selectedObjects( selected );
1762 if( selected.Extent() ) {
1763 Handle(SALOME_InteractiveObject) anIO = selected.First();
1764 if( anIO->hasEntry() ) {
1765 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1766 anActor->SetControlMode( SMESH_Actor::eNone );
1774 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1779 // dump control distribution data to the text file
1780 ::SaveDistribution();
1790 ::DisableAutoColor();
1793 case 1134: // Clipping
1794 case 1133: // Tranparency
1795 case 1132: // Colors / Size
1802 ::SetDisplayMode(theCommandID, myMarkerMap);
1805 //2D quadratic representation
1808 ::SetDisplayMode(theCommandID, myMarkerMap);
1812 case 216: // 0D elements
1815 case 219: // Volumes
1816 case 220: // All Entity
1817 ::SetDisplayEntity(theCommandID);
1820 case 221: // Orientation of faces
1822 LightApp_SelectionMgr* mgr = selectionMgr();
1823 SALOME_ListIO selected; mgr->selectedObjects( selected );
1825 SALOME_ListIteratorOfListIO it(selected);
1826 for( ; it.More(); it.Next()) {
1827 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1828 if(anIObject->hasEntry()) {
1829 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1830 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1839 if(checkLock(aStudy)) break;
1841 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1844 SMESH::UpdateView();
1846 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1847 SMESH::OnVisuException();
1849 catch (...) { // PAL16774 (Crash after display of many groups)
1850 SMESH::OnVisuException();
1854 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1855 aSel->selectedObjects( l );
1856 aSel->setSelectedObjects( l );
1861 case 301: // DISPLAY
1862 case 302: // DISPLAY ONLY
1864 SMESH::EDisplaing anAction;
1865 switch (theCommandID) {
1866 case 300: anAction = SMESH::eErase; break;
1867 case 301: anAction = SMESH::eDisplay; break;
1868 case 302: anAction = SMESH::eDisplayOnly; break;
1871 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1872 SALOME_ListIO sel_objects, to_process;
1874 aSel->selectedObjects( sel_objects );
1876 if( theCommandID==302 )
1877 startOperation( myEraseAll );
1879 extractContainers( sel_objects, to_process );
1882 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1886 SALOME_ListIteratorOfListIO It( to_process );
1887 for ( ; It.More(); It.Next()) {
1888 Handle(SALOME_InteractiveObject) IOS = It.Value();
1889 if (IOS->hasEntry()) {
1890 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1891 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1892 break; // PAL16774 (Crash after display of many groups)
1894 if (anAction == SMESH::eDisplayOnly)
1895 anAction = SMESH::eDisplay;
1900 // PAL13338 + PAL15161 -->
1901 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1902 SMESH::UpdateView();
1903 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1905 // PAL13338 + PAL15161 <--
1907 catch (...) { // PAL16774 (Crash after display of many groups)
1908 SMESH::OnVisuException();
1911 if (anAction == SMESH::eErase) {
1913 aSel->setSelectedObjects( l1 );
1916 aSel->setSelectedObjects( to_process );
1923 if(checkLock(aStudy)) break;
1926 EmitSignalDeactivateDialog();
1928 ( new SMESHGUI_NodesDlg( this ) )->show();
1931 SUIT_MessageBox::warning(desktop(),
1932 tr("SMESH_WRN_WARNING"),
1933 tr("SMESH_WRN_VIEWER_VTK"));
1938 case 2151: // FILTER
1942 EmitSignalDeactivateDialog();
1943 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1948 case 701: // COMPUTE MESH
1949 case 711: // PRECOMPUTE MESH
1950 case 712: // EVALUATE MESH
1951 case 713: // MESH ORDER
1953 if (checkLock(aStudy)) break;
1954 startOperation( theCommandID );
1958 case 702: // Create mesh
1959 case 703: // Create sub-mesh
1960 case 704: // Edit mesh/sub-mesh
1961 startOperation( theCommandID );
1963 case 710: // Build compound mesh
1965 if (checkLock(aStudy)) break;
1966 EmitSignalDeactivateDialog();
1967 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1971 case 407: // DIAGONAL INVERSION
1972 case 408: // Delete diagonal
1976 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1977 tr( "NOT_A_VTK_VIEWER" ) );
1981 if ( checkLock( aStudy ) )
1984 /*Standard_Boolean aRes;
1985 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1986 if ( aMesh->_is_nil() )
1988 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1989 tr( "SMESH_BAD_SELECTION" ) );
1993 EmitSignalDeactivateDialog();
1994 if ( theCommandID == 407 )
1995 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1997 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2000 case 409: // Change orientation
2001 case 410: // Union of triangles
2002 case 411: // Cutting of quadrangles
2003 case 419: // Splitting volumes into tetrahedra
2007 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2008 tr( "NOT_A_VTK_VIEWER" ) );
2012 if ( checkLock( aStudy ) )
2015 EmitSignalDeactivateDialog();
2016 SMESHGUI_MultiEditDlg* aDlg = NULL;
2017 if ( theCommandID == 409 )
2018 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2019 else if ( theCommandID == 410 )
2020 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2021 else if ( theCommandID == 419 )
2022 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2024 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2029 case 412: // Smoothing
2031 if(checkLock(aStudy)) break;
2033 EmitSignalDeactivateDialog();
2034 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2037 SUIT_MessageBox::warning(desktop(),
2038 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2042 case 413: // Extrusion
2044 if (checkLock(aStudy)) break;
2046 EmitSignalDeactivateDialog();
2047 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2049 SUIT_MessageBox::warning(desktop(),
2050 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2054 case 414: // Revolution
2056 if(checkLock(aStudy)) break;
2058 EmitSignalDeactivateDialog();
2059 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2062 SUIT_MessageBox::warning(desktop(),
2063 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2067 case 415: // Pattern mapping
2069 if ( checkLock( aStudy ) )
2073 EmitSignalDeactivateDialog();
2074 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2077 SUIT_MessageBox::warning(desktop(),
2078 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2082 case 416: // Extrusion along a path
2084 if (checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2089 SUIT_MessageBox::warning(desktop(),
2090 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2094 case 417: // Convert mesh to quadratic
2096 startOperation( 417 );
2097 /* if (checkLock(aStudy)) break;
2099 EmitSignalDeactivateDialog();
2100 new SMESHGUI_ConvToQuadDlg();
2102 SUIT_MessageBox::warning(desktop(),
2103 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2107 case 418: // create 2D mesh from 3D
2109 startOperation( 418 );
2112 case 806: // CREATE GEO GROUP
2114 startOperation( 806 );
2117 case 801: // CREATE GROUP
2121 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2122 tr( "NOT_A_VTK_VIEWER" ) );
2126 if(checkLock(aStudy)) break;
2127 EmitSignalDeactivateDialog();
2128 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2130 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2131 SALOME_ListIO selected;
2133 aSel->selectedObjects( selected );
2135 int nbSel = selected.Extent();
2137 // check if mesh is selected
2138 aMesh = SMESH::GetMeshByIO( selected.First() );
2140 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2145 case 802: // CONSTRUCT GROUP
2149 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2150 tr( "NOT_A_VTK_VIEWER" ) );
2154 if(checkLock(aStudy)) break;
2155 EmitSignalDeactivateDialog();
2157 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2158 SALOME_ListIO selected;
2160 aSel->selectedObjects( selected );
2162 int nbSel = selected.Extent();
2164 // check if submesh is selected
2165 Handle(SALOME_InteractiveObject) IObject = selected.First();
2166 if (IObject->hasEntry()) {
2167 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2169 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2170 if (!aSubMesh->_is_nil()) {
2172 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2173 // get submesh elements list by types
2174 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2175 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2176 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2177 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2178 // create group for each type o elements
2179 QString aName = IObject->getName();
2180 if (aNodes->length() > 0) {
2181 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2182 aGroup->Add(aNodes.inout());
2184 if (aEdges->length() > 0) {
2185 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2186 aGroup->Add(aEdges.inout());
2188 if (aFaces->length() > 0) {
2189 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2190 aGroup->Add(aFaces.inout());
2192 if (aVolumes->length() > 0) {
2193 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2194 aGroup->Add(aVolumes.inout());
2199 catch(const SALOME::SALOME_Exception & S_ex){
2200 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2207 SUIT_MessageBox::warning(desktop(),
2208 tr("SMESH_WRN_WARNING"),
2209 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2214 case 803: // EDIT GROUP
2218 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2219 tr( "NOT_A_VTK_VIEWER" ) );
2223 if(checkLock(aStudy)) break;
2224 EmitSignalDeactivateDialog();
2226 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2227 SALOME_ListIO selected;
2229 aSel->selectedObjects( selected );
2231 SALOME_ListIteratorOfListIO It (selected);
2232 int nbSelectedGroups = 0;
2233 for ( ; It.More(); It.Next() )
2235 SMESH::SMESH_GroupBase_var aGroup =
2236 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2237 if (!aGroup->_is_nil()) {
2239 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2243 if (nbSelectedGroups == 0)
2245 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2251 case 804: // Add elements to group
2253 if(checkLock(aStudy)) break;
2254 if (myState == 800) {
2255 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2256 if (aDlg) aDlg->onAdd();
2261 case 805: // Remove elements from group
2263 if(checkLock(aStudy)) break;
2264 if (myState == 800) {
2265 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2266 if (aDlg) aDlg->onRemove();
2271 case 815: // Edit GEOM GROUP as standalone
2275 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2276 tr( "NOT_A_VTK_VIEWER" ) );
2280 if(checkLock(aStudy)) break;
2281 EmitSignalDeactivateDialog();
2283 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2284 SALOME_ListIO selected;
2286 aSel->selectedObjects( selected );
2288 SALOME_ListIteratorOfListIO It (selected);
2289 for ( ; It.More(); It.Next() )
2291 SMESH::SMESH_GroupOnGeom_var aGroup =
2292 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2293 if (!aGroup->_is_nil()) {
2294 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2301 case 810: // Union Groups
2302 case 811: // Intersect groups
2303 case 812: // Cut groups
2307 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2308 tr( "NOT_A_VTK_VIEWER" ) );
2312 if ( checkLock( aStudy ) )
2315 EmitSignalDeactivateDialog();
2317 SMESHGUI_GroupOpDlg* aDlg = 0;
2318 if ( theCommandID == 810 )
2319 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2320 else if ( theCommandID == 811 )
2321 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2323 aDlg = new SMESHGUI_CutGroupsDlg( this );
2330 case 814: // Create groups of entities from existing groups of superior dimensions
2332 if ( checkLock( aStudy ) )
2335 EmitSignalDeactivateDialog();
2336 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2342 case 813: // Delete groups with their contents
2346 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2347 tr( "NOT_A_VTK_VIEWER" ) );
2351 if ( checkLock( aStudy ) )
2354 EmitSignalDeactivateDialog();
2356 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2360 case 900: // MESH INFOS
2362 EmitSignalDeactivateDialog();
2363 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2364 SALOME_ListIO selected;
2366 aSel->selectedObjects( selected );
2368 if ( selected.Extent() > 1 ) { // a dlg for each IO
2370 SALOME_ListIteratorOfListIO It (selected);
2371 for ( ; It.More(); It.Next() ) {
2372 IOs.Clear(); IOs.Append( It.Value() );
2373 aSel->setSelectedObjects( IOs );
2374 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2376 // restore selection
2377 aSel->setSelectedObjects( selected );
2380 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
2384 case 902: // STANDARD MESH INFOS
2386 EmitSignalDeactivateDialog();
2387 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2388 SALOME_ListIO selected;
2390 aSel->selectedObjects( selected );
2392 if ( selected.Extent() > 1 ) { // a dlg for each IO
2394 SALOME_ListIteratorOfListIO It (selected);
2395 for ( ; It.More(); It.Next() ) {
2397 IOs.Append( It.Value() );
2398 aSel->setSelectedObjects( IOs );
2399 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2401 // restore selection
2402 aSel->setSelectedObjects( selected );
2405 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2409 case 903: // WHAT IS
2411 EmitSignalDeactivateDialog();
2412 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2416 case 904: // FIND ELEM
2418 startOperation( theCommandID );
2422 case 1100: // EDIT HYPOTHESIS
2424 if(checkLock(aStudy)) break;
2426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2427 SALOME_ListIO selected;
2429 aSel->selectedObjects( selected );
2431 int nbSel = selected.Extent();
2434 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2435 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2437 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2438 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2439 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2440 if ( !aHypothesis->_is_nil() )
2443 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2444 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2446 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2457 case 1101: // RENAME
2459 if ( checkLock( aStudy ) )
2462 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2463 SALOME_ListIO selected;
2465 aSel->selectedObjects( selected );
2467 bool isAny = false; // is there any appropriate object selected
2469 SALOME_ListIteratorOfListIO It( selected );
2470 for ( ; It.More(); It.Next() )
2472 Handle(SALOME_InteractiveObject) IObject = It.Value();
2473 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2474 _PTR(GenericAttribute) anAttr;
2475 _PTR(AttributeName) aName;
2478 if ( obj->FindAttribute(anAttr, "AttributeName") )
2481 QString newName = QString(aName->Value().c_str());
2483 // check type to prevent renaming of inappropriate objects
2484 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2485 if (aType == MESH || aType == GROUP ||
2486 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2487 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2488 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2489 aType == HYPOTHESIS || aType == ALGORITHM)
2492 newName = LightApp_NameDlg::getName(desktop(), newName);
2493 if ( !newName.isEmpty() )
2495 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2497 // update name of group object and its actor
2498 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2499 if( !aGroupObject->_is_nil() )
2501 aGroupObject->SetName( newName.toLatin1().data() );
2502 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2503 anActor->setName( newName.toLatin1().data() );
2514 SUIT_MessageBox::warning(desktop(),
2515 QObject::tr("SMESH_WRN_WARNING"),
2516 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2521 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2523 if(checkLock(aStudy)) break;
2524 SUIT_OverrideCursor wc;
2526 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2527 SALOME_ListIO selected;
2529 aSel->selectedObjects( selected, QString::null, false );
2531 SALOME_ListIteratorOfListIO It(selected);
2532 for (int i = 0; It.More(); It.Next(), i++) {
2533 Handle(SALOME_InteractiveObject) IObject = It.Value();
2534 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2537 aSel->setSelectedObjects( l1 );
2542 case 4009: // ELEM0D
2543 case 4010: // GEOM::EDGE
2544 case 4021: // TRIANGLE
2546 case 4023: // POLYGON
2550 if(checkLock(aStudy)) break;
2552 EmitSignalDeactivateDialog();
2553 SMDSAbs_ElementType type = SMDSAbs_Edge;
2555 switch (theCommandID) {
2556 case 4009: // ELEM0D
2557 type = SMDSAbs_0DElement; nbNodes = 1; break;
2558 case 4021: // TRIANGLE
2559 type = SMDSAbs_Face; nbNodes = 3; break;
2561 type = SMDSAbs_Face; nbNodes = 4; break;
2563 type = SMDSAbs_Volume; nbNodes = 4; break;
2564 case 4023: // POLYGON
2565 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2567 type = SMDSAbs_Volume; nbNodes = 8; break;
2568 case 4033: // POLYHEDRE
2569 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2572 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2575 SUIT_MessageBox::warning(desktop(),
2576 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2580 case 4033: // POLYHEDRON
2582 if(checkLock(aStudy)) break;
2584 EmitSignalDeactivateDialog();
2585 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2588 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2589 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2593 case 4034: // QUADRATIC EDGE
2594 case 4035: // QUADRATIC TRIANGLE
2595 case 4036: // QUADRATIC QUADRANGLE
2596 case 4037: // QUADRATIC TETRAHEDRON
2597 case 4038: // QUADRATIC PYRAMID
2598 case 4039: // QUADRATIC PENTAHEDRON
2599 case 4040: // QUADRATIC HEXAHEDRON
2601 if(checkLock(aStudy)) break;
2603 EmitSignalDeactivateDialog();
2606 switch (theCommandID) {
2608 type = QUAD_EDGE; break;
2610 type = QUAD_TRIANGLE; break;
2612 type = QUAD_QUADRANGLE; break;
2614 type = QUAD_TETRAHEDRON; break;
2616 type = QUAD_PYRAMID; break;
2618 type = QUAD_PENTAHEDRON; break;
2620 type = QUAD_HEXAHEDRON;
2624 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2627 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2628 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2632 case 4041: // REMOVES NODES
2634 if(checkLock(aStudy)) break;
2636 EmitSignalDeactivateDialog();
2637 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2640 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2641 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2645 case 4042: // REMOVES ELEMENTS
2647 if(checkLock(aStudy)) break;
2649 EmitSignalDeactivateDialog();
2650 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2654 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2655 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2659 case 4043: { // CLEAR_MESH
2661 if(checkLock(aStudy)) break;
2663 SALOME_ListIO selected;
2664 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2665 aSel->selectedObjects( selected );
2667 SUIT_OverrideCursor wc;
2668 SALOME_ListIteratorOfListIO It (selected);
2669 for ( ; It.More(); It.Next() )
2671 Handle(SALOME_InteractiveObject) IOS = It.Value();
2672 SMESH::SMESH_Mesh_var aMesh =
2673 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2674 if ( aMesh->_is_nil()) continue;
2676 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2678 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2679 SMESH::ModifiedMesh( aMeshSObj, false, true);
2680 // hide groups and submeshes
2681 _PTR(ChildIterator) anIter =
2682 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2683 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2685 _PTR(SObject) so = anIter->Value();
2686 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2689 catch (const SALOME::SALOME_Exception& S_ex){
2691 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2695 SMESH::UpdateView();
2699 case 4044: // REMOVE ORPHAN NODES
2701 if(checkLock(aStudy)) break;
2702 SALOME_ListIO selected;
2703 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2704 aSel->selectedObjects( selected );
2705 if ( selected.Extent() == 1 ) {
2706 Handle(SALOME_InteractiveObject) anIO = selected.First();
2707 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2708 if ( !aMesh->_is_nil() ) {
2709 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2710 tr( "SMESH_WARNING" ),
2711 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2712 SUIT_MessageBox::Yes |
2713 SUIT_MessageBox::No,
2714 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2717 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2718 int removed = aMeshEditor->RemoveOrphanNodes();
2719 SUIT_MessageBox::information(SMESHGUI::desktop(),
2720 tr("SMESH_INFORMATION"),
2721 tr("NB_NODES_REMOVED").arg(removed));
2722 if ( removed > 0 ) {
2723 SMESH::UpdateView();
2724 SMESHGUI::Modified();
2727 catch (const SALOME::SALOME_Exception& S_ex) {
2728 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2737 case 4051: // RENUMBERING NODES
2739 if(checkLock(aStudy)) break;
2741 EmitSignalDeactivateDialog();
2742 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2746 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2747 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2751 case 4052: // RENUMBERING ELEMENTS
2753 if(checkLock(aStudy)) break;
2755 EmitSignalDeactivateDialog();
2756 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2760 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2761 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2765 case 4061: // TRANSLATION
2767 if(checkLock(aStudy)) break;
2769 EmitSignalDeactivateDialog();
2770 ( new SMESHGUI_TranslationDlg( this ) )->show();
2773 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2774 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2778 case 4062: // ROTATION
2780 if(checkLock(aStudy)) break;
2782 EmitSignalDeactivateDialog();
2783 ( new SMESHGUI_RotationDlg( this ) )->show();
2786 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2787 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2791 case 4063: // SYMMETRY
2793 if(checkLock(aStudy)) break;
2795 EmitSignalDeactivateDialog();
2796 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2799 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2800 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2804 case 4064: // SEWING
2806 if(checkLock(aStudy)) break;
2808 EmitSignalDeactivateDialog();
2809 ( new SMESHGUI_SewingDlg( this ) )->show();
2812 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2813 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2817 case 4065: // MERGE NODES
2819 if(checkLock(aStudy)) break;
2821 EmitSignalDeactivateDialog();
2822 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2825 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2826 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2830 case 4066: // MERGE EQUAL ELEMENTS
2832 if (checkLock(aStudy)) break;
2834 EmitSignalDeactivateDialog();
2835 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2837 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2838 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2843 case 4067: // MAKE MESH PASS THROUGH POINT
2844 startOperation( 4067 );
2849 if(checkLock(aStudy)) break;
2851 EmitSignalDeactivateDialog();
2852 ( new SMESHGUI_ScaleDlg( this ) )->show();
2855 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2856 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2861 case 4069: // DUPLICATE NODES
2863 if(checkLock(aStudy)) break;
2865 EmitSignalDeactivateDialog();
2866 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2869 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2870 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2875 case 5105: // Library of selection filters
2877 static QList<int> aTypes;
2878 if ( aTypes.isEmpty() )
2880 aTypes.append( SMESH::NODE );
2881 aTypes.append( SMESH::EDGE );
2882 aTypes.append( SMESH::FACE );
2883 aTypes.append( SMESH::VOLUME );
2885 if (!myFilterLibraryDlg)
2886 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2887 else if (myFilterLibraryDlg->isHidden())
2888 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2889 myFilterLibraryDlg->raise();
2893 case 6017: // CONTROLS
2913 LightApp_SelectionMgr* mgr = selectionMgr();
2914 SALOME_ListIO selected; mgr->selectedObjects( selected );
2916 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2917 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2919 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2920 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2921 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2922 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2923 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2924 ::Control( theCommandID );
2929 SUIT_MessageBox::warning(desktop(),
2930 tr( "SMESH_WRN_WARNING" ),
2931 tr( "SMESH_BAD_SELECTION" ) );
2935 SUIT_MessageBox::warning(desktop(),
2936 tr( "SMESH_WRN_WARNING" ),
2937 tr( "NOT_A_VTK_VIEWER" ) );
2942 LightApp_SelectionMgr* mgr = selectionMgr();
2943 SALOME_ListIO selected; mgr->selectedObjects( selected );
2945 SALOME_ListIteratorOfListIO it(selected);
2946 for( ; it.More(); it.Next()) {
2947 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2948 if(anIObject->hasEntry()) {
2949 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2950 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2958 LightApp_SelectionMgr* mgr = selectionMgr();
2959 SALOME_ListIO selected; mgr->selectedObjects( selected );
2961 SALOME_ListIteratorOfListIO it(selected);
2962 for( ; it.More(); it.Next()) {
2963 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2964 if(anIObject->hasEntry())
2965 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2966 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2973 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2974 //updateObjBrowser();
2978 //=============================================================================
2982 //=============================================================================
2983 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2988 //=============================================================================
2992 //=============================================================================
2993 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2998 //=============================================================================
3002 //=============================================================================
3003 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3008 //=============================================================================
3009 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3010 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3012 //=============================================================================
3013 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3014 SUIT_ViewWindow* wnd )
3016 if(theIO->hasEntry()){
3017 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3018 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3022 //=======================================================================
3023 // function : createSMESHAction
3025 //=======================================================================
3026 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3027 const int key, const bool toggle, const QString& shortcutAction )
3030 QWidget* parent = application()->desktop();
3031 SUIT_ResourceMgr* resMgr = resourceMgr();
3033 if ( !icon_id.isEmpty() )
3034 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3036 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3037 if ( !pix.isNull() )
3038 icon = QIcon( pix );
3040 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3041 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3042 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3044 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3045 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3048 //=======================================================================
3049 // function : createPopupItem
3051 //=======================================================================
3052 void SMESHGUI::createPopupItem( const int id,
3053 const QString& clients,
3054 const QString& types,
3055 const QString& theRule,
3060 parentId = popupMgr()->actionId( action( pId ) );
3062 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3063 popupMgr()->insert( action( id ), parentId, 0 );
3065 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3066 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3067 QString rule = "(%1) and (%2) and (%3)";
3068 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3069 if( clients.isEmpty() )
3070 rule = rule.arg( QString( "true" ) );
3072 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3073 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3076 bool cont = myRules.contains( id );
3078 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3080 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3081 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3084 //=======================================================================
3085 // function : initialize
3087 //=======================================================================
3088 void SMESHGUI::initialize( CAM_Application* app )
3090 SalomeApp_Module::initialize( app );
3092 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3094 /* Automatic Update flag */
3095 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3097 // ----- create actions --------------
3099 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3100 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3101 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3102 createSMESHAction( 114, "NUM" );
3103 createSMESHAction( 121, "DAT" );
3104 createSMESHAction( 122, "MED" );
3105 createSMESHAction( 123, "UNV" );
3106 createSMESHAction( 140, "STL" );
3107 createSMESHAction( 124, "EXPORT_DAT" );
3108 createSMESHAction( 125, "EXPORT_MED" );
3109 createSMESHAction( 126, "EXPORT_UNV" );
3110 createSMESHAction( 141, "EXPORT_STL" );
3111 createSMESHAction( 150, "FILE_INFO" );
3112 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3113 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3114 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3115 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3116 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3117 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3118 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3119 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3120 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3121 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3122 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3123 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3124 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3125 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3126 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3127 createSMESHAction( 804, "ADD" );
3128 createSMESHAction( 805, "REMOVE" );
3129 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3130 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3131 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3132 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3133 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3134 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3135 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3136 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3137 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3138 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3139 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3140 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3141 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3142 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3143 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3144 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3145 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3146 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3147 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3148 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3149 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3150 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3151 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3152 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3153 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3154 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3155 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3156 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3157 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3158 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3159 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3160 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3161 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3162 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3163 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3164 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3165 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3166 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3167 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3168 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3169 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3170 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3171 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3172 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3173 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3174 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3175 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3176 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3177 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3178 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3179 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3180 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3181 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3182 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3183 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3184 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3185 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3186 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3187 createSMESHAction( 415, "MAP", "ICON_MAP" );
3188 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3189 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3190 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3191 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3192 createSMESHAction( 200, "RESET" );
3193 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3194 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3195 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3196 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3197 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3198 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3199 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3200 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3201 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3202 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3203 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3204 createSMESHAction( 220, "ALL" );
3205 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3207 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3208 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3210 createSMESHAction( 1100, "EDIT_HYPO" );
3211 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3212 createSMESHAction( 1102, "UNASSIGN" );
3213 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3214 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3215 createSMESHAction( 1131, "DISPMODE" );
3216 createSMESHAction( 1132, "COLORS" );
3217 createSMESHAction( 1133, "TRANSP" );
3218 createSMESHAction( 1134, "CLIP" );
3219 createSMESHAction( 1135, "DISP_ENT" );
3220 createSMESHAction( 1136, "AUTO_COLOR" );
3221 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3222 createSMESHAction( 2000, "CTRL" );
3224 createSMESHAction( 300, "ERASE" );
3225 createSMESHAction( 301, "DISPLAY" );
3226 createSMESHAction( 302, "DISPLAY_ONLY" );
3227 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3228 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3229 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3230 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3231 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3232 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3233 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3234 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3236 // ----- create menu --------------
3237 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3238 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3239 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3240 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3241 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3242 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3243 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3245 createMenu( separator(), fileId );
3247 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3248 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3249 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3250 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3251 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3252 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3253 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3254 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3255 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3256 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3258 createMenu( 111, importId, -1 );
3259 createMenu( 112, importId, -1 );
3260 createMenu( 113, importId, -1 );
3262 createMenu( 121, exportId, -1 );
3263 createMenu( 122, exportId, -1 );
3264 createMenu( 123, exportId, -1 );
3265 createMenu( 140, exportId, -1 ); // export to stl STL
3267 createMenu( separator(), fileId, 10 );
3269 createMenu( 33, editId, -1 );
3271 createMenu( 5105, toolsId, -1 );
3273 createMenu( 702, meshId, -1 ); // "Mesh" menu
3274 createMenu( 703, meshId, -1 );
3275 createMenu( 704, meshId, -1 );
3276 createMenu( 710, meshId, -1 );
3277 createMenu( separator(), meshId, -1 );
3278 createMenu( 701, meshId, -1 );
3279 createMenu( 711, meshId, -1 );
3280 createMenu( 712, meshId, -1 );
3281 createMenu( 713, meshId, -1 );
3282 createMenu( separator(), meshId, -1 );
3283 createMenu( 801, meshId, -1 );
3284 createMenu( 806, meshId, -1 );
3285 createMenu( 802, meshId, -1 );
3286 createMenu( 803, meshId, -1 );
3287 createMenu( 815, meshId, -1 );
3288 createMenu( separator(), meshId, -1 );
3289 createMenu( 810, meshId, -1 );
3290 createMenu( 811, meshId, -1 );
3291 createMenu( 812, meshId, -1 );
3292 createMenu( separator(), meshId, -1 );
3293 createMenu( 814, meshId, -1 );
3294 createMenu( separator(), meshId, -1 );
3295 createMenu( 813, meshId, -1 );
3296 createMenu( separator(), meshId, -1 );
3297 createMenu( 900, meshId, -1 );
3298 createMenu( 902, meshId, -1 );
3299 createMenu( 903, meshId, -1 );
3300 createMenu( 904, meshId, -1 );
3301 createMenu( separator(), meshId, -1 );
3303 createMenu( 6005, nodeId, -1 );
3304 createMenu( 6002, edgeId, -1 );
3305 createMenu( 6003, edgeId, -1 );
3306 createMenu( 6001, edgeId, -1 );
3307 createMenu( 6004, edgeId, -1 );
3308 createMenu( 6021, faceId, -1 );
3309 createMenu( 6018, faceId, -1 );
3310 createMenu( 6019, faceId, -1 );
3311 createMenu( 6011, faceId, -1 );
3312 createMenu( 6012, faceId, -1 );
3313 createMenu( 6013, faceId, -1 );
3314 createMenu( 6014, faceId, -1 );
3315 createMenu( 6015, faceId, -1 );
3316 createMenu( 6016, faceId, -1 );
3317 createMenu( 6022, faceId, -1 );
3318 createMenu( 6017, volumeId, -1 );
3319 createMenu( 6009, volumeId, -1 );
3320 createMenu( 6023, volumeId, -1 );
3322 createMenu( 4000, addId, -1 );
3323 createMenu( 4009, addId, -1 );
3324 createMenu( 4010, addId, -1 );
3325 createMenu( 4021, addId, -1 );
3326 createMenu( 4022, addId, -1 );
3327 createMenu( 4023, addId, -1 );
3328 createMenu( 4031, addId, -1 );
3329 createMenu( 4032, addId, -1 );
3330 createMenu( 4033, addId, -1 );
3331 createMenu( separator(), addId, -1 );
3332 createMenu( 4034, addId, -1 );
3333 createMenu( 4035, addId, -1 );
3334 createMenu( 4036, addId, -1 );
3335 createMenu( 4037, addId, -1 );
3336 createMenu( 4038, addId, -1 );
3337 createMenu( 4039, addId, -1 );
3338 createMenu( 4040, addId, -1 );
3340 createMenu( 4041, removeId, -1 );
3341 createMenu( 4042, removeId, -1 );
3342 createMenu( 4044, removeId, -1 );
3343 createMenu( separator(), removeId, -1 );
3344 createMenu( 4043, removeId, -1 );
3346 createMenu( 4051, renumId, -1 );
3347 createMenu( 4052, renumId, -1 );
3349 createMenu( 4061, transfId, -1 );
3350 createMenu( 4062, transfId, -1 );
3351 createMenu( 4063, transfId, -1 );
3352 createMenu( 4064, transfId, -1 );
3353 createMenu( 4065, transfId, -1 );
3354 createMenu( 4066, transfId, -1 );
3355 createMenu( 4068, transfId, -1 );
3356 createMenu( 4069, transfId, -1 );
3358 createMenu( 4067,modifyId, -1 );
3359 createMenu( 407, modifyId, -1 );
3360 createMenu( 408, modifyId, -1 );
3361 createMenu( 409, modifyId, -1 );
3362 createMenu( 410, modifyId, -1 );
3363 createMenu( 411, modifyId, -1 );
3364 createMenu( 419, modifyId, -1 );
3365 createMenu( 412, modifyId, -1 );
3366 createMenu( 413, modifyId, -1 );
3367 createMenu( 416, modifyId, -1 );
3368 createMenu( 414, modifyId, -1 );
3369 createMenu( 415, modifyId, -1 );
3370 createMenu( 417, modifyId, -1 );
3371 createMenu( 418, modifyId, -1 );
3373 createMenu( 214, viewId, -1 );
3375 // ----- create toolbars --------------
3376 int meshTb = createTool( tr( "TB_MESH" ) ),
3377 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3378 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3379 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3380 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3382 createTool( 702, meshTb );
3383 createTool( 703, meshTb );
3384 createTool( 704, meshTb );
3385 createTool( 710, meshTb );
3386 createTool( separator(), meshTb );
3387 createTool( 701, meshTb );
3388 createTool( 711, meshTb );
3389 createTool( 712, meshTb );
3390 createTool( 713, meshTb );
3391 createTool( separator(), meshTb );
3392 createTool( 801, meshTb );
3393 createTool( 806, meshTb );
3394 createTool( 802, meshTb );
3395 createTool( 803, meshTb );
3396 //createTool( 815, meshTb );
3397 createTool( separator(), meshTb );
3398 createTool( 900, meshTb );
3399 createTool( 902, meshTb );
3400 createTool( 903, meshTb );
3401 createTool( 904, meshTb );
3402 createTool( separator(), meshTb );
3404 createTool( 6005, ctrlTb );
3405 createTool( separator(), ctrlTb );
3406 createTool( 6002, ctrlTb );
3407 createTool( 6003, ctrlTb );
3408 createTool( 6001, ctrlTb );
3409 createTool( 6004, ctrlTb );
3410 createTool( separator(), ctrlTb );
3411 createTool( 6021, ctrlTb );
3412 createTool( 6018, ctrlTb );
3413 createTool( 6019, ctrlTb );
3414 createTool( 6011, ctrlTb );
3415 createTool( 6012, ctrlTb );
3416 createTool( 6013, ctrlTb );
3417 createTool( 6014, ctrlTb );
3418 createTool( 6015, ctrlTb );
3419 createTool( 6016, ctrlTb );
3420 createTool( 6022, ctrlTb );
3421 createTool( separator(), ctrlTb );
3422 createTool( 6017, ctrlTb );
3423 createTool( 6009, ctrlTb );
3424 createTool( 6023, ctrlTb );
3425 createTool( separator(), ctrlTb );
3427 createTool( 4000, addRemTb );
3428 createTool( 4009, addRemTb );
3429 createTool( 4010, addRemTb );
3430 createTool( 4021, addRemTb );
3431 createTool( 4022, addRemTb );
3432 createTool( 4023, addRemTb );
3433 createTool( 4031, addRemTb );
3434 createTool( 4032, addRemTb );
3435 createTool( 4033, addRemTb );
3436 createTool( separator(), addRemTb );
3437 createTool( 4034, addRemTb );
3438 createTool( 4035, addRemTb );
3439 createTool( 4036, addRemTb );
3440 createTool( 4037, addRemTb );
3441 createTool( 4038, addRemTb );
3442 createTool( 4039, addRemTb );
3443 createTool( 4040, addRemTb );
3444 createTool( separator(), addRemTb );
3445 createTool( 4041, addRemTb );
3446 createTool( 4042, addRemTb );
3447 createTool( 4044, addRemTb );
3448 createTool( 4043, addRemTb );
3449 createTool( separator(), addRemTb );
3450 createTool( 4051, addRemTb );
3451 createTool( 4052, addRemTb );
3452 createTool( separator(), addRemTb );
3453 createTool( 4061, addRemTb );
3454 createTool( 4062, addRemTb );
3455 createTool( 4063, addRemTb );
3456 createTool( 4064, addRemTb );
3457 createTool( 4065, addRemTb );
3458 createTool( 4066, addRemTb );
3459 createTool( 4068, addRemTb );
3460 createTool( 4069, addRemTb );
3461 createTool( separator(), addRemTb );
3463 createTool( 4067,modifyTb );
3464 createTool( 407, modifyTb );
3465 createTool( 408, modifyTb );
3466 createTool( 409, modifyTb );
3467 createTool( 410, modifyTb );
3468 createTool( 411, modifyTb );
3469 createTool( 419, modifyTb );
3470 createTool( 412, modifyTb );
3471 createTool( 413, modifyTb );
3472 createTool( 416, modifyTb );
3473 createTool( 414, modifyTb );
3474 createTool( 415, modifyTb );
3475 createTool( 417, modifyTb );
3476 createTool( 418, modifyTb );
3478 createTool( 214, dispModeTb );
3480 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3481 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3484 QString OB = "'ObjectBrowser'",
3485 View = "'" + SVTK_Viewer::Type() + "'",
3487 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3488 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3489 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3490 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3491 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3492 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3493 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3494 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3495 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3496 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3497 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3499 mesh_group = mesh + " " + subMesh + " " + group,
3500 hyp_alg = hypo + " " + algo;
3502 // popup for object browser
3504 isInvisible("not( isVisible )"),
3505 isEmpty("numberOfNodes = 0"),
3506 isNotEmpty("numberOfNodes <> 0"),
3508 // has nodes, edges, etc in VISIBLE! actor
3509 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3510 hasElems("(count( elemTypes ) > 0)"),
3511 hasDifferentElems("(count( elemTypes ) > 1)"),
3512 hasElems0d("({'Elem0d'} in elemTypes)"),
3513 hasEdges("({'Edge'} in elemTypes)"),
3514 hasFaces("({'Face'} in elemTypes)"),
3515 hasVolumes("({'Volume'} in elemTypes)");
3517 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3518 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3519 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3520 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3521 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3522 createPopupItem( 803, OB, group ); // EDIT_GROUP
3523 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3525 popupMgr()->insert( separator(), -1, 0 );
3526 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3527 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3528 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3529 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3530 createPopupItem( 214, OB, mesh_group ); // UPDATE
3531 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3532 createPopupItem( 902, OB, mesh ); // STD_INFO
3533 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3534 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3535 popupMgr()->insert( separator(), -1, 0 );
3536 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3537 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3538 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3539 popupMgr()->insert( separator(), -1, 0 );
3540 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3541 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3542 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3543 popupMgr()->insert( separator(), -1, 0 );
3544 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3545 popupMgr()->insert( separator(), -1, 0 );
3546 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3547 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3548 popupMgr()->insert( separator(), -1, 0 );
3550 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3551 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3553 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3554 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3555 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3556 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3557 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3558 popupMgr()->insert( separator(), -1, 0 );
3561 createPopupItem( 803, View, group ); // EDIT_GROUP
3562 createPopupItem( 804, View, elems ); // ADD
3563 createPopupItem( 805, View, elems ); // REMOVE
3565 popupMgr()->insert( separator(), -1, 0 );
3566 createPopupItem( 214, View, mesh_group ); // UPDATE
3567 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3568 createPopupItem( 902, View, mesh ); // STD_INFO
3569 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3570 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3571 popupMgr()->insert( separator(), -1, 0 );
3573 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3574 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3575 popupMgr()->insert( separator(), -1, 0 );
3578 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3579 QString aType = QString( "%1type in {%2}" ).arg( lc );
3580 aType = aType.arg( mesh_group );
3581 QString aMeshInVTK = aClient + "&&" + aType;
3583 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3584 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3585 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3587 //-------------------------------------------------
3589 //-------------------------------------------------
3590 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3592 popupMgr()->insert( action( 9010 ), anId, -1 );
3593 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3594 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3596 popupMgr()->insert( action( 9011 ), anId, -1 );
3597 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3598 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3600 popupMgr()->insert( separator(), -1, -1 );
3602 //-------------------------------------------------
3604 //-------------------------------------------------
3605 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3607 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3608 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3609 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3611 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3612 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3613 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3615 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3616 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3617 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3619 popupMgr()->insert( separator(), anId, -1 );
3621 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3622 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3623 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3625 //-------------------------------------------------
3627 //-------------------------------------------------
3628 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3630 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3632 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3633 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3634 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3636 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3637 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3638 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3640 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3641 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3642 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3644 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3645 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3646 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3648 popupMgr()->insert( separator(), anId, -1 );
3650 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3651 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3654 //-------------------------------------------------
3655 // Representation of the 2D Quadratic elements
3656 //-------------------------------------------------
3657 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3658 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3659 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3660 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3662 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3663 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3664 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3666 //-------------------------------------------------
3667 // Orientation of faces
3668 //-------------------------------------------------
3669 popupMgr()->insert( action( 221 ), -1, -1 );
3670 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3671 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3673 //-------------------------------------------------
3675 //-------------------------------------------------
3676 popupMgr()->insert( action( 1132 ), -1, -1 );
3677 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3679 //-------------------------------------------------
3681 //-------------------------------------------------
3682 popupMgr()->insert( action( 1133 ), -1, -1 );
3683 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3685 //-------------------------------------------------
3687 //-------------------------------------------------
3688 popupMgr()->insert( action( 1134 ), -1, -1 );
3689 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& selcount=1 && isVisible", QtxPopupMgr::VisibleRule );
3691 popupMgr()->insert( separator(), -1, -1 );
3693 //-------------------------------------------------
3695 //-------------------------------------------------
3697 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3698 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3699 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3700 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3702 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3704 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3705 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3707 popupMgr()->insert( separator(), anId, -1 );
3709 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3711 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3712 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3713 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3715 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3717 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3718 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3719 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3721 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3722 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3723 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3725 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3726 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3727 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3729 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3730 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3731 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3733 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3735 popupMgr()->insert( action( 6021 ), aSubId, -1 ); // FREE_FACE
3736 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3737 QtxPopupMgr::VisibleRule );
3738 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3740 popupMgr()->insert( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3741 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3742 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3744 popupMgr()->insert( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3745 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3746 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3748 popupMgr()->insert( action( 6011 ), aSubId, -1 ); // AREA
3749 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3750 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3752 popupMgr()->insert( action( 6012 ), aSubId, -1 ); // TAPER
3753 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3754 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3756 popupMgr()->insert( action( 6013 ), aSubId, -1 ); // ASPECT
3757 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3758 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3760 popupMgr()->insert( action( 6014 ), aSubId, -1 ); // MIN_ANG
3761 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3762 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3764 popupMgr()->insert( action( 6015 ), aSubId, -1 ); // WARP
3765 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3766 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3768 popupMgr()->insert( action( 6016 ), aSubId, -1 ); // SKEW
3769 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3770 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3772 popupMgr()->insert( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3773 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3774 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3776 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3778 popupMgr()->insert( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3779 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3780 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3782 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3783 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3784 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3786 popupMgr()->insert( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3787 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3788 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3790 popupMgr()->insert( separator(), anId, -1 );
3792 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3793 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3795 popupMgr()->insert( separator(), anId, -1 );
3797 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3798 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3800 popupMgr()->insert( separator(), -1, -1 );
3802 //-------------------------------------------------
3804 //-------------------------------------------------
3805 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3806 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3807 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3808 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3810 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3811 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3813 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3814 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3816 popupMgr()->insert( separator(), -1, -1 );
3818 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3819 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3822 //================================================================================
3824 * \brief Return true if SMESH or GEOM objects are selected.
3825 * Is called form LightApp_Module::activateModule() which clear selection if
3826 * not isSelectionCompatible()
3828 //================================================================================
3830 bool SMESHGUI::isSelectionCompatible()
3832 bool isCompatible = true;
3833 SALOME_ListIO selected;
3834 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3835 Sel->selectedObjects( selected );
3837 SALOME_ListIteratorOfListIO It( selected );
3838 for ( ; isCompatible && It.More(); It.Next())
3840 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3841 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3843 return isCompatible;
3847 bool SMESHGUI::reusableOperation( const int id )
3849 // compute, evaluate and precompute are not reusable operations
3850 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3853 bool SMESHGUI::activateModule( SUIT_Study* study )
3855 bool res = SalomeApp_Module::activateModule( study );
3857 setMenuShown( true );
3858 setToolShown( true );
3860 // Reset actions accelerator keys
3861 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3862 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3863 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3865 action( 33)->setEnabled(true); // Delete: Key_Delete
3866 action(1101)->setEnabled(true); // Rename: Key_F2
3868 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3869 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3870 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3871 if ( _PTR(Study) aStudy = s->studyDS()) {
3872 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3873 updateObjBrowser(); // objects can be removed
3879 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3881 setMenuShown( false );
3882 setToolShown( false );
3884 EmitSignalCloseAllDialogs();
3886 // Unset actions accelerator keys
3887 action(111)->setShortcut(QKeySequence()); // Import DAT
3888 action(112)->setShortcut(QKeySequence()); // Import UNV
3889 action(113)->setShortcut(QKeySequence()); // Import MED
3891 action( 33)->setEnabled(false); // Delete: Key_Delete
3892 action(1101)->setEnabled(false); // Rename: Key_F2
3894 return SalomeApp_Module::deactivateModule( study );
3897 void SMESHGUI::studyClosed( SUIT_Study* s )
3899 SMESH::RemoveVisuData( s->id() );
3900 SalomeApp_Module::studyClosed( s );
3903 void SMESHGUI::OnGUIEvent()
3905 const QObject* obj = sender();
3906 if ( !obj || !obj->inherits( "QAction" ) )
3908 int id = actionId((QAction*)obj);
3913 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3915 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3916 if ( CORBA::is_nil( myComponentSMESH ) )
3918 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3920 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3921 return aGUI.myComponentSMESH;
3924 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3925 return myComponentSMESH;
3928 QString SMESHGUI::engineIOR() const
3930 CORBA::ORB_var anORB = getApp()->orb();
3931 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3932 return QString( anIOR.in() );
3935 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3937 SalomeApp_Module::contextMenuPopup( client, menu, title );
3939 selectionMgr()->selectedObjects( lst );
3940 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3941 Handle(SALOME_InteractiveObject) io = lst.First();
3942 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3943 _PTR(Study) study = appStudy->studyDS();
3944 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3946 QString aName = QString( obj->GetName().c_str() );
3947 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3948 aName.remove( (aName.length() - 1), 1 );
3954 LightApp_Selection* SMESHGUI::createSelection() const
3956 return new SMESHGUI_Selection();
3959 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3961 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3962 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3965 void SMESHGUI::viewManagers( QStringList& list ) const
3967 list.append( SVTK_Viewer::Type() );
3970 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3972 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3973 SMESH::UpdateSelectionProp( this );
3976 void SMESHGUI::createPreferences()
3978 // General tab ------------------------------------------------------------------------
3979 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3981 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3982 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3984 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3985 setPreferenceProperty( qaGroup, "columns", 2 );
3986 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3987 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3988 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3989 setPreferenceProperty( prec, "min", 0 );
3990 setPreferenceProperty( prec, "max", 16 );
3992 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3993 setPreferenceProperty( dispgroup, "columns", 2 );
3994 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3996 modes.append( "Wireframe" );
3997 modes.append( "Shading" );
3998 modes.append( "Nodes" );
3999 modes.append( "Shrink" );
4000 QList<QVariant> indices;
4001 indices.append( 0 );
4002 indices.append( 1 );
4003 indices.append( 2 );
4004 indices.append( 3 );
4005 setPreferenceProperty( dispmode, "strings", modes );
4006 setPreferenceProperty( dispmode, "indexes", indices );
4008 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4009 setPreferenceProperty( arcgroup, "columns", 2 );
4010 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4011 QStringList quadraticModes;
4012 quadraticModes.append("Lines");
4013 quadraticModes.append("Arcs");
4015 indices.append( 0 );
4016 indices.append( 1 );
4017 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4018 setPreferenceProperty( quadraticmode, "indexes", indices );
4020 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4021 "SMESH", "max_angle" );
4022 setPreferenceProperty( maxAngle, "min", 1 );
4023 setPreferenceProperty( maxAngle, "max", 90 );
4027 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4028 setPreferenceProperty( exportgroup, "columns", 2 );
4029 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4030 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4032 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4033 setPreferenceProperty( computeGroup, "columns", 2 );
4034 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4036 modes.append( "Never" );
4037 modes.append( "Errors only" );
4038 modes.append( "Always" );
4040 indices.append( 0 );
4041 indices.append( 1 );
4042 indices.append( 2 );
4043 setPreferenceProperty( notifyMode, "strings", modes );
4044 setPreferenceProperty( notifyMode, "indexes", indices );
4046 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4047 setPreferenceProperty( segGroup, "columns", 2 );
4048 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4049 "SMESH", "segmentation" );
4050 setPreferenceProperty( segLen, "min", 1 );
4051 setPreferenceProperty( segLen, "max", 10000000 );
4052 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4053 "SMESH", "nb_segments_per_edge" );
4054 setPreferenceProperty( nbSeg, "min", 1 );
4055 setPreferenceProperty( nbSeg, "max", 10000000 );
4057 // Quantities with individual precision settings
4058 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4059 setPreferenceProperty( precGroup, "columns", 2 );
4061 const int nbQuantities = 6;
4062 int precs[nbQuantities], ii = 0;
4063 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4064 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4065 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4066 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4067 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4068 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4069 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4070 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4071 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4072 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4073 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4074 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4076 // Set property for precision value for spinboxes
4077 for ( ii = 0; ii < nbQuantities; ii++ ){
4078 setPreferenceProperty( precs[ii], "min", -14 );
4079 setPreferenceProperty( precs[ii], "max", 14 );
4080 setPreferenceProperty( precs[ii], "precision", 2 );
4083 // Mesh tab ------------------------------------------------------------------------
4084 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4085 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4086 setPreferenceProperty( nodeGroup, "columns", 3 );
4088 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4090 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4092 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4093 QList<QVariant> aMarkerTypeIndicesList;
4094 QList<QVariant> aMarkerTypeIconsList;
4095 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4096 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4097 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4098 aMarkerTypeIndicesList << i;
4099 aMarkerTypeIconsList << pixmap;
4101 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4102 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4104 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4106 QList<QVariant> aMarkerScaleIndicesList;
4107 QStringList aMarkerScaleValuesList;
4108 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4109 aMarkerScaleIndicesList << i;
4110 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4112 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4113 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4115 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4116 setPreferenceProperty( elemGroup, "columns", 2 );
4118 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4119 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4120 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4121 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4123 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4124 setPreferenceProperty( grpGroup, "columns", 2 );
4126 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4128 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4129 //setPreferenceProperty( sp, "hstretch", 0 );
4130 //setPreferenceProperty( sp, "vstretch", 0 );
4132 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4133 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4134 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4135 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4136 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4137 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4138 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4140 setPreferenceProperty( size0d, "min", 1 );
4141 setPreferenceProperty( size0d, "max", 10 );
4143 setPreferenceProperty( sp, "hstretch", 0 );
4144 setPreferenceProperty( sp, "vstretch", 0 );
4146 setPreferenceProperty( elemW, "min", 1 );
4147 setPreferenceProperty( elemW, "max", 5 );
4149 setPreferenceProperty( shrink, "min", 0 );
4150 setPreferenceProperty( shrink, "max", 100 );
4152 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4153 setPreferenceProperty( orientGroup, "columns", 1 );
4155 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4156 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4158 setPreferenceProperty( orientScale, "min", 0.05 );
4159 setPreferenceProperty( orientScale, "max", 0.5 );
4160 setPreferenceProperty( orientScale, "step", 0.05 );
4162 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4164 // Selection tab ------------------------------------------------------------------------
4165 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4167 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4168 setPreferenceProperty( selGroup, "columns", 2 );
4170 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4171 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4172 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4174 setPreferenceProperty( selW, "min", 1 );
4175 setPreferenceProperty( selW, "max", 5 );
4177 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4178 setPreferenceProperty( preGroup, "columns", 2 );
4180 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4181 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4183 setPreferenceProperty( preW, "min", 1 );
4184 setPreferenceProperty( preW, "max", 5 );
4186 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4187 setPreferenceProperty( precSelGroup, "columns", 2 );
4189 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4190 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4191 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4193 // Scalar Bar tab ------------------------------------------------------------------------
4194 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4195 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4196 setPreferenceProperty( fontGr, "columns", 2 );
4198 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4199 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4201 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4202 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4204 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4205 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4207 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4208 setPreferenceProperty( numcol, "min", 2 );
4209 setPreferenceProperty( numcol, "max", 256 );
4211 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4212 setPreferenceProperty( numlab, "min", 2 );
4213 setPreferenceProperty( numlab, "max", 65 );
4215 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4216 setPreferenceProperty( orientGr, "columns", 2 );
4217 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4218 QStringList orients;
4219 orients.append( tr( "SMESH_VERTICAL" ) );
4220 orients.append( tr( "SMESH_HORIZONTAL" ) );
4221 indices.clear(); indices.append( 0 ); indices.append( 1 );
4222 setPreferenceProperty( orient, "strings", orients );
4223 setPreferenceProperty( orient, "indexes", indices );
4225 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4226 setPreferenceProperty( posVSizeGr, "columns", 2 );
4227 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4228 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4229 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4230 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4231 setPreferenceProperty( xv, "step", 0.1 );
4232 setPreferenceProperty( xv, "min", 0.0 );
4233 setPreferenceProperty( xv, "max", 1.0 );
4234 setPreferenceProperty( yv, "step", 0.1 );
4235 setPreferenceProperty( yv, "min", 0.0 );
4236 setPreferenceProperty( yv, "max", 1.0 );
4237 setPreferenceProperty( wv, "step", 0.1 );
4238 setPreferenceProperty( wv, "min", 0.0 );
4239 setPreferenceProperty( wv, "max", 1.0 );
4240 setPreferenceProperty( hv, "min", 0.0 );
4241 setPreferenceProperty( hv, "max", 1.0 );
4242 setPreferenceProperty( hv, "step", 0.1 );
4244 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4245 setPreferenceProperty( posHSizeGr, "columns", 2 );
4246 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4247 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4248 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4249 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4250 setPreferenceProperty( xv, "min", 0.0 );
4251 setPreferenceProperty( xv, "max", 1.0 );
4252 setPreferenceProperty( xv, "step", 0.1 );
4253 setPreferenceProperty( xh, "min", 0.0 );
4254 setPreferenceProperty( xh, "max", 1.0 );
4255 setPreferenceProperty( xh, "step", 0.1 );
4256 setPreferenceProperty( yh, "min", 0.0 );
4257 setPreferenceProperty( yh, "max", 1.0 );
4258 setPreferenceProperty( yh, "step", 0.1 );
4259 setPreferenceProperty( wh, "min", 0.0 );
4260 setPreferenceProperty( wh, "max", 1.0 );
4261 setPreferenceProperty( wh, "step", 0.1 );
4262 setPreferenceProperty( hh, "min", 0.0 );
4263 setPreferenceProperty( hh, "max", 1.0 );
4264 setPreferenceProperty( hh, "step", 0.1 );
4267 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4269 if( sect=="SMESH" ) {
4270 float sbX1,sbY1,sbW,sbH;
4271 float aTol = 1.00000009999999;
4272 std::string aWarning;
4273 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4274 if( name=="selection_object_color" || name=="selection_element_color" ||
4275 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4276 name=="selection_precision_node" || name=="selection_precision_element" ||
4277 name=="selection_precision_object")
4278 SMESH::UpdateSelectionProp( this );
4279 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4280 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4281 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4282 if(sbX1+sbW > aTol){
4283 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4286 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4287 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4290 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4291 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4292 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4293 if(sbY1+sbH > aTol){
4294 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4295 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4296 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4299 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4300 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4301 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4302 if(sbX1+sbW > aTol){
4303 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4306 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4307 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4310 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4311 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4312 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4313 if(sbY1+sbH > aTol){
4314 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4317 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4318 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4321 else if ( name == "segmentation" ) {
4322 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4323 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4325 else if ( name == "nb_segments_per_edge" ) {
4326 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4327 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4330 if(aWarning.size() != 0){
4331 aWarning += "The default values are applied instead.";
4332 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4333 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4334 QObject::tr(aWarning.c_str()));
4339 //================================================================================
4341 * \brief Update something in accordance with update flags
4342 * \param theFlags - update flags
4344 * Update viewer or/and object browser etc. in accordance with update flags ( see
4345 * LightApp_UpdateFlags enumeration ).
4347 //================================================================================
4348 void SMESHGUI::update( const int flags )
4350 if ( flags & UF_Viewer | flags & UF_Forced )
4351 SMESH::UpdateView();
4353 SalomeApp_Module::update( flags );
4356 //================================================================================
4358 * \brief Set default selection mode
4360 * SLOT called when operation commited. Sets default selection mode
4362 //================================================================================
4363 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4365 SVTK_ViewWindow* vtkWnd =
4366 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4368 vtkWnd->SetSelectionMode( ActorSelection );
4371 //================================================================================
4373 * \brief Set default selection mode
4375 * SLOT called when operation aborted. Sets default selection mode
4377 //================================================================================
4378 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4380 SVTK_ViewWindow* vtkWnd =
4381 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4383 vtkWnd->SetSelectionMode( ActorSelection );
4386 //================================================================================
4388 * \brief Creates operation with given identifier
4389 * \param id - identifier of operation to be started
4390 * \return Pointer on created operation or NULL if operation is not created
4392 * Virtual method redefined from the base class creates operation with given id.
4393 * It is called called automatically from startOperation method of base class.
4395 //================================================================================
4396 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4398 LightApp_Operation* op = 0;
4399 // to do : create operation here
4402 case 417: //convert to quadratic
4403 op = new SMESHGUI_ConvToQuadOp();
4405 case 418: // create 2D mesh as boundary on 3D
4406 op = new SMESHGUI_Make2DFrom3DOp();
4408 case 701: // Compute mesh
4409 op = new SMESHGUI_ComputeOp();
4411 case 702: // Create mesh
4412 op = new SMESHGUI_MeshOp( true, true );
4414 case 703: // Create sub-mesh
4415 op = new SMESHGUI_MeshOp( true, false );
4417 case 704: // Edit mesh/sub-mesh
4418 op = new SMESHGUI_MeshOp( false );
4420 case 711: // Precompute mesh
4421 op = new SMESHGUI_PrecomputeOp();
4423 case 712: // Evaluate mesh
4424 op = new SMESHGUI_EvaluateOp();
4426 case 713: // Evaluate mesh
4427 op = new SMESHGUI_MeshOrderOp();
4429 case 806: // Create group on geom
4430 op = new SMESHGUI_GroupOnShapeOp();
4432 case 904: // Find element
4433 op = new SMESHGUI_FindElemByPointOp();
4435 case 4067: // make mesh pass through point
4436 op = new SMESHGUI_MakeNodeAtPointOp();
4443 op = SalomeApp_Module::createOperation( id );
4447 //================================================================================
4449 * \brief Stops current operations and starts a given one
4450 * \param id - The id of the operation to start
4452 //================================================================================
4454 void SMESHGUI::switchToOperation(int id)
4456 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4457 activeStudy()->abortAllOperations();
4458 startOperation( id );
4461 LightApp_Displayer* SMESHGUI::displayer()
4464 myDisplayer = new SMESHGUI_Displayer( getApp() );
4468 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4471 int aTolerance = 64;
4472 int anIterations = 0;
4478 if( anIterations % aPeriod == 0 )
4481 if( aTolerance < 1 )
4484 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
4486 aHue = (int)( 360.0 * rand() / RAND_MAX );
4487 //cout << "Hue = " << aHue << endl;
4489 //cout << "Auto colors : ";
4491 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4492 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4493 for( ; it != itEnd; ++it )
4495 SALOMEDS::Color anAutoColor = *it;
4496 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4499 aQColor.getHsv( &h, &s, &v );
4501 if( abs( h - aHue ) < aTolerance )
4504 //cout << "break (diff = " << abs( h - aHue ) << ")";
4514 //cout << "Hue of the returned color = " << aHue << endl;
4516 aColor.setHsv( aHue, 255, 255 );
4518 SALOMEDS::Color aSColor;
4519 aSColor.R = (double)aColor.red() / 255.0;
4520 aSColor.G = (double)aColor.green() / 255.0;
4521 aSColor.B = (double)aColor.blue() / 255.0;
4526 const char gSeparator = '_'; // character used to separate parameter names
4527 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4528 const char gPathSep = '|'; // character used to separate paths
4531 * \brief Store visual parameters
4533 * This method is called just before the study document is saved.
4534 * Store visual parameters in AttributeParameter attribue(s)
4536 void SMESHGUI::storeVisualParameters (int savePoint)
4538 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4539 if (!appStudy || !appStudy->studyDS())
4541 _PTR(Study) studyDS = appStudy->studyDS();
4543 // componentName is used for encoding of entries when storing them in IParameters
4544 std::string componentName = myComponentSMESH->ComponentDataType();
4545 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4546 //if (!aSComponent) return;
4549 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4550 componentName.c_str(),
4552 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4554 // store map of custom markers
4555 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4556 if( !aMarkerMap.empty() )
4558 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4559 for( ; anIter != aMarkerMap.end(); anIter++ )
4561 int anId = anIter->first;
4562 VTK::MarkerData aMarkerData = anIter->second;
4563 std::string aMarkerFileName = aMarkerData.first;
4564 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4565 if( aMarkerTexture.size() < 3 )
4566 continue; // should contain at least width, height and the first value
4568 QString aPropertyName( "texture" );
4569 aPropertyName += gSeparator;
4570 aPropertyName += QString::number( anId );
4572 QString aPropertyValue = aMarkerFileName.c_str();
4573 aPropertyValue += gPathSep;
4575 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4576 ushort aWidth = *aTextureIter++;
4577 ushort aHeight = *aTextureIter++;
4578 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4579 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4580 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4581 aPropertyValue += QString::number( *aTextureIter );
4583 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4587 // viewers counters are used for storing view_numbers in IParameters
4590 // main cycle to store parameters of displayed objects
4591 QList<SUIT_ViewManager*> lst;
4592 QList<SUIT_ViewManager*>::Iterator it;
4593 getApp()->viewManagers(lst);
4594 for (it = lst.begin(); it != lst.end(); it++)
4596 SUIT_ViewManager* vman = *it;
4597 QString vType = vman->getType();
4599 // saving VTK actors properties
4600 if (vType == SVTK_Viewer::Type())
4602 QVector<SUIT_ViewWindow*> views = vman->getViews();
4603 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4605 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4607 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4608 vtkActorCollection* allActors = aCopy.GetActors();
4609 allActors->InitTraversal();
4610 while (vtkActor* actor = allActors->GetNextActor())
4612 if (actor->GetVisibility()) // store only visible actors
4614 SMESH_Actor* aSmeshActor = 0;
4615 if (actor->IsA("SMESH_Actor"))
4616 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4617 if (aSmeshActor && aSmeshActor->hasIO())
4619 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4622 // entry is "encoded" = it does NOT contain component adress,
4623 // since it is a subject to change on next component loading
4624 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4626 std::string param, vtkParam = vType.toLatin1().data();
4627 vtkParam += gSeparator;
4628 vtkParam += QString::number(vtkViewers).toLatin1().data();
4629 vtkParam += gSeparator;
4632 param = vtkParam + "Visibility";
4633 ip->setParameter(entry, param, "On");
4636 param = vtkParam + "Representation";
4637 ip->setParameter(entry, param, QString::number
4638 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4641 param = vtkParam + "IsShrunk";
4642 ip->setParameter(entry, param, QString::number
4643 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4645 // Displayed entities
4646 unsigned int aMode = aSmeshActor->GetEntityMode();
4647 bool isE = aMode & SMESH_Actor::eEdges;
4648 bool isF = aMode & SMESH_Actor::eFaces;
4649 bool isV = aMode & SMESH_Actor::eVolumes;
4651 QString modeStr ("e");
4652 modeStr += gDigitsSep; modeStr += QString::number(isE);
4653 modeStr += gDigitsSep; modeStr += "f";
4654 modeStr += gDigitsSep; modeStr += QString::number(isF);
4655 modeStr += gDigitsSep; modeStr += "v";
4656 modeStr += gDigitsSep; modeStr += QString::number(isV);
4658 param = vtkParam + "Entities";
4659 ip->setParameter(entry, param, modeStr.toLatin1().data());
4661 // Colors (surface:edge:)
4662 vtkFloatingPointType r, g, b;
4664 aSmeshActor->GetSufaceColor(r, g, b);
4665 QString colorStr ("surface");
4666 colorStr += gDigitsSep; colorStr += QString::number(r);
4667 colorStr += gDigitsSep; colorStr += QString::number(g);
4668 colorStr += gDigitsSep; colorStr += QString::number(b);
4670 aSmeshActor->GetBackSufaceColor(r, g, b);
4671 colorStr += gDigitsSep; colorStr += "backsurface";
4672 colorStr += gDigitsSep; colorStr += QString::number(r);
4673 colorStr += gDigitsSep; colorStr += QString::number(g);
4674 colorStr += gDigitsSep; colorStr += QString::number(b);
4676 aSmeshActor->GetEdgeColor(r, g, b);
4677 colorStr += gDigitsSep; colorStr += "edge";
4678 colorStr += gDigitsSep; colorStr += QString::number(r);
4679 colorStr += gDigitsSep; colorStr += QString::number(g);
4680 colorStr += gDigitsSep; colorStr += QString::number(b);
4682 aSmeshActor->GetNodeColor(r, g, b);
4683 colorStr += gDigitsSep; colorStr += "node";
4684 colorStr += gDigitsSep; colorStr += QString::number(r);
4685 colorStr += gDigitsSep; colorStr += QString::number(g);
4686 colorStr += gDigitsSep; colorStr += QString::number(b);
4688 param = vtkParam + "Colors";
4689 ip->setParameter(entry, param, colorStr.toLatin1().data());
4691 // Sizes of lines and points
4692 QString sizeStr ("line");
4693 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4694 sizeStr += gDigitsSep; sizeStr += "shrink";
4695 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4697 param = vtkParam + "Sizes";
4698 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4703 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4704 if( aMarkerType == VTK::MT_USER ) {
4705 markerStr += "custom";
4706 markerStr += gDigitsSep;
4707 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4711 markerStr += gDigitsSep;
4712 markerStr += QString::number( (int)aMarkerType );
4713 markerStr += gDigitsSep;
4714 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4717 param = vtkParam + "PointMarker";
4718 ip->setParameter(entry, param, markerStr.toLatin1().data());
4721 param = vtkParam + "Opacity";
4722 ip->setParameter(entry, param,
4723 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4726 param = vtkParam + "ClippingPlane";
4727 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
4729 ip->setParameter(entry, param, "Off");
4730 for (int ipl = 0; ipl < nPlanes; ipl++) {
4731 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
4732 SMESH::Orientation anOrientation;
4734 vtkFloatingPointType anAngle[2];
4735 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
4736 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
4737 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
4738 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
4739 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
4741 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
4743 } // if (io->hasEntry())
4744 } // SMESH_Actor && hasIO
4746 } // while.. actors traversal
4750 } // if (SVTK view model)
4751 } // for (viewManagers)
4755 * \brief Restore visual parameters
4757 * This method is called after the study document is opened.
4758 * Restore visual parameters from AttributeParameter attribue(s)
4760 void SMESHGUI::restoreVisualParameters (int savePoint)
4762 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4763 if (!appStudy || !appStudy->studyDS())
4765 _PTR(Study) studyDS = appStudy->studyDS();
4767 // componentName is used for encoding of entries when storing them in IParameters
4768 std::string componentName = myComponentSMESH->ComponentDataType();
4769 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4770 //if (!aSComponent) return;
4773 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4774 componentName.c_str(),
4776 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4778 // restore map of custom markers
4779 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4781 std::vector<std::string> properties = ip->getProperties();
4782 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4784 std::string property = *propIt;
4785 QString aPropertyName( property.c_str() );
4786 QString aPropertyValue( ip->getProperty( property ).c_str() );
4788 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4789 if( aPropertyNameList.size() != 2 )
4794 if( aPropertyNameList[0] == "texture" )
4795 anId = aPropertyNameList[1].toInt( &ok );
4797 if( !ok || anId < 1 )
4800 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4801 if( aPropertyValueList.size() != 2 )
4804 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
4805 QString aMarkerTextureString = aPropertyValueList[1];
4806 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
4807 if( aMarkerTextureStringList.size() != 3 )
4811 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
4816 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
4820 VTK::MarkerTexture aMarkerTexture;
4821 aMarkerTexture.push_back( aWidth );
4822 aMarkerTexture.push_back( aHeight );
4824 QString aMarkerTextureData = aMarkerTextureStringList[2];
4825 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
4827 QChar aChar = aMarkerTextureData.at( i );
4828 if( aChar.isDigit() )
4829 aMarkerTexture.push_back( aChar.digitValue() );
4832 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
4835 std::vector<std::string> entries = ip->getEntries();
4837 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
4839 // entry is a normal entry - it should be "decoded" (setting base adress of component)
4840 QString entry (ip->decodeEntry(*entIt).c_str());
4842 // Check that the entry corresponds to a real object in the Study
4843 // as the object may be deleted or modified after the visual state is saved.
4844 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4845 if (!so) continue; //Skip the not existent entry
4847 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4848 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4850 std::vector<std::string>::iterator namesIt = paramNames.begin();
4851 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4853 // actors are stored in a map after displaying of them for
4854 // quicker access in the future: map < viewID to actor >
4855 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4857 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4859 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4860 // '_' is used as separator and should not be used in viewer type or parameter names.
4861 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4862 if (lst.size() != 3)
4865 QString viewerTypStr = lst[0];
4866 QString viewIndexStr = lst[1];
4867 QString paramNameStr = lst[2];
4870 int viewIndex = viewIndexStr.toUInt(&ok);
4871 if (!ok) // bad conversion of view index to integer
4875 if (viewerTypStr == SVTK_Viewer::Type())
4877 SMESH_Actor* aSmeshActor = 0;
4878 if (vtkActors.IsBound(viewIndex))
4879 aSmeshActor = vtkActors.Find(viewIndex);
4881 if (paramNameStr == "Visibility")
4883 if (!aSmeshActor && displayer())
4885 QList<SUIT_ViewManager*> lst;
4886 getApp()->viewManagers(viewerTypStr, lst);
4888 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4889 if (viewIndex >= 0 && viewIndex < lst.count()) {
4890 SUIT_ViewManager* vman = lst.at(viewIndex);
4891 SUIT_ViewModel* vmodel = vman->getViewModel();
4892 // SVTK view model can be casted to SALOME_View
4893 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4895 // store displayed actor in a temporary map for quicker
4896 // access later when restoring other parameters
4897 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4898 vtkRenderer* Renderer = vtkView->getRenderer();
4899 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
4900 vtkActorCollection* theActors = aCopy.GetActors();
4901 theActors->InitTraversal();
4902 bool isFound = false;
4903 vtkActor *ac = theActors->GetNextActor();
4904 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4905 if (ac->IsA("SMESH_Actor")) {
4906 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4907 if (aGeomAc->hasIO()) {
4908 Handle(SALOME_InteractiveObject) io =
4909 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4910 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4912 vtkActors.Bind(viewIndex, aGeomAc);
4919 } // if (paramNameStr == "Visibility")
4922 // the rest properties "work" with SMESH_Actor
4925 QString val ((*valuesIt).c_str());
4928 if (paramNameStr == "Representation") {
4929 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4932 else if (paramNameStr == "IsShrunk") {
4934 if (!aSmeshActor->IsShrunk())
4935 aSmeshActor->SetShrink();
4938 if (aSmeshActor->IsShrunk())
4939 aSmeshActor->UnShrink();
4942 // Displayed entities
4943 else if (paramNameStr == "Entities") {
4944 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4945 if (mode.count() == 6) {
4946 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4947 MESSAGE("Invalid order of data in Entities, must be: "
4948 "e:0/1:f:0/1:v:0/1");
4951 unsigned int aMode = aSmeshActor->GetEntityMode();
4952 unsigned int aNewMode =
4953 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4954 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4955 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4956 if (aNewMode != aMode)
4957 aSmeshActor->SetEntityMode(aNewMode);
4962 else if (paramNameStr == "Colors") {
4963 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4964 if (colors.count() == 16) {
4965 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4966 colors[8] != "edge" || colors[12] != "node") {
4967 MESSAGE("Invalid order of data in Colors, must be: "
4968 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4971 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4972 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4973 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4974 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4978 // Sizes of lines and points
4979 else if (paramNameStr == "Sizes") {
4980 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4981 if (sizes.count() == 4) {
4982 if (sizes[0] != "line" || sizes[2] != "shrink") {
4983 MESSAGE("Invalid order of data in Sizes, must be: "
4984 "line:int:shrink:float");
4987 aSmeshActor->SetLineWidth(sizes[1].toInt());
4988 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
4991 else if (sizes.count() == 6) { // just to support old format
4992 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4993 MESSAGE("Invalid order of data in Sizes, must be: "
4994 "line:int:node:int:shrink:float");
4997 aSmeshActor->SetLineWidth(sizes[1].toInt());
4998 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
4999 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5004 else if (paramNameStr == "PointMarker") {
5005 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5006 if( data.count() >= 2 ) {
5008 int aParam1 = data[1].toInt( &ok );
5010 if( data[0] == "std" && data.count() == 3 ) {
5011 int aParam2 = data[2].toInt( &ok );
5012 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5014 else if( data[0] == "custom" ) {
5015 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5016 if( markerIt != aMarkerMap.end() ) {
5017 VTK::MarkerData aMarkerData = markerIt->second;
5018 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5025 else if (paramNameStr == "Opacity") {
5026 aSmeshActor->SetOpacity(val.toFloat());
5029 else if (paramNameStr.startsWith("ClippingPlane")) {
5030 cout << "$$$ ClippingPlane 1" << endl;
5031 if (paramNameStr == "ClippingPlane1" || val == "Off")
5032 aSmeshActor->RemoveAllClippingPlanes();
5034 cout << "$$$ ClippingPlane 2" << endl;
5035 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5036 if (vals.count() == 4) { // format check: 4 values
5037 cout << "$$$ ClippingPlane 3" << endl;
5038 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5039 double aDistance = vals[1].toFloat();
5040 vtkFloatingPointType anAngle[2];
5041 anAngle[0] = vals[2].toFloat();
5042 anAngle[1] = vals[3].toFloat();
5044 QList<SUIT_ViewManager*> lst;
5045 getApp()->viewManagers(viewerTypStr, lst);
5046 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5047 if (viewIndex >= 0 && viewIndex < lst.count()) {
5048 SUIT_ViewManager* vman = lst.at(viewIndex);
5049 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5050 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
5051 anOrientation, aDistance, anAngle);
5056 } // if (aSmeshActor)
5057 } // other parameters than Visibility
5059 } // for names/parameters iterator
5060 } // for entries iterator
5062 // update all VTK views
5063 QList<SUIT_ViewManager*> lst;
5064 getApp()->viewManagers(lst);
5065 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5066 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5067 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5068 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5069 vtkView->getRenderer()->ResetCameraClippingRange();
5076 \brief Adds preferences for dfont of VTK viewer
5078 \param pIf group identifier
5079 \param param parameter
5080 \return identifier of preferences
5082 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5084 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5086 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5089 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5090 fam.append( tr( "SMESH_FONT_COURIER" ) );
5091 fam.append( tr( "SMESH_FONT_TIMES" ) );
5093 setPreferenceProperty( tfont, "fonts", fam );
5095 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5096 setPreferenceProperty( tfont, "features", f );
5102 \brief Actions after hypothesis edition
5103 Updates object browser after hypothesis edition
5105 void SMESHGUI::onHypothesisEdit( int result )
5108 SMESHGUI::Modified();
5109 updateObjBrowser( true );