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_Measurements.h"
53 #include "SMESHGUI_MeshInfo.h"
54 #include "SMESHGUI_MeshOp.h"
55 #include "SMESHGUI_MeshOrderOp.h"
56 #include "SMESHGUI_MeshPatternDlg.h"
57 #include "SMESHGUI_MultiEditDlg.h"
58 #include "SMESHGUI_NodesDlg.h"
59 #include "SMESHGUI_Preferences_ColorDlg.h"
60 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
61 #include "SMESHGUI_RemoveElementsDlg.h"
62 #include "SMESHGUI_RemoveNodesDlg.h"
63 #include "SMESHGUI_RenumberingDlg.h"
64 #include "SMESHGUI_RevolutionDlg.h"
65 #include "SMESHGUI_RotationDlg.h"
66 #include "SMESHGUI_Selection.h"
67 #include "SMESHGUI_SewingDlg.h"
68 #include "SMESHGUI_SingleEditDlg.h"
69 #include "SMESHGUI_SmoothingDlg.h"
70 //#include "SMESHGUI_StandardMeshInfosDlg.h"
71 #include "SMESHGUI_SymmetryDlg.h"
72 #include "SMESHGUI_TranslationDlg.h"
73 #include "SMESHGUI_ScaleDlg.h"
74 #include "SMESHGUI_TransparencyDlg.h"
75 //#include "SMESHGUI_WhatIsDlg.h"
76 #include "SMESHGUI_DuplicateNodesDlg.h"
78 #include "SMESHGUI_Utils.h"
79 #include "SMESHGUI_MeshUtils.h"
80 #include "SMESHGUI_GroupUtils.h"
81 #include "SMESHGUI_FilterUtils.h"
82 #include "SMESHGUI_PatternUtils.h"
83 #include "SMESHGUI_VTKUtils.h"
84 #include "SMESHGUI_HypothesesUtils.h"
86 #include <SMESH_Client.hxx>
87 #include <SMESH_Actor.h>
88 #include <SMESH_ScalarBarActor.h>
89 #include <SMESH_TypeFilter.hxx>
90 #include "SMESH_ControlsDef.hxx"
92 // SALOME GUI includes
93 #include <SalomeApp_Tools.h>
94 #include <SalomeApp_Study.h>
95 #include <SalomeApp_Application.h>
96 #include <SalomeApp_CheckFileDlg.h>
98 #include <LightApp_DataOwner.h>
99 #include <LightApp_Preferences.h>
100 #include <LightApp_SelectionMgr.h>
101 #include <LightApp_UpdateFlags.h>
102 #include <LightApp_NameDlg.h>
104 #include <SVTK_ViewWindow.h>
105 #include <SVTK_ViewModel.h>
106 #include <SVTK_ViewManager.h>
108 #include <VTKViewer_Algorithm.h>
110 #include <SUIT_MessageBox.h>
111 #include <SUIT_ResourceMgr.h>
112 #include <SUIT_FileDlg.h>
113 #include <SUIT_Desktop.h>
114 #include <SUIT_OverrideCursor.h>
115 #include <SUIT_Session.h>
117 #include <QtxPopupMgr.h>
118 #include <QtxFontEdit.h>
120 #include <SALOME_ListIO.hxx>
121 #include <SALOME_ListIteratorOfListIO.hxx>
124 #include <SALOMEconfig.h>
125 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
126 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
127 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
130 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
132 #include <QTextStream>
135 #include <boost/shared_ptr.hpp>
138 #include <vtkCamera.h>
139 #include <vtkRenderer.h>
140 #include <vtkPlane.h>
141 #include <vtkCallbackCommand.h>
143 // SALOME KERNEL includes
144 #include <SALOMEDS_Study.hxx>
145 #include <SALOMEDSClient_StudyBuilder.hxx>
146 #include <SALOMEDSClient_SComponent.hxx>
147 #include <SALOMEDSClient_ClientFactory.hxx>
148 #include <SALOMEDSClient_IParameters.hxx>
151 #include <Standard_ErrorHandler.hxx>
152 #include <NCollection_DataMap.hxx>
154 //To disable automatic genericobj management, the following line should be commented.
155 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
156 #define WITHGENERICOBJ
160 //=============================================================
161 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
164 void ExportMeshToFile(int theCommandID);
166 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
168 void SetDisplayEntity(int theCommandID);
170 void Control( int theCommandID );
174 //=============================================================
175 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
179 std::string myExtension;
181 if ( theCommandID == 113 ) {
182 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
183 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
185 else if ( theCommandID == 112 ) {
186 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
188 else if ( theCommandID == 111 ) {
189 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
192 QString anInitialPath = "";
193 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
194 anInitialPath = QDir::currentPath();
196 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
199 QObject::tr( "SMESH_IMPORT_MESH" ) );
200 if ( filenames.count() > 0 ) {
201 SUIT_OverrideCursor wc;
202 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
205 bool isEmpty = false;
206 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
207 QString filename = *it;
208 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
210 switch ( theCommandID ) {
213 // DAT format (currently unsupported)
214 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
215 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
221 aMeshes->length( 1 );
222 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
223 if ( aMeshes[0]->_is_nil() )
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
231 SMESH::DriverMED_ReadStatus res;
232 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
233 if ( res != SMESH::DRS_OK ) {
234 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
235 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
241 catch ( const SALOME::SALOME_Exception& S_ex ) {
242 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
243 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
246 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
247 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
249 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
250 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
251 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
252 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
253 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
255 #ifdef WITHGENERICOBJ
256 // obj has been published in study. Its refcount has been incremented.
257 // It is safe to decrement its refcount
258 // so that it will be destroyed when the entry in study will be removed
259 aMeshes[i]->Destroy();
268 // update Object browser
269 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
271 // show Error message box if there were errors
272 if ( errors.count() > 0 ) {
273 SUIT_MessageBox::critical( SMESHGUI::desktop(),
274 QObject::tr( "SMESH_ERROR" ),
275 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
278 // show warning message box, if some imported mesh is empty
280 SUIT_MessageBox::warning( SMESHGUI::desktop(),
281 QObject::tr( "SMESH_WRN_WARNING" ),
282 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
287 void ExportMeshToFile( int theCommandID )
289 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
290 SALOME_ListIO selected;
292 aSel->selectedObjects( selected );
294 // actually, the following condition can't be met (added for insurance)
295 if( selected.Extent() == 0 ||
296 ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
299 bool hasDuplicatedMeshNames = false;
300 QList< QPair< SMESH::SMESH_Mesh_var, QString > > aMeshList;
301 QList< QPair< SMESH::SMESH_Mesh_var, QString > >::iterator aMeshIter;
302 SALOME_ListIteratorOfListIO It( selected );
303 for( ; It.More(); It.Next() ) {
304 Handle(SALOME_InteractiveObject) anIObject = It.Value();
305 SMESH::SMESH_Mesh_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIObject );
306 if ( aMeshItem->_is_nil() ) {
307 SUIT_MessageBox::warning( SMESHGUI::desktop(),
308 QObject::tr( "SMESH_WRN_WARNING" ),
309 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
313 QString aMeshName = anIObject->getName();
315 // check for duplications
316 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
317 if( aMeshName == (*aMeshIter).second ) {
318 hasDuplicatedMeshNames = true;
323 aMeshList.append( QPair< SMESH::SMESH_Mesh_var, QString >( aMeshItem, aMeshName ) );
326 if( hasDuplicatedMeshNames ) {
327 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
328 QObject::tr("SMESH_WRN_WARNING"),
329 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
330 QObject::tr("SMESH_BUT_YES"),
331 QObject::tr("SMESH_BUT_NO"), 0, 1);
336 aMeshIter = aMeshList.begin();
337 SMESH::SMESH_Mesh_var aMesh = (*aMeshIter).first;
338 QString aMeshName = (*aMeshIter).second;
340 QList<SALOMEDS::Color> aReservedColors;
342 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
343 QMap<QString, SMESH::MED_VERSION> aFilterMap;
344 QMap<QString, int> aFilterMapSTL;
345 switch ( theCommandID ) {
349 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
350 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
351 if (aMeshItem->HasDuplicatedGroupNamesMED()) {
352 int aRet = SUIT_MessageBox::warning
353 (SMESHGUI::desktop(),
354 QObject::tr("SMESH_WRN_WARNING"),
355 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
356 QObject::tr("SMESH_BUT_YES"),
357 QObject::tr("SMESH_BUT_NO"), 0, 1);
363 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
364 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
365 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
366 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
371 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
376 if (aMesh->NbPyramids()) {
377 int aRet = SUIT_MessageBox::warning
378 (SMESHGUI::desktop(),
379 QObject::tr("SMESH_WRN_WARNING"),
380 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
381 QObject::tr("SMESH_BUT_YES"),
382 QObject::tr("SMESH_BUT_NO"), 0, 1);
386 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
394 there must be check on others mesh elements not equal triangles
396 if (aMesh->NbTriangles() < 1) {
397 SUIT_MessageBox::warning
398 (SMESHGUI::desktop(),
399 QObject::tr("SMESH_WRN_WARNING"),
400 QObject::tr("SMESH_EXPORT_STL1").arg(aMeshName));
403 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
404 int aRet = SUIT_MessageBox::warning
405 (SMESHGUI::desktop(),
406 QObject::tr("SMESH_WRN_WARNING"),
407 QObject::tr("SMESH_EXPORT_STL2").arg(aMeshName),
408 QObject::tr("SMESH_BUT_YES"),
409 QObject::tr("SMESH_BUT_NO"), 0, 1);
414 aFilterMapSTL.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); // 1 - ASCII mode
415 aFilterMapSTL.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); // 0 - Binary mode
423 SMESH::MED_VERSION aFormat;
424 // Init the parameter with the default value
425 bool aIsASCII_STL = true;
426 bool toCreateGroups = false;
427 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
429 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
430 bool toOverwrite = true;
432 QString anInitialPath = "";
433 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
434 anInitialPath = QDir::currentPath();
436 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
437 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
438 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
439 aFilter, aTitle, false);
441 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
443 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
444 for ( ; it != aFilterMapSTL.end(); ++it )
445 filters.push_back( it.key() );
447 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
448 fd->setWindowTitle( aTitle );
449 fd->setNameFilters( filters );
450 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
451 if ( !anInitialPath.isEmpty() )
452 fd->setDirectory( anInitialPath );
453 fd->selectFile(aMeshName);
457 aFilename = fd->selectedFile();
458 aIsASCII_STL = (aFilterMapSTL[fd->selectedNameFilter()]) == 1 ? true: false;
463 else { // Export to MED
465 QString aDefaultFilter;
466 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
467 for ( ; it != aFilterMap.end(); ++it ) {
468 filters.push_back( it.key() );
469 if (it.value() == SMESH::MED_V2_2)
470 aDefaultFilter = it.key();
473 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
474 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
475 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
476 fd->setWindowTitle( aTitle );
477 fd->setNameFilters( filters );
478 //fd->setSelectedNameFilter( QObject::tr("MED 2.2 (*.med)") );
479 fd->selectNameFilter(aDefaultFilter);
480 fd->SetChecked(toCreateGroups);
481 if ( !anInitialPath.isEmpty() )
482 fd->setDirectory( anInitialPath );
483 fd->selectFile(aMeshName);
485 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
486 fd->setValidator( fv );
491 aFilename = fd->selectedFile();
493 aFilename = QString::null;
496 aFormat = aFilterMap[fd->selectedNameFilter()];
497 toOverwrite = fv->isOverwrite();
499 if ( !aFilename.isEmpty() ) {
500 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
501 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
502 if( (aMeshItem->NbPolygons()>0 || aMeshItem->NbPolyhedrons()>0)
503 && aFormat==SMESH::MED_V2_1) {
504 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
505 QObject::tr("SMESH_WRN_WARNING"),
506 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
507 QObject::tr("SMESH_BUT_YES"),
508 QObject::tr("SMESH_BUT_NO"), 0, 1);
516 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
517 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
518 if( !isVersionOk || aVersion != aFormat ) {
519 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
520 QObject::tr("SMESH_WRN_WARNING"),
521 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
522 QObject::tr("SMESH_BUT_YES"),
523 QObject::tr("SMESH_BUT_NO"), 0, 1);
530 QStringList aMeshNamesCollisionList;
531 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
532 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
533 QString anExistingMeshName( aMeshNames[ i ] );
534 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
535 QString anExportMeshName = (*aMeshIter).second;
536 if( anExportMeshName == anExistingMeshName ) {
537 aMeshNamesCollisionList.append( anExportMeshName );
543 if( !aMeshNamesCollisionList.isEmpty() ) {
544 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
545 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
546 QObject::tr("SMESH_WRN_WARNING"),
547 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
548 QObject::tr("SMESH_BUT_YES"),
549 QObject::tr("SMESH_BUT_NO"),
550 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
559 toCreateGroups = fd->IsChecked();
562 if ( !aFilename.isEmpty() ) {
563 // Check whether the file already exists and delete it if yes
564 QFile aFile( aFilename );
565 if ( aFile.exists() && toOverwrite )
567 SUIT_OverrideCursor wc;
570 bool Renumber = false;
571 // PAL 14172 : Check of we have to renumber or not from the preferences before export
573 Renumber= resMgr->booleanValue("SMESH","renumbering");
575 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
576 aMeshEditor->RenumberNodes();
577 aMeshEditor->RenumberElements();
578 if ( SMESHGUI::automaticUpdate() )
581 switch ( theCommandID ) {
585 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) {
586 SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
587 if( !aMeshItem->_is_nil() )
588 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0 );
594 aMesh->ExportDAT( aFilename.toLatin1().data() );
598 aMesh->ExportUNV( aFilename.toLatin1().data() );
602 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
608 catch (const SALOME::SALOME_Exception& S_ex){
610 SUIT_MessageBox::warning(SMESHGUI::desktop(),
611 QObject::tr("SMESH_WRN_WARNING"),
612 QObject::tr("SMESH_EXPORT_FAILED"));
618 inline void InverseEntityMode(unsigned int& theOutputMode,
619 unsigned int theMode)
621 bool anIsNotPresent = ~theOutputMode & theMode;
623 theOutputMode |= theMode;
625 theOutputMode &= ~theMode;
628 void SetDisplayEntity(int theCommandID){
629 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
630 SALOME_ListIO selected;
632 aSel->selectedObjects( selected );
634 if(selected.Extent() >= 1){
635 SALOME_ListIteratorOfListIO It( selected );
636 for( ; It.More(); It.Next()){
637 Handle(SALOME_InteractiveObject) IObject = It.Value();
638 if(IObject->hasEntry()){
639 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
640 unsigned int aMode = anActor->GetEntityMode();
641 switch(theCommandID){
643 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
646 InverseEntityMode(aMode,SMESH_Actor::eEdges);
649 InverseEntityMode(aMode,SMESH_Actor::eFaces);
652 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
655 aMode = SMESH_Actor::eAllEntity;
659 anActor->SetEntityMode(aMode);
667 SALOME_ListIO selected;
668 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
672 LightApp_SelectionMgr* aSel = app->selectionMgr();
673 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
674 if( !aSel || !appStudy )
677 aSel->selectedObjects( selected );
678 if( selected.IsEmpty() )
681 Handle(SALOME_InteractiveObject) anIObject = selected.First();
683 _PTR(Study) aStudy = appStudy->studyDS();
684 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
685 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
686 if( aMainObject->_is_nil() )
689 aMainObject->SetAutoColor( true );
691 QList<SALOMEDS::Color> aReservedColors;
693 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
694 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
696 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
697 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
699 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
700 aGroupObject->SetColor( aColor );
701 aReservedColors.append( aColor );
703 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
705 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
706 if( aGroupObject->GetType() == SMESH::NODE )
707 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
708 else if( aGroupObject->GetType() == SMESH::EDGE )
709 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
710 else if( aGroupObject->GetType() == SMESH::ELEM0D )
711 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
713 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
718 SMESH::RepaintCurrentView();
721 QString functorToString( SMESH::Controls::FunctorPtr f )
723 QString type = QObject::tr( "UNKNOWN_CONTROL" );
724 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
725 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
726 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
727 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
728 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
729 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
730 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
731 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
732 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
733 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
734 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
735 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
736 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
737 type = QObject::tr( "WARP_ELEMENTS" );
738 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
739 type = QObject::tr( "TAPER_ELEMENTS" );
740 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
741 type = QObject::tr( "SKEW_ELEMENTS" );
742 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
743 type = QObject::tr( "AREA_ELEMENTS" );
744 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
745 type = QObject::tr( "LENGTH_EDGES" );
746 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
747 type = QObject::tr( "LENGTH2D_EDGES" );
748 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
749 type = QObject::tr( "MULTI_BORDERS" );
750 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
751 type = QObject::tr( "MULTI2D_BORDERS" );
752 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
753 type = QObject::tr( "FREE_NODES" );
754 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
755 type = QObject::tr( "FREE_EDGES" );
756 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
757 type = QObject::tr( "FREE_BORDERS" );
758 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
759 type = QObject::tr( "FREE_FACES" );
760 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
761 type = QObject::tr( "BARE_BORDER_VOLUME" );
762 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
763 type = QObject::tr( "BARE_BORDER_FACE" );
767 void SaveDistribution()
769 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
770 SALOME_ListIO selected;
772 aSel->selectedObjects( selected );
774 if ( selected.Extent() == 1 ) {
775 Handle(SALOME_InteractiveObject) anIO = selected.First();
776 if ( anIO->hasEntry() ) {
777 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
778 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
779 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
780 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
781 if ( aScalarBarActor && aFunctor ) {
782 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
784 int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
785 std::vector<int> nbEvents;
786 std::vector<double> funValues;
787 aNumFun->GetHistogram( nbRanges, nbEvents, funValues );
788 QString anInitialPath = "";
789 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
790 anInitialPath = QDir::currentPath();
791 QString aMeshName = anIO->getName();
793 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
794 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
795 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
796 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
797 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
800 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
802 if ( !aFilename.isEmpty() ) {
803 QFile f( aFilename );
804 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
805 QTextStream out( &f );
806 out << "# Mesh: " << aMeshName << endl;
807 out << "# Control: " << functorToString( aFunctor ) << endl;
809 out.setFieldWidth( 10 );
810 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
811 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
822 void ShowDistribution() {
823 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
824 SALOME_ListIO selected;
826 aSel->selectedObjects( selected );
828 if ( selected.Extent() == 1 ) {
829 Handle(SALOME_InteractiveObject) anIO = selected.First();
830 if ( anIO->hasEntry() ) {
831 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
832 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
833 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
834 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
840 void DisableAutoColor(){
841 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
842 SALOME_ListIO selected;
844 aSel->selectedObjects( selected );
846 if(selected.Extent()){
847 Handle(SALOME_InteractiveObject) anIObject = selected.First();
848 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
849 if ( !aMesh->_is_nil() ) {
850 aMesh->SetAutoColor( false );
855 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
856 SALOME_ListIO selected;
857 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
861 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
862 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
863 if( !aSel || !appStudy )
866 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
867 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
868 aModule->EmitSignalDeactivateDialog();
869 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
870 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
875 _PTR(Study) aStudy = appStudy->studyDS();
877 aSel->selectedObjects( selected );
879 if(selected.Extent() >= 1){
880 switch(theCommandID){
882 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
883 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
887 QColor c, e, b, n, c0D, o;
890 vtkFloatingPointType Shrink = 0.0;
891 vtkFloatingPointType faces_orientation_scale = 0.0;
892 bool faces_orientation_3dvectors = false;
894 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
895 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
896 int aMarkerTextureCurrent = 0;
898 SALOME_ListIteratorOfListIO It( selected );
899 for( ; It.More(); It.Next()){
900 Handle(SALOME_InteractiveObject) IObject = It.Value();
901 if(IObject->hasEntry()){
902 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
903 vtkFloatingPointType color[3];
904 anActor->GetSufaceColor(color[0], color[1], color[2]);
905 int c0 = int (color[0] * 255);
906 int c1 = int (color[1] * 255);
907 int c2 = int (color[2] * 255);
908 c.setRgb(c0, c1, c2);
910 vtkFloatingPointType edgecolor[3];
911 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
912 c0 = int (edgecolor[0] * 255);
913 c1 = int (edgecolor[1] * 255);
914 c2 = int (edgecolor[2] * 255);
915 e.setRgb(c0, c1, c2);
917 vtkFloatingPointType backfacecolor[3];
918 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
919 c0 = int (backfacecolor[0] * 255);
920 c1 = int (backfacecolor[1] * 255);
921 c2 = int (backfacecolor[2] * 255);
922 b.setRgb(c0, c1, c2);
924 vtkFloatingPointType nodecolor[3];
925 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
926 c0 = int (nodecolor[0] * 255);
927 c1 = int (nodecolor[1] * 255);
928 c2 = int (nodecolor[2] * 255);
929 n.setRgb(c0, c1, c2);
931 vtkFloatingPointType color0D[3];
932 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
933 c0 = int (color0D[0] * 255);
934 c1 = int (color0D[1] * 255);
935 c2 = int (color0D[2] * 255);
936 c0D.setRgb(c0, c1, c2);
938 size0D = (int)anActor->Get0DSize();
941 Edgewidth = (int)anActor->GetLineWidth();
944 Shrink = anActor->GetShrinkFactor();
946 vtkFloatingPointType faces_orientation_color[3];
947 anActor->GetFacesOrientationColor(faces_orientation_color);
948 c0 = int (faces_orientation_color[0] * 255);
949 c1 = int (faces_orientation_color[1] * 255);
950 c2 = int (faces_orientation_color[2] * 255);
951 o.setRgb(c0, c1, c2);
953 faces_orientation_scale = anActor->GetFacesOrientationScale();
954 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
956 aMarkerTypeCurrent = anActor->GetMarkerType();
957 aMarkerScaleCurrent = anActor->GetMarkerScale();
958 aMarkerTextureCurrent = anActor->GetMarkerTexture();
960 // even if there are multiple objects in the selection,
961 // we need only the first one to get values for the dialog
967 SMESHGUI_Preferences_ColorDlg *aDlg =
968 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
969 aDlg->SetColor(1, c);
970 aDlg->SetColor(2, e);
971 aDlg->SetColor(3, n);
972 aDlg->SetColor(4, b);
973 aDlg->SetColor(5, c0D);
974 aDlg->SetColor(6, o);
975 aDlg->SetIntValue(1, Edgewidth);
976 aDlg->SetIntValue(2, int(Shrink*100.));
977 aDlg->SetIntValue(3, size0D);
978 aDlg->SetDoubleValue(1, faces_orientation_scale);
979 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
981 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
983 if( aMarkerTypeCurrent != VTK::MT_USER )
984 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
986 aDlg->setCustomMarker( aMarkerTextureCurrent );
989 QColor color = aDlg->GetColor(1);
990 QColor edgecolor = aDlg->GetColor(2);
991 QColor nodecolor = aDlg->GetColor(3);
992 QColor backfacecolor = aDlg->GetColor(4);
993 QColor color0D = aDlg->GetColor(5);
994 QColor faces_orientation_color = aDlg->GetColor(6);
997 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
999 SALOME_ListIteratorOfListIO It( selected );
1000 for( ; It.More(); It.Next()){
1001 Handle(SALOME_InteractiveObject) IObject = It.Value();
1002 if(IObject->hasEntry()){
1003 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1004 /* actor color and backface color */
1005 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1006 vtkFloatingPointType (color.green()) / 255.,
1007 vtkFloatingPointType (color.blue()) / 255.);
1008 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1009 vtkFloatingPointType (backfacecolor.green()) / 255.,
1010 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1013 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1014 vtkFloatingPointType (edgecolor.green()) / 255.,
1015 vtkFloatingPointType (edgecolor.blue()) / 255.);
1017 /* Shrink factor and size edges */
1018 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1019 anActor->SetLineWidth(aDlg->GetIntValue(1));
1021 /* Nodes color and size */
1022 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1023 vtkFloatingPointType (nodecolor.green()) / 255.,
1024 vtkFloatingPointType (nodecolor.blue()) / 255.);
1027 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1028 vtkFloatingPointType (color0D.green()) / 255.,
1029 vtkFloatingPointType (color0D.blue()) / 255.);
1030 anActor->Set0DSize(aDlg->GetIntValue(3));
1032 /* Faces orientation */
1033 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1034 vtkFloatingPointType(faces_orientation_color.greenF()),
1035 vtkFloatingPointType(faces_orientation_color.blueF())};
1036 anActor->SetFacesOrientationColor(c);
1037 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1038 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1040 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1041 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1042 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1043 if( aMarkerTypeNew != VTK::MT_USER )
1044 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1046 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1047 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1048 if( anIter != aMarkerMap.end() )
1049 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1052 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1053 if( !aGroupObject->_is_nil() )
1055 SMESH::ElementType anElementType = aGroupObject->GetType();
1057 switch( anElementType )
1059 case SMESH::NODE: aColor = nodecolor; break;
1060 case SMESH::EDGE: aColor = edgecolor; break;
1061 default: aColor = color; break;
1064 SALOMEDS::Color aGroupColor;
1065 aGroupColor.R = (float)aColor.red() / 255.0;
1066 aGroupColor.G = (float)aColor.green() / 255.0;
1067 aGroupColor.B = (float)aColor.blue() / 255.0;
1068 aGroupObject->SetColor( aGroupColor );
1073 SMESH::RepaintCurrentView();
1079 SALOME_ListIteratorOfListIO It( selected );
1080 for( ; It.More(); It.Next()){
1081 Handle(SALOME_InteractiveObject) IObject = It.Value();
1082 if(IObject->hasEntry()){
1083 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1084 switch(theCommandID){
1086 anActor->SetRepresentation(SMESH_Actor::eEdge);
1089 anActor->SetRepresentation(SMESH_Actor::eSurface);
1092 if(anActor->IsShrunk())
1093 anActor->UnShrink();
1095 anActor->SetShrink();
1098 anActor->SetRepresentation(SMESH_Actor::ePoint);
1101 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1102 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1105 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1106 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1112 SMESH::RepaintCurrentView();
1116 void Control( int theCommandID )
1118 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1119 SALOME_ListIO selected;
1121 aSel->selectedObjects( selected );
1123 if( !selected.IsEmpty() ){
1124 Handle(SALOME_InteractiveObject) anIO = selected.First();
1126 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1127 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1128 switch ( theCommandID ){
1130 aControl = SMESH_Actor::eLength;
1133 aControl = SMESH_Actor::eLength2D;
1136 aControl = SMESH_Actor::eFreeEdges;
1139 aControl = SMESH_Actor::eFreeBorders;
1142 aControl = SMESH_Actor::eMultiConnection;
1145 aControl = SMESH_Actor::eFreeNodes;
1148 aControl = SMESH_Actor::eMultiConnection2D;
1151 aControl = SMESH_Actor::eArea;
1154 aControl = SMESH_Actor::eTaper;
1157 aControl = SMESH_Actor::eAspectRatio;
1160 aControl = SMESH_Actor::eAspectRatio3D;
1163 aControl = SMESH_Actor::eMinimumAngle;
1166 aControl = SMESH_Actor::eWarping;
1169 aControl = SMESH_Actor::eSkew;
1172 aControl = SMESH_Actor::eVolume3D;
1175 aControl = SMESH_Actor::eFreeFaces;
1178 aControl = SMESH_Actor::eMaxElementLength2D;
1181 aControl = SMESH_Actor::eMaxElementLength3D;
1184 aControl = SMESH_Actor::eBareBorderVolume;
1187 aControl = SMESH_Actor::eBareBorderFace;
1190 anActor->SetControlMode(aControl);
1191 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1192 SMESH::RepaintCurrentView();
1199 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1200 MeshObjectType theType,
1201 const QString theInTypeName,
1202 QString & theOutTypeName)
1204 SMESH_TypeFilter aTypeFilter( theType );
1206 if( !theIO.IsNull() )
1208 entry = theIO->getEntry();
1209 LightApp_DataOwner owner( entry );
1210 if ( aTypeFilter.isOk( &owner )) {
1211 theOutTypeName = theInTypeName;
1219 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1221 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1222 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1224 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1225 CORBA::String_var anID = aSComp->GetID().c_str();
1226 if (!strcmp(anID.in(),theIO->getEntry()))
1232 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1233 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1234 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1235 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1236 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1244 QString CheckHomogeneousSelection()
1246 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 QString RefType = CheckTypeObject(selected.First());
1253 SALOME_ListIteratorOfListIO It(selected);
1254 for ( ; It.More(); It.Next())
1256 Handle(SALOME_InteractiveObject) IObject = It.Value();
1257 QString Type = CheckTypeObject(IObject);
1258 if (Type.compare(RefType) != 0)
1259 return "Heterogeneous Selection";
1266 void SMESHGUI::OnEditDelete()
1268 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1269 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1270 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1272 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1273 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1274 _PTR(GenericAttribute) anAttr;
1275 _PTR(AttributeIOR) anIOR;
1277 int objectCount = 0;
1279 QString aParentComponent = QString::null;
1280 Handle(SALOME_InteractiveObject) anIO;
1281 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1283 anIO = anIt.Value();
1284 QString cur = anIO->getComponentDataType();
1285 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1287 // check if object is reference
1288 _PTR(SObject) aRefSObj;
1289 aNameList.append("\n - ");
1290 if ( aSO->ReferencedObject( aRefSObj ) ) {
1291 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1292 aNameList.append( aRefName );
1293 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1296 aNameList.append(anIO->getName());
1300 if( aParentComponent.isNull() )
1301 aParentComponent = cur;
1302 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1303 aParentComponent = "";
1306 if ( objectCount == 0 )
1307 return; // No Valid Objects Selected
1309 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1310 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1311 QObject::tr("ERR_ERROR"),
1312 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1315 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1316 if (SUIT_MessageBox::warning
1317 (SMESHGUI::desktop(),
1318 QObject::tr("SMESH_WRN_WARNING"),
1319 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1320 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1321 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1324 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1325 SUIT_ViewManager* vm = anApp->activeViewManager();
1326 int nbSf = vm->getViewsCount();
1328 SALOME_ListIteratorOfListIO It(selected);
1330 aStudyBuilder->NewCommand(); // There is a transaction
1331 for( ; It.More(); It.Next()){ // loop on selected IO's
1332 Handle(SALOME_InteractiveObject) IObject = It.Value();
1333 if(IObject->hasEntry()) {
1334 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1336 // disable removal of "SMESH" component object
1337 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1339 if ( engineIOR() == anIOR->Value().c_str() )
1342 //Check the referenced object
1343 _PTR(SObject) aRefSObject;
1344 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1345 aSO = aRefSObject; // Delete main Object instead of reference
1347 // put the whole hierarchy of sub-objects of the selected SO into a list and
1348 // then treat them all starting from the deepest objects (at list back)
1350 std::list< _PTR(SObject) > listSO;
1351 listSO.push_back( aSO );
1352 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1353 for ( ; itSO != listSO.end(); ++itSO ) {
1354 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1355 for (it->InitEx(false); it->More(); it->Next())
1356 listSO.push_back( it->Value() );
1359 // treat SO's in the list starting from the back
1361 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1362 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1363 _PTR(SObject) SO = *ritSO;
1364 if ( !SO ) continue;
1365 std::string anEntry = SO->GetID();
1367 /** Erase graphical object **/
1368 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1369 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1370 for(int i = 0; i < nbSf; i++){
1371 SUIT_ViewWindow *sf = aViews[i];
1372 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1373 SMESH::RemoveActor(sf,anActor);
1378 /** Remove an object from data structures **/
1379 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1380 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1381 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1382 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1383 aMesh->RemoveGroup( aGroup );
1385 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1386 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1387 aMesh->RemoveSubMesh( aSubMesh );
1389 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1391 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1394 IObject = new SALOME_InteractiveObject
1395 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1396 QString objType = CheckTypeObject(IObject);
1397 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1398 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1399 aStudyBuilder->RemoveObjectWithChildren( SO );
1401 else {// default action: remove SObject from the study
1402 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1403 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1405 aStudyBuilder->RemoveObjectWithChildren( SO );
1409 } /* listSO back loop */
1410 } /* IObject->hasEntry() */
1412 aStudyBuilder->CommitCommand();
1414 /* Clear any previous selection */
1416 aSel->setSelectedObjects( l1 );
1418 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1423 SMESHGUI_EXPORT CAM_Module* createModule()
1425 return new SMESHGUI();
1429 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1431 //=============================================================================
1435 //=============================================================================
1436 SMESHGUI::SMESHGUI() :
1437 SalomeApp_Module( "SMESH" ),
1438 LightApp_Module( "SMESH" )
1440 if ( CORBA::is_nil( myComponentSMESH ) )
1442 CORBA::Boolean anIsEmbeddedMode;
1443 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1445 // 0019923: EDF 765 SMESH : default values of hypothesis
1446 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1447 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1448 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1449 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1450 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1453 myActiveDialogBox = 0;
1454 myFilterLibraryDlg = 0;
1458 myEventCallbackCommand = vtkCallbackCommand::New();
1459 myEventCallbackCommand->Delete();
1460 myEventCallbackCommand->SetClientData( this );
1461 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1464 SMESH::GetFilterManager();
1465 SMESH::GetPattern();
1466 SMESH::GetMeasurements();
1468 /* load resources for all available meshers */
1469 SMESH::InitAvailableHypotheses();
1472 //=============================================================================
1476 //=============================================================================
1477 SMESHGUI::~SMESHGUI()
1479 #ifdef WITHGENERICOBJ
1480 SMESH::GetFilterManager()->Destroy();
1481 SMESH::GetMeasurements()->Destroy();
1483 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1484 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1487 //=============================================================================
1491 //=============================================================================
1492 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1494 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1496 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1501 bool SMESHGUI::automaticUpdate()
1503 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1507 return resMgr->booleanValue( "SMESH", "auto_update", false );
1510 //=============================================================================
1514 //=============================================================================
1515 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1517 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1520 //=============================================================================
1524 //=============================================================================
1525 SMESHGUI* SMESHGUI::GetSMESHGUI()
1527 SMESHGUI* smeshMod = 0;
1528 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1531 CAM_Module* module = app->module( "Mesh" );
1532 smeshMod = dynamic_cast<SMESHGUI*>( module );
1535 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1537 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1540 _PTR(Study) aStudy = study->studyDS();
1542 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1551 Standard_EXPORT SMESHGUI* GetComponentGUI()
1553 return SMESHGUI::GetSMESHGUI();
1557 //=============================================================================
1561 //=============================================================================
1562 void SMESHGUI::SetState(int aState)
1567 //=============================================================================
1571 //=============================================================================
1572 void SMESHGUI::ResetState()
1577 //=============================================================================
1581 //=============================================================================
1582 void SMESHGUI::EmitSignalDeactivateDialog()
1584 emit SignalDeactivateActiveDialog();
1587 //=============================================================================
1591 //=============================================================================
1592 void SMESHGUI::EmitSignalStudyFrameChanged()
1594 emit SignalStudyFrameChanged();
1597 //=============================================================================
1601 //=============================================================================
1602 void SMESHGUI::EmitSignalCloseAllDialogs()
1604 emit SignalCloseAllDialogs();
1607 //=============================================================================
1611 //=============================================================================
1612 void SMESHGUI::EmitSignalVisibilityChanged()
1614 emit SignalVisibilityChanged();
1617 //=============================================================================
1621 //=============================================================================
1622 QDialog *SMESHGUI::GetActiveDialogBox()
1624 return myActiveDialogBox;
1627 //=============================================================================
1631 //=============================================================================
1632 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1634 myActiveDialogBox = (QDialog *) aDlg;
1638 //=============================================================================
1642 //=============================================================================
1643 SUIT_Desktop* SMESHGUI::desktop()
1645 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1647 return app->desktop();
1652 //=============================================================================
1656 //=============================================================================
1657 SalomeApp_Study* SMESHGUI::activeStudy()
1659 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1661 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1666 //=============================================================================
1670 //=============================================================================
1671 void SMESHGUI::Modified( bool theIsUpdateActions )
1673 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1674 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1675 appStudy->Modified();
1676 if( theIsUpdateActions )
1677 app->updateActions();
1682 //=============================================================================
1686 //=============================================================================
1687 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1689 /* Here the position is on the bottom right corner - 10 */
1690 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1692 SUIT_Desktop *PP = desktop();
1693 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1694 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1698 //=============================================================================
1702 //=============================================================================
1703 static int isStudyLocked(_PTR(Study) theStudy){
1704 return theStudy->GetProperties()->IsLocked();
1707 static bool checkLock(_PTR(Study) theStudy) {
1708 if (isStudyLocked(theStudy)) {
1709 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1710 QObject::tr("WRN_WARNING"),
1711 QObject::tr("WRN_STUDY_LOCKED") );
1717 //=======================================================================
1718 //function : CheckActiveStudyLocked
1720 //=======================================================================
1722 bool SMESHGUI::isActiveStudyLocked()
1724 _PTR(Study) aStudy = activeStudy()->studyDS();
1725 return checkLock( aStudy );
1728 //=============================================================================
1732 //=============================================================================
1733 bool SMESHGUI::OnGUIEvent( int theCommandID )
1735 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1739 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1740 SUIT_ResourceMgr* mgr = resourceMgr();
1744 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1745 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1748 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1749 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1751 //QAction* act = action( theCommandID );
1753 switch (theCommandID) {
1755 if(checkLock(aStudy)) break;
1763 if(checkLock(aStudy)) break;
1764 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1768 case 150: //MED FILE INFORMATION
1770 SALOME_ListIO selected;
1771 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1773 aSel->selectedObjects( selected );
1774 if( selected.Extent() )
1776 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1777 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1778 if ( !aMesh->_is_nil() )
1780 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1787 case 122: // EXPORT MED
1796 ::ExportMeshToFile(theCommandID);
1800 case 200: // SCALAR BAR
1802 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1803 SALOME_ListIO selected;
1805 aSel->selectedObjects( selected );
1807 if( selected.Extent() ) {
1808 Handle(SALOME_InteractiveObject) anIO = selected.First();
1809 if( anIO->hasEntry() ) {
1810 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1811 anActor->SetControlMode( SMESH_Actor::eNone );
1819 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1824 // dump control distribution data to the text file
1825 ::SaveDistribution();
1831 // show/ distribution
1832 ::ShowDistribution();
1842 ::DisableAutoColor();
1845 case 1134: // Clipping
1846 case 1133: // Tranparency
1847 case 1132: // Colors / Size
1854 ::SetDisplayMode(theCommandID, myMarkerMap);
1857 //2D quadratic representation
1860 ::SetDisplayMode(theCommandID, myMarkerMap);
1864 case 216: // 0D elements
1867 case 219: // Volumes
1868 case 220: // All Entity
1869 ::SetDisplayEntity(theCommandID);
1872 case 221: // Orientation of faces
1874 LightApp_SelectionMgr* mgr = selectionMgr();
1875 SALOME_ListIO selected; mgr->selectedObjects( selected );
1877 SALOME_ListIteratorOfListIO it(selected);
1878 for( ; it.More(); it.Next()) {
1879 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1880 if(anIObject->hasEntry()) {
1881 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1882 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1891 if(checkLock(aStudy)) break;
1893 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1896 SMESH::UpdateView();
1898 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1899 SMESH::OnVisuException();
1901 catch (...) { // PAL16774 (Crash after display of many groups)
1902 SMESH::OnVisuException();
1906 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1907 aSel->selectedObjects( l );
1908 aSel->setSelectedObjects( l );
1913 case 301: // DISPLAY
1914 case 302: // DISPLAY ONLY
1916 SMESH::EDisplaing anAction;
1917 switch (theCommandID) {
1918 case 300: anAction = SMESH::eErase; break;
1919 case 301: anAction = SMESH::eDisplay; break;
1920 case 302: anAction = SMESH::eDisplayOnly; break;
1923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1924 SALOME_ListIO sel_objects, to_process;
1926 aSel->selectedObjects( sel_objects );
1928 if( theCommandID==302 )
1929 startOperation( myEraseAll );
1931 extractContainers( sel_objects, to_process );
1934 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1938 SALOME_ListIteratorOfListIO It( to_process );
1939 for ( ; It.More(); It.Next()) {
1940 Handle(SALOME_InteractiveObject) IOS = It.Value();
1941 if (IOS->hasEntry()) {
1942 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1943 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1944 break; // PAL16774 (Crash after display of many groups)
1946 if (anAction == SMESH::eDisplayOnly)
1947 anAction = SMESH::eDisplay;
1952 // PAL13338 + PAL15161 -->
1953 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1954 SMESH::UpdateView();
1955 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1957 // PAL13338 + PAL15161 <--
1959 catch (...) { // PAL16774 (Crash after display of many groups)
1960 SMESH::OnVisuException();
1963 if (anAction == SMESH::eErase) {
1965 aSel->setSelectedObjects( l1 );
1968 aSel->setSelectedObjects( to_process );
1975 if(checkLock(aStudy)) break;
1978 EmitSignalDeactivateDialog();
1980 ( new SMESHGUI_NodesDlg( this ) )->show();
1983 SUIT_MessageBox::warning(desktop(),
1984 tr("SMESH_WRN_WARNING"),
1985 tr("SMESH_WRN_VIEWER_VTK"));
1990 case 2151: // FILTER
1994 EmitSignalDeactivateDialog();
1995 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2000 case 701: // COMPUTE MESH
2001 case 711: // PRECOMPUTE MESH
2002 case 712: // EVALUATE MESH
2003 case 713: // MESH ORDER
2005 if (checkLock(aStudy)) break;
2006 startOperation( theCommandID );
2010 case 702: // Create mesh
2011 case 703: // Create sub-mesh
2012 case 704: // Edit mesh/sub-mesh
2013 startOperation( theCommandID );
2015 case 710: // Build compound mesh
2017 if (checkLock(aStudy)) break;
2018 EmitSignalDeactivateDialog();
2019 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2023 case 407: // DIAGONAL INVERSION
2024 case 408: // Delete diagonal
2028 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2029 tr( "NOT_A_VTK_VIEWER" ) );
2033 if ( checkLock( aStudy ) )
2036 /*Standard_Boolean aRes;
2037 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2038 if ( aMesh->_is_nil() )
2040 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2041 tr( "SMESH_BAD_SELECTION" ) );
2045 EmitSignalDeactivateDialog();
2046 if ( theCommandID == 407 )
2047 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2049 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2052 case 409: // Change orientation
2053 case 410: // Union of triangles
2054 case 411: // Cutting of quadrangles
2055 case 419: // Splitting volumes into tetrahedra
2059 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2060 tr( "NOT_A_VTK_VIEWER" ) );
2064 if ( checkLock( aStudy ) )
2067 EmitSignalDeactivateDialog();
2068 SMESHGUI_MultiEditDlg* aDlg = NULL;
2069 if ( theCommandID == 409 )
2070 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2071 else if ( theCommandID == 410 )
2072 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2073 else if ( theCommandID == 419 )
2074 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2076 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2081 case 412: // Smoothing
2083 if(checkLock(aStudy)) break;
2085 EmitSignalDeactivateDialog();
2086 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2089 SUIT_MessageBox::warning(desktop(),
2090 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2094 case 413: // Extrusion
2096 if (checkLock(aStudy)) break;
2098 EmitSignalDeactivateDialog();
2099 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2101 SUIT_MessageBox::warning(desktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2106 case 414: // Revolution
2108 if(checkLock(aStudy)) break;
2110 EmitSignalDeactivateDialog();
2111 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2114 SUIT_MessageBox::warning(desktop(),
2115 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2119 case 415: // Pattern mapping
2121 if ( checkLock( aStudy ) )
2125 EmitSignalDeactivateDialog();
2126 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2129 SUIT_MessageBox::warning(desktop(),
2130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2134 case 416: // Extrusion along a path
2136 if (checkLock(aStudy)) break;
2138 EmitSignalDeactivateDialog();
2139 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2141 SUIT_MessageBox::warning(desktop(),
2142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2146 case 417: // Convert mesh to quadratic
2148 startOperation( 417 );
2149 /* if (checkLock(aStudy)) break;
2151 EmitSignalDeactivateDialog();
2152 new SMESHGUI_ConvToQuadDlg();
2154 SUIT_MessageBox::warning(desktop(),
2155 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2159 case 418: // create 2D mesh from 3D
2161 startOperation( 418 );
2164 case 806: // CREATE GEO GROUP
2166 startOperation( 806 );
2169 case 801: // CREATE GROUP
2173 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2174 tr( "NOT_A_VTK_VIEWER" ) );
2178 if(checkLock(aStudy)) break;
2179 EmitSignalDeactivateDialog();
2180 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2182 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2183 SALOME_ListIO selected;
2185 aSel->selectedObjects( selected );
2187 int nbSel = selected.Extent();
2189 // check if mesh is selected
2190 aMesh = SMESH::GetMeshByIO( selected.First() );
2192 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2197 case 802: // CONSTRUCT GROUP
2201 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2202 tr( "NOT_A_VTK_VIEWER" ) );
2206 if(checkLock(aStudy)) break;
2207 EmitSignalDeactivateDialog();
2209 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2210 SALOME_ListIO selected;
2212 aSel->selectedObjects( selected );
2214 int nbSel = selected.Extent();
2216 // check if submesh is selected
2217 Handle(SALOME_InteractiveObject) IObject = selected.First();
2218 if (IObject->hasEntry()) {
2219 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2221 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2222 if (!aSubMesh->_is_nil()) {
2224 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2225 // get submesh elements list by types
2226 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2227 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2228 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2229 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2230 // create group for each type o elements
2231 QString aName = IObject->getName();
2232 if (aNodes->length() > 0) {
2233 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2234 aGroup->Add(aNodes.inout());
2236 if (aEdges->length() > 0) {
2237 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2238 aGroup->Add(aEdges.inout());
2240 if (aFaces->length() > 0) {
2241 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2242 aGroup->Add(aFaces.inout());
2244 if (aVolumes->length() > 0) {
2245 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2246 aGroup->Add(aVolumes.inout());
2251 catch(const SALOME::SALOME_Exception & S_ex){
2252 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2259 SUIT_MessageBox::warning(desktop(),
2260 tr("SMESH_WRN_WARNING"),
2261 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2266 case 803: // EDIT GROUP
2270 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2271 tr( "NOT_A_VTK_VIEWER" ) );
2275 if(checkLock(aStudy)) break;
2276 EmitSignalDeactivateDialog();
2278 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2279 SALOME_ListIO selected;
2281 aSel->selectedObjects( selected );
2283 SALOME_ListIteratorOfListIO It (selected);
2284 int nbSelectedGroups = 0;
2285 for ( ; It.More(); It.Next() )
2287 SMESH::SMESH_GroupBase_var aGroup =
2288 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2289 if (!aGroup->_is_nil()) {
2291 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2295 if (nbSelectedGroups == 0)
2297 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2303 case 804: // Add elements to group
2305 if(checkLock(aStudy)) break;
2306 if (myState == 800) {
2307 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2308 if (aDlg) aDlg->onAdd();
2313 case 805: // Remove elements from group
2315 if(checkLock(aStudy)) break;
2316 if (myState == 800) {
2317 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2318 if (aDlg) aDlg->onRemove();
2323 case 815: // Edit GEOM GROUP as standalone
2327 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2328 tr( "NOT_A_VTK_VIEWER" ) );
2332 if(checkLock(aStudy)) break;
2333 EmitSignalDeactivateDialog();
2335 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2336 SALOME_ListIO selected;
2338 aSel->selectedObjects( selected );
2340 SALOME_ListIteratorOfListIO It (selected);
2341 for ( ; It.More(); It.Next() )
2343 SMESH::SMESH_GroupOnGeom_var aGroup =
2344 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2345 if (!aGroup->_is_nil()) {
2346 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2353 case 810: // Union Groups
2354 case 811: // Intersect groups
2355 case 812: // Cut groups
2359 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2360 tr( "NOT_A_VTK_VIEWER" ) );
2364 if ( checkLock( aStudy ) )
2367 EmitSignalDeactivateDialog();
2369 SMESHGUI_GroupOpDlg* aDlg = 0;
2370 if ( theCommandID == 810 )
2371 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2372 else if ( theCommandID == 811 )
2373 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2375 aDlg = new SMESHGUI_CutGroupsDlg( this );
2382 case 814: // Create groups of entities from existing groups of superior dimensions
2384 if ( checkLock( aStudy ) )
2387 EmitSignalDeactivateDialog();
2388 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2394 case 813: // Delete groups with their contents
2398 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2399 tr( "NOT_A_VTK_VIEWER" ) );
2403 if ( checkLock( aStudy ) )
2406 EmitSignalDeactivateDialog();
2408 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2412 case 900: // MESH INFOS
2413 case 903: // WHAT IS
2415 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2416 EmitSignalDeactivateDialog();
2417 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2418 SALOME_ListIO selected;
2420 aSel->selectedObjects( selected );
2422 if ( selected.Extent() > 1 ) { // a dlg for each IO
2423 SALOME_ListIteratorOfListIO It( selected );
2424 for ( ; It.More(); It.Next() ) {
2425 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2426 dlg->showInfo( It.Value() );
2431 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2437 case 902: // STANDARD MESH INFOS
2439 EmitSignalDeactivateDialog();
2440 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2441 SALOME_ListIO selected;
2443 aSel->selectedObjects( selected );
2445 if ( selected.Extent() > 1 ) { // a dlg for each IO
2447 SALOME_ListIteratorOfListIO It (selected);
2448 for ( ; It.More(); It.Next() ) {
2450 IOs.Append( It.Value() );
2451 aSel->setSelectedObjects( IOs );
2452 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2454 // restore selection
2455 aSel->setSelectedObjects( selected );
2458 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2461 case 903: // WHAT IS
2463 EmitSignalDeactivateDialog();
2464 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2469 case 904: // FIND ELEM
2471 startOperation( theCommandID );
2475 case 1100: // EDIT HYPOTHESIS
2477 if(checkLock(aStudy)) break;
2479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2480 SALOME_ListIO selected;
2482 aSel->selectedObjects( selected );
2484 int nbSel = selected.Extent();
2487 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2488 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2490 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2491 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2492 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2493 if ( !aHypothesis->_is_nil() )
2496 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2497 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2499 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2510 case 1101: // RENAME
2512 if ( checkLock( aStudy ) )
2515 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2516 SALOME_ListIO selected;
2518 aSel->selectedObjects( selected );
2520 bool isAny = false; // is there any appropriate object selected
2522 SALOME_ListIteratorOfListIO It( selected );
2523 for ( ; It.More(); It.Next() )
2525 Handle(SALOME_InteractiveObject) IObject = It.Value();
2526 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2527 _PTR(GenericAttribute) anAttr;
2528 _PTR(AttributeName) aName;
2531 if ( obj->FindAttribute(anAttr, "AttributeName") )
2534 QString newName = QString(aName->Value().c_str());
2536 // check type to prevent renaming of inappropriate objects
2537 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2538 if (aType == MESH || aType == GROUP ||
2539 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2540 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2541 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2542 aType == HYPOTHESIS || aType == ALGORITHM)
2545 newName = LightApp_NameDlg::getName(desktop(), newName);
2546 if ( !newName.isEmpty() )
2548 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2550 // update name of group object and its actor
2551 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2552 if( !aGroupObject->_is_nil() )
2554 aGroupObject->SetName( newName.toLatin1().data() );
2555 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2556 anActor->setName( newName.toLatin1().data() );
2567 SUIT_MessageBox::warning(desktop(),
2568 QObject::tr("SMESH_WRN_WARNING"),
2569 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2574 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2576 if(checkLock(aStudy)) break;
2577 SUIT_OverrideCursor wc;
2579 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2580 SALOME_ListIO selected;
2582 aSel->selectedObjects( selected, QString::null, false );
2584 SALOME_ListIteratorOfListIO It(selected);
2585 for (int i = 0; It.More(); It.Next(), i++) {
2586 Handle(SALOME_InteractiveObject) IObject = It.Value();
2587 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2590 aSel->setSelectedObjects( l1 );
2595 case 4009: // ELEM0D
2596 case 4010: // GEOM::EDGE
2597 case 4021: // TRIANGLE
2599 case 4023: // POLYGON
2603 if(checkLock(aStudy)) break;
2605 EmitSignalDeactivateDialog();
2606 SMDSAbs_ElementType type = SMDSAbs_Edge;
2608 switch (theCommandID) {
2609 case 4009: // ELEM0D
2610 type = SMDSAbs_0DElement; nbNodes = 1; break;
2611 case 4021: // TRIANGLE
2612 type = SMDSAbs_Face; nbNodes = 3; break;
2614 type = SMDSAbs_Face; nbNodes = 4; break;
2616 type = SMDSAbs_Volume; nbNodes = 4; break;
2617 case 4023: // POLYGON
2618 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2620 type = SMDSAbs_Volume; nbNodes = 8; break;
2621 case 4033: // POLYHEDRE
2622 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2625 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2628 SUIT_MessageBox::warning(desktop(),
2629 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2633 case 4033: // POLYHEDRON
2635 if(checkLock(aStudy)) break;
2637 EmitSignalDeactivateDialog();
2638 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2641 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2642 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2646 case 4034: // QUADRATIC EDGE
2647 case 4035: // QUADRATIC TRIANGLE
2648 case 4036: // QUADRATIC QUADRANGLE
2649 case 4037: // QUADRATIC TETRAHEDRON
2650 case 4038: // QUADRATIC PYRAMID
2651 case 4039: // QUADRATIC PENTAHEDRON
2652 case 4040: // QUADRATIC HEXAHEDRON
2654 if(checkLock(aStudy)) break;
2656 EmitSignalDeactivateDialog();
2659 switch (theCommandID) {
2661 type = QUAD_EDGE; break;
2663 type = QUAD_TRIANGLE; break;
2665 type = QUAD_QUADRANGLE; break;
2667 type = QUAD_TETRAHEDRON; break;
2669 type = QUAD_PYRAMID; break;
2671 type = QUAD_PENTAHEDRON; break;
2673 type = QUAD_HEXAHEDRON;
2677 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2680 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2681 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2685 case 4041: // REMOVES NODES
2687 if(checkLock(aStudy)) break;
2689 EmitSignalDeactivateDialog();
2690 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2693 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2694 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2698 case 4042: // REMOVES ELEMENTS
2700 if(checkLock(aStudy)) break;
2702 EmitSignalDeactivateDialog();
2703 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2707 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2708 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2712 case 4043: { // CLEAR_MESH
2714 if(checkLock(aStudy)) break;
2716 SALOME_ListIO selected;
2717 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2718 aSel->selectedObjects( selected );
2720 SUIT_OverrideCursor wc;
2721 SALOME_ListIteratorOfListIO It (selected);
2722 for ( ; It.More(); It.Next() )
2724 Handle(SALOME_InteractiveObject) IOS = It.Value();
2725 SMESH::SMESH_Mesh_var aMesh =
2726 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2727 if ( aMesh->_is_nil()) continue;
2729 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2731 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2732 SMESH::ModifiedMesh( aMeshSObj, false, true);
2733 // hide groups and submeshes
2734 _PTR(ChildIterator) anIter =
2735 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2736 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2738 _PTR(SObject) so = anIter->Value();
2739 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2742 catch (const SALOME::SALOME_Exception& S_ex){
2744 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2748 SMESH::UpdateView();
2752 case 4044: // REMOVE ORPHAN NODES
2754 if(checkLock(aStudy)) break;
2755 SALOME_ListIO selected;
2756 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2757 aSel->selectedObjects( selected );
2758 if ( selected.Extent() == 1 ) {
2759 Handle(SALOME_InteractiveObject) anIO = selected.First();
2760 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2761 if ( !aMesh->_is_nil() ) {
2762 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2763 tr( "SMESH_WARNING" ),
2764 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2765 SUIT_MessageBox::Yes |
2766 SUIT_MessageBox::No,
2767 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2770 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2771 int removed = aMeshEditor->RemoveOrphanNodes();
2772 SUIT_MessageBox::information(SMESHGUI::desktop(),
2773 tr("SMESH_INFORMATION"),
2774 tr("NB_NODES_REMOVED").arg(removed));
2775 if ( removed > 0 ) {
2776 SMESH::UpdateView();
2777 SMESHGUI::Modified();
2780 catch (const SALOME::SALOME_Exception& S_ex) {
2781 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2790 case 4051: // RENUMBERING NODES
2792 if(checkLock(aStudy)) break;
2794 EmitSignalDeactivateDialog();
2795 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2799 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2800 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2804 case 4052: // RENUMBERING ELEMENTS
2806 if(checkLock(aStudy)) break;
2808 EmitSignalDeactivateDialog();
2809 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2813 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2814 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2818 case 4061: // TRANSLATION
2820 if(checkLock(aStudy)) break;
2822 EmitSignalDeactivateDialog();
2823 ( new SMESHGUI_TranslationDlg( this ) )->show();
2826 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2827 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2831 case 4062: // ROTATION
2833 if(checkLock(aStudy)) break;
2835 EmitSignalDeactivateDialog();
2836 ( new SMESHGUI_RotationDlg( this ) )->show();
2839 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2840 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2844 case 4063: // SYMMETRY
2846 if(checkLock(aStudy)) break;
2848 EmitSignalDeactivateDialog();
2849 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2852 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2853 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2857 case 4064: // SEWING
2859 if(checkLock(aStudy)) break;
2861 EmitSignalDeactivateDialog();
2862 ( new SMESHGUI_SewingDlg( this ) )->show();
2865 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2866 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2870 case 4065: // MERGE NODES
2872 if(checkLock(aStudy)) break;
2874 EmitSignalDeactivateDialog();
2875 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2878 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2879 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2883 case 4066: // MERGE EQUAL ELEMENTS
2885 if (checkLock(aStudy)) break;
2887 EmitSignalDeactivateDialog();
2888 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2890 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2891 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2896 case 4067: // MAKE MESH PASS THROUGH POINT
2897 startOperation( 4067 );
2902 if(checkLock(aStudy)) break;
2904 EmitSignalDeactivateDialog();
2905 ( new SMESHGUI_ScaleDlg( this ) )->show();
2908 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2909 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2914 case 4069: // DUPLICATE NODES
2916 if(checkLock(aStudy)) break;
2918 EmitSignalDeactivateDialog();
2919 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2922 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2923 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2928 case 5105: // Library of selection filters
2930 static QList<int> aTypes;
2931 if ( aTypes.isEmpty() )
2933 aTypes.append( SMESH::NODE );
2934 aTypes.append( SMESH::EDGE );
2935 aTypes.append( SMESH::FACE );
2936 aTypes.append( SMESH::VOLUME );
2938 if (!myFilterLibraryDlg)
2939 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2940 else if (myFilterLibraryDlg->isHidden())
2941 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2942 myFilterLibraryDlg->raise();
2946 case 6017: // CONTROLS
2968 LightApp_SelectionMgr* mgr = selectionMgr();
2969 SALOME_ListIO selected; mgr->selectedObjects( selected );
2971 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2972 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2974 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2975 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2976 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2977 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2978 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2979 ::Control( theCommandID );
2984 SUIT_MessageBox::warning(desktop(),
2985 tr( "SMESH_WRN_WARNING" ),
2986 tr( "SMESH_BAD_SELECTION" ) );
2990 SUIT_MessageBox::warning(desktop(),
2991 tr( "SMESH_WRN_WARNING" ),
2992 tr( "NOT_A_VTK_VIEWER" ) );
2997 LightApp_SelectionMgr* mgr = selectionMgr();
2998 SALOME_ListIO selected; mgr->selectedObjects( selected );
3000 SALOME_ListIteratorOfListIO it(selected);
3001 for( ; it.More(); it.Next()) {
3002 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3003 if(anIObject->hasEntry()) {
3004 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3005 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3013 LightApp_SelectionMgr* mgr = selectionMgr();
3014 SALOME_ListIO selected; mgr->selectedObjects( selected );
3016 SALOME_ListIteratorOfListIO it(selected);
3017 for( ; it.More(); it.Next()) {
3018 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3019 if(anIObject->hasEntry())
3020 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3021 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3029 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3030 EmitSignalDeactivateDialog();
3031 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3037 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3038 //updateObjBrowser();
3042 //=============================================================================
3046 //=============================================================================
3047 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3052 //=============================================================================
3056 //=============================================================================
3057 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3062 //=============================================================================
3066 //=============================================================================
3067 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3072 //=============================================================================
3073 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3074 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3076 //=============================================================================
3077 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3078 SUIT_ViewWindow* wnd )
3080 if(theIO->hasEntry()){
3081 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3082 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3086 //=======================================================================
3087 // function : createSMESHAction
3089 //=======================================================================
3090 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3091 const int key, const bool toggle, const QString& shortcutAction )
3094 QWidget* parent = application()->desktop();
3095 SUIT_ResourceMgr* resMgr = resourceMgr();
3097 if ( !icon_id.isEmpty() )
3098 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3100 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3101 if ( !pix.isNull() )
3102 icon = QIcon( pix );
3104 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3105 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3106 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3108 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3109 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3112 //=======================================================================
3113 // function : createPopupItem
3115 //=======================================================================
3116 void SMESHGUI::createPopupItem( const int id,
3117 const QString& clients,
3118 const QString& types,
3119 const QString& theRule,
3124 parentId = popupMgr()->actionId( action( pId ) );
3126 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3127 popupMgr()->insert( action( id ), parentId, 0 );
3129 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3130 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3131 QString rule = "(%1) and (%2) and (%3)";
3132 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3133 if( clients.isEmpty() )
3134 rule = rule.arg( QString( "true" ) );
3136 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3137 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3140 bool cont = myRules.contains( id );
3142 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3144 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3145 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3148 //=======================================================================
3149 // function : initialize
3151 //=======================================================================
3152 void SMESHGUI::initialize( CAM_Application* app )
3154 SalomeApp_Module::initialize( app );
3156 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3158 /* Automatic Update flag */
3159 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3161 // ----- create actions --------------
3163 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3164 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3165 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3166 createSMESHAction( 114, "NUM" );
3167 createSMESHAction( 121, "DAT" );
3168 createSMESHAction( 122, "MED" );
3169 createSMESHAction( 123, "UNV" );
3170 createSMESHAction( 140, "STL" );
3171 createSMESHAction( 124, "EXPORT_DAT" );
3172 createSMESHAction( 125, "EXPORT_MED" );
3173 createSMESHAction( 126, "EXPORT_UNV" );
3174 createSMESHAction( 141, "EXPORT_STL" );
3175 createSMESHAction( 150, "FILE_INFO" );
3176 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3177 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3178 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3179 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3180 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3181 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3182 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3183 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3184 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3185 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3186 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3187 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3188 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3189 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3190 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3191 createSMESHAction( 804, "ADD" );
3192 createSMESHAction( 805, "REMOVE" );
3193 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3194 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3195 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3196 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3197 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3198 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3199 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3200 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3201 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3202 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3203 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3204 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3205 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3206 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3207 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3208 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3209 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3210 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3211 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3212 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3213 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3214 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3215 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3216 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3217 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3218 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3219 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3220 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3221 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3222 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3223 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3224 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3225 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3226 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3227 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3228 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3229 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3230 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3231 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3232 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3233 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3234 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3235 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3236 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3237 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3238 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3239 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3240 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3241 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3242 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3243 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3244 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3245 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3246 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3247 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3248 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3249 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3250 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3251 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3252 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3253 createSMESHAction( 415, "MAP", "ICON_MAP" );
3254 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3255 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3256 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3257 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3258 createSMESHAction( 200, "RESET" );
3259 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3260 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3261 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3262 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3263 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3264 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3265 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3266 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3267 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3268 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3269 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3270 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3271 createSMESHAction( 220, "ALL" );
3272 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3274 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3275 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3277 createSMESHAction( 1100, "EDIT_HYPO" );
3278 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3279 createSMESHAction( 1102, "UNASSIGN" );
3280 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3281 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3282 createSMESHAction( 1131, "DISPMODE" );
3283 createSMESHAction( 1132, "COLORS" );
3284 createSMESHAction( 1133, "TRANSP" );
3285 createSMESHAction( 1134, "CLIP" );
3286 createSMESHAction( 1135, "DISP_ENT" );
3287 createSMESHAction( 1136, "AUTO_COLOR" );
3288 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3289 createSMESHAction( 2000, "CTRL" );
3291 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3292 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3294 createSMESHAction( 300, "ERASE" );
3295 createSMESHAction( 301, "DISPLAY" );
3296 createSMESHAction( 302, "DISPLAY_ONLY" );
3297 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3298 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3299 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3300 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3301 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3302 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3303 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3304 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3306 // ----- create menu --------------
3307 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3308 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3309 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3310 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3311 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3312 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3313 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3314 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3316 createMenu( separator(), fileId );
3318 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3319 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3320 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3321 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3322 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3323 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3324 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3325 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3326 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3327 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3329 createMenu( 111, importId, -1 );
3330 createMenu( 112, importId, -1 );
3331 createMenu( 113, importId, -1 );
3333 createMenu( 121, exportId, -1 );
3334 createMenu( 122, exportId, -1 );
3335 createMenu( 123, exportId, -1 );
3336 createMenu( 140, exportId, -1 ); // export to stl STL
3338 createMenu( separator(), fileId, 10 );
3340 createMenu( 33, editId, -1 );
3342 createMenu( 5105, toolsId, -1 );
3344 createMenu( 702, meshId, -1 ); // "Mesh" menu
3345 createMenu( 703, meshId, -1 );
3346 createMenu( 704, meshId, -1 );
3347 createMenu( 710, meshId, -1 );
3348 createMenu( separator(), meshId, -1 );
3349 createMenu( 701, meshId, -1 );
3350 createMenu( 711, meshId, -1 );
3351 createMenu( 712, meshId, -1 );
3352 createMenu( 713, meshId, -1 );
3353 createMenu( separator(), meshId, -1 );
3354 createMenu( 801, meshId, -1 );
3355 createMenu( 806, meshId, -1 );
3356 createMenu( 802, meshId, -1 );
3357 createMenu( 803, meshId, -1 );
3358 createMenu( 815, meshId, -1 );
3359 createMenu( separator(), meshId, -1 );
3360 createMenu( 810, meshId, -1 );
3361 createMenu( 811, meshId, -1 );
3362 createMenu( 812, meshId, -1 );
3363 createMenu( separator(), meshId, -1 );
3364 createMenu( 814, meshId, -1 );
3365 createMenu( separator(), meshId, -1 );
3366 createMenu( 813, meshId, -1 );
3367 createMenu( separator(), meshId, -1 );
3368 createMenu( 900, meshId, -1 );
3369 //createMenu( 902, meshId, -1 );
3370 createMenu( 903, meshId, -1 );
3371 createMenu( 904, meshId, -1 );
3372 createMenu( separator(), meshId, -1 );
3374 createMenu( 6005, nodeId, -1 );
3375 createMenu( 6002, edgeId, -1 );
3376 createMenu( 6003, edgeId, -1 );
3377 createMenu( 6001, edgeId, -1 );
3378 createMenu( 6004, edgeId, -1 );
3379 createMenu( 6021, faceId, -1 );
3380 createMenu( 6025, faceId, -1 );
3381 createMenu( 6018, faceId, -1 );
3382 createMenu( 6019, faceId, -1 );
3383 createMenu( 6011, faceId, -1 );
3384 createMenu( 6012, faceId, -1 );
3385 createMenu( 6013, faceId, -1 );
3386 createMenu( 6014, faceId, -1 );
3387 createMenu( 6015, faceId, -1 );
3388 createMenu( 6016, faceId, -1 );
3389 createMenu( 6022, faceId, -1 );
3390 createMenu( 6017, volumeId, -1 );
3391 createMenu( 6009, volumeId, -1 );
3392 createMenu( 6023, volumeId, -1 );
3393 createMenu( 6024, volumeId, -1 );
3395 createMenu( 4000, addId, -1 );
3396 createMenu( 4009, addId, -1 );
3397 createMenu( 4010, addId, -1 );
3398 createMenu( 4021, addId, -1 );
3399 createMenu( 4022, addId, -1 );
3400 createMenu( 4023, addId, -1 );
3401 createMenu( 4031, addId, -1 );
3402 createMenu( 4032, addId, -1 );
3403 createMenu( 4033, addId, -1 );
3404 createMenu( separator(), addId, -1 );
3405 createMenu( 4034, addId, -1 );
3406 createMenu( 4035, addId, -1 );
3407 createMenu( 4036, addId, -1 );
3408 createMenu( 4037, addId, -1 );
3409 createMenu( 4038, addId, -1 );
3410 createMenu( 4039, addId, -1 );
3411 createMenu( 4040, addId, -1 );
3413 createMenu( 4041, removeId, -1 );
3414 createMenu( 4042, removeId, -1 );
3415 createMenu( 4044, removeId, -1 );
3416 createMenu( separator(), removeId, -1 );
3417 createMenu( 4043, removeId, -1 );
3419 createMenu( 4051, renumId, -1 );
3420 createMenu( 4052, renumId, -1 );
3422 createMenu( 4061, transfId, -1 );
3423 createMenu( 4062, transfId, -1 );
3424 createMenu( 4063, transfId, -1 );
3425 createMenu( 4064, transfId, -1 );
3426 createMenu( 4065, transfId, -1 );
3427 createMenu( 4066, transfId, -1 );
3428 createMenu( 4068, transfId, -1 );
3429 createMenu( 4069, transfId, -1 );
3431 createMenu( 4067,modifyId, -1 );
3432 createMenu( 407, modifyId, -1 );
3433 createMenu( 408, modifyId, -1 );
3434 createMenu( 409, modifyId, -1 );
3435 createMenu( 410, modifyId, -1 );
3436 createMenu( 411, modifyId, -1 );
3437 createMenu( 419, modifyId, -1 );
3438 createMenu( 412, modifyId, -1 );
3439 createMenu( 413, modifyId, -1 );
3440 createMenu( 416, modifyId, -1 );
3441 createMenu( 414, modifyId, -1 );
3442 createMenu( 415, modifyId, -1 );
3443 createMenu( 417, modifyId, -1 );
3444 createMenu( 418, modifyId, -1 );
3446 createMenu( 501, measureId, -1 );
3447 createMenu( 502, measureId, -1 );
3448 createMenu( 214, viewId, -1 );
3450 // ----- create toolbars --------------
3451 int meshTb = createTool( tr( "TB_MESH" ) ),
3452 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3453 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3454 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3455 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3457 createTool( 702, meshTb );
3458 createTool( 703, meshTb );
3459 createTool( 704, meshTb );
3460 createTool( 710, meshTb );
3461 createTool( separator(), meshTb );
3462 createTool( 701, meshTb );
3463 createTool( 711, meshTb );
3464 createTool( 712, meshTb );
3465 createTool( 713, meshTb );
3466 createTool( separator(), meshTb );
3467 createTool( 801, meshTb );
3468 createTool( 806, meshTb );
3469 createTool( 802, meshTb );
3470 createTool( 803, meshTb );
3471 //createTool( 815, meshTb );
3472 createTool( separator(), meshTb );
3473 createTool( 900, meshTb );
3474 //createTool( 902, meshTb );
3475 createTool( 903, meshTb );
3476 createTool( 904, meshTb );
3477 createTool( separator(), meshTb );
3479 createTool( 6005, ctrlTb );
3480 createTool( separator(), ctrlTb );
3481 createTool( 6002, ctrlTb );
3482 createTool( 6003, ctrlTb );
3483 createTool( 6001, ctrlTb );
3484 createTool( 6004, ctrlTb );
3485 createTool( separator(), ctrlTb );
3486 createTool( 6021, ctrlTb );
3487 createTool( 6025, ctrlTb );
3488 createTool( 6018, ctrlTb );
3489 createTool( 6019, ctrlTb );
3490 createTool( 6011, ctrlTb );
3491 createTool( 6012, ctrlTb );
3492 createTool( 6013, ctrlTb );
3493 createTool( 6014, ctrlTb );
3494 createTool( 6015, ctrlTb );
3495 createTool( 6016, ctrlTb );
3496 createTool( 6022, ctrlTb );
3497 createTool( separator(), ctrlTb );
3498 createTool( 6017, ctrlTb );
3499 createTool( 6009, ctrlTb );
3500 createTool( 6023, ctrlTb );
3501 createTool( 6024, ctrlTb );
3502 createTool( separator(), ctrlTb );
3504 createTool( 4000, addRemTb );
3505 createTool( 4009, addRemTb );
3506 createTool( 4010, addRemTb );
3507 createTool( 4021, addRemTb );
3508 createTool( 4022, addRemTb );
3509 createTool( 4023, addRemTb );
3510 createTool( 4031, addRemTb );
3511 createTool( 4032, addRemTb );
3512 createTool( 4033, addRemTb );
3513 createTool( separator(), addRemTb );
3514 createTool( 4034, addRemTb );
3515 createTool( 4035, addRemTb );
3516 createTool( 4036, addRemTb );
3517 createTool( 4037, addRemTb );
3518 createTool( 4038, addRemTb );
3519 createTool( 4039, addRemTb );
3520 createTool( 4040, addRemTb );
3521 createTool( separator(), addRemTb );
3522 createTool( 4041, addRemTb );
3523 createTool( 4042, addRemTb );
3524 createTool( 4044, addRemTb );
3525 createTool( 4043, addRemTb );
3526 createTool( separator(), addRemTb );
3527 createTool( 4051, addRemTb );
3528 createTool( 4052, addRemTb );
3529 createTool( separator(), addRemTb );
3530 createTool( 4061, addRemTb );
3531 createTool( 4062, addRemTb );
3532 createTool( 4063, addRemTb );
3533 createTool( 4064, addRemTb );
3534 createTool( 4065, addRemTb );
3535 createTool( 4066, addRemTb );
3536 createTool( 4068, addRemTb );
3537 createTool( 4069, addRemTb );
3538 createTool( separator(), addRemTb );
3540 createTool( 4067,modifyTb );
3541 createTool( 407, modifyTb );
3542 createTool( 408, modifyTb );
3543 createTool( 409, modifyTb );
3544 createTool( 410, modifyTb );
3545 createTool( 411, modifyTb );
3546 createTool( 419, modifyTb );
3547 createTool( 412, modifyTb );
3548 createTool( 413, modifyTb );
3549 createTool( 416, modifyTb );
3550 createTool( 414, modifyTb );
3551 createTool( 415, modifyTb );
3552 createTool( 417, modifyTb );
3553 createTool( 418, modifyTb );
3555 createTool( 214, dispModeTb );
3557 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3558 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3561 QString OB = "'ObjectBrowser'",
3562 View = "'" + SVTK_Viewer::Type() + "'",
3564 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3565 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3566 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3567 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3568 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3569 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3570 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3571 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3572 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3573 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3574 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3576 mesh_group = mesh + " " + subMesh + " " + group,
3577 hyp_alg = hypo + " " + algo;
3579 // popup for object browser
3581 isInvisible("not( isVisible )"),
3582 isEmpty("numberOfNodes = 0"),
3583 isNotEmpty("numberOfNodes <> 0"),
3585 // has nodes, edges, etc in VISIBLE! actor
3586 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3587 hasElems("(count( elemTypes ) > 0)"),
3588 hasDifferentElems("(count( elemTypes ) > 1)"),
3589 hasElems0d("({'Elem0d'} in elemTypes)"),
3590 hasEdges("({'Edge'} in elemTypes)"),
3591 hasFaces("({'Face'} in elemTypes)"),
3592 hasVolumes("({'Volume'} in elemTypes)");
3594 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3595 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3596 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3597 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3598 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3599 createPopupItem( 803, OB, group ); // EDIT_GROUP
3600 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3602 popupMgr()->insert( separator(), -1, 0 );
3603 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3604 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3605 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3606 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3607 createPopupItem( 214, OB, mesh_group ); // UPDATE
3608 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3609 //createPopupItem( 902, OB, mesh ); // STD_INFO
3610 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3611 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3612 popupMgr()->insert( separator(), -1, 0 );
3613 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3614 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3615 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3616 popupMgr()->insert( separator(), -1, 0 );
3617 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3618 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3619 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3620 popupMgr()->insert( separator(), -1, 0 );
3621 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3622 popupMgr()->insert( separator(), -1, 0 );
3623 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3624 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3625 popupMgr()->insert( separator(), -1, 0 );
3627 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3628 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3630 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3631 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3632 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3633 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3634 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3635 popupMgr()->insert( separator(), -1, 0 );
3638 createPopupItem( 803, View, group ); // EDIT_GROUP
3639 createPopupItem( 804, View, elems ); // ADD
3640 createPopupItem( 805, View, elems ); // REMOVE
3642 popupMgr()->insert( separator(), -1, 0 );
3643 createPopupItem( 214, View, mesh_group ); // UPDATE
3644 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3645 //createPopupItem( 902, View, mesh ); // STD_INFO
3646 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3647 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3648 popupMgr()->insert( separator(), -1, 0 );
3650 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3651 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3652 popupMgr()->insert( separator(), -1, 0 );
3655 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3656 QString aType = QString( "%1type in {%2}" ).arg( lc );
3657 aType = aType.arg( mesh_group );
3658 QString aMeshInVTK = aClient + "&&" + aType;
3660 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3661 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3662 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3664 //-------------------------------------------------
3666 //-------------------------------------------------
3667 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3669 popupMgr()->insert( action( 9010 ), anId, -1 );
3670 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3671 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3673 popupMgr()->insert( action( 9011 ), anId, -1 );
3674 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3675 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3677 popupMgr()->insert( separator(), -1, -1 );
3679 //-------------------------------------------------
3681 //-------------------------------------------------
3682 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3684 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3685 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3686 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3688 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3689 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3690 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3692 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3693 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3694 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3696 popupMgr()->insert( separator(), anId, -1 );
3698 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3699 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3700 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3702 //-------------------------------------------------
3704 //-------------------------------------------------
3705 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3707 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3709 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3710 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3711 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3713 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3714 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3715 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3717 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3718 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3719 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3721 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3722 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3723 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3725 popupMgr()->insert( separator(), anId, -1 );
3727 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3728 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3731 //-------------------------------------------------
3732 // Representation of the 2D Quadratic elements
3733 //-------------------------------------------------
3734 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3735 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3736 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3737 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3739 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3740 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3741 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3743 //-------------------------------------------------
3744 // Orientation of faces
3745 //-------------------------------------------------
3746 popupMgr()->insert( action( 221 ), -1, -1 );
3747 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3748 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3750 //-------------------------------------------------
3752 //-------------------------------------------------
3753 popupMgr()->insert( action( 1132 ), -1, -1 );
3754 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3756 //-------------------------------------------------
3758 //-------------------------------------------------
3759 popupMgr()->insert( action( 1133 ), -1, -1 );
3760 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3762 //-------------------------------------------------
3764 //-------------------------------------------------
3766 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3767 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3768 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3769 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3771 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3773 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3774 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3776 popupMgr()->insert( separator(), anId, -1 );
3778 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3780 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3781 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3782 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3784 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3786 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3787 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3788 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3790 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3791 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3792 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3794 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3795 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3796 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3798 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3799 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3800 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3802 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3804 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3805 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3806 QtxPopupMgr::VisibleRule );
3807 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3809 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3810 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3811 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3813 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3814 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3815 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3817 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3818 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3819 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3821 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
3822 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3823 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3825 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
3826 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3827 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3829 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
3830 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3831 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3833 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
3834 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3835 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3837 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
3838 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3839 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3841 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3842 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3843 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3845 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
3846 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3847 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
3849 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3851 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3852 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3856 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3857 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3859 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3860 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3861 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3863 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
3864 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3865 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
3867 popupMgr()->insert( separator(), anId, -1 );
3869 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3870 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3872 popupMgr()->insert( separator(), anId, -1 );
3874 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3875 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3877 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3878 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3879 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3882 popupMgr()->insert( separator(), -1, -1 );
3884 //-------------------------------------------------
3886 //-------------------------------------------------
3887 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3888 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3889 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3890 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3892 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3893 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3895 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3896 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3898 popupMgr()->insert( separator(), -1, -1 );
3900 //-------------------------------------------------
3902 //-------------------------------------------------
3903 popupMgr()->insert( action( 1134 ), -1, -1 );
3904 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3906 popupMgr()->insert( separator(), -1, -1 );
3908 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3909 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3911 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3912 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3915 //================================================================================
3917 * \brief Return true if SMESH or GEOM objects are selected.
3918 * Is called form LightApp_Module::activateModule() which clear selection if
3919 * not isSelectionCompatible()
3921 //================================================================================
3923 bool SMESHGUI::isSelectionCompatible()
3925 bool isCompatible = true;
3926 SALOME_ListIO selected;
3927 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3928 Sel->selectedObjects( selected );
3930 SALOME_ListIteratorOfListIO It( selected );
3931 for ( ; isCompatible && It.More(); It.Next())
3933 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3934 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3936 return isCompatible;
3940 bool SMESHGUI::reusableOperation( const int id )
3942 // compute, evaluate and precompute are not reusable operations
3943 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3946 bool SMESHGUI::activateModule( SUIT_Study* study )
3948 bool res = SalomeApp_Module::activateModule( study );
3950 setMenuShown( true );
3951 setToolShown( true );
3953 // Reset actions accelerator keys
3954 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3955 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3956 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3958 action( 33)->setEnabled(true); // Delete: Key_Delete
3959 action(1101)->setEnabled(true); // Rename: Key_F2
3961 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3962 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3963 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3964 if ( _PTR(Study) aStudy = s->studyDS()) {
3965 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3966 updateObjBrowser(); // objects can be removed
3972 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3974 setMenuShown( false );
3975 setToolShown( false );
3977 EmitSignalCloseAllDialogs();
3979 // Unset actions accelerator keys
3980 action(111)->setShortcut(QKeySequence()); // Import DAT
3981 action(112)->setShortcut(QKeySequence()); // Import UNV
3982 action(113)->setShortcut(QKeySequence()); // Import MED
3984 action( 33)->setEnabled(false); // Delete: Key_Delete
3985 action(1101)->setEnabled(false); // Rename: Key_F2
3987 return SalomeApp_Module::deactivateModule( study );
3990 void SMESHGUI::studyClosed( SUIT_Study* s )
3992 SMESH::RemoveVisuData( s->id() );
3993 SalomeApp_Module::studyClosed( s );
3996 void SMESHGUI::OnGUIEvent()
3998 const QObject* obj = sender();
3999 if ( !obj || !obj->inherits( "QAction" ) )
4001 int id = actionId((QAction*)obj);
4006 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4008 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4009 if ( CORBA::is_nil( myComponentSMESH ) )
4011 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4013 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4014 return aGUI.myComponentSMESH;
4017 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4018 return myComponentSMESH;
4021 QString SMESHGUI::engineIOR() const
4023 CORBA::ORB_var anORB = getApp()->orb();
4024 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4025 return QString( anIOR.in() );
4028 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4030 SalomeApp_Module::contextMenuPopup( client, menu, title );
4032 selectionMgr()->selectedObjects( lst );
4033 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4034 Handle(SALOME_InteractiveObject) io = lst.First();
4035 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4036 _PTR(Study) study = appStudy->studyDS();
4037 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4039 QString aName = QString( obj->GetName().c_str() );
4040 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4041 aName.remove( (aName.length() - 1), 1 );
4047 LightApp_Selection* SMESHGUI::createSelection() const
4049 return new SMESHGUI_Selection();
4052 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4054 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4055 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4058 void SMESHGUI::viewManagers( QStringList& list ) const
4060 list.append( SVTK_Viewer::Type() );
4063 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4065 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4066 SMESH::UpdateSelectionProp( this );
4069 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4071 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4072 myClippingPlaneInfoMap.erase( theViewManager );
4075 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4077 theActor->AddObserver( SMESH::DeleteActorEvent,
4078 myEventCallbackCommand.GetPointer(),
4082 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4083 unsigned long theEvent,
4084 void* theClientData,
4087 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4088 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4089 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4090 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4091 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4092 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4093 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4094 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4095 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4096 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4097 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4098 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4099 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4100 if( anActor == *anIter3 ) {
4101 anActorList.erase( anIter3 );
4112 void SMESHGUI::createPreferences()
4114 // General tab ------------------------------------------------------------------------
4115 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4117 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
4118 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
4120 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4121 setPreferenceProperty( qaGroup, "columns", 2 );
4122 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4123 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4124 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4125 setPreferenceProperty( prec, "min", 0 );
4126 setPreferenceProperty( prec, "max", 16 );
4128 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4129 setPreferenceProperty( dispgroup, "columns", 2 );
4130 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4132 modes.append( "Wireframe" );
4133 modes.append( "Shading" );
4134 modes.append( "Nodes" );
4135 modes.append( "Shrink" );
4136 QList<QVariant> indices;
4137 indices.append( 0 );
4138 indices.append( 1 );
4139 indices.append( 2 );
4140 indices.append( 3 );
4141 setPreferenceProperty( dispmode, "strings", modes );
4142 setPreferenceProperty( dispmode, "indexes", indices );
4144 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4145 setPreferenceProperty( arcgroup, "columns", 2 );
4146 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4147 QStringList quadraticModes;
4148 quadraticModes.append("Lines");
4149 quadraticModes.append("Arcs");
4151 indices.append( 0 );
4152 indices.append( 1 );
4153 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4154 setPreferenceProperty( quadraticmode, "indexes", indices );
4156 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4157 "SMESH", "max_angle" );
4158 setPreferenceProperty( maxAngle, "min", 1 );
4159 setPreferenceProperty( maxAngle, "max", 90 );
4163 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4164 setPreferenceProperty( exportgroup, "columns", 2 );
4165 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4166 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4168 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4169 setPreferenceProperty( computeGroup, "columns", 2 );
4170 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4172 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4173 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4174 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4176 indices.append( 0 );
4177 indices.append( 1 );
4178 indices.append( 2 );
4179 setPreferenceProperty( notifyMode, "strings", modes );
4180 setPreferenceProperty( notifyMode, "indexes", indices );
4182 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4183 setPreferenceProperty( computeGroup, "columns", 2 );
4184 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4186 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4187 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4189 indices.append( 0 );
4190 indices.append( 1 );
4191 setPreferenceProperty( elemInfo, "strings", modes );
4192 setPreferenceProperty( elemInfo, "indexes", indices );
4194 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4195 setPreferenceProperty( segGroup, "columns", 2 );
4196 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4197 "SMESH", "segmentation" );
4198 setPreferenceProperty( segLen, "min", 1 );
4199 setPreferenceProperty( segLen, "max", 10000000 );
4200 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4201 "SMESH", "nb_segments_per_edge" );
4202 setPreferenceProperty( nbSeg, "min", 1 );
4203 setPreferenceProperty( nbSeg, "max", 10000000 );
4205 // Quantities with individual precision settings
4206 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4207 setPreferenceProperty( precGroup, "columns", 2 );
4209 const int nbQuantities = 6;
4210 int precs[nbQuantities], ii = 0;
4211 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4212 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4213 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4214 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4215 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4216 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4217 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4218 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4219 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4220 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4221 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4222 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4224 // Set property for precision value for spinboxes
4225 for ( ii = 0; ii < nbQuantities; ii++ ){
4226 setPreferenceProperty( precs[ii], "min", -14 );
4227 setPreferenceProperty( precs[ii], "max", 14 );
4228 setPreferenceProperty( precs[ii], "precision", 2 );
4231 // Mesh tab ------------------------------------------------------------------------
4232 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4233 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4234 setPreferenceProperty( nodeGroup, "columns", 3 );
4236 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4238 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4240 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4241 QList<QVariant> aMarkerTypeIndicesList;
4242 QList<QVariant> aMarkerTypeIconsList;
4243 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4244 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4245 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4246 aMarkerTypeIndicesList << i;
4247 aMarkerTypeIconsList << pixmap;
4249 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4250 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4252 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4254 QList<QVariant> aMarkerScaleIndicesList;
4255 QStringList aMarkerScaleValuesList;
4256 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4257 aMarkerScaleIndicesList << i;
4258 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4260 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4261 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4263 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4264 setPreferenceProperty( elemGroup, "columns", 2 );
4266 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4267 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4268 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4269 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4271 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4272 setPreferenceProperty( grpGroup, "columns", 2 );
4274 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4276 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4277 //setPreferenceProperty( sp, "hstretch", 0 );
4278 //setPreferenceProperty( sp, "vstretch", 0 );
4280 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4281 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4282 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4283 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4284 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4285 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4286 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4288 setPreferenceProperty( size0d, "min", 1 );
4289 setPreferenceProperty( size0d, "max", 10 );
4291 setPreferenceProperty( sp, "hstretch", 0 );
4292 setPreferenceProperty( sp, "vstretch", 0 );
4294 setPreferenceProperty( elemW, "min", 1 );
4295 setPreferenceProperty( elemW, "max", 5 );
4297 setPreferenceProperty( shrink, "min", 0 );
4298 setPreferenceProperty( shrink, "max", 100 );
4300 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4301 setPreferenceProperty( orientGroup, "columns", 1 );
4303 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4304 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4306 setPreferenceProperty( orientScale, "min", 0.05 );
4307 setPreferenceProperty( orientScale, "max", 0.5 );
4308 setPreferenceProperty( orientScale, "step", 0.05 );
4310 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4312 // Selection tab ------------------------------------------------------------------------
4313 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4315 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4316 setPreferenceProperty( selGroup, "columns", 2 );
4318 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4319 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4320 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4322 setPreferenceProperty( selW, "min", 1 );
4323 setPreferenceProperty( selW, "max", 5 );
4325 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4326 setPreferenceProperty( preGroup, "columns", 2 );
4328 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4329 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4331 setPreferenceProperty( preW, "min", 1 );
4332 setPreferenceProperty( preW, "max", 5 );
4334 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4335 setPreferenceProperty( precSelGroup, "columns", 2 );
4337 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4338 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4339 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4341 // Scalar Bar tab ------------------------------------------------------------------------
4342 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4343 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4344 setPreferenceProperty( fontGr, "columns", 2 );
4346 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4347 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4349 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4350 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4352 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4353 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4355 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4356 setPreferenceProperty( numcol, "min", 2 );
4357 setPreferenceProperty( numcol, "max", 256 );
4359 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4360 setPreferenceProperty( numlab, "min", 2 );
4361 setPreferenceProperty( numlab, "max", 65 );
4363 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4364 setPreferenceProperty( orientGr, "columns", 2 );
4365 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4366 QStringList orients;
4367 orients.append( tr( "SMESH_VERTICAL" ) );
4368 orients.append( tr( "SMESH_HORIZONTAL" ) );
4369 indices.clear(); indices.append( 0 ); indices.append( 1 );
4370 setPreferenceProperty( orient, "strings", orients );
4371 setPreferenceProperty( orient, "indexes", indices );
4373 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4374 setPreferenceProperty( posVSizeGr, "columns", 2 );
4375 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4376 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4377 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4378 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4379 setPreferenceProperty( xv, "step", 0.1 );
4380 setPreferenceProperty( xv, "min", 0.0 );
4381 setPreferenceProperty( xv, "max", 1.0 );
4382 setPreferenceProperty( yv, "step", 0.1 );
4383 setPreferenceProperty( yv, "min", 0.0 );
4384 setPreferenceProperty( yv, "max", 1.0 );
4385 setPreferenceProperty( wv, "step", 0.1 );
4386 setPreferenceProperty( wv, "min", 0.0 );
4387 setPreferenceProperty( wv, "max", 1.0 );
4388 setPreferenceProperty( hv, "min", 0.0 );
4389 setPreferenceProperty( hv, "max", 1.0 );
4390 setPreferenceProperty( hv, "step", 0.1 );
4392 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4393 setPreferenceProperty( posHSizeGr, "columns", 2 );
4394 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4395 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4396 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4397 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4398 setPreferenceProperty( xv, "min", 0.0 );
4399 setPreferenceProperty( xv, "max", 1.0 );
4400 setPreferenceProperty( xv, "step", 0.1 );
4401 setPreferenceProperty( xh, "min", 0.0 );
4402 setPreferenceProperty( xh, "max", 1.0 );
4403 setPreferenceProperty( xh, "step", 0.1 );
4404 setPreferenceProperty( yh, "min", 0.0 );
4405 setPreferenceProperty( yh, "max", 1.0 );
4406 setPreferenceProperty( yh, "step", 0.1 );
4407 setPreferenceProperty( wh, "min", 0.0 );
4408 setPreferenceProperty( wh, "max", 1.0 );
4409 setPreferenceProperty( wh, "step", 0.1 );
4410 setPreferenceProperty( hh, "min", 0.0 );
4411 setPreferenceProperty( hh, "max", 1.0 );
4412 setPreferenceProperty( hh, "step", 0.1 );
4414 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4415 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4416 setPreferenceProperty( distributionGr, "columns", 3 );
4418 types.append( tr( "SMESH_MONOCOLOR" ) );
4419 types.append( tr( "SMESH_MULTICOLOR" ) );
4420 indices.clear(); indices.append( 0 ); indices.append( 1 );
4421 setPreferenceProperty( coloringType, "strings", types );
4422 setPreferenceProperty( coloringType, "indexes", indices );
4423 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4427 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4429 if( sect=="SMESH" ) {
4430 float sbX1,sbY1,sbW,sbH;
4431 float aTol = 1.00000009999999;
4432 std::string aWarning;
4433 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4434 if( name=="selection_object_color" || name=="selection_element_color" ||
4435 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4436 name=="selection_precision_node" || name=="selection_precision_element" ||
4437 name=="selection_precision_object")
4438 SMESH::UpdateSelectionProp( this );
4439 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4440 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4441 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4442 if(sbX1+sbW > aTol){
4443 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4446 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4447 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4450 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4451 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4452 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4453 if(sbY1+sbH > aTol){
4454 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4455 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4456 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4459 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4460 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4461 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4462 if(sbX1+sbW > aTol){
4463 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4466 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4467 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4470 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4471 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4472 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4473 if(sbY1+sbH > aTol){
4474 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4477 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4478 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4481 else if ( name == "segmentation" ) {
4482 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4483 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4485 else if ( name == "nb_segments_per_edge" ) {
4486 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4487 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4490 if(aWarning.size() != 0){
4491 aWarning += "The default values are applied instead.";
4492 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4493 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4494 QObject::tr(aWarning.c_str()));
4499 //================================================================================
4501 * \brief Update something in accordance with update flags
4502 * \param theFlags - update flags
4504 * Update viewer or/and object browser etc. in accordance with update flags ( see
4505 * LightApp_UpdateFlags enumeration ).
4507 //================================================================================
4508 void SMESHGUI::update( const int flags )
4510 if ( flags & UF_Viewer | flags & UF_Forced )
4511 SMESH::UpdateView();
4513 SalomeApp_Module::update( flags );
4516 //================================================================================
4518 * \brief Set default selection mode
4520 * SLOT called when operation commited. Sets default selection mode
4522 //================================================================================
4523 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4525 SVTK_ViewWindow* vtkWnd =
4526 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4528 vtkWnd->SetSelectionMode( ActorSelection );
4531 //================================================================================
4533 * \brief Set default selection mode
4535 * SLOT called when operation aborted. Sets default selection mode
4537 //================================================================================
4538 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4540 SVTK_ViewWindow* vtkWnd =
4541 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4543 vtkWnd->SetSelectionMode( ActorSelection );
4546 //================================================================================
4548 * \brief Creates operation with given identifier
4549 * \param id - identifier of operation to be started
4550 * \return Pointer on created operation or NULL if operation is not created
4552 * Virtual method redefined from the base class creates operation with given id.
4553 * It is called called automatically from startOperation method of base class.
4555 //================================================================================
4556 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4558 LightApp_Operation* op = 0;
4559 // to do : create operation here
4562 case 417: //convert to quadratic
4563 op = new SMESHGUI_ConvToQuadOp();
4565 case 418: // create 2D mesh as boundary on 3D
4566 op = new SMESHGUI_Make2DFrom3DOp();
4568 case 701: // Compute mesh
4569 op = new SMESHGUI_ComputeOp();
4571 case 702: // Create mesh
4572 op = new SMESHGUI_MeshOp( true, true );
4574 case 703: // Create sub-mesh
4575 op = new SMESHGUI_MeshOp( true, false );
4577 case 704: // Edit mesh/sub-mesh
4578 op = new SMESHGUI_MeshOp( false );
4580 case 711: // Precompute mesh
4581 op = new SMESHGUI_PrecomputeOp();
4583 case 712: // Evaluate mesh
4584 op = new SMESHGUI_EvaluateOp();
4586 case 713: // Evaluate mesh
4587 op = new SMESHGUI_MeshOrderOp();
4589 case 806: // Create group on geom
4590 op = new SMESHGUI_GroupOnShapeOp();
4592 case 904: // Find element
4593 op = new SMESHGUI_FindElemByPointOp();
4595 case 4067: // make mesh pass through point
4596 op = new SMESHGUI_MakeNodeAtPointOp();
4603 op = SalomeApp_Module::createOperation( id );
4607 //================================================================================
4609 * \brief Stops current operations and starts a given one
4610 * \param id - The id of the operation to start
4612 //================================================================================
4614 void SMESHGUI::switchToOperation(int id)
4616 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4617 activeStudy()->abortAllOperations();
4618 startOperation( id );
4621 LightApp_Displayer* SMESHGUI::displayer()
4624 myDisplayer = new SMESHGUI_Displayer( getApp() );
4628 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4631 int aTolerance = 64;
4632 int anIterations = 0;
4638 if( anIterations % aPeriod == 0 )
4641 if( aTolerance < 1 )
4645 aHue = (int)( 360.0 * rand() / RAND_MAX );
4648 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4649 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4650 for( ; it != itEnd; ++it )
4652 SALOMEDS::Color anAutoColor = *it;
4653 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4656 aQColor.getHsv( &h, &s, &v );
4657 if( abs( h - aHue ) < aTolerance )
4669 aColor.setHsv( aHue, 255, 255 );
4671 SALOMEDS::Color aSColor;
4672 aSColor.R = (double)aColor.red() / 255.0;
4673 aSColor.G = (double)aColor.green() / 255.0;
4674 aSColor.B = (double)aColor.blue() / 255.0;
4679 const char gSeparator = '_'; // character used to separate parameter names
4680 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4681 const char gPathSep = '|'; // character used to separate paths
4684 * \brief Store visual parameters
4686 * This method is called just before the study document is saved.
4687 * Store visual parameters in AttributeParameter attribue(s)
4689 void SMESHGUI::storeVisualParameters (int savePoint)
4691 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4692 if (!appStudy || !appStudy->studyDS())
4694 _PTR(Study) studyDS = appStudy->studyDS();
4696 // componentName is used for encoding of entries when storing them in IParameters
4697 std::string componentName = myComponentSMESH->ComponentDataType();
4698 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4699 //if (!aSComponent) return;
4702 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4703 componentName.c_str(),
4705 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4707 // store map of custom markers
4708 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4709 if( !aMarkerMap.empty() )
4711 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4712 for( ; anIter != aMarkerMap.end(); anIter++ )
4714 int anId = anIter->first;
4715 VTK::MarkerData aMarkerData = anIter->second;
4716 std::string aMarkerFileName = aMarkerData.first;
4717 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4718 if( aMarkerTexture.size() < 3 )
4719 continue; // should contain at least width, height and the first value
4721 QString aPropertyName( "texture" );
4722 aPropertyName += gSeparator;
4723 aPropertyName += QString::number( anId );
4725 QString aPropertyValue = aMarkerFileName.c_str();
4726 aPropertyValue += gPathSep;
4728 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4729 ushort aWidth = *aTextureIter++;
4730 ushort aHeight = *aTextureIter++;
4731 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4732 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4733 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4734 aPropertyValue += QString::number( *aTextureIter );
4736 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4740 // viewers counters are used for storing view_numbers in IParameters
4743 // main cycle to store parameters of displayed objects
4744 QList<SUIT_ViewManager*> lst;
4745 QList<SUIT_ViewManager*>::Iterator it;
4746 getApp()->viewManagers(lst);
4747 for (it = lst.begin(); it != lst.end(); it++)
4749 SUIT_ViewManager* vman = *it;
4750 QString vType = vman->getType();
4752 // saving VTK actors properties
4753 if (vType == SVTK_Viewer::Type())
4755 // store the clipping planes attached to the view manager
4756 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4757 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4758 if( anIter != myClippingPlaneInfoMap.end() )
4759 aClippingPlaneInfoList = anIter->second;
4761 if( !aClippingPlaneInfoList.empty() ) {
4762 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4763 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4765 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4766 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4768 QString aPropertyName( "ClippingPlane" );
4769 aPropertyName += gSeparator;
4770 aPropertyName += QString::number( vtkViewers );
4771 aPropertyName += gSeparator;
4772 aPropertyName += QString::number( anId );
4774 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4775 aPropertyValue += gDigitsSep;
4776 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4777 aPropertyValue += gDigitsSep;
4778 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4779 aPropertyValue += gDigitsSep;
4780 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4782 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4786 QVector<SUIT_ViewWindow*> views = vman->getViews();
4787 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4789 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4791 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4792 vtkActorCollection* allActors = aCopy.GetActors();
4793 allActors->InitTraversal();
4794 while (vtkActor* actor = allActors->GetNextActor())
4796 if (actor->GetVisibility()) // store only visible actors
4798 SMESH_Actor* aSmeshActor = 0;
4799 if (actor->IsA("SMESH_Actor"))
4800 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4801 if (aSmeshActor && aSmeshActor->hasIO())
4803 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4806 // entry is "encoded" = it does NOT contain component adress,
4807 // since it is a subject to change on next component loading
4808 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4810 std::string param, vtkParam = vType.toLatin1().data();
4811 vtkParam += gSeparator;
4812 vtkParam += QString::number(vtkViewers).toLatin1().data();
4813 vtkParam += gSeparator;
4816 param = vtkParam + "Visibility";
4817 ip->setParameter(entry, param, "On");
4820 param = vtkParam + "Representation";
4821 ip->setParameter(entry, param, QString::number
4822 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4825 param = vtkParam + "IsShrunk";
4826 ip->setParameter(entry, param, QString::number
4827 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4829 // Displayed entities
4830 unsigned int aMode = aSmeshActor->GetEntityMode();
4831 bool isE = aMode & SMESH_Actor::eEdges;
4832 bool isF = aMode & SMESH_Actor::eFaces;
4833 bool isV = aMode & SMESH_Actor::eVolumes;
4835 QString modeStr ("e");
4836 modeStr += gDigitsSep; modeStr += QString::number(isE);
4837 modeStr += gDigitsSep; modeStr += "f";
4838 modeStr += gDigitsSep; modeStr += QString::number(isF);
4839 modeStr += gDigitsSep; modeStr += "v";
4840 modeStr += gDigitsSep; modeStr += QString::number(isV);
4842 param = vtkParam + "Entities";
4843 ip->setParameter(entry, param, modeStr.toLatin1().data());
4845 // Colors (surface:edge:)
4846 vtkFloatingPointType r, g, b;
4848 aSmeshActor->GetSufaceColor(r, g, b);
4849 QString colorStr ("surface");
4850 colorStr += gDigitsSep; colorStr += QString::number(r);
4851 colorStr += gDigitsSep; colorStr += QString::number(g);
4852 colorStr += gDigitsSep; colorStr += QString::number(b);
4854 aSmeshActor->GetBackSufaceColor(r, g, b);
4855 colorStr += gDigitsSep; colorStr += "backsurface";
4856 colorStr += gDigitsSep; colorStr += QString::number(r);
4857 colorStr += gDigitsSep; colorStr += QString::number(g);
4858 colorStr += gDigitsSep; colorStr += QString::number(b);
4860 aSmeshActor->GetEdgeColor(r, g, b);
4861 colorStr += gDigitsSep; colorStr += "edge";
4862 colorStr += gDigitsSep; colorStr += QString::number(r);
4863 colorStr += gDigitsSep; colorStr += QString::number(g);
4864 colorStr += gDigitsSep; colorStr += QString::number(b);
4866 aSmeshActor->GetNodeColor(r, g, b);
4867 colorStr += gDigitsSep; colorStr += "node";
4868 colorStr += gDigitsSep; colorStr += QString::number(r);
4869 colorStr += gDigitsSep; colorStr += QString::number(g);
4870 colorStr += gDigitsSep; colorStr += QString::number(b);
4872 param = vtkParam + "Colors";
4873 ip->setParameter(entry, param, colorStr.toLatin1().data());
4875 // Sizes of lines and points
4876 QString sizeStr ("line");
4877 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4878 sizeStr += gDigitsSep; sizeStr += "shrink";
4879 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4881 param = vtkParam + "Sizes";
4882 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4887 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4888 if( aMarkerType == VTK::MT_USER ) {
4889 markerStr += "custom";
4890 markerStr += gDigitsSep;
4891 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4895 markerStr += gDigitsSep;
4896 markerStr += QString::number( (int)aMarkerType );
4897 markerStr += gDigitsSep;
4898 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4901 param = vtkParam + "PointMarker";
4902 ip->setParameter(entry, param, markerStr.toLatin1().data());
4905 param = vtkParam + "Opacity";
4906 ip->setParameter(entry, param,
4907 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4910 param = vtkParam + "ClippingPlane";
4912 if( !aClippingPlaneInfoList.empty() ) {
4913 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4914 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
4916 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
4917 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
4918 SMESH::TActorList::iterator anIter2 = anActorList.begin();
4919 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
4920 if( aSmeshActor == *anIter2 ) {
4921 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
4922 QString::number( anId ).toLatin1().constData() );
4929 ip->setParameter( entry, param, "Off" );
4930 } // if (io->hasEntry())
4931 } // SMESH_Actor && hasIO
4933 } // while.. actors traversal
4937 } // if (SVTK view model)
4938 } // for (viewManagers)
4941 // data structures for clipping planes processing
4944 vtkIdType Orientation;
4945 vtkFloatingPointType Distance;
4946 vtkFloatingPointType Angle[2];
4948 typedef std::list<TPlaneData> TPlaneDataList;
4949 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
4951 typedef std::list<vtkActor*> TActorList;
4954 TActorList ActorList;
4955 SUIT_ViewManager* ViewManager;
4957 typedef std::list<TPlaneInfo> TPlaneInfoList;
4958 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
4961 * \brief Restore visual parameters
4963 * This method is called after the study document is opened.
4964 * Restore visual parameters from AttributeParameter attribue(s)
4966 void SMESHGUI::restoreVisualParameters (int savePoint)
4968 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4969 if (!appStudy || !appStudy->studyDS())
4971 _PTR(Study) studyDS = appStudy->studyDS();
4973 // componentName is used for encoding of entries when storing them in IParameters
4974 std::string componentName = myComponentSMESH->ComponentDataType();
4975 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4976 //if (!aSComponent) return;
4979 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4980 componentName.c_str(),
4982 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4984 // restore map of custom markers and map of clipping planes
4985 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4986 TPlaneDataMap aPlaneDataMap;
4988 std::vector<std::string> properties = ip->getProperties();
4989 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4991 std::string property = *propIt;
4992 QString aPropertyName( property.c_str() );
4993 QString aPropertyValue( ip->getProperty( property ).c_str() );
4995 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4996 if( aPropertyNameList.isEmpty() )
4999 QString aPropertyType = aPropertyNameList[0];
5000 if( aPropertyType == "texture" )
5002 if( aPropertyNameList.size() != 2 )
5006 int anId = aPropertyNameList[1].toInt( &ok );
5007 if( !ok || anId < 1 )
5010 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5011 if( aPropertyValueList.size() != 2 )
5014 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5015 QString aMarkerTextureString = aPropertyValueList[1];
5016 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5017 if( aMarkerTextureStringList.size() != 3 )
5021 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5026 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5030 VTK::MarkerTexture aMarkerTexture;
5031 aMarkerTexture.push_back( aWidth );
5032 aMarkerTexture.push_back( aHeight );
5034 QString aMarkerTextureData = aMarkerTextureStringList[2];
5035 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5037 QChar aChar = aMarkerTextureData.at( i );
5038 if( aChar.isDigit() )
5039 aMarkerTexture.push_back( aChar.digitValue() );
5042 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5044 else if( aPropertyType == "ClippingPlane" )
5046 if( aPropertyNameList.size() != 3 )
5050 int aViewId = aPropertyNameList[1].toInt( &ok );
5051 if( !ok || aViewId < 0 )
5055 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5056 if( !ok || aClippingPlaneId < 0 )
5059 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5060 if( aPropertyValueList.size() != 4 )
5063 TPlaneData aPlaneData;
5064 aPlaneData.Id = aClippingPlaneId;
5067 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5072 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5077 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5082 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5086 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5087 aPlaneDataList.push_back( aPlaneData );
5091 TPlaneInfoMap aPlaneInfoMap;
5093 std::vector<std::string> entries = ip->getEntries();
5095 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5097 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5098 QString entry (ip->decodeEntry(*entIt).c_str());
5100 // Check that the entry corresponds to a real object in the Study
5101 // as the object may be deleted or modified after the visual state is saved.
5102 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5103 if (!so) continue; //Skip the not existent entry
5105 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5106 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5108 std::vector<std::string>::iterator namesIt = paramNames.begin();
5109 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5111 // actors are stored in a map after displaying of them for
5112 // quicker access in the future: map < viewID to actor >
5113 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5115 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5117 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5118 // '_' is used as separator and should not be used in viewer type or parameter names.
5119 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5120 if (lst.size() != 3)
5123 QString viewerTypStr = lst[0];
5124 QString viewIndexStr = lst[1];
5125 QString paramNameStr = lst[2];
5128 int viewIndex = viewIndexStr.toUInt(&ok);
5129 if (!ok) // bad conversion of view index to integer
5133 if (viewerTypStr == SVTK_Viewer::Type())
5135 SMESH_Actor* aSmeshActor = 0;
5136 if (vtkActors.IsBound(viewIndex))
5137 aSmeshActor = vtkActors.Find(viewIndex);
5139 QList<SUIT_ViewManager*> lst;
5140 getApp()->viewManagers(viewerTypStr, lst);
5142 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5143 SUIT_ViewManager* vman = NULL;
5144 if (viewIndex >= 0 && viewIndex < lst.count())
5145 vman = lst.at(viewIndex);
5147 if (paramNameStr == "Visibility")
5149 if (!aSmeshActor && displayer() && vman)
5151 SUIT_ViewModel* vmodel = vman->getViewModel();
5152 // SVTK view model can be casted to SALOME_View
5153 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5155 // store displayed actor in a temporary map for quicker
5156 // access later when restoring other parameters
5157 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5158 vtkRenderer* Renderer = vtkView->getRenderer();
5159 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5160 vtkActorCollection* theActors = aCopy.GetActors();
5161 theActors->InitTraversal();
5162 bool isFound = false;
5163 vtkActor *ac = theActors->GetNextActor();
5164 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5165 if (ac->IsA("SMESH_Actor")) {
5166 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5167 if (aGeomAc->hasIO()) {
5168 Handle(SALOME_InteractiveObject) io =
5169 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5170 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5172 vtkActors.Bind(viewIndex, aGeomAc);
5178 } // if (paramNameStr == "Visibility")
5181 // the rest properties "work" with SMESH_Actor
5184 QString val ((*valuesIt).c_str());
5187 if (paramNameStr == "Representation") {
5188 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5191 else if (paramNameStr == "IsShrunk") {
5193 if (!aSmeshActor->IsShrunk())
5194 aSmeshActor->SetShrink();
5197 if (aSmeshActor->IsShrunk())
5198 aSmeshActor->UnShrink();
5201 // Displayed entities
5202 else if (paramNameStr == "Entities") {
5203 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5204 if (mode.count() == 6) {
5205 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5206 MESSAGE("Invalid order of data in Entities, must be: "
5207 "e:0/1:f:0/1:v:0/1");
5210 unsigned int aMode = aSmeshActor->GetEntityMode();
5211 unsigned int aNewMode =
5212 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5213 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5214 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5215 if (aNewMode != aMode)
5216 aSmeshActor->SetEntityMode(aNewMode);
5221 else if (paramNameStr == "Colors") {
5222 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5223 if (colors.count() == 16) {
5224 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5225 colors[8] != "edge" || colors[12] != "node") {
5226 MESSAGE("Invalid order of data in Colors, must be: "
5227 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5230 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5231 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5232 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5233 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5237 // Sizes of lines and points
5238 else if (paramNameStr == "Sizes") {
5239 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5240 if (sizes.count() == 4) {
5241 if (sizes[0] != "line" || sizes[2] != "shrink") {
5242 MESSAGE("Invalid order of data in Sizes, must be: "
5243 "line:int:shrink:float");
5246 aSmeshActor->SetLineWidth(sizes[1].toInt());
5247 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5250 else if (sizes.count() == 6) { // just to support old format
5251 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5252 MESSAGE("Invalid order of data in Sizes, must be: "
5253 "line:int:node:int:shrink:float");
5256 aSmeshActor->SetLineWidth(sizes[1].toInt());
5257 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5258 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5263 else if (paramNameStr == "PointMarker") {
5264 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5265 if( data.count() >= 2 ) {
5267 int aParam1 = data[1].toInt( &ok );
5269 if( data[0] == "std" && data.count() == 3 ) {
5270 int aParam2 = data[2].toInt( &ok );
5271 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5273 else if( data[0] == "custom" ) {
5274 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5275 if( markerIt != aMarkerMap.end() ) {
5276 VTK::MarkerData aMarkerData = markerIt->second;
5277 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5284 else if (paramNameStr == "Opacity") {
5285 aSmeshActor->SetOpacity(val.toFloat());
5288 else if (paramNameStr.startsWith("ClippingPlane")) {
5289 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5290 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5291 // new format - val looks like "Off" or "0" (plane id)
5292 // (note: in new format "Off" value is used only for consistency,
5293 // so it is processed together with values in old format)
5294 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5295 if( anIsOldFormat ) {
5296 if (paramNameStr == "ClippingPlane1" || val == "Off")
5297 aSmeshActor->RemoveAllClippingPlanes();
5299 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5300 double aDistance = vals[1].toFloat();
5301 vtkFloatingPointType anAngle[2];
5302 anAngle[0] = vals[2].toFloat();
5303 anAngle[1] = vals[3].toFloat();
5305 QList<SUIT_ViewManager*> lst;
5306 getApp()->viewManagers(viewerTypStr, lst);
5307 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5308 if (viewIndex >= 0 && viewIndex < lst.count()) {
5309 SUIT_ViewManager* vman = lst.at(viewIndex);
5310 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5312 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5314 SMESH::TActorList anActorList;
5315 anActorList.push_back( aSmeshActor );
5316 SMESH::OrientedPlane* aPlane =
5317 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5319 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5320 aClippingPlaneInfo.Plane = aPlane;
5321 aClippingPlaneInfo.ActorList = anActorList;
5322 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5329 int aPlaneId = val.toInt( &ok );
5330 if( ok && aPlaneId >= 0 ) {
5331 bool anIsDefinedPlane = false;
5332 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5333 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5334 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5335 TPlaneInfo& aPlaneInfo = *anIter;
5336 if( aPlaneInfo.PlaneId == aPlaneId ) {
5337 aPlaneInfo.ActorList.push_back( aSmeshActor );
5338 anIsDefinedPlane = true;
5342 if( !anIsDefinedPlane ) {
5343 TPlaneInfo aPlaneInfo;
5344 aPlaneInfo.PlaneId = aPlaneId;
5345 aPlaneInfo.ActorList.push_back( aSmeshActor );
5346 aPlaneInfo.ViewManager = vman;
5347 aPlaneInfoList.push_back( aPlaneInfo );
5352 } // if (aSmeshActor)
5353 } // other parameters than Visibility
5355 } // for names/parameters iterator
5356 } // for entries iterator
5358 // add clipping planes to actors according to the restored parameters
5359 // and update the clipping plane map
5360 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5361 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5362 int aViewId = anIter1->first;
5363 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5365 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5366 if( anIter2 == aPlaneDataMap.end() )
5368 const TPlaneDataList& aPlaneDataList = anIter2->second;
5370 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5371 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5372 const TPlaneInfo& aPlaneInfo = *anIter3;
5373 int aPlaneId = aPlaneInfo.PlaneId;
5374 const TActorList& anActorList = aPlaneInfo.ActorList;
5375 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5379 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5383 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5385 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5386 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5387 const TPlaneData& aPlaneData = *anIter4;
5388 if( aPlaneData.Id == aPlaneId ) {
5389 SMESH::OrientedPlane* aPlane =
5390 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5392 (SMESH::Orientation)aPlaneData.Orientation,
5393 aPlaneData.Distance,
5396 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5397 aClippingPlaneInfo.Plane = aPlane;
5398 aClippingPlaneInfo.ActorList = anActorList;
5399 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5407 // update all VTK views
5408 QList<SUIT_ViewManager*> lst;
5409 getApp()->viewManagers(lst);
5410 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5411 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5412 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5413 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5414 vtkView->getRenderer()->ResetCameraClippingRange();
5421 \brief Adds preferences for dfont of VTK viewer
5423 \param pIf group identifier
5424 \param param parameter
5425 \return identifier of preferences
5427 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5429 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5431 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5434 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5435 fam.append( tr( "SMESH_FONT_COURIER" ) );
5436 fam.append( tr( "SMESH_FONT_TIMES" ) );
5438 setPreferenceProperty( tfont, "fonts", fam );
5440 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5441 setPreferenceProperty( tfont, "features", f );
5447 \brief Actions after hypothesis edition
5448 Updates object browser after hypothesis edition
5450 void SMESHGUI::onHypothesisEdit( int result )
5453 SMESHGUI::Modified();
5454 updateObjBrowser( true );