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" );
763 void SaveDistribution()
765 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
766 SALOME_ListIO selected;
768 aSel->selectedObjects( selected );
770 if ( selected.Extent() == 1 ) {
771 Handle(SALOME_InteractiveObject) anIO = selected.First();
772 if ( anIO->hasEntry() ) {
773 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
774 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
775 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
776 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
777 if ( aScalarBarActor && aFunctor ) {
778 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
780 int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
781 std::vector<int> nbEvents;
782 std::vector<double> funValues;
783 aNumFun->GetHistogram( nbRanges, nbEvents, funValues );
784 QString anInitialPath = "";
785 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
786 anInitialPath = QDir::currentPath();
787 QString aMeshName = anIO->getName();
789 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
790 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
791 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
792 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
793 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
796 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
798 if ( !aFilename.isEmpty() ) {
799 QFile f( aFilename );
800 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
801 QTextStream out( &f );
802 out << "# Mesh: " << aMeshName << endl;
803 out << "# Control: " << functorToString( aFunctor ) << endl;
805 out.setFieldWidth( 10 );
806 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
807 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
818 void ShowDistribution() {
819 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
820 SALOME_ListIO selected;
822 aSel->selectedObjects( selected );
824 if ( selected.Extent() == 1 ) {
825 Handle(SALOME_InteractiveObject) anIO = selected.First();
826 if ( anIO->hasEntry() ) {
827 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
828 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
829 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
830 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
836 void DisableAutoColor(){
837 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
838 SALOME_ListIO selected;
840 aSel->selectedObjects( selected );
842 if(selected.Extent()){
843 Handle(SALOME_InteractiveObject) anIObject = selected.First();
844 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
845 if ( !aMesh->_is_nil() ) {
846 aMesh->SetAutoColor( false );
851 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
852 SALOME_ListIO selected;
853 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
857 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
858 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
859 if( !aSel || !appStudy )
862 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
863 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
864 aModule->EmitSignalDeactivateDialog();
865 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
866 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
871 _PTR(Study) aStudy = appStudy->studyDS();
873 aSel->selectedObjects( selected );
875 if(selected.Extent() >= 1){
876 switch(theCommandID){
878 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
879 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
883 QColor c, e, b, n, c0D, o;
886 vtkFloatingPointType Shrink = 0.0;
887 vtkFloatingPointType faces_orientation_scale = 0.0;
888 bool faces_orientation_3dvectors = false;
890 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
891 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
892 int aMarkerTextureCurrent = 0;
894 SALOME_ListIteratorOfListIO It( selected );
895 for( ; It.More(); It.Next()){
896 Handle(SALOME_InteractiveObject) IObject = It.Value();
897 if(IObject->hasEntry()){
898 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
899 vtkFloatingPointType color[3];
900 anActor->GetSufaceColor(color[0], color[1], color[2]);
901 int c0 = int (color[0] * 255);
902 int c1 = int (color[1] * 255);
903 int c2 = int (color[2] * 255);
904 c.setRgb(c0, c1, c2);
906 vtkFloatingPointType edgecolor[3];
907 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
908 c0 = int (edgecolor[0] * 255);
909 c1 = int (edgecolor[1] * 255);
910 c2 = int (edgecolor[2] * 255);
911 e.setRgb(c0, c1, c2);
913 vtkFloatingPointType backfacecolor[3];
914 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
915 c0 = int (backfacecolor[0] * 255);
916 c1 = int (backfacecolor[1] * 255);
917 c2 = int (backfacecolor[2] * 255);
918 b.setRgb(c0, c1, c2);
920 vtkFloatingPointType nodecolor[3];
921 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
922 c0 = int (nodecolor[0] * 255);
923 c1 = int (nodecolor[1] * 255);
924 c2 = int (nodecolor[2] * 255);
925 n.setRgb(c0, c1, c2);
927 vtkFloatingPointType color0D[3];
928 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
929 c0 = int (color0D[0] * 255);
930 c1 = int (color0D[1] * 255);
931 c2 = int (color0D[2] * 255);
932 c0D.setRgb(c0, c1, c2);
934 size0D = (int)anActor->Get0DSize();
937 Edgewidth = (int)anActor->GetLineWidth();
940 Shrink = anActor->GetShrinkFactor();
942 vtkFloatingPointType faces_orientation_color[3];
943 anActor->GetFacesOrientationColor(faces_orientation_color);
944 c0 = int (faces_orientation_color[0] * 255);
945 c1 = int (faces_orientation_color[1] * 255);
946 c2 = int (faces_orientation_color[2] * 255);
947 o.setRgb(c0, c1, c2);
949 faces_orientation_scale = anActor->GetFacesOrientationScale();
950 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
952 aMarkerTypeCurrent = anActor->GetMarkerType();
953 aMarkerScaleCurrent = anActor->GetMarkerScale();
954 aMarkerTextureCurrent = anActor->GetMarkerTexture();
956 // even if there are multiple objects in the selection,
957 // we need only the first one to get values for the dialog
963 SMESHGUI_Preferences_ColorDlg *aDlg =
964 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
965 aDlg->SetColor(1, c);
966 aDlg->SetColor(2, e);
967 aDlg->SetColor(3, n);
968 aDlg->SetColor(4, b);
969 aDlg->SetColor(5, c0D);
970 aDlg->SetColor(6, o);
971 aDlg->SetIntValue(1, Edgewidth);
972 aDlg->SetIntValue(2, int(Shrink*100.));
973 aDlg->SetIntValue(3, size0D);
974 aDlg->SetDoubleValue(1, faces_orientation_scale);
975 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
977 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
979 if( aMarkerTypeCurrent != VTK::MT_USER )
980 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
982 aDlg->setCustomMarker( aMarkerTextureCurrent );
985 QColor color = aDlg->GetColor(1);
986 QColor edgecolor = aDlg->GetColor(2);
987 QColor nodecolor = aDlg->GetColor(3);
988 QColor backfacecolor = aDlg->GetColor(4);
989 QColor color0D = aDlg->GetColor(5);
990 QColor faces_orientation_color = aDlg->GetColor(6);
993 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
995 SALOME_ListIteratorOfListIO It( selected );
996 for( ; It.More(); It.Next()){
997 Handle(SALOME_InteractiveObject) IObject = It.Value();
998 if(IObject->hasEntry()){
999 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1000 /* actor color and backface color */
1001 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1002 vtkFloatingPointType (color.green()) / 255.,
1003 vtkFloatingPointType (color.blue()) / 255.);
1004 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1005 vtkFloatingPointType (backfacecolor.green()) / 255.,
1006 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1009 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1010 vtkFloatingPointType (edgecolor.green()) / 255.,
1011 vtkFloatingPointType (edgecolor.blue()) / 255.);
1013 /* Shrink factor and size edges */
1014 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1015 anActor->SetLineWidth(aDlg->GetIntValue(1));
1017 /* Nodes color and size */
1018 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1019 vtkFloatingPointType (nodecolor.green()) / 255.,
1020 vtkFloatingPointType (nodecolor.blue()) / 255.);
1023 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1024 vtkFloatingPointType (color0D.green()) / 255.,
1025 vtkFloatingPointType (color0D.blue()) / 255.);
1026 anActor->Set0DSize(aDlg->GetIntValue(3));
1028 /* Faces orientation */
1029 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1030 vtkFloatingPointType(faces_orientation_color.greenF()),
1031 vtkFloatingPointType(faces_orientation_color.blueF())};
1032 anActor->SetFacesOrientationColor(c);
1033 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1034 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1036 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1037 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1038 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1039 if( aMarkerTypeNew != VTK::MT_USER )
1040 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1042 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1043 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1044 if( anIter != aMarkerMap.end() )
1045 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1048 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1049 if( !aGroupObject->_is_nil() )
1051 SMESH::ElementType anElementType = aGroupObject->GetType();
1053 switch( anElementType )
1055 case SMESH::NODE: aColor = nodecolor; break;
1056 case SMESH::EDGE: aColor = edgecolor; break;
1057 default: aColor = color; break;
1060 SALOMEDS::Color aGroupColor;
1061 aGroupColor.R = (float)aColor.red() / 255.0;
1062 aGroupColor.G = (float)aColor.green() / 255.0;
1063 aGroupColor.B = (float)aColor.blue() / 255.0;
1064 aGroupObject->SetColor( aGroupColor );
1069 SMESH::RepaintCurrentView();
1075 SALOME_ListIteratorOfListIO It( selected );
1076 for( ; It.More(); It.Next()){
1077 Handle(SALOME_InteractiveObject) IObject = It.Value();
1078 if(IObject->hasEntry()){
1079 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1080 switch(theCommandID){
1082 anActor->SetRepresentation(SMESH_Actor::eEdge);
1085 anActor->SetRepresentation(SMESH_Actor::eSurface);
1088 if(anActor->IsShrunk())
1089 anActor->UnShrink();
1091 anActor->SetShrink();
1094 anActor->SetRepresentation(SMESH_Actor::ePoint);
1097 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1098 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1101 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1102 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1108 SMESH::RepaintCurrentView();
1112 void Control( int theCommandID )
1114 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1115 SALOME_ListIO selected;
1117 aSel->selectedObjects( selected );
1119 if( !selected.IsEmpty() ){
1120 Handle(SALOME_InteractiveObject) anIO = selected.First();
1122 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1123 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1124 switch ( theCommandID ){
1126 aControl = SMESH_Actor::eLength;
1129 aControl = SMESH_Actor::eLength2D;
1132 aControl = SMESH_Actor::eFreeEdges;
1135 aControl = SMESH_Actor::eFreeBorders;
1138 aControl = SMESH_Actor::eMultiConnection;
1141 aControl = SMESH_Actor::eFreeNodes;
1144 aControl = SMESH_Actor::eMultiConnection2D;
1147 aControl = SMESH_Actor::eArea;
1150 aControl = SMESH_Actor::eTaper;
1153 aControl = SMESH_Actor::eAspectRatio;
1156 aControl = SMESH_Actor::eAspectRatio3D;
1159 aControl = SMESH_Actor::eMinimumAngle;
1162 aControl = SMESH_Actor::eWarping;
1165 aControl = SMESH_Actor::eSkew;
1168 aControl = SMESH_Actor::eVolume3D;
1171 aControl = SMESH_Actor::eFreeFaces;
1174 aControl = SMESH_Actor::eMaxElementLength2D;
1177 aControl = SMESH_Actor::eMaxElementLength3D;
1180 anActor->SetControlMode(aControl);
1181 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1182 SMESH::RepaintCurrentView();
1189 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1190 MeshObjectType theType,
1191 const QString theInTypeName,
1192 QString & theOutTypeName)
1194 SMESH_TypeFilter aTypeFilter( theType );
1196 if( !theIO.IsNull() )
1198 entry = theIO->getEntry();
1199 LightApp_DataOwner owner( entry );
1200 if ( aTypeFilter.isOk( &owner )) {
1201 theOutTypeName = theInTypeName;
1209 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1211 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1212 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1214 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1215 CORBA::String_var anID = aSComp->GetID().c_str();
1216 if (!strcmp(anID.in(),theIO->getEntry()))
1222 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1223 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1224 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1225 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1226 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1234 QString CheckHomogeneousSelection()
1236 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1237 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1238 SALOME_ListIO selected;
1240 aSel->selectedObjects( selected );
1242 QString RefType = CheckTypeObject(selected.First());
1243 SALOME_ListIteratorOfListIO It(selected);
1244 for ( ; It.More(); It.Next())
1246 Handle(SALOME_InteractiveObject) IObject = It.Value();
1247 QString Type = CheckTypeObject(IObject);
1248 if (Type.compare(RefType) != 0)
1249 return "Heterogeneous Selection";
1256 void SMESHGUI::OnEditDelete()
1258 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1259 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1260 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1262 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1263 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1264 _PTR(GenericAttribute) anAttr;
1265 _PTR(AttributeIOR) anIOR;
1267 int objectCount = 0;
1269 QString aParentComponent = QString::null;
1270 Handle(SALOME_InteractiveObject) anIO;
1271 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1273 anIO = anIt.Value();
1274 QString cur = anIO->getComponentDataType();
1275 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1277 // check if object is reference
1278 _PTR(SObject) aRefSObj;
1279 aNameList.append("\n - ");
1280 if ( aSO->ReferencedObject( aRefSObj ) ) {
1281 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1282 aNameList.append( aRefName );
1283 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1286 aNameList.append(anIO->getName());
1290 if( aParentComponent.isNull() )
1291 aParentComponent = cur;
1292 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1293 aParentComponent = "";
1296 if ( objectCount == 0 )
1297 return; // No Valid Objects Selected
1299 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1300 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1301 QObject::tr("ERR_ERROR"),
1302 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1305 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1306 if (SUIT_MessageBox::warning
1307 (SMESHGUI::desktop(),
1308 QObject::tr("SMESH_WRN_WARNING"),
1309 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1310 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1311 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1314 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1315 SUIT_ViewManager* vm = anApp->activeViewManager();
1316 int nbSf = vm ? vm->getViewsCount() : 0;
1318 SALOME_ListIteratorOfListIO It(selected);
1320 aStudyBuilder->NewCommand(); // There is a transaction
1321 for( ; It.More(); It.Next()){ // loop on selected IO's
1322 Handle(SALOME_InteractiveObject) IObject = It.Value();
1323 if(IObject->hasEntry()) {
1324 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1326 // disable removal of "SMESH" component object
1327 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1329 if ( engineIOR() == anIOR->Value().c_str() )
1332 //Check the referenced object
1333 _PTR(SObject) aRefSObject;
1334 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1335 aSO = aRefSObject; // Delete main Object instead of reference
1337 // put the whole hierarchy of sub-objects of the selected SO into a list and
1338 // then treat them all starting from the deepest objects (at list back)
1340 std::list< _PTR(SObject) > listSO;
1341 listSO.push_back( aSO );
1342 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1343 for ( ; itSO != listSO.end(); ++itSO ) {
1344 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1345 for (it->InitEx(false); it->More(); it->Next())
1346 listSO.push_back( it->Value() );
1349 // treat SO's in the list starting from the back
1351 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1352 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1353 _PTR(SObject) SO = *ritSO;
1354 if ( !SO ) continue;
1355 std::string anEntry = SO->GetID();
1357 /** Erase graphical object **/
1358 if(SO->FindAttribute(anAttr, "AttributeIOR") && vm ){
1359 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1360 for(int i = 0; i < nbSf; i++){
1361 SUIT_ViewWindow *sf = aViews[i];
1362 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1363 SMESH::RemoveActor(sf,anActor);
1368 /** Remove an object from data structures **/
1369 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1370 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1371 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1372 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1373 aMesh->RemoveGroup( aGroup );
1375 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1376 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1377 aMesh->RemoveSubMesh( aSubMesh );
1379 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1381 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1384 IObject = new SALOME_InteractiveObject
1385 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1386 QString objType = CheckTypeObject(IObject);
1387 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1388 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1389 aStudyBuilder->RemoveObjectWithChildren( SO );
1391 else {// default action: remove SObject from the study
1392 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1393 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1395 aStudyBuilder->RemoveObjectWithChildren( SO );
1399 } /* listSO back loop */
1400 } /* IObject->hasEntry() */
1402 aStudyBuilder->CommitCommand();
1404 /* Clear any previous selection */
1406 aSel->setSelectedObjects( l1 );
1408 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1413 SMESHGUI_EXPORT CAM_Module* createModule()
1415 return new SMESHGUI();
1419 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1421 //=============================================================================
1425 //=============================================================================
1426 SMESHGUI::SMESHGUI() :
1427 SalomeApp_Module( "SMESH" ),
1428 LightApp_Module( "SMESH" )
1430 if ( CORBA::is_nil( myComponentSMESH ) )
1432 CORBA::Boolean anIsEmbeddedMode;
1433 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1435 // 0019923: EDF 765 SMESH : default values of hypothesis
1436 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1437 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1438 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1439 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1440 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1443 myActiveDialogBox = 0;
1444 myFilterLibraryDlg = 0;
1448 myEventCallbackCommand = vtkCallbackCommand::New();
1449 myEventCallbackCommand->Delete();
1450 myEventCallbackCommand->SetClientData( this );
1451 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1454 SMESH::GetFilterManager();
1455 SMESH::GetPattern();
1456 SMESH::GetMeasurements();
1458 /* load resources for all available meshers */
1459 SMESH::InitAvailableHypotheses();
1462 //=============================================================================
1466 //=============================================================================
1467 SMESHGUI::~SMESHGUI()
1469 #ifdef WITHGENERICOBJ
1470 SMESH::GetFilterManager()->Destroy();
1471 SMESH::GetMeasurements()->Destroy();
1473 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1474 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1477 //=============================================================================
1481 //=============================================================================
1482 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1484 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1486 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1491 //=============================================================================
1495 //=============================================================================
1496 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1498 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1502 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1503 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1504 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1505 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1506 return autoUpdate && !exceeded;
1509 //=============================================================================
1513 //=============================================================================
1514 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1516 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1519 //=============================================================================
1523 //=============================================================================
1524 SMESHGUI* SMESHGUI::GetSMESHGUI()
1526 SMESHGUI* smeshMod = 0;
1527 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1530 CAM_Module* module = app->module( "Mesh" );
1531 smeshMod = dynamic_cast<SMESHGUI*>( module );
1534 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1536 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1539 _PTR(Study) aStudy = study->studyDS();
1541 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1550 Standard_EXPORT SMESHGUI* GetComponentGUI()
1552 return SMESHGUI::GetSMESHGUI();
1556 //=============================================================================
1560 //=============================================================================
1561 void SMESHGUI::SetState(int aState)
1566 //=============================================================================
1570 //=============================================================================
1571 void SMESHGUI::ResetState()
1576 //=============================================================================
1580 //=============================================================================
1581 void SMESHGUI::EmitSignalDeactivateDialog()
1583 emit SignalDeactivateActiveDialog();
1586 //=============================================================================
1590 //=============================================================================
1591 void SMESHGUI::EmitSignalStudyFrameChanged()
1593 emit SignalStudyFrameChanged();
1596 //=============================================================================
1600 //=============================================================================
1601 void SMESHGUI::EmitSignalCloseAllDialogs()
1603 emit SignalCloseAllDialogs();
1606 //=============================================================================
1610 //=============================================================================
1611 void SMESHGUI::EmitSignalVisibilityChanged()
1613 emit SignalVisibilityChanged();
1616 //=============================================================================
1620 //=============================================================================
1621 QDialog *SMESHGUI::GetActiveDialogBox()
1623 return myActiveDialogBox;
1626 //=============================================================================
1630 //=============================================================================
1631 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1633 myActiveDialogBox = (QDialog *) aDlg;
1637 //=============================================================================
1641 //=============================================================================
1642 SUIT_Desktop* SMESHGUI::desktop()
1644 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1646 return app->desktop();
1651 //=============================================================================
1655 //=============================================================================
1656 SalomeApp_Study* SMESHGUI::activeStudy()
1658 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1660 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1665 //=============================================================================
1669 //=============================================================================
1670 void SMESHGUI::Modified( bool theIsUpdateActions )
1672 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1673 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1674 appStudy->Modified();
1675 if( theIsUpdateActions )
1676 app->updateActions();
1681 //=============================================================================
1685 //=============================================================================
1686 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1688 /* Here the position is on the bottom right corner - 10 */
1689 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1691 SUIT_Desktop *PP = desktop();
1692 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1693 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1697 //=============================================================================
1701 //=============================================================================
1702 static int isStudyLocked(_PTR(Study) theStudy){
1703 return theStudy->GetProperties()->IsLocked();
1706 static bool checkLock(_PTR(Study) theStudy) {
1707 if (isStudyLocked(theStudy)) {
1708 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1709 QObject::tr("WRN_WARNING"),
1710 QObject::tr("WRN_STUDY_LOCKED") );
1716 //=======================================================================
1717 //function : CheckActiveStudyLocked
1719 //=======================================================================
1721 bool SMESHGUI::isActiveStudyLocked()
1723 _PTR(Study) aStudy = activeStudy()->studyDS();
1724 return checkLock( aStudy );
1727 //=============================================================================
1731 //=============================================================================
1732 bool SMESHGUI::OnGUIEvent( int theCommandID )
1734 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1738 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1739 SUIT_ResourceMgr* mgr = resourceMgr();
1743 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1744 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1747 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1748 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1750 //QAction* act = action( theCommandID );
1752 switch (theCommandID) {
1754 if(checkLock(aStudy)) break;
1762 if(checkLock(aStudy)) break;
1763 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1767 case 150: //MED FILE INFORMATION
1769 SALOME_ListIO selected;
1770 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1772 aSel->selectedObjects( selected );
1773 if( selected.Extent() )
1775 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1776 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1777 if ( !aMesh->_is_nil() )
1779 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1786 case 122: // EXPORT MED
1795 ::ExportMeshToFile(theCommandID);
1799 case 200: // SCALAR BAR
1801 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1802 SALOME_ListIO selected;
1804 aSel->selectedObjects( selected );
1806 if( selected.Extent() ) {
1807 Handle(SALOME_InteractiveObject) anIO = selected.First();
1808 if( anIO->hasEntry() ) {
1809 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1810 anActor->SetControlMode( SMESH_Actor::eNone );
1818 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1823 // dump control distribution data to the text file
1824 ::SaveDistribution();
1830 // show/ distribution
1831 ::ShowDistribution();
1841 ::DisableAutoColor();
1844 case 1134: // Clipping
1845 case 1133: // Tranparency
1846 case 1132: // Colors / Size
1853 ::SetDisplayMode(theCommandID, myMarkerMap);
1856 //2D quadratic representation
1859 ::SetDisplayMode(theCommandID, myMarkerMap);
1863 case 216: // 0D elements
1866 case 219: // Volumes
1867 case 220: // All Entity
1868 ::SetDisplayEntity(theCommandID);
1871 case 221: // Orientation of faces
1873 LightApp_SelectionMgr* mgr = selectionMgr();
1874 SALOME_ListIO selected; mgr->selectedObjects( selected );
1876 SALOME_ListIteratorOfListIO it(selected);
1877 for( ; it.More(); it.Next()) {
1878 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1879 if(anIObject->hasEntry()) {
1880 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1881 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1890 if(checkLock(aStudy)) break;
1892 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1895 SMESH::UpdateView();
1897 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1898 SMESH::OnVisuException();
1900 catch (...) { // PAL16774 (Crash after display of many groups)
1901 SMESH::OnVisuException();
1905 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1906 aSel->selectedObjects( l );
1907 aSel->setSelectedObjects( l );
1912 case 301: // DISPLAY
1913 case 302: // DISPLAY ONLY
1915 SMESH::EDisplaing anAction;
1916 switch (theCommandID) {
1917 case 300: anAction = SMESH::eErase; break;
1918 case 301: anAction = SMESH::eDisplay; break;
1919 case 302: anAction = SMESH::eDisplayOnly; break;
1922 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1923 SALOME_ListIO sel_objects, to_process;
1925 aSel->selectedObjects( sel_objects );
1927 if( theCommandID==302 )
1928 startOperation( myEraseAll );
1930 extractContainers( sel_objects, to_process );
1933 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1937 SALOME_ListIteratorOfListIO It( to_process );
1938 for ( ; It.More(); It.Next()) {
1939 Handle(SALOME_InteractiveObject) IOS = It.Value();
1940 if (IOS->hasEntry()) {
1941 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
1942 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1943 break; // PAL16774 (Crash after display of many groups)
1945 if (anAction == SMESH::eDisplayOnly)
1946 anAction = SMESH::eDisplay;
1951 // PAL13338 + PAL15161 -->
1952 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
1953 SMESH::UpdateView();
1954 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
1956 // PAL13338 + PAL15161 <--
1958 catch (...) { // PAL16774 (Crash after display of many groups)
1959 SMESH::OnVisuException();
1962 if (anAction == SMESH::eErase) {
1964 aSel->setSelectedObjects( l1 );
1967 aSel->setSelectedObjects( to_process );
1974 if(checkLock(aStudy)) break;
1977 EmitSignalDeactivateDialog();
1979 ( new SMESHGUI_NodesDlg( this ) )->show();
1982 SUIT_MessageBox::warning(desktop(),
1983 tr("SMESH_WRN_WARNING"),
1984 tr("SMESH_WRN_VIEWER_VTK"));
1989 case 2151: // FILTER
1993 EmitSignalDeactivateDialog();
1994 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1999 case 701: // COMPUTE MESH
2000 case 711: // PRECOMPUTE MESH
2001 case 712: // EVALUATE MESH
2002 case 713: // MESH ORDER
2004 if (checkLock(aStudy)) break;
2005 startOperation( theCommandID );
2009 case 702: // Create mesh
2010 case 703: // Create sub-mesh
2011 case 704: // Edit mesh/sub-mesh
2012 startOperation( theCommandID );
2014 case 710: // Build compound mesh
2016 if (checkLock(aStudy)) break;
2017 EmitSignalDeactivateDialog();
2018 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2022 case 407: // DIAGONAL INVERSION
2023 case 408: // Delete diagonal
2027 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2028 tr( "NOT_A_VTK_VIEWER" ) );
2032 if ( checkLock( aStudy ) )
2035 /*Standard_Boolean aRes;
2036 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2037 if ( aMesh->_is_nil() )
2039 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2040 tr( "SMESH_BAD_SELECTION" ) );
2044 EmitSignalDeactivateDialog();
2045 if ( theCommandID == 407 )
2046 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2048 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2051 case 409: // Change orientation
2052 case 410: // Union of triangles
2053 case 411: // Cutting of quadrangles
2054 case 419: // Splitting volumes into tetrahedra
2058 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2059 tr( "NOT_A_VTK_VIEWER" ) );
2063 if ( checkLock( aStudy ) )
2066 EmitSignalDeactivateDialog();
2067 SMESHGUI_MultiEditDlg* aDlg = NULL;
2068 if ( theCommandID == 409 )
2069 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2070 else if ( theCommandID == 410 )
2071 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2072 else if ( theCommandID == 419 )
2073 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2075 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2080 case 412: // Smoothing
2082 if(checkLock(aStudy)) break;
2084 EmitSignalDeactivateDialog();
2085 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2088 SUIT_MessageBox::warning(desktop(),
2089 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2093 case 413: // Extrusion
2095 if (checkLock(aStudy)) break;
2097 EmitSignalDeactivateDialog();
2098 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2100 SUIT_MessageBox::warning(desktop(),
2101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2105 case 414: // Revolution
2107 if(checkLock(aStudy)) break;
2109 EmitSignalDeactivateDialog();
2110 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2113 SUIT_MessageBox::warning(desktop(),
2114 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2118 case 415: // Pattern mapping
2120 if ( checkLock( aStudy ) )
2124 EmitSignalDeactivateDialog();
2125 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2128 SUIT_MessageBox::warning(desktop(),
2129 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2133 case 416: // Extrusion along a path
2135 if (checkLock(aStudy)) break;
2137 EmitSignalDeactivateDialog();
2138 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2140 SUIT_MessageBox::warning(desktop(),
2141 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2145 case 417: // Convert mesh to quadratic
2147 startOperation( 417 );
2148 /* if (checkLock(aStudy)) break;
2150 EmitSignalDeactivateDialog();
2151 new SMESHGUI_ConvToQuadDlg();
2153 SUIT_MessageBox::warning(desktop(),
2154 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2158 case 418: // create 2D mesh from 3D
2160 startOperation( 418 );
2163 case 806: // CREATE GEO GROUP
2165 startOperation( 806 );
2168 case 801: // CREATE GROUP
2172 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2173 tr( "NOT_A_VTK_VIEWER" ) );
2177 if(checkLock(aStudy)) break;
2178 EmitSignalDeactivateDialog();
2179 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2181 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2182 SALOME_ListIO selected;
2184 aSel->selectedObjects( selected );
2186 int nbSel = selected.Extent();
2188 // check if mesh is selected
2189 aMesh = SMESH::GetMeshByIO( selected.First() );
2191 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2196 case 802: // CONSTRUCT GROUP
2200 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2201 tr( "NOT_A_VTK_VIEWER" ) );
2205 if(checkLock(aStudy)) break;
2206 EmitSignalDeactivateDialog();
2208 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2209 SALOME_ListIO selected;
2211 aSel->selectedObjects( selected );
2213 int nbSel = selected.Extent();
2215 // check if submesh is selected
2216 Handle(SALOME_InteractiveObject) IObject = selected.First();
2217 if (IObject->hasEntry()) {
2218 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2220 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2221 if (!aSubMesh->_is_nil()) {
2223 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2224 // get submesh elements list by types
2225 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2226 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2227 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2228 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2229 // create group for each type o elements
2230 QString aName = IObject->getName();
2231 if (aNodes->length() > 0) {
2232 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2233 aGroup->Add(aNodes.inout());
2235 if (aEdges->length() > 0) {
2236 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2237 aGroup->Add(aEdges.inout());
2239 if (aFaces->length() > 0) {
2240 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2241 aGroup->Add(aFaces.inout());
2243 if (aVolumes->length() > 0) {
2244 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2245 aGroup->Add(aVolumes.inout());
2250 catch(const SALOME::SALOME_Exception & S_ex){
2251 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2258 SUIT_MessageBox::warning(desktop(),
2259 tr("SMESH_WRN_WARNING"),
2260 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2265 case 803: // EDIT GROUP
2269 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2270 tr( "NOT_A_VTK_VIEWER" ) );
2274 if(checkLock(aStudy)) break;
2275 EmitSignalDeactivateDialog();
2277 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2278 SALOME_ListIO selected;
2280 aSel->selectedObjects( selected );
2282 SALOME_ListIteratorOfListIO It (selected);
2283 int nbSelectedGroups = 0;
2284 for ( ; It.More(); It.Next() )
2286 SMESH::SMESH_GroupBase_var aGroup =
2287 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2288 if (!aGroup->_is_nil()) {
2290 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2294 if (nbSelectedGroups == 0)
2296 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2302 case 804: // Add elements to group
2304 if(checkLock(aStudy)) break;
2305 if (myState == 800) {
2306 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2307 if (aDlg) aDlg->onAdd();
2312 case 805: // Remove elements from group
2314 if(checkLock(aStudy)) break;
2315 if (myState == 800) {
2316 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2317 if (aDlg) aDlg->onRemove();
2322 case 815: // Edit GEOM GROUP as standalone
2326 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2327 tr( "NOT_A_VTK_VIEWER" ) );
2331 if(checkLock(aStudy)) break;
2332 EmitSignalDeactivateDialog();
2334 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2335 SALOME_ListIO selected;
2337 aSel->selectedObjects( selected );
2339 SALOME_ListIteratorOfListIO It (selected);
2340 for ( ; It.More(); It.Next() )
2342 SMESH::SMESH_GroupOnGeom_var aGroup =
2343 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2344 if (!aGroup->_is_nil()) {
2345 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2352 case 810: // Union Groups
2353 case 811: // Intersect groups
2354 case 812: // Cut groups
2358 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2359 tr( "NOT_A_VTK_VIEWER" ) );
2363 if ( checkLock( aStudy ) )
2366 EmitSignalDeactivateDialog();
2368 SMESHGUI_GroupOpDlg* aDlg = 0;
2369 if ( theCommandID == 810 )
2370 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2371 else if ( theCommandID == 811 )
2372 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2374 aDlg = new SMESHGUI_CutGroupsDlg( this );
2381 case 814: // Create groups of entities from existing groups of superior dimensions
2383 if ( checkLock( aStudy ) )
2386 EmitSignalDeactivateDialog();
2387 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2393 case 813: // Delete groups with their contents
2397 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2398 tr( "NOT_A_VTK_VIEWER" ) );
2402 if ( checkLock( aStudy ) )
2405 EmitSignalDeactivateDialog();
2407 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2411 case 900: // MESH INFOS
2412 case 903: // WHAT IS
2414 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2415 EmitSignalDeactivateDialog();
2416 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2417 SALOME_ListIO selected;
2419 aSel->selectedObjects( selected );
2421 if ( selected.Extent() > 1 ) { // a dlg for each IO
2422 SALOME_ListIteratorOfListIO It( selected );
2423 for ( ; It.More(); It.Next() ) {
2424 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2425 dlg->showInfo( It.Value() );
2430 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2436 case 902: // STANDARD MESH INFOS
2438 EmitSignalDeactivateDialog();
2439 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2440 SALOME_ListIO selected;
2442 aSel->selectedObjects( selected );
2444 if ( selected.Extent() > 1 ) { // a dlg for each IO
2446 SALOME_ListIteratorOfListIO It (selected);
2447 for ( ; It.More(); It.Next() ) {
2449 IOs.Append( It.Value() );
2450 aSel->setSelectedObjects( IOs );
2451 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2453 // restore selection
2454 aSel->setSelectedObjects( selected );
2457 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2460 case 903: // WHAT IS
2462 EmitSignalDeactivateDialog();
2463 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2468 case 904: // FIND ELEM
2470 startOperation( theCommandID );
2474 case 1100: // EDIT HYPOTHESIS
2476 if(checkLock(aStudy)) break;
2478 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2479 SALOME_ListIO selected;
2481 aSel->selectedObjects( selected );
2483 int nbSel = selected.Extent();
2486 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2487 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2489 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2490 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2491 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2492 if ( !aHypothesis->_is_nil() )
2495 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2496 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2498 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2509 case 1101: // RENAME
2511 if ( checkLock( aStudy ) )
2514 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2515 SALOME_ListIO selected;
2517 aSel->selectedObjects( selected );
2519 bool isAny = false; // is there any appropriate object selected
2521 SALOME_ListIteratorOfListIO It( selected );
2522 for ( ; It.More(); It.Next() )
2524 Handle(SALOME_InteractiveObject) IObject = It.Value();
2525 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2526 _PTR(GenericAttribute) anAttr;
2527 _PTR(AttributeName) aName;
2530 if ( obj->FindAttribute(anAttr, "AttributeName") )
2533 QString newName = QString(aName->Value().c_str());
2535 // check type to prevent renaming of inappropriate objects
2536 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2537 if (aType == MESH || aType == GROUP ||
2538 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2539 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2540 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2541 aType == HYPOTHESIS || aType == ALGORITHM)
2544 newName = LightApp_NameDlg::getName(desktop(), newName);
2545 if ( !newName.isEmpty() )
2547 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
2549 // update name of group object and its actor
2550 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2551 if( !aGroupObject->_is_nil() )
2553 aGroupObject->SetName( newName.toLatin1().data() );
2554 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) )
2555 anActor->setName( newName.toLatin1().data() );
2566 SUIT_MessageBox::warning(desktop(),
2567 QObject::tr("SMESH_WRN_WARNING"),
2568 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2573 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2575 if(checkLock(aStudy)) break;
2576 SUIT_OverrideCursor wc;
2578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2579 SALOME_ListIO selected;
2581 aSel->selectedObjects( selected, QString::null, false );
2583 SALOME_ListIteratorOfListIO It(selected);
2584 for (int i = 0; It.More(); It.Next(), i++) {
2585 Handle(SALOME_InteractiveObject) IObject = It.Value();
2586 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2589 aSel->setSelectedObjects( l1 );
2594 case 4009: // ELEM0D
2595 case 4010: // GEOM::EDGE
2596 case 4021: // TRIANGLE
2598 case 4023: // POLYGON
2602 if(checkLock(aStudy)) break;
2604 EmitSignalDeactivateDialog();
2605 SMDSAbs_ElementType type = SMDSAbs_Edge;
2607 switch (theCommandID) {
2608 case 4009: // ELEM0D
2609 type = SMDSAbs_0DElement; nbNodes = 1; break;
2610 case 4021: // TRIANGLE
2611 type = SMDSAbs_Face; nbNodes = 3; break;
2613 type = SMDSAbs_Face; nbNodes = 4; break;
2615 type = SMDSAbs_Volume; nbNodes = 4; break;
2616 case 4023: // POLYGON
2617 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2619 type = SMDSAbs_Volume; nbNodes = 8; break;
2620 case 4033: // POLYHEDRE
2621 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2624 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2627 SUIT_MessageBox::warning(desktop(),
2628 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2632 case 4033: // POLYHEDRON
2634 if(checkLock(aStudy)) break;
2636 EmitSignalDeactivateDialog();
2637 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2640 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2641 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2645 case 4034: // QUADRATIC EDGE
2646 case 4035: // QUADRATIC TRIANGLE
2647 case 4036: // QUADRATIC QUADRANGLE
2648 case 4037: // QUADRATIC TETRAHEDRON
2649 case 4038: // QUADRATIC PYRAMID
2650 case 4039: // QUADRATIC PENTAHEDRON
2651 case 4040: // QUADRATIC HEXAHEDRON
2653 if(checkLock(aStudy)) break;
2655 EmitSignalDeactivateDialog();
2658 switch (theCommandID) {
2660 type = QUAD_EDGE; break;
2662 type = QUAD_TRIANGLE; break;
2664 type = QUAD_QUADRANGLE; break;
2666 type = QUAD_TETRAHEDRON; break;
2668 type = QUAD_PYRAMID; break;
2670 type = QUAD_PENTAHEDRON; break;
2672 type = QUAD_HEXAHEDRON;
2676 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2679 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2680 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2684 case 4041: // REMOVES NODES
2686 if(checkLock(aStudy)) break;
2688 EmitSignalDeactivateDialog();
2689 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2692 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2693 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2697 case 4042: // REMOVES ELEMENTS
2699 if(checkLock(aStudy)) break;
2701 EmitSignalDeactivateDialog();
2702 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2706 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2707 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2711 case 4043: { // CLEAR_MESH
2713 if(checkLock(aStudy)) break;
2715 SALOME_ListIO selected;
2716 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2717 aSel->selectedObjects( selected );
2719 SUIT_OverrideCursor wc;
2720 SALOME_ListIteratorOfListIO It (selected);
2721 for ( ; It.More(); It.Next() )
2723 Handle(SALOME_InteractiveObject) IOS = It.Value();
2724 SMESH::SMESH_Mesh_var aMesh =
2725 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2726 if ( aMesh->_is_nil()) continue;
2728 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2730 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2731 SMESH::ModifiedMesh( aMeshSObj, false, true);
2732 // hide groups and submeshes
2733 _PTR(ChildIterator) anIter =
2734 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2735 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2737 _PTR(SObject) so = anIter->Value();
2738 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2741 catch (const SALOME::SALOME_Exception& S_ex){
2743 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2747 SMESH::UpdateView();
2751 case 4044: // REMOVE ORPHAN NODES
2753 if(checkLock(aStudy)) break;
2754 SALOME_ListIO selected;
2755 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2756 aSel->selectedObjects( selected );
2757 if ( selected.Extent() == 1 ) {
2758 Handle(SALOME_InteractiveObject) anIO = selected.First();
2759 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2760 if ( !aMesh->_is_nil() ) {
2761 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2762 tr( "SMESH_WARNING" ),
2763 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2764 SUIT_MessageBox::Yes |
2765 SUIT_MessageBox::No,
2766 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2769 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2770 int removed = aMeshEditor->RemoveOrphanNodes();
2771 SUIT_MessageBox::information(SMESHGUI::desktop(),
2772 tr("SMESH_INFORMATION"),
2773 tr("NB_NODES_REMOVED").arg(removed));
2774 if ( removed > 0 ) {
2775 SMESH::UpdateView();
2776 SMESHGUI::Modified();
2779 catch (const SALOME::SALOME_Exception& S_ex) {
2780 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2789 case 4051: // RENUMBERING NODES
2791 if(checkLock(aStudy)) break;
2793 EmitSignalDeactivateDialog();
2794 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2798 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2799 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2803 case 4052: // RENUMBERING ELEMENTS
2805 if(checkLock(aStudy)) break;
2807 EmitSignalDeactivateDialog();
2808 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2812 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2813 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2817 case 4061: // TRANSLATION
2819 if(checkLock(aStudy)) break;
2821 EmitSignalDeactivateDialog();
2822 ( new SMESHGUI_TranslationDlg( this ) )->show();
2825 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2826 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2830 case 4062: // ROTATION
2832 if(checkLock(aStudy)) break;
2834 EmitSignalDeactivateDialog();
2835 ( new SMESHGUI_RotationDlg( this ) )->show();
2838 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2839 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2843 case 4063: // SYMMETRY
2845 if(checkLock(aStudy)) break;
2847 EmitSignalDeactivateDialog();
2848 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2851 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2852 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2856 case 4064: // SEWING
2858 if(checkLock(aStudy)) break;
2860 EmitSignalDeactivateDialog();
2861 ( new SMESHGUI_SewingDlg( this ) )->show();
2864 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2865 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2869 case 4065: // MERGE NODES
2871 if(checkLock(aStudy)) break;
2873 EmitSignalDeactivateDialog();
2874 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
2877 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2878 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2882 case 4066: // MERGE EQUAL ELEMENTS
2884 if (checkLock(aStudy)) break;
2886 EmitSignalDeactivateDialog();
2887 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
2889 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2890 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2895 case 4067: // MAKE MESH PASS THROUGH POINT
2896 startOperation( 4067 );
2901 if(checkLock(aStudy)) break;
2903 EmitSignalDeactivateDialog();
2904 ( new SMESHGUI_ScaleDlg( this ) )->show();
2907 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2908 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2913 case 4069: // DUPLICATE NODES
2915 if(checkLock(aStudy)) break;
2917 EmitSignalDeactivateDialog();
2918 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
2921 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2927 case 5105: // Library of selection filters
2929 static QList<int> aTypes;
2930 if ( aTypes.isEmpty() )
2932 aTypes.append( SMESH::NODE );
2933 aTypes.append( SMESH::EDGE );
2934 aTypes.append( SMESH::FACE );
2935 aTypes.append( SMESH::VOLUME );
2937 if (!myFilterLibraryDlg)
2938 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2939 else if (myFilterLibraryDlg->isHidden())
2940 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2941 myFilterLibraryDlg->raise();
2945 case 6017: // CONTROLS
2965 LightApp_SelectionMgr* mgr = selectionMgr();
2966 SALOME_ListIO selected; mgr->selectedObjects( selected );
2968 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2969 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2971 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2972 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2973 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2974 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2975 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2976 ::Control( theCommandID );
2981 SUIT_MessageBox::warning(desktop(),
2982 tr( "SMESH_WRN_WARNING" ),
2983 tr( "SMESH_BAD_SELECTION" ) );
2987 SUIT_MessageBox::warning(desktop(),
2988 tr( "SMESH_WRN_WARNING" ),
2989 tr( "NOT_A_VTK_VIEWER" ) );
2994 LightApp_SelectionMgr* mgr = selectionMgr();
2995 SALOME_ListIO selected; mgr->selectedObjects( selected );
2997 SALOME_ListIteratorOfListIO it(selected);
2998 for( ; it.More(); it.Next()) {
2999 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3000 if(anIObject->hasEntry()) {
3001 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3002 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3010 LightApp_SelectionMgr* mgr = selectionMgr();
3011 SALOME_ListIO selected; mgr->selectedObjects( selected );
3013 SALOME_ListIteratorOfListIO it(selected);
3014 for( ; it.More(); it.Next()) {
3015 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3016 if(anIObject->hasEntry())
3017 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3018 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3026 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3027 EmitSignalDeactivateDialog();
3028 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3034 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3035 //updateObjBrowser();
3039 //=============================================================================
3043 //=============================================================================
3044 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3049 //=============================================================================
3053 //=============================================================================
3054 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3059 //=============================================================================
3063 //=============================================================================
3064 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3069 //=============================================================================
3070 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3071 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3073 //=============================================================================
3074 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3075 SUIT_ViewWindow* wnd )
3077 if(theIO->hasEntry()){
3078 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3079 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3083 //=======================================================================
3084 // function : createSMESHAction
3086 //=======================================================================
3087 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3088 const int key, const bool toggle, const QString& shortcutAction )
3091 QWidget* parent = application()->desktop();
3092 SUIT_ResourceMgr* resMgr = resourceMgr();
3094 if ( !icon_id.isEmpty() )
3095 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3097 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3098 if ( !pix.isNull() )
3099 icon = QIcon( pix );
3101 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3102 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3103 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3105 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3106 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3109 //=======================================================================
3110 // function : createPopupItem
3112 //=======================================================================
3113 void SMESHGUI::createPopupItem( const int id,
3114 const QString& clients,
3115 const QString& types,
3116 const QString& theRule,
3121 parentId = popupMgr()->actionId( action( pId ) );
3123 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3124 popupMgr()->insert( action( id ), parentId, 0 );
3126 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3127 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3128 QString rule = "(%1) and (%2) and (%3)";
3129 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3130 if( clients.isEmpty() )
3131 rule = rule.arg( QString( "true" ) );
3133 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3134 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3137 bool cont = myRules.contains( id );
3139 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3141 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3142 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3145 //=======================================================================
3146 // function : initialize
3148 //=======================================================================
3149 void SMESHGUI::initialize( CAM_Application* app )
3151 SalomeApp_Module::initialize( app );
3153 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3155 /* Automatic Update flag */
3156 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3158 // ----- create actions --------------
3160 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3161 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3162 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3163 createSMESHAction( 114, "NUM" );
3164 createSMESHAction( 121, "DAT" );
3165 createSMESHAction( 122, "MED" );
3166 createSMESHAction( 123, "UNV" );
3167 createSMESHAction( 140, "STL" );
3168 createSMESHAction( 124, "EXPORT_DAT" );
3169 createSMESHAction( 125, "EXPORT_MED" );
3170 createSMESHAction( 126, "EXPORT_UNV" );
3171 createSMESHAction( 141, "EXPORT_STL" );
3172 createSMESHAction( 150, "FILE_INFO" );
3173 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3174 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3175 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3176 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3177 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3178 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3179 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3180 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3181 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3182 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3183 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3184 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3185 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3186 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3187 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3188 createSMESHAction( 804, "ADD" );
3189 createSMESHAction( 805, "REMOVE" );
3190 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3191 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3192 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3193 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3194 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3195 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3196 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3197 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
3198 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3199 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3200 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3201 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3202 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3203 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3204 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3205 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3206 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3207 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3208 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3209 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3210 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3211 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3212 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3213 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3214 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3215 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3216 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3217 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3218 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3219 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3220 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3221 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3222 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3223 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3224 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3225 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3226 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3227 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3228 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3229 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3230 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3231 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3232 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3233 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3234 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3235 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3236 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3237 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3238 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3239 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3240 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3241 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3242 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3243 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3244 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3245 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3246 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3247 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3248 createSMESHAction( 415, "MAP", "ICON_MAP" );
3249 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3250 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3251 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3252 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3253 createSMESHAction( 200, "RESET" );
3254 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3255 createSMESHAction( 202, "SAVE_DISTRIBUTION" );
3256 createSMESHAction( 203, "SHOW_DISTRIBUTION","",0, true );
3257 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3258 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3259 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3260 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3261 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3262 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3263 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3264 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3265 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3266 createSMESHAction( 220, "ALL" );
3267 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3269 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3270 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3272 createSMESHAction( 1100, "EDIT_HYPO" );
3273 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
3274 createSMESHAction( 1102, "UNASSIGN" );
3275 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3276 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3277 createSMESHAction( 1131, "DISPMODE" );
3278 createSMESHAction( 1132, "COLORS" );
3279 createSMESHAction( 1133, "TRANSP" );
3280 createSMESHAction( 1134, "CLIP" );
3281 createSMESHAction( 1135, "DISP_ENT" );
3282 createSMESHAction( 1136, "AUTO_COLOR" );
3283 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3284 createSMESHAction( 2000, "CTRL" );
3286 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3287 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3289 createSMESHAction( 300, "ERASE" );
3290 createSMESHAction( 301, "DISPLAY" );
3291 createSMESHAction( 302, "DISPLAY_ONLY" );
3292 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3293 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3294 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3295 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3296 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3297 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3298 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3299 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3301 // ----- create menu --------------
3302 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3303 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3304 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3305 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3306 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3307 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3308 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3309 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3311 createMenu( separator(), fileId );
3313 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3314 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3315 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3316 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3317 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3318 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3319 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3320 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3321 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3322 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3324 createMenu( 111, importId, -1 );
3325 createMenu( 112, importId, -1 );
3326 createMenu( 113, importId, -1 );
3328 createMenu( 121, exportId, -1 );
3329 createMenu( 122, exportId, -1 );
3330 createMenu( 123, exportId, -1 );
3331 createMenu( 140, exportId, -1 ); // export to stl STL
3333 createMenu( separator(), fileId, 10 );
3335 createMenu( 33, editId, -1 );
3337 createMenu( 5105, toolsId, -1 );
3339 createMenu( 702, meshId, -1 ); // "Mesh" menu
3340 createMenu( 703, meshId, -1 );
3341 createMenu( 704, meshId, -1 );
3342 createMenu( 710, meshId, -1 );
3343 createMenu( separator(), meshId, -1 );
3344 createMenu( 701, meshId, -1 );
3345 createMenu( 711, meshId, -1 );
3346 createMenu( 712, meshId, -1 );
3347 createMenu( 713, meshId, -1 );
3348 createMenu( separator(), meshId, -1 );
3349 createMenu( 801, meshId, -1 );
3350 createMenu( 806, meshId, -1 );
3351 createMenu( 802, meshId, -1 );
3352 createMenu( 803, meshId, -1 );
3353 createMenu( 815, meshId, -1 );
3354 createMenu( separator(), meshId, -1 );
3355 createMenu( 810, meshId, -1 );
3356 createMenu( 811, meshId, -1 );
3357 createMenu( 812, meshId, -1 );
3358 createMenu( separator(), meshId, -1 );
3359 createMenu( 814, meshId, -1 );
3360 createMenu( separator(), meshId, -1 );
3361 createMenu( 813, meshId, -1 );
3362 createMenu( separator(), meshId, -1 );
3363 createMenu( 900, meshId, -1 );
3364 //createMenu( 902, meshId, -1 );
3365 createMenu( 903, meshId, -1 );
3366 createMenu( 904, meshId, -1 );
3367 createMenu( separator(), meshId, -1 );
3369 createMenu( 6005, nodeId, -1 );
3370 createMenu( 6002, edgeId, -1 );
3371 createMenu( 6003, edgeId, -1 );
3372 createMenu( 6001, edgeId, -1 );
3373 createMenu( 6004, edgeId, -1 );
3374 createMenu( 6021, faceId, -1 );
3375 createMenu( 6018, faceId, -1 );
3376 createMenu( 6019, faceId, -1 );
3377 createMenu( 6011, faceId, -1 );
3378 createMenu( 6012, faceId, -1 );
3379 createMenu( 6013, faceId, -1 );
3380 createMenu( 6014, faceId, -1 );
3381 createMenu( 6015, faceId, -1 );
3382 createMenu( 6016, faceId, -1 );
3383 createMenu( 6022, faceId, -1 );
3384 createMenu( 6017, volumeId, -1 );
3385 createMenu( 6009, volumeId, -1 );
3386 createMenu( 6023, volumeId, -1 );
3388 createMenu( 4000, addId, -1 );
3389 createMenu( 4009, addId, -1 );
3390 createMenu( 4010, addId, -1 );
3391 createMenu( 4021, addId, -1 );
3392 createMenu( 4022, addId, -1 );
3393 createMenu( 4023, addId, -1 );
3394 createMenu( 4031, addId, -1 );
3395 createMenu( 4032, addId, -1 );
3396 createMenu( 4033, addId, -1 );
3397 createMenu( separator(), addId, -1 );
3398 createMenu( 4034, addId, -1 );
3399 createMenu( 4035, addId, -1 );
3400 createMenu( 4036, addId, -1 );
3401 createMenu( 4037, addId, -1 );
3402 createMenu( 4038, addId, -1 );
3403 createMenu( 4039, addId, -1 );
3404 createMenu( 4040, addId, -1 );
3406 createMenu( 4041, removeId, -1 );
3407 createMenu( 4042, removeId, -1 );
3408 createMenu( 4044, removeId, -1 );
3409 createMenu( separator(), removeId, -1 );
3410 createMenu( 4043, removeId, -1 );
3412 createMenu( 4051, renumId, -1 );
3413 createMenu( 4052, renumId, -1 );
3415 createMenu( 4061, transfId, -1 );
3416 createMenu( 4062, transfId, -1 );
3417 createMenu( 4063, transfId, -1 );
3418 createMenu( 4064, transfId, -1 );
3419 createMenu( 4065, transfId, -1 );
3420 createMenu( 4066, transfId, -1 );
3421 createMenu( 4068, transfId, -1 );
3422 createMenu( 4069, transfId, -1 );
3424 createMenu( 4067,modifyId, -1 );
3425 createMenu( 407, modifyId, -1 );
3426 createMenu( 408, modifyId, -1 );
3427 createMenu( 409, modifyId, -1 );
3428 createMenu( 410, modifyId, -1 );
3429 createMenu( 411, modifyId, -1 );
3430 createMenu( 419, modifyId, -1 );
3431 createMenu( 412, modifyId, -1 );
3432 createMenu( 413, modifyId, -1 );
3433 createMenu( 416, modifyId, -1 );
3434 createMenu( 414, modifyId, -1 );
3435 createMenu( 415, modifyId, -1 );
3436 createMenu( 417, modifyId, -1 );
3437 createMenu( 418, modifyId, -1 );
3439 createMenu( 501, measureId, -1 );
3440 createMenu( 502, measureId, -1 );
3441 createMenu( 214, viewId, -1 );
3443 // ----- create toolbars --------------
3444 int meshTb = createTool( tr( "TB_MESH" ) ),
3445 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3446 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3447 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3448 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3450 createTool( 702, meshTb );
3451 createTool( 703, meshTb );
3452 createTool( 704, meshTb );
3453 createTool( 710, meshTb );
3454 createTool( separator(), meshTb );
3455 createTool( 701, meshTb );
3456 createTool( 711, meshTb );
3457 createTool( 712, meshTb );
3458 createTool( 713, meshTb );
3459 createTool( separator(), meshTb );
3460 createTool( 801, meshTb );
3461 createTool( 806, meshTb );
3462 createTool( 802, meshTb );
3463 createTool( 803, meshTb );
3464 //createTool( 815, meshTb );
3465 createTool( separator(), meshTb );
3466 createTool( 900, meshTb );
3467 //createTool( 902, meshTb );
3468 createTool( 903, meshTb );
3469 createTool( 904, meshTb );
3470 createTool( separator(), meshTb );
3472 createTool( 6005, ctrlTb );
3473 createTool( separator(), ctrlTb );
3474 createTool( 6002, ctrlTb );
3475 createTool( 6003, ctrlTb );
3476 createTool( 6001, ctrlTb );
3477 createTool( 6004, ctrlTb );
3478 createTool( separator(), ctrlTb );
3479 createTool( 6021, ctrlTb );
3480 createTool( 6018, ctrlTb );
3481 createTool( 6019, ctrlTb );
3482 createTool( 6011, ctrlTb );
3483 createTool( 6012, ctrlTb );
3484 createTool( 6013, ctrlTb );
3485 createTool( 6014, ctrlTb );
3486 createTool( 6015, ctrlTb );
3487 createTool( 6016, ctrlTb );
3488 createTool( 6022, ctrlTb );
3489 createTool( separator(), ctrlTb );
3490 createTool( 6017, ctrlTb );
3491 createTool( 6009, ctrlTb );
3492 createTool( 6023, ctrlTb );
3493 createTool( separator(), ctrlTb );
3495 createTool( 4000, addRemTb );
3496 createTool( 4009, addRemTb );
3497 createTool( 4010, addRemTb );
3498 createTool( 4021, addRemTb );
3499 createTool( 4022, addRemTb );
3500 createTool( 4023, addRemTb );
3501 createTool( 4031, addRemTb );
3502 createTool( 4032, addRemTb );
3503 createTool( 4033, addRemTb );
3504 createTool( separator(), addRemTb );
3505 createTool( 4034, addRemTb );
3506 createTool( 4035, addRemTb );
3507 createTool( 4036, addRemTb );
3508 createTool( 4037, addRemTb );
3509 createTool( 4038, addRemTb );
3510 createTool( 4039, addRemTb );
3511 createTool( 4040, addRemTb );
3512 createTool( separator(), addRemTb );
3513 createTool( 4041, addRemTb );
3514 createTool( 4042, addRemTb );
3515 createTool( 4044, addRemTb );
3516 createTool( 4043, addRemTb );
3517 createTool( separator(), addRemTb );
3518 createTool( 4051, addRemTb );
3519 createTool( 4052, addRemTb );
3520 createTool( separator(), addRemTb );
3521 createTool( 4061, addRemTb );
3522 createTool( 4062, addRemTb );
3523 createTool( 4063, addRemTb );
3524 createTool( 4064, addRemTb );
3525 createTool( 4065, addRemTb );
3526 createTool( 4066, addRemTb );
3527 createTool( 4068, addRemTb );
3528 createTool( 4069, addRemTb );
3529 createTool( separator(), addRemTb );
3531 createTool( 4067,modifyTb );
3532 createTool( 407, modifyTb );
3533 createTool( 408, modifyTb );
3534 createTool( 409, modifyTb );
3535 createTool( 410, modifyTb );
3536 createTool( 411, modifyTb );
3537 createTool( 419, modifyTb );
3538 createTool( 412, modifyTb );
3539 createTool( 413, modifyTb );
3540 createTool( 416, modifyTb );
3541 createTool( 414, modifyTb );
3542 createTool( 415, modifyTb );
3543 createTool( 417, modifyTb );
3544 createTool( 418, modifyTb );
3546 createTool( 214, dispModeTb );
3548 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3549 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3552 QString OB = "'ObjectBrowser'",
3553 View = "'" + SVTK_Viewer::Type() + "'",
3555 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3556 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3557 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3558 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3559 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3560 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3561 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3562 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3563 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3564 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3565 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3567 mesh_group = mesh + " " + subMesh + " " + group,
3568 hyp_alg = hypo + " " + algo;
3570 // popup for object browser
3572 isInvisible("not( isVisible )"),
3573 isEmpty("numberOfNodes = 0"),
3574 isNotEmpty("numberOfNodes <> 0"),
3576 // has nodes, edges, etc in VISIBLE! actor
3577 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3578 hasElems("(count( elemTypes ) > 0)"),
3579 hasDifferentElems("(count( elemTypes ) > 1)"),
3580 hasElems0d("({'Elem0d'} in elemTypes)"),
3581 hasEdges("({'Edge'} in elemTypes)"),
3582 hasFaces("({'Face'} in elemTypes)"),
3583 hasVolumes("({'Volume'} in elemTypes)");
3585 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3586 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3587 //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
3588 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3589 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3590 createPopupItem( 803, OB, group ); // EDIT_GROUP
3591 createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
3593 popupMgr()->insert( separator(), -1, 0 );
3594 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3595 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3596 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3597 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3598 createPopupItem( 214, OB, mesh_group ); // UPDATE
3599 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
3600 //createPopupItem( 902, OB, mesh ); // STD_INFO
3601 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
3602 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3603 popupMgr()->insert( separator(), -1, 0 );
3604 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3605 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3606 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3607 popupMgr()->insert( separator(), -1, 0 );
3608 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3609 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3610 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
3611 popupMgr()->insert( separator(), -1, 0 );
3612 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3613 popupMgr()->insert( separator(), -1, 0 );
3614 createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic
3615 createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
3616 popupMgr()->insert( separator(), -1, 0 );
3618 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3619 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3621 createPopupItem( 125, OB, mesh, multiple_non_empty ); // EXPORT_MED
3622 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
3623 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
3624 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
3625 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
3626 popupMgr()->insert( separator(), -1, 0 );
3629 createPopupItem( 803, View, group ); // EDIT_GROUP
3630 createPopupItem( 804, View, elems ); // ADD
3631 createPopupItem( 805, View, elems ); // REMOVE
3633 popupMgr()->insert( separator(), -1, 0 );
3634 createPopupItem( 214, View, mesh_group ); // UPDATE
3635 createPopupItem( 900, View, mesh_group ); // ADV_INFO
3636 //createPopupItem( 902, View, mesh ); // STD_INFO
3637 createPopupItem( 903, View, mesh_group ); // WHAT_IS
3638 createPopupItem( 904, View, mesh_group ); // FIND_ELEM
3639 popupMgr()->insert( separator(), -1, 0 );
3641 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3642 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3643 popupMgr()->insert( separator(), -1, 0 );
3646 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3647 QString aType = QString( "%1type in {%2}" ).arg( lc );
3648 aType = aType.arg( mesh_group );
3649 QString aMeshInVTK = aClient + "&&" + aType;
3651 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3652 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3653 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3655 //-------------------------------------------------
3657 //-------------------------------------------------
3658 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3660 popupMgr()->insert( action( 9010 ), anId, -1 );
3661 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3662 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3664 popupMgr()->insert( action( 9011 ), anId, -1 );
3665 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3666 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3668 popupMgr()->insert( separator(), -1, -1 );
3670 //-------------------------------------------------
3672 //-------------------------------------------------
3673 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3675 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3676 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3677 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3679 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3680 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3681 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3683 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3684 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3685 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3687 popupMgr()->insert( separator(), anId, -1 );
3689 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3690 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3691 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3693 //-------------------------------------------------
3695 //-------------------------------------------------
3696 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3698 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3700 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3701 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3702 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3704 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3705 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3706 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3708 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3709 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3710 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3712 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3713 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3714 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3716 popupMgr()->insert( separator(), anId, -1 );
3718 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3719 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3722 //-------------------------------------------------
3723 // Representation of the 2D Quadratic elements
3724 //-------------------------------------------------
3725 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3726 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3727 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3728 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3730 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3731 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3732 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3734 //-------------------------------------------------
3735 // Orientation of faces
3736 //-------------------------------------------------
3737 popupMgr()->insert( action( 221 ), -1, -1 );
3738 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3739 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3741 //-------------------------------------------------
3743 //-------------------------------------------------
3744 popupMgr()->insert( action( 1132 ), -1, -1 );
3745 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3747 //-------------------------------------------------
3749 //-------------------------------------------------
3750 popupMgr()->insert( action( 1133 ), -1, -1 );
3751 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3753 //-------------------------------------------------
3755 //-------------------------------------------------
3757 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3758 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3759 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3760 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3762 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3764 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3765 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3767 popupMgr()->insert( separator(), anId, -1 );
3769 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3771 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3772 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3773 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3775 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3777 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3778 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3779 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3781 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3782 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3783 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3785 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3786 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3787 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3789 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3790 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3791 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3793 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3795 popupMgr()->insert( action( 6021 ), aSubId, -1 ); // FREE_FACE
3796 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3797 QtxPopupMgr::VisibleRule );
3798 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3800 popupMgr()->insert( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3801 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3802 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3804 popupMgr()->insert( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3805 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3806 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3808 popupMgr()->insert( action( 6011 ), aSubId, -1 ); // AREA
3809 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3810 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3812 popupMgr()->insert( action( 6012 ), aSubId, -1 ); // TAPER
3813 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3814 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3816 popupMgr()->insert( action( 6013 ), aSubId, -1 ); // ASPECT
3817 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3818 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3820 popupMgr()->insert( action( 6014 ), aSubId, -1 ); // MIN_ANG
3821 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3822 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3824 popupMgr()->insert( action( 6015 ), aSubId, -1 ); // WARP
3825 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3826 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3828 popupMgr()->insert( action( 6016 ), aSubId, -1 ); // SKEW
3829 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3830 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3832 popupMgr()->insert( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
3833 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3834 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
3836 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
3838 popupMgr()->insert( action( 6017 ), aSubId, -1 ); // ASPECT_3D
3839 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3840 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3842 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
3843 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3844 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3846 popupMgr()->insert( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
3847 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3848 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
3850 popupMgr()->insert( separator(), anId, -1 );
3852 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3853 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3855 popupMgr()->insert( separator(), anId, -1 );
3857 popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
3858 popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3860 popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
3861 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
3862 popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
3865 popupMgr()->insert( separator(), -1, -1 );
3867 //-------------------------------------------------
3869 //-------------------------------------------------
3870 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3871 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3872 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3873 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3875 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3876 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3878 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3879 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3881 popupMgr()->insert( separator(), -1, -1 );
3883 //-------------------------------------------------
3885 //-------------------------------------------------
3886 popupMgr()->insert( action( 1134 ), -1, -1 );
3887 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
3889 popupMgr()->insert( separator(), -1, -1 );
3891 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3892 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3894 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
3895 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
3898 //================================================================================
3900 * \brief Return true if SMESH or GEOM objects are selected.
3901 * Is called form LightApp_Module::activateModule() which clear selection if
3902 * not isSelectionCompatible()
3904 //================================================================================
3906 bool SMESHGUI::isSelectionCompatible()
3908 bool isCompatible = true;
3909 SALOME_ListIO selected;
3910 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3911 Sel->selectedObjects( selected );
3913 SALOME_ListIteratorOfListIO It( selected );
3914 for ( ; isCompatible && It.More(); It.Next())
3916 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3917 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3919 return isCompatible;
3923 bool SMESHGUI::reusableOperation( const int id )
3925 // compute, evaluate and precompute are not reusable operations
3926 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
3929 bool SMESHGUI::activateModule( SUIT_Study* study )
3931 bool res = SalomeApp_Module::activateModule( study );
3933 setMenuShown( true );
3934 setToolShown( true );
3936 // Reset actions accelerator keys
3937 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3938 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3939 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3941 action( 33)->setEnabled(true); // Delete: Key_Delete
3942 action(1101)->setEnabled(true); // Rename: Key_F2
3944 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
3945 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
3946 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
3947 if ( _PTR(Study) aStudy = s->studyDS()) {
3948 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
3949 updateObjBrowser(); // objects can be removed
3955 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3957 setMenuShown( false );
3958 setToolShown( false );
3960 EmitSignalCloseAllDialogs();
3962 // Unset actions accelerator keys
3963 action(111)->setShortcut(QKeySequence()); // Import DAT
3964 action(112)->setShortcut(QKeySequence()); // Import UNV
3965 action(113)->setShortcut(QKeySequence()); // Import MED
3967 action( 33)->setEnabled(false); // Delete: Key_Delete
3968 action(1101)->setEnabled(false); // Rename: Key_F2
3970 return SalomeApp_Module::deactivateModule( study );
3973 void SMESHGUI::studyClosed( SUIT_Study* s )
3975 SMESH::RemoveVisuData( s->id() );
3976 SalomeApp_Module::studyClosed( s );
3979 void SMESHGUI::OnGUIEvent()
3981 const QObject* obj = sender();
3982 if ( !obj || !obj->inherits( "QAction" ) )
3984 int id = actionId((QAction*)obj);
3989 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3991 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3992 if ( CORBA::is_nil( myComponentSMESH ) )
3994 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3996 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3997 return aGUI.myComponentSMESH;
4000 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4001 return myComponentSMESH;
4004 QString SMESHGUI::engineIOR() const
4006 CORBA::ORB_var anORB = getApp()->orb();
4007 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4008 return QString( anIOR.in() );
4011 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4013 SalomeApp_Module::contextMenuPopup( client, menu, title );
4015 selectionMgr()->selectedObjects( lst );
4016 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4017 Handle(SALOME_InteractiveObject) io = lst.First();
4018 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4019 _PTR(Study) study = appStudy->studyDS();
4020 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4022 QString aName = QString( obj->GetName().c_str() );
4023 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4024 aName.remove( (aName.length() - 1), 1 );
4030 LightApp_Selection* SMESHGUI::createSelection() const
4032 return new SMESHGUI_Selection();
4035 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4037 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4038 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4041 void SMESHGUI::viewManagers( QStringList& list ) const
4043 list.append( SVTK_Viewer::Type() );
4046 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4048 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
4049 SMESH::UpdateSelectionProp( this );
4052 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4054 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4055 myClippingPlaneInfoMap.erase( theViewManager );
4058 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4060 theActor->AddObserver( SMESH::DeleteActorEvent,
4061 myEventCallbackCommand.GetPointer(),
4065 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4066 unsigned long theEvent,
4067 void* theClientData,
4070 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4071 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4072 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4073 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4074 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4075 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4076 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4077 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4078 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4079 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4080 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4081 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4082 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4083 if( anActor == *anIter3 ) {
4084 anActorList.erase( anIter3 );
4095 void SMESHGUI::createPreferences()
4097 // General tab ------------------------------------------------------------------------
4098 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4100 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4101 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4102 setPreferenceProperty( lim, "min", 0 );
4103 setPreferenceProperty( lim, "max", 100000000 );
4104 setPreferenceProperty( lim, "step", 1000 );
4105 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4107 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4108 setPreferenceProperty( qaGroup, "columns", 2 );
4109 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4110 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4111 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4112 setPreferenceProperty( prec, "min", 0 );
4113 setPreferenceProperty( prec, "max", 16 );
4115 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4116 setPreferenceProperty( dispgroup, "columns", 2 );
4117 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4119 modes.append( "Wireframe" );
4120 modes.append( "Shading" );
4121 modes.append( "Nodes" );
4122 modes.append( "Shrink" );
4123 QList<QVariant> indices;
4124 indices.append( 0 );
4125 indices.append( 1 );
4126 indices.append( 2 );
4127 indices.append( 3 );
4128 setPreferenceProperty( dispmode, "strings", modes );
4129 setPreferenceProperty( dispmode, "indexes", indices );
4131 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4132 setPreferenceProperty( arcgroup, "columns", 2 );
4133 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4134 QStringList quadraticModes;
4135 quadraticModes.append("Lines");
4136 quadraticModes.append("Arcs");
4138 indices.append( 0 );
4139 indices.append( 1 );
4140 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4141 setPreferenceProperty( quadraticmode, "indexes", indices );
4143 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4144 "SMESH", "max_angle" );
4145 setPreferenceProperty( maxAngle, "min", 1 );
4146 setPreferenceProperty( maxAngle, "max", 90 );
4150 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4151 setPreferenceProperty( exportgroup, "columns", 2 );
4152 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4153 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4155 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4156 setPreferenceProperty( computeGroup, "columns", 2 );
4157 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4159 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4160 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4161 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4163 indices.append( 0 );
4164 indices.append( 1 );
4165 indices.append( 2 );
4166 setPreferenceProperty( notifyMode, "strings", modes );
4167 setPreferenceProperty( notifyMode, "indexes", indices );
4169 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4170 setPreferenceProperty( computeGroup, "columns", 2 );
4171 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4173 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4174 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4176 indices.append( 0 );
4177 indices.append( 1 );
4178 setPreferenceProperty( elemInfo, "strings", modes );
4179 setPreferenceProperty( elemInfo, "indexes", indices );
4181 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4182 setPreferenceProperty( segGroup, "columns", 2 );
4183 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4184 "SMESH", "segmentation" );
4185 setPreferenceProperty( segLen, "min", 1 );
4186 setPreferenceProperty( segLen, "max", 10000000 );
4187 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4188 "SMESH", "nb_segments_per_edge" );
4189 setPreferenceProperty( nbSeg, "min", 1 );
4190 setPreferenceProperty( nbSeg, "max", 10000000 );
4192 // Quantities with individual precision settings
4193 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4194 setPreferenceProperty( precGroup, "columns", 2 );
4196 const int nbQuantities = 6;
4197 int precs[nbQuantities], ii = 0;
4198 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4199 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4200 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4201 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4202 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4203 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4204 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4205 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4206 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4207 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4208 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4209 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4211 // Set property for precision value for spinboxes
4212 for ( ii = 0; ii < nbQuantities; ii++ ){
4213 setPreferenceProperty( precs[ii], "min", -14 );
4214 setPreferenceProperty( precs[ii], "max", 14 );
4215 setPreferenceProperty( precs[ii], "precision", 2 );
4218 // Mesh tab ------------------------------------------------------------------------
4219 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4220 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4221 setPreferenceProperty( nodeGroup, "columns", 3 );
4223 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4225 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4227 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4228 QList<QVariant> aMarkerTypeIndicesList;
4229 QList<QVariant> aMarkerTypeIconsList;
4230 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4231 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4232 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4233 aMarkerTypeIndicesList << i;
4234 aMarkerTypeIconsList << pixmap;
4236 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4237 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4239 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4241 QList<QVariant> aMarkerScaleIndicesList;
4242 QStringList aMarkerScaleValuesList;
4243 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4244 aMarkerScaleIndicesList << i;
4245 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4247 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4248 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4250 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4251 setPreferenceProperty( elemGroup, "columns", 2 );
4253 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4254 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4255 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4256 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4258 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4259 setPreferenceProperty( grpGroup, "columns", 2 );
4261 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4263 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4264 //setPreferenceProperty( sp, "hstretch", 0 );
4265 //setPreferenceProperty( sp, "vstretch", 0 );
4267 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4268 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4269 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4270 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4271 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4272 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4273 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4275 setPreferenceProperty( size0d, "min", 1 );
4276 setPreferenceProperty( size0d, "max", 10 );
4278 setPreferenceProperty( sp, "hstretch", 0 );
4279 setPreferenceProperty( sp, "vstretch", 0 );
4281 setPreferenceProperty( elemW, "min", 1 );
4282 setPreferenceProperty( elemW, "max", 5 );
4284 setPreferenceProperty( shrink, "min", 0 );
4285 setPreferenceProperty( shrink, "max", 100 );
4287 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4288 setPreferenceProperty( orientGroup, "columns", 1 );
4290 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4291 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4293 setPreferenceProperty( orientScale, "min", 0.05 );
4294 setPreferenceProperty( orientScale, "max", 0.5 );
4295 setPreferenceProperty( orientScale, "step", 0.05 );
4297 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4299 // Selection tab ------------------------------------------------------------------------
4300 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4302 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4303 setPreferenceProperty( selGroup, "columns", 2 );
4305 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4306 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4307 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4309 setPreferenceProperty( selW, "min", 1 );
4310 setPreferenceProperty( selW, "max", 5 );
4312 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4313 setPreferenceProperty( preGroup, "columns", 2 );
4315 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4316 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4318 setPreferenceProperty( preW, "min", 1 );
4319 setPreferenceProperty( preW, "max", 5 );
4321 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4322 setPreferenceProperty( precSelGroup, "columns", 2 );
4324 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4325 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4326 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4328 // Scalar Bar tab ------------------------------------------------------------------------
4329 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4330 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4331 setPreferenceProperty( fontGr, "columns", 2 );
4333 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4334 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4336 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4337 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4339 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4340 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4342 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4343 setPreferenceProperty( numcol, "min", 2 );
4344 setPreferenceProperty( numcol, "max", 256 );
4346 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4347 setPreferenceProperty( numlab, "min", 2 );
4348 setPreferenceProperty( numlab, "max", 65 );
4350 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4351 setPreferenceProperty( orientGr, "columns", 2 );
4352 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4353 QStringList orients;
4354 orients.append( tr( "SMESH_VERTICAL" ) );
4355 orients.append( tr( "SMESH_HORIZONTAL" ) );
4356 indices.clear(); indices.append( 0 ); indices.append( 1 );
4357 setPreferenceProperty( orient, "strings", orients );
4358 setPreferenceProperty( orient, "indexes", indices );
4360 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4361 setPreferenceProperty( posVSizeGr, "columns", 2 );
4362 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4363 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4364 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4365 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4366 setPreferenceProperty( xv, "step", 0.1 );
4367 setPreferenceProperty( xv, "min", 0.0 );
4368 setPreferenceProperty( xv, "max", 1.0 );
4369 setPreferenceProperty( yv, "step", 0.1 );
4370 setPreferenceProperty( yv, "min", 0.0 );
4371 setPreferenceProperty( yv, "max", 1.0 );
4372 setPreferenceProperty( wv, "step", 0.1 );
4373 setPreferenceProperty( wv, "min", 0.0 );
4374 setPreferenceProperty( wv, "max", 1.0 );
4375 setPreferenceProperty( hv, "min", 0.0 );
4376 setPreferenceProperty( hv, "max", 1.0 );
4377 setPreferenceProperty( hv, "step", 0.1 );
4379 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4380 setPreferenceProperty( posHSizeGr, "columns", 2 );
4381 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4382 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4383 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4384 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4385 setPreferenceProperty( xv, "min", 0.0 );
4386 setPreferenceProperty( xv, "max", 1.0 );
4387 setPreferenceProperty( xv, "step", 0.1 );
4388 setPreferenceProperty( xh, "min", 0.0 );
4389 setPreferenceProperty( xh, "max", 1.0 );
4390 setPreferenceProperty( xh, "step", 0.1 );
4391 setPreferenceProperty( yh, "min", 0.0 );
4392 setPreferenceProperty( yh, "max", 1.0 );
4393 setPreferenceProperty( yh, "step", 0.1 );
4394 setPreferenceProperty( wh, "min", 0.0 );
4395 setPreferenceProperty( wh, "max", 1.0 );
4396 setPreferenceProperty( wh, "step", 0.1 );
4397 setPreferenceProperty( hh, "min", 0.0 );
4398 setPreferenceProperty( hh, "max", 1.0 );
4399 setPreferenceProperty( hh, "step", 0.1 );
4401 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4402 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4403 setPreferenceProperty( distributionGr, "columns", 3 );
4405 types.append( tr( "SMESH_MONOCOLOR" ) );
4406 types.append( tr( "SMESH_MULTICOLOR" ) );
4407 indices.clear(); indices.append( 0 ); indices.append( 1 );
4408 setPreferenceProperty( coloringType, "strings", types );
4409 setPreferenceProperty( coloringType, "indexes", indices );
4410 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4414 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4416 if( sect=="SMESH" ) {
4417 float sbX1,sbY1,sbW,sbH;
4418 float aTol = 1.00000009999999;
4419 std::string aWarning;
4420 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4421 if( name=="selection_object_color" || name=="selection_element_color" ||
4422 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4423 name=="selection_precision_node" || name=="selection_precision_element" ||
4424 name=="selection_precision_object")
4425 SMESH::UpdateSelectionProp( this );
4426 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4427 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4428 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4429 if(sbX1+sbW > aTol){
4430 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4433 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4434 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4437 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4438 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4439 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4440 if(sbY1+sbH > aTol){
4441 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4442 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4443 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4446 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4447 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4448 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4449 if(sbX1+sbW > aTol){
4450 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4453 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4454 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4457 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4458 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4459 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4460 if(sbY1+sbH > aTol){
4461 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4464 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4465 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4468 else if ( name == "segmentation" ) {
4469 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4470 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4472 else if ( name == "nb_segments_per_edge" ) {
4473 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4474 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4477 if(aWarning.size() != 0){
4478 aWarning += "The default values are applied instead.";
4479 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4480 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4481 QObject::tr(aWarning.c_str()));
4486 //================================================================================
4488 * \brief Update something in accordance with update flags
4489 * \param theFlags - update flags
4491 * Update viewer or/and object browser etc. in accordance with update flags ( see
4492 * LightApp_UpdateFlags enumeration ).
4494 //================================================================================
4495 void SMESHGUI::update( const int flags )
4497 if ( flags & UF_Viewer | flags & UF_Forced )
4498 SMESH::UpdateView();
4500 SalomeApp_Module::update( flags );
4503 //================================================================================
4505 * \brief Set default selection mode
4507 * SLOT called when operation commited. Sets default selection mode
4509 //================================================================================
4510 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4512 SVTK_ViewWindow* vtkWnd =
4513 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4515 vtkWnd->SetSelectionMode( ActorSelection );
4518 //================================================================================
4520 * \brief Set default selection mode
4522 * SLOT called when operation aborted. Sets default selection mode
4524 //================================================================================
4525 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4527 SVTK_ViewWindow* vtkWnd =
4528 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4530 vtkWnd->SetSelectionMode( ActorSelection );
4533 //================================================================================
4535 * \brief Creates operation with given identifier
4536 * \param id - identifier of operation to be started
4537 * \return Pointer on created operation or NULL if operation is not created
4539 * Virtual method redefined from the base class creates operation with given id.
4540 * It is called called automatically from startOperation method of base class.
4542 //================================================================================
4543 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4545 LightApp_Operation* op = 0;
4546 // to do : create operation here
4549 case 417: //convert to quadratic
4550 op = new SMESHGUI_ConvToQuadOp();
4552 case 418: // create 2D mesh as boundary on 3D
4553 op = new SMESHGUI_Make2DFrom3DOp();
4555 case 701: // Compute mesh
4556 op = new SMESHGUI_ComputeOp();
4558 case 702: // Create mesh
4559 op = new SMESHGUI_MeshOp( true, true );
4561 case 703: // Create sub-mesh
4562 op = new SMESHGUI_MeshOp( true, false );
4564 case 704: // Edit mesh/sub-mesh
4565 op = new SMESHGUI_MeshOp( false );
4567 case 711: // Precompute mesh
4568 op = new SMESHGUI_PrecomputeOp();
4570 case 712: // Evaluate mesh
4571 op = new SMESHGUI_EvaluateOp();
4573 case 713: // Evaluate mesh
4574 op = new SMESHGUI_MeshOrderOp();
4576 case 806: // Create group on geom
4577 op = new SMESHGUI_GroupOnShapeOp();
4579 case 904: // Find element
4580 op = new SMESHGUI_FindElemByPointOp();
4582 case 4067: // make mesh pass through point
4583 op = new SMESHGUI_MakeNodeAtPointOp();
4590 op = SalomeApp_Module::createOperation( id );
4594 //================================================================================
4596 * \brief Stops current operations and starts a given one
4597 * \param id - The id of the operation to start
4599 //================================================================================
4601 void SMESHGUI::switchToOperation(int id)
4603 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4604 activeStudy()->abortAllOperations();
4605 startOperation( id );
4608 LightApp_Displayer* SMESHGUI::displayer()
4611 myDisplayer = new SMESHGUI_Displayer( getApp() );
4615 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4618 int aTolerance = 64;
4619 int anIterations = 0;
4625 if( anIterations % aPeriod == 0 )
4628 if( aTolerance < 1 )
4632 aHue = (int)( 360.0 * rand() / RAND_MAX );
4635 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4636 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4637 for( ; it != itEnd; ++it )
4639 SALOMEDS::Color anAutoColor = *it;
4640 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4643 aQColor.getHsv( &h, &s, &v );
4644 if( abs( h - aHue ) < aTolerance )
4656 aColor.setHsv( aHue, 255, 255 );
4658 SALOMEDS::Color aSColor;
4659 aSColor.R = (double)aColor.red() / 255.0;
4660 aSColor.G = (double)aColor.green() / 255.0;
4661 aSColor.B = (double)aColor.blue() / 255.0;
4666 const char gSeparator = '_'; // character used to separate parameter names
4667 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4668 const char gPathSep = '|'; // character used to separate paths
4671 * \brief Store visual parameters
4673 * This method is called just before the study document is saved.
4674 * Store visual parameters in AttributeParameter attribue(s)
4676 void SMESHGUI::storeVisualParameters (int savePoint)
4678 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4679 if (!appStudy || !appStudy->studyDS())
4681 _PTR(Study) studyDS = appStudy->studyDS();
4683 // componentName is used for encoding of entries when storing them in IParameters
4684 std::string componentName = myComponentSMESH->ComponentDataType();
4685 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4686 //if (!aSComponent) return;
4689 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4690 componentName.c_str(),
4692 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4694 // store map of custom markers
4695 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4696 if( !aMarkerMap.empty() )
4698 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4699 for( ; anIter != aMarkerMap.end(); anIter++ )
4701 int anId = anIter->first;
4702 VTK::MarkerData aMarkerData = anIter->second;
4703 std::string aMarkerFileName = aMarkerData.first;
4704 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4705 if( aMarkerTexture.size() < 3 )
4706 continue; // should contain at least width, height and the first value
4708 QString aPropertyName( "texture" );
4709 aPropertyName += gSeparator;
4710 aPropertyName += QString::number( anId );
4712 QString aPropertyValue = aMarkerFileName.c_str();
4713 aPropertyValue += gPathSep;
4715 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4716 ushort aWidth = *aTextureIter++;
4717 ushort aHeight = *aTextureIter++;
4718 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4719 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4720 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4721 aPropertyValue += QString::number( *aTextureIter );
4723 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4727 // viewers counters are used for storing view_numbers in IParameters
4730 // main cycle to store parameters of displayed objects
4731 QList<SUIT_ViewManager*> lst;
4732 QList<SUIT_ViewManager*>::Iterator it;
4733 getApp()->viewManagers(lst);
4734 for (it = lst.begin(); it != lst.end(); it++)
4736 SUIT_ViewManager* vman = *it;
4737 QString vType = vman->getType();
4739 // saving VTK actors properties
4740 if (vType == SVTK_Viewer::Type())
4742 // store the clipping planes attached to the view manager
4743 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4744 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4745 if( anIter != myClippingPlaneInfoMap.end() )
4746 aClippingPlaneInfoList = anIter->second;
4748 if( !aClippingPlaneInfoList.empty() ) {
4749 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4750 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4752 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4753 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
4755 QString aPropertyName( "ClippingPlane" );
4756 aPropertyName += gSeparator;
4757 aPropertyName += QString::number( vtkViewers );
4758 aPropertyName += gSeparator;
4759 aPropertyName += QString::number( anId );
4761 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
4762 aPropertyValue += gDigitsSep;
4763 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
4764 aPropertyValue += gDigitsSep;
4765 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
4766 aPropertyValue += gDigitsSep;
4767 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
4769 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4773 QVector<SUIT_ViewWindow*> views = vman->getViews();
4774 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
4776 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
4778 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
4779 vtkActorCollection* allActors = aCopy.GetActors();
4780 allActors->InitTraversal();
4781 while (vtkActor* actor = allActors->GetNextActor())
4783 if (actor->GetVisibility()) // store only visible actors
4785 SMESH_Actor* aSmeshActor = 0;
4786 if (actor->IsA("SMESH_Actor"))
4787 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
4788 if (aSmeshActor && aSmeshActor->hasIO())
4790 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
4793 // entry is "encoded" = it does NOT contain component adress,
4794 // since it is a subject to change on next component loading
4795 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
4797 std::string param, vtkParam = vType.toLatin1().data();
4798 vtkParam += gSeparator;
4799 vtkParam += QString::number(vtkViewers).toLatin1().data();
4800 vtkParam += gSeparator;
4803 param = vtkParam + "Visibility";
4804 ip->setParameter(entry, param, "On");
4807 param = vtkParam + "Representation";
4808 ip->setParameter(entry, param, QString::number
4809 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
4812 param = vtkParam + "IsShrunk";
4813 ip->setParameter(entry, param, QString::number
4814 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
4816 // Displayed entities
4817 unsigned int aMode = aSmeshActor->GetEntityMode();
4818 bool isE = aMode & SMESH_Actor::eEdges;
4819 bool isF = aMode & SMESH_Actor::eFaces;
4820 bool isV = aMode & SMESH_Actor::eVolumes;
4822 QString modeStr ("e");
4823 modeStr += gDigitsSep; modeStr += QString::number(isE);
4824 modeStr += gDigitsSep; modeStr += "f";
4825 modeStr += gDigitsSep; modeStr += QString::number(isF);
4826 modeStr += gDigitsSep; modeStr += "v";
4827 modeStr += gDigitsSep; modeStr += QString::number(isV);
4829 param = vtkParam + "Entities";
4830 ip->setParameter(entry, param, modeStr.toLatin1().data());
4832 // Colors (surface:edge:)
4833 vtkFloatingPointType r, g, b;
4835 aSmeshActor->GetSufaceColor(r, g, b);
4836 QString colorStr ("surface");
4837 colorStr += gDigitsSep; colorStr += QString::number(r);
4838 colorStr += gDigitsSep; colorStr += QString::number(g);
4839 colorStr += gDigitsSep; colorStr += QString::number(b);
4841 aSmeshActor->GetBackSufaceColor(r, g, b);
4842 colorStr += gDigitsSep; colorStr += "backsurface";
4843 colorStr += gDigitsSep; colorStr += QString::number(r);
4844 colorStr += gDigitsSep; colorStr += QString::number(g);
4845 colorStr += gDigitsSep; colorStr += QString::number(b);
4847 aSmeshActor->GetEdgeColor(r, g, b);
4848 colorStr += gDigitsSep; colorStr += "edge";
4849 colorStr += gDigitsSep; colorStr += QString::number(r);
4850 colorStr += gDigitsSep; colorStr += QString::number(g);
4851 colorStr += gDigitsSep; colorStr += QString::number(b);
4853 aSmeshActor->GetNodeColor(r, g, b);
4854 colorStr += gDigitsSep; colorStr += "node";
4855 colorStr += gDigitsSep; colorStr += QString::number(r);
4856 colorStr += gDigitsSep; colorStr += QString::number(g);
4857 colorStr += gDigitsSep; colorStr += QString::number(b);
4859 param = vtkParam + "Colors";
4860 ip->setParameter(entry, param, colorStr.toLatin1().data());
4862 // Sizes of lines and points
4863 QString sizeStr ("line");
4864 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
4865 sizeStr += gDigitsSep; sizeStr += "shrink";
4866 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
4868 param = vtkParam + "Sizes";
4869 ip->setParameter(entry, param, sizeStr.toLatin1().data());
4874 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
4875 if( aMarkerType == VTK::MT_USER ) {
4876 markerStr += "custom";
4877 markerStr += gDigitsSep;
4878 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
4882 markerStr += gDigitsSep;
4883 markerStr += QString::number( (int)aMarkerType );
4884 markerStr += gDigitsSep;
4885 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
4888 param = vtkParam + "PointMarker";
4889 ip->setParameter(entry, param, markerStr.toLatin1().data());
4892 param = vtkParam + "Opacity";
4893 ip->setParameter(entry, param,
4894 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
4897 param = vtkParam + "ClippingPlane";
4899 if( !aClippingPlaneInfoList.empty() ) {
4900 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
4901 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
4903 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
4904 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
4905 SMESH::TActorList::iterator anIter2 = anActorList.begin();
4906 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
4907 if( aSmeshActor == *anIter2 ) {
4908 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
4909 QString::number( anId ).toLatin1().constData() );
4916 ip->setParameter( entry, param, "Off" );
4917 } // if (io->hasEntry())
4918 } // SMESH_Actor && hasIO
4920 } // while.. actors traversal
4924 } // if (SVTK view model)
4925 } // for (viewManagers)
4928 // data structures for clipping planes processing
4931 vtkIdType Orientation;
4932 vtkFloatingPointType Distance;
4933 vtkFloatingPointType Angle[2];
4935 typedef std::list<TPlaneData> TPlaneDataList;
4936 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
4938 typedef std::list<vtkActor*> TActorList;
4941 TActorList ActorList;
4942 SUIT_ViewManager* ViewManager;
4944 typedef std::list<TPlaneInfo> TPlaneInfoList;
4945 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
4948 * \brief Restore visual parameters
4950 * This method is called after the study document is opened.
4951 * Restore visual parameters from AttributeParameter attribue(s)
4953 void SMESHGUI::restoreVisualParameters (int savePoint)
4955 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4956 if (!appStudy || !appStudy->studyDS())
4958 _PTR(Study) studyDS = appStudy->studyDS();
4960 // componentName is used for encoding of entries when storing them in IParameters
4961 std::string componentName = myComponentSMESH->ComponentDataType();
4962 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
4963 //if (!aSComponent) return;
4966 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4967 componentName.c_str(),
4969 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4971 // restore map of custom markers and map of clipping planes
4972 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4973 TPlaneDataMap aPlaneDataMap;
4975 std::vector<std::string> properties = ip->getProperties();
4976 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
4978 std::string property = *propIt;
4979 QString aPropertyName( property.c_str() );
4980 QString aPropertyValue( ip->getProperty( property ).c_str() );
4982 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
4983 if( aPropertyNameList.isEmpty() )
4986 QString aPropertyType = aPropertyNameList[0];
4987 if( aPropertyType == "texture" )
4989 if( aPropertyNameList.size() != 2 )
4993 int anId = aPropertyNameList[1].toInt( &ok );
4994 if( !ok || anId < 1 )
4997 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
4998 if( aPropertyValueList.size() != 2 )
5001 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5002 QString aMarkerTextureString = aPropertyValueList[1];
5003 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5004 if( aMarkerTextureStringList.size() != 3 )
5008 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5013 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5017 VTK::MarkerTexture aMarkerTexture;
5018 aMarkerTexture.push_back( aWidth );
5019 aMarkerTexture.push_back( aHeight );
5021 QString aMarkerTextureData = aMarkerTextureStringList[2];
5022 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5024 QChar aChar = aMarkerTextureData.at( i );
5025 if( aChar.isDigit() )
5026 aMarkerTexture.push_back( aChar.digitValue() );
5029 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5031 else if( aPropertyType == "ClippingPlane" )
5033 if( aPropertyNameList.size() != 3 )
5037 int aViewId = aPropertyNameList[1].toInt( &ok );
5038 if( !ok || aViewId < 0 )
5042 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5043 if( !ok || aClippingPlaneId < 0 )
5046 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5047 if( aPropertyValueList.size() != 4 )
5050 TPlaneData aPlaneData;
5051 aPlaneData.Id = aClippingPlaneId;
5054 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5059 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5064 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5069 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5073 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5074 aPlaneDataList.push_back( aPlaneData );
5078 TPlaneInfoMap aPlaneInfoMap;
5080 std::vector<std::string> entries = ip->getEntries();
5082 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5084 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5085 QString entry (ip->decodeEntry(*entIt).c_str());
5087 // Check that the entry corresponds to a real object in the Study
5088 // as the object may be deleted or modified after the visual state is saved.
5089 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5090 if (!so) continue; //Skip the not existent entry
5092 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5093 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5095 std::vector<std::string>::iterator namesIt = paramNames.begin();
5096 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5098 // actors are stored in a map after displaying of them for
5099 // quicker access in the future: map < viewID to actor >
5100 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5102 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5104 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5105 // '_' is used as separator and should not be used in viewer type or parameter names.
5106 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5107 if (lst.size() != 3)
5110 QString viewerTypStr = lst[0];
5111 QString viewIndexStr = lst[1];
5112 QString paramNameStr = lst[2];
5115 int viewIndex = viewIndexStr.toUInt(&ok);
5116 if (!ok) // bad conversion of view index to integer
5120 if (viewerTypStr == SVTK_Viewer::Type())
5122 SMESH_Actor* aSmeshActor = 0;
5123 if (vtkActors.IsBound(viewIndex))
5124 aSmeshActor = vtkActors.Find(viewIndex);
5126 QList<SUIT_ViewManager*> lst;
5127 getApp()->viewManagers(viewerTypStr, lst);
5129 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5130 SUIT_ViewManager* vman = NULL;
5131 if (viewIndex >= 0 && viewIndex < lst.count())
5132 vman = lst.at(viewIndex);
5134 if (paramNameStr == "Visibility")
5136 if (!aSmeshActor && displayer() && vman)
5138 SUIT_ViewModel* vmodel = vman->getViewModel();
5139 // SVTK view model can be casted to SALOME_View
5140 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5142 // store displayed actor in a temporary map for quicker
5143 // access later when restoring other parameters
5144 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5145 vtkRenderer* Renderer = vtkView->getRenderer();
5146 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5147 vtkActorCollection* theActors = aCopy.GetActors();
5148 theActors->InitTraversal();
5149 bool isFound = false;
5150 vtkActor *ac = theActors->GetNextActor();
5151 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5152 if (ac->IsA("SMESH_Actor")) {
5153 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5154 if (aGeomAc->hasIO()) {
5155 Handle(SALOME_InteractiveObject) io =
5156 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5157 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5159 vtkActors.Bind(viewIndex, aGeomAc);
5165 } // if (paramNameStr == "Visibility")
5168 // the rest properties "work" with SMESH_Actor
5171 QString val ((*valuesIt).c_str());
5174 if (paramNameStr == "Representation") {
5175 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5178 else if (paramNameStr == "IsShrunk") {
5180 if (!aSmeshActor->IsShrunk())
5181 aSmeshActor->SetShrink();
5184 if (aSmeshActor->IsShrunk())
5185 aSmeshActor->UnShrink();
5188 // Displayed entities
5189 else if (paramNameStr == "Entities") {
5190 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5191 if (mode.count() == 6) {
5192 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5193 MESSAGE("Invalid order of data in Entities, must be: "
5194 "e:0/1:f:0/1:v:0/1");
5197 unsigned int aMode = aSmeshActor->GetEntityMode();
5198 unsigned int aNewMode =
5199 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5200 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5201 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5202 if (aNewMode != aMode)
5203 aSmeshActor->SetEntityMode(aNewMode);
5208 else if (paramNameStr == "Colors") {
5209 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5210 if (colors.count() == 16) {
5211 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5212 colors[8] != "edge" || colors[12] != "node") {
5213 MESSAGE("Invalid order of data in Colors, must be: "
5214 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5217 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5218 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5219 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5220 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5224 // Sizes of lines and points
5225 else if (paramNameStr == "Sizes") {
5226 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5227 if (sizes.count() == 4) {
5228 if (sizes[0] != "line" || sizes[2] != "shrink") {
5229 MESSAGE("Invalid order of data in Sizes, must be: "
5230 "line:int:shrink:float");
5233 aSmeshActor->SetLineWidth(sizes[1].toInt());
5234 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5237 else if (sizes.count() == 6) { // just to support old format
5238 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5239 MESSAGE("Invalid order of data in Sizes, must be: "
5240 "line:int:node:int:shrink:float");
5243 aSmeshActor->SetLineWidth(sizes[1].toInt());
5244 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5245 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5250 else if (paramNameStr == "PointMarker") {
5251 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5252 if( data.count() >= 2 ) {
5254 int aParam1 = data[1].toInt( &ok );
5256 if( data[0] == "std" && data.count() == 3 ) {
5257 int aParam2 = data[2].toInt( &ok );
5258 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5260 else if( data[0] == "custom" ) {
5261 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5262 if( markerIt != aMarkerMap.end() ) {
5263 VTK::MarkerData aMarkerData = markerIt->second;
5264 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5271 else if (paramNameStr == "Opacity") {
5272 aSmeshActor->SetOpacity(val.toFloat());
5275 else if (paramNameStr.startsWith("ClippingPlane")) {
5276 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5277 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5278 // new format - val looks like "Off" or "0" (plane id)
5279 // (note: in new format "Off" value is used only for consistency,
5280 // so it is processed together with values in old format)
5281 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5282 if( anIsOldFormat ) {
5283 if (paramNameStr == "ClippingPlane1" || val == "Off")
5284 aSmeshActor->RemoveAllClippingPlanes();
5286 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5287 double aDistance = vals[1].toFloat();
5288 vtkFloatingPointType anAngle[2];
5289 anAngle[0] = vals[2].toFloat();
5290 anAngle[1] = vals[3].toFloat();
5292 QList<SUIT_ViewManager*> lst;
5293 getApp()->viewManagers(viewerTypStr, lst);
5294 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5295 if (viewIndex >= 0 && viewIndex < lst.count()) {
5296 SUIT_ViewManager* vman = lst.at(viewIndex);
5297 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5299 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5301 SMESH::TActorList anActorList;
5302 anActorList.push_back( aSmeshActor );
5303 SMESH::OrientedPlane* aPlane =
5304 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5306 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5307 aClippingPlaneInfo.Plane = aPlane;
5308 aClippingPlaneInfo.ActorList = anActorList;
5309 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5316 int aPlaneId = val.toInt( &ok );
5317 if( ok && aPlaneId >= 0 ) {
5318 bool anIsDefinedPlane = false;
5319 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5320 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5321 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5322 TPlaneInfo& aPlaneInfo = *anIter;
5323 if( aPlaneInfo.PlaneId == aPlaneId ) {
5324 aPlaneInfo.ActorList.push_back( aSmeshActor );
5325 anIsDefinedPlane = true;
5329 if( !anIsDefinedPlane ) {
5330 TPlaneInfo aPlaneInfo;
5331 aPlaneInfo.PlaneId = aPlaneId;
5332 aPlaneInfo.ActorList.push_back( aSmeshActor );
5333 aPlaneInfo.ViewManager = vman;
5334 aPlaneInfoList.push_back( aPlaneInfo );
5339 } // if (aSmeshActor)
5340 } // other parameters than Visibility
5342 } // for names/parameters iterator
5343 } // for entries iterator
5345 // add clipping planes to actors according to the restored parameters
5346 // and update the clipping plane map
5347 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5348 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5349 int aViewId = anIter1->first;
5350 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5352 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5353 if( anIter2 == aPlaneDataMap.end() )
5355 const TPlaneDataList& aPlaneDataList = anIter2->second;
5357 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5358 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5359 const TPlaneInfo& aPlaneInfo = *anIter3;
5360 int aPlaneId = aPlaneInfo.PlaneId;
5361 const TActorList& anActorList = aPlaneInfo.ActorList;
5362 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5366 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5370 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5372 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5373 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5374 const TPlaneData& aPlaneData = *anIter4;
5375 if( aPlaneData.Id == aPlaneId ) {
5376 SMESH::OrientedPlane* aPlane =
5377 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5379 (SMESH::Orientation)aPlaneData.Orientation,
5380 aPlaneData.Distance,
5383 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5384 aClippingPlaneInfo.Plane = aPlane;
5385 aClippingPlaneInfo.ActorList = anActorList;
5386 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5394 // update all VTK views
5395 QList<SUIT_ViewManager*> lst;
5396 getApp()->viewManagers(lst);
5397 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5398 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5399 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5400 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5401 vtkView->getRenderer()->ResetCameraClippingRange();
5408 \brief Adds preferences for dfont of VTK viewer
5410 \param pIf group identifier
5411 \param param parameter
5412 \return identifier of preferences
5414 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5416 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
5418 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5421 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5422 fam.append( tr( "SMESH_FONT_COURIER" ) );
5423 fam.append( tr( "SMESH_FONT_TIMES" ) );
5425 setPreferenceProperty( tfont, "fonts", fam );
5427 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5428 setPreferenceProperty( tfont, "features", f );
5434 \brief Actions after hypothesis edition
5435 Updates object browser after hypothesis edition
5437 void SMESHGUI::onHypothesisEdit( int result )
5440 SMESHGUI::Modified();
5441 updateObjBrowser( true );