1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_NodesDlg.h"
29 #include "SMESHGUI_TransparencyDlg.h"
30 #include "SMESHGUI_ClippingDlg.h"
31 #include "SMESHGUI_GroupDlg.h"
32 #include "SMESHGUI_RemoveNodesDlg.h"
33 #include "SMESHGUI_RemoveElementsDlg.h"
34 #include "SMESHGUI_MeshInfosDlg.h"
35 #include "SMESHGUI_StandardMeshInfosDlg.h"
36 #include "SMESHGUI_WhatIsDlg.h"
37 #include "SMESHGUI_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_MoveNodesDlg.h"
41 #include "SMESHGUI_AddMeshElementDlg.h"
42 #include "SMESHGUI_AddQuadraticElementDlg.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_SingleEditDlg.h"
46 #include "SMESHGUI_MultiEditDlg.h"
47 #include "SMESHGUI_GroupOpDlg.h"
48 #include "SMESHGUI_DeleteGroupDlg.h"
49 #include "SMESHGUI_SmoothingDlg.h"
50 #include "SMESHGUI_RenumberingDlg.h"
51 #include "SMESHGUI_ExtrusionDlg.h"
52 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
53 #include "SMESHGUI_RevolutionDlg.h"
54 #include "SMESHGUI_TranslationDlg.h"
55 #include "SMESHGUI_RotationDlg.h"
56 #include "SMESHGUI_SymmetryDlg.h"
57 #include "SMESHGUI_SewingDlg.h"
58 #include "SMESHGUI_EditMeshDlg.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_Selection.h"
61 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
62 #include "SMESHGUI_ConvToQuadOp.h"
63 #include "SMESHGUI_MeshOp.h"
64 #include "SMESHGUI_Displayer.h"
65 #include "SMESHGUI_MakeNodeAtPointDlg.h"
66 #include "SMESHGUI_BuildCompoundDlg.h"
67 #include "SMESHGUI_ComputeDlg.h"
68 #include "SMESHGUI_FileInfoDlg.h"
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_GroupUtils.h"
73 #include "SMESHGUI_FilterUtils.h"
74 #include "SMESHGUI_PatternUtils.h"
75 #include "SMESHGUI_VTKUtils.h"
76 #include "SMESHGUI_HypothesesUtils.h"
78 #include <SMESH_Client.hxx>
79 #include <SMESH_Actor.h>
80 #include <SMESH_TypeFilter.hxx>
82 // SALOME GUI includes
83 #include <SalomeApp_Tools.h>
84 #include <SalomeApp_Study.h>
85 #include <SalomeApp_Application.h>
86 #include <SalomeApp_CheckFileDlg.h>
88 #include <LightApp_DataOwner.h>
89 #include <LightApp_Preferences.h>
90 #include <LightApp_SelectionMgr.h>
91 #include <LightApp_UpdateFlags.h>
92 #include <LightApp_NameDlg.h>
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_ViewModel.h>
96 #include <SVTK_ViewManager.h>
98 #include <SUIT_MessageBox.h>
99 #include <SUIT_ResourceMgr.h>
100 #include <SUIT_FileDlg.h>
101 #include <SUIT_Desktop.h>
102 #include <SUIT_OverrideCursor.h>
103 #include <SUIT_Session.h>
105 #include <QtxPopupMgr.h>
106 #include <QtxFontEdit.h>
108 #include <SALOME_ListIO.hxx>
109 #include <SALOME_ListIteratorOfListIO.hxx>
112 #include <SALOMEconfig.h>
113 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
114 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
117 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
121 #include <boost/shared_ptr.hpp>
124 #include <vtkScalarBarActor.h>
125 #include <vtkCamera.h>
126 #include <vtkRenderer.h>
127 #include <vtkPlane.h>
129 // SALOME KERNEL includes
130 #include <SALOMEDS_Study.hxx>
131 #include <SALOMEDSClient_StudyBuilder.hxx>
132 #include <SALOMEDSClient_SComponent.hxx>
133 #include <SALOMEDSClient_ClientFactory.hxx>
134 #include <SALOMEDSClient_IParameters.hxx>
137 #include <Standard_ErrorHandler.hxx>
138 #include <NCollection_DataMap.hxx>
142 //=============================================================
143 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
146 void ExportMeshToFile(int theCommandID);
148 void SetDisplayMode(int theCommandID);
150 void SetDisplayEntity(int theCommandID);
152 void Control( int theCommandID );
156 //=============================================================
157 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
161 std::string myExtension;
163 if ( theCommandID == 113 ) {
164 filter.append( QObject::tr( "MED files (*.med)" ) );
165 filter.append( QObject::tr( "All files (*)" ) );
167 else if ( theCommandID == 112 ) {
168 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
170 else if ( theCommandID == 111 ) {
171 filter.append( QObject::tr( "DAT files (*.dat)" ) );
174 QString anInitialPath = "";
175 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
176 anInitialPath = QDir::currentPath();
178 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
181 QObject::tr( "SMESH_IMPORT_MESH" ) );
182 if ( filenames.count() > 0 ) {
183 SUIT_OverrideCursor wc;
184 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
187 bool isEmpty = false;
188 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
189 QString filename = *it;
190 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
192 switch ( theCommandID ) {
195 // DAT format (currently unsupported)
196 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
197 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
203 aMeshes->length( 1 );
204 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
205 if ( aMeshes[0]->_is_nil() )
206 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
207 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
213 SMESH::DriverMED_ReadStatus res;
214 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
215 if ( res != SMESH::DRS_OK ) {
216 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
217 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
223 catch ( const SALOME::SALOME_Exception& S_ex ) {
224 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
225 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
228 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
229 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
231 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
232 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
233 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
234 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
235 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
243 // update Object browser
244 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
246 // show Error message box if there were errors
247 if ( errors.count() > 0 ) {
248 SUIT_MessageBox::critical( SMESHGUI::desktop(),
249 QObject::tr( "SMESH_ERROR" ),
250 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
253 // show warning message box, if some imported mesh is empty
255 SUIT_MessageBox::warning( SMESHGUI::desktop(),
256 QObject::tr( "SMESH_WRN_WARNING" ),
257 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
262 void ExportMeshToFile( int theCommandID )
264 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
265 SALOME_ListIO selected;
267 aSel->selectedObjects( selected );
269 if(selected.Extent()){
270 Handle(SALOME_InteractiveObject) anIObject = selected.First();
271 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
272 if ( !aMesh->_is_nil() ) {
273 QString aFilter, aTitle = QObject::tr("Export mesh");
274 QMap<QString, SMESH::MED_VERSION> aFilterMap;
275 QMap<QString, int> aFilterMapSTL;
276 switch ( theCommandID ) {
280 if (aMesh->HasDuplicatedGroupNamesMED()) {
281 int aRet = SUIT_MessageBox::warning
282 (SMESHGUI::desktop(),
283 QObject::tr("SMESH_WRN_WARNING"),
284 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
285 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
286 if (aRet != SUIT_MessageBox::Yes)
290 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
291 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
292 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
293 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
298 aFilter = QObject::tr("DAT files (*.dat)");
303 if (aMesh->NbPyramids()) {
304 int aRet = SUIT_MessageBox::warning
305 (SMESHGUI::desktop(),
306 QObject::tr("SMESH_WRN_WARNING"),
307 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
308 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
309 if (aRet != SUIT_MessageBox::Yes)
312 aFilter = QObject::tr("IDEAS files (*.unv)");
320 there must be check on others mesh elements not equal triangles
322 if (aMesh->NbTriangles() < 1) {
323 SUIT_MessageBox::warning
324 (SMESHGUI::desktop(),
325 QObject::tr("SMESH_WRN_WARNING"),
326 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
329 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
330 int aRet = SUIT_MessageBox::warning
331 (SMESHGUI::desktop(),
332 QObject::tr("SMESH_WRN_WARNING"),
333 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
334 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
335 if (aRet != SUIT_MessageBox::Yes)
339 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
340 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
348 SMESH::MED_VERSION aFormat;
349 // Init the parameter with the default value
350 bool aIsASCII_STL = true;
351 bool toCreateGroups = false;
352 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
354 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
356 QString anInitialPath = "";
357 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
358 anInitialPath = QDir::currentPath();
360 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
361 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
362 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
363 aFilter, aTitle, false);
365 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
367 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
368 for ( ; it != aFilterMapSTL.end(); ++it )
369 filters.push_back( it.key() );
371 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
372 fd->setWindowTitle( aTitle );
373 fd->setFilters( filters );
374 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
375 if ( !anInitialPath.isEmpty() )
376 fd->setDirectory( anInitialPath );
377 fd->selectFile(anIObject->getName());
381 aFilename = fd->selectedFile();
382 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
387 else { // Export to MED
389 QString aDefaultFilter;
390 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
391 for ( ; it != aFilterMap.end(); ++it ) {
392 filters.push_back( it.key() );
393 if (it.value() == SMESH::MED_V2_2)
394 aDefaultFilter = it.key();
397 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
398 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
399 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
400 fd->setWindowTitle( aTitle );
401 fd->setFilters( filters );
402 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
403 fd->selectFilter(aDefaultFilter);
404 fd->SetChecked(toCreateGroups);
405 if ( !anInitialPath.isEmpty() )
406 fd->setDirectory( anInitialPath );
407 fd->selectFile(anIObject->getName());
411 aFilename = fd->selectedFile();
412 aFormat = aFilterMap[fd->selectedFilter()];
414 if ( !aFilename.isEmpty()
415 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
416 && aFormat==SMESH::MED_V2_1) {
417 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
418 QObject::tr("SMESH_WRN_WARNING"),
419 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
420 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
421 if (aRet != SUIT_MessageBox::Yes) {
426 toCreateGroups = fd->IsChecked();
429 if ( !aFilename.isEmpty() ) {
430 // Check whether the file already exists and delete it if yes
431 QFile aFile( aFilename );
432 if ( aFile.exists() )
434 SUIT_OverrideCursor wc;
437 bool Renumber = false;
438 // PAL 14172 : Check of we have to renumber or not from the preferences before export
440 Renumber= resMgr->booleanValue("SMESH","renumbering");
442 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
443 aMeshEditor->RenumberNodes();
444 aMeshEditor->RenumberElements();
445 if ( SMESHGUI::automaticUpdate() )
448 switch ( theCommandID ) {
451 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
455 aMesh->ExportDAT( aFilename.toLatin1().data() );
459 aMesh->ExportUNV( aFilename.toLatin1().data() );
463 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
469 catch (const SALOME::SALOME_Exception& S_ex){
471 SUIT_MessageBox::warning(SMESHGUI::desktop(),
472 QObject::tr("SMESH_WRN_WARNING"),
473 QObject::tr("SMESH_EXPORT_FAILED"));
481 inline void InverseEntityMode(unsigned int& theOutputMode,
482 unsigned int theMode)
484 bool anIsNotPresent = ~theOutputMode & theMode;
486 theOutputMode |= theMode;
488 theOutputMode &= ~theMode;
491 void SetDisplayEntity(int theCommandID){
492 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
493 SALOME_ListIO selected;
495 aSel->selectedObjects( selected );
497 if(selected.Extent() >= 1){
498 SALOME_ListIteratorOfListIO It( selected );
499 for( ; It.More(); It.Next()){
500 Handle(SALOME_InteractiveObject) IObject = It.Value();
501 if(IObject->hasEntry()){
502 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
503 unsigned int aMode = anActor->GetEntityMode();
504 switch(theCommandID){
506 InverseEntityMode(aMode,SMESH_Actor::eEdges);
509 InverseEntityMode(aMode,SMESH_Actor::eFaces);
512 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
515 aMode = SMESH_Actor::eAllEntity;
519 anActor->SetEntityMode(aMode);
527 SALOME_ListIO selected;
528 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
532 LightApp_SelectionMgr* aSel = app->selectionMgr();
533 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
534 if( !aSel || !appStudy )
537 aSel->selectedObjects( selected );
538 if( selected.IsEmpty() )
541 Handle(SALOME_InteractiveObject) anIObject = selected.First();
543 _PTR(Study) aStudy = appStudy->studyDS();
544 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
545 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
546 if( aMainObject->_is_nil() )
549 aMainObject->SetAutoColor( true );
551 QList<SALOMEDS::Color> aReservedColors;
553 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
554 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
556 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
557 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
559 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
560 aGroupObject->SetColor( aColor );
561 aReservedColors.append( aColor );
563 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
564 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
566 if( aGroupObject->GetType() == SMESH::NODE )
567 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
568 else if( aGroupObject->GetType() == SMESH::EDGE )
569 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
571 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
575 SMESH::RepaintCurrentView();
578 void DisableAutoColor(){
579 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
580 SALOME_ListIO selected;
582 aSel->selectedObjects( selected );
584 if(selected.Extent()){
585 Handle(SALOME_InteractiveObject) anIObject = selected.First();
586 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
587 if ( !aMesh->_is_nil() ) {
588 aMesh->SetAutoColor( false );
593 void SetDisplayMode(int theCommandID){
594 SALOME_ListIO selected;
595 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
599 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
600 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
601 if( !aSel || !appStudy )
604 _PTR(Study) aStudy = appStudy->studyDS();
606 aSel->selectedObjects( selected );
608 if(selected.Extent() >= 1){
609 switch(theCommandID){
611 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
612 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
616 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
617 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
620 SALOME_ListIteratorOfListIO It( selected );
621 for( ; It.More(); It.Next()){
622 Handle(SALOME_InteractiveObject) IObject = It.Value();
623 if(IObject->hasEntry()){
624 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
625 switch(theCommandID){
627 anActor->SetRepresentation(SMESH_Actor::eEdge);
630 anActor->SetRepresentation(SMESH_Actor::eSurface);
633 if(anActor->IsShrunk())
636 anActor->SetShrink();
639 anActor->SetRepresentation(SMESH_Actor::ePoint);
642 vtkFloatingPointType color[3];
643 anActor->GetSufaceColor(color[0], color[1], color[2]);
644 int c0 = int (color[0] * 255);
645 int c1 = int (color[1] * 255);
646 int c2 = int (color[2] * 255);
647 QColor c(c0, c1, c2);
649 vtkFloatingPointType edgecolor[3];
650 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
651 c0 = int (edgecolor[0] * 255);
652 c1 = int (edgecolor[1] * 255);
653 c2 = int (edgecolor[2] * 255);
654 QColor e(c0, c1, c2);
656 vtkFloatingPointType backfacecolor[3];
657 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
658 c0 = int (backfacecolor[0] * 255);
659 c1 = int (backfacecolor[1] * 255);
660 c2 = int (backfacecolor[2] * 255);
661 QColor b(c0, c1, c2);
663 vtkFloatingPointType nodecolor[3];
664 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
665 c0 = int (nodecolor[0] * 255);
666 c1 = int (nodecolor[1] * 255);
667 c2 = int (nodecolor[2] * 255);
668 QColor n(c0, c1, c2);
670 int Edgewidth = (int)anActor->GetLineWidth();
673 int intValue = int(anActor->GetNodeSize());
674 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
676 SMESHGUI_Preferences_ColorDlg *aDlg =
677 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
678 aDlg->SetColor(1, c);
679 aDlg->SetColor(2, e);
680 aDlg->SetColor(3, n);
681 aDlg->SetColor(4, b);
682 aDlg->SetIntValue(1, Edgewidth);
683 aDlg->SetIntValue(2, intValue);
684 aDlg->SetIntValue(3, int(Shrink*100.));
686 QColor color = aDlg->GetColor(1);
687 QColor edgecolor = aDlg->GetColor(2);
688 QColor nodecolor = aDlg->GetColor(3);
689 QColor backfacecolor = aDlg->GetColor(4);
690 /* actor color and backface color */
691 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
692 vtkFloatingPointType (color.green()) / 255.,
693 vtkFloatingPointType (color.blue()) / 255.);
694 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
695 vtkFloatingPointType (backfacecolor.green()) / 255.,
696 vtkFloatingPointType (backfacecolor.blue()) / 255.);
699 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
700 vtkFloatingPointType (edgecolor.green()) / 255.,
701 vtkFloatingPointType (edgecolor.blue()) / 255.);
703 /* Shrink factor and size edges */
704 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
705 anActor->SetLineWidth(aDlg->GetIntValue(1));
707 /* Nodes color and size */
708 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
709 vtkFloatingPointType (nodecolor.green()) / 255.,
710 vtkFloatingPointType (nodecolor.blue()) / 255.);
711 anActor->SetNodeSize(aDlg->GetIntValue(2));
713 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
714 if( !aGroupObject->_is_nil() )
716 SALOMEDS::Color aColor;
717 aColor.R = (float)color.red() / 255.0;
718 aColor.G = (float)color.green() / 255.0;
719 aColor.B = (float)color.blue() / 255.0;
720 aGroupObject->SetColor( aColor );
730 SMESH::RepaintCurrentView();
734 void Control( int theCommandID )
736 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
737 SALOME_ListIO selected;
739 aSel->selectedObjects( selected );
741 if( !selected.IsEmpty() ){
742 Handle(SALOME_InteractiveObject) anIO = selected.First();
745 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
746 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
747 switch ( theCommandID ){
749 aTitle = QObject::tr( "LENGTH_EDGES" );
750 aControl = SMESH_Actor::eLength;
753 aTitle = QObject::tr( "LENGTH2D_EDGES" );
754 aControl = SMESH_Actor::eLength2D;
757 aTitle = QObject::tr( "FREE_EDGES" );
758 aControl = SMESH_Actor::eFreeEdges;
761 aTitle = QObject::tr( "FREE_BORDERS" );
762 aControl = SMESH_Actor::eFreeBorders;
765 aTitle = QObject::tr( "MULTI_BORDERS" );
766 aControl = SMESH_Actor::eMultiConnection;
769 aTitle = QObject::tr( "MULTI2D_BORDERS" );
770 aControl = SMESH_Actor::eMultiConnection2D;
773 aTitle = QObject::tr( "AREA_ELEMENTS" );
774 aControl = SMESH_Actor::eArea;
777 aTitle = QObject::tr( "TAPER_ELEMENTS" );
778 aControl = SMESH_Actor::eTaper;
781 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
782 aControl = SMESH_Actor::eAspectRatio;
785 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
786 aControl = SMESH_Actor::eAspectRatio3D;
789 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
790 aControl = SMESH_Actor::eMinimumAngle;
793 aTitle = QObject::tr( "WARP_ELEMENTS" );
794 aControl = SMESH_Actor::eWarping;
797 aTitle = QObject::tr( "SKEW_ELEMENTS" );
798 aControl = SMESH_Actor::eSkew;
801 aTitle = QObject::tr( "SMESH_VOLUME" );
802 aControl = SMESH_Actor::eVolume3D;
805 anActor->SetControlMode(aControl);
806 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
807 SMESH::RepaintCurrentView();
814 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
815 MeshObjectType theType,
816 const QString theInTypeName,
817 QString & theOutTypeName)
819 SMESH_TypeFilter aTypeFilter( theType );
821 if( !theIO.IsNull() )
823 entry = theIO->getEntry();
824 LightApp_DataOwner owner( entry );
825 if ( aTypeFilter.isOk( &owner )) {
826 theOutTypeName = theInTypeName;
834 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
836 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
837 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
839 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
840 CORBA::String_var anID = aSComp->GetID().c_str();
841 if (!strcmp(anID.in(),theIO->getEntry()))
847 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
848 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
849 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
850 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
851 CheckOIType ( theIO, GROUP, "Group", aTypeName )
859 QString CheckHomogeneousSelection()
861 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
862 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
863 SALOME_ListIO selected;
865 aSel->selectedObjects( selected );
867 QString RefType = CheckTypeObject(selected.First());
868 SALOME_ListIteratorOfListIO It(selected);
869 for ( ; It.More(); It.Next())
871 Handle(SALOME_InteractiveObject) IObject = It.Value();
872 QString Type = CheckTypeObject(IObject);
873 if (Type.compare(RefType) != 0)
874 return "Heterogeneous Selection";
881 void SMESHGUI::OnEditDelete()
883 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
884 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
885 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
887 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
888 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
889 _PTR(GenericAttribute) anAttr;
890 _PTR(AttributeIOR) anIOR;
893 QString aParentComponent = QString::null;
894 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
896 _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
898 // check if object is not reference
899 _PTR(SObject) refobj;
900 if ( !aSO->ReferencedObject( refobj ) )
904 QString cur = anIt.Value()->getComponentDataType();
905 if( aParentComponent.isNull() )
906 aParentComponent = cur;
907 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
908 aParentComponent = "";
911 if ( objectCount == 0 )
912 return; // No Valid Objects Selected
914 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
915 SUIT_MessageBox::warning( SMESHGUI::desktop(),
916 QObject::tr("ERR_ERROR"),
917 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
920 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
921 if (SUIT_MessageBox::warning
922 (SMESHGUI::desktop(),
923 QObject::tr("SMESH_WRN_WARNING"),
924 QObject::tr("SMESH_REALLY_DELETE"),
925 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
926 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
929 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
930 SUIT_ViewManager* vm = anApp->activeViewManager();
931 int nbSf = vm->getViewsCount();
933 SALOME_ListIteratorOfListIO It(selected);
935 aStudyBuilder->NewCommand(); // There is a transaction
936 for( ; It.More(); It.Next()){ // loop on selected IO's
937 Handle(SALOME_InteractiveObject) IObject = It.Value();
938 if(IObject->hasEntry()) {
939 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
941 // disable removal of "SMESH" component object
942 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
944 if ( engineIOR() == anIOR->Value().c_str() )
948 _PTR(SObject) refobj;
949 if ( aSO && aSO->ReferencedObject( refobj ) )
950 continue; // skip references
952 // put the whole hierarchy of sub-objects of the selected SO into a list and
953 // then treat them all starting from the deepest objects (at list back)
955 std::list< _PTR(SObject) > listSO;
956 listSO.push_back( aSO );
957 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
958 for ( ; itSO != listSO.end(); ++itSO ) {
959 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
960 for (it->InitEx(false); it->More(); it->Next())
961 listSO.push_back( it->Value() );
964 // treat SO's in the list starting from the back
966 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
967 for ( ; ritSO != listSO.rend(); ++ritSO ) {
968 _PTR(SObject) SO = *ritSO;
970 std::string anEntry = SO->GetID();
972 /** Erase graphical object **/
973 if(SO->FindAttribute(anAttr, "AttributeIOR")){
974 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
975 for(int i = 0; i < nbSf; i++){
976 SUIT_ViewWindow *sf = aViews[i];
977 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
978 SMESH::RemoveActor(sf,anActor);
983 /** Remove an object from data structures **/
984 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
985 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
986 if ( !aGroup->_is_nil() ) { // DELETE GROUP
987 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
988 aMesh->RemoveGroup( aGroup );
990 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
991 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
992 aMesh->RemoveSubMesh( aSubMesh );
994 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
996 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
999 IObject = new SALOME_InteractiveObject
1000 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1001 QString objType = CheckTypeObject(IObject);
1002 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1003 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1004 aStudyBuilder->RemoveObjectWithChildren( SO );
1006 else {// default action: remove SObject from the study
1007 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1008 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1010 aStudyBuilder->RemoveObjectWithChildren( SO );
1014 } /* listSO back loop */
1015 } /* IObject->hasEntry() */
1017 aStudyBuilder->CommitCommand();
1019 /* Clear any previous selection */
1021 aSel->setSelectedObjects( l1 );
1023 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1028 SMESHGUI_EXPORT CAM_Module* createModule()
1030 return new SMESHGUI();
1034 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1036 //=============================================================================
1040 //=============================================================================
1041 SMESHGUI::SMESHGUI() :
1042 SalomeApp_Module( "SMESH" )
1044 if ( CORBA::is_nil( myComponentSMESH ) )
1046 CORBA::Boolean anIsEmbeddedMode;
1047 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1050 myActiveDialogBox = 0;
1051 myFilterLibraryDlg = 0;
1055 SMESH::GetFilterManager();
1056 SMESH::GetPattern();
1058 /* load resources for all available meshers */
1059 SMESH::InitAvailableHypotheses();
1062 //=============================================================================
1066 //=============================================================================
1067 SMESHGUI::~SMESHGUI()
1069 SMESH::GetFilterManager()->Destroy();
1070 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1073 //=============================================================================
1077 //=============================================================================
1078 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1080 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1082 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1087 bool SMESHGUI::automaticUpdate()
1089 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1093 return resMgr->booleanValue( "SMESH", "auto_update", false );
1096 //=============================================================================
1100 //=============================================================================
1101 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1103 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1106 //=============================================================================
1110 //=============================================================================
1111 SMESHGUI* SMESHGUI::GetSMESHGUI()
1113 SMESHGUI* smeshMod = 0;
1114 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1117 CAM_Module* module = app->module( "Mesh" );
1118 smeshMod = dynamic_cast<SMESHGUI*>( module );
1121 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1123 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1126 _PTR(Study) aStudy = study->studyDS();
1128 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1137 Standard_EXPORT SMESHGUI* GetComponentGUI()
1139 return SMESHGUI::GetSMESHGUI();
1143 //=============================================================================
1147 //=============================================================================
1148 void SMESHGUI::SetState(int aState)
1153 //=============================================================================
1157 //=============================================================================
1158 void SMESHGUI::ResetState()
1163 //=============================================================================
1167 //=============================================================================
1168 void SMESHGUI::EmitSignalDeactivateDialog()
1170 emit SignalDeactivateActiveDialog();
1173 //=============================================================================
1177 //=============================================================================
1178 void SMESHGUI::EmitSignalStudyFrameChanged()
1180 emit SignalStudyFrameChanged();
1183 //=============================================================================
1187 //=============================================================================
1188 void SMESHGUI::EmitSignalCloseAllDialogs()
1190 emit SignalCloseAllDialogs();
1193 //=============================================================================
1197 //=============================================================================
1198 QDialog *SMESHGUI::GetActiveDialogBox()
1200 return myActiveDialogBox;
1203 //=============================================================================
1207 //=============================================================================
1208 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1210 myActiveDialogBox = (QDialog *) aDlg;
1214 //=============================================================================
1218 //=============================================================================
1219 SUIT_Desktop* SMESHGUI::desktop()
1221 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1223 return app->desktop();
1228 //=============================================================================
1232 //=============================================================================
1233 SalomeApp_Study* SMESHGUI::activeStudy()
1235 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1237 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1242 //=============================================================================
1246 //=============================================================================
1247 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1249 /* Here the position is on the bottom right corner - 10 */
1250 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1252 SUIT_Desktop *PP = desktop();
1253 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1254 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1258 //=============================================================================
1262 //=============================================================================
1263 static int isStudyLocked(_PTR(Study) theStudy){
1264 return theStudy->GetProperties()->IsLocked();
1267 static bool checkLock(_PTR(Study) theStudy) {
1268 if (isStudyLocked(theStudy)) {
1269 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1270 QObject::tr("WRN_WARNING"),
1271 QObject::tr("WRN_STUDY_LOCKED") );
1277 //=======================================================================
1278 //function : CheckActiveStudyLocked
1280 //=======================================================================
1282 bool SMESHGUI::isActiveStudyLocked()
1284 _PTR(Study) aStudy = activeStudy()->studyDS();
1285 return checkLock( aStudy );
1288 //=============================================================================
1292 //=============================================================================
1293 bool SMESHGUI::OnGUIEvent( int theCommandID )
1295 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1299 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1300 SUIT_ResourceMgr* mgr = resourceMgr();
1304 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1305 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1308 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1309 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1311 //QAction* act = action( theCommandID );
1313 switch (theCommandID) {
1315 if(checkLock(aStudy)) break;
1323 if(checkLock(aStudy)) break;
1324 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1328 case 150: //MED FILE INFORMATION
1330 SALOME_ListIO selected;
1331 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1333 aSel->selectedObjects( selected );
1334 if( selected.Extent() )
1336 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1337 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1338 if ( !aMesh->_is_nil() )
1340 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1347 case 122: // EXPORT MED
1356 ::ExportMeshToFile(theCommandID);
1360 case 200: // SCALAR BAR
1362 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1363 SALOME_ListIO selected;
1365 aSel->selectedObjects( selected );
1367 if( selected.Extent() ) {
1368 Handle(SALOME_InteractiveObject) anIO = selected.First();
1369 if( anIO->hasEntry() ) {
1370 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1371 anActor->SetControlMode( SMESH_Actor::eNone );
1379 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1389 ::DisableAutoColor();
1392 case 1134: // Clipping
1393 case 1133: // Tranparency
1394 case 1132: // Colors / Size
1401 ::SetDisplayMode(theCommandID);
1407 case 219: // Volumes
1408 case 220: // All Entity
1409 ::SetDisplayEntity(theCommandID);
1412 case 221: // Orientation of faces
1414 LightApp_SelectionMgr* mgr = selectionMgr();
1415 SALOME_ListIO selected; mgr->selectedObjects( selected );
1417 SALOME_ListIteratorOfListIO it(selected);
1418 for( ; it.More(); it.Next()) {
1419 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1420 if(anIObject->hasEntry()) {
1421 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1422 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1431 if(checkLock(aStudy)) break;
1433 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1436 SMESH::UpdateView();
1438 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1439 SMESH::OnVisuException();
1441 catch (...) { // PAL16774 (Crash after display of many groups)
1442 SMESH::OnVisuException();
1446 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1447 aSel->selectedObjects( l );
1448 aSel->setSelectedObjects( l );
1453 case 301: // DISPLAY
1454 case 302: // DISPLAY ONLY
1456 SMESH::EDisplaing anAction;
1457 switch (theCommandID) {
1458 case 300: anAction = SMESH::eErase; break;
1459 case 301: anAction = SMESH::eDisplay; break;
1460 case 302: anAction = SMESH::eDisplayOnly; break;
1463 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1464 SALOME_ListIO sel_objects, to_process;
1466 aSel->selectedObjects( sel_objects );
1468 if( theCommandID==302 )
1469 startOperation( myEraseAll );
1471 extractContainers( sel_objects, to_process );
1474 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1478 SALOME_ListIteratorOfListIO It( to_process );
1479 for ( ; It.More(); It.Next()) {
1480 Handle(SALOME_InteractiveObject) IOS = It.Value();
1481 if (IOS->hasEntry()) {
1482 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1483 break; // PAL16774 (Crash after display of many groups)
1484 if (anAction == SMESH::eDisplayOnly)
1485 anAction = SMESH::eDisplay;
1490 // PAL13338 + PAL15161 -->
1491 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1492 SMESH::UpdateView();
1493 // PAL13338 + PAL15161 <--
1495 catch (...) { // PAL16774 (Crash after display of many groups)
1496 SMESH::OnVisuException();
1499 if (anAction == SMESH::eErase) {
1501 aSel->setSelectedObjects( l1 );
1504 aSel->setSelectedObjects( to_process );
1511 if(checkLock(aStudy)) break;
1514 EmitSignalDeactivateDialog();
1516 ( new SMESHGUI_NodesDlg( this ) )->show();
1519 SUIT_MessageBox::warning(desktop(),
1520 tr("SMESH_WRN_WARNING"),
1521 tr("SMESH_WRN_VIEWER_VTK"));
1526 case 2151: // FILTER
1530 EmitSignalDeactivateDialog();
1531 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1536 case 406: // MOVE NODE
1540 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1541 tr( "NOT_A_VTK_VIEWER" ) );
1545 if(checkLock(aStudy)) break;
1546 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1550 case 701: // COMPUTE MESH
1552 if (checkLock(aStudy)) break;
1554 startOperation( 701 );
1558 case 702: // Create mesh
1559 startOperation( 702 );
1561 case 703: // Create sub-mesh
1562 startOperation( 703 );
1564 case 704: // Edit mesh/sub-mesh
1565 startOperation( 704 );
1567 case 710: // Build compound mesh
1569 if (checkLock(aStudy)) break;
1570 EmitSignalDeactivateDialog();
1571 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1575 case 407: // DIAGONAL INVERSION
1576 case 408: // Delete diagonal
1580 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1581 tr( "NOT_A_VTK_VIEWER" ) );
1585 if ( checkLock( aStudy ) )
1588 /*Standard_Boolean aRes;
1589 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1590 if ( aMesh->_is_nil() )
1592 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1593 tr( "SMESH_BAD_SELECTION" ) );
1597 EmitSignalDeactivateDialog();
1598 if ( theCommandID == 407 )
1599 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1601 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1604 case 409: // Change orientation
1605 case 410: // Union of triangles
1606 case 411: // Cutting of quadrangles
1610 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1611 tr( "NOT_A_VTK_VIEWER" ) );
1615 if ( checkLock( aStudy ) )
1618 EmitSignalDeactivateDialog();
1619 SMESHGUI_MultiEditDlg* aDlg = NULL;
1620 if ( theCommandID == 409 )
1621 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1622 else if ( theCommandID == 410 )
1623 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1625 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1630 case 412: // Smoothing
1632 if(checkLock(aStudy)) break;
1634 EmitSignalDeactivateDialog();
1635 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1638 SUIT_MessageBox::warning(desktop(),
1639 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1643 case 413: // Extrusion
1645 if (checkLock(aStudy)) break;
1647 EmitSignalDeactivateDialog();
1648 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1650 SUIT_MessageBox::warning(desktop(),
1651 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1655 case 414: // Revolution
1657 if(checkLock(aStudy)) break;
1659 EmitSignalDeactivateDialog();
1660 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1663 SUIT_MessageBox::warning(desktop(),
1664 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1668 case 415: // Pattern mapping
1670 if ( checkLock( aStudy ) )
1674 EmitSignalDeactivateDialog();
1675 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1678 SUIT_MessageBox::warning(desktop(),
1679 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1683 case 416: // Extrusion along a path
1685 if (checkLock(aStudy)) break;
1687 EmitSignalDeactivateDialog();
1688 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1690 SUIT_MessageBox::warning(desktop(),
1691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1695 case 417: // Convert mesh to quadratic
1697 startOperation( 417 );
1698 /* if (checkLock(aStudy)) break;
1700 EmitSignalDeactivateDialog();
1701 new SMESHGUI_ConvToQuadDlg();
1703 SUIT_MessageBox::warning(desktop(),
1704 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1708 case 801: // CREATE GROUP
1712 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1713 tr( "NOT_A_VTK_VIEWER" ) );
1717 if(checkLock(aStudy)) break;
1718 EmitSignalDeactivateDialog();
1719 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1721 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1722 SALOME_ListIO selected;
1724 aSel->selectedObjects( selected );
1726 int nbSel = selected.Extent();
1728 // check if mesh is selected
1729 aMesh = SMESH::GetMeshByIO( selected.First() );
1731 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1736 case 802: // CONSTRUCT GROUP
1740 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1741 tr( "NOT_A_VTK_VIEWER" ) );
1745 if(checkLock(aStudy)) break;
1746 EmitSignalDeactivateDialog();
1748 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1749 SALOME_ListIO selected;
1751 aSel->selectedObjects( selected );
1753 int nbSel = selected.Extent();
1755 // check if submesh is selected
1756 Handle(SALOME_InteractiveObject) IObject = selected.First();
1757 if (IObject->hasEntry()) {
1758 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1760 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1761 if (!aSubMesh->_is_nil()) {
1763 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1764 // get submesh elements list by types
1765 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1766 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1767 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1768 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1769 // create group for each type o elements
1770 QString aName = IObject->getName();
1771 if (aNodes->length() > 0) {
1772 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1773 aGroup->Add(aNodes.inout());
1775 if (aEdges->length() > 0) {
1776 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1777 aGroup->Add(aEdges.inout());
1779 if (aFaces->length() > 0) {
1780 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1781 aGroup->Add(aFaces.inout());
1783 if (aVolumes->length() > 0) {
1784 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1785 aGroup->Add(aVolumes.inout());
1790 catch(const SALOME::SALOME_Exception & S_ex){
1791 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1798 SUIT_MessageBox::warning(desktop(),
1799 tr("SMESH_WRN_WARNING"),
1800 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1805 case 803: // EDIT GROUP
1809 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1810 tr( "NOT_A_VTK_VIEWER" ) );
1814 if(checkLock(aStudy)) break;
1815 EmitSignalDeactivateDialog();
1817 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1818 SALOME_ListIO selected;
1820 aSel->selectedObjects( selected );
1822 SALOME_ListIteratorOfListIO It (selected);
1823 int nbSelectedGroups = 0;
1824 for ( ; It.More(); It.Next() )
1826 SMESH::SMESH_GroupBase_var aGroup =
1827 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1828 if (!aGroup->_is_nil()) {
1830 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1834 if (nbSelectedGroups == 0)
1836 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1842 case 804: // Add elements to group
1844 if(checkLock(aStudy)) break;
1845 if (myState == 800) {
1846 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1847 if (aDlg) aDlg->onAdd();
1852 case 805: // Remove elements from group
1854 if(checkLock(aStudy)) break;
1855 if (myState == 800) {
1856 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1857 if (aDlg) aDlg->onRemove();
1862 case 810: // Union Groups
1863 case 811: // Intersect groups
1864 case 812: // Cut groups
1868 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1869 tr( "NOT_A_VTK_VIEWER" ) );
1873 if ( checkLock( aStudy ) )
1876 EmitSignalDeactivateDialog();
1879 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1880 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1881 else aMode = SMESHGUI_GroupOpDlg::CUT;
1883 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1887 case 813: // Delete groups with their contents
1891 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1892 tr( "NOT_A_VTK_VIEWER" ) );
1896 if ( checkLock( aStudy ) )
1899 EmitSignalDeactivateDialog();
1901 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1905 case 900: // MESH INFOS
1907 EmitSignalDeactivateDialog();
1908 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1909 SALOME_ListIO selected;
1911 aSel->selectedObjects( selected );
1913 if ( selected.Extent() > 1 ) { // a dlg for each IO
1915 SALOME_ListIteratorOfListIO It (selected);
1916 for ( ; It.More(); It.Next() ) {
1917 IOs.Clear(); IOs.Append( It.Value() );
1918 aSel->setSelectedObjects( IOs );
1919 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1921 // restore selection
1922 aSel->setSelectedObjects( selected );
1925 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1929 case 902: // STANDARD MESH INFOS
1931 EmitSignalDeactivateDialog();
1932 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1933 SALOME_ListIO selected;
1935 aSel->selectedObjects( selected );
1937 if ( selected.Extent() > 1 ) { // a dlg for each IO
1939 SALOME_ListIteratorOfListIO It (selected);
1940 for ( ; It.More(); It.Next() ) {
1942 IOs.Append( It.Value() );
1943 aSel->setSelectedObjects( IOs );
1944 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1946 // restore selection
1947 aSel->setSelectedObjects( selected );
1950 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1954 case 903: // WHAT IS
1956 EmitSignalDeactivateDialog();
1957 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1961 case 1100: // EDIT HYPOTHESIS
1963 if(checkLock(aStudy)) break;
1965 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1966 SALOME_ListIO selected;
1968 aSel->selectedObjects( selected );
1970 int nbSel = selected.Extent();
1973 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1974 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1976 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1977 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1978 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1979 if ( !aHypothesis->_is_nil() )
1981 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
1983 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1990 updateObjBrowser( true );
1994 case 1101: // RENAME
1996 if ( checkLock( aStudy ) )
1999 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2000 SALOME_ListIO selected;
2002 aSel->selectedObjects( selected );
2004 bool isAny = false; // iss there any appropriate object selected
2006 SALOME_ListIteratorOfListIO It( selected );
2007 for ( ; It.More(); It.Next() )
2009 Handle(SALOME_InteractiveObject) IObject = It.Value();
2010 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2011 _PTR(GenericAttribute) anAttr;
2012 _PTR(AttributeName) aName;
2015 if ( obj->FindAttribute(anAttr, "AttributeName") )
2018 QString newName = QString(aName->Value().c_str());
2020 // check type to prevent renaming of inappropriate objects
2021 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2022 if (aType == MESH || aType == GROUP ||
2023 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2024 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2025 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2026 aType == HYPOTHESIS || aType == ALGORITHM)
2029 newName = LightApp_NameDlg::getName(desktop(), newName);
2030 if ( !newName.isEmpty() )
2032 //old source: aStudy->renameIObject( IObject, newName );
2033 aName->SetValue( newName.toLatin1().constData() );
2035 // if current object is group update group's name
2036 SMESH::SMESH_GroupBase_var aGroup =
2037 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2038 if (!aGroup->_is_nil() )
2039 aGroup->SetName( newName.toLatin1().constData() );
2049 SUIT_MessageBox::warning(desktop(),
2050 QObject::tr("SMESH_WRN_WARNING"),
2051 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2056 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2058 if(checkLock(aStudy)) break;
2059 SUIT_OverrideCursor wc;
2061 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2062 SALOME_ListIO selected;
2064 aSel->selectedObjects( selected, QString::null, false );
2066 SALOME_ListIteratorOfListIO It(selected);
2067 for (int i = 0; It.More(); It.Next(), i++) {
2068 Handle(SALOME_InteractiveObject) IObject = It.Value();
2069 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2072 aSel->setSelectedObjects( l1 );
2077 case 401: // GEOM::EDGE
2078 case 4021: // TRIANGLE
2080 case 4023: // POLYGON
2084 if(checkLock(aStudy)) break;
2086 EmitSignalDeactivateDialog();
2087 SMDSAbs_ElementType type = SMDSAbs_Edge;
2089 switch (theCommandID) {
2090 case 4021: // TRIANGLE
2091 type = SMDSAbs_Face; nbNodes = 3; break;
2093 type = SMDSAbs_Face; nbNodes = 4; break;
2095 type = SMDSAbs_Volume; nbNodes = 4; break;
2096 case 4023: // POLYGON
2097 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2099 type = SMDSAbs_Volume; nbNodes = 8; break;
2100 case 4033: // POLYHEDRE
2101 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2104 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2107 SUIT_MessageBox::warning(desktop(),
2108 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2112 case 4033: // POLYHEDRON
2114 if(checkLock(aStudy)) break;
2116 EmitSignalDeactivateDialog();
2117 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2120 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2121 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2125 case 4034: // QUADRATIC EDGE
2126 case 4035: // QUADRATIC TRIANGLE
2127 case 4036: // QUADRATIC QUADRANGLE
2128 case 4037: // QUADRATIC TETRAHEDRON
2129 case 4038: // QUADRATIC PYRAMID
2130 case 4039: // QUADRATIC PENTAHEDRON
2131 case 4040: // QUADRATIC HEXAHEDRON
2133 if(checkLock(aStudy)) break;
2135 EmitSignalDeactivateDialog();
2138 switch (theCommandID) {
2140 type = QUAD_EDGE; break;
2142 type = QUAD_TRIANGLE; break;
2144 type = QUAD_QUADRANGLE; break;
2146 type = QUAD_TETRAHEDRON; break;
2148 type = QUAD_PYRAMID; break;
2150 type = QUAD_PENTAHEDRON; break;
2152 type = QUAD_HEXAHEDRON;
2156 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2159 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2160 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2164 case 4041: // REMOVES NODES
2166 if(checkLock(aStudy)) break;
2168 EmitSignalDeactivateDialog();
2169 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2172 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2173 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2177 case 4042: // REMOVES ELEMENTS
2179 if(checkLock(aStudy)) break;
2181 EmitSignalDeactivateDialog();
2182 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2186 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2187 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2191 case 4043: { // CLEAR_MESH
2193 if(checkLock(aStudy)) break;
2195 SALOME_ListIO selected;
2196 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2197 aSel->selectedObjects( selected );
2199 SUIT_OverrideCursor wc;
2200 SALOME_ListIteratorOfListIO It (selected);
2201 for ( ; It.More(); It.Next() )
2203 Handle(SALOME_InteractiveObject) IOS = It.Value();
2204 SMESH::SMESH_Mesh_var aMesh =
2205 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2206 if ( aMesh->_is_nil()) continue;
2208 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2210 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2211 SMESH::ModifiedMesh( aMeshSObj, false, true);
2212 // hide groups and submeshes
2213 _PTR(ChildIterator) anIter =
2214 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2215 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2217 _PTR(SObject) so = anIter->Value();
2218 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2221 catch (const SALOME::SALOME_Exception& S_ex){
2223 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2227 SMESH::UpdateView();
2231 case 4051: // RENUMBERING NODES
2233 if(checkLock(aStudy)) break;
2235 EmitSignalDeactivateDialog();
2236 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2240 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2241 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2245 case 4052: // RENUMBERING ELEMENTS
2247 if(checkLock(aStudy)) break;
2249 EmitSignalDeactivateDialog();
2250 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2254 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2255 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2259 case 4061: // TRANSLATION
2261 if(checkLock(aStudy)) break;
2263 EmitSignalDeactivateDialog();
2264 ( new SMESHGUI_TranslationDlg( this ) )->show();
2267 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2268 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2272 case 4062: // ROTATION
2274 if(checkLock(aStudy)) break;
2276 EmitSignalDeactivateDialog();
2277 ( new SMESHGUI_RotationDlg( this ) )->show();
2280 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2281 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2285 case 4063: // SYMMETRY
2287 if(checkLock(aStudy)) break;
2289 EmitSignalDeactivateDialog();
2290 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2293 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2294 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2298 case 4064: // SEWING
2300 if(checkLock(aStudy)) break;
2302 EmitSignalDeactivateDialog();
2303 ( new SMESHGUI_SewingDlg( this ) )->show();
2306 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2307 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2311 case 4065: // MERGE NODES
2313 if(checkLock(aStudy)) break;
2315 EmitSignalDeactivateDialog();
2316 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2319 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2320 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2324 case 4066: // MERGE EQUAL ELEMENTS
2326 if (checkLock(aStudy)) break;
2328 EmitSignalDeactivateDialog();
2329 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2331 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2332 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2337 case 4067: // MAKE MESH PASS THROUGH POINT
2338 startOperation( 4067 );
2341 case 5105: // Library of selection filters
2343 static QList<int> aTypes;
2344 if ( aTypes.isEmpty() )
2346 aTypes.append( SMESH::NODE );
2347 aTypes.append( SMESH::EDGE );
2348 aTypes.append( SMESH::FACE );
2349 aTypes.append( SMESH::VOLUME );
2351 if (!myFilterLibraryDlg)
2352 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2353 else if (myFilterLibraryDlg->isHidden())
2354 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2355 myFilterLibraryDlg->raise();
2359 case 6017: // CONTROLS
2375 LightApp_SelectionMgr* mgr = selectionMgr();
2376 SALOME_ListIO selected; mgr->selectedObjects( selected );
2378 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2379 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2381 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2382 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2383 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2384 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2385 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2386 ::Control( theCommandID );
2391 SUIT_MessageBox::warning(desktop(),
2392 tr( "SMESH_WRN_WARNING" ),
2393 tr( "SMESH_BAD_SELECTION" ) );
2397 SUIT_MessageBox::warning(desktop(),
2398 tr( "SMESH_WRN_WARNING" ),
2399 tr( "NOT_A_VTK_VIEWER" ) );
2404 LightApp_SelectionMgr* mgr = selectionMgr();
2405 SALOME_ListIO selected; mgr->selectedObjects( selected );
2407 SALOME_ListIteratorOfListIO it(selected);
2408 for( ; it.More(); it.Next()) {
2409 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2410 if(anIObject->hasEntry()) {
2411 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2412 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2420 LightApp_SelectionMgr* mgr = selectionMgr();
2421 SALOME_ListIO selected; mgr->selectedObjects( selected );
2423 if (selected.Extent() == 1) {
2424 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2425 if(anIObject->hasEntry())
2426 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2427 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2434 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2435 //updateObjBrowser();
2439 //=============================================================================
2443 //=============================================================================
2444 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2449 //=============================================================================
2453 //=============================================================================
2454 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2459 //=============================================================================
2463 //=============================================================================
2464 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2469 //=============================================================================
2470 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2471 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2473 //=============================================================================
2474 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2475 SUIT_ViewWindow* wnd )
2477 if(theIO->hasEntry()){
2478 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2479 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2483 //=======================================================================
2484 // function : createSMESHAction
2486 //=======================================================================
2487 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2490 QWidget* parent = application()->desktop();
2491 SUIT_ResourceMgr* resMgr = resourceMgr();
2493 if ( !icon_id.isEmpty() )
2494 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2496 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2497 if ( !pix.isNull() )
2498 icon = QIcon( pix );
2500 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2501 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2502 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2504 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2507 //=======================================================================
2508 // function : createPopupItem
2510 //=======================================================================
2511 void SMESHGUI::createPopupItem( const int id,
2512 const QString& clients,
2513 const QString& types,
2514 const QString& theRule,
2519 parentId = popupMgr()->actionId( action( pId ) );
2521 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2522 popupMgr()->insert( action( id ), parentId, 0 );
2524 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2525 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2526 QString rule = "(%1) and (%2) and (%3)";
2527 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2528 if( clients.isEmpty() )
2529 rule = rule.arg( QString( "true" ) );
2531 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2532 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2535 bool cont = myRules.contains( id );
2537 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2539 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2540 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2543 //=======================================================================
2544 // function : initialize
2546 //=======================================================================
2547 void SMESHGUI::initialize( CAM_Application* app )
2549 SalomeApp_Module::initialize( app );
2551 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2553 /* Automatic Update flag */
2554 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2556 // ----- create actions --------------
2558 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2559 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2560 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2561 createSMESHAction( 114, "NUM" );
2562 createSMESHAction( 121, "DAT" );
2563 createSMESHAction( 122, "MED" );
2564 createSMESHAction( 123, "UNV" );
2565 createSMESHAction( 140, "STL" );
2566 createSMESHAction( 124, "EXPORT_DAT" );
2567 createSMESHAction( 125, "EXPORT_MED" );
2568 createSMESHAction( 126, "EXPORT_UNV" );
2569 createSMESHAction( 141, "EXPORT_STL" );
2570 createSMESHAction( 150, "FILE_INFO" );
2571 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2572 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2573 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2574 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2575 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2576 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2577 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2578 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2579 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2580 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2581 createSMESHAction( 804, "ADD" );
2582 createSMESHAction( 805, "REMOVE" );
2583 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2584 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2585 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2586 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2587 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2588 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2589 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2590 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2591 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2592 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2593 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2594 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2595 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2596 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2597 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2598 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2599 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2600 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2601 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2602 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2603 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2604 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2605 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2606 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2607 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2608 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2609 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2610 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2611 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2612 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2613 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2614 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2615 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2616 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2617 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2618 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2619 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2620 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2621 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2622 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2623 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2624 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2625 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2626 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2627 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2628 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2629 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2630 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2631 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2632 createSMESHAction( 415, "MAP", "ICON_MAP" );
2633 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2634 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2635 createSMESHAction( 200, "RESET" );
2636 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2637 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2638 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2639 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2640 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2641 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2642 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2643 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2644 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2645 createSMESHAction( 220, "ALL" );
2646 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2647 createSMESHAction( 1100, "EDIT_HYPO" );
2648 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2649 createSMESHAction( 1102, "UNASSIGN" );
2650 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2651 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2652 createSMESHAction( 1131, "DISPMODE" );
2653 createSMESHAction( 1132, "COLORS" );
2654 createSMESHAction( 1133, "TRANSP" );
2655 createSMESHAction( 1134, "CLIP" );
2656 createSMESHAction( 1135, "DISP_ENT" );
2657 createSMESHAction( 1136, "AUTO_COLOR" );
2658 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2659 createSMESHAction( 2000, "CTRL" );
2661 createSMESHAction( 300, "ERASE" );
2662 createSMESHAction( 301, "DISPLAY" );
2663 createSMESHAction( 302, "DISPLAY_ONLY" );
2664 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2665 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2666 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2667 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2668 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2669 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2670 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2671 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2673 // ----- create menu --------------
2674 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2675 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2676 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2677 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2678 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2679 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2680 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2682 createMenu( separator(), fileId );
2684 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2685 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2686 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2687 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2688 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2689 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2691 createMenu( 111, importId, -1 );
2692 createMenu( 112, importId, -1 );
2693 createMenu( 113, importId, -1 );
2695 createMenu( 121, exportId, -1 );
2696 createMenu( 122, exportId, -1 );
2697 createMenu( 123, exportId, -1 );
2698 createMenu( 140, exportId, -1 ); // export to stl STL
2700 createMenu( separator(), fileId, 10 );
2702 createMenu( 33, editId, -1 );
2704 createMenu( 5105, toolsId, -1 );
2706 createMenu( 702, meshId, -1 ); // "Mesh" menu
2707 createMenu( 703, meshId, -1 );
2708 createMenu( 704, meshId, -1 );
2709 createMenu( 710, meshId, -1 );
2710 createMenu( separator(), meshId, -1 );
2711 createMenu( 701, meshId, -1 );
2712 createMenu( separator(), meshId, -1 );
2713 createMenu( 801, meshId, -1 );
2714 createMenu( 802, meshId, -1 );
2715 createMenu( 803, meshId, -1 );
2716 createMenu( separator(), meshId, -1 );
2717 createMenu( 810, meshId, -1 );
2718 createMenu( 811, meshId, -1 );
2719 createMenu( 812, meshId, -1 );
2720 createMenu( separator(), meshId, -1 );
2721 createMenu( 813, meshId, -1 );
2722 createMenu( separator(), meshId, -1 );
2723 createMenu( 900, meshId, -1 );
2724 createMenu( 902, meshId, -1 );
2725 createMenu( 903, meshId, -1 );
2726 createMenu( separator(), meshId, -1 );
2728 createMenu( 6003, ctrlId, -1 );
2729 createMenu( 6001, ctrlId, -1 );
2730 createMenu( 6004, ctrlId, -1 );
2731 createMenu( separator(), ctrlId, -1 );
2732 createMenu( 6002, ctrlId, -1 );
2733 createMenu( 6018, ctrlId, -1 );
2734 createMenu( 6019, ctrlId, -1 );
2735 createMenu( 6011, ctrlId, -1 );
2736 createMenu( 6012, ctrlId, -1 );
2737 createMenu( 6013, ctrlId, -1 );
2738 createMenu( 6014, ctrlId, -1 );
2739 createMenu( 6015, ctrlId, -1 );
2740 createMenu( 6016, ctrlId, -1 );
2741 createMenu( separator(), ctrlId, -1 );
2742 createMenu( 6017, ctrlId, -1 );
2743 createMenu( 6009, ctrlId, -1 );
2744 createMenu( separator(), ctrlId, -1 );
2746 createMenu( 400, addId, -1 );
2747 createMenu( 401, addId, -1 );
2748 createMenu( 4021, addId, -1 );
2749 createMenu( 4022, addId, -1 );
2750 createMenu( 4023, addId, -1 );
2751 createMenu( 4031, addId, -1 );
2752 createMenu( 4032, addId, -1 );
2753 createMenu( 4033, addId, -1 );
2754 createMenu( separator(), addId, -1 );
2755 createMenu( 4034, addId, -1 );
2756 createMenu( 4035, addId, -1 );
2757 createMenu( 4036, addId, -1 );
2758 createMenu( 4037, addId, -1 );
2759 createMenu( 4038, addId, -1 );
2760 createMenu( 4039, addId, -1 );
2761 createMenu( 4040, addId, -1 );
2763 createMenu( 4041, removeId, -1 );
2764 createMenu( 4042, removeId, -1 );
2765 createMenu( 4043, removeId, -1 );
2767 createMenu( 4051, renumId, -1 );
2768 createMenu( 4052, renumId, -1 );
2770 createMenu( 4061, transfId, -1 );
2771 createMenu( 4062, transfId, -1 );
2772 createMenu( 4063, transfId, -1 );
2773 createMenu( 4064, transfId, -1 );
2774 createMenu( 4065, transfId, -1 );
2775 createMenu( 4066, transfId, -1 );
2777 createMenu( 406, modifyId, -1 );
2778 createMenu( 4067,modifyId, -1 );
2779 createMenu( 407, modifyId, -1 );
2780 createMenu( 408, modifyId, -1 );
2781 createMenu( 409, modifyId, -1 );
2782 createMenu( 410, modifyId, -1 );
2783 createMenu( 411, modifyId, -1 );
2784 createMenu( 412, modifyId, -1 );
2785 createMenu( 413, modifyId, -1 );
2786 createMenu( 416, modifyId, -1 );
2787 createMenu( 414, modifyId, -1 );
2788 createMenu( 415, modifyId, -1 );
2789 createMenu( 417, modifyId, -1 );
2791 createMenu( 214, viewId, -1 );
2793 // ----- create toolbars --------------
2794 int meshTb = createTool( tr( "TB_MESH" ) ),
2795 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2796 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2797 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2798 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2800 createTool( 702, meshTb );
2801 createTool( 703, meshTb );
2802 createTool( 704, meshTb );
2803 createTool( 710, meshTb );
2804 createTool( separator(), meshTb );
2805 createTool( 701, meshTb );
2806 createTool( separator(), meshTb );
2807 createTool( 801, meshTb );
2808 createTool( 802, meshTb );
2809 createTool( 803, meshTb );
2810 createTool( separator(), meshTb );
2811 createTool( 900, meshTb );
2812 createTool( 902, meshTb );
2813 createTool( 903, meshTb );
2814 createTool( separator(), meshTb );
2816 createTool( 6001, ctrlTb );
2817 createTool( 6003, ctrlTb );
2818 createTool( 6004, ctrlTb );
2819 createTool( separator(), ctrlTb );
2820 createTool( 6002, ctrlTb );
2821 createTool( 6018, ctrlTb );
2822 createTool( 6019, ctrlTb );
2823 createTool( 6011, ctrlTb );
2824 createTool( 6012, ctrlTb );
2825 createTool( 6013, ctrlTb );
2826 createTool( 6014, ctrlTb );
2827 createTool( 6015, ctrlTb );
2828 createTool( 6016, ctrlTb );
2829 createTool( separator(), ctrlTb );
2830 createTool( 6017, ctrlTb );
2831 createTool( 6009, ctrlTb );
2832 createTool( separator(), ctrlTb );
2834 createTool( 400, addRemTb );
2835 createTool( 401, addRemTb );
2836 createTool( 4021, addRemTb );
2837 createTool( 4022, addRemTb );
2838 createTool( 4023, addRemTb );
2839 createTool( 4031, addRemTb );
2840 createTool( 4032, addRemTb );
2841 createTool( 4033, addRemTb );
2842 createTool( separator(), addRemTb );
2843 createTool( 4034, addRemTb );
2844 createTool( 4035, addRemTb );
2845 createTool( 4036, addRemTb );
2846 createTool( 4037, addRemTb );
2847 createTool( 4038, addRemTb );
2848 createTool( 4039, addRemTb );
2849 createTool( 4040, addRemTb );
2850 createTool( separator(), addRemTb );
2851 createTool( 4041, addRemTb );
2852 createTool( 4042, addRemTb );
2853 createTool( 4043, addRemTb );
2854 createTool( separator(), addRemTb );
2855 createTool( 4051, addRemTb );
2856 createTool( 4052, addRemTb );
2857 createTool( separator(), addRemTb );
2858 createTool( 4061, addRemTb );
2859 createTool( 4062, addRemTb );
2860 createTool( 4063, addRemTb );
2861 createTool( 4064, addRemTb );
2862 createTool( 4065, addRemTb );
2863 createTool( 4066, addRemTb );
2864 createTool( separator(), addRemTb );
2866 createTool( 406, modifyTb );
2867 createTool( 4067,modifyTb );
2868 createTool( 407, modifyTb );
2869 createTool( 408, modifyTb );
2870 createTool( 409, modifyTb );
2871 createTool( 410, modifyTb );
2872 createTool( 411, modifyTb );
2873 createTool( 412, modifyTb );
2874 createTool( 413, modifyTb );
2875 createTool( 416, modifyTb );
2876 createTool( 414, modifyTb );
2877 createTool( 415, modifyTb );
2878 createTool( 417, modifyTb );
2880 createTool( 214, dispModeTb );
2882 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2883 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
2886 QString OB = "'ObjectBrowser'",
2887 View = "'" + SVTK_Viewer::Type() + "'",
2889 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2890 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2891 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2892 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2893 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2894 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2895 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2896 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2897 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2898 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2899 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2901 mesh_group = mesh + " " + subMesh + " " + group,
2902 hyp_alg = hypo + " " + algo;
2904 // popup for object browser
2906 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2907 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2908 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2909 createPopupItem( 803, OB, group ); // EDIT_GROUP
2910 popupMgr()->insert( separator(), -1, 0 );
2911 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2912 createPopupItem( 214, OB, mesh_group ); // UPDATE
2913 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2914 createPopupItem( 902, OB, mesh ); // STD_INFO
2915 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2916 popupMgr()->insert( separator(), -1, 0 );
2917 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2918 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2919 popupMgr()->insert( separator(), -1, 0 );
2920 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2921 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2922 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2923 popupMgr()->insert( separator(), -1, 0 );
2924 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2925 popupMgr()->insert( separator(), -1, 0 );
2927 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2929 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2930 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2931 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2932 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2933 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2934 popupMgr()->insert( separator(), -1, 0 );
2937 createPopupItem( 803, View, group ); // EDIT_GROUP
2938 createPopupItem( 804, View, elems ); // ADD
2939 createPopupItem( 805, View, elems ); // REMOVE
2940 popupMgr()->insert( separator(), -1, 0 );
2941 createPopupItem( 214, View, mesh_group ); // UPDATE
2942 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2943 createPopupItem( 902, View, mesh ); // STD_INFO
2944 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2945 popupMgr()->insert( separator(), -1, 0 );
2947 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2948 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2949 popupMgr()->insert( separator(), -1, 0 );
2953 isInvisible("not( isVisible )"),
2954 isEmpty("numberOfNodes = 0"),
2955 isNotEmpty("numberOfNodes <> 0"),
2957 // has nodes, edges, etc in VISIBLE! actor
2958 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2959 hasElems("(count( elemTypes ) > 0)"),
2960 hasDifferentElems("(count( elemTypes ) > 1)"),
2961 hasEdges("({'Edge'} in elemTypes)"),
2962 hasFaces("({'Face'} in elemTypes)"),
2963 hasVolumes("({'Volume'} in elemTypes)");
2965 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2966 QString aType = QString( "%1type in {%2}" ).arg( lc );
2967 aType = aType.arg( mesh_group );
2968 QString aMeshInVTK = aClient + "&&" + aType;
2970 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2971 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2972 QString aSelCount = QString( "%1 > 0" ).arg( dc );
2974 //-------------------------------------------------
2976 //-------------------------------------------------
2977 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2979 popupMgr()->insert( action( 9010 ), anId, -1 );
2980 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
2981 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
2983 popupMgr()->insert( action( 9011 ), anId, -1 );
2984 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
2985 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
2987 popupMgr()->insert( separator(), -1, -1 );
2989 //-------------------------------------------------
2991 //-------------------------------------------------
2992 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2994 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2995 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
2996 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
2998 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2999 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3000 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3002 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3003 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3004 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3006 popupMgr()->insert( separator(), anId, -1 );
3008 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3009 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3010 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3012 //-------------------------------------------------
3014 //-------------------------------------------------
3015 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3017 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3019 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3020 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3021 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3023 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3024 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3025 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3027 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3028 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3029 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3031 popupMgr()->insert( separator(), anId, -1 );
3033 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3034 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3036 //-------------------------------------------------
3037 // Orientation of faces
3038 //-------------------------------------------------
3039 popupMgr()->insert( action( 221 ), -1, -1 );
3040 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3041 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3043 //-------------------------------------------------
3045 //-------------------------------------------------
3046 popupMgr()->insert( action( 1132 ), -1, -1 );
3047 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3049 //-------------------------------------------------
3051 //-------------------------------------------------
3052 popupMgr()->insert( action( 1133 ), -1, -1 );
3053 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3055 //-------------------------------------------------
3057 //-------------------------------------------------
3058 popupMgr()->insert( action( 1134 ), -1, -1 );
3059 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3061 popupMgr()->insert( separator(), -1, -1 );
3063 //-------------------------------------------------
3065 //-------------------------------------------------
3067 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3068 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3069 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3071 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3073 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3074 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3076 popupMgr()->insert( separator(), anId, -1 );
3078 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3079 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3080 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3082 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3083 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3084 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3086 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3087 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3088 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3090 popupMgr()->insert( separator(), anId, -1 );
3092 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3093 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3094 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3096 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3097 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3098 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3100 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3101 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3102 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3104 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3105 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3106 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3108 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3109 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3110 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3112 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3113 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3114 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3116 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3117 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3118 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3120 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3121 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3122 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3124 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3125 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3126 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3128 popupMgr()->insert( separator(), anId, -1 );
3130 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3131 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3132 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3134 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3135 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3136 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3138 popupMgr()->insert( separator(), anId, -1 );
3140 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3141 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3143 popupMgr()->insert( separator(), -1, -1 );
3145 //-------------------------------------------------
3147 //-------------------------------------------------
3148 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3149 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3150 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3151 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3153 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3154 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3156 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3157 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3159 popupMgr()->insert( separator(), -1, -1 );
3161 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3162 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3165 //================================================================================
3167 * \brief Return true if SMESH or GEOM objects are selected.
3168 * Is called form LightApp_Module::activateModule() which clear selection if
3169 * not isSelectionCompatible()
3171 //================================================================================
3173 bool SMESHGUI::isSelectionCompatible()
3175 bool isCompatible = true;
3176 SALOME_ListIO selected;
3177 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3178 Sel->selectedObjects( selected );
3180 SALOME_ListIteratorOfListIO It( selected );
3181 for ( ; isCompatible && It.More(); It.Next())
3183 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3184 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3186 return isCompatible;
3189 bool SMESHGUI::activateModule( SUIT_Study* study )
3191 bool res = SalomeApp_Module::activateModule( study );
3193 setMenuShown( true );
3194 setToolShown( true );
3196 // Reset actions accelerator keys
3197 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3198 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3199 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3201 action( 33)->setEnabled(true); // Delete: Key_Delete
3202 action(1101)->setEnabled(true); // Rename: Key_F2
3207 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3209 setMenuShown( false );
3210 setToolShown( false );
3212 EmitSignalCloseAllDialogs();
3214 // Unset actions accelerator keys
3215 action(111)->setShortcut(QKeySequence()); // Import DAT
3216 action(112)->setShortcut(QKeySequence()); // Import UNV
3217 action(113)->setShortcut(QKeySequence()); // Import MED
3219 action( 33)->setEnabled(false); // Delete: Key_Delete
3220 action(1101)->setEnabled(false); // Rename: Key_F2
3222 return SalomeApp_Module::deactivateModule( study );
3225 void SMESHGUI::studyClosed( SUIT_Study* s )
3227 SMESH::RemoveVisuData( s->id() );
3228 SalomeApp_Module::studyClosed( s );
3231 void SMESHGUI::OnGUIEvent()
3233 const QObject* obj = sender();
3234 if ( !obj || !obj->inherits( "QAction" ) )
3236 int id = actionId((QAction*)obj);
3241 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3243 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3244 if ( CORBA::is_nil( myComponentSMESH ) )
3246 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3248 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3249 return aGUI.myComponentSMESH;
3252 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3253 return myComponentSMESH;
3256 QString SMESHGUI::engineIOR() const
3258 CORBA::ORB_var anORB = getApp()->orb();
3259 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3260 return QString( anIOR.in() );
3263 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3265 SalomeApp_Module::contextMenuPopup( client, menu, title );
3267 selectionMgr()->selectedObjects( lst );
3268 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3269 Handle(SALOME_InteractiveObject) io = lst.First();
3270 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3271 _PTR(Study) study = appStudy->studyDS();
3272 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3274 QString aName = QString( obj->GetName().c_str() );
3275 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3276 aName.remove( (aName.length() - 1), 1 );
3282 LightApp_Selection* SMESHGUI::createSelection() const
3284 return new SMESHGUI_Selection();
3287 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3289 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3290 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3293 void SMESHGUI::viewManagers( QStringList& list ) const
3295 list.append( SVTK_Viewer::Type() );
3298 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3300 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3301 SMESH::UpdateSelectionProp( this );
3304 void SMESHGUI::createPreferences()
3306 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3308 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3309 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3311 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3312 setPreferenceProperty( qaGroup, "columns", 2 );
3313 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3314 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3316 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3317 setPreferenceProperty( precGroup, "columns", 2 );
3319 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3321 setPreferenceProperty( prec, "min", 0 );
3322 setPreferenceProperty( prec, "max", 16 );
3324 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3325 setPreferenceProperty( dispgroup, "columns", 2 );
3326 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3328 modes.append( "Wireframe" );
3329 modes.append( "Shading" );
3330 modes.append( "Nodes" );
3331 modes.append( "Shrink" );
3332 QList<QVariant> indices;
3333 indices.append( 0 );
3334 indices.append( 1 );
3335 indices.append( 2 );
3336 indices.append( 3 );
3337 setPreferenceProperty( dispmode, "strings", modes );
3338 setPreferenceProperty( dispmode, "indexes", indices );
3340 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3341 setPreferenceProperty( exportgroup, "columns", 2 );
3342 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3343 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3345 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3346 setPreferenceProperty( computeGroup, "columns", 2 );
3347 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3349 modes.append( "Never" );
3350 modes.append( "Errors only" );
3351 modes.append( "Always" );
3353 indices.append( 0 );
3354 indices.append( 1 );
3355 indices.append( 2 );
3356 setPreferenceProperty( notifyMode, "strings", modes );
3357 setPreferenceProperty( notifyMode, "indexes", indices );
3359 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3360 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3361 setPreferenceProperty( nodeGroup, "columns", 2 );
3363 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3364 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3366 setPreferenceProperty( nodeSz, "min", 1 );
3367 setPreferenceProperty( nodeSz, "max", 5 );
3369 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3370 setPreferenceProperty( elemGroup, "columns", 2 );
3372 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3373 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3374 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3375 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3377 setPreferenceProperty( sp, "hstretch", 0 );
3378 setPreferenceProperty( sp, "vstretch", 0 );
3380 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3381 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3383 setPreferenceProperty( elemW, "min", 1 );
3384 setPreferenceProperty( elemW, "max", 5 );
3386 setPreferenceProperty( shrink, "min", 0 );
3387 setPreferenceProperty( shrink, "max", 100 );
3389 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3390 setPreferenceProperty( orientGroup, "columns", 1 );
3392 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3393 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3395 setPreferenceProperty( orientScale, "min", 0.05 );
3396 setPreferenceProperty( orientScale, "max", 0.5 );
3397 setPreferenceProperty( orientScale, "step", 0.05 );
3399 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3401 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3403 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3404 setPreferenceProperty( selGroup, "columns", 2 );
3406 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3407 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3408 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3410 setPreferenceProperty( selW, "min", 1 );
3411 setPreferenceProperty( selW, "max", 5 );
3413 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3414 setPreferenceProperty( preGroup, "columns", 2 );
3416 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3417 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3419 setPreferenceProperty( preW, "min", 1 );
3420 setPreferenceProperty( preW, "max", 5 );
3422 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3423 setPreferenceProperty( precSelGroup, "columns", 2 );
3425 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3426 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3427 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3429 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3430 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3431 setPreferenceProperty( fontGr, "columns", 2 );
3433 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3434 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3435 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3436 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3439 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3440 fam.append( tr( "SMESH_FONT_COURIER" ) );
3441 fam.append( tr( "SMESH_FONT_TIMES" ) );
3442 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3444 setPreferenceProperty( tfont, "families", fam );
3445 setPreferenceProperty( tfont, "system", false );
3446 setPreferenceProperty( tfont, "widget_flags", wflag );
3447 setPreferenceProperty( lfont, "families", fam );
3448 setPreferenceProperty( lfont, "system", false );
3449 setPreferenceProperty( lfont, "widget_flags", wflag );
3451 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3452 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3454 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3455 setPreferenceProperty( numcol, "min", 2 );
3456 setPreferenceProperty( numcol, "max", 256 );
3458 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3459 setPreferenceProperty( numlab, "min", 2 );
3460 setPreferenceProperty( numlab, "max", 65 );
3462 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3463 setPreferenceProperty( orientGr, "columns", 2 );
3464 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3465 QStringList orients;
3466 orients.append( tr( "SMESH_VERTICAL" ) );
3467 orients.append( tr( "SMESH_HORIZONTAL" ) );
3468 indices.clear(); indices.append( 0 ); indices.append( 1 );
3469 setPreferenceProperty( orient, "strings", orients );
3470 setPreferenceProperty( orient, "indexes", indices );
3472 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3473 setPreferenceProperty( posVSizeGr, "columns", 2 );
3474 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3475 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3476 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3477 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3478 setPreferenceProperty( xv, "step", 0.1 );
3479 setPreferenceProperty( xv, "min", 0.0 );
3480 setPreferenceProperty( xv, "max", 1.0 );
3481 setPreferenceProperty( yv, "step", 0.1 );
3482 setPreferenceProperty( yv, "min", 0.0 );
3483 setPreferenceProperty( yv, "max", 1.0 );
3484 setPreferenceProperty( wv, "step", 0.1 );
3485 setPreferenceProperty( wv, "min", 0.0 );
3486 setPreferenceProperty( wv, "max", 1.0 );
3487 setPreferenceProperty( hv, "min", 0.0 );
3488 setPreferenceProperty( hv, "max", 1.0 );
3489 setPreferenceProperty( hv, "step", 0.1 );
3491 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3492 setPreferenceProperty( posHSizeGr, "columns", 2 );
3493 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3494 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3495 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3496 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3497 setPreferenceProperty( xv, "min", 0.0 );
3498 setPreferenceProperty( xv, "max", 1.0 );
3499 setPreferenceProperty( xv, "step", 0.1 );
3500 setPreferenceProperty( xh, "min", 0.0 );
3501 setPreferenceProperty( xh, "max", 1.0 );
3502 setPreferenceProperty( xh, "step", 0.1 );
3503 setPreferenceProperty( yh, "min", 0.0 );
3504 setPreferenceProperty( yh, "max", 1.0 );
3505 setPreferenceProperty( yh, "step", 0.1 );
3506 setPreferenceProperty( wh, "min", 0.0 );
3507 setPreferenceProperty( wh, "max", 1.0 );
3508 setPreferenceProperty( wh, "step", 0.1 );
3509 setPreferenceProperty( hh, "min", 0.0 );
3510 setPreferenceProperty( hh, "max", 1.0 );
3511 setPreferenceProperty( hh, "step", 0.1 );
3514 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3516 if( sect=="SMESH" ){
3517 float sbX1,sbY1,sbW,sbH;
3518 float aTol = 1.00000009999999;
3519 std::string aWarning;
3520 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3521 if( name=="selection_object_color" || name=="selection_element_color" ||
3522 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3523 name=="selection_precision_node" || name=="selection_precision_element" ||
3524 name=="selection_precision_object")
3525 SMESH::UpdateSelectionProp( this );
3526 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3527 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3528 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3529 if(sbX1+sbW > aTol){
3530 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3533 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3534 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3537 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3538 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3539 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3540 if(sbY1+sbH > aTol){
3541 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3542 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3543 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3546 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3547 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3548 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3549 if(sbX1+sbW > aTol){
3550 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3553 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3554 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3557 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3558 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3559 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3560 if(sbY1+sbH > aTol){
3561 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3564 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3565 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3569 if(aWarning.size() != 0){
3570 aWarning += "The default values are applied instead.";
3571 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3572 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3573 QObject::tr(aWarning.c_str()));
3578 //================================================================================
3580 * \brief Update something in accordance with update flags
3581 * \param theFlags - update flags
3583 * Update viewer or/and object browser etc. in accordance with update flags ( see
3584 * LightApp_UpdateFlags enumeration ).
3586 //================================================================================
3587 void SMESHGUI::update( const int flags )
3589 if ( flags & UF_Viewer | flags & UF_Forced )
3590 SMESH::UpdateView();
3592 SalomeApp_Module::update( flags );
3595 //================================================================================
3597 * \brief Set default selection mode
3599 * SLOT called when operation commited. Sets default selection mode
3601 //================================================================================
3602 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3604 SVTK_ViewWindow* vtkWnd =
3605 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3607 vtkWnd->SetSelectionMode( ActorSelection );
3610 //================================================================================
3612 * \brief Set default selection mode
3614 * SLOT called when operation aborted. Sets default selection mode
3616 //================================================================================
3617 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3619 SVTK_ViewWindow* vtkWnd =
3620 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3622 vtkWnd->SetSelectionMode( ActorSelection );
3625 //================================================================================
3627 * \brief Creates operation with given identifier
3628 * \param id - identifier of operation to be started
3629 * \return Pointer on created operation or NULL if operation is not created
3631 * Virtual method redefined from the base class creates operation with given id.
3632 * It is called called automatically from startOperation method of base class.
3634 //================================================================================
3635 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3637 LightApp_Operation* op = 0;
3638 // to do : create operation here
3641 case 701: // Compute mesh
3642 op = new SMESHGUI_ComputeOp();
3644 case 702: // Create mesh
3645 op = new SMESHGUI_MeshOp( true, true );
3647 case 703: // Create sub-mesh
3648 op = new SMESHGUI_MeshOp( true, false );
3650 case 704: // Edit mesh/sub-mesh
3651 op = new SMESHGUI_MeshOp( false );
3653 case 417: //convert to quadratic
3654 op = new SMESHGUI_ConvToQuadOp();
3656 case 4067: // make mesh pass through point
3657 op = new SMESHGUI_MakeNodeAtPointOp();
3664 op = SalomeApp_Module::createOperation( id );
3668 //================================================================================
3670 * \brief Stops current operations and starts a given one
3671 * \param id - The id of the operation to start
3673 //================================================================================
3675 void SMESHGUI::switchToOperation(int id)
3677 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3678 activeStudy()->abortAllOperations();
3679 startOperation( id );
3682 LightApp_Displayer* SMESHGUI::displayer()
3685 myDisplayer = new SMESHGUI_Displayer( getApp() );
3689 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3692 int aTolerance = 64;
3693 int anIterations = 0;
3699 if( anIterations % aPeriod == 0 )
3702 if( aTolerance < 1 )
3705 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3707 aHue = (int)( 360.0 * rand() / RAND_MAX );
3708 //cout << "Hue = " << aHue << endl;
3710 //cout << "Auto colors : ";
3712 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3713 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3714 for( ; it != itEnd; ++it )
3716 SALOMEDS::Color anAutoColor = *it;
3717 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3720 aQColor.getHsv( &h, &s, &v );
3722 if( abs( h - aHue ) < aTolerance )
3725 //cout << "break (diff = " << abs( h - aHue ) << ")";
3735 //cout << "Hue of the returned color = " << aHue << endl;
3737 aColor.setHsv( aHue, 255, 255 );
3739 SALOMEDS::Color aSColor;
3740 aSColor.R = (double)aColor.red() / 255.0;
3741 aSColor.G = (double)aColor.green() / 255.0;
3742 aSColor.B = (double)aColor.blue() / 255.0;
3747 const char gSeparator = '_'; // character used to separate parameter names
3748 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
3751 * \brief Store visual parameters
3753 * This method is called just before the study document is saved.
3754 * Store visual parameters in AttributeParameter attribue(s)
3756 void SMESHGUI::storeVisualParameters (int savePoint)
3758 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3759 if (!appStudy || !appStudy->studyDS())
3761 _PTR(Study) studyDS = appStudy->studyDS();
3763 // componentName is used for encoding of entries when storing them in IParameters
3764 std::string componentName = myComponentSMESH->ComponentDataType();
3765 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
3766 //if (!aSComponent) return;
3769 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3770 componentName.c_str(),
3772 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3774 // viewers counters are used for storing view_numbers in IParameters
3777 // main cycle to store parameters of displayed objects
3778 QList<SUIT_ViewManager*> lst;
3779 QList<SUIT_ViewManager*>::Iterator it;
3780 getApp()->viewManagers(lst);
3781 for (it = lst.begin(); it != lst.end(); it++)
3783 SUIT_ViewManager* vman = *it;
3784 QString vType = vman->getType();
3786 // saving VTK actors properties
3787 if (vType == SVTK_Viewer::Type())
3789 QVector<SUIT_ViewWindow*> views = vman->getViews();
3790 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
3792 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
3794 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
3795 allActors->InitTraversal();
3796 while (vtkActor* actor = allActors->GetNextActor())
3798 if (actor->GetVisibility()) // store only visible actors
3800 SMESH_Actor* aSmeshActor = 0;
3801 if (actor->IsA("SMESH_Actor"))
3802 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
3803 if (aSmeshActor && aSmeshActor->hasIO())
3805 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
3808 // entry is "encoded" = it does NOT contain component adress,
3809 // since it is a subject to change on next component loading
3810 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
3812 std::string param, vtkParam = vType.toLatin1().data();
3813 vtkParam += gSeparator;
3814 vtkParam += QString::number(vtkViewers).toLatin1().data();
3815 vtkParam += gSeparator;
3818 param = vtkParam + "Visibility";
3819 ip->setParameter(entry, param, "On");
3822 param = vtkParam + "Representation";
3823 ip->setParameter(entry, param, QString::number
3824 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
3827 param = vtkParam + "IsShrunk";
3828 ip->setParameter(entry, param, QString::number
3829 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
3831 // Displayed entities
3832 unsigned int aMode = aSmeshActor->GetEntityMode();
3833 bool isE = aMode & SMESH_Actor::eEdges;
3834 bool isF = aMode & SMESH_Actor::eFaces;
3835 bool isV = aMode & SMESH_Actor::eVolumes;
3837 QString modeStr ("e");
3838 modeStr += gDigitsSep; modeStr += QString::number(isE);
3839 modeStr += gDigitsSep; modeStr += "f";
3840 modeStr += gDigitsSep; modeStr += QString::number(isF);
3841 modeStr += gDigitsSep; modeStr += "v";
3842 modeStr += gDigitsSep; modeStr += QString::number(isV);
3844 param = vtkParam + "Entities";
3845 ip->setParameter(entry, param, modeStr.toLatin1().data());
3847 // Colors (surface:edge:)
3848 vtkFloatingPointType r, g, b;
3850 aSmeshActor->GetSufaceColor(r, g, b);
3851 QString colorStr ("surface");
3852 colorStr += gDigitsSep; colorStr += QString::number(r);
3853 colorStr += gDigitsSep; colorStr += QString::number(g);
3854 colorStr += gDigitsSep; colorStr += QString::number(b);
3856 aSmeshActor->GetBackSufaceColor(r, g, b);
3857 colorStr += gDigitsSep; colorStr += "backsurface";
3858 colorStr += gDigitsSep; colorStr += QString::number(r);
3859 colorStr += gDigitsSep; colorStr += QString::number(g);
3860 colorStr += gDigitsSep; colorStr += QString::number(b);
3862 aSmeshActor->GetEdgeColor(r, g, b);
3863 colorStr += gDigitsSep; colorStr += "edge";
3864 colorStr += gDigitsSep; colorStr += QString::number(r);
3865 colorStr += gDigitsSep; colorStr += QString::number(g);
3866 colorStr += gDigitsSep; colorStr += QString::number(b);
3868 aSmeshActor->GetNodeColor(r, g, b);
3869 colorStr += gDigitsSep; colorStr += "node";
3870 colorStr += gDigitsSep; colorStr += QString::number(r);
3871 colorStr += gDigitsSep; colorStr += QString::number(g);
3872 colorStr += gDigitsSep; colorStr += QString::number(b);
3874 param = vtkParam + "Colors";
3875 ip->setParameter(entry, param, colorStr.toLatin1().data());
3877 // Sizes of lines and points
3878 QString sizeStr ("line");
3879 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
3880 sizeStr += gDigitsSep; sizeStr += "node";
3881 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
3882 sizeStr += gDigitsSep; sizeStr += "shrink";
3883 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
3885 param = vtkParam + "Sizes";
3886 ip->setParameter(entry, param, sizeStr.toLatin1().data());
3889 param = vtkParam + "Opacity";
3890 ip->setParameter(entry, param,
3891 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
3894 param = vtkParam + "ClippingPlane";
3895 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
3897 ip->setParameter(entry, param, "Off");
3898 for (int ipl = 0; ipl < nPlanes; ipl++) {
3899 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
3900 SMESH::Orientation anOrientation;
3902 vtkFloatingPointType anAngle[2];
3903 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
3904 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
3905 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
3906 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
3907 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
3909 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
3911 } // if (io->hasEntry())
3912 } // SMESH_Actor && hasIO
3914 } // while.. actors traversal
3918 } // if (SVTK view model)
3919 } // for (viewManagers)
3923 * \brief Restore visual parameters
3925 * This method is called after the study document is opened.
3926 * Restore visual parameters from AttributeParameter attribue(s)
3928 void SMESHGUI::restoreVisualParameters (int savePoint)
3930 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3931 if (!appStudy || !appStudy->studyDS())
3933 _PTR(Study) studyDS = appStudy->studyDS();
3935 // componentName is used for encoding of entries when storing them in IParameters
3936 std::string componentName = myComponentSMESH->ComponentDataType();
3937 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3938 //if (!aSComponent) return;
3941 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3942 componentName.c_str(),
3944 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3946 std::vector<std::string> entries = ip->getEntries();
3948 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3950 // entry is a normal entry - it should be "decoded" (setting base adress of component)
3951 QString entry (ip->decodeEntry(*entIt).c_str());
3953 // Check that the entry corresponds to a real object in the Study
3954 // as the object may be deleted or modified after the visual state is saved.
3955 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
3956 if (!so) continue; //Skip the not existent entry
3958 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3959 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3961 std::vector<std::string>::iterator namesIt = paramNames.begin();
3962 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3964 // actors are stored in a map after displaying of them for
3965 // quicker access in the future: map < viewID to actor >
3966 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
3968 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3970 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
3971 // '_' is used as separator and should not be used in viewer type or parameter names.
3972 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
3973 if (lst.size() != 3)
3976 QString viewerTypStr = lst[0];
3977 QString viewIndexStr = lst[1];
3978 QString paramNameStr = lst[2];
3981 int viewIndex = viewIndexStr.toUInt(&ok);
3982 if (!ok) // bad conversion of view index to integer
3986 if (viewerTypStr == SVTK_Viewer::Type())
3988 SMESH_Actor* aSmeshActor = 0;
3989 if (vtkActors.IsBound(viewIndex))
3990 aSmeshActor = vtkActors.Find(viewIndex);
3992 if (paramNameStr == "Visibility")
3994 if (!aSmeshActor && displayer())
3996 QList<SUIT_ViewManager*> lst;
3997 getApp()->viewManagers(viewerTypStr, lst);
3999 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4000 if (viewIndex >= 0 && viewIndex < lst.count()) {
4001 SUIT_ViewManager* vman = lst.at(viewIndex);
4002 SUIT_ViewModel* vmodel = vman->getViewModel();
4003 // SVTK view model can be casted to SALOME_View
4004 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4006 // store displayed actor in a temporary map for quicker
4007 // access later when restoring other parameters
4008 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4009 vtkRenderer* Renderer = vtkView->getRenderer();
4010 vtkActorCollection* theActors = Renderer->GetActors();
4011 theActors->InitTraversal();
4012 bool isFound = false;
4013 vtkActor *ac = theActors->GetNextActor();
4014 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4015 if (ac->IsA("SMESH_Actor")) {
4016 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4017 if (aGeomAc->hasIO()) {
4018 Handle(SALOME_InteractiveObject) io =
4019 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4020 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4022 vtkActors.Bind(viewIndex, aGeomAc);
4029 } // if (paramNameStr == "Visibility")
4032 // the rest properties "work" with SMESH_Actor
4035 QString val ((*valuesIt).c_str());
4038 if (paramNameStr == "Representation") {
4039 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4042 else if (paramNameStr == "IsShrunk") {
4044 if (!aSmeshActor->IsShrunk())
4045 aSmeshActor->SetShrink();
4048 if (aSmeshActor->IsShrunk())
4049 aSmeshActor->UnShrink();
4052 // Displayed entities
4053 else if (paramNameStr == "Entities") {
4054 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4055 if (mode.count() == 6) {
4056 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4057 MESSAGE("Invalid order of data in Entities, must be: "
4058 "e:0/1:f:0/1:v:0/1");
4061 unsigned int aMode = aSmeshActor->GetEntityMode();
4062 unsigned int aNewMode =
4063 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4064 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4065 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4066 if (aNewMode != aMode)
4067 aSmeshActor->SetEntityMode(aNewMode);
4072 else if (paramNameStr == "Colors") {
4073 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4074 if (colors.count() == 16) {
4075 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4076 colors[8] != "edge" || colors[12] != "node") {
4077 MESSAGE("Invalid order of data in Colors, must be: "
4078 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4081 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4082 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4083 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4084 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4088 // Sizes of lines and points
4089 else if (paramNameStr == "Sizes") {
4090 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4091 if (sizes.count() == 6) {
4092 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4093 MESSAGE("Invalid order of data in Sizes, must be: "
4094 "line:int:node:int:shrink:float");
4097 aSmeshActor->SetLineWidth(sizes[1].toInt());
4098 aSmeshActor->SetNodeSize(sizes[3].toInt());
4099 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4104 else if (paramNameStr == "Opacity") {
4105 aSmeshActor->SetOpacity(val.toFloat());
4108 else if (paramNameStr.startsWith("ClippingPlane")) {
4109 cout << "$$$ ClippingPlane 1" << endl;
4110 if (paramNameStr == "ClippingPlane1" || val == "Off")
4111 aSmeshActor->RemoveAllClippingPlanes();
4113 cout << "$$$ ClippingPlane 2" << endl;
4114 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4115 if (vals.count() == 4) { // format check: 4 values
4116 cout << "$$$ ClippingPlane 3" << endl;
4117 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4118 double aDistance = vals[1].toFloat();
4119 vtkFloatingPointType anAngle[2];
4120 anAngle[0] = vals[2].toFloat();
4121 anAngle[1] = vals[3].toFloat();
4123 QList<SUIT_ViewManager*> lst;
4124 getApp()->viewManagers(viewerTypStr, lst);
4125 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4126 if (viewIndex >= 0 && viewIndex < lst.count()) {
4127 SUIT_ViewManager* vman = lst.at(viewIndex);
4128 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4129 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4130 anOrientation, aDistance, anAngle);
4135 } // if (aSmeshActor)
4136 } // other parameters than Visibility
4138 } // for names/parameters iterator
4139 } // for entries iterator
4141 // update all VTK views
4142 QList<SUIT_ViewManager*> lst;
4143 getApp()->viewManagers(lst);
4144 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4145 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4146 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4147 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4148 vtkView->getRenderer()->ResetCameraClippingRange();